use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder in project openflowplugin by opendaylight.
the class OF10FlowRemovedMessageFactoryTest method testSerialize.
@Test
public void testSerialize() throws Exception {
FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
MatchV10Builder matchBuilder = new MatchV10Builder();
matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
matchBuilder.setNwSrcMask((short) 0);
matchBuilder.setNwDstMask((short) 0);
matchBuilder.setInPort(58);
matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff"));
matchBuilder.setDlVlan(18);
matchBuilder.setDlVlanPcp((short) 5);
matchBuilder.setDlType(42);
matchBuilder.setNwTos((short) 4);
matchBuilder.setNwProto((short) 7);
matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8"));
matchBuilder.setNwDst(new Ipv4Address("16.16.16.16"));
matchBuilder.setTpSrc(6653);
matchBuilder.setTpDst(6633);
builder.setMatchV10(matchBuilder.build());
byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x01, 0x01, 0x04, 0x01 };
builder.setCookie(new BigInteger(1, cookie));
builder.setPriority(1);
builder.setReason(FlowRemovedReason.forValue(1));
builder.setDurationSec(1L);
builder.setDurationNsec(1L);
builder.setIdleTimeout(12);
builder.setPacketCount(BigInteger.valueOf(1L));
builder.setByteCount(BigInteger.valueOf(2L));
FlowRemovedMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 88);
Assert.assertEquals("Wrong wildcards", 3678463, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong inPort", 58, serializedBuffer.readUnsignedShort());
byte[] dlSrc = new byte[6];
serializedBuffer.readBytes(dlSrc);
Assert.assertEquals("Wrong dlSrc", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
byte[] dlDst = new byte[6];
serializedBuffer.readBytes(dlDst);
Assert.assertEquals("Wrong dlDst", "FF:FF:FF:FF:FF:FF", ByteBufUtils.macAddressToString(dlDst));
Assert.assertEquals("Wrong dlVlan", 18, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong dlVlanPcp", 5, serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(1);
Assert.assertEquals("Wrong dlType", 42, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong nwTos", 4, serializedBuffer.readUnsignedByte());
Assert.assertEquals("Wrong nwProto", 7, serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(2);
Assert.assertEquals("Wrong nwSrc", 134744072, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong nwDst", 269488144, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong tpSrc", 6653, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong tpDst", 6633, serializedBuffer.readUnsignedShort());
byte[] cookieRead = new byte[8];
serializedBuffer.readBytes(cookieRead);
Assert.assertArrayEquals("Wrong cookie", cookie, cookieRead);
Assert.assertEquals("Wrong priority", 1, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong reason", 1, serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(1);
Assert.assertEquals("Wrong duration", 1L, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong duration nsec", 1L, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong idle timeout", 12, serializedBuffer.readUnsignedShort());
serializedBuffer.skipBytes(2);
Assert.assertEquals("Wrong packet count", 1L, serializedBuffer.readLong());
Assert.assertEquals("Wrong byte count", 2L, serializedBuffer.readLong());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactoryTest method createFlowStats.
private static List<FlowStats> createFlowStats() {
FlowStatsBuilder builder = new FlowStatsBuilder();
builder.setTableId((short) 1);
MatchV10Builder matchBuilder = new MatchV10Builder();
matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
matchBuilder.setNwSrcMask((short) 0);
matchBuilder.setNwDstMask((short) 0);
matchBuilder.setInPort(58);
matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff"));
matchBuilder.setDlVlan(18);
matchBuilder.setDlVlanPcp((short) 5);
matchBuilder.setDlType(42);
matchBuilder.setNwTos((short) 4);
matchBuilder.setNwProto((short) 7);
matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8"));
matchBuilder.setNwDst(new Ipv4Address("16.16.16.16"));
matchBuilder.setTpSrc(6653);
matchBuilder.setTpDst(6633);
builder.setMatchV10(matchBuilder.build());
builder.setDurationSec(1L);
builder.setDurationNsec(2L);
builder.setPriority(1);
builder.setIdleTimeout(1);
builder.setHardTimeout(1);
builder.setCookie(BigInteger.valueOf(1234L));
builder.setPacketCount(BigInteger.valueOf(1234L));
builder.setByteCount(BigInteger.valueOf(1234L));
final List<Action> actions = new ArrayList<>();
final ActionBuilder actionBuilder = new ActionBuilder();
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(42L));
outputBuilder.setMaxLength(50);
caseBuilder.setOutputAction(outputBuilder.build());
actionBuilder.setActionChoice(caseBuilder.build());
actions.add(actionBuilder.build());
builder.setAction(actions);
List<FlowStats> list = new ArrayList<>();
list.add(builder.build());
return list;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder 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.oxm.rev150225.match.v10.grouping.MatchV10Builder in project openflowplugin by opendaylight.
the class MatchUtilTest method createEmptyV10MatchTest.
@Test
public void createEmptyV10MatchTest() {
MatchV10Builder expectedV10Match = expectedV10Match();
MatchV10Builder emptyV10Match = MatchUtil.createEmptyV10Match();
assertEquals(expectedV10Match.build(), emptyV10Match.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder 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;
}
Aggregations