Added support for TCP and UDP port mask in Nicira extention 73/30273/3
authorAswin Suryanarayanan <aswin.suryanarayanan@hp.com>
Thu, 26 Nov 2015 23:53:36 +0000 (05:23 +0530)
committerAswin Suryanarayanan <aswin.suryanarayanan@hp.com>
Mon, 7 Dec 2015 15:40:26 +0000 (21:10 +0530)
Change-Id: I4c89c8ee57860e6439c66f74606b62076b0bfae6
Signed-off-by: Aswin Suryanarayanan <aswin.suryanarayanan@hp.com>
14 files changed:
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpDstCodec.java [new file with mode: 0644]
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpSrcCodec.java [new file with mode: 0644]
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpDstCodec.java [new file with mode: 0644]
extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpSrcCodec.java [new file with mode: 0644]
extension/openflowjava-extension-nicira/src/main/yang/nicira-match.yang
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/NiciraExtensionProvider.java
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/MatchUtil.java
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TcpDstConvertor.java [new file with mode: 0644]
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TcpSrcConvertor.java [new file with mode: 0644]
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpDstConvertor.java [new file with mode: 0644]
extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpSrcConvertor.java [new file with mode: 0644]
extension/openflowplugin-extension-nicira/src/main/yang/openflowplugin-extension-nicira-match.yang

index 968769f6bf9c736b945294cebe264fe2500429a4..f88ecd320bfc35c744c4c234e4ada206d279773a 100644 (file)
@@ -43,9 +43,13 @@ import org.opendaylight.openflowjava.nx.codec.match.Reg4Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg5Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg6Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg7Codec;
+import org.opendaylight.openflowjava.nx.codec.match.TcpDstCodec;
+import org.opendaylight.openflowjava.nx.codec.match.TcpSrcCodec;
 import org.opendaylight.openflowjava.nx.codec.match.TunIdCodec;
 import org.opendaylight.openflowjava.nx.codec.match.TunIpv4DstCodec;
 import org.opendaylight.openflowjava.nx.codec.match.TunIpv4SrcCodec;
+import org.opendaylight.openflowjava.nx.codec.match.UdpDstCodec;
+import org.opendaylight.openflowjava.nx.codec.match.UdpSrcCodec;
 
 import com.google.common.base.Preconditions;
 
@@ -135,6 +139,14 @@ public class NiciraExtensionsRegistrator implements AutoCloseable {
         registrator.registerMatchEntryDeserializer(TunIpv4DstCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_DST_CODEC);
         registrator.registerMatchEntrySerializer(TunIpv4SrcCodec.SERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_SRC_CODEC);
         registrator.registerMatchEntryDeserializer(TunIpv4SrcCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_SRC_CODEC);
+        registrator.registerMatchEntrySerializer(TcpSrcCodec.SERIALIZER_KEY, NiciraMatchCodecs.TCP_SRC_CODEC);
+        registrator.registerMatchEntryDeserializer(TcpSrcCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TCP_SRC_CODEC);
+        registrator.registerMatchEntrySerializer(TcpDstCodec.SERIALIZER_KEY, NiciraMatchCodecs.TCP_DST_CODEC);
+        registrator.registerMatchEntryDeserializer(TcpDstCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TCP_DST_CODEC);
+        registrator.registerMatchEntrySerializer(UdpSrcCodec.SERIALIZER_KEY, NiciraMatchCodecs.UDP_SRC_CODEC);
+        registrator.registerMatchEntryDeserializer(UdpSrcCodec.DESERIALIZER_KEY, NiciraMatchCodecs.UDP_SRC_CODEC);
+        registrator.registerMatchEntrySerializer(UdpDstCodec.SERIALIZER_KEY, NiciraMatchCodecs.UDP_DST_CODEC);
+        registrator.registerMatchEntryDeserializer(UdpDstCodec.DESERIALIZER_KEY, NiciraMatchCodecs.UDP_DST_CODEC);
     }
 
     public void unregisterExtensions() {
@@ -211,6 +223,14 @@ public class NiciraExtensionsRegistrator implements AutoCloseable {
         registrator.unregisterMatchEntryDeserializer(TunIpv4DstCodec.DESERIALIZER_KEY);
         registrator.unregisterMatchEntrySerializer(TunIpv4SrcCodec.SERIALIZER_KEY);
         registrator.unregisterMatchEntryDeserializer(TunIpv4SrcCodec.DESERIALIZER_KEY);
+        registrator.unregisterMatchEntrySerializer(TcpSrcCodec.SERIALIZER_KEY);
+        registrator.unregisterMatchEntryDeserializer(TcpSrcCodec.DESERIALIZER_KEY);
+        registrator.unregisterMatchEntrySerializer(TcpDstCodec.SERIALIZER_KEY);
+        registrator.unregisterMatchEntryDeserializer(TcpDstCodec.DESERIALIZER_KEY);
+        registrator.unregisterMatchEntrySerializer(UdpSrcCodec.SERIALIZER_KEY);
+        registrator.unregisterMatchEntryDeserializer(UdpSrcCodec.DESERIALIZER_KEY);
+        registrator.unregisterMatchEntrySerializer(UdpDstCodec.SERIALIZER_KEY);
+        registrator.unregisterMatchEntryDeserializer(UdpDstCodec.DESERIALIZER_KEY);
     }
 
     @Override
index f9961540c7cee895dc5a1f37887bb0c51e02605d..6f850a83ba48154f9b8d015ac47f43d78c1e18de 100644 (file)
@@ -29,9 +29,13 @@ import org.opendaylight.openflowjava.nx.codec.match.Reg4Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg5Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg6Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg7Codec;
+import org.opendaylight.openflowjava.nx.codec.match.TcpDstCodec;
+import org.opendaylight.openflowjava.nx.codec.match.TcpSrcCodec;
 import org.opendaylight.openflowjava.nx.codec.match.TunIdCodec;
 import org.opendaylight.openflowjava.nx.codec.match.TunIpv4DstCodec;
 import org.opendaylight.openflowjava.nx.codec.match.TunIpv4SrcCodec;
+import org.opendaylight.openflowjava.nx.codec.match.UdpDstCodec;
+import org.opendaylight.openflowjava.nx.codec.match.UdpSrcCodec;
 
 /**
  * @author msunal
@@ -64,4 +68,8 @@ public class NiciraMatchCodecs {
     public static final Nshc2Codec NSC2_CODEC = new Nshc2Codec();
     public static final Nshc3Codec NSC3_CODEC = new Nshc3Codec();
     public static final Nshc4Codec NSC4_CODEC = new Nshc4Codec();
+    public static final TcpSrcCodec TCP_SRC_CODEC = new TcpSrcCodec();
+    public static final TcpDstCodec TCP_DST_CODEC = new TcpDstCodec();
+    public static final UdpSrcCodec UDP_SRC_CODEC = new UdpSrcCodec();
+    public static final UdpDstCodec UDP_DST_CODEC = new UdpDstCodec();
 }
diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpDstCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpDstCodec.java
new file mode 100644 (file)
index 0000000..38d3fd2
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2015 Hewlett-Packard Enterprise 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.match;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+
+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.openflowjava.nx.match.rev140421.NxmOfTcpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.tcp.dst.grouping.TcpDstValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpDstCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpDstCaseValueBuilder;
+
+/**
+ * @author Aswin Suryanarayanan.
+ */
+
+public class TcpDstCodec extends AbstractMatchCodec {
+
+    private static final int VALUE_LENGTH = 4;
+    private static final int NXM_FIELD_CODE = 10;
+    public static final MatchEntrySerializerKey<Nxm0Class, NxmOfTcpDst> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
+            EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfTcpDst.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
+            EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
+
+    @Override
+    public void serialize(MatchEntry input, ByteBuf outBuffer) {
+        serializeHeader(input, outBuffer);
+        TcpDstCaseValue tcpDstCase = ((TcpDstCaseValue) input.getMatchEntryValue());
+        outBuffer.writeShort(tcpDstCase.getTcpDstValues().getPort().getValue());
+        outBuffer.writeShort(tcpDstCase.getTcpDstValues().getMask());
+    }
+
+    @Override
+    public MatchEntry deserialize(ByteBuf message) {
+        MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
+        matchEntryBuilder.setHasMask(true);
+        int portNo = message.readUnsignedShort();
+        int mask = message.readUnsignedShort();
+        message.readBytes(mask);
+        TcpDstCaseValueBuilder caseBuilder = new TcpDstCaseValueBuilder();
+        TcpDstValuesBuilder tcpDstValuesBuilder = new TcpDstValuesBuilder();
+        tcpDstValuesBuilder.setPort(new PortNumber(portNo));
+        tcpDstValuesBuilder.setMask(portNo);
+        caseBuilder.setTcpDstValues(tcpDstValuesBuilder.build());
+        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
+        return matchEntryBuilder.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 NxmOfTcpDst.class;
+    }
+
+    @Override
+    public Class<? extends OxmClassBase> getOxmClass() {
+        return Nxm0Class.class;
+    }
+
+}
diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpSrcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpSrcCodec.java
new file mode 100644 (file)
index 0000000..5c48387
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2015 Hewlett-Packard Enterprise 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.match;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+
+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.openflowjava.nx.match.rev140421.NxmOfTcpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.tcp.src.grouping.TcpSrcValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpSrcCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpSrcCaseValueBuilder;
+
+/**
+ * @author Aswin Suryanarayanan.
+ */
+
+public class TcpSrcCodec extends AbstractMatchCodec {
+
+    private static final int VALUE_LENGTH = 4;
+    private static final int NXM_FIELD_CODE = 9;
+    public static final MatchEntrySerializerKey<Nxm0Class, NxmOfTcpSrc> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
+            EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfTcpSrc.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
+            EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
+
+    @Override
+    public void serialize(MatchEntry input, ByteBuf outBuffer) {
+        serializeHeader(input, outBuffer);
+        TcpSrcCaseValue tcpSrcCase = ((TcpSrcCaseValue) input.getMatchEntryValue());
+        outBuffer.writeShort(tcpSrcCase.getTcpSrcValues().getPort().getValue());
+        outBuffer.writeShort(tcpSrcCase.getTcpSrcValues().getMask());
+    }
+
+    @Override
+    public MatchEntry deserialize(ByteBuf message) {
+        MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
+        matchEntryBuilder.setHasMask(true);
+        int portNo = message.readUnsignedShort();
+        int mask = message.readUnsignedShort();
+        message.readBytes(mask);
+        TcpSrcCaseValueBuilder caseBuilder = new TcpSrcCaseValueBuilder();
+        TcpSrcValuesBuilder tcpSrcValuesBuilder = new TcpSrcValuesBuilder();
+        tcpSrcValuesBuilder.setPort(new PortNumber(portNo));
+        tcpSrcValuesBuilder.setMask(portNo);
+        caseBuilder.setTcpSrcValues(tcpSrcValuesBuilder.build());
+        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
+        return matchEntryBuilder.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 NxmOfTcpSrc.class;
+    }
+
+    @Override
+    public Class<? extends OxmClassBase> getOxmClass() {
+        return Nxm0Class.class;
+    }
+
+}
diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpDstCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpDstCodec.java
new file mode 100644 (file)
index 0000000..9347dcd
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2015 Hewlett-Packard Enterprise 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.match;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+
+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.openflowjava.nx.match.rev140421.NxmOfUdpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.udp.dst.grouping.UdpDstValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.UdpDstCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.UdpDstCaseValueBuilder;
+
+/**
+ * @author Aswin Suryanarayanan.
+ */
+
+public class UdpDstCodec extends AbstractMatchCodec {
+
+    private static final int VALUE_LENGTH = 4;
+    private static final int NXM_FIELD_CODE = 12;
+    public static final MatchEntrySerializerKey<Nxm0Class, NxmOfUdpDst> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
+            EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfUdpDst.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
+            EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
+
+    @Override
+    public void serialize(MatchEntry input, ByteBuf outBuffer) {
+        serializeHeader(input, outBuffer);
+        UdpDstCaseValue udpDstCase = ((UdpDstCaseValue) input.getMatchEntryValue());
+        outBuffer.writeShort(udpDstCase.getUdpDstValues().getPort().getValue());
+        outBuffer.writeShort(udpDstCase.getUdpDstValues().getMask());
+    }
+
+    @Override
+    public MatchEntry deserialize(ByteBuf message) {
+        MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
+        matchEntryBuilder.setHasMask(true);
+        int portNo = message.readUnsignedShort();
+        int mask = message.readUnsignedShort();
+        message.readBytes(mask);
+        UdpDstCaseValueBuilder caseBuilder = new UdpDstCaseValueBuilder();
+        UdpDstValuesBuilder udpDstValuesBuilder = new UdpDstValuesBuilder();
+        udpDstValuesBuilder.setPort(new PortNumber(portNo));
+        udpDstValuesBuilder.setMask(portNo);
+        caseBuilder.setUdpDstValues(udpDstValuesBuilder.build());
+        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
+        return matchEntryBuilder.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 NxmOfUdpDst.class;
+    }
+
+    @Override
+    public Class<? extends OxmClassBase> getOxmClass() {
+        return Nxm0Class.class;
+    }
+
+}
diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpSrcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpSrcCodec.java
new file mode 100644 (file)
index 0000000..44c2e64
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2015 Hewlett-Packard Enterprise 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.match;
+
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+
+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.openflowjava.nx.match.rev140421.NxmOfUdpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.udp.src.grouping.UdpSrcValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.UdpSrcCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.UdpSrcCaseValueBuilder;
+
+/**
+ * @author Aswin Suryanarayanan.
+ */
+
+public class UdpSrcCodec extends AbstractMatchCodec {
+
+    private static final int VALUE_LENGTH = 4;
+    private static final int NXM_FIELD_CODE = 11;
+    public static final MatchEntrySerializerKey<Nxm0Class, NxmOfUdpSrc> SERIALIZER_KEY = new MatchEntrySerializerKey<>(
+            EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfUdpSrc.class);
+    public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey(
+            EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE);
+
+    @Override
+    public void serialize(MatchEntry input, ByteBuf outBuffer) {
+        serializeHeader(input, outBuffer);
+        UdpSrcCaseValue udpSrcCase = ((UdpSrcCaseValue) input.getMatchEntryValue());
+        outBuffer.writeShort(udpSrcCase.getUdpSrcValues().getPort().getValue());
+        outBuffer.writeShort(udpSrcCase.getUdpSrcValues().getMask());
+    }
+
+    @Override
+    public MatchEntry deserialize(ByteBuf message) {
+        MatchEntryBuilder matchEntryBuilder = deserializeHeader(message);
+        matchEntryBuilder.setHasMask(true);
+        int portNo = message.readUnsignedShort();
+        int mask = message.readUnsignedShort();
+        message.readBytes(mask);
+        UdpSrcCaseValueBuilder caseBuilder = new UdpSrcCaseValueBuilder();
+        UdpSrcValuesBuilder udpSrcValuesBuilder = new UdpSrcValuesBuilder();
+        udpSrcValuesBuilder.setPort(new PortNumber(portNo));
+        udpSrcValuesBuilder.setMask(portNo);
+        caseBuilder.setUdpSrcValues(udpSrcValuesBuilder.build());
+        matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
+        return matchEntryBuilder.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 NxmOfUdpSrc.class;
+    }
+
+    @Override
+    public Class<? extends OxmClassBase> getOxmClass() {
+        return Nxm0Class.class;
+    }
+
+}
index 6cc1f148191ec531951ca8d1c4fcc299bc90bce6..79c98f4eabb0b42e4343faccf5376b9ed4bf624a 100644 (file)
@@ -3,13 +3,14 @@ module nicira-match {
 
     namespace "urn:opendaylight:openflowjava:nx:match";
     prefix "nicira-match";
-    
+
     import openflow-extensible-match {prefix ofoxm;}
     import openflow-types {prefix oft;}
     import ietf-yang-types {prefix yang; revision-date "2010-09-24";}
     import yang-ext {prefix ext; revision-date "2013-07-09";}
+    import ietf-inet-types {prefix inet; revision-date "2010-09-24";}
 
-    description 
+    description
         "Nicira openflow extensions of match.";
 
     revision "2014-04-21" {
@@ -95,6 +96,18 @@ module nicira-match {
     identity nxm-nx-nshc-4 {
         base ofoxm:match-field;
     }
+    identity nxm-of-tcp-src {
+        base ofoxm:match-field;
+    }
+    identity nxm-of-tcp-dst {
+        base ofoxm:match-field;
+    }
+    identity nxm-of-udp-src {
+        base ofoxm:match-field;
+    }
+    identity nxm-of-udp-dst {
+        base ofoxm:match-field;
+    }
 
     grouping ofj-nxm-nx-match-reg-grouping {
         container reg-values {
@@ -223,6 +236,46 @@ module nicira-match {
             uses ofj-nxm-nx-match-nshc-grouping;
         }
     }
+    grouping ofj-nxm-of-match-tcp-src-grouping {
+        container tcp-src-values {
+            leaf port {
+               type inet:port-number;
+            }
+            leaf mask {
+               type uint16;
+            }
+        }
+    }
+    grouping ofj-nxm-of-match-tcp-dst-grouping {
+        container tcp-dst-values {
+            leaf port {
+               type inet:port-number;
+            }
+            leaf mask {
+               type uint16;
+            }
+        }
+    }
+     grouping ofj-nxm-of-match-udp-src-grouping {
+        container udp-src-values {
+            leaf port {
+               type inet:port-number;
+            }
+            leaf mask {
+               type uint16;
+            }
+        }
+    }
+    grouping ofj-nxm-of-match-udp-dst-grouping {
+        container udp-dst-values {
+            leaf port {
+               type inet:port-number;
+            }
+            leaf mask {
+               type uint16;
+            }
+        }
+    }
 
     augment "/ofoxm:oxm-container/ofoxm:match-entry-value" {
         ext:augment-identifier "ofj-aug-nx-match";
@@ -281,6 +334,18 @@ module nicira-match {
         case nshc-4-case-value {
             uses ofj-nxm-nx-match-nshc-4-grouping;
         }
+        case tcp-src-case-value {
+            uses ofj-nxm-of-match-tcp-src-grouping;
+        }
+        case tcp-dst-case-value {
+            uses ofj-nxm-of-match-tcp-dst-grouping;
+        }
+        case udp-src-case-value {
+            uses ofj-nxm-of-match-udp-src-grouping;
+        }
+        case udp-dst-case-value {
+            uses ofj-nxm-of-match-udp-dst-grouping;
+        }
 
     }
 
index 929ff73d2680b0abcce4d08a5a5bb7198e033ff2..f9fcf81b999b1d772c049954533fe28b610251cd 100644 (file)
@@ -48,8 +48,12 @@ import org.opendaylight.openflowjava.nx.codec.match.Reg4Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg5Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg6Codec;
 import org.opendaylight.openflowjava.nx.codec.match.Reg7Codec;
+import org.opendaylight.openflowjava.nx.codec.match.TcpSrcCodec;
+import org.opendaylight.openflowjava.nx.codec.match.TcpDstCodec;
 import org.opendaylight.openflowjava.nx.codec.match.TunIdCodec;
 import org.opendaylight.openflowjava.nx.codec.match.TunIpv4SrcCodec;
+import org.opendaylight.openflowjava.nx.codec.match.UdpSrcCodec;
+import org.opendaylight.openflowjava.nx.codec.match.UdpDstCodec;
 import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
@@ -84,8 +88,12 @@ import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.N
 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.NsiConvertor;
 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.NspConvertor;
 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.RegConvertor;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.TcpDstConvertor;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.TcpSrcConvertor;
 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.TunIPv4SrcConvertor;
 import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.TunIdConvertor;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.UdpDstConvertor;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.UdpSrcConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath;
@@ -218,6 +226,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfEthDstKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfEthSrcKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfEthTypeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfTcpDstKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfTcpSrcKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpDstKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpSrcKey;
 import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -262,6 +274,10 @@ public class NiciraExtensionProvider implements AutoCloseable {
     private final static Nshc4Convertor NSC4_CONVERTOR = new Nshc4Convertor();
     private final static TunIPv4SrcConvertor TUN_IPV4_SRC_CONVERTOR = new TunIPv4SrcConvertor();
     private final static TunIPv4DstConvertor TUN_IPV4_DST_CONVERTOR = new TunIPv4DstConvertor();
+    private final static TcpSrcConvertor TCP_SRC_CONVERTOR = new TcpSrcConvertor();
+    private final static TcpDstConvertor TCP_DST_CONVERTOR = new TcpDstConvertor();
+    private final static UdpSrcConvertor UDP_SRC_CONVERTOR = new UdpSrcConvertor();
+    private final static UdpDstConvertor UDP_DST_CONVERTOR = new UdpDstConvertor();
 
     @Override
     public void close() {
@@ -468,6 +484,14 @@ public class NiciraExtensionProvider implements AutoCloseable {
         registrations.add(extensionConverterRegistrator.registerMatchConvertor(TunIpv4SrcCodec.SERIALIZER_KEY, TUN_IPV4_SRC_CONVERTOR));
         registrations.add(extensionConverterRegistrator.registerMatchConvertor(new ConverterExtensionKey<>(NxmNxTunIpv4DstKey.class, EncodeConstants.OF13_VERSION_ID), TUN_IPV4_DST_CONVERTOR));
         registrations.add(extensionConverterRegistrator.registerMatchConvertor(TunIpv4DstCodec.SERIALIZER_KEY, TUN_IPV4_DST_CONVERTOR));
+        registrations.add(extensionConverterRegistrator.registerMatchConvertor(new ConverterExtensionKey<>(NxmOfTcpSrcKey.class, EncodeConstants.OF13_VERSION_ID), TCP_SRC_CONVERTOR));
+        registrations.add(extensionConverterRegistrator.registerMatchConvertor(TcpSrcCodec.SERIALIZER_KEY, TCP_SRC_CONVERTOR));
+        registrations.add(extensionConverterRegistrator.registerMatchConvertor(new ConverterExtensionKey<>(NxmOfTcpDstKey.class, EncodeConstants.OF13_VERSION_ID), TCP_DST_CONVERTOR));
+        registrations.add(extensionConverterRegistrator.registerMatchConvertor(TcpDstCodec.SERIALIZER_KEY, TCP_DST_CONVERTOR));
+        registrations.add(extensionConverterRegistrator.registerMatchConvertor(new ConverterExtensionKey<>(NxmOfUdpSrcKey.class, EncodeConstants.OF13_VERSION_ID), UDP_SRC_CONVERTOR));
+        registrations.add(extensionConverterRegistrator.registerMatchConvertor(UdpSrcCodec.SERIALIZER_KEY, UDP_SRC_CONVERTOR));
+        registrations.add(extensionConverterRegistrator.registerMatchConvertor(new ConverterExtensionKey<>(NxmOfUdpDstKey.class, EncodeConstants.OF13_VERSION_ID), UDP_DST_CONVERTOR));
+        registrations.add(extensionConverterRegistrator.registerMatchConvertor(UdpDstCodec.SERIALIZER_KEY, UDP_DST_CONVERTOR));
     }
 
     /**
index 2a039b845fb912a7456d63642a98f0788c5f2eea..92d92e81f6a6198599f0cb74db95c93aaa015f83 100644 (file)
@@ -48,6 +48,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfEthDstGrouping;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfEthSrcGrouping;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfEthTypeGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfTcpDstGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfTcpSrcGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpDstGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpSrcGrouping;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 
 /**
@@ -95,6 +99,15 @@ public class MatchUtil {
             NxmNxNshc3Grouping.class);
     public final static GroupingResolver<NxmNxNshc4Grouping, Extension> nsc4Resolver = new GroupingResolver<>(
             NxmNxNshc4Grouping.class);
+    public final static GroupingResolver<NxmOfTcpSrcGrouping, Extension> tcpSrcResolver = new GroupingResolver<>(
+            NxmOfTcpSrcGrouping.class);
+    public final static GroupingResolver<NxmOfTcpDstGrouping, Extension> tcpDstResolver = new GroupingResolver<>(
+            NxmOfTcpDstGrouping.class);
+    public final static GroupingResolver<NxmOfUdpSrcGrouping, Extension> udpSrcResolver = new GroupingResolver<>(
+            NxmOfUdpSrcGrouping.class);
+    public final static GroupingResolver<NxmOfUdpDstGrouping, Extension> udpDstResolver = new GroupingResolver<>(
+            NxmOfUdpDstGrouping.class);
+
 
     static {
         augmentationsOfExtension.add(NxAugMatchRpcAddFlow.class);
@@ -123,6 +136,10 @@ public class MatchUtil {
         nsc2Resolver.setAugmentations(augmentationsOfExtension);
         nsc3Resolver.setAugmentations(augmentationsOfExtension);
         nsc4Resolver.setAugmentations(augmentationsOfExtension);
+        tcpSrcResolver.setAugmentations(augmentationsOfExtension);
+        tcpDstResolver.setAugmentations(augmentationsOfExtension);
+        udpSrcResolver.setAugmentations(augmentationsOfExtension);
+        udpDstResolver.setAugmentations(augmentationsOfExtension);
 
     }
 
diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TcpDstConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TcpDstConvertor.java
new file mode 100644 (file)
index 0000000..e37259c
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2015 Hewlett-Packard Enterprise 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.openflowplugin.extension.vendor.nicira.convertor.match;
+
+import com.google.common.base.Optional;
+
+import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava;
+import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
+import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketInBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemovedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifUpdateFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifUpdateFlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfTcpDstGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfTcpDstKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.tcp.dst.grouping.NxmOfTcpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.tcp.dst.grouping.NxmOfTcpDstBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.tcp.dst.grouping.TcpDstValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpDstCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpDstCaseValueBuilder;
+
+/**
+ * @author Aswin Suryanarayanan.
+ */
+public class TcpDstConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFromOFJava<MatchEntry, MatchPath> {
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava#convert
+     * (org.opendaylight.yangtools.yang.binding.DataContainer,
+     * org.opendaylight.openflowplugin.extension.api.path.AugmentationPath)
+     */
+    @Override
+    public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
+        TcpDstCaseValue tcpDstCaseValue = ((TcpDstCaseValue) input.getMatchEntryValue());
+        NxmOfTcpDstBuilder tcpDstBuilder = new NxmOfTcpDstBuilder();
+        tcpDstBuilder.setPort(tcpDstCaseValue.getTcpDstValues().getPort());
+        tcpDstBuilder.setMask(tcpDstCaseValue.getTcpDstValues().getMask());
+        return resolveAugmentation(tcpDstBuilder.build(), path,
+                NxmOfTcpDstKey.class);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava#convert
+     * (org
+     * .opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general
+     * .rev140714.general.extension.grouping.Extension)
+     */
+    @Override
+    public MatchEntry convert(Extension extension) {
+        Optional<NxmOfTcpDstGrouping> matchGrouping = MatchUtil.tcpDstResolver.getExtension(extension);
+        if (!matchGrouping.isPresent()) {
+            throw new CodecPreconditionException(extension);
+        }
+        TcpDstCaseValueBuilder tcpDstCaseValueBuilder = new TcpDstCaseValueBuilder();
+        TcpDstValuesBuilder tcpDstValuesBuilder = new TcpDstValuesBuilder();
+        tcpDstValuesBuilder.setPort(matchGrouping.get().getNxmOfTcpDst().getPort());
+        tcpDstValuesBuilder.setMask(matchGrouping.get().getNxmOfTcpDst().getMask());
+        tcpDstCaseValueBuilder.setTcpDstValues(tcpDstValuesBuilder.build());
+        MatchEntryBuilder ofMatch = MatchUtil
+                .createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn
+                                                .opendaylight.openflowjava.nx.match.rev140421.NxmOfTcpDst.class,
+                                                Nxm0Class.class, tcpDstCaseValueBuilder.build());
+        ofMatch.setHasMask(true);
+        return ofMatch.build();
+    }
+
+    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(NxmOfTcpDst value,
+                                                                   MatchPath path, Class<? extends ExtensionKey> key) {
+        switch (path) {
+            case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH:
+                return new ExtensionAugment<>(NxAugMatchNotifUpdateFlowStats.class,
+                        new NxAugMatchNotifUpdateFlowStatsBuilder().setNxmOfTcpDst(value).build(), key);
+            case PACKETRECEIVED_MATCH:
+                return new ExtensionAugment<>(NxAugMatchNotifPacketIn.class, new NxAugMatchNotifPacketInBuilder()
+                        .setNxmOfTcpDst(value).build(), key);
+            case SWITCHFLOWREMOVED_MATCH:
+                return new ExtensionAugment<>(NxAugMatchNotifSwitchFlowRemoved.class,
+                        new NxAugMatchNotifSwitchFlowRemovedBuilder().setNxmOfTcpDst(value).build(), key);
+            default:
+                throw new CodecPreconditionException(path);
+        }
+    }
+}
diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TcpSrcConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/TcpSrcConvertor.java
new file mode 100644 (file)
index 0000000..734b59e
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2015 Hewlett-Packard Enterprise 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.openflowplugin.extension.vendor.nicira.convertor.match;
+
+import com.google.common.base.Optional;
+
+import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava;
+import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
+import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketInBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemovedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifUpdateFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifUpdateFlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfTcpSrcGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfTcpSrcKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.tcp.src.grouping.NxmOfTcpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.tcp.src.grouping.NxmOfTcpSrcBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.tcp.src.grouping.TcpSrcValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpSrcCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpSrcCaseValueBuilder;
+
+/**
+ * @author Aswin Suryanarayanan.
+ */
+public class TcpSrcConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFromOFJava<MatchEntry, MatchPath> {
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava#convert
+     * (org.opendaylight.yangtools.yang.binding.DataContainer,
+     * org.opendaylight.openflowplugin.extension.api.path.AugmentationPath)
+     */
+    @Override
+    public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
+        TcpSrcCaseValue tcpSrcCaseValue = ((TcpSrcCaseValue) input.getMatchEntryValue());
+        NxmOfTcpSrcBuilder tcpSrcBuilder = new NxmOfTcpSrcBuilder();
+        tcpSrcBuilder.setPort(tcpSrcCaseValue.getTcpSrcValues().getPort());
+        tcpSrcBuilder.setMask(tcpSrcCaseValue.getTcpSrcValues().getMask());
+        return resolveAugmentation(tcpSrcBuilder.build(), path,
+                NxmOfTcpSrcKey.class);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava#convert
+     * (org
+     * .opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general
+     * .rev140714.general.extension.grouping.Extension)
+     */
+    @Override
+    public MatchEntry convert(Extension extension) {
+        Optional<NxmOfTcpSrcGrouping> matchGrouping = MatchUtil.tcpSrcResolver.getExtension(extension);
+        if (!matchGrouping.isPresent()) {
+            throw new CodecPreconditionException(extension);
+        }
+        TcpSrcCaseValueBuilder tcpSrcCaseValueBuilder = new TcpSrcCaseValueBuilder();
+        TcpSrcValuesBuilder tcpSrcValuesBuilder = new TcpSrcValuesBuilder();
+        tcpSrcValuesBuilder.setPort(matchGrouping.get().getNxmOfTcpSrc().getPort());
+        tcpSrcValuesBuilder.setMask(matchGrouping.get().getNxmOfTcpSrc().getMask());
+        tcpSrcCaseValueBuilder.setTcpSrcValues(tcpSrcValuesBuilder.build());
+        MatchEntryBuilder ofMatch = MatchUtil
+                .createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn
+                                                .opendaylight.openflowjava.nx.match.rev140421.NxmOfTcpSrc.class,
+                                                Nxm0Class.class, tcpSrcCaseValueBuilder.build());
+        ofMatch.setHasMask(true);
+        return ofMatch.build();
+    }
+
+    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(NxmOfTcpSrc value,
+                                                                   MatchPath path, Class<? extends ExtensionKey> key) {
+        switch (path) {
+            case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH:
+                return new ExtensionAugment<>(NxAugMatchNotifUpdateFlowStats.class,
+                        new NxAugMatchNotifUpdateFlowStatsBuilder().setNxmOfTcpSrc(value).build(), key);
+            case PACKETRECEIVED_MATCH:
+                return new ExtensionAugment<>(NxAugMatchNotifPacketIn.class, new NxAugMatchNotifPacketInBuilder()
+                        .setNxmOfTcpSrc(value).build(), key);
+            case SWITCHFLOWREMOVED_MATCH:
+                return new ExtensionAugment<>(NxAugMatchNotifSwitchFlowRemoved.class,
+                        new NxAugMatchNotifSwitchFlowRemovedBuilder().setNxmOfTcpSrc(value).build(), key);
+            default:
+                throw new CodecPreconditionException(path);
+        }
+    }
+}
diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpDstConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpDstConvertor.java
new file mode 100644 (file)
index 0000000..4016cb9
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2015 Hewlett-Packard Enterprise 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.openflowplugin.extension.vendor.nicira.convertor.match;
+
+import com.google.common.base.Optional;
+
+import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava;
+import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
+import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketInBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemovedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifUpdateFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifUpdateFlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpDstGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpDstKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.udp.dst.grouping.NxmOfUdpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.udp.dst.grouping.NxmOfUdpDstBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.udp.dst.grouping.UdpDstValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.UdpDstCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.UdpDstCaseValueBuilder;
+
+/**
+ * @author Aswin Suryanarayanan.
+ */
+public class UdpDstConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFromOFJava<MatchEntry, MatchPath> {
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava#convert
+     * (org.opendaylight.yangtools.yang.binding.DataContainer,
+     * org.opendaylight.openflowplugin.extension.api.path.AugmentationPath)
+     */
+    @Override
+    public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
+        UdpDstCaseValue udpDstCaseValue = ((UdpDstCaseValue) input.getMatchEntryValue());
+        NxmOfUdpDstBuilder udpDstBuilder = new NxmOfUdpDstBuilder();
+        udpDstBuilder.setPort(udpDstCaseValue.getUdpDstValues().getPort());
+        udpDstBuilder.setMask(udpDstCaseValue.getUdpDstValues().getMask());
+        return resolveAugmentation(udpDstBuilder.build(), path,
+                NxmOfUdpDstKey.class);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava#convert
+     * (org
+     * .opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general
+     * .rev140714.general.extension.grouping.Extension)
+     */
+    @Override
+    public MatchEntry convert(Extension extension) {
+        Optional<NxmOfUdpDstGrouping> matchGrouping = MatchUtil.udpDstResolver.getExtension(extension);
+        if (!matchGrouping.isPresent()) {
+            throw new CodecPreconditionException(extension);
+        }
+        UdpDstCaseValueBuilder udpDstCaseValueBuilder = new UdpDstCaseValueBuilder();
+        UdpDstValuesBuilder udpDstValuesBuilder = new UdpDstValuesBuilder();
+        udpDstValuesBuilder.setPort(matchGrouping.get().getNxmOfUdpDst().getPort());
+        udpDstValuesBuilder.setMask(matchGrouping.get().getNxmOfUdpDst().getMask());
+        udpDstCaseValueBuilder.setUdpDstValues(udpDstValuesBuilder.build());
+        MatchEntryBuilder ofMatch = MatchUtil
+                .createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight
+                                                .openflowjava.nx.match.rev140421.NxmOfUdpDst.class,
+                Nxm0Class.class,udpDstCaseValueBuilder.build());
+        ofMatch.setHasMask(true);
+        return ofMatch.build();
+    }
+
+    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(NxmOfUdpDst value,
+                                                                   MatchPath path, Class<? extends ExtensionKey> key) {
+        switch (path) {
+            case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH:
+                return new ExtensionAugment<>(NxAugMatchNotifUpdateFlowStats.class,
+                        new NxAugMatchNotifUpdateFlowStatsBuilder().setNxmOfUdpDst(value).build(), key);
+            case PACKETRECEIVED_MATCH:
+                return new ExtensionAugment<>(NxAugMatchNotifPacketIn.class, new NxAugMatchNotifPacketInBuilder()
+                        .setNxmOfUdpDst(value).build(), key);
+            case SWITCHFLOWREMOVED_MATCH:
+                return new ExtensionAugment<>(NxAugMatchNotifSwitchFlowRemoved.class,
+                        new NxAugMatchNotifSwitchFlowRemovedBuilder().setNxmOfUdpDst(value).build(), key);
+            default:
+                throw new CodecPreconditionException(path);
+        }
+    }
+}
diff --git a/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpSrcConvertor.java b/extension/openflowplugin-extension-nicira/src/main/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpSrcConvertor.java
new file mode 100644 (file)
index 0000000..0594115
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2015 Hewlett-Packard Enterprise 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.openflowplugin.extension.vendor.nicira.convertor.match;
+
+import com.google.common.base.Optional;
+
+import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava;
+import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
+import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketIn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketInBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemovedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifUpdateFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifUpdateFlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpSrcGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpSrcKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.udp.src.grouping.NxmOfUdpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.udp.src.grouping.NxmOfUdpSrcBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.udp.src.grouping.UdpSrcValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.UdpSrcCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.UdpSrcCaseValueBuilder;
+
+/**
+ * @author Aswin Suryanarayanan.
+ */
+public class UdpSrcConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFromOFJava<MatchEntry, MatchPath> {
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava#convert
+     * (org.opendaylight.yangtools.yang.binding.DataContainer,
+     * org.opendaylight.openflowplugin.extension.api.path.AugmentationPath)
+     */
+    @Override
+    public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
+        UdpSrcCaseValue udpSrcCaseValue = ((UdpSrcCaseValue) input.getMatchEntryValue());
+        NxmOfUdpSrcBuilder udpSrcBuilder = new NxmOfUdpSrcBuilder();
+        udpSrcBuilder.setPort(udpSrcCaseValue.getUdpSrcValues().getPort());
+        udpSrcBuilder.setMask(udpSrcCaseValue.getUdpSrcValues().getMask());
+        return resolveAugmentation(udpSrcBuilder.build(), path,
+                NxmOfUdpSrcKey.class);
+    }
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava#convert
+     * (org
+     * .opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general
+     * .rev140714.general.extension.grouping.Extension)
+     */
+    @Override
+    public MatchEntry convert(Extension extension) {
+        Optional<NxmOfUdpSrcGrouping> matchGrouping = MatchUtil.udpSrcResolver.getExtension(extension);
+        if (!matchGrouping.isPresent()) {
+            throw new CodecPreconditionException(extension);
+        }
+        UdpSrcCaseValueBuilder udpSrcCaseValueBuilder = new UdpSrcCaseValueBuilder();
+        UdpSrcValuesBuilder udpSrcValuesBuilder = new UdpSrcValuesBuilder();
+        udpSrcValuesBuilder.setPort(matchGrouping.get().getNxmOfUdpSrc().getPort());
+        udpSrcValuesBuilder.setMask(matchGrouping.get().getNxmOfUdpSrc().getMask());
+        udpSrcCaseValueBuilder.setUdpSrcValues(udpSrcValuesBuilder.build());
+        MatchEntryBuilder ofMatch = MatchUtil
+                .createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight
+                                                .openflowjava.nx.match.rev140421.NxmOfUdpSrc.class,
+                Nxm0Class.class, udpSrcCaseValueBuilder.build());
+        ofMatch.setHasMask(true);
+        return ofMatch.build();
+    }
+
+    private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(NxmOfUdpSrc value,
+                                                                   MatchPath path, Class<? extends ExtensionKey> key) {
+        switch (path) {
+            case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH:
+                return new ExtensionAugment<>(NxAugMatchNotifUpdateFlowStats.class,
+                        new NxAugMatchNotifUpdateFlowStatsBuilder().setNxmOfUdpSrc(value).build(), key);
+            case PACKETRECEIVED_MATCH:
+                return new ExtensionAugment<>(NxAugMatchNotifPacketIn.class, new NxAugMatchNotifPacketInBuilder()
+                        .setNxmOfUdpSrc(value).build(), key);
+            case SWITCHFLOWREMOVED_MATCH:
+                return new ExtensionAugment<>(NxAugMatchNotifSwitchFlowRemoved.class,
+                        new NxAugMatchNotifSwitchFlowRemovedBuilder().setNxmOfUdpSrc(value).build(), key);
+            default:
+                throw new CodecPreconditionException(path);
+        }
+    }
+}
index a20da32c277239422ac491cec5c3c7407e4174c4..3f0ce8137247fbfe1da078491994a7e22777f38a 100644 (file)
@@ -97,6 +97,18 @@ module openflowplugin-extension-nicira-match {
     identity nxm-nx-nshc-4-key {
         base ext-gen:extension-key;
     }
+    identity nxm-of-tcp-src-key {
+        base ext-gen:extension-key;
+    }
+    identity nxm-of-tcp-dst-key {
+        base ext-gen:extension-key;
+    }
+    identity nxm-of-udp-src-key {
+        base ext-gen:extension-key;
+    }
+    identity nxm-of-udp-dst-key {
+        base ext-gen:extension-key;
+    }
     grouping ipv4-address-grouping {
         leaf ipv4-address {
             type inet:ipv4-address;
@@ -151,6 +163,46 @@ module openflowplugin-extension-nicira-match {
             uses ipv4-address-grouping;
         }
     }
+    grouping nxm-of-tcp-src-grouping {
+        container nxm-of-tcp-src {
+            leaf port {
+               type inet:port-number;
+            }
+            leaf mask {
+               type uint16;
+            }
+        }
+    }
+    grouping nxm-of-tcp-dst-grouping {
+        container nxm-of-tcp-dst {
+            leaf port {
+                        type inet:port-number;
+            }
+            leaf mask {
+               type uint16;
+            }
+        }
+    }
+    grouping nxm-of-udp-src-grouping {
+        container nxm-of-udp-src {
+            leaf port {
+               type inet:port-number;
+            }
+            leaf mask {
+               type uint16;
+            }
+        }
+    }
+    grouping nxm-of-udp-dst-grouping {
+        container nxm-of-udp-dst {
+            leaf port {
+                        type inet:port-number;
+            }
+            leaf mask {
+               type uint16;
+            }
+        }
+    }
     grouping nxm-of-arp-tpa-grouping {
         container nxm-of-arp-tpa {
             description "Prereqs: NXM_OF_ETH_TYPE must match either 0x0806 or 0x8035.";
@@ -247,8 +299,12 @@ module openflowplugin-extension-nicira-match {
         uses nxm-nx-nshc-2-grouping;
         uses nxm-nx-nshc-3-grouping;
         uses nxm-nx-nshc-4-grouping;
+        uses nxm-of-tcp-src-grouping;
+        uses nxm-of-tcp-dst-grouping;
+        uses nxm-of-udp-src-grouping;
+        uses nxm-of-udp-dst-grouping;
     }
-    
+
     // MATCH augmentations
     // RPCS
     augment "/sal-flow:add-flow/sal-flow:input/sal-flow:match/ext-gen:extension-list/ext-gen:extension" {