use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst in project openflowplugin by opendaylight.
the class RegMoveConvertorTest method setUp.
@Before
public void setUp() throws Exception {
final Src src = Mockito.mock(Src.class);
final Dst dst = Mockito.mock(Dst.class);
when(actionsCase.getNxRegMove()).thenReturn(nxRegMove);
when(nxRegMove.getSrc()).thenReturn(src);
when(nxRegMove.getDst()).thenReturn(dst);
when(nxRegMove.getSrc().getStart()).thenReturn(1);
when(nxRegMove.getSrc().getEnd()).thenReturn(2);
when(nxRegMove.getDst().getStart()).thenReturn(3);
when(nxRegMove.getDst().getEnd()).thenReturn(4);
when(nxRegMove.getDst().getDstChoice()).thenReturn(Mockito.mock(DstNxTunIdCase.class));
when(nxRegMove.getSrc().getSrcChoice()).thenReturn(Mockito.mock(SrcNxTunIdCase.class));
final ActionRegMove actionRegMove = Mockito.mock(ActionRegMove.class);
final NxActionRegMove nxActionRegMove = Mockito.mock(NxActionRegMove.class);
when(nxActionRegMove.getSrc()).thenReturn(NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong());
when(nxActionRegMove.getDst()).thenReturn(NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong());
when(nxActionRegMove.getNBits()).thenReturn(7);
when(actionRegMove.getNxActionRegMove()).thenReturn(nxActionRegMove);
when(action.getActionChoice()).thenReturn(actionRegMove);
regMoveConvertor = new RegMoveConvertor();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst 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.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst 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.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst in project openflowplugin by opendaylight.
the class OF10StatsRequestInputFactoryTest method testFlow.
/**
* Testing OF10StatsRequestInputFactory (Flow) for correct serialization.
*/
@Test
public void testFlow() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setType(MultipartType.OFPMPFLOW);
builder.setFlags(new MultipartRequestFlags(false));
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());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV10(out, (byte) 16, 56);
Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong wildcards", 3414271, out.readUnsignedInt());
Assert.assertEquals("Wrong in-port", 51, out.readUnsignedShort());
byte[] dlSrc = new byte[6];
out.readBytes(dlSrc);
Assert.assertEquals("Wrong dl-src", "00:01:02:03:04:05", ByteBufUtils.macAddressToString(dlSrc));
byte[] dlDst = new byte[6];
out.readBytes(dlDst);
Assert.assertEquals("Wrong dl-dst", "05:04:03:02:01:00", ByteBufUtils.macAddressToString(dlDst));
Assert.assertEquals("Wrong dl-vlan", 52, out.readUnsignedShort());
Assert.assertEquals("Wrong dl-vlan-pcp", 53, out.readUnsignedByte());
out.skipBytes(1);
Assert.assertEquals("Wrong dl-type", 54, out.readUnsignedShort());
Assert.assertEquals("Wrong nw-tos", 55, out.readUnsignedByte());
Assert.assertEquals("Wrong nw-proto", 56, out.readUnsignedByte());
out.skipBytes(2);
Assert.assertEquals("Wrong nw-src", 167772161, out.readUnsignedInt());
Assert.assertEquals("Wrong nw-dst", 167772162, out.readUnsignedInt());
Assert.assertEquals("Wrong tp-src", 57, out.readUnsignedShort());
Assert.assertEquals("Wrong tp-dst", 58, out.readUnsignedShort());
Assert.assertEquals("Wrong table-id", 1, out.readUnsignedByte());
out.skipBytes(1);
Assert.assertEquals("Wrong out-port", 42, out.readUnsignedShort());
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst in project openflowplugin by opendaylight.
the class OF10StatsRequestInputFactoryTest method testAggregate.
/**
* Testing OF10StatsRequestInputFactory (Aggregate) for correct serialization.
*/
@Test
public void testAggregate() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setType(MultipartType.OFPMPAGGREGATE);
builder.setFlags(new MultipartRequestFlags(false));
final MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder();
final MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder();
MatchV10Builder matchBuilder = new MatchV10Builder();
matchBuilder.setWildcards(new FlowWildcardsV10(false, false, false, false, false, false, false, false, false, false));
matchBuilder.setNwSrcMask((short) 32);
matchBuilder.setNwDstMask((short) 32);
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) 42);
flowBuilder.setOutPort(6653L);
caseBuilder.setMultipartRequestFlow(flowBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV10(out, (byte) 16, 56);
Assert.assertEquals("Wrong type", 2, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong wildcards", 0, out.readUnsignedInt());
Assert.assertEquals("Wrong in-port", 51, out.readUnsignedShort());
byte[] dlSrc = new byte[6];
out.readBytes(dlSrc);
Assert.assertEquals("Wrong dl-src", "00:01:02:03:04:05", ByteBufUtils.macAddressToString(dlSrc));
byte[] dlDst = new byte[6];
out.readBytes(dlDst);
Assert.assertEquals("Wrong dl-dst", "05:04:03:02:01:00", ByteBufUtils.macAddressToString(dlDst));
Assert.assertEquals("Wrong dl-vlan", 52, out.readUnsignedShort());
Assert.assertEquals("Wrong dl-vlan-pcp", 53, out.readUnsignedByte());
out.skipBytes(1);
Assert.assertEquals("Wrong dl-type", 54, out.readUnsignedShort());
Assert.assertEquals("Wrong nw-tos", 55, out.readUnsignedByte());
Assert.assertEquals("Wrong nw-proto", 56, out.readUnsignedByte());
out.skipBytes(2);
Assert.assertEquals("Wrong nw-src", 167772161, out.readUnsignedInt());
Assert.assertEquals("Wrong nw-dst", 167772162, out.readUnsignedInt());
Assert.assertEquals("Wrong tp-src", 57, out.readUnsignedShort());
Assert.assertEquals("Wrong tp-dst", 58, out.readUnsignedShort());
Assert.assertEquals("Wrong table-id", 42, out.readUnsignedByte());
out.skipBytes(1);
Assert.assertEquals("Wrong out-port", 6653, out.readUnsignedShort());
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
Aggregations