[ONOS-4258] Initial implementation of supporting extension in REST
- Support Nicira extension
Change-Id: I62bf4417e43459727ce7d4b1ac929c6cf0b7826f
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/MoveExtensionTreatmentCodec.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/MoveExtensionTreatmentCodec.java
new file mode 100644
index 0000000..4610c1b
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/MoveExtensionTreatmentCodec.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.extensions.codec;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.driver.extensions.DefaultMoveExtensionTreatment;
+import org.onosproject.driver.extensions.MoveExtensionTreatment;
+import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.Tools.nullIsIllegal;
+
+/**
+ * JSON Codec for MoveExtensionTreatment class.
+ */
+public final class MoveExtensionTreatmentCodec extends JsonCodec<MoveExtensionTreatment> {
+
+ private static final String SRC_OFS = "srcOfs";
+ private static final String DST_OFS = "dstOfs";
+ private static final String N_BITS = "nBits";
+ private static final String SRC = "src";
+ private static final String DST = "dst";
+ private static final String TYPE = "type";
+
+ private static final String MISSING_MEMBER_MESSAGE = " member is required in MoveExtensionTreatment";
+
+ @Override
+ public ObjectNode encode(MoveExtensionTreatment moveExtensionTreatment, CodecContext context) {
+ checkNotNull(moveExtensionTreatment, "Move Extension Treatment cannot be null");
+ ObjectNode root = context.mapper().createObjectNode()
+ .put(SRC_OFS, moveExtensionTreatment.srcOffset())
+ .put(DST_OFS, moveExtensionTreatment.dstOffset())
+ .put(N_BITS, moveExtensionTreatment.nBits())
+ .put(SRC, moveExtensionTreatment.src())
+ .put(DST, moveExtensionTreatment.dst());
+ return root;
+ }
+
+ @Override
+ public MoveExtensionTreatment decode(ObjectNode json, CodecContext context) {
+ if (json == null || !json.isObject()) {
+ return null;
+ }
+
+ // parse extension treatment type
+ ExtensionTreatmentType type = new ExtensionTreatmentType(nullIsIllegal(json.get(TYPE),
+ TYPE + MISSING_MEMBER_MESSAGE).asInt());
+
+ // parse src off set
+ int srcOfs = nullIsIllegal(json.get(SRC_OFS), SRC_OFS + MISSING_MEMBER_MESSAGE).asInt();
+
+ // parse dst off set
+ int dstOfs = nullIsIllegal(json.get(DST_OFS), DST_OFS + MISSING_MEMBER_MESSAGE).asInt();
+
+ // parse n bits
+ int nBits = nullIsIllegal(json.get(N_BITS), N_BITS + MISSING_MEMBER_MESSAGE).asInt();
+
+ // parse src
+ int src = nullIsIllegal(json.get(SRC), SRC + MISSING_MEMBER_MESSAGE).asInt();
+
+ // parse dst
+ int dst = nullIsIllegal(json.get(DST), DST + MISSING_MEMBER_MESSAGE).asInt();
+
+ MoveExtensionTreatment moveExtensionTreatment =
+ new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, src, dst, type);
+
+ return moveExtensionTreatment;
+ }
+}
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraMatchNshSiCodec.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraMatchNshSiCodec.java
new file mode 100644
index 0000000..e6ca4a9
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraMatchNshSiCodec.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.extensions.codec;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.driver.extensions.NiciraMatchNshSi;
+import org.onosproject.net.NshServiceIndex;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.Tools.nullIsIllegal;
+
+/**
+ * JSON Codec for NiciraMatchNshSi class.
+ */
+public final class NiciraMatchNshSiCodec extends JsonCodec<NiciraMatchNshSi> {
+
+ private static final String NSH_SERVICE_INDEX = "nsi";
+
+ private static final String MISSING_MEMBER_MESSAGE = " member is required in NiciraMatchNshSi";
+
+ @Override
+ public ObjectNode encode(NiciraMatchNshSi niciraMatchNshSi, CodecContext context) {
+ checkNotNull(niciraMatchNshSi, "Nicira Match Nsh Si cannot be null");
+ ObjectNode root = context.mapper().createObjectNode()
+ .put(NSH_SERVICE_INDEX, niciraMatchNshSi.nshSi().serviceIndex());
+ return root;
+ }
+
+ @Override
+ public NiciraMatchNshSi decode(ObjectNode json, CodecContext context) {
+ if (json == null || !json.isObject()) {
+ return null;
+ }
+
+ // parse nsh service index
+ short nshSiShort = (short) nullIsIllegal(json.get(NSH_SERVICE_INDEX),
+ NSH_SERVICE_INDEX + MISSING_MEMBER_MESSAGE).asInt();
+ NshServiceIndex nshSi = NshServiceIndex.of(nshSiShort);
+
+ NiciraMatchNshSi niciraMatchNshSi = new NiciraMatchNshSi(nshSi);
+
+ return niciraMatchNshSi;
+ }
+}
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraMatchNshSpiCodec.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraMatchNshSpiCodec.java
new file mode 100644
index 0000000..150125a
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraMatchNshSpiCodec.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.extensions.codec;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.driver.extensions.NiciraMatchNshSpi;
+import org.onosproject.net.NshServicePathId;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.Tools.nullIsIllegal;
+
+/**
+ * JSON Codec for NiciraMatchNshSpi class.
+ */
+public final class NiciraMatchNshSpiCodec extends JsonCodec<NiciraMatchNshSpi> {
+
+ private static final String NSH_PATH_ID = "nsp";
+
+ private static final String MISSING_MEMBER_MESSAGE = " member is required in NiciraMatchNshSpi";
+
+ @Override
+ public ObjectNode encode(NiciraMatchNshSpi niciraMatchNshSpi, CodecContext context) {
+ checkNotNull(niciraMatchNshSpi, "Nicira Match Nsh Spi cannot be null");
+ ObjectNode root = context.mapper().createObjectNode()
+ .put(NSH_PATH_ID, niciraMatchNshSpi.nshSpi().servicePathId());
+ return root;
+ }
+
+ @Override
+ public NiciraMatchNshSpi decode(ObjectNode json, CodecContext context) {
+ if (json == null || !json.isObject()) {
+ return null;
+ }
+
+ // parse nsh path id
+ int nshSpiInt = nullIsIllegal(json.get(NSH_PATH_ID),
+ NSH_PATH_ID + MISSING_MEMBER_MESSAGE).asInt();
+ NshServicePathId nshSpi = NshServicePathId.of(nshSpiInt);
+
+ NiciraMatchNshSpi niciraMatchNshSpi = new NiciraMatchNshSpi(nshSpi);
+
+ return niciraMatchNshSpi;
+ }
+}
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraResubmitCodec.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraResubmitCodec.java
new file mode 100644
index 0000000..62db7f8
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraResubmitCodec.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.extensions.codec;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.driver.extensions.NiciraResubmit;
+import org.onosproject.net.PortNumber;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.Tools.nullIsIllegal;
+
+/**
+ * JSON Codec for NiciraResubmit class.
+ */
+public final class NiciraResubmitCodec extends JsonCodec<NiciraResubmit> {
+
+ private static final String RESUBMIT_PORT = "inPort";
+ private static final String RESUBMIT_TABLE = "table";
+
+ private static final String MISSING_MEMBER_MESSAGE = " member is required in NiciraResubmit";
+
+ @Override
+ public ObjectNode encode(NiciraResubmit niciraResubmit, CodecContext context) {
+ checkNotNull(niciraResubmit, "Nicira Resubmit cannot be null");
+ ObjectNode root = context.mapper().createObjectNode()
+ .put(RESUBMIT_PORT, niciraResubmit.inPort().toLong())
+ .put(RESUBMIT_TABLE, niciraResubmit.table());
+ return root;
+ }
+
+ @Override
+ public NiciraResubmit decode(ObjectNode json, CodecContext context) {
+ if (json == null || !json.isObject()) {
+ return null;
+ }
+
+ // parse in port number
+ long portNumberLong = nullIsIllegal(json.get(RESUBMIT_PORT), RESUBMIT_PORT + MISSING_MEMBER_MESSAGE).asLong();
+ PortNumber portNumber = PortNumber.portNumber(portNumberLong);
+
+ NiciraResubmit niciraResubmit = new NiciraResubmit(portNumber);
+
+ return niciraResubmit;
+ }
+}
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraResubmitTableCodec.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraResubmitTableCodec.java
new file mode 100644
index 0000000..5a8eb73
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraResubmitTableCodec.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.extensions.codec;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.driver.extensions.NiciraResubmitTable;
+import org.onosproject.net.PortNumber;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.Tools.nullIsIllegal;
+
+/**
+ * JSON Codec for NiciraResubmitTable class.
+ */
+public final class NiciraResubmitTableCodec extends JsonCodec<NiciraResubmitTable> {
+
+ private static final String RESUBMIT_PORT = "inPort";
+ private static final String RESUBMIT_TABLE = "table";
+
+ private static final String MISSING_MEMBER_MESSAGE = " member is required in NiciraResubmitTable";
+
+ @Override
+ public ObjectNode encode(NiciraResubmitTable niciraResubmitTable, CodecContext context) {
+ checkNotNull(niciraResubmitTable, "Nicira Resubmit Table cannot be null");
+ ObjectNode root = context.mapper().createObjectNode()
+ .put(RESUBMIT_PORT, niciraResubmitTable.inPort().toLong())
+ .put(RESUBMIT_TABLE, niciraResubmitTable.table());
+ return root;
+ }
+
+ @Override
+ public NiciraResubmitTable decode(ObjectNode json, CodecContext context) {
+ if (json == null || !json.isObject()) {
+ return null;
+ }
+
+ // parse in port number
+ long portNumberLong = nullIsIllegal(json.get(RESUBMIT_PORT),
+ RESUBMIT_PORT + MISSING_MEMBER_MESSAGE).asLong();
+ PortNumber portNumber = PortNumber.portNumber(portNumberLong);
+
+ // parse table id
+ short tableId = (short) nullIsIllegal(json.get(RESUBMIT_TABLE),
+ RESUBMIT_TABLE + MISSING_MEMBER_MESSAGE).asInt();
+
+ NiciraResubmitTable niciraResubmitTable = new NiciraResubmitTable(portNumber, tableId);
+
+ return niciraResubmitTable;
+ }
+}
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraSetNshContextHeaderCodec.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraSetNshContextHeaderCodec.java
new file mode 100644
index 0000000..9cf8bc8
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraSetNshContextHeaderCodec.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.extensions.codec;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.driver.extensions.NiciraSetNshContextHeader;
+import org.onosproject.net.NshContextHeader;
+import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.Tools.nullIsIllegal;
+
+/**
+ * JSON Codec for NiciraSetNshContextHeader class.
+ */
+public class NiciraSetNshContextHeaderCodec extends JsonCodec<NiciraSetNshContextHeader> {
+
+ private static final String NSH_CONTEXT_HEADER = "nshch";
+ private static final String TYPE = "type";
+
+ private static final String MISSING_MEMBER_MESSAGE = " member is required in NiciraSetNshContextHeader";
+
+ @Override
+ public ObjectNode encode(NiciraSetNshContextHeader niciraSetNshContextHeader, CodecContext context) {
+ checkNotNull(niciraSetNshContextHeader, "Nicira Set Nsh Context Header cannot be null");
+ ObjectNode root = context.mapper().createObjectNode()
+ .put(NSH_CONTEXT_HEADER, niciraSetNshContextHeader.nshCh().nshContextHeader())
+ .put(TYPE, niciraSetNshContextHeader.type().type());
+ return root;
+ }
+
+ @Override
+ public NiciraSetNshContextHeader decode(ObjectNode json, CodecContext context) {
+ if (json == null || !json.isObject()) {
+ return null;
+ }
+
+ // parse nsh context header
+ int contextHeaderInt = nullIsIllegal(json.get(NSH_CONTEXT_HEADER),
+ NSH_CONTEXT_HEADER + MISSING_MEMBER_MESSAGE).asInt();
+
+ NshContextHeader contextHeader = NshContextHeader.of(contextHeaderInt);
+
+ // parse type
+ int extensionTypeInt = nullIsIllegal(json.get(TYPE),
+ TYPE + MISSING_MEMBER_MESSAGE).asInt();
+
+ ExtensionTreatmentType type = new ExtensionTreatmentType(extensionTypeInt);
+
+ NiciraSetNshContextHeader niciraSetNshContextHeader =
+ new NiciraSetNshContextHeader(contextHeader, type);
+
+ return niciraSetNshContextHeader;
+ }
+}
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraSetNshSiCodec.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraSetNshSiCodec.java
new file mode 100644
index 0000000..d62eb69
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraSetNshSiCodec.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.extensions.codec;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.driver.extensions.NiciraSetNshSi;
+import org.onosproject.net.NshServiceIndex;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.Tools.nullIsIllegal;
+
+/**
+ * JSON Codec for NiciraSetNshSi class.
+ */
+public final class NiciraSetNshSiCodec extends JsonCodec<NiciraSetNshSi> {
+
+ private static final String NSH_SERVICE_INDEX = "setNsi";
+
+ private static final String MISSING_MEMBER_MESSAGE = " member is required in NiciraSetNshSi";
+
+ @Override
+ public ObjectNode encode(NiciraSetNshSi niciraSetNshSi, CodecContext context) {
+ checkNotNull(niciraSetNshSi, "Nicira Set Nsh Si cannot be null");
+ ObjectNode root = context.mapper().createObjectNode()
+ .put(NSH_SERVICE_INDEX, niciraSetNshSi.nshSi().serviceIndex());
+ return root;
+ }
+
+ @Override
+ public NiciraSetNshSi decode(ObjectNode json, CodecContext context) {
+ if (json == null || !json.isObject()) {
+ return null;
+ }
+
+ // parse service index port
+ short serviceIndexShort = (short) nullIsIllegal(json.get(NSH_SERVICE_INDEX),
+ NSH_SERVICE_INDEX + MISSING_MEMBER_MESSAGE).asInt();
+
+ NshServiceIndex index = NshServiceIndex.of(serviceIndexShort);
+
+ NiciraSetNshSi niciraSetNshSi = new NiciraSetNshSi(index);
+
+ return niciraSetNshSi;
+ }
+}
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraSetNshSpiCodec.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraSetNshSpiCodec.java
new file mode 100644
index 0000000..e6c209d
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraSetNshSpiCodec.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.extensions.codec;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.driver.extensions.NiciraSetNshSpi;
+import org.onosproject.net.NshServicePathId;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.Tools.nullIsIllegal;
+
+/**
+ * JSON Codec for NiciraSetNshSpi class.
+ */
+public final class NiciraSetNshSpiCodec extends JsonCodec<NiciraSetNshSpi> {
+
+ private static final String NSH_PATH_ID = "setNsp";
+
+ private static final String MISSING_MEMBER_MESSAGE = " member is required in NiciraSetNshSpi";
+
+ @Override
+ public ObjectNode encode(NiciraSetNshSpi niciraSetNshSpi, CodecContext context) {
+ checkNotNull(niciraSetNshSpi, "Nicira Set Nsh Spi cannot be null");
+ ObjectNode root = context.mapper().createObjectNode()
+ .put(NSH_PATH_ID, niciraSetNshSpi.nshSpi().servicePathId());
+ return root;
+ }
+
+ @Override
+ public NiciraSetNshSpi decode(ObjectNode json, CodecContext context) {
+ if (json == null || !json.isObject()) {
+ return null;
+ }
+
+ // parse service path id
+ int servicePathIdInt = nullIsIllegal(json.get(NSH_PATH_ID),
+ NSH_PATH_ID + MISSING_MEMBER_MESSAGE).asInt();
+
+ NshServicePathId pathId = NshServicePathId.of(servicePathIdInt);
+
+ NiciraSetNshSpi niciraSetNshSpi = new NiciraSetNshSpi(pathId);
+
+ return niciraSetNshSpi;
+ }
+}
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraSetTunnelDstCodec.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraSetTunnelDstCodec.java
new file mode 100644
index 0000000..fc7fa1b
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/NiciraSetTunnelDstCodec.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.extensions.codec;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.driver.extensions.NiciraSetTunnelDst;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.Tools.nullIsIllegal;
+
+/**
+ * JSON Codec for NiciraSetTunnelDst class.
+ */
+public final class NiciraSetTunnelDstCodec extends JsonCodec<NiciraSetTunnelDst> {
+
+ private static final String TUNNEL_DST = "tunnelDst";
+
+ private static final String MISSING_MEMBER_MESSAGE = " member is required in NiciraSetTunnelDst";
+
+ @Override
+ public ObjectNode encode(NiciraSetTunnelDst niciraSetTunnelDst, CodecContext context) {
+ checkNotNull(niciraSetTunnelDst, "Nicira Set Tunnel DST cannot be null");
+ ObjectNode root = context.mapper().createObjectNode()
+ .put(TUNNEL_DST, niciraSetTunnelDst.tunnelDst().toString());
+ return root;
+ }
+
+ @Override
+ public NiciraSetTunnelDst decode(ObjectNode json, CodecContext context) {
+ if (json == null || !json.isObject()) {
+ return null;
+ }
+
+ // parse tunnel destination IP address
+ String dstIp = nullIsIllegal(json.get(TUNNEL_DST), TUNNEL_DST + MISSING_MEMBER_MESSAGE).asText();
+
+ Ip4Address tunnelDst = Ip4Address.valueOf(dstIp);
+
+ NiciraSetTunnelDst niciraSetTunnelDst = new NiciraSetTunnelDst(tunnelDst);
+
+ return niciraSetTunnelDst;
+ }
+}
diff --git a/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/package-info.java b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/package-info.java
new file mode 100644
index 0000000..45dc2f5
--- /dev/null
+++ b/drivers/default/src/main/java/org/onosproject/driver/extensions/codec/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Implementations of the codec broker and NICIRA and OFDPA extension JSON codecs.
+ */
+package org.onosproject.driver.extensions.codec;