add port adjacency message

Change-Id: If98ba9a368b01dd64927dde07b6ad5e96bd3f142
diff --git a/java_gen/java_type.py b/java_gen/java_type.py
index f9f5728..b14b72b 100644
--- a/java_gen/java_type.py
+++ b/java_gen/java_type.py
@@ -456,6 +456,10 @@
             .op(read='OFBitMask128.read16Bytes(bb)',
                 write='$name.write16Bytes(bb)',
                 default='OFBitMask128.NONE')
+port_bitmap_256 = JType('OFBitMask256') \
+            .op(read='OFBitMask256.read32Bytes(bb)',
+                write='$name.write32Bytes(bb)',
+                default='OFBitMask256.NONE')
 port_bitmap_512 = JType('OFBitMask512') \
             .op(read='OFBitMask512.read64Bytes(bb)',
                 write='$name.write64Bytes(bb)',
@@ -592,6 +596,7 @@
         'of_oxm_t': oxm,
         'of_meter_features_t': meter_features,
         'of_bitmap_128_t': port_bitmap_128,
+        'of_bitmap_256_t': port_bitmap_256,
         'of_bitmap_512_t': port_bitmap_512,
         'of_checksum_128_t': u128,
         'of_bsn_vport_t': bsn_vport,
@@ -662,6 +667,9 @@
 
         'of_oxm_bsn_in_ports_128' : { 'value': port_bitmap_128 },
         'of_oxm_bsn_in_ports_128_masked' : { 'value': port_bitmap_128, 'value_mask': port_bitmap_128 },
+        
+        'of_oxm_bsn_in_ports_256' : { 'value': port_bitmap_256 },
+        'of_oxm_bsn_in_ports_256_masked' : { 'value': port_bitmap_256, 'value_mask': port_bitmap_256 },
 
         'of_oxm_bsn_in_ports_512' : { 'value': port_bitmap_512 },
         'of_oxm_bsn_in_ports_512_masked' : { 'value': port_bitmap_512, 'value_mask': port_bitmap_512 },
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFBitMask256.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFBitMask256.java
new file mode 100644
index 0000000..5326e0d
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFBitMask256.java
@@ -0,0 +1,162 @@
+/**
+ *    Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
+ *    University
+ *
+ *    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.projectfloodlight.openflow.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+
+import com.google.common.hash.PrimitiveSink;
+
+/**
+ * Class defintion of 256 bits object for OpenFlow messages, including
+ * related methods.
+ */
+public class OFBitMask256 implements OFValueType<OFBitMask256> {
+
+    static final int LENGTH = 32;
+
+    private final long raw1;
+    private final long raw2;
+    private final long raw3;
+    private final long raw4;
+
+    public static final OFBitMask256 ALL = new OFBitMask256(-1, -1, -1, -1);
+    public static final OFBitMask256 NONE = new OFBitMask256(0, 0, 0, 0);
+
+    public static final OFBitMask256 NO_MASK = ALL;
+    public static final OFBitMask256 FULL_MASK = NONE;
+
+    private OFBitMask256(long raw1, long raw2, long raw3, long raw4) {
+        this.raw1 = raw1;
+        this.raw2 = raw2;
+        this.raw3 = raw3;
+        this.raw4 = raw4;
+    }
+
+    public static OFBitMask256 of(long raw1, long raw2, long raw3, long raw4) {
+        if (raw1 == -1 && raw2 == -1 && raw3 == -1 && raw4 == -1)
+            return ALL;
+        if (raw1 == 0 && raw2 == 0 && raw3 == 0 && raw4 == 0)
+            return NONE;
+        return new OFBitMask256(raw1, raw2, raw3, raw4);
+    }
+
+    @Override
+    public int getLength() {
+        return LENGTH;
+    }
+
+    @Override
+    public OFBitMask256 applyMask(OFBitMask256 mask) {
+        return of(this.raw1 & mask.raw1, this.raw2 & mask.raw2,
+                  this.raw3 & mask.raw3, this.raw4 & mask.raw4);
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (int) (raw1 ^ (raw1 >>> 32));
+        result = prime * result + (int) (raw2 ^ (raw2 >>> 32));
+        result = prime * result + (int) (raw3 ^ (raw3 >>> 32));
+        result = prime * result + (int) (raw4 ^ (raw4 >>> 32));
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) return true;
+        if (obj == null) return false;
+        if (getClass() != obj.getClass()) return false;
+        OFBitMask256 other = (OFBitMask256) obj;
+        if (raw1 != other.raw1) return false;
+        if (raw2 != other.raw2) return false;
+        if (raw3 != other.raw3) return false;
+        if (raw4 != other.raw4) return false;
+        return true;
+    }
+
+    protected static boolean isBitOn(long raw1, long raw2, long raw3, long raw4,
+                                     int bit) {
+        if (bit < 0 || bit >= 256)
+            throw new IndexOutOfBoundsException();
+        long word;
+        if (bit < 64) {
+            word = raw4;
+        } else if (bit < 128) {
+            word = raw3;
+            bit -= 64;
+        } else if (bit < 192) {
+            word = raw2;
+            bit -= 128;
+        } else {
+            word = raw1;
+            bit -= 192;
+        }
+        return (word & ((long)1 << bit)) != 0;
+    }
+
+    public void write32Bytes(ChannelBuffer cb) {
+        cb.writeLong(raw1);
+        cb.writeLong(raw2);
+        cb.writeLong(raw3);
+        cb.writeLong(raw4);
+    }
+
+    public static OFBitMask256 read32Bytes(ChannelBuffer cb) {
+        long raw1 = cb.readLong();
+        long raw2 = cb.readLong();
+        long raw3 = cb.readLong();
+        long raw4 = cb.readLong();
+        return of(raw1, raw2, raw3, raw4);
+    }
+
+    public boolean isOn(int bit) {
+        return isBitOn(raw1, raw2, raw3, raw4, bit);
+    }
+
+    @Override
+    public String toString() {
+        return (String.format("%64s", Long.toBinaryString(raw4))
+                + String.format("%64s", Long.toBinaryString(raw3))
+                + String.format("%64s", Long.toBinaryString(raw2))
+                + String.format("%64s", Long.toBinaryString(raw1))).replaceAll(" ", "0");
+    }
+
+    @Override
+    public int compareTo(OFBitMask256 o) {
+        long c = this.raw1 - o.raw1;
+        if (c != 0)
+            return Long.signum(c);
+        c = this.raw2 - o.raw2;
+        if (c != 0)
+            return Long.signum(c);
+        c = this.raw3 - o.raw3;
+        if (c != 0)
+            return Long.signum(c);
+        return Long.signum(this.raw4 - o.raw4);
+    }
+
+    @Override
+    public void putTo(PrimitiveSink sink) {
+        sink.putLong(raw1);
+        sink.putLong(raw2);
+        sink.putLong(raw3);
+        sink.putLong(raw4);
+    }
+
+}
diff --git a/loxi_ir/ir_offset.py b/loxi_ir/ir_offset.py
index 59d659a..b1cf785 100644
--- a/loxi_ir/ir_offset.py
+++ b/loxi_ir/ir_offset.py
@@ -114,6 +114,7 @@
     of_checksum_128_t = (16, True),
     of_app_code_t = (15,True),
     of_sig_id_t = (6, True),
+    of_bitmap_256_t = (32, True),
     of_bitmap_512_t = (64, True),
     of_odu_sig_id_t = (16, True),
     of_och_sig_id_t = (6, True),
diff --git a/openflow_input/optical_tras_ext b/openflow_input/optical_tras_ext
index ddb08df..1c4b1e8 100644
--- a/openflow_input/optical_tras_ext
+++ b/openflow_input/optical_tras_ext
@@ -16,11 +16,13 @@
 
 
 //enum ofp_experimenter_multipart_type_exp (wire_type=uint32_t){
-  //OFPEMPTE = 1,
+  //OFPEMPTE = 1, /*extended port discription */
+  //OFPEMPAD = 2, /*extended port adjacency discovery */
 //};
 
 //enum ofp_port_desc_prop_type_exp (wire_type=uint32_t){
  //OFPPDPT_OPTICAL_TRAMSPORT = 2,
+ //OFPPDPT_ADJACENCY_DISCOVERY = 3,
 //};
 
 /* Supported signal types for layer class OFPPOTL_PORT */
@@ -129,9 +131,33 @@
      of_och_sig_id_t value;   
 }; 
 
+// Optical transport protocol extensions request & reply head
+struct of_exp_optical_ext_request : of_experimenter_stats_request {
+    uint8_t version;
+    uint8_t type == 18;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t stats_type == 0xffff;
+    enum ofp_stats_request_flags flags;
+    pad(4);
+    uint32_t experimenter == 0xFF000007;
+    uint32_t subtype == ?;
+};
+
+struct of_exp_optical_ext_reply : of_experimenter_stats_reply {
+    uint8_t version;
+    uint8_t type == 19;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t stats_type == 0xffff;
+    enum ofp_stats_reply_flags flags;
+    pad(4);
+    uint32_t experimenter == 0xFF000007;
+    uint32_t subtype == ?;
+};
 
 // open flow extention - support port description Extentions for OTN Ports 
-struct of_exp_port_desc_request : of_experimenter_stats_request {
+struct of_exp_port_desc_request : of_exp_optical_ext_request {
     uint8_t version;
     uint8_t type == 18;
     uint16_t length;
@@ -143,7 +169,7 @@
     uint32_t subtype == 1;//enum ofp_experimenter_multipart_type exp_type == 1;
 };
 
-struct of_exp_port_desc_reply : of_experimenter_stats_reply {
+struct of_exp_port_desc_reply : of_exp_optical_ext_reply {
     uint8_t version;
     uint8_t type == 19;
     uint16_t length;
@@ -207,6 +233,99 @@
 };
 
 
+// open flow extention - support port adjacency extentions
+/* SubTLVs used for send, expected and received identity strings */
+//enum ofp_exp_ext_port_tlv_types (wire_type=uint8_t) {
+//     OFP_EXP_EXT_PORT_TLV_AD_ID_SENT = 2, //TTI to be send by the port 
+//     OFP_EXP_EXT_PORT_TLV_AD_ID_RECEIVED = 4, //TTI rcvd on port 
+//};
 
+/* used in state field in ofp_port */
+//enum ofp_port_state (wire_type=uint8_t) {
+//     OPPPS_AD_ID_MISMATCH = 1 << 16
+//};
 
+/* used in config field in ofp_port */
+//enum ofp_port_config {
+//    OFPPF_AD_ENABL = 1<< 16,
+//    OFPPF_AIS_AD_ID_MISMATCH = 1 << 17
+//};
 
+struct of_exp_port_adjacency_request : of_exp_optical_ext_request {
+    uint8_t version;
+    uint8_t type == 18;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t stats_type == 0xffff;
+    enum ofp_stats_request_flags flags;
+    pad(4);
+    uint32_t experimenter == 0xFF000007;
+    uint32_t subtype == 2;//enum ofp_experimenter_multipart_type exp_type == 2;
+};
+
+struct of_exp_port_adjacency_reply : of_exp_optical_ext_reply {
+    uint8_t version;
+    uint8_t type == 19;
+    uint16_t length;
+    uint32_t xid;
+    uint16_t stats_type == 0xffff;
+    enum ofp_stats_reply_flags flags;
+    pad(4);
+    uint32_t experimenter == 0xFF000007;
+    uint32_t subtype == 2;//enum ofp_experimenter_multipart_type subtype == 2;
+    list(of_exp_port_adjacency_t) entries;
+};
+
+//Port adjacency discovery property,
+//the body of ofp_experimenter_port in the spec.
+struct of_exp_port_adjacency {
+  of_port_no_t port_no;
+  uint16_t length;
+  pad(2);
+  of_mac_addr_t hw_addr;
+  pad(2);
+  of_port_name_t name;
+  enum ofp_port_config config;
+  enum ofp_port_state state;
+  list(of_exp_port_adjacency_id_t) properties;
+};
+
+//coresponding to ofp_port_desc_prop_adjacency_discovery in the spec
+//with adjecency id definition for otn network
+struct of_exp_port_adjacency_id
+{
+  uint16_t type == 3; //enum ofp_port_desc_prop_type_exp type == 3 
+  uint16_t length; // length in bytes of this property
+  list(of_exp_ext_ad_id_t) ad_id;
+};
+
+struct of_exp_ext_ad_id
+{
+  uint16_t type;//enum ofp_exp_ext_port_tlv_types type;
+  uint16_t length; // The TLV value field length.
+                   //defined as 8 + the length of id[] field
+  uint16_t namespace == 0; // One of OFPHTN*. OFPHTN_ONF = 0
+  uint16_t ns_type == ?; // type witin namespace
+};
+
+struct of_exp_port_adid_otn : of_exp_ext_ad_id
+{
+  uint16_t type; // ofp_exp_ext_port_tlv_types type;
+  uint16_t length; // The TLV value field length.
+                   //defined as 8 + the length of id[] field
+  uint16_t namespace == 0; // One of OFPHTN*. OFPHTN_ONF = 0
+  uint16_t ns_type == 0; // type witin namespace
+  of_bitmap_128_t sapi; //source asccess point identifier, ex.ITUT G.831
+  of_bitmap_128_t dapi; //destination asccess point identifier,ex. ITUT G.831
+  of_bitmap_256_t opspec;//Operator specific value, ex. ITUT G.7714
+};
+
+struct of_exp_ext_adid_sonet : of_exp_ext_ad_id
+{
+  uint16_t type; //enum ofp_exp_ext_port_tlv_types type;
+  uint16_t length; // The TLV value field length.
+                   //defined as 8 + the length of id[] field
+  uint16_t namespace == 0; // One of OFPHTN*. OFPHTN_ONF = 0
+  uint16_t ns_type == 1; // type witin namespace
+  of_bitmap_128_t id;
+};