use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage in project openflowplugin by opendaylight.
the class PacketReceivedTranslator method getPacketInMatch.
@VisibleForTesting
org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match getPacketInMatch(final PacketInMessage input, final BigInteger datapathId) {
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(input.getVersion());
datapathIdConvertorData.setDatapathId(datapathId);
final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder> matchOptional = convertorExecutor.convert(input.getMatch(), datapathIdConvertorData);
final MatchBuilder matchBuilder = matchOptional.map(matchBuilder1 -> new MatchBuilder(matchBuilder1.build())).orElseGet(MatchBuilder::new);
final AugmentTuple<org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match> matchExtensionWrap = MatchExtensionHelper.processAllExtensions(input.getMatch().getMatchEntry(), OpenflowVersion.get(input.getVersion()), MatchPath.PACKET_RECEIVED_MATCH);
if (matchExtensionWrap != null) {
matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
}
return matchBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage in project openflowplugin by opendaylight.
the class PacketReceivedTranslatorTest method testTranslate.
@Test
public void testTranslate() throws Exception {
final KeyedInstanceIdentifier<Node, NodeKey> nodePath = KeyedInstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:10")));
final PacketReceivedTranslator packetReceivedTranslator = new PacketReceivedTranslator(convertorManager);
final PacketInMessage packetInMessage = createPacketInMessage(DATA.getBytes(), PORT_NO);
Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
final PacketReceived packetReceived = packetReceivedTranslator.translate(packetInMessage, deviceInfo, null);
Assert.assertArrayEquals(packetInMessage.getData(), packetReceived.getPayload());
Assert.assertEquals("org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.SendToController", packetReceived.getPacketInReason().getName());
Assert.assertEquals("openflow:10:" + PORT_NO, packetReceived.getIngress().getValue().firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue());
Assert.assertEquals(0L, packetReceived.getFlowCookie().getValue().longValue());
Assert.assertEquals(42L, packetReceived.getTableId().getValue().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage in project openflowplugin by opendaylight.
the class DeviceContextImpl method processPacketInMessage.
@Override
public void processPacketInMessage(final PacketInMessage packetInMessage) {
if (isMasterOfDevice()) {
final PacketReceived packetReceived = packetInTranslator.translate(packetInMessage, getDeviceInfo(), null);
handlePacketInMessage(packetReceived, packetInMessage.getImplementedInterface(), packetReceived.getMatch());
} else {
LOG.debug("Controller is not owner of the device {}, skipping packet_in message", deviceInfo.getLOGValue());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage in project openflowplugin by opendaylight.
the class DeviceContextImplTest method testProcessPacketInMessageFutureFailure.
@Test
public void testProcessPacketInMessageFutureFailure() {
final PacketInMessage mockedPacketInMessage = mock(PacketInMessage.class);
final NotificationPublishService mockedNotificationPublishService = mock(NotificationPublishService.class);
final ListenableFuture dummyFuture = Futures.immediateFailedFuture(new IllegalStateException());
when(mockedNotificationPublishService.offerNotification(any(PacketReceived.class))).thenReturn(dummyFuture);
deviceContext.setNotificationPublishService(mockedNotificationPublishService);
deviceContext.processPacketInMessage(mockedPacketInMessage);
verify(messageSpy).spyMessage(any(Class.class), eq(MessageSpy.StatisticsGroup.FROM_SWITCH_NOTIFICATION_REJECTED));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage in project openflowplugin by opendaylight.
the class OpenflowProtocolListenerFullImplTest method testOnPacketInMessage.
/**
* Test method for
* {@link OpenflowProtocolListenerFullImpl#onPacketInMessage(
* org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage)}.
*/
@Test
public void testOnPacketInMessage() {
PacketInMessage packetInMessage = new PacketInMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build();
ofProtocolListener.onPacketInMessage(packetInMessage);
Mockito.verify(deviceReplyProcessor).processPacketInMessage(Matchers.any(PacketInMessage.class));
}
Aggregations