/*
 * Copyright (c) 2015-2020 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 = "4.0.2";

import "vnet/interface_types.api";
import "vnet/ip/ip_types.api";


typedef sdl_rule
{
  vl_api_prefix_t lcl;
  u32 action_index;
  string tag[64];
};

typedef sdl_rule_v2
{
  vl_api_prefix_t rmt;
  u32 action_index;
  string tag[64];
};

enum transport_proto : u8
{
        TRANSPORT_PROTO_API_TCP,
        TRANSPORT_PROTO_API_UDP,
        TRANSPORT_PROTO_API_NONE,
        TRANSPORT_PROTO_API_TLS,
        TRANSPORT_PROTO_API_QUIC,
};

enum rt_backend_engine : u8
{
        RT_BACKEND_ENGINE_API_DISABLE = 0,
        RT_BACKEND_ENGINE_API_RULE_TABLE,
        RT_BACKEND_ENGINE_API_NONE,
        RT_BACKEND_ENGINE_API_SDL,
};

/** \brief Application attach to session layer
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param options - segment size, fifo sizes, etc.
    @param namespace_id - string
*/
 define app_attach {
    u32 client_index;
    u32 context;
    u64 options[18];
    string namespace_id[];
 };

/** \brief Application attach reply
    @param context - sender context, to match reply w/ request
    @param retval - return code for the request
    @param app_mq - app message queue
    @param vpp_ctrl_mq - vpp message queue for control events that should
    					 be handled in main thread, i.e., bind/connect
    @param vpp_ctrl_mq_thread_index - thread index of the ctrl mq
    @param app_index - index of the newly created app
    @param n_fds - number of fds exchanged
    @param fd_flags - set of flags that indicate which fds are to be expected
    				  over the socket (set only if socket transport available)
    @param segment_size - size of first shm segment
    @param segment_handle - handle for segment
    @param segment_name - name of segment client needs to attach to
*/
define app_attach_reply {
    u32 context;
    i32 retval;
    u64 app_mq;
    u64 vpp_ctrl_mq;
    u8 vpp_ctrl_mq_thread;
    u32 app_index;
    u8 n_fds;
    u8 fd_flags;
    u32 segment_size;
    u64 segment_handle;
    string segment_name[];
};

/** \brief Application detach from session layer
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
*/
autoreply define application_detach {
    u32 client_index;
    u32 context;
};

/** \brief Add certificate and key
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param engine - crypto engine
    @param cert_len - cert length (comes first)
    @param certkey_len - cert and key length
    @param certkey - cert & key data (due to API limitation)
*/
define app_add_cert_key_pair {
    u32 client_index;
    u32 context;
    u16 cert_len;
    u16 certkey_len;
    u8 certkey[certkey_len];
};

/** \brief Add certificate and key
    @param context - sender context, to match reply w/ request
    @param retval - return code for the request
    @param index - index in certificate store
*/
define app_add_cert_key_pair_reply {
    u32 context;
    i32 retval;
    u32 index;
};

/** \brief Delete certificate and key
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param index - index in certificate store
*/
autoreply define app_del_cert_key_pair {
    u32 client_index;
    u32 context;
    u32 index;
};

/** \brief add/del application worker
    @param client_index - opaque cookie to identify the sender
                          client to vpp direction only
    @param context - sender context, to match reply w/ request
    @param app_index - application index
    @param wrk_index - worker index, if a delete
    @param is_add - set if an add
*/
define app_worker_add_del
{
  u32 client_index;
  u32 context;
  u32 app_index;
  u32 wrk_index;
  bool is_add [default=true];
};

/** \brief Reply for app worker add/del
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
    @param wrk_index - worker index, if add
    @param app_event_queue_address - vpp event queue address of new worker
    @param n_fds - number of fds exchanged
    @param fd_flags - set of flags that indicate which fds are to be expected
    				  over the socket (set only if socket transport available)
    @param segment_handle - handle for segment
    @param is_add - add if non zero, else delete
    @param segment_name - name of segment client needs to attach to
*/
define app_worker_add_del_reply
{
  u32 context;
  i32 retval;
  u32 wrk_index;
  u64 app_event_queue_address;
  u8 n_fds;
  u8 fd_flags;
  u64 segment_handle;
  bool is_add [default=true];
  string segment_name[];
};

/** \brief enable/disable session layer
    @param client_index - opaque cookie to identify the sender
                          client to vpp direction only
    @param context - sender context, to match reply w/ request
    @param is_enable - disable session layer if 0, enable otherwise
*/
autoreply define session_enable_disable {
  option deprecated;
  u32 client_index;
  u32 context;
  bool is_enable [default=true];
};

autoreply define session_enable_disable_v2 {
  u32 client_index;
  u32 context;
  vl_api_rt_backend_engine_t rt_engine_type;
};

/** \brief enable/disable session layer socket api
    @param client_index - opaque cookie to identify the sender
                          client to vpp direction only
    @param context - sender context, to match reply w/ request
    @param is_enable - disable session layer if 0, enable otherwise
*/
autoreply define session_sapi_enable_disable {
  u32 client_index;
  u32 context;
  bool is_enable [default=true];
};

/** \brief add/del application namespace
    @param client_index - opaque cookie to identify the sender
                          client to vpp direction only
    @param context - sender context, to match reply w/ request
    @param secret - secret shared between app and vpp
    @param sw_if_index - local interface that "supports" namespace. Set to
                         ~0 if no preference
    @param ip4_fib_id - id of ip4 fib that "supports" the namespace. Ignored
                        if sw_if_index set.
    @param ip6_fib_id - id of ip6 fib that "supports" the namespace. Ignored
                        if sw_if_index set.
    @param namespace_id - namespace id
*/
define app_namespace_add_del {
  option deprecated;
  u32 client_index;
  u32 context;
  u64 secret;
  vl_api_interface_index_t sw_if_index [default=0xffffffff];
  u32 ip4_fib_id;
  u32 ip6_fib_id;
  string namespace_id[];
};

/** \brief add/del application namespace
    @param client_index - opaque cookie to identify the sender
                          client to vpp direction only
    @param context - sender context, to match reply w/ request
    @param secret - secret shared between app and vpp
    @param sw_if_index - local interface that "supports" namespace. Set to
                         ~0 if no preference
    @param ip4_fib_id - id of ip4 fib that "supports" the namespace. Ignored
                        if sw_if_index set.
    @param ip6_fib_id - id of ip6 fib that "supports" the namespace. Ignored
                        if sw_if_index set.
    @param namespace_id - namespace id
    @param sock_name - socket name (path, abstract socket name)
*/
define app_namespace_add_del_v4 {
  option deprecated;
  u32 client_index;
  u32 context;
  u64 secret;
  bool is_add [default=true];
  vl_api_interface_index_t sw_if_index [default=0xffffffff];
  u32 ip4_fib_id;
  u32 ip6_fib_id;
  string namespace_id[64];
  string sock_name[];
};

/** \brief Reply for app namespace add/del
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
    @param appns_index - app namespace index
*/
define app_namespace_add_del_v4_reply
{
  u32 context;
  i32 retval;
  u32 appns_index;
};

/** \brief add/del application namespace
    @param client_index - opaque cookie to identify the sender
                          client to vpp direction only
    @param context - sender context, to match reply w/ request
    @param secret - secret shared between app and vpp
    @param sw_if_index - local interface that "supports" namespace. Set to
                         ~0 if no preference
    @param ip4_fib_id - id of ip4 fib that "supports" the namespace. Ignored
                        if sw_if_index set.
    @param ip6_fib_id - id of ip6 fib that "supports" the namespace. Ignored
                        if sw_if_index set.
    @param namespace_id - namespace id
    @param netns - linux net namespace
*/
define app_namespace_add_del_v2 {
  option deprecated;
  u32 client_index;
  u32 context;
  u64 secret;
  vl_api_interface_index_t sw_if_index [default=0xffffffff];
  u32 ip4_fib_id;
  u32 ip6_fib_id;
  string namespace_id[64];
  string netns[64];
};

/** \brief add/del application namespace
    @param client_index - opaque cookie to identify the sender
                          client to vpp direction only
    @param context - sender context, to match reply w/ request
    @param secret - secret shared between app and vpp
    @param sw_if_index - local interface that "supports" namespace. Set to
                         ~0 if no preference
    @param ip4_fib_id - id of ip4 fib that "supports" the namespace. Ignored
                        if sw_if_index set.
    @param ip6_fib_id - id of ip6 fib that "supports" the namespace. Ignored
                        if sw_if_index set.
    @param namespace_id - namespace id
    @param netns - linux net namespace
    @param sock_name - socket name (path, abstract socket name)
*/
define app_namespace_add_del_v3 {
  option deprecated;
  u32 client_index;
  u32 context;
  u64 secret;
  bool is_add [default=true];
  vl_api_interface_index_t sw_if_index [default=0xffffffff];
  u32 ip4_fib_id;
  u32 ip6_fib_id;
  string namespace_id[64];
  string netns[64];
  string sock_name[];
};

/** \brief Reply for app namespace add/del
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
    @param appns_index - app namespace index
*/
define app_namespace_add_del_reply
{
  option deprecated;
  u32 context;
  i32 retval;
  u32 appns_index;
};

/** \brief Reply for app namespace add/del
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
    @param appns_index - app namespace index
*/
define app_namespace_add_del_v2_reply
{
  option deprecated;
  u32 context;
  i32 retval;
  u32 appns_index;
};

define app_namespace_add_del_v3_reply
{
  option deprecated;
  u32 context;
  i32 retval;
  u32 appns_index;
};

enum session_rule_scope {
	SESSION_RULE_SCOPE_API_GLOBAL = 0,
	SESSION_RULE_SCOPE_API_LOCAL = 1,
	SESSION_RULE_SCOPE_API_BOTH = 2,
};

/** \brief add/del session rule
    @param client_index - opaque cookie to identify the sender
                          client to vpp direction only
    @param context - sender context, to match reply w/ request
    @param transport_proto - transport protocol
    @param is_ip4 - flag to indicate if ip addresses are ip4 or 6
    @param lcl_ip - local ip
    @param lcl_plen - local prefix length
    @param rmt_ip - remote ip
    @param rmt_ple - remote prefix length
    @param lcl_port - local port
    @param rmt_port - remote port
    @param action_index - the only action defined now is forward to
                          application with index action_index
    @param is_add - flag to indicate if add or del
    @param appns_index - application namespace where rule is to be applied to
    @param scope - enum that indicates scope of the rule: global or local.
                   If 0, default is global, 1 is global 2 is local, 3 is both
    @param tag - tag
*/
autoreply define session_rule_add_del {
  u32 client_index;
  u32 context;
  vl_api_transport_proto_t transport_proto;
  vl_api_prefix_t lcl;
  vl_api_prefix_t rmt;
  u16 lcl_port;
  u16 rmt_port;
  u32 action_index;
  bool is_add [default=true];
  u32 appns_index;
  vl_api_session_rule_scope_t scope;
  string tag[64];
};

/** \brief Dump session rules
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
 */
define session_rules_dump
{
  u32 client_index;
  u32 context;
};

/** \brief Session rules details
    @param context - sender context, to match reply w/ request
    @param transport_proto - transport protocol
    @param is_ip4 - flag to indicate if ip addresses are ip4 or 6
    @param lcl_ip - local ip
    @param lcl_plen - local prefix length
    @param rmt_ip - remote ip
    @param rmt_ple - remote prefix length
    @param lcl_port - local port
    @param rmt_port - remote port
    @param action_index - the only action defined now is forward to
                          application with index action_index
    @param appns_index - application namespace where rule is to be applied to
    @param scope - enum that indicates scope of the rule: global or local.
                   If 0, default is global, 1 is global 2 is local, 3 is both
    @param tag - tag
  */
define session_rules_details
{
  u32 context;
  vl_api_transport_proto_t transport_proto;
  vl_api_prefix_t lcl;
  vl_api_prefix_t rmt;
  u16 lcl_port;
  u16 rmt_port;
  u32 action_index;
  u32 appns_index;
  vl_api_session_rule_scope_t scope;
  string tag[64];
};

autoreply define session_sdl_add_del {
  option deprecated;
  u32 client_index;
  u32 context;
  u32 appns_index;
  bool is_add;
  u32 count;
  vl_api_sdl_rule_t r[count];
};

autoreply define session_sdl_add_del_v2 {
  u32 client_index;
  u32 context;
  u32 appns_index;
  bool is_add;
  u32 count;
  vl_api_sdl_rule_v2_t r[count];
};

/** \brief Dump session sdl
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
 */
define session_sdl_dump
{
  option deprecated;
  u32 client_index;
  u32 context;
};

/** \brief Session sdl details
    @param context - sender context, to match reply w/ request
    @param lcl - local prefix
    @param action_index - the only action defined now is forward to
                          application with index action_index
    @param appns_index - application namespace where rule is to be applied to
    @param tag - tag
  */
define session_sdl_details
{
  option deprecated;
  u32 context;
  vl_api_prefix_t lcl;
  u32 action_index;
  u32 appns_index;
  string tag[64];
};

/** \brief Dump session sdl v2
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
 */
define session_sdl_v2_dump
{
  u32 client_index;
  u32 context;
};

/** \brief Session sdl details v2
    @param context - sender context, to match reply w/ request
    @param rmt - remote prefix
    @param action_index - the only action defined now is forward to
                          application with index action_index
    @param appns_index - application namespace where rule is to be applied to
    @param tag - tag
  */
define session_sdl_v2_details
{
  u32 context;
  vl_api_prefix_t rmt;
  u32 action_index;
  u32 appns_index;
  string tag[64];
};

/*
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
