use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order in project openflowplugin by opendaylight.
the class HandshakeManagerImplTest method addVersionBitmap.
/**
* Adds version bitmap.
* @param versionOrder version order
* @param helloBuilder hello builder
* @return builder
*/
private static HelloMessageBuilder addVersionBitmap(List<Short> versionOrder, HelloMessageBuilder helloBuilder) {
short highestVersion = versionOrder.get(0);
int elementsCount = highestVersion / Integer.SIZE;
ElementsBuilder elementsBuilder = new ElementsBuilder();
List<Elements> elementList = new ArrayList<>();
int orderIndex = versionOrder.size();
int value = versionOrder.get(--orderIndex);
for (int index = 0; index <= elementsCount; index++) {
List<Boolean> booleanList = new ArrayList<>();
for (int i = 0; i < Integer.SIZE; i++) {
if (value == index * Integer.SIZE + i) {
booleanList.add(true);
value = orderIndex == 0 ? highestVersion : versionOrder.get(--orderIndex);
} else {
booleanList.add(false);
}
}
elementsBuilder.setType(HelloElementType.forValue(1));
elementsBuilder.setVersionBitmap(booleanList);
elementList.add(elementsBuilder.build());
}
helloBuilder.setElements(elementList);
return helloBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order in project openflowplugin by opendaylight.
the class MessageFactory method createHelloInput.
/**
* Creates hello input.
*
* @param helloVersion openflow version for hello message to send to switch
* @param helloXid transaction id for hello message
* @param versionOrder list of openflow version in order
* @return HelloInput with elements (version bitmap)
*/
public static HelloInput createHelloInput(short helloVersion, long helloXid, List<Short> versionOrder) {
HelloInputBuilder helloInputbuilder = prepareHelloInputBuilder(helloVersion, helloXid);
if (versionOrder != null) {
ElementsBuilder elementsBuilder = new ElementsBuilder();
elementsBuilder.setType(HelloElementType.VERSIONBITMAP);
int resultVersionListSize = 0;
if (!versionOrder.isEmpty()) {
resultVersionListSize = versionOrder.get(0) + 1;
}
List<Boolean> booleanList = new ArrayList<>(resultVersionListSize);
int versionOrderIndex = versionOrder.size() - 1;
while (versionOrderIndex >= 0) {
short version = versionOrder.get(versionOrderIndex);
if (version == booleanList.size()) {
booleanList.add(true);
versionOrderIndex--;
} else {
booleanList.add(false);
}
}
elementsBuilder.setVersionBitmap(booleanList);
List<Elements> elementList = Collections.singletonList(elementsBuilder.build());
helloInputbuilder.setElements(elementList);
}
return helloInputbuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order in project openflowplugin by opendaylight.
the class PacketInDispatcherImpl method onPacketReceived.
@Override
public void onPacketReceived(PacketReceived notification) {
// find corresponding handler
/*
* Notification contains reference to ingress port
* in a form of path in inventory: /nodes/node/node-connector
*
* In order to get path we shorten path to the first node reference
* by using firstIdentifierOf helper method provided by InstanceIdentifier,
* this will effectively shorten the path to /nodes/node.
*/
InstanceIdentifier<?> ingressPort = notification.getIngress().getValue();
InstanceIdentifier<Node> nodeOfPacket = ingressPort.firstIdentifierOf(Node.class);
/**
* We lookup up the the packet-in listener for this node.
*/
PacketProcessingListener nodeHandler = handlerMapping.get(nodeOfPacket);
/**
* If we have packet-processing listener, we delegate notification.
*/
if (nodeHandler != null) {
nodeHandler.onPacketReceived(notification);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order in project openflowplugin by opendaylight.
the class TableFeaturesResponseConvertor method setActionTableFeatureProperty.
private static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> setActionTableFeatureProperty(final TableFeatureProperties properties) {
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList = new ArrayList<>();
int order = 0;
for (Action action : properties.getAugmentation(ActionRelatedTableFeatureProperty.class).getAction()) {
if (action != null && null != action.getActionChoice()) {
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
actionBuilder.setOrder(order++);
ActionChoice actionType = action.getActionChoice();
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action salAction = OF_TO_SAL_ACTION.get(actionType.getImplementedInterface());
actionBuilder.setAction(salAction);
actionList.add(actionBuilder.build());
}
}
return actionList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order in project openflowplugin by opendaylight.
the class ApplyActionsInstructionSerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final int order = 0;
final Ipv4Prefix prefix = new Ipv4Prefix("192.168.76.0/32");
final Instruction instruction = new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(Collections.singletonList(new ActionBuilder().setOrder(order).setKey(new ActionKey(order)).setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(new SetNwSrcActionBuilder().setAddress(new Ipv4Builder().setIpv4Address(prefix).build()).build()).build()).build())).build()).build();
assertInstruction(instruction, out -> {
out.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
assertEquals(out.readUnsignedShort(), ActionConstants.SET_FIELD_CODE);
// Skip length of set field action
out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
assertEquals(out.readUnsignedShort(), OxmMatchConstants.OPENFLOW_BASIC_CLASS);
assertEquals(out.readUnsignedByte(), OxmMatchConstants.IPV4_SRC << 1);
// Skip match entry length
out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
byte[] addressBytes = new byte[4];
out.readBytes(addressBytes);
assertArrayEquals(addressBytes, new byte[] { (byte) 192, (byte) 168, 76, 0 });
// Padding at end
out.skipBytes(4);
});
}
Aggregations