Search in sources :

Example 1 with FlowRemovedMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage in project openflowplugin by opendaylight.

the class OpenflowProtocolListenerFullImplTest method testOnFlowRemovedMessage.

/**
 * Test method for
 * {@link OpenflowProtocolListenerFullImpl#onFlowRemovedMessage(
 * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage)}.
 */
@Test
public void testOnFlowRemovedMessage() {
    FlowRemovedMessage flowRemovedMessage = new FlowRemovedMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build();
    ofProtocolListener.onFlowRemovedMessage(flowRemovedMessage);
    Mockito.verify(deviceReplyProcessor).processFlowRemovedMessage(Matchers.any(FlowRemovedMessage.class));
}
Also used : FlowRemovedMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) Test(org.junit.Test)

Example 2 with FlowRemovedMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage in project openflowplugin by opendaylight.

the class ConnectionAdapterImplTest method testConsume.

/**
 * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with notifications.
 */
@Test
public void testConsume() {
    DataObject message = new EchoRequestMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message);
    message = new ErrorMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onErrorMessage((ErrorMessage) message);
    message = new ExperimenterMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onExperimenterMessage((ExperimenterMessage) message);
    message = new FlowRemovedMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onFlowRemovedMessage((FlowRemovedMessage) message);
    message = new HelloMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onHelloMessage((HelloMessage) message);
    message = new MultipartReplyMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onMultipartReplyMessage((MultipartReplyMessage) message);
    message = new PacketInMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onPacketInMessage((PacketInMessage) message);
    message = new PortStatusMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onPortStatusMessage((PortStatusMessage) message);
    message = new SwitchIdleEventBuilder().build();
    adapter.consume(message);
    verify(systemListener, times(1)).onSwitchIdleEvent((SwitchIdleEvent) message);
    message = new DisconnectEventBuilder().build();
    adapter.consume(message);
    verify(systemListener, times(1)).onDisconnectEvent((DisconnectEvent) message);
    message = new EchoRequestMessageBuilder().build();
    adapter.consume(message);
    verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message);
}
Also used : ErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder) DisconnectEventBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder) ExperimenterMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder) PacketInMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) SwitchIdleEventBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder) PortStatusMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) EchoRequestMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder) Test(org.junit.Test)

Example 3 with FlowRemovedMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage in project openflowplugin by opendaylight.

the class OF10FlowRemovedMessageFactory method deserialize.

@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public FlowRemovedMessage deserialize(ByteBuf rawMessage) {
    Objects.requireNonNull(registry);
    FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
    builder.setMatchV10(matchDeserializer.deserialize(rawMessage));
    byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(cookie);
    builder.setCookie(new BigInteger(1, cookie));
    builder.setPriority(rawMessage.readUnsignedShort());
    builder.setReason(FlowRemovedReason.forValue(rawMessage.readUnsignedByte()));
    rawMessage.skipBytes(PADDING_IN_FLOW_REMOVED_MESSAGE);
    builder.setDurationSec(rawMessage.readUnsignedInt());
    builder.setDurationNsec(rawMessage.readUnsignedInt());
    builder.setIdleTimeout(rawMessage.readUnsignedShort());
    rawMessage.skipBytes(PADDING_IN_FLOW_REMOVED_MESSAGE_2);
    byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(packetCount);
    builder.setPacketCount(new BigInteger(1, packetCount));
    byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    rawMessage.readBytes(byteCount);
    builder.setByteCount(new BigInteger(1, byteCount));
    return builder.build();
}
Also used : MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) BigInteger(java.math.BigInteger) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 4 with FlowRemovedMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage in project openflowplugin by opendaylight.

the class OF10FlowRemovedMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    MatchV10Builder matchBuilder = new MatchV10Builder();
    matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
    matchBuilder.setNwSrcMask((short) 0);
    matchBuilder.setNwDstMask((short) 0);
    matchBuilder.setInPort(58);
    matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
    matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff"));
    matchBuilder.setDlVlan(18);
    matchBuilder.setDlVlanPcp((short) 5);
    matchBuilder.setDlType(42);
    matchBuilder.setNwTos((short) 4);
    matchBuilder.setNwProto((short) 7);
    matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8"));
    matchBuilder.setNwDst(new Ipv4Address("16.16.16.16"));
    matchBuilder.setTpSrc(6653);
    matchBuilder.setTpDst(6633);
    builder.setMatchV10(matchBuilder.build());
    byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x01, 0x01, 0x04, 0x01 };
    builder.setCookie(new BigInteger(1, cookie));
    builder.setPriority(1);
    builder.setReason(FlowRemovedReason.forValue(1));
    builder.setDurationSec(1L);
    builder.setDurationNsec(1L);
    builder.setIdleTimeout(12);
    builder.setPacketCount(BigInteger.valueOf(1L));
    builder.setByteCount(BigInteger.valueOf(2L));
    FlowRemovedMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 88);
    Assert.assertEquals("Wrong wildcards", 3678463, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong inPort", 58, serializedBuffer.readUnsignedShort());
    byte[] dlSrc = new byte[6];
    serializedBuffer.readBytes(dlSrc);
    Assert.assertEquals("Wrong dlSrc", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
    byte[] dlDst = new byte[6];
    serializedBuffer.readBytes(dlDst);
    Assert.assertEquals("Wrong dlDst", "FF:FF:FF:FF:FF:FF", ByteBufUtils.macAddressToString(dlDst));
    Assert.assertEquals("Wrong dlVlan", 18, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong dlVlanPcp", 5, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(1);
    Assert.assertEquals("Wrong dlType", 42, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong nwTos", 4, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong nwProto", 7, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(2);
    Assert.assertEquals("Wrong nwSrc", 134744072, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong nwDst", 269488144, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong tpSrc", 6653, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong tpDst", 6633, serializedBuffer.readUnsignedShort());
    byte[] cookieRead = new byte[8];
    serializedBuffer.readBytes(cookieRead);
    Assert.assertArrayEquals("Wrong cookie", cookie, cookieRead);
    Assert.assertEquals("Wrong priority", 1, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong reason", 1, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(1);
    Assert.assertEquals("Wrong duration", 1L, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong duration nsec", 1L, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong idle timeout", 12, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(2);
    Assert.assertEquals("Wrong packet count", 1L, serializedBuffer.readLong());
    Assert.assertEquals("Wrong byte count", 2L, serializedBuffer.readLong());
}
Also used : FlowRemovedMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage) FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) BigInteger(java.math.BigInteger) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ByteBuf(io.netty.buffer.ByteBuf) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 5 with FlowRemovedMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage in project openflowplugin by opendaylight.

the class FlowRemovedTranslatorTest method testTranslate.

@Test
public void testTranslate() throws Exception {
    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved flowRemovedMessage = buildMessage(false);
    final FlowRemoved flowRemoved = translator.translate(flowRemovedMessage, deviceInfo, null);
    assertEquals(flowRemovedMessage.getCookie(), flowRemoved.getCookie().getValue());
    assertEquals(flowRemovedMessage.getPriority(), flowRemoved.getPriority());
    assertEquals((long) flowRemovedMessage.getTableId().getValue(), (long) flowRemoved.getTableId());
}
Also used : FlowRemoved(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 FlowRemovedMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder)6 FlowRemovedMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage)5 ByteBuf (io.netty.buffer.ByteBuf)4 BigInteger (java.math.BigInteger)3 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 MessageCodeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)2 FlowRemoved (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved)2 ArrayList (java.util.ArrayList)1 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)1 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)1 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)1 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)1 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)1 InPhyPortCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder)1 IpEcnCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder)1 InPhyPortBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder)1 IpEcnBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder)1