use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.
the class OF10StatsRequestAggregateTest method test.
/**
* Tests {@link OF10StatsRequestInputFactory} for correct serialization.
*/
@Test
public void test() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setType(MultipartType.OFPMPAGGREGATE);
builder.setFlags(new MultipartRequestFlags(false));
final MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder();
final MultipartRequestAggregateBuilder aggBuilder = new MultipartRequestAggregateBuilder();
MatchV10Builder matchBuilder = new MatchV10Builder();
matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
matchBuilder.setNwSrcMask((short) 8);
matchBuilder.setNwDstMask((short) 16);
matchBuilder.setInPort(51);
matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05"));
matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00"));
matchBuilder.setDlVlan(52);
matchBuilder.setDlVlanPcp((short) 53);
matchBuilder.setDlType(54);
matchBuilder.setNwTos((short) 55);
matchBuilder.setNwProto((short) 56);
matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1"));
matchBuilder.setNwDst(new Ipv4Address("10.0.0.2"));
matchBuilder.setTpSrc(57);
matchBuilder.setTpDst(58);
aggBuilder.setMatchV10(matchBuilder.build());
aggBuilder.setTableId((short) 5);
aggBuilder.setOutPort(42L);
caseBuilder.setMultipartRequestAggregate(aggBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
statsFactory.serialize(message, out);
BufferHelper.checkHeaderV10(out, (byte) 16, 56);
Assert.assertEquals("Wrong type", 2, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
// skip match check
out.skipBytes(40);
Assert.assertEquals("Wrong table-id", 5, out.readUnsignedByte());
out.skipBytes(1);
Assert.assertEquals("Wrong out port", 42, out.readUnsignedShort());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactoryTest method testTable.
/**
* Testing OF10StatsReplyMessageFactory (Table) for correct deserialization.
*/
@Test
public void testTable() {
ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 " + "08 00 00 00 4A 41 4D 45 53 20 42 4F 4E 44 00 00 00 00 00 00 00 00 00 " + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + "00 00 00 30 00 00 00 10 FF 01 01 01 01 01 01 01 FF 01 01 01 01 01 01 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody();
MultipartReplyTable message = messageCase.getMultipartReplyTable();
Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue());
Assert.assertEquals("Wrong name", "JAMES BOND", message.getTableStats().get(0).getName());
Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, false, false, false, false, false, false, false, false), message.getTableStats().get(0).getWildcards());
Assert.assertEquals("Wrong src-mask", 32, message.getTableStats().get(0).getNwSrcMask().intValue());
Assert.assertEquals("Wrong dst-mask", 32, message.getTableStats().get(0).getNwDstMask().intValue());
Assert.assertEquals("Wrong max-entries", 48, message.getTableStats().get(0).getMaxEntries().longValue());
Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());
Assert.assertEquals("Wrong lookupCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getTableStats().get(0).getLookupCount());
Assert.assertEquals("Wrong matchedCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 }), message.getTableStats().get(0).getMatchedCount());
Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.
the class MatchUtilTest method expectedV10Match.
private MatchV10Builder expectedV10Match() {
Short zeroShort = Short.valueOf("0");
Integer zeroInteger = 0;
MatchV10Builder matchV10Builder = new MatchV10Builder();
matchV10Builder.setDlDst(ZERO_MAC_ADDRESS);
matchV10Builder.setDlSrc(ZERO_MAC_ADDRESS);
matchV10Builder.setDlType(zeroInteger);
matchV10Builder.setDlVlan(zeroInteger);
matchV10Builder.setDlVlanPcp(zeroShort);
matchV10Builder.setInPort(zeroInteger);
matchV10Builder.setNwDst(ZERO_IPV4_ADDRESS);
matchV10Builder.setNwDstMask(zeroShort);
matchV10Builder.setNwProto(zeroShort);
matchV10Builder.setNwSrc(ZERO_IPV4_ADDRESS);
matchV10Builder.setNwSrcMask(zeroShort);
matchV10Builder.setNwTos(zeroShort);
matchV10Builder.setTpDst(zeroInteger);
matchV10Builder.setTpSrc(zeroInteger);
FlowWildcardsV10 flowWildcardsV10 = new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true);
matchV10Builder.setWildcards(flowWildcardsV10);
return matchV10Builder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.
the class MatchResponseConvertorTest method checkDefaultV10.
private static void checkDefaultV10(final Match match, final FlowWildcardsV10 wc, final int vid) {
EthernetMatch ethMatch = match.getEthernetMatch();
if (wc.isDLSRC()) {
if (ethMatch != null) {
assertEquals(null, ethMatch.getEthernetSource());
}
} else {
assertEquals(MAC_SRC, ethMatch.getEthernetSource().getAddress());
}
if (ethMatch != null) {
if (wc.isDLDST()) {
assertEquals(null, ethMatch.getEthernetDestination());
} else {
assertNotEquals(null, ethMatch.getEthernetDestination());
assertEquals(MAC_DST, ethMatch.getEthernetDestination().getAddress());
}
}
if (wc.isDLTYPE()) {
if (ethMatch != null) {
assertEquals(null, ethMatch.getEthernetType());
}
assertEquals(null, match.getLayer3Match());
} else {
assert ethMatch != null;
assertEquals(ETHTYPE_IPV4, ethMatch.getEthernetType().getType().getValue().intValue());
Ipv4Match ipv4Match = (Ipv4Match) match.getLayer3Match();
assertEquals(IPV4_SRC.getValue() + "/32", ipv4Match.getIpv4Source().getValue());
assertEquals(IPV4_DST.getValue() + "/32", ipv4Match.getIpv4Destination().getValue());
}
VlanMatch vlanMatch = match.getVlanMatch();
if (wc.isDLVLAN()) {
assertEquals(null, vlanMatch);
} else {
int expectedVid;
Boolean expectedCfi;
if (vid == DL_VLAN_NONE) {
expectedVid = 0;
expectedCfi = Boolean.FALSE;
} else {
expectedVid = vid;
expectedCfi = Boolean.TRUE;
}
assertEquals(expectedVid, vlanMatch.getVlanId().getVlanId().getValue().intValue());
assertEquals(expectedCfi, vlanMatch.getVlanId().isVlanIdPresent());
if (wc.isDLVLANPCP()) {
assertEquals(null, vlanMatch.getVlanPcp());
} else {
assertEquals(VLAN_PCP, vlanMatch.getVlanPcp().getValue().shortValue());
}
}
}
Aggregations