Search in sources :

Example 1 with NxActionConntrackBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder in project openflowplugin by opendaylight.

the class ConntrackCodecTest method createActionWithoutCtAction.

private Action createActionWithoutCtAction() {
    NxActionConntrackBuilder nxActionConntrackBuilder = new NxActionConntrackBuilder();
    nxActionConntrackBuilder.setFlags(1);
    nxActionConntrackBuilder.setZoneSrc((long) 2);
    nxActionConntrackBuilder.setConntrackZone(3);
    nxActionConntrackBuilder.setRecircTable((short) 4);
    ExperimenterId experimenterId = new ExperimenterId(NiciraConstants.NX_VENDOR_ID);
    ActionBuilder actionBuilder = new ActionBuilder();
    actionBuilder.setExperimenterId(experimenterId);
    ActionConntrackBuilder actionConntrackBuilder = new ActionConntrackBuilder();
    actionConntrackBuilder.setNxActionConntrack(nxActionConntrackBuilder.build());
    actionBuilder.setActionChoice(actionConntrackBuilder.build());
    return actionBuilder.build();
}
Also used : NxActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) NxActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder) ActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionConntrackBuilder) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)

Example 2 with NxActionConntrackBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder in project openflowplugin by opendaylight.

the class ConntrackCodec method deserialize.

@Override
public Action deserialize(final ByteBuf message) {
    final short length = deserializeCtHeader(message);
    NxActionConntrackBuilder nxActionConntrackBuilder = new NxActionConntrackBuilder();
    nxActionConntrackBuilder.setFlags(message.readUnsignedShort());
    nxActionConntrackBuilder.setZoneSrc(message.readUnsignedInt());
    nxActionConntrackBuilder.setConntrackZone(message.readUnsignedShort());
    nxActionConntrackBuilder.setRecircTable(message.readUnsignedByte());
    message.skipBytes(5);
    if (length > CT_LENGTH) {
        deserializeCtAction(message, nxActionConntrackBuilder, length - CT_LENGTH);
    }
    ActionBuilder actionBuilder = new ActionBuilder();
    actionBuilder.setExperimenterId(getExperimenterId());
    ActionConntrackBuilder actionConntrackBuilder = new ActionConntrackBuilder();
    actionConntrackBuilder.setNxActionConntrack(nxActionConntrackBuilder.build());
    actionBuilder.setActionChoice(actionConntrackBuilder.build());
    return actionBuilder.build();
}
Also used : NxActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) NxActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder) ActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionConntrackBuilder)

Example 3 with NxActionConntrackBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder in project openflowplugin by opendaylight.

the class ConntrackCodecTest method createAction.

private Action createAction() {
    NxActionConntrackBuilder nxActionConntrackBuilder = new NxActionConntrackBuilder();
    nxActionConntrackBuilder.setFlags(1);
    nxActionConntrackBuilder.setZoneSrc((long) 2);
    nxActionConntrackBuilder.setConntrackZone(3);
    nxActionConntrackBuilder.setRecircTable((short) 4);
    NxActionNatBuilder nxActionNatBuilder = new NxActionNatBuilder();
    nxActionNatBuilder.setFlags(5);
    nxActionNatBuilder.setRangePresent(0x3F);
    nxActionNatBuilder.setIpAddressMin(new IpAddress("192.168.0.0".toCharArray()));
    nxActionNatBuilder.setIpAddressMax(new IpAddress("192.168.10.0".toCharArray()));
    nxActionNatBuilder.setPortMin(3000);
    nxActionNatBuilder.setPortMax(4000);
    NxActionNatCaseBuilder nxActionNatCaseBuilder = new NxActionNatCaseBuilder();
    nxActionNatCaseBuilder.setNxActionNat(nxActionNatBuilder.build());
    CtActionsBuilder ctActionsBuilder = new CtActionsBuilder();
    ctActionsBuilder.setOfpactActions(nxActionNatCaseBuilder.build());
    List<CtActions> ctActionsList = new ArrayList<>();
    ctActionsList.add(ctActionsBuilder.build());
    nxActionNatBuilder = new NxActionNatBuilder();
    nxActionNatBuilder.setFlags(5);
    nxActionNatBuilder.setRangePresent(0x21);
    nxActionNatBuilder.setIpAddressMin(new IpAddress("192.168.0.0".toCharArray()));
    nxActionNatBuilder.setPortMax(4000);
    nxActionNatCaseBuilder = new NxActionNatCaseBuilder();
    nxActionNatCaseBuilder.setNxActionNat(nxActionNatBuilder.build());
    ctActionsBuilder = new CtActionsBuilder();
    ctActionsBuilder.setOfpactActions(nxActionNatCaseBuilder.build());
    ctActionsList.add(ctActionsBuilder.build());
    nxActionConntrackBuilder.setCtActions(ctActionsList);
    NxActionCtMarkBuilder nxActionCtMarkBuilder = new NxActionCtMarkBuilder();
    nxActionCtMarkBuilder.setCtMark((long) 36);
    NxActionCtMarkCaseBuilder nxActionCtMarkCaseBuilder = new NxActionCtMarkCaseBuilder();
    nxActionCtMarkCaseBuilder.setNxActionCtMark(nxActionCtMarkBuilder.build());
    ctActionsBuilder = new CtActionsBuilder();
    ctActionsBuilder.setOfpactActions(nxActionCtMarkCaseBuilder.build());
    ctActionsList.add(ctActionsBuilder.build());
    nxActionConntrackBuilder.setCtActions(ctActionsList);
    ExperimenterId experimenterId = new ExperimenterId(NiciraConstants.NX_VENDOR_ID);
    ActionBuilder actionBuilder = new ActionBuilder();
    actionBuilder.setExperimenterId(experimenterId);
    ActionConntrackBuilder actionConntrackBuilder = new ActionConntrackBuilder();
    actionConntrackBuilder.setNxActionConntrack(nxActionConntrackBuilder.build());
    actionBuilder.setActionChoice(actionConntrackBuilder.build());
    return actionBuilder.build();
}
Also used : NxActionCtMarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) NxActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder) ActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionConntrackBuilder) CtActions(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions) NxActionCtMarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder) NxActionNatBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder) ArrayList(java.util.ArrayList) CtActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) NxActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder) NxActionNatCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 4 with NxActionConntrackBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder in project openflowplugin by opendaylight.

the class ConntrackCodec method deserializeCtAction.

private void deserializeCtAction(final ByteBuf message, final NxActionConntrackBuilder nxActionConntrackBuilder, final int ctActionsLength) {
    List<CtActions> ctActionsList = new ArrayList<>();
    int processedCtActionsLength = ctActionsLength;
    while (processedCtActionsLength > 0) {
        int startReaderIndex = message.readerIndex();
        if (EncodeConstants.EXPERIMENTER_VALUE == message.readUnsignedShort()) {
            // NAT action
            // reset indices
            message.setIndex(startReaderIndex, message.writerIndex());
            final int startIndex = message.readerIndex();
            int length = deserializeCtHeader(message);
            processedCtActionsLength = processedCtActionsLength - length;
            NxActionNatBuilder nxActionNatBuilder = new NxActionNatBuilder();
            message.skipBytes(2);
            nxActionNatBuilder.setFlags(message.readUnsignedShort());
            int rangePresent = message.readUnsignedShort();
            nxActionNatBuilder.setRangePresent(rangePresent);
            if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEIPV4MIN.getIntValue())) {
                InetAddress address = InetAddresses.fromInteger((int) message.readUnsignedInt());
                nxActionNatBuilder.setIpAddressMin(new IpAddress(address.getHostAddress().toCharArray()));
            }
            if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEIPV4MAX.getIntValue())) {
                InetAddress address = InetAddresses.fromInteger((int) message.readUnsignedInt());
                nxActionNatBuilder.setIpAddressMax(new IpAddress(address.getHostAddress().toCharArray()));
            }
            if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEPROTOMIN.getIntValue())) {
                nxActionNatBuilder.setPortMin(message.readUnsignedShort());
            }
            if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEPROTOMAX.getIntValue())) {
                nxActionNatBuilder.setPortMax(message.readUnsignedShort());
            }
            NxActionNatCaseBuilder caseBuilder = new NxActionNatCaseBuilder();
            caseBuilder.setNxActionNat(nxActionNatBuilder.build());
            CtActionsBuilder ctActionsBuilder = new CtActionsBuilder();
            ctActionsBuilder.setOfpactActions(caseBuilder.build());
            ctActionsList.add(ctActionsBuilder.build());
            int pad = length - (message.readerIndex() - startIndex);
            message.skipBytes(pad);
        } else {
            // only other possible action here is currently ct_mark
            // reset indices
            message.setIndex(startReaderIndex, message.writerIndex());
            processedCtActionsLength = processedCtActionsLength - SET_FIELD_LENGTH;
            deserializeCtHeaderWithoutSubtype(message);
            NxActionCtMarkBuilder nxActionCtMarkBuilder = new NxActionCtMarkBuilder();
            nxActionCtMarkBuilder.setCtMark(message.readUnsignedInt());
            NxActionCtMarkCaseBuilder caseBuilder = new NxActionCtMarkCaseBuilder();
            caseBuilder.setNxActionCtMark(nxActionCtMarkBuilder.build());
            CtActionsBuilder ctActionsBuilder = new CtActionsBuilder();
            ctActionsBuilder.setOfpactActions(caseBuilder.build());
            ctActionsList.add(ctActionsBuilder.build());
            // padding
            message.skipBytes(EncodeConstants.SIZE_OF_INT_IN_BYTES);
        }
    }
    nxActionConntrackBuilder.setCtActions(ctActionsList);
}
Also used : NxActionCtMarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder) CtActions(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions) NxActionCtMarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder) ArrayList(java.util.ArrayList) NxActionNatBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder) NxActionNatCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) CtActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder) InetAddress(java.net.InetAddress)

Example 5 with NxActionConntrackBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder in project openflowplugin by opendaylight.

the class ConntrackConvertor method convert.

@Override
public Action convert(final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxActionArg) {
    Preconditions.checkArgument(nxActionArg instanceof NxActionConntrackGrouping);
    NxActionConntrackGrouping nxAction = (NxActionConntrackGrouping) nxActionArg;
    NxActionConntrackBuilder nxActionConntrackBuilder = new NxActionConntrackBuilder();
    nxActionConntrackBuilder.setFlags(nxAction.getNxConntrack().getFlags());
    nxActionConntrackBuilder.setZoneSrc(nxAction.getNxConntrack().getZoneSrc());
    nxActionConntrackBuilder.setRecircTable(nxAction.getNxConntrack().getRecircTable());
    nxActionConntrackBuilder.setConntrackZone(nxAction.getNxConntrack().getConntrackZone());
    nxActionConntrackBuilder.setCtActions(getCtAction(nxAction.getNxConntrack()));
    ActionConntrackBuilder actionConntrackBuilder = new ActionConntrackBuilder();
    actionConntrackBuilder.setNxActionConntrack(nxActionConntrackBuilder.build());
    return ActionUtil.createAction(actionConntrackBuilder.build());
}
Also used : NxActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder) NxActionConntrackGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.NxActionConntrackGrouping) NxActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder) ActionConntrackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionConntrackBuilder)

Aggregations

ActionConntrackBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionConntrackBuilder)5 NxActionConntrackBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.NxActionConntrackBuilder)5 ArrayList (java.util.ArrayList)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)4 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)4 Test (org.junit.Test)2 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)2 CtActions (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions)2 CtActionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder)2 NxActionCtMarkCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder)2 NxActionNatCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder)2 NxActionCtMarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder)2 NxActionNatBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder)2 NxActionConntrackNodesNodeTableFlowWriteActionsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionConntrackNodesNodeTableFlowWriteActionsCase)2 CtActions (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.conntrack.grouping.nx.conntrack.CtActions)2 NxActionNatCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.NxActionNatCase)2 NxActionNat (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNat)2 NxActionNatBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder)2 InetAddress (java.net.InetAddress)1 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)1