use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder in project openflowplugin by opendaylight.
the class ConntrackConvertor method getCtAction.
private List<CtActions> getCtAction(final NxActionConntrack action) {
if (action.getCtActions() == null) {
return null;
}
List<CtActions> ctActions = new ArrayList<>();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions ctAction : action.getCtActions()) {
org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.OfpactActions ofpactAction = ctAction.getOfpactActions();
if (ofpactAction instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCase) {
org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNat nxActionNat = ((org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCase) ofpactAction).getNxActionNat();
NxActionNatBuilder nxActionNatBuilder = new NxActionNatBuilder();
nxActionNatBuilder.setFlags(nxActionNat.getFlags());
nxActionNatBuilder.setRangePresent(nxActionNat.getRangePresent());
nxActionNatBuilder.setIpAddressMin(nxActionNat.getIpAddressMin());
nxActionNatBuilder.setIpAddressMax(nxActionNat.getIpAddressMax());
nxActionNatBuilder.setPortMin(nxActionNat.getPortMin());
nxActionNatBuilder.setPortMax(nxActionNat.getPortMax());
NxActionNatCaseBuilder caseBuilder = new NxActionNatCaseBuilder();
caseBuilder.setNxActionNat(nxActionNatBuilder.build());
CtActionsBuilder ctActionsBuilder = new CtActionsBuilder();
ctActionsBuilder.setOfpactActions(caseBuilder.build());
ctActions.add(ctActionsBuilder.build());
} else if (ofpactAction instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCase) {
org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMark nxActionCtMark = ((org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCase) ofpactAction).getNxActionCtMark();
NxActionCtMarkBuilder nxActionCtMarkBuilder = new NxActionCtMarkBuilder();
nxActionCtMarkBuilder.setCtMark(nxActionCtMark.getCtMark());
// TODO: ct_mark mask is not supported yet
NxActionCtMarkCaseBuilder caseBuilder = new NxActionCtMarkCaseBuilder();
caseBuilder.setNxActionCtMark(nxActionCtMarkBuilder.build());
CtActionsBuilder ctActionsBuilder = new CtActionsBuilder();
ctActionsBuilder.setOfpactActions(caseBuilder.build());
ctActions.add(ctActionsBuilder.build());
}
}
return ctActions;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder in project openflowplugin by opendaylight.
the class ConntrackConvertor method getCtAction.
private List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions> getCtAction(final NxConntrack action) {
if (action.getCtActions() == null) {
return null;
}
List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActions> ctActions = new ArrayList<>();
for (CtActions ctAction : action.getCtActions()) {
OfpactActions ofpactAction = ctAction.getOfpactActions();
if (ofpactAction instanceof NxActionNatCase) {
NxActionNat nxActionNat = ((NxActionNatCase) ofpactAction).getNxActionNat();
org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder nxActionNatBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.nat._case.NxActionNatBuilder();
nxActionNatBuilder.setFlags(nxActionNat.getFlags());
nxActionNatBuilder.setRangePresent(nxActionNat.getRangePresent());
nxActionNatBuilder.setIpAddressMin(nxActionNat.getIpAddressMin());
nxActionNatBuilder.setIpAddressMax(nxActionNat.getIpAddressMax());
nxActionNatBuilder.setPortMin(nxActionNat.getPortMin());
nxActionNatBuilder.setPortMax(nxActionNat.getPortMax());
org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder caseBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionNatCaseBuilder();
caseBuilder.setNxActionNat(nxActionNatBuilder.build());
org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder ctActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder();
ctActionsBuilder.setOfpactActions(caseBuilder.build());
ctActions.add(ctActionsBuilder.build());
} else if (ofpactAction instanceof NxActionCtMarkCase) {
NxActionCtMark nxActionCtMark = ((NxActionCtMarkCase) ofpactAction).getNxActionCtMark();
org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder nxActionCtMarkBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.nx.action.ct.mark._case.NxActionCtMarkBuilder();
nxActionCtMarkBuilder.setCtMark(nxActionCtMark.getCtMark());
// TODO: ct_mark mask is not supported yet
org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder caseBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofpact.actions.ofpact.actions.NxActionCtMarkCaseBuilder();
caseBuilder.setNxActionCtMark(nxActionCtMarkBuilder.build());
org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder ctActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.conntrack.grouping.nx.action.conntrack.CtActionsBuilder();
ctActionsBuilder.setOfpactActions(caseBuilder.build());
ctActions.add(ctActionsBuilder.build());
}
}
return ctActions;
}
Aggregations