Search in sources :

Example 6 with OfInput

use of org.openkilda.floodlight.model.OfInput in project open-kilda by telstra.

the class PathVerificationPacketSignTest method testSignPacketMissedSign.

@Test
public void testSignPacketMissedSign() {
    replay(producerService);
    OFPacketOut noSignPacket = pvs.generateDiscoveryPacket(sw1, OFPort.of(1), false, null);
    IPacket noSignPacketData = new Ethernet().deserialize(noSignPacket.getData(), 0, noSignPacket.getData().length);
    context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, noSignPacketData);
    pvs.handlePacketIn(new OfInput(sw2, ofPacketIn, context));
    verify(producerService);
}
Also used : OfInput(org.openkilda.floodlight.model.OfInput) IPacket(net.floodlightcontroller.packet.IPacket) Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketOut(org.projectfloodlight.openflow.protocol.OFPacketOut) Test(org.junit.Test)

Example 7 with OfInput

use of org.openkilda.floodlight.model.OfInput in project open-kilda by telstra.

the class PingResponseCommandTest method foreignPackage.

@Test
public void foreignPackage() throws Exception {
    expect(pingService.unwrapData(eq(dpId), anyObject())).andReturn(null);
    OfInput input = createMock(OfInput.class);
    expect(input.packetInCookieMismatchAll(anyObject(), anyObject(), anyObject())).andReturn(false);
    expect(input.getPacketInPayload()).andReturn(new Ethernet());
    expect(input.getDpId()).andReturn(dpId);
    replayAll();
    PingResponseCommand command = makeCommand(input);
    expectSkip(command);
}
Also used : OfInput(org.openkilda.floodlight.model.OfInput) Ethernet(net.floodlightcontroller.packet.Ethernet) Test(org.junit.Test)

Example 8 with OfInput

use of org.openkilda.floodlight.model.OfInput in project open-kilda by telstra.

the class PingResponseCommandTest method success.

@Test
public void success() throws Exception {
    final PingService realPingService = new PingService();
    moduleContext.addService(PingService.class, realPingService);
    final ISwitchManager realSwitchManager = new SwitchManager();
    moduleContext.addService(ISwitchManager.class, realSwitchManager);
    InputService inputService = createMock(InputService.class);
    moduleContext.addService(InputService.class, inputService);
    inputService.addTranslator(eq(OFType.PACKET_IN), anyObject());
    replayAll();
    final DatapathId dpIdBeta = DatapathId.of(0x0000fffe000002L);
    final Ping ping = new Ping(new NetworkEndpoint(new SwitchId(dpIdBeta.getLong()), 8), new NetworkEndpoint(new SwitchId(dpId.getLong()), 9), new FlowTransitEncapsulation(2, FlowEncapsulationType.TRANSIT_VLAN), 3);
    final PingData payload = PingData.of(ping);
    moduleContext.addConfigParam(new PathVerificationService(), "hmac256-secret", "secret");
    realPingService.setup(moduleContext);
    byte[] signedPayload = realPingService.getSignature().sign(payload);
    byte[] wireData = realPingService.wrapData(ping, signedPayload).serialize();
    OFFactory ofFactory = new OFFactoryVer13();
    OFPacketIn message = ofFactory.buildPacketIn().setReason(OFPacketInReason.ACTION).setXid(1L).setCookie(PingService.OF_CATCH_RULE_COOKIE).setData(wireData).build();
    FloodlightContext metadata = new FloodlightContext();
    IPacket decodedEthernet = new Ethernet().deserialize(wireData, 0, wireData.length);
    Assert.assertTrue(decodedEthernet instanceof Ethernet);
    IFloodlightProviderService.bcStore.put(metadata, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, (Ethernet) decodedEthernet);
    OfInput input = new OfInput(iofSwitch, message, metadata);
    final PingResponseCommand command = makeCommand(input);
    command.call();
    final List<Message> replies = kafkaMessageCatcher.getValues();
    Assert.assertEquals(1, replies.size());
    InfoMessage response = (InfoMessage) replies.get(0);
    PingResponse pingResponse = (PingResponse) response.getData();
    Assert.assertNull(pingResponse.getError());
    Assert.assertNotNull(pingResponse.getMeters());
    Assert.assertEquals(payload.getPingId(), pingResponse.getPingId());
}
Also used : OfInput(org.openkilda.floodlight.model.OfInput) IPacket(net.floodlightcontroller.packet.IPacket) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) DatapathId(org.projectfloodlight.openflow.types.DatapathId) SwitchId(org.openkilda.model.SwitchId) PingResponse(org.openkilda.messaging.floodlight.response.PingResponse) SwitchManager(org.openkilda.floodlight.switchmanager.SwitchManager) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) PingData(org.openkilda.floodlight.model.PingData) InputService(org.openkilda.floodlight.service.of.InputService) PathVerificationService(org.openkilda.floodlight.pathverification.PathVerificationService) InfoMessage(org.openkilda.messaging.info.InfoMessage) PingService(org.openkilda.floodlight.service.ping.PingService) Ping(org.openkilda.messaging.model.Ping) Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Test(org.junit.Test)

Aggregations

OfInput (org.openkilda.floodlight.model.OfInput)8 Test (org.junit.Test)7 Ethernet (net.floodlightcontroller.packet.Ethernet)3 Message (org.openkilda.messaging.Message)3 FloodlightContext (net.floodlightcontroller.core.FloodlightContext)2 IPacket (net.floodlightcontroller.packet.IPacket)2 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)2 OFMessage (org.projectfloodlight.openflow.protocol.OFMessage)2 OFFactoryVer13 (org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13)2 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 IAnswer (org.easymock.IAnswer)1 PingData (org.openkilda.floodlight.model.PingData)1 PathVerificationService (org.openkilda.floodlight.pathverification.PathVerificationService)1 InputService (org.openkilda.floodlight.service.of.InputService)1 PingService (org.openkilda.floodlight.service.ping.PingService)1 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)1 SwitchManager (org.openkilda.floodlight.switchmanager.SwitchManager)1 NewCorrelationContextRequired (org.openkilda.floodlight.utils.NewCorrelationContextRequired)1 PingResponse (org.openkilda.messaging.floodlight.response.PingResponse)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1