Merge branch 'master' of github.com:alshabib/loxigen into of14-pr
diff --git a/java_gen/java_type.py b/java_gen/java_type.py
index 12d6260..abd9e5b 100644
--- a/java_gen/java_type.py
+++ b/java_gen/java_type.py
@@ -360,10 +360,20 @@
         .op(read="IPv4Address.read4Bytes(bb)", \
             write="$name.write4Bytes(bb)",
             default='IPv4Address.NONE')
+ipv4_list =  JType('List<IPv4Address>') \
+        .op(read='ChannelUtils.readList(bb, $length, IPv4Address.READER)',
+            write='ChannelUtils.writeList(bb, $name)',
+            default='ImmutableList.<IPv4Address>of()',
+            funnel="FunnelUtils.putList($name, sink)")
 ipv6 = JType("IPv6Address") \
         .op(read="IPv6Address.read16Bytes(bb)", \
             write="$name.write16Bytes(bb)",
             default='IPv6Address.NONE')
+ipv6_list =  JType('List<IPv46ddress>') \
+        .op(read='ChannelUtils.readList(bb, $length, IPv6Address.READER)',
+            write='ChannelUtils.writeList(bb, $name)',
+            default='ImmutableList.<IPv6Address>of()',
+            funnel="FunnelUtils.putList($name, sink)")
 packetin_reason = gen_enum_jtype("OFPacketInReason")
 transport_port = JType("TransportPort")\
         .op(read="TransportPort.read2Bytes(bb)",
@@ -531,6 +541,8 @@
         'list(of_uint32_t)' : u32_list,
         'list(of_uint8_t)' : u8_list,
         'list(of_oxm_t)' : oxm_list,
+        'list(of_ipv4_t)' : ipv4_list,
+        'list(of_ipv6_t)' : ipv6_list,
         'of_octets_t' : octets,
         'of_match_t': of_match,
         'of_fm_cmd_t': flow_mod_cmd,
diff --git a/java_gen/pre-written/pom.xml b/java_gen/pre-written/pom.xml
index f45e39f..1c405ce 100644
--- a/java_gen/pre-written/pom.xml
+++ b/java_gen/pre-written/pom.xml
@@ -10,7 +10,7 @@
 
     <groupId>org.projectfloodlight</groupId>
     <artifactId>openflowj</artifactId>
-    <version>0.3.8-SNAPSHOT</version>
+    <version>0.4.0-SNAPSHOT</version>
     <packaging>jar</packaging>
 
     <name>OpenFlowJ-Loxi</name>
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
index 3a1b15e..eb37a20 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
@@ -12,14 +12,16 @@
 import com.google.common.hash.PrimitiveSink;
 import com.google.common.primitives.UnsignedInts;
 
-
+import org.projectfloodlight.openflow.protocol.Writeable;
+import org.projectfloodlight.openflow.protocol.OFMessageReader;
+import org.projectfloodlight.openflow.exceptions.OFParseError;
 
 /**
  * Wrapper around an IPv4Address address
  *
  * @author Andreas Wundsam <andreas.wundsam@bigswitch.com>
  */
-public class IPv4Address extends IPAddress<IPv4Address> {
+public class IPv4Address extends IPAddress<IPv4Address> implements Writeable {
     static final int LENGTH = 4;
     private final int rawValue;
 
@@ -38,6 +40,15 @@
         this.rawValue = rawValue;
     }
 
+    public final static Reader READER = new Reader();
+
+    private static class Reader implements OFMessageReader<IPv4Address> {
+        @Override
+        public IPv4Address readFrom(ChannelBuffer bb) throws OFParseError {
+            return new IPv4Address(bb.readInt());
+        }
+    }
+
     @Override
     public IPVersion getIpVersion() {
         return IPVersion.IPv4;
@@ -345,4 +356,8 @@
         sink.putInt(rawValue);
     }
 
+    @Override
+    public void writeTo(ChannelBuffer bb) {
+        bb.writeInt(rawValue);
+    }
 }
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
index 471d0fb..9d6fa4d 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
@@ -8,19 +8,22 @@
 import javax.annotation.Nonnull;
 
 import org.jboss.netty.buffer.ChannelBuffer;
-import org.projectfloodlight.openflow.exceptions.OFParseError;
 
 import com.google.common.base.Preconditions;
 import com.google.common.hash.PrimitiveSink;
 import com.google.common.primitives.Longs;
 
+import org.projectfloodlight.openflow.protocol.Writeable;
+import org.projectfloodlight.openflow.protocol.OFMessageReader;
+import org.projectfloodlight.openflow.exceptions.OFParseError;
+
 /**
  * IPv6 address object. Instance controlled, immutable. Internal representation:
  * two 64 bit longs (not that you'd have to know).
  *
  * @author Andreas Wundsam <andreas.wundsam@teleteach.de>
  */
-public class IPv6Address extends IPAddress<IPv6Address> {
+public class IPv6Address extends IPAddress<IPv6Address> implements Writeable {
     static final int LENGTH = 16;
     private final long raw1;
     private final long raw2;
@@ -43,6 +46,15 @@
         this.raw2 = raw2;
     }
 
+    public final static Reader READER = new Reader();
+
+    private static class Reader implements OFMessageReader<IPv6Address> {
+        @Override
+        public IPv6Address readFrom(ChannelBuffer bb) throws OFParseError {
+            return new IPv6Address(bb.readLong(), bb.readLong());
+        }
+    }
+
     @Override
     public IPVersion getIpVersion() {
         return IPVersion.IPv6;
@@ -213,8 +225,17 @@
     public static IPv6Address of(@Nonnull final String string) throws IllegalArgumentException {
         Preconditions.checkNotNull(string, "string must not be null");
 
+        // remove the zone id
+        int zoneDelimIndex = string.indexOf("%");
+        String substring;
+        if (zoneDelimIndex != -1) {
+            substring = string.substring(0, zoneDelimIndex);
+        } else {
+            substring = string;
+        }
+
         IPv6Builder builder = new IPv6Builder();
-        String[] parts = colonPattern.split(string, -1);
+        String[] parts = colonPattern.split(substring, -1);
 
         int leftWord = 0;
         int leftIndex = 0;
@@ -538,4 +559,10 @@
         sink.putLong(raw1);
         sink.putLong(raw2);
     }
+
+    @Override
+    public void writeTo(ChannelBuffer bb) {
+        bb.writeLong(raw1);
+        bb.writeLong(raw2);
+    }
 }
diff --git a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv6AddressTest.java b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv6AddressTest.java
index a397c2a..fd26856 100644
--- a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv6AddressTest.java
+++ b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv6AddressTest.java
@@ -399,4 +399,10 @@
             assertNotNull(e.getMessage());
         }
     }
+
+    @Test
+    public void testZoneId() throws OFParseError {
+        assertEquals("::", IPv6Address.of("::%eth0").toString(true, false));
+        assertEquals("1:0:0:4::8", IPv6Address.of("1:0:0:4:0:0:0:8%2").toString(true, false));
+    }
 }
diff --git a/openflow_input/bsn_span_destination b/openflow_input/bsn_span_destination
new file mode 100644
index 0000000..7fd900d
--- /dev/null
+++ b/openflow_input/bsn_span_destination
@@ -0,0 +1,40 @@
+// Copyright 2014, Big Switch Networks, Inc.
+//
+// LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+// the following special exception:
+//
+// LOXI Exception
+//
+// As a special exception to the terms of the EPL, you may distribute libraries
+// generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+// that copyright and licensing notices generated by LoxiGen are not altered or removed
+// from the LoxiGen Libraries and the notice provided below is (i) included in
+// the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+// documentation for the LoxiGen Libraries, if distributed in binary form.
+//
+// Notice: "Copyright 2014, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+//
+// You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+// a copy of the EPL at:
+//
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// 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
+// EPL for the specific language governing permissions and limitations
+// under the EPL.
+//
+// Also derived from the OpenFlow header files which have these copyrights:
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+
+#version 4
+
+struct of_instruction_bsn_span_destination : of_instruction_bsn {
+    uint16_t type == 65535;
+    uint16_t len;
+    uint32_t experimenter == 0x5c16c7;
+    uint32_t subtype == 10;
+    pad(4);
+};
diff --git a/openflow_input/bsn_tlv b/openflow_input/bsn_tlv
index 4113759..c4c8995 100644
--- a/openflow_input/bsn_tlv
+++ b/openflow_input/bsn_tlv
@@ -172,3 +172,39 @@
     uint16_t length;
     uint8_t value;
 };
+
+struct of_bsn_tlv_external_ip : of_bsn_tlv {
+    uint16_t type == 23;
+    uint16_t length;
+    of_ipv4_t value;
+};
+
+struct of_bsn_tlv_external_mac : of_bsn_tlv {
+    uint16_t type == 24;
+    uint16_t length;
+    of_mac_addr_t value;
+};
+
+struct of_bsn_tlv_external_netmask : of_bsn_tlv {
+    uint16_t type == 25;
+    uint16_t length;
+    of_ipv4_t value;
+};
+
+struct of_bsn_tlv_external_gateway_ip : of_bsn_tlv {
+    uint16_t type == 26;
+    uint16_t length;
+    of_ipv4_t value;
+};
+
+struct of_bsn_tlv_internal_mac : of_bsn_tlv {
+    uint16_t type == 27;
+    uint16_t length;
+    of_mac_addr_t value;
+};
+
+struct of_bsn_tlv_internal_gateway_mac : of_bsn_tlv {
+    uint16_t type == 28;
+    uint16_t length;
+    of_mac_addr_t value;
+};