34 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 41 #define foreach_session_api_msg \ 42 _(MAP_ANOTHER_SEGMENT_REPLY, map_another_segment_reply) \ 43 _(APPLICATION_ATTACH, application_attach) \ 44 _(APPLICATION_DETACH, application_detach) \ 45 _(BIND_URI, bind_uri) \ 46 _(UNBIND_URI, unbind_uri) \ 47 _(CONNECT_URI, connect_uri) \ 48 _(DISCONNECT_SESSION, disconnect_session) \ 49 _(DISCONNECT_SESSION_REPLY, disconnect_session_reply) \ 50 _(ACCEPT_SESSION_REPLY, accept_session_reply) \ 51 _(RESET_SESSION_REPLY, reset_session_reply) \ 52 _(BIND_SOCK, bind_sock) \ 53 _(UNBIND_SOCK, unbind_sock) \ 54 _(CONNECT_SOCK, connect_sock) \ 55 _(SESSION_ENABLE_DISABLE, session_enable_disable) \ 56 _(APP_NAMESPACE_ADD_DEL, app_namespace_add_del) \ 57 _(SESSION_RULE_ADD_DEL, session_rule_add_del) \ 58 _(SESSION_RULES_DUMP, session_rules_dump) \ 73 memset (mp, 0,
sizeof (*mp));
74 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_MAP_ANOTHER_SEGMENT);
76 strncpy ((
char *) mp->
segment_name, (
char *) segment_name,
101 memset (mp, 0,
sizeof (*mp));
103 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_ACCEPT_SESSION);
107 tc = tp_vft->get_connection (s->connection_index, s->thread_index);
123 mp->
port = tc->rmt_port;
144 memset (mp, 0,
sizeof (*mp));
145 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_DISCONNECT_SESSION);
163 memset (mp, 0,
sizeof (*mp));
164 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_RESET_SESSION);
186 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_CONNECT_SESSION_REPLY);
210 clib_host_to_net_u32 (VNET_API_ERROR_SESSION_CONNECT) : 0;
235 rv = VNET_API_ERROR_INVALID_VALUE;
242 rv = VNET_API_ERROR_INVALID_VALUE_2;
272 return VNET_API_ERROR_SESSION_REDIRECT;
280 rv = VNET_API_ERROR_QUEUE_FULL;
302 vl_api_session_enable_disable_reply_t *rmp;
320 rv = VNET_API_ERROR_FEATURE_DISABLED;
326 "Out of options, fix api message definition");
328 memset (a, 0,
sizeof (*a));
335 rv = VNET_API_ERROR_INVALID_VALUE;
360 if (a->segment_name_length)
362 memcpy (rmp->segment_name, a->segment_name,
363 a->segment_name_length);
364 rmp->segment_name_length = a->segment_name_length;
375 vl_api_application_detach_reply_t *rmp;
376 int rv = VNET_API_ERROR_INVALID_VALUE_2;
382 rv = VNET_API_ERROR_FEATURE_DISABLED;
389 a->app_index = app->index;
400 vl_api_bind_uri_reply_t *rmp;
407 rv = VNET_API_ERROR_FEATURE_DISABLED;
414 memset (a, 0,
sizeof (*a));
415 a->uri = (
char *) mp->
uri;
416 a->app_index = app->index;
421 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
431 vl_api_unbind_uri_reply_t *rmp;
438 rv = VNET_API_ERROR_FEATURE_DISABLED;
445 a->uri = (
char *) mp->
uri;
446 a->app_index = app->index;
451 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
469 rv = VNET_API_ERROR_FEATURE_DISABLED;
476 a->uri = (
char *) mp->
uri;
478 a->app_index = app->index;
483 if (rv != VNET_API_ERROR_SESSION_REDIRECT)
489 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
497 if (rv == 0 || rv == VNET_API_ERROR_SESSION_REDIRECT)
516 rv = VNET_API_ERROR_FEATURE_DISABLED;
524 a->app_index = app->index;
529 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
555 a->app_index = app->index;
565 u32 index, thread_index;
573 if (s == 0 || app->index != s->app_index)
595 u32 session_index, thread_index;
614 if (s->app_index != mp->
context)
640 ip46_address_t *ip46;
644 rv = VNET_API_ERROR_FEATURE_DISABLED;
651 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
655 ip46 = (ip46_address_t *) mp->
ip;
656 memset (a, 0,
sizeof (*a));
657 a->sep.is_ip4 = mp->
is_ip4;
659 a->sep.port = mp->
port;
660 a->sep.fib_index = mp->
vrf;
662 a->sep.transport_proto = mp->
proto;
663 a->app_index = app->index;
693 vl_api_unbind_sock_reply_t *rmp;
701 rv = VNET_API_ERROR_FEATURE_DISABLED;
708 a->app_index = app->index;
732 rv = VNET_API_ERROR_FEATURE_DISABLED;
740 ip46_address_t *ip46 = (ip46_address_t *) mp->
ip;
744 a->sep.is_ip4 = mp->
is_ip4;
746 a->sep.port = mp->
port;
747 a->sep.transport_proto = mp->
proto;
748 a->sep.fib_index = mp->
vrf;
751 a->app_index = app->index;
756 if (rv != VNET_API_ERROR_SESSION_REDIRECT)
762 rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
765 if (rv == 0 || rv == VNET_API_ERROR_SESSION_REDIRECT)
784 rv = VNET_API_ERROR_FEATURE_DISABLED;
790 rv = VNET_API_ERROR_INVALID_VALUE;
798 .secret = clib_net_to_host_u64 (mp->
secret),
799 .sw_if_index = clib_net_to_host_u32 (mp->
sw_if_index),
800 .ip4_fib_id = clib_net_to_host_u32 (mp->
ip4_fib_id),
801 .ip6_fib_id = clib_net_to_host_u32 (mp->
ip6_fib_id),
816 rv = VNET_API_ERROR_UNSPECIFIED;
825 rmp->
appns_index = clib_host_to_net_u32 (appns_index);
833 vl_api_session_rule_add_del_reply_t *rmp;
840 memset (&args, 0,
sizeof (args));
843 table_args->lcl.fp_len = mp->
lcl_plen;
844 table_args->lcl.fp_proto = fib_proto;
845 table_args->rmt.fp_len = mp->
rmt_plen;
846 table_args->rmt.fp_proto = fib_proto;
847 table_args->lcl_port = mp->
lcl_port;
848 table_args->rmt_port = mp->
rmt_port;
849 table_args->action_index = clib_net_to_host_u32 (mp->
action_index);
850 table_args->is_add = mp->
is_add;
851 mp->
tag[
sizeof (mp->
tag) - 1] = 0;
852 table_args->tag =
format (0,
"%s", mp->
tag);
853 args.appns_index = clib_net_to_host_u32 (mp->
appns_index);
854 args.scope = mp->
scope;
857 memset (&table_args->lcl.fp_addr, 0, sizeof (table_args->lcl.fp_addr));
858 memset (&table_args->rmt.fp_addr, 0, sizeof (table_args->rmt.fp_addr));
873 u8 transport_proto,
u32 appns_index,
u8 * tag,
877 session_mask_or_match_4_t *match =
878 (session_mask_or_match_4_t *) & rule->match;
879 session_mask_or_match_4_t *mask =
880 (session_mask_or_match_4_t *) & rule->mask;
883 memset (rmp, 0,
sizeof (*rmp));
884 rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS);
894 rmp->
action_index = clib_host_to_net_u32 (rule->action_index);
898 rmp->
appns_index = clib_host_to_net_u32 (appns_index);
910 u8 transport_proto,
u32 appns_index,
u8 * tag,
914 session_mask_or_match_6_t *match =
915 (session_mask_or_match_6_t *) & rule->match;
916 session_mask_or_match_6_t *mask =
917 (session_mask_or_match_6_t *) & rule->mask;
920 memset (rmp, 0,
sizeof (*rmp));
921 rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS);
931 rmp->
action_index = clib_host_to_net_u32 (rule->action_index);
935 rmp->
appns_index = clib_host_to_net_u32 (appns_index);
947 u8 tp,
u8 is_local,
u32 appns_index,
950 mma_rule_16_t *rule16;
951 mma_rule_40_t *rule40;
952 mma_rules_table_16_t *srt16;
953 mma_rules_table_40_t *srt40;
960 srt16 = &srt->session_rules_tables_16;
962 ri = mma_rules_table_rule_index_16 (srt16, rule16);
963 tag = session_rules_table_rule_tag (srt, ri, 1);
964 send_session_rule_details4 (rule16, is_local, tp, appns_index, tag,
973 srt40 = &srt->session_rules_tables_40;
975 ri = mma_rules_table_rule_index_40 (srt40, rule40);
976 tag = session_rules_table_rule_tag (srt, ri, 1);
977 send_session_rule_details6 (rule40, is_local, tp, appns_index, tag,
1000 st->active_fib_proto, tp,
1001 st->is_local, st->appns_index, q,
1015 a->app_index = app->index;
1023 #define vl_msg_name_crc_list 1025 #undef vl_msg_name_crc_list 1030 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); 1031 foreach_vl_msg_name_crc_session;
1048 vl_msg_api_set_handlers(VL_API_##N, #n, \ 1049 vl_api_##n##_t_handler, \ 1051 vl_api_##n##_t_endian, \ 1052 vl_api_##n##_t_print, \ 1053 sizeof(vl_api_##n##_t), 1);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static void vl_api_disconnect_session_reply_t_handler(vl_api_disconnect_session_reply_t *mp)
void * vl_msg_api_alloc_as_if_client(int nbytes)
#define APP_NAMESPACE_INVALID_INDEX
static clib_error_t * session_api_hookup(vlib_main_t *vm)
static stream_session_t * listen_session_get_from_handle(u64 handle)
clib_error_t * vnet_app_namespace_add_del(vnet_app_namespace_add_del_args_t *a)
vpp->client reset session API
VL_MSG_API_REAPER_FUNCTION(application_reaper_cb)
struct _session_rules_table_t session_rules_table_t
u8 application_has_global_scope(application_t *app)
struct _transport_connection transport_connection_t
u64 vpp_event_queue_address
struct _segment_manager_properties segment_manager_properties_t
struct _vnet_connect_args vnet_connect_args_t
static void send_session_rule_details4(mma_rule_16_t *rule, u8 is_local, u8 transport_proto, u32 appns_index, u8 *tag, unix_shared_memory_queue_t *q, u32 context)
int vnet_bind_uri(vnet_bind_args_t *a)
static void vl_api_app_namespace_add_del_t_handler(vl_api_app_namespace_add_del_t *mp)
void ip_set(ip46_address_t *dst, void *src, u8 is_ip4)
clib_error_t * vnet_unbind(vnet_unbind_args_t *a)
#define REPLY_MACRO2(t, body)
static f64 vlib_time_now(vlib_main_t *vm)
u8 * message_bounce
Don't automatically free message buffer vetor.
static void vl_api_map_another_segment_reply_t_handler(vl_api_map_another_segment_reply_t *mp)
struct _transport_proto_vft transport_proto_vft_t
Bind to an ip:port pair for a given transport protocol.
struct _vnet_app_namespace_add_del_args vnet_app_namespace_add_del_args_t
client->vpp, reply to an accept message
application_t * application_lookup(u32 api_client_index)
Request for map server summary status.
static void vl_api_unbind_sock_t_handler(vl_api_unbind_sock_t *mp)
transport_connection_t * session_get_transport(stream_session_t *s)
#define foreach_session_api_msg
static u8 session_manager_is_enabled()
int application_is_proxy(application_t *app)
clib_error_t * vnet_session_rule_add_del(session_rule_add_del_args_t *args)
static void vl_api_connect_uri_t_handler(vl_api_connect_uri_t *mp)
int vnet_unbind_uri(vnet_unbind_args_t *a)
static void vl_api_session_enable_disable_t_handler(vl_api_session_enable_disable_t *mp)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
struct _vnet_disconnect_args_t vnet_disconnect_args_t
static void send_session_reset_callback(stream_session_t *s)
struct _stream_session_cb_vft session_cb_vft_t
struct _vnet_unbind_args_t vnet_unbind_args_t
vpp/server->client, connect reply – used for all connect_* messages
add/del application namespace
void stream_session_cleanup(stream_session_t *s)
Cleanup transport and session state.
u32 app_namespace_index_from_id(const u8 *ns_id)
struct _stream_session_t stream_session_t
static uword pointer_to_uword(const void *p)
void * vl_msg_api_alloc(int nbytes)
struct _vnet_app_attach_args_t vnet_app_attach_args_t
transport_proto_vft_t * transport_protocol_get_vft(transport_proto_t transport_proto)
Get transport virtual function table.
int unix_shared_memory_queue_add(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
static transport_proto_t session_get_transport_proto(stream_session_t *s)
static void vl_api_session_rules_dump_t_handler(vl_api_one_map_server_dump_t *mp)
static void session_parse_handle(u64 handle, u32 *index, u32 *thread_index)
static session_cb_vft_t session_cb_vft
static void vl_api_accept_session_reply_t_handler(vl_api_accept_session_reply_t *mp)
struct _session_rule_add_del_args session_rule_add_del_args_t
client->vpp, attach application to session layer
static void vl_api_disconnect_session_t_handler(vl_api_disconnect_session_t *mp)
void vl_msg_api_free(void *)
stream_session_t * application_first_listener(application_t *app, u8 fib_proto, u8 transport_proto)
static clib_error_t * application_reaper_cb(u32 client_index)
clib_error_t * vnet_connect(vnet_connect_args_t *a)
static stream_session_t * session_get_if_valid(u64 si, u32 thread_index)
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
u64 vpp_event_queue_address
vpp->client, accept this session
u32 ip6_mask_to_preflen(ip6_address_t *mask)
int send_session_connected_callback(u32 app_index, u32 api_context, stream_session_t *s, u8 is_fail)
API main structure, used by both vpp and binary API clients.
static int send_session_accept_callback(stream_session_t *s)
static unix_shared_memory_queue_t * session_manager_get_vpp_event_queue(u32 thread_index)
#define vec_free(V)
Free vector's memory (no header).
#define ENDPOINT_INVALID_INDEX
#define clib_warning(format, args...)
static int redirect_connect_callback(u32 server_api_client_index, void *mp_arg)
Redirect a connect_uri message to the indicated server.
#define clib_memcpy(a, b, c)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
static u8 transport_connection_fib_proto(transport_connection_t *tc)
static void send_session_rules_table_details(session_rules_table_t *srt, u8 fib_proto, u8 tp, u8 is_local, u32 appns_index, unix_shared_memory_queue_t *q, u32 context)
u32 ip4_mask_to_preflen(ip4_address_t *mask)
struct _application application_t
int vnet_disconnect_session(vnet_disconnect_args_t *a)
Application attach reply.
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
enable/disable session layer
static void vl_api_connect_sock_t_handler(vl_api_connect_sock_t *mp)
clib_error_t * vnet_bind(vnet_bind_args_t *a)
Reply for app namespace add/del.
u64 app_event_queue_address
client->vpp, attach application to session layer
static void vl_api_bind_sock_t_handler(vl_api_bind_sock_t *mp)
vpp->client, please map an additional shared memory segment
#define clib_error_report(e)
struct _vnet_app_detach_args_t vnet_app_detach_args_t
Connect to a remote peer.
static vlib_main_t * vlib_get_main(void)
static void vl_api_application_attach_t_handler(vl_api_application_attach_t *mp)
static void setup_message_id_table(api_main_t *am)
bidirectional disconnect API
static u64 session_handle(stream_session_t *s)
clib_error_t * vnet_connect_uri(vnet_connect_args_t *a)
transport_connection_t * listen_session_get_transport(stream_session_t *s)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static stream_session_t * listen_session_get(session_type_t type, u32 index)
clib_error_t * vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
#define STATIC_ASSERT(truth,...)
application_t * application_get(u32 index)
#define clib_error_get_code(err)
VLIB_API_INIT_FUNCTION(session_api_hookup)
struct _session_lookup_table session_table_t
static int send_add_segment_callback(u32 api_client_index, const u8 *segment_name, u32 segment_size)
static void send_session_disconnect_callback(stream_session_t *s)
static void vl_api_application_detach_t_handler(vl_api_application_detach_t *mp)
struct _session_rules_table_add_del_args session_rule_table_add_del_args_t
#define session_table_foreach(VAR, BODY)
static void send_session_rule_details6(mma_rule_40_t *rule, u8 is_local, u8 transport_proto, u32 appns_index, u8 *tag, unix_shared_memory_queue_t *q, u32 context)
client->vpp reset session reply
static void vl_api_session_rule_add_del_t_handler(vl_api_session_rule_add_del_t *mp)
bidirectional disconnect reply API
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
struct _vnet_bind_args_t vnet_bind_args_t
static u64 listen_session_get_handle(stream_session_t *s)
static void vl_api_bind_uri_t_handler(vl_api_bind_uri_t *mp)
static void vl_api_reset_session_reply_t_handler(vl_api_reset_session_reply_t *mp)
struct _unix_shared_memory_queue unix_shared_memory_queue_t
segment_manager_properties_t * segment_manager_properties_get(u32 smp_index)
static void vl_api_unbind_uri_t_handler(vl_api_unbind_uri_t *mp)