// 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

enum ofp_bsn_vport_status {
    OF_BSN_VPORT_STATUS_OK = 0,
    OF_BSN_VPORT_STATUS_FAILED = 1,
};

// When the ingress or egress VID has this value, no outer tag should be used.
// In this case, the corresponding TPID is ignored.

enum ofp_bsn_vport_q_in_q_untagged(wire_type=uint16_t, complete=False) {
    OF_BSN_VPORT_Q_IN_Q_UNTAGGED = 0xffff,
};

enum ofp_bsn_vport_l2gre_flags(wire_type=uint32_t, bitmask=True) {
    OF_BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID = 0x1,

    /* DSCP flags are mutually exclusive */
    OF_BSN_VPORT_L2GRE_DSCP_ASSIGN = 0x2,
    OF_BSN_VPORT_L2GRE_DSCP_COPY = 0x4,
};

// BSN Virtual port object header
// FIXME For now, inheritance is not exercised.  See below.
struct of_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 */
};


// Q-in-Q virtual port specification

struct of_bsn_vport_q_in_q : of_bsn_vport {
    uint16_t type == 0;
    uint16_t length;
    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;
    of_port_name_t if_name;  /* Name to use in create operation */
};


// L2GRE tunnel virtual port specification

struct of_bsn_vport_l2gre : of_bsn_vport {
    uint16_t type == 1;
    uint16_t length;
    enum ofp_bsn_vport_l2gre_flags flags;
    of_port_no_t port_no;           /* OF port number of parent */
    of_port_no_t loopback_port_no;  /* OF port number of loopback */
    of_mac_addr_t local_mac;        /* Local MAC */
    of_mac_addr_t nh_mac;           /* Next Hop MAC */
    of_ipv4_t src_ip;               /* Source IP */
    of_ipv4_t dst_ip;               /* Destination IP */
    uint8_t dscp;
    uint8_t ttl;
    pad(2);
    uint32_t vpn;                   /* VPN ID (for GRE Key) */
    of_port_name_t if_name;         /* Virtual Interface Name */
};


// Request from controller to switch to create vport
struct of_bsn_virtual_port_create_request : of_bsn_header {
    uint8_t version;
    uint8_t type == 4;
    uint16_t length;
    uint32_t xid;
    uint32_t experimenter == 0x5c16c7;
    uint32_t subtype == 15;
    of_bsn_vport_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 of_bsn_virtual_port_create_reply : of_bsn_header {
    uint8_t version;
    uint8_t type == 4;
    uint16_t length;
    uint32_t xid;           // Must match create_request
    uint32_t experimenter == 0x5c16c7;
    uint32_t subtype == 16;
    uint32_t status;        // 0 means success
    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 of_bsn_virtual_port_remove_request : of_bsn_header {
    uint8_t version;
    uint8_t type == 4;
    uint16_t length;
    uint32_t xid;
    uint32_t experimenter == 0x5c16c7;
    uint32_t subtype == 17;
    uint32_t vport_no;      // The OF port number to be removed
};

// Request from controller to switch to remove a vport
struct of_bsn_virtual_port_remove_reply : of_bsn_header {
    uint8_t version;
    uint8_t type == 4;
    uint16_t length;
    uint32_t xid;           // Must match request xid
    uint32_t experimenter == 0x5c16c7;
    uint32_t subtype == 26;
    uint32_t status;        // 0 means success
};
