use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.
the class MatchResponseConvertorTest method testFromOFMatchV10ToSALMatch.
/**
* Test method for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testFromOFMatchV10ToSALMatch() {
int[] vids = { // Match untagged frame.
DL_VLAN_NONE, // Match packet with VLAN tag and VID equals the specified value.
1, 20, 4095 };
short[] dscps = { 0, 1, 20, 40, 62, 63 };
FlowWildcardsV10Builder wcBuilder = new FlowWildcardsV10Builder();
for (int vid : vids) {
for (short dscp : dscps) {
short tos = (short) (dscp << 2);
MatchV10Builder builder = new MatchV10Builder();
builder.setDlSrc(MAC_SRC).setDlDst(MAC_DST).setDlVlan(vid).setDlVlanPcp(VLAN_PCP).setDlType(ETHTYPE_IPV4).setInPort(IN_PORT.intValue()).setNwSrc(IPV4_SRC).setNwDst(IPV4_DST).setNwTos(tos);
wcBuilder.setAll(false).setNwProto(true).setTpSrc(true).setTpDst(true);
if (vid == DL_VLAN_NONE) {
wcBuilder.setDlVlanPcp(true);
}
FlowWildcardsV10 wc = wcBuilder.build();
MatchV10 ofMatch = builder.setWildcards(wc).build();
final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
data.setDatapathId(DPID);
Match match = convert(ofMatch, data).build();
checkDefaultV10(match, wc, vid);
IpMatch ipMatch = match.getIpMatch();
assertEquals(null, ipMatch.getIpProtocol());
assertEquals(dscp, ipMatch.getIpDscp().getValue().shortValue());
assertEquals(null, ipMatch.getIpEcn());
// Set all wildcard bits.
wc = wcBuilder.setAll(true).build();
ofMatch = builder.setWildcards(wc).build();
match = convert(ofMatch, data).build();
checkDefaultV10(match, wc, vid);
assertEquals(null, match.getIpMatch());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactoryTest method createTableStats.
private static List<TableStats> createTableStats() {
TableStatsBuilder builder = new TableStatsBuilder();
builder.setTableId((short) 1);
builder.setName("Table name");
builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
builder.setMaxEntries(1L);
builder.setActiveCount(1L);
builder.setLookupCount(BigInteger.valueOf(1234L));
builder.setMatchedCount(BigInteger.valueOf(1234L));
List<TableStats> list = new ArrayList<>();
list.add(builder.build());
return list;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.
the class OF10MatchSerializerTest method test.
/**
* Testing correct serialization of ofp_match.
*/
@Test
public void test() {
final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
MatchV10Builder builder = new MatchV10Builder();
builder.setWildcards(new FlowWildcardsV10(false, false, true, false, false, true, false, true, true, true));
builder.setNwSrcMask((short) 24);
builder.setNwDstMask((short) 16);
builder.setInPort(6653);
builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
builder.setDlVlan(128);
builder.setDlVlanPcp((short) 2);
builder.setDlType(15);
builder.setNwTos((short) 14);
builder.setNwProto((short) 85);
builder.setNwSrc(new Ipv4Address("1.1.1.2"));
builder.setNwDst(new Ipv4Address("32.16.8.1"));
builder.setTpSrc(2048);
builder.setTpDst(4096);
MatchV10 match = builder.build();
matchSerializer.serialize(match, out);
Assert.assertEquals("Wrong wildcards", 2361553, out.readUnsignedInt());
Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
byte[] dlSrc = new byte[6];
out.readBytes(dlSrc);
Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
byte[] dlDst = new byte[6];
out.readBytes(dlDst);
Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst));
Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort());
Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte());
out.skipBytes(1);
Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort());
Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte());
Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte());
out.skipBytes(2);
Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt());
Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt());
Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());
Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.
the class OF10MatchSerializerTest method test2.
/**
* Testing correct serialization of ofp_match.
*/
@Test
public void test2() {
final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
MatchV10Builder builder = new MatchV10Builder();
builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
builder.setNwSrcMask((short) 0);
builder.setNwDstMask((short) 0);
builder.setInPort(6653);
builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
builder.setDlVlan(128);
builder.setDlVlanPcp((short) 2);
builder.setDlType(15);
builder.setNwTos((short) 14);
builder.setNwProto((short) 85);
builder.setNwSrc(new Ipv4Address("1.1.1.2"));
builder.setNwDst(new Ipv4Address("32.16.8.1"));
builder.setTpSrc(2048);
builder.setTpDst(4096);
MatchV10 match = builder.build();
matchSerializer.serialize(match, out);
Assert.assertEquals("Wrong wildcards", 3678463, out.readUnsignedInt());
Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
byte[] dlSrc = new byte[6];
out.readBytes(dlSrc);
Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
byte[] dlDst = new byte[6];
out.readBytes(dlDst);
Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst));
Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort());
Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte());
out.skipBytes(1);
Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort());
Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte());
Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte());
out.skipBytes(2);
Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt());
Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt());
Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());
Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.
the class MatchUtil method createEmptyV10Match.
public static MatchV10Builder createEmptyV10Match() {
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;
}
Aggregations