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();
}
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());
}
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());
}
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());
}
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());
}
Aggregations