/*
 * 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.0";

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


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

/** \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 {
  u32 client_index;
  u32 context;
  bool is_enable [default=true];
};

/** \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];
};

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