Search in sources :

Example 11 with MatchV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 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 12 with MatchV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.

the class OF10MatchDeserializerTest method test2.

/**
 * Testing correct deserialization of ofp_match.
 */
@Test
public void test2() {
    ByteBuf message = BufferHelper.buildBuffer("00 3F FF FF 00 20 AA BB CC DD EE FF " + "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 " + "50 50 20 20");
    // skip XID
    message.skipBytes(4);
    MatchV10 match = matchDeserializer.deserialize(message);
    Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true), match.getWildcards());
    Assert.assertEquals("Wrong srcMask", 0, match.getNwSrcMask().shortValue());
    Assert.assertEquals("Wrong dstMask", 0, match.getNwDstMask().shortValue());
    Assert.assertEquals("Wrong in-port", 32, match.getInPort().intValue());
    Assert.assertEquals("Wrong dl-src", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlSrc());
    Assert.assertEquals("Wrong dl-dst", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlDst());
    Assert.assertEquals("Wrong dl-vlan", 5, match.getDlVlan().intValue());
    Assert.assertEquals("Wrong dl-vlan-pcp", 16, match.getDlVlanPcp().shortValue());
    Assert.assertEquals("Wrong dl-type", 8, match.getDlType().intValue());
    Assert.assertEquals("Wrong nw-tos", 7, match.getNwTos().shortValue());
    Assert.assertEquals("Wrong nw-proto", 6, match.getNwProto().shortValue());
    Assert.assertEquals("Wrong nw-src", new Ipv4Address("16.17.18.19"), match.getNwSrc());
    Assert.assertEquals("Wrong nw-dst", new Ipv4Address("1.2.3.4"), match.getNwDst());
    Assert.assertEquals("Wrong tp-src", 20560, match.getTpSrc().shortValue());
    Assert.assertEquals("Wrong tp-dst", 8224, match.getTpDst().shortValue());
}
Also used : FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) ByteBuf(io.netty.buffer.ByteBuf) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 13 with MatchV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.

the class OF10MatchDeserializerTest method test.

/**
 * Testing correct deserialization of ofp_match.
 */
@Test
public void test() {
    ByteBuf message = BufferHelper.buildBuffer("00 24 08 91 00 20 AA BB CC DD EE FF " + "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 " + "50 50 20 20");
    // skip XID
    message.skipBytes(4);
    MatchV10 match = matchDeserializer.deserialize(message);
    Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, true, false, false, true, false, true, true, false), match.getWildcards());
    Assert.assertEquals("Wrong srcMask", 24, match.getNwSrcMask().shortValue());
    Assert.assertEquals("Wrong dstMask", 16, match.getNwDstMask().shortValue());
    Assert.assertEquals("Wrong in-port", 32, match.getInPort().intValue());
    Assert.assertEquals("Wrong dl-src", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlSrc());
    Assert.assertEquals("Wrong dl-dst", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlDst());
    Assert.assertEquals("Wrong dl-vlan", 5, match.getDlVlan().intValue());
    Assert.assertEquals("Wrong dl-vlan-pcp", 16, match.getDlVlanPcp().shortValue());
    Assert.assertEquals("Wrong dl-type", 8, match.getDlType().intValue());
    Assert.assertEquals("Wrong nw-tos", 7, match.getNwTos().shortValue());
    Assert.assertEquals("Wrong nw-proto", 6, match.getNwProto().shortValue());
    Assert.assertEquals("Wrong nw-src", new Ipv4Address("16.17.18.19"), match.getNwSrc());
    Assert.assertEquals("Wrong nw-dst", new Ipv4Address("1.2.3.4"), match.getNwDst());
    Assert.assertEquals("Wrong tp-src", 20560, match.getTpSrc().shortValue());
    Assert.assertEquals("Wrong tp-dst", 8224, match.getTpDst().shortValue());
}
Also used : FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) ByteBuf(io.netty.buffer.ByteBuf) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 14 with MatchV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.

the class MatchConvertorV10Test method testConvert.

@Test
public void testConvert() {
    Optional<MatchV10> matchV10Optional = converterManager.convert(createL4UdpMatch().build(), new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
    MatchV10 matchV10 = matchV10Optional.get();
    assertEquals(ZERO_MAC, matchV10.getDlDst());
    assertEquals(FF_MAC, matchV10.getDlSrc());
    assertEquals(0, matchV10.getDlType().intValue());
    assertEquals(0xffff, matchV10.getDlVlan().intValue());
    assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpSrc().intValue());
    assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpDst().intValue());
    assertEquals(Integer.parseInt(NODE_CONNECTOR_ID), matchV10.getInPort().intValue());
    assertEquals(DEFAULT_IPV4_ADDRESS.getValue(), matchV10.getNwDst().getValue());
    assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue());
    assertEquals(0, matchV10.getNwTos().shortValue());
    assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpSrc().intValue());
    assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpDst().intValue());
    matchV10Optional = converterManager.convert(createL4TcpMatch().build(), new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
    matchV10 = matchV10Optional.get();
    assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpSrc().intValue());
    assertEquals(DEFAULT_PORT.getValue().intValue(), matchV10.getTpDst().intValue());
    matchV10Optional = converterManager.convert(createVlanTcpMatch().build(), new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
    matchV10 = matchV10Optional.get();
    assertEquals(DEFAULT_VLAN_ID.getValue().intValue(), matchV10.getDlVlan().intValue());
}
Also used : VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) Test(org.junit.Test)

Example 15 with MatchV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.

the class MatchConvertorV10Test method testConvertIcmpv4.

@Test
public void testConvertIcmpv4() {
    MatchBuilder matchBuilder = createMatchBuilderWithDefaults();
    Match match = matchBuilder.build();
    Optional<MatchV10> matchV10Optional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
    MatchV10 matchV10 = matchV10Optional.get();
    final Integer zero = 0;
    assertEquals(ZERO_MAC, matchV10.getDlDst());
    assertEquals(FF_MAC, matchV10.getDlSrc());
    assertEquals(0, matchV10.getDlType().intValue());
    assertEquals(0xffff, matchV10.getDlVlan().intValue());
    assertEquals(Integer.parseInt(NODE_CONNECTOR_ID), matchV10.getInPort().intValue());
    assertEquals(DEFAULT_IPV4_ADDRESS.getValue(), matchV10.getNwDst().getValue());
    assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue());
    assertEquals(0, matchV10.getNwTos().shortValue());
    assertEquals(zero, matchV10.getTpSrc());
    assertEquals(zero, matchV10.getTpDst());
    boolean wcTpSrc = true;
    boolean wcTpDst = true;
    FlowWildcardsV10 wc = new FlowWildcardsV10(false, false, false, true, true, false, false, false, wcTpDst, wcTpSrc);
    assertEquals(wc, matchV10.getWildcards());
    // Specify ICMP type only.
    Integer icmpType = 55;
    Icmpv4MatchBuilder icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type(icmpType.shortValue());
    wcTpSrc = false;
    wc = new FlowWildcardsV10(false, false, false, true, true, false, false, false, wcTpDst, wcTpSrc);
    match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).build();
    matchV10Optional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
    matchV10 = matchV10Optional.get();
    assertEquals(ZERO_MAC, matchV10.getDlDst());
    assertEquals(FF_MAC, matchV10.getDlSrc());
    assertEquals(0, matchV10.getDlType().intValue());
    assertEquals(0xffff, matchV10.getDlVlan().intValue());
    assertEquals(Integer.parseInt(NODE_CONNECTOR_ID), matchV10.getInPort().intValue());
    assertEquals(DEFAULT_IPV4_ADDRESS.getValue(), matchV10.getNwDst().getValue());
    assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue());
    assertEquals(0, matchV10.getNwTos().shortValue());
    assertEquals(icmpType, matchV10.getTpSrc());
    assertEquals(zero, matchV10.getTpDst());
    assertEquals(wc, matchV10.getWildcards());
    // Specify ICMP code only.
    Integer icmpCode = 31;
    icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type(null).setIcmpv4Code(icmpCode.shortValue());
    wcTpSrc = true;
    wcTpDst = false;
    wc = new FlowWildcardsV10(false, false, false, true, true, false, false, false, wcTpDst, wcTpSrc);
    match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).build();
    matchV10Optional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
    matchV10 = matchV10Optional.get();
    assertEquals(ZERO_MAC, matchV10.getDlDst());
    assertEquals(FF_MAC, matchV10.getDlSrc());
    assertEquals(0, matchV10.getDlType().intValue());
    assertEquals(0xffff, matchV10.getDlVlan().intValue());
    assertEquals(Integer.parseInt(NODE_CONNECTOR_ID), matchV10.getInPort().intValue());
    assertEquals(DEFAULT_IPV4_ADDRESS.getValue(), matchV10.getNwDst().getValue());
    assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue());
    assertEquals(0, matchV10.getNwTos().shortValue());
    assertEquals(zero, matchV10.getTpSrc());
    assertEquals(icmpCode, matchV10.getTpDst());
    assertEquals(wc, matchV10.getWildcards());
    // Specify both ICMP type and code.
    icmpType = 11;
    icmpCode = 22;
    icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type(icmpType.shortValue()).setIcmpv4Code(icmpCode.shortValue());
    wcTpSrc = false;
    wcTpDst = false;
    wc = new FlowWildcardsV10(false, false, false, true, true, false, false, false, wcTpDst, wcTpSrc);
    match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).build();
    matchV10Optional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
    matchV10 = matchV10Optional.get();
    assertEquals(ZERO_MAC, matchV10.getDlDst());
    assertEquals(FF_MAC, matchV10.getDlSrc());
    assertEquals(0, matchV10.getDlType().intValue());
    assertEquals(0xffff, matchV10.getDlVlan().intValue());
    assertEquals(Integer.parseInt(NODE_CONNECTOR_ID), matchV10.getInPort().intValue());
    assertEquals(DEFAULT_IPV4_ADDRESS.getValue(), matchV10.getNwDst().getValue());
    assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue());
    assertEquals(0, matchV10.getNwTos().shortValue());
    assertEquals(icmpType, matchV10.getTpSrc());
    assertEquals(icmpCode, matchV10.getTpDst());
    assertEquals(wc, matchV10.getWildcards());
}
Also used : VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) Icmpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) TcpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder) Icmpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder) VlanMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) UdpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) Test(org.junit.Test)

Aggregations

MatchV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10)27 Test (org.junit.Test)16 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)16 MatchV10Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)15 BigInteger (java.math.BigInteger)12 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match)10 EthernetMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch)10 IpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch)10 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)10 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)9 Icmpv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match)9 TcpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch)9 UdpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch)9 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8 MessageCodeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)7 ByteBuf (io.netty.buffer.ByteBuf)5 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 CodeKeyMaker (org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker)2 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)2