/*
 * Copyright (c) 2015-2016 Cisco and/or its affiliates. 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.
 */

option version = "1.0.0";

/** \brief MPLS SR policy add
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param bsid is the bindingSID of the SR Policy. MPLS label (20bit)
    @param weight is the weight of the sid list. optional.
    @param type is the type of the SR policy. (0.Default // 1.Spray)
    @param segments vector of labels (20bit) composing the segment list
*/
autoreply define sr_mpls_policy_add
{
  u32 client_index;
  u32 context;
  u32 bsid;
  u32 weight;
  u8 type;
  u8 n_segments;
  u32 segments[n_segments];
};

/** \brief MPLS SR policy modification
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param bsid is the bindingSID of the SR Policy. MPLS label (20bit)
    @param sr_policy_index is the index of the SR policy
    @param fib_table is the VRF where to install the FIB entry for the BSID
    @param operation is the operation to perform (among the top ones)
    @param segments is a vector of MPLS labels composing the segment list
    @param sl_index is the index of the Segment List to modify/delete
    @param weight is the weight of the sid list. optional.
    @param is_encap Mode. Encapsulation or SRH insertion.
*/
autoreply define sr_mpls_policy_mod
{
  u32 client_index;
  u32 context;
  u32 bsid;
  u8 operation;
  u32 sl_index;
  u32 weight;
  u8 n_segments;
  u32 segments[n_segments];
};

/** \brief MPLS SR policy deletion
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param bsid is the bindingSID of the SR Policy. MPLS label (20bit)
*/
autoreply define sr_mpls_policy_del
{
  u32 client_index;
  u32 context;
  u32 bsid;
};

/** \brief MPLS SR steering add/del
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_del
    @param bsid is the bindingSID of the SR Policy (~0 is no bsid)
    @param table_id is the VRF where to install the FIB entry for the BSID
    @param prefix is the IPv4/v6 address for L3 traffic type. If IPv4 (first 4B).
    @param mask_width is the mask for L3 traffic type
    @param sw_if_index is the incoming interface for L2 traffic
    @param traffic_type describes the type of traffic
    @param next_hop describes the next_hop (in case no BSID)
    @param nh_type describes type of NH (IPv4=4, IPv6=6)
    @param color describes the color
    @param co_bits are the CO_bits of the steering policy
    @param vpn_label is an additonal last VPN label. (~0 is no label)
*/
autoreply define sr_mpls_steering_add_del
{
  u32 client_index;
  u32 context;
  u8 is_del;
  u32 bsid;
  u32 table_id;
  u8 prefix_addr[16];
  u32 mask_width;
  u8 traffic_type;
  u8 next_hop[16];
  u8 nh_type;
  u32 color;
  u8 co_bits;
  u32 vpn_label;
};

/** \brief MPLS SR steering add/del
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param bsid is the bindingSID of the SR Policy
    @param endpoint is the endpoint of the SR policy
    @param endpoint_type describes type of NH (IPv4=4, IPv6=6)
    @param color is the color of the sr policy
*/
autoreply define sr_mpls_policy_assign_endpoint_color
{
  u32 client_index;
  u32 context;
  u32 bsid;
  u8 endpoint[16];
  u8 endpoint_type;
  u32 color;
};

/*
 * fd.io coding-style-patch-verification: ON Local Variables: eval:
 * (c-set-style "gnu") End:
 */
