use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber in project openflowplugin by opendaylight.
the class GroupModInputMessageFactoryTest method test.
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("00 02 03 00 00 00 01 00 00 10 00 0a 00 " + "00 00 41 00 00 00 16 00 00 00 00");
GroupModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(deserializedMessage);
// Test Message
Assert.assertEquals("Wrong command", GroupModCommand.forValue(2), deserializedMessage.getCommand());
Assert.assertEquals("Wrong type", GroupType.forValue(3), deserializedMessage.getType());
Assert.assertEquals("Wrong group id", new GroupId(256L), deserializedMessage.getGroupId());
BucketsList bucket = deserializedMessage.getBucketsList().get(0);
Assert.assertEquals("Wrong weight", 10, bucket.getWeight().intValue());
Assert.assertEquals("Wrong watch port", new PortNumber(65L), bucket.getWatchPort());
Assert.assertEquals("Wrong watch group", 22L, bucket.getWatchGroup().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber in project openflowplugin by opendaylight.
the class FlowModInputMessageFactoryTest method test.
@Test
public void test() throws Exception {
ByteBuf bb = BufferHelper.buildBuffer("ff 01 04 01 06 00 07 01 ff 05 00 00 09 30 00 30 41 02 00 0c 00 00 00 7e 00 " + "00 00 02 00 00 11 46 00 00 00 62 00 0b 00 00 00 01 00 11 80 00 02 04 00 00 00 2a 80 00 12 01 04 00 " + "00 00 00 00 00 00 00 01 00 08 2b 00 00 00 00 02 00 18 00 00 00 00 ff 01 04 01 06 00 07 01 ff 05 00 00 " + "09 30 00 30 00 04 00 18 00 00 00 00 00 00 00 10 00 00 00 2a 00 34 00 00 00 00 00 00");
FlowModInput deserializedMessage = BufferHelper.deserialize(flowFactory, bb);
BufferHelper.checkHeaderV13(deserializedMessage);
byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 };
Assert.assertEquals("Wrong cookie", new BigInteger(1, cookie), deserializedMessage.getCookie());
byte[] cookieMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 };
Assert.assertEquals("Wrong cookie mask", new BigInteger(1, cookieMask), deserializedMessage.getCookieMask());
Assert.assertEquals("Wrong table id", new TableId(65L), deserializedMessage.getTableId());
Assert.assertEquals("Wrong command", FlowModCommand.forValue(2), deserializedMessage.getCommand());
Assert.assertEquals("Wrong idle timeout", 12, deserializedMessage.getIdleTimeout().intValue());
Assert.assertEquals("Wrong hard timeout", 0, deserializedMessage.getHardTimeout().intValue());
Assert.assertEquals("Wrong priority", 126, deserializedMessage.getPriority().intValue());
Assert.assertEquals("Wrong buffer id ", 2L, deserializedMessage.getBufferId().longValue());
Assert.assertEquals("Wrong out port", new PortNumber(4422L), deserializedMessage.getOutPort());
Assert.assertEquals("Wrong out group", 98L, deserializedMessage.getOutGroup().longValue());
Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true), deserializedMessage.getFlags());
Assert.assertEquals("Wrong match", createMatch(), deserializedMessage.getMatch());
Assert.assertEquals("Wrong instructions", createInstructions(), deserializedMessage.getInstruction());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber in project openflowplugin by opendaylight.
the class FlowModInputMessageFactoryTest method createMatch.
private Match createMatch() {
MatchBuilder matchBuilder = new MatchBuilder();
matchBuilder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(InPhyPort.class);
entriesBuilder.setHasMask(false);
InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
inPhyPortBuilder.setPortNumber(new PortNumber(42L));
inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(IpEcn.class);
entriesBuilder.setHasMask(false);
IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
ipEcnBuilder.setEcn((short) 4);
ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
entries.add(entriesBuilder.build());
matchBuilder.setMatchEntry(entries);
return matchBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber in project openflowplugin by opendaylight.
the class MatchConvertor method inPhyPortMatch.
private static void inPhyPortMatch(final List<MatchEntry> matchEntryList, NodeConnectorId inPhyPort) {
if (inPhyPort == null) {
return;
}
// TODO: currently this matchconverter is mapped to OF1.3 in MatchInjector. Will need to revisit during 1.4+
final long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.OF13, inPhyPort);
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setHasMask(false);
matchEntryBuilder.setOxmMatchField(InPhyPort.class);
InPhyPortCaseBuilder caseBuilder = new InPhyPortCaseBuilder();
InPhyPortBuilder portBuilder = new InPhyPortBuilder();
portBuilder.setPortNumber(new PortNumber(portNumber));
caseBuilder.setInPhyPort(portBuilder.build());
matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
matchEntryList.add(matchEntryBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber in project openflowplugin by opendaylight.
the class MatchConvertor method inPortMatch.
private static void inPortMatch(final List<MatchEntry> matchEntryList, NodeConnectorId inPort) {
if (inPort == null) {
return;
}
// TODO: currently this matchconverter is mapped to OF1.3 in MatchInjector. Will need to revisit during 1.4+
final long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.OF13, inPort);
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setHasMask(false);
matchEntryBuilder.setOxmMatchField(InPort.class);
InPortCaseBuilder caseBuilder = new InPortCaseBuilder();
InPortBuilder portBuilder = new InPortBuilder();
portBuilder.setPortNumber(new PortNumber(portNumber));
caseBuilder.setInPort(portBuilder.build());
matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
matchEntryList.add(matchEntryBuilder.build());
}
Aggregations