use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder 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.oxm.rev150225.match.v10.grouping.MatchV10Builder 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.oxm.rev150225.match.v10.grouping.MatchV10Builder 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.oxm.rev150225.match.v10.grouping.MatchV10Builder 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder in project openflowplugin by opendaylight.
the class OF10StatsRequestInputFlowFactoryTest method createMultipartRequestBody.
private static MultipartRequestBody createMultipartRequestBody() {
final MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder();
final MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder();
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);
flowBuilder.setMatchV10(matchBuilder.build());
flowBuilder.setTableId((short) 1);
flowBuilder.setOutPort(42L);
caseBuilder.setMultipartRequestFlow(flowBuilder.build());
return caseBuilder.build();
}
Aggregations