Search in sources :

Example 51 with Order

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;
}
Also used : ArrayList(java.util.ArrayList) ElementsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder) Elements(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements)

Example 52 with Order

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();
}
Also used : ArrayList(java.util.ArrayList) ElementsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder) Elements(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements) HelloInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder)

Example 53 with Order

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);
    }
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) PacketProcessingListener(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener)

Example 54 with Order

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;
}
Also used : ActionChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) PushPbbActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder) SetMplsTtlActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder) PopMplsActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder) SetNwTtlActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder) PopPbbActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder) SetNwDstActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder) GroupActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder) PushMplsActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder) PopVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) SetQueueActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder) SetNwSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder) ArrayList(java.util.ArrayList) ActionRelatedTableFeatureProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty)

Example 55 with Order

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);
    });
}
Also used : SetNwSrcActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder) SetNwSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) SetNwSrcActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder) ActionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey) Ipv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)25 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)19 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder)17 VisibleForTesting (com.google.common.annotations.VisibleForTesting)7 Test (org.junit.Test)6 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)5 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 Batch (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch)4 BatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.BatchBuilder)4 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 HashMap (java.util.HashMap)3 List (java.util.List)3 ExecutionException (java.util.concurrent.ExecutionException)3 Inject (javax.inject.Inject)3 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)3 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)3 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)3