Added virtual port

Currently incomplete in that virtual port is not generic.  The
vport create command explicitly specifies q-in-q.  This is to
avoid some issues with loxi currently.
diff --git a/c_gen/c_test_gen.py b/c_gen/c_test_gen.py
index 3609f98..fe7a41d 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -92,7 +92,10 @@
         # Non-scalars; more TBD
         of_octets_t="octets",
         of_meter_features_t="features",
-        of_match_t="match")
+        of_match_t="match",
+        # BSN extensions
+        of_bsn_vport_q_in_q_t="vport",
+        )
 
     if m_type.find("of_list_") == 0:
         return "list"
diff --git a/c_gen/templates/loci_show.h b/c_gen/templates/loci_show.h
index 3d27827..91d3a57 100644
--- a/c_gen/templates/loci_show.h
+++ b/c_gen/templates/loci_show.h
@@ -109,6 +109,12 @@
 #define LOCI_SHOW_u8_ip_proto(writer, cookie, val)         LOCI_SHOW_u8(writer, cookie, val)
 #define LOCI_SHOW_u64_metadata(writer, cookie, val)        LOCI_SHOW_x64(writer, cookie, val)
 #define LOCI_SHOW_u8_enabled(writer, cookie, val)          LOCI_SHOW_u8(writer, cookie, val)
+#define LOCI_SHOW_u32_vport_no(writer, cookie, val)        LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u32_port_no(writer, cookie, val)         LOCI_SHOW_u32(writer, cookie, val)
+#define LOCI_SHOW_u16_ingress_tpid(writer, cookie, val)    LOCI_SHOW_x16(writer, cookie, val)
+#define LOCI_SHOW_u16_egress_tpid(writer, cookie, val)     LOCI_SHOW_x16(writer, cookie, val)
+#define LOCI_SHOW_u16_ingress_vlan_id(writer, cookie, val) LOCI_SHOW_u16(writer, cookie, val)
+#define LOCI_SHOW_u16_egress_vlan_id(writer, cookie, val)  LOCI_SHOW_u16(writer, cookie, val)
 
 
 
diff --git a/loxi_front_end/type_maps.py b/loxi_front_end/type_maps.py
index 5f58eb3..53334f7 100644
--- a/loxi_front_end/type_maps.py
+++ b/loxi_front_end/type_maps.py
@@ -227,6 +227,25 @@
         )
     }
 
+bsn_vport_types = {
+    # version 1.0
+    of_g.VERSION_1_0:dict(
+        q_in_q      = 0,
+        ),
+    # version 1.1
+    of_g.VERSION_1_1:dict(
+        q_in_q      = 0,
+        ),
+    # version 1.2
+    of_g.VERSION_1_2:dict(
+        q_in_q      = 0,
+        ),
+    # version 1.3
+    of_g.VERSION_1_3:dict(
+        q_in_q      = 0,
+        )
+    }
+
 oxm_types = {
     # version 1.0
     of_g.VERSION_1_0:dict(),
@@ -316,7 +335,9 @@
     of_queue_prop = queue_prop_types,
     of_hello_elem = hello_elem_types,
     of_table_feature_prop = table_feature_prop_types,
-    of_meter_band = meter_band_types
+    of_meter_band = meter_band_types,
+    # BSN specific inheritance extensions
+    of_bsn_vport = bsn_vport_types
     )
 
 ################################################################
@@ -784,21 +805,24 @@
     # version 1.0
     of_g.VERSION_1_0:dict(  # Version 1.0 extensions
         bsn = {   # BSN extensions; indexed by class name, value is subtype
-            "of_bsn_set_ip_mask"             : 0,
-            "of_bsn_get_ip_mask_request"     : 1,
-            "of_bsn_get_ip_mask_reply"       : 2,
-            "of_bsn_set_mirroring"           : 3,
-            "of_bsn_get_mirroring_request"   : 4,
-            "of_bsn_get_mirroring_reply"     : 5,
-            "of_bsn_shell_command"           : 6,
-            "of_bsn_shell_output"            : 7,
-            "of_bsn_shell_status"            : 8,
-            "of_bsn_get_interfaces_request"  : 9,
-            "of_bsn_get_interfaces_reply"    : 10,
-            "of_bsn_set_pktin_suppression"   : 11,
-            "of_bsn_set_l2_table"            : 12,
-            "of_bsn_get_l2_table_request"    : 13,
-            "of_bsn_get_l2_table_reply"      : 14,
+            "of_bsn_set_ip_mask"                     : 0,
+            "of_bsn_get_ip_mask_request"             : 1,
+            "of_bsn_get_ip_mask_reply"               : 2,
+            "of_bsn_set_mirroring"                   : 3,
+            "of_bsn_get_mirroring_request"           : 4,
+            "of_bsn_get_mirroring_reply"             : 5,
+            "of_bsn_shell_command"                   : 6,
+            "of_bsn_shell_output"                    : 7,
+            "of_bsn_shell_status"                    : 8,
+            "of_bsn_get_interfaces_request"          : 9,
+            "of_bsn_get_interfaces_reply"            : 10,
+            "of_bsn_set_pktin_suppression"           : 11,
+            "of_bsn_set_l2_table"                    : 12,
+            "of_bsn_get_l2_table_request"            : 13,
+            "of_bsn_get_l2_table_reply"              : 14,
+            "of_bsn_virtual_port_create_request"     : 15,
+            "of_bsn_virtual_port_create_reply"       : 16,
+            "of_bsn_virtual_port_remove"             : 17,
             },
         nicira = {   # Nicira extensions, value is subtype
             "of_nicira_controller_role_request"      : 10,
@@ -807,32 +831,41 @@
         ),
     of_g.VERSION_1_1:dict(  # Version 1.0 extensions
         bsn = {   # BSN extensions; indexed by class name, value is subtype
-            "of_bsn_set_mirroring"           : 3,
-            "of_bsn_get_mirroring_request"   : 4,
-            "of_bsn_get_mirroring_reply"     : 5,
-            "of_bsn_get_interfaces_request"  : 9,
-            "of_bsn_get_interfaces_reply"    : 10,
-            "of_bsn_set_pktin_suppression"   : 11,
+            "of_bsn_set_mirroring"                   : 3,
+            "of_bsn_get_mirroring_request"           : 4,
+            "of_bsn_get_mirroring_reply"             : 5,
+            "of_bsn_get_interfaces_request"          : 9,
+            "of_bsn_get_interfaces_reply"            : 10,
+            "of_bsn_set_pktin_suppression"           : 11,
+            "of_bsn_virtual_port_create_request"     : 15,
+            "of_bsn_virtual_port_create_reply"       : 16,
+            "of_bsn_virtual_port_remove"             : 17,
             },
         ),
     of_g.VERSION_1_2:dict(  # Version 1.0 extensions
         bsn = {   # BSN extensions; indexed by class name, value is subtype
-            "of_bsn_set_mirroring"           : 3,
-            "of_bsn_get_mirroring_request"   : 4,
-            "of_bsn_get_mirroring_reply"     : 5,
-            "of_bsn_get_interfaces_request"  : 9,
-            "of_bsn_get_interfaces_reply"    : 10,
-            "of_bsn_set_pktin_suppression"   : 11,
+            "of_bsn_set_mirroring"                   : 3,
+            "of_bsn_get_mirroring_request"           : 4,
+            "of_bsn_get_mirroring_reply"             : 5,
+            "of_bsn_get_interfaces_request"          : 9,
+            "of_bsn_get_interfaces_reply"            : 10,
+            "of_bsn_set_pktin_suppression"           : 11,
+            "of_bsn_virtual_port_create_request"     : 15,
+            "of_bsn_virtual_port_create_reply"       : 16,
+            "of_bsn_virtual_port_remove"             : 17,
             },
         ),
     of_g.VERSION_1_3:dict(  # Version 1.0 extensions
         bsn = {   # BSN extensions; indexed by class name, value is subtype
-            "of_bsn_set_mirroring"           : 3,
-            "of_bsn_get_mirroring_request"   : 4,
-            "of_bsn_get_mirroring_reply"     : 5,
-            "of_bsn_get_interfaces_request"  : 9,
-            "of_bsn_get_interfaces_reply"    : 10,
-            "of_bsn_set_pktin_suppression"   : 11,
+            "of_bsn_set_mirroring"                   : 3,
+            "of_bsn_get_mirroring_request"           : 4,
+            "of_bsn_get_mirroring_reply"             : 5,
+            "of_bsn_get_interfaces_request"          : 9,
+            "of_bsn_get_interfaces_reply"            : 10,
+            "of_bsn_set_pktin_suppression"           : 11,
+            "of_bsn_virtual_port_create_request"     : 15,
+            "of_bsn_virtual_port_create_reply"       : 16,
+            "of_bsn_virtual_port_remove"             : 17,
             },
         ),
 }
diff --git a/of_g.py b/of_g.py
index 046273c..db040f1 100644
--- a/of_g.py
+++ b/of_g.py
@@ -219,6 +219,13 @@
         4: "of_port_desc_t",
         "short_name":"port_desc"
         },
+    of_bsn_vport_t = {
+        1: "of_bsn_vport_t",
+        2: "of_bsn_vport_t",
+        3: "of_bsn_vport_t",
+        4: "of_bsn_vport_t",
+        "short_name":"bsn_vport"
+        },
     of_fm_cmd_t = { # Flow mod command went from u16 to u8
         1: "uint16_t",
         2: "uint8_t",
diff --git a/openflow_input/bsn_vport b/openflow_input/bsn_vport
new file mode 100644
index 0000000..f23219d
--- /dev/null
+++ b/openflow_input/bsn_vport
@@ -0,0 +1,89 @@
+// Copyright 2013, 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 2013, 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.
+
+#version any
+
+// BSN Virtual port object header
+// FIXME For now, inheritance is not exercised.  See below.
+struct ofp_bsn_vport {
+    uint16_t type;  /* Discriminate virtual port type */
+    uint16_t length; /* Length in bytes of this structure with this header */
+    /* Remainder of data is specific to the port type */
+};
+
+
+// When the ingress or egress VID has this value, no outer tag should be used.
+// In this case, the corresponding TPID is ignored.
+// #define OF_BSN_VPORT_Q_IN_Q_UNTAGGED 0xffff
+
+// Q-in-Q virtual port specification
+
+struct of_bsn_vport_q_in_q {
+    uint16_t type;    /* 0 */
+    uint16_t length;  /* 16 */
+    uint32_t port_no;     /* OF port number of parent; usually phys port */
+    uint16_t ingress_tpid;
+    uint16_t ingress_vlan_id;
+    uint16_t egress_tpid;
+    uint16_t egress_vlan_id;
+};
+
+// Request from controller to switch to create vport
+struct ofp_bsn_virtual_port_create_request {
+    uint8_t version;
+    uint8_t type;
+    uint16_t length;
+    uint32_t xid;
+    uint32_t experimenter;  // OF_EXPERIMENTER_ID_BSN
+    uint32_t subtype;       // BSN_VIRTUAL_PORT_CREATE_REQUEST
+    // FIXME This should be an instance of the inheritance superclass
+    of_bsn_vport_q_in_q_t vport;   // Description of vport to create
+    // Additional data follows depending on header type
+};
+
+// Reply from switch to controller indicating port number created
+// vport_no must be 16 bits to be compatible with 1.0
+struct ofp_bsn_virtual_port_create_reply {
+    uint8_t version;
+    uint8_t type;
+    uint16_t length;
+    uint32_t xid;           // Must match create_request
+    uint32_t experimenter;  // OF_EXPERIMENTER_ID_BSN
+    uint32_t subtype;       // BSN_VIRTUAL_PORT_CREATE_REPLY
+    uint32_t vport_no;      // The OF port number created.  16-bits for OF 1.0
+};
+
+// Request from controller to switch to remove a vport
+struct ofp_bsn_virtual_port_remove {
+    uint8_t version;
+    uint8_t type;
+    uint16_t length;
+    uint32_t xid;
+    uint32_t experimenter;  // OF_EXPERIMENTER_ID_BSN
+    uint32_t subtype;       // BSN_VIRTUAL_PORT_REMOVE
+    uint32_t vport_no;      // The OF port number to be removed
+};