ExperimenterActionSerializerKey has a new parameter which is type of vendor's action.
It allows to select right serializer directly in OFJava so a vendor does not need to care about it.
- created codec for Nicira match nxm_of_eth_type
Change-Id: Id9bc0f06820cab7b897eb710a70ddc3d6af13a45
Signed-off-by: Martin Sunal <msunal@cisco.com>
import java.util.List;
-import org.opendaylight.openflowjava.nx.codec.action.ActionCodec;
+import org.opendaylight.openflowjava.nx.codec.action.ActionDeserializer;
+import org.opendaylight.openflowjava.nx.codec.action.NiciraActionCodecs;
+import org.opendaylight.openflowjava.nx.codec.action.RegLoadCodec;
+import org.opendaylight.openflowjava.nx.codec.action.RegMoveCodec;
import org.opendaylight.openflowjava.nx.codec.match.ArpOpCodec;
import org.opendaylight.openflowjava.nx.codec.match.ArpShaCodec;
import org.opendaylight.openflowjava.nx.codec.match.ArpSpaCodec;
import org.opendaylight.openflowjava.nx.codec.match.ArpTpaCodec;
import org.opendaylight.openflowjava.nx.codec.match.EthDstCodec;
import org.opendaylight.openflowjava.nx.codec.match.EthSrcCodec;
+import org.opendaylight.openflowjava.nx.codec.match.EthTypeCodec;
import org.opendaylight.openflowjava.nx.codec.match.Reg0Codec;
import org.opendaylight.openflowjava.nx.codec.match.Reg1Codec;
import org.opendaylight.openflowjava.nx.codec.match.Reg2Codec;
public class NiciraExtensionsRegistrator implements AutoCloseable {
- private static final ActionCodec ACTION_CODEC = new ActionCodec();
private final List<SwitchConnectionProvider> providers;
/**
public void registerNiciraExtensions() {
for (SwitchConnectionProvider provider : providers) {
- provider.registerActionDeserializer(ActionCodec.DESERIALIZER_KEY, ACTION_CODEC);
- provider.registerActionSerializer(ActionCodec.SERIALIZER_KEY, ACTION_CODEC);
+ provider.registerActionDeserializer(ActionDeserializer.DESERIALIZER_KEY, NiciraActionCodecs.ACTION_DESERIALIZER);
+ provider.registerActionSerializer(RegLoadCodec.SERIALIZER_KEY, NiciraActionCodecs.REG_LOAD_CODEC);
+ provider.registerActionSerializer(RegMoveCodec.SERIALIZER_KEY, NiciraActionCodecs.REG_MOVE_CODEC);
provider.registerMatchEntrySerializer(Reg0Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG0_CODEC);
provider.registerMatchEntryDeserializer(Reg0Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG0_CODEC);
provider.registerMatchEntrySerializer(Reg1Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG1_CODEC);
provider.registerMatchEntryDeserializer(TunIpv4DstCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_DST_CODEC);
provider.registerMatchEntrySerializer(TunIpv4SrcCodec.SERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_SRC_CODEC);
provider.registerMatchEntryDeserializer(TunIpv4SrcCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_SRC_CODEC);
+ provider.registerMatchEntrySerializer(EthTypeCodec.SERIALIZER_KEY, NiciraMatchCodecs.ETH_TYPE_CODEC);
+ provider.registerMatchEntryDeserializer(EthTypeCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ETH_TYPE_CODEC);
}
}
public void unregisterExtensions() {
for (SwitchConnectionProvider provider : providers) {
- provider.unregisterSerializer(ActionCodec.SERIALIZER_KEY);
- provider.unregisterDeserializer(ActionCodec.DESERIALIZER_KEY);
+ provider.unregisterDeserializer(ActionDeserializer.DESERIALIZER_KEY);
+ provider.unregisterSerializer(RegLoadCodec.SERIALIZER_KEY);
+ provider.unregisterSerializer(RegMoveCodec.SERIALIZER_KEY);
provider.unregisterSerializer(Reg0Codec.SERIALIZER_KEY);
provider.unregisterDeserializer(Reg0Codec.DESERIALIZER_KEY);
provider.unregisterSerializer(Reg1Codec.SERIALIZER_KEY);
provider.unregisterDeserializer(TunIpv4DstCodec.DESERIALIZER_KEY);
provider.unregisterSerializer(TunIpv4SrcCodec.SERIALIZER_KEY);
provider.unregisterDeserializer(TunIpv4SrcCodec.DESERIALIZER_KEY);
+ provider.unregisterSerializer(EthTypeCodec.SERIALIZER_KEY);
+ provider.unregisterDeserializer(EthTypeCodec.DESERIALIZER_KEY);
}
}
import org.opendaylight.openflowjava.nx.codec.match.ArpTpaCodec;
import org.opendaylight.openflowjava.nx.codec.match.EthDstCodec;
import org.opendaylight.openflowjava.nx.codec.match.EthSrcCodec;
+import org.opendaylight.openflowjava.nx.codec.match.EthTypeCodec;
import org.opendaylight.openflowjava.nx.codec.match.Reg0Codec;
import org.opendaylight.openflowjava.nx.codec.match.Reg1Codec;
import org.opendaylight.openflowjava.nx.codec.match.Reg2Codec;
public static final EthSrcCodec ETH_SRC_CODEC = new EthSrcCodec();
public static final TunIpv4DstCodec TUN_IPV4_DST_CODEC = new TunIpv4DstCodec();
public static final TunIpv4SrcCodec TUN_IPV4_SRC_CODEC = new TunIpv4SrcCodec();
+ public static final EthTypeCodec ETH_TYPE_CODEC = new EthTypeCodec();
}
--- /dev/null
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.nx.codec.action;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.nx.NiciraConstants;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
+
+/**
+ * @author msunal
+ *
+ */
+public abstract class AbstractActionSerializer implements OFSerializer<Action> {
+
+ protected final static void serializeHeader(int msgLength, int subtype, ByteBuf outBuffer) {
+ outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE);
+ writeMsgLengthVendorIdSubtypeToBuffer(msgLength, subtype, outBuffer);
+ }
+
+ private final static void writeMsgLengthVendorIdSubtypeToBuffer(int msgLength, int subtype, ByteBuf outBuffer) {
+ outBuffer.writeShort(msgLength);
+ outBuffer.writeInt(NiciraConstants.NX_VENDOR_ID.intValue());
+ outBuffer.writeShort(subtype);
+ }
+
+}
import org.opendaylight.openflowjava.nx.NiciraConstants;
import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey;
-import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegLoad;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegMove;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxActionBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ActionCodec implements OFSerializer<Action>, OFDeserializer<Action> {
+public class ActionDeserializer implements OFDeserializer<Action> {
- private static final Logger LOG = LoggerFactory.getLogger(ActionCodec.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ActionDeserializer.class);
- public static final ExperimenterActionSerializerKey SERIALIZER_KEY = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID);
- public static final ExperimenterActionDeserializerKey DESERIALIZER_KEY = new ExperimenterActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID);
- private static final RegMoveCodec regMoveCodec = new RegMoveCodec();
- private static final RegLoadCodec regLoadCodec = new RegLoadCodec();
-
- @Override
- public void serialize(Action input, ByteBuf outBuffer) {
- outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE);
- OfjAugNxAction augNxAction = input.getAugmentation(OfjAugNxAction.class);
- if (augNxAction == null) {
- LOG.info("Action {} does not have any serializer.", input.getClass());
- return;
- }
- if (augNxAction.getActionRegMove() != null) {
- writeMsgLengthVendorIdSubtypeToBuffer(RegMoveCodec.LENGTH, RegMoveCodec.SUBTYPE, outBuffer);
- regMoveCodec.serialize(augNxAction.getActionRegMove(), outBuffer);
- } else if (augNxAction.getActionRegLoad() != null) {
- writeMsgLengthVendorIdSubtypeToBuffer(RegLoadCodec.LENGTH, RegLoadCodec.SUBTYPE, outBuffer);
- regLoadCodec.serialize(augNxAction.getActionRegLoad(), outBuffer);
- } else {
- LOG.info("Action {} does not have any serializer.", input.getClass());
- }
- }
-
- private final static void writeMsgLengthVendorIdSubtypeToBuffer(int msgLength, int subtype, ByteBuf outBuffer) {
- outBuffer.writeShort(msgLength);
- outBuffer.writeInt(NiciraConstants.NX_VENDOR_ID.intValue());
- outBuffer.writeShort(subtype);
- }
+ public static final ExperimenterActionDeserializerKey DESERIALIZER_KEY = new ExperimenterActionDeserializerKey(
+ EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID);
@Override
public Action deserialize(ByteBuf message) {
OfjAugNxActionBuilder augNxActionBuilder = new OfjAugNxActionBuilder();
switch (subtype) {
case RegMoveCodec.SUBTYPE:
- augNxActionBuilder.setActionRegMove(regMoveCodec.deserialize(message));
+ augNxActionBuilder.setActionRegMove(NiciraActionCodecs.REG_MOVE_CODEC.deserialize(message));
+ expIdBuilder.setSubType(NxmNxRegMove.class);
break;
case RegLoadCodec.SUBTYPE:
- augNxActionBuilder.setActionRegLoad(regLoadCodec.deserialize(message));
+ augNxActionBuilder.setActionRegLoad(NiciraActionCodecs.REG_LOAD_CODEC.deserialize(message));
+ expIdBuilder.setSubType(NxmNxRegLoad.class);
break;
default:
LOG.info("Action {} does not have any deserializer.", subtype);
--- /dev/null
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.nx.codec.action;
+
+/**
+ * @author msunal
+ *
+ */
+public class NiciraActionCodecs {
+
+ public static final RegMoveCodec REG_MOVE_CODEC = new RegMoveCodec();
+ public static final RegLoadCodec REG_LOAD_CODEC = new RegLoadCodec();
+ public static final ActionDeserializer ACTION_DESERIALIZER = new ActionDeserializer();
+}
import java.math.BigInteger;
+import org.opendaylight.openflowjava.nx.NiciraConstants;
import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegLoad;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoad;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoadBuilder;
-public class RegLoadCodec implements OFSerializer<ActionRegLoad>, OFDeserializer<ActionRegLoad> {
+public class RegLoadCodec extends AbstractActionSerializer implements OFDeserializer<ActionRegLoad> {
+ public static final ExperimenterActionSerializerKey SERIALIZER_KEY = new ExperimenterActionSerializerKey(
+ EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID, NxmNxRegLoad.class);
public static final int LENGTH = 24;
public static final byte SUBTYPE = 7; // NXAST_REG_LOAD
@Override
- public void serialize(ActionRegLoad input, ByteBuf outBuffer) {
- outBuffer.writeShort(input.getOfsNbits());
- outBuffer.writeInt(input.getDst().intValue());
- outBuffer.writeLong(input.getValue().longValue());
+ public void serialize(Action input, ByteBuf outBuffer) {
+ ActionRegLoad actionRegLoad = input.getAugmentation(OfjAugNxAction.class).getActionRegLoad();
+ serializeHeader(LENGTH, SUBTYPE, outBuffer);
+ outBuffer.writeShort(actionRegLoad.getOfsNbits());
+ outBuffer.writeInt(actionRegLoad.getDst().intValue());
+ outBuffer.writeLong(actionRegLoad.getValue().longValue());
}
@Override
import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.nx.NiciraConstants;
import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
+import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegMove;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.move.grouping.ActionRegMove;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.move.grouping.ActionRegMoveBuilder;
-public class RegMoveCodec implements OFSerializer<ActionRegMove>, OFDeserializer<ActionRegMove> {
+public class RegMoveCodec extends AbstractActionSerializer implements OFDeserializer<ActionRegMove> {
+ public static final ExperimenterActionSerializerKey SERIALIZER_KEY = new ExperimenterActionSerializerKey(
+ EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID, NxmNxRegMove.class);
public static final int LENGTH = 24;
public static final byte SUBTYPE = 6; // NXAST_REG_MOVE
@Override
- public void serialize(ActionRegMove input, ByteBuf outBuffer) {
- outBuffer.writeShort(input.getNBits());
- outBuffer.writeShort(input.getSrcOfs());
- outBuffer.writeShort(input.getDstOfs());
- outBuffer.writeInt(input.getSrc().intValue());
- outBuffer.writeInt(input.getDst().intValue());
+ public void serialize(Action input, ByteBuf outBuffer) {
+ ActionRegMove actionRegMove = input.getAugmentation(OfjAugNxAction.class).getActionRegMove();
+ serializeHeader(LENGTH, SUBTYPE, outBuffer);
+ outBuffer.writeShort(actionRegMove.getNBits());
+ outBuffer.writeShort(actionRegMove.getSrcOfs());
+ outBuffer.writeShort(actionRegMove.getDstOfs());
+ outBuffer.writeInt(actionRegMove.getSrc().intValue());
+ outBuffer.writeInt(actionRegMove.getDst().intValue());
}
@Override
public class ArpTpaCodec extends AbstractMatchCodec {
private static final int VALUE_LENGTH = 4;
- private static final int NXM_FIELD_CODE = 16;
+ private static final int NXM_FIELD_CODE = 17;
public static final MatchEntrySerializerKey<Nxm0Class, NxmOfArpTpa> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpTpa.class);
public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
public class EthDstCodec extends AbstractMatchCodec {
private static final int VALUE_LENGTH = 6;
- private static final int NXM_FIELD_CODE = 2;
+ private static final int NXM_FIELD_CODE = 1;
public static final MatchEntrySerializerKey<Nxm0Class, NxmOfEthDst> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthDst.class);
public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
--- /dev/null
+package org.opendaylight.openflowjava.nx.codec.match;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfEthType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.eth.type.grouping.EthTypeValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
+
+public class EthTypeCodec extends AbstractMatchCodec {
+
+ private static final int VALUE_LENGTH = 2;
+ private static final int NXM_FIELD_CODE = 3;
+ public static final MatchEntrySerializerKey<Nxm0Class, NxmOfEthType> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
+ EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthType.class);
+ public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
+ EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
+
+ @Override
+ public void serialize(MatchEntries input, ByteBuf outBuffer) {
+ serializeHeader(input, outBuffer);
+ Integer value = input.getAugmentation(OfjAugNxMatch.class).getEthTypeValues().getValue();
+ outBuffer.writeShort(value);
+ }
+
+ @Override
+ public MatchEntries deserialize(ByteBuf message) {
+ MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message);
+ OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder();
+ augNxMatchBuilder.setEthTypeValues(new EthTypeValuesBuilder().setValue(message.readUnsignedShort()).build());
+ matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build());
+ return matchEntriesBuilder.build();
+ }
+
+ @Override
+ public int getNxmFieldCode() {
+ return NXM_FIELD_CODE;
+ }
+
+ @Override
+ public int getOxmClassCode() {
+ return OxmMatchConstants.NXM_0_CLASS;
+ }
+
+ @Override
+ public int getValueLength() {
+ return VALUE_LENGTH;
+ }
+
+ @Override
+ public Class<? extends MatchField> getNxmField() {
+ return NxmOfEthType.class;
+ }
+
+ @Override
+ public Class<? extends OxmClassBase> getOxmClass() {
+ return Nxm0Class.class;
+ }
+
+}
revision "2014-04-21" {
description "Initial revision";
}
+
+ identity nxm-nx-reg-load {
+ base ofaction:experimenter-action-sub-type;
+ }
+ identity nxm-nx-reg-move {
+ base ofaction:experimenter-action-sub-type;
+ }
grouping ofj-nx-action-reg-load-grouping {
container action-reg-load {
identity nxm-of-eth-dst {
base ofoxm:match-field;
}
+ identity nxm-of-eth-type {
+ base ofoxm:match-field;
+ }
grouping ofj-nxm-nx-match-reg-grouping {
container reg-values {
}
}
}
+ grouping ofj-nxm-of-match-eth-type-grouping {
+ container eth-type-values {
+ leaf value {
+ type uint16;
+ }
+ }
+ }
augment "/ofoxm:oxm-container/ofoxm:match-entries" {
ext:augment-identifier "ofj-aug_nx_match";
uses ofj-nxm-nx-match-tun-ipv4-src-grouping;
uses ofj-nxm-of-match-eth-src-grouping;
uses ofj-nxm-of-match-eth-dst-grouping;
+ uses ofj-nxm-of-match-eth-type-grouping;
}
}
\ No newline at end of file
import org.opendaylight.openflowjava.protocol.nx.deserialization.NxActionResubmitDeserializer;\r
import org.opendaylight.openflowjava.protocol.nx.serialization.NxActionResubmitSerializer;\r
import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxResubmitAction;\r
\r
/**\r
* @author michal.polkorab\r
if (providers != null) {\r
this.providers = providers;\r
for (SwitchConnectionProvider provider : providers) {\r
- /* In case of handling multiple actions, instructions and other structures which\r
- * are differentiated by vendor / experimenter subtype, vendor has to\r
- * switch / choose between these subtypes.\r
- * \r
- * This has to be done in this way because of experimenter headers, which\r
- * provide only vendor / experimenter ID. Subtype position may be different\r
- * for different vendors (or not present at all) - that's why vendor has to\r
- * handle it in his own implementations.\r
- */\r
provider.registerActionSerializer(new ExperimenterActionSerializerKey(\r
- EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID),\r
+ EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID, NxResubmitAction.class),\r
new NxActionResubmitSerializer());\r
}\r
}\r
for (SwitchConnectionProvider provider : providers) {\r
// unregister serializer\r
provider.unregisterSerializer(new ExperimenterActionSerializerKey(\r
- EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID));\r
+ EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID, NxResubmitAction.class));\r
// unregister deserializer\r
provider.unregisterDeserializer(new ExperimenterActionDeserializerKey(\r
EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID));\r
revision "2013-07-31" {\r
description "OpenFlow 1.3 - action model";\r
}\r
+ \r
+ identity nx-resubmit-action {\r
+ base ofaction:experimenter-action-sub-type;\r
+ }\r
\r
augment "/ofaction:actions-container/ofaction:action" {\r
ext:augment-identifier "nx-action-resubmit-augment";\r
return true;\r
if (!super.equals(obj))\r
return false;\r
- if (!(obj instanceof ActionSerializerKey))\r
+ if (getClass() != obj.getClass())\r
return false;\r
ActionSerializerKey<?> other = (ActionSerializerKey<?>) obj;\r
if (actionType == null) {\r
\r
import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType;\r
\r
/**\r
* @author michal.polkorab\r
public final class ExperimenterActionSerializerKey extends ActionSerializerKey<Experimenter> \r
implements ExperimenterSerializerKey {\r
\r
+ private Class<? extends ExperimenterActionSubType> actionSubType;\r
+\r
/**\r
* @param msgVersion protocol wire version\r
* @param experimenterId experimenter / vendor ID\r
*/\r
- public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId) {\r
+ public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId, Class<? extends ExperimenterActionSubType> actionSubType) {\r
super(msgVersion, Experimenter.class, experimenterId);\r
+ this.actionSubType = actionSubType;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = super.hashCode();\r
+ result = prime * result + ((actionSubType == null) ? 0 : actionSubType.hashCode());\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj)\r
+ return true;\r
+ if (!super.equals(obj))\r
+ return false;\r
+ if (getClass() != obj.getClass())\r
+ return false;\r
+ ExperimenterActionSerializerKey other = (ExperimenterActionSerializerKey) obj;\r
+ if (actionSubType == null) {\r
+ if (other.actionSubType != null)\r
+ return false;\r
+ } else if (!actionSubType.equals(other.actionSubType))\r
+ return false;\r
+ return true;\r
}\r
\r
}
\ No newline at end of file
description "";
base oft:action-base;
}
-
+
+ identity experimenter-action-sub-type {
+ description "The base identity for vendor's actions.";
+ }
+
container actions-container {
uses actions-grouping;
}
leaf experimenter {\r
type oft:experimenter-id;\r
}\r
+ leaf sub-type {\r
+ type identityref {\r
+ base ofaction:experimenter-action-sub-type;\r
+ }\r
+ }\r
}\r
// OF1.0 structures\r
augment "/ofaction:actions-container/ofaction:action" {\r
import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType;
/**
* @author michal.polkorab
ActionSerializerKey<Experimenter> actionSerializerKey = new ActionSerializerKey<>(
EncodeConstants.OF13_VERSION_ID, Experimenter.class, 1L);
ExperimenterActionSerializerKey experimenterActionSerializerKey = new ExperimenterActionSerializerKey(
- EncodeConstants.OF13_VERSION_ID, 1L);
- Assert.assertEquals(actionSerializerKey, experimenterActionSerializerKey);
- Assert.assertEquals(actionSerializerKey.hashCode(), experimenterActionSerializerKey.hashCode());
+ EncodeConstants.OF13_VERSION_ID, 1L, ExpSubType.class);
+ Assert.assertFalse(actionSerializerKey.equals(experimenterActionSerializerKey));
+ Assert.assertFalse(experimenterActionSerializerKey.equals(actionSerializerKey));
InstructionSerializerKey<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter> instructionSerializerKey = new InstructionSerializerKey<>(
EncodeConstants.OF13_VERSION_ID,
Assert.assertEquals(instructionSerializerKey, experimenterInstructionSerializerKey);
Assert.assertEquals(instructionSerializerKey.hashCode(), experimenterInstructionSerializerKey.hashCode());
}
+
+ private static class ExpSubType extends ExperimenterActionSubType {
+
+ }
}
public MessageTypeKey<?> make(Action entry) {\r
if (entry.getType().equals(Experimenter.class)) {\r
return new ExperimenterActionSerializerKey(getVersion(),\r
- entry.getAugmentation(ExperimenterIdAction.class).getExperimenter().getValue());\r
+ entry.getAugmentation(ExperimenterIdAction.class).getExperimenter().getValue(), entry.getAugmentation(ExperimenterIdAction.class).getSubType());\r
}\r
return new ActionSerializerKey<>(getVersion(), entry.getType(), null);\r
}\r