/* Hey Emacs use -*- mode: C -*- */
/*
 * Copyright (c) 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.
 */

/**
 * @file
 *   This file defines the vpp control-plane API messages
 *   used to control the Source VRF select (SVS) plugin
 */

option version = "1.0.0";
import "vnet/ip/ip_types.api";

/**
 * brief Get the plugin version
 * @param client_index - opaque cookie to identify the sender
 *@param context - sender context, to match reply w/ request
 */
define svs_plugin_get_version
{
  u32 client_index;
  u32 context;
};

/**
 * @brief Reply to get the plugin version
 * @param context - returned sender context, to match reply w/ request
 * @param major - Incremented every time a known breaking behavior change is introduced
 * @param minor - Incremented with small changes, may be used to avoid buggy versions
 */
define svs_plugin_get_version_reply
{
  u32 context;
  u32 major;
  u32 minor;
};

/**
 * @brief Add a table in which to add routes that will match against source
 *        addresses
 * @param client_index - opaque cookie to identify the sender
 * @param context - sender context, to match reply w/ request
 * @param af - Address Family
 * @param table_id - User provided ID for the table
 * @param is_add - add or delete
 */
autoreply define svs_table_add_del
{
  u32 client_index;
  u32 context;
  u8 is_add;
  vl_api_address_family_t af;
  u32 table_id;
};

/**
 * @brief Add a route into the source address matching table
 * @param client_index - opaque cookie to identify the sender
 * @param context - sender context, to match reply w/ request
 * @param prefix - prefix
 * @param table_id - The SVS table (from svs_table_add_del)
 * @param source_table_id - This is the table ID that will be used for
 *                          the subsequent lookup of the packet. The V in SVS.
 *                          this table must exist (from e.g. ip_table_add_del)
 */
autoreply define svs_route_add_del
{
  u32 client_index;
  u32 context;
  u8 is_add;
  vl_api_prefix_t prefix;
  u32 table_id;
  u32 source_table_id;
};

/**
 * @brief Enable SVS on a given interface by using the given table to match
 *        RX'd packets' source addresses
 * @param client_index - opaque cookie to identify the sender
 * @param context - sender context, to match reply w/ request
 * @param af - Address Family
 * @param table_id - The SVS table (from svs_table_add_del)
 * @param sw_if_index - Interface
 */
autoreply define svs_enable_disable
{
  u32 client_index;
  u32 context;
  u8 is_enable;
  vl_api_address_family_t af;
  u32 table_id;
  u32 sw_if_index;
};

/**
 * @brief Dump the SVS table mappings of table_id to interface
 *        To see the routes added to a given table use ip_fib_dump()
 */
define svs_dump
{
  u32 client_index;
  u32 context;
};

/**
 * @brief SVS table-id to interface mapping
 * @param context - sender context, to match reply w/ request
 * @param af - Address Family
 * @param table_id - The SVS table (from svs_table_add_del)
 * @param sw_if_index - Interface
 */
define svs_details
{
  u32 context;
  u32 table_id;
  u32 sw_if_index;
  vl_api_address_family_t af;
};