use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId in project openflowplugin by opendaylight.
the class QueueDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final QueueIdAndStatisticsMap queueStats = new QueueIdAndStatisticsMapBuilder().setQueueId(new QueueId(QUEUE_NO)).setNodeConnectorId(new NodeConnectorId(PORT_NO.toString())).setTransmittedBytes(new Counter64(BigInteger.ONE)).setTransmissionErrors(new Counter64(BigInteger.ONE)).setTransmittedBytes(new Counter64(BigInteger.ONE)).build();
final MultipartReply reply = new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyQueueStatsBuilder().setQueueIdAndStatisticsMap(Collections.singletonList(queueStats)).build()).build();
final List<MultipartReply> input = Collections.singletonList(reply);
final GetQueueStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getQueueIdAndStatisticsMap().size() > 0);
final QueueIdAndStatisticsMap map = output.getQueueIdAndStatisticsMap().get(0);
assertEquals(map.getQueueId().getValue(), QUEUE_NO);
assertEquals(map.getNodeConnectorId().getValue(), PORT_NO.toString());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId in project openflowplugin by opendaylight.
the class QueueGetConfigReplyMessageFactory method createQueuesList.
private List<Queues> createQueuesList(ByteBuf input) {
List<Queues> queuesList = new ArrayList<>();
while (input.readableBytes() > 0) {
QueuesBuilder queueBuilder = new QueuesBuilder();
queueBuilder.setQueueId(new QueueId(input.readUnsignedInt()));
queueBuilder.setPort(new PortNumber(input.readUnsignedInt()));
int length = input.readUnsignedShort();
input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER);
queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_LENGTH));
queuesList.add(queueBuilder.build());
}
return queuesList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId in project openflowplugin by opendaylight.
the class QueueGetConfigReplyMessageFactoryTest method createQueuesList.
private static List<Queues> createQueuesList() {
List<Queues> queuesList = new ArrayList<>();
for (int i = 1; i < 3; i++) {
QueuesBuilder qb = new QueuesBuilder();
qb.setQueueId(new QueueId((long) i));
qb.setPort(new PortNumber((long) i));
qb.setQueueProperty(createPropertiesList());
queuesList.add(qb.build());
}
return queuesList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactoryTest method testQueue.
/**
* Testing OF10StatsReplyMessageFactory (Queue) for correct deserialization.
*/
@Test
public void testQueue() {
ByteBuf bb = BufferHelper.buildBuffer("00 05 00 00 " + "00 FF 00 00 00 00 00 10 " + "FF 02 03 02 03 02 03 02 " + "FF 02 02 02 02 02 02 02 " + "FF 02 03 02 03 02 03 02");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyQueueCase messageCase = (MultipartReplyQueueCase) builtByFactory.getMultipartReplyBody();
MultipartReplyQueue message = messageCase.getMultipartReplyQueue();
Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue());
Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue());
Assert.assertEquals("Wrong txBytes", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getQueueStats().get(0).getTxBytes());
Assert.assertEquals("Wrong txPackets", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getQueueStats().get(0).getTxPackets());
Assert.assertEquals("Wrong txErrors", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getQueueStats().get(0).getTxErrors());
Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId in project openflowplugin by opendaylight.
the class OF10ActionsSerializerTest method test.
/**
* Testing correct serialization of actions (OF v1.0).
*/
@Test
public void test() {
final List<Action> actions = new ArrayList<>();
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(42L));
outputBuilder.setMaxLength(32);
caseBuilder.setOutputAction(outputBuilder.build());
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(caseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetVlanVidCaseBuilder vlanVidCaseBuilder = new SetVlanVidCaseBuilder();
SetVlanVidActionBuilder vlanVidBuilder = new SetVlanVidActionBuilder();
vlanVidBuilder.setVlanVid(15);
vlanVidCaseBuilder.setSetVlanVidAction(vlanVidBuilder.build());
actionBuilder.setActionChoice(vlanVidCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetVlanPcpCaseBuilder vlanPcpCaseBuilder = new SetVlanPcpCaseBuilder();
SetVlanPcpActionBuilder vlanPcpBuilder = new SetVlanPcpActionBuilder();
vlanPcpBuilder.setVlanPcp((short) 16);
vlanPcpCaseBuilder.setSetVlanPcpAction(vlanPcpBuilder.build());
actionBuilder.setActionChoice(vlanPcpCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new StripVlanCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetDlSrcCaseBuilder dlSrcCaseBuilder = new SetDlSrcCaseBuilder();
SetDlSrcActionBuilder dlSrcBuilder = new SetDlSrcActionBuilder();
dlSrcBuilder.setDlSrcAddress(new MacAddress("00:00:00:02:03:04"));
dlSrcCaseBuilder.setSetDlSrcAction(dlSrcBuilder.build());
actionBuilder.setActionChoice(dlSrcCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetDlDstCaseBuilder dlDstCaseBuilder = new SetDlDstCaseBuilder();
SetDlDstActionBuilder dlDstBuilder = new SetDlDstActionBuilder();
dlDstBuilder.setDlDstAddress(new MacAddress("00:00:00:01:02:03"));
dlDstCaseBuilder.setSetDlDstAction(dlDstBuilder.build());
actionBuilder.setActionChoice(dlDstCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwSrcCaseBuilder nwSrcCaseBuilder = new SetNwSrcCaseBuilder();
SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();
nwSrcBuilder.setIpAddress(new Ipv4Address("10.0.0.1"));
nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());
actionBuilder.setActionChoice(nwSrcCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwDstCaseBuilder nwDstCaseBuilder = new SetNwDstCaseBuilder();
SetNwDstActionBuilder nwDstBuilder = new SetNwDstActionBuilder();
nwDstBuilder.setIpAddress(new Ipv4Address("10.0.0.3"));
nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build());
actionBuilder.setActionChoice(nwDstCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwTosCaseBuilder tosCaseBuilder = new SetNwTosCaseBuilder();
SetNwTosActionBuilder tosBuilder = new SetNwTosActionBuilder();
tosBuilder.setNwTos((short) 204);
tosCaseBuilder.setSetNwTosAction(tosBuilder.build());
actionBuilder.setActionChoice(tosCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetTpSrcCaseBuilder tpSrcCaseBuilder = new SetTpSrcCaseBuilder();
SetTpSrcActionBuilder tpSrcBuilder = new SetTpSrcActionBuilder();
tpSrcBuilder.setPort(new PortNumber(6653L));
tpSrcCaseBuilder.setSetTpSrcAction(tpSrcBuilder.build());
actionBuilder.setActionChoice(tpSrcCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetTpDstCaseBuilder tpDstCaseBuilder = new SetTpDstCaseBuilder();
SetTpDstActionBuilder tpDstBuilder = new SetTpDstActionBuilder();
tpDstBuilder.setPort(new PortNumber(6633L));
tpDstCaseBuilder.setSetTpDstAction(tpDstBuilder.build());
actionBuilder.setActionChoice(tpDstCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
EnqueueCaseBuilder enqueueCaseBuilder = new EnqueueCaseBuilder();
EnqueueActionBuilder enqueueBuilder = new EnqueueActionBuilder();
enqueueBuilder.setPort(new PortNumber(6613L));
enqueueBuilder.setQueueId(new QueueId(400L));
enqueueCaseBuilder.setEnqueueAction(enqueueBuilder.build());
actionBuilder.setActionChoice(enqueueCaseBuilder.build());
actions.add(actionBuilder.build());
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
ListSerializer.serializeList(actions, TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, out);
Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong port", 42, out.readUnsignedShort());
Assert.assertEquals("Wrong max-length", 32, out.readUnsignedShort());
Assert.assertEquals("Wrong action type", 1, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong vlan-vid", 15, out.readUnsignedShort());
out.skipBytes(2);
Assert.assertEquals("Wrong action type", 2, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong vlan-pcp", 16, out.readUnsignedByte());
out.skipBytes(3);
Assert.assertEquals("Wrong action type", 3, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong action type", 4, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
byte[] data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
out.readBytes(data);
Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:02:03:04"), data);
out.skipBytes(6);
Assert.assertEquals("Wrong action type", 5, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
out.readBytes(data);
Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:01:02:03"), data);
out.skipBytes(6);
Assert.assertEquals("Wrong action type", 6, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte());
Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte());
Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte());
Assert.assertEquals("Wrong ip-address(4)", 1, out.readUnsignedByte());
Assert.assertEquals("Wrong action type", 7, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte());
Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte());
Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte());
Assert.assertEquals("Wrong ip-address(4)", 3, out.readUnsignedByte());
Assert.assertEquals("Wrong action type", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong nw-tos", 204, out.readUnsignedByte());
out.skipBytes(3);
Assert.assertEquals("Wrong action type", 9, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong port", 6653, out.readUnsignedShort());
out.skipBytes(2);
Assert.assertEquals("Wrong action type", 10, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong port", 6633, out.readUnsignedShort());
out.skipBytes(2);
Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
Assert.assertEquals("Wrong port", 6613, out.readUnsignedShort());
out.skipBytes(6);
Assert.assertEquals("Wrong queue-id", 400, out.readUnsignedInt());
Assert.assertTrue("Written more bytes than needed", out.readableBytes() == 0);
}
Aggregations