Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #include <vnet/vnet.h> |
| 17 | #include <vlibmemory/api.h> |
| 18 | #include <vnet/session/application.h> |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 19 | #include <vnet/session/application_interface.h> |
| 20 | #include <vnet/session/session_rules_table.h> |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 21 | #include <vnet/session/session_table.h> |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 22 | |
| 23 | #include <vnet/vnet_msg_enum.h> |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 24 | |
| 25 | #define vl_typedefs /* define message structures */ |
| 26 | #include <vnet/vnet_all_api_h.h> |
| 27 | #undef vl_typedefs |
| 28 | |
| 29 | #define vl_endianfun /* define message structures */ |
| 30 | #include <vnet/vnet_all_api_h.h> |
| 31 | #undef vl_endianfun |
| 32 | |
| 33 | /* instantiate all the print functions we know about */ |
| 34 | #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) |
| 35 | #define vl_printfun |
| 36 | #include <vnet/vnet_all_api_h.h> |
| 37 | #undef vl_printfun |
| 38 | |
| 39 | #include <vlibapi/api_helper_macros.h> |
| 40 | |
| 41 | #define foreach_session_api_msg \ |
| 42 | _(MAP_ANOTHER_SEGMENT_REPLY, map_another_segment_reply) \ |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 43 | _(APPLICATION_ATTACH, application_attach) \ |
| 44 | _(APPLICATION_DETACH, application_detach) \ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 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) \ |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 52 | _(BIND_SOCK, bind_sock) \ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 53 | _(UNBIND_SOCK, unbind_sock) \ |
| 54 | _(CONNECT_SOCK, connect_sock) \ |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 55 | _(SESSION_ENABLE_DISABLE, session_enable_disable) \ |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 56 | _(APP_NAMESPACE_ADD_DEL, app_namespace_add_del) \ |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 57 | _(SESSION_RULE_ADD_DEL, session_rule_add_del) \ |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 58 | _(SESSION_RULES_DUMP, session_rules_dump) \ |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 59 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 60 | static int |
| 61 | send_add_segment_callback (u32 api_client_index, const u8 * segment_name, |
| 62 | u32 segment_size) |
| 63 | { |
| 64 | vl_api_map_another_segment_t *mp; |
| 65 | unix_shared_memory_queue_t *q; |
| 66 | |
| 67 | q = vl_api_client_index_to_input_queue (api_client_index); |
| 68 | |
| 69 | if (!q) |
| 70 | return -1; |
| 71 | |
| 72 | mp = vl_msg_api_alloc (sizeof (*mp)); |
| 73 | memset (mp, 0, sizeof (*mp)); |
| 74 | mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_MAP_ANOTHER_SEGMENT); |
| 75 | mp->segment_size = segment_size; |
| 76 | strncpy ((char *) mp->segment_name, (char *) segment_name, |
| 77 | sizeof (mp->segment_name) - 1); |
| 78 | |
| 79 | vl_msg_api_send_shmem (q, (u8 *) & mp); |
| 80 | |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | static int |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 85 | send_session_accept_callback (stream_session_t * s) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 86 | { |
| 87 | vl_api_accept_session_t *mp; |
| 88 | unix_shared_memory_queue_t *q, *vpp_queue; |
| 89 | application_t *server = application_get (s->app_index); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 90 | transport_connection_t *tc; |
| 91 | transport_proto_vft_t *tp_vft; |
| 92 | stream_session_t *listener; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 93 | |
| 94 | q = vl_api_client_index_to_input_queue (server->api_client_index); |
| 95 | vpp_queue = session_manager_get_vpp_event_queue (s->thread_index); |
| 96 | |
| 97 | if (!q) |
| 98 | return -1; |
| 99 | |
| 100 | mp = vl_msg_api_alloc (sizeof (*mp)); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 101 | memset (mp, 0, sizeof (*mp)); |
| 102 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 103 | mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_ACCEPT_SESSION); |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 104 | mp->context = server->index; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 105 | listener = listen_session_get (s->session_type, s->listener_index); |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 106 | tp_vft = transport_protocol_get_vft (s->session_type); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 107 | tc = tp_vft->get_connection (s->connection_index, s->thread_index); |
| 108 | mp->listener_handle = listen_session_get_handle (listener); |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 109 | mp->handle = session_handle (s); |
Damjan Marion | 7bee80c | 2017-04-26 15:32:12 +0200 | [diff] [blame] | 110 | mp->server_rx_fifo = pointer_to_uword (s->server_rx_fifo); |
| 111 | mp->server_tx_fifo = pointer_to_uword (s->server_tx_fifo); |
| 112 | mp->vpp_event_queue_address = pointer_to_uword (vpp_queue); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 113 | mp->port = tc->rmt_port; |
| 114 | mp->is_ip4 = tc->is_ip4; |
| 115 | clib_memcpy (&mp->ip, &tc->rmt_ip, sizeof (tc->rmt_ip)); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 116 | vl_msg_api_send_shmem (q, (u8 *) & mp); |
| 117 | |
| 118 | return 0; |
| 119 | } |
| 120 | |
| 121 | static void |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 122 | send_session_disconnect_callback (stream_session_t * s) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 123 | { |
| 124 | vl_api_disconnect_session_t *mp; |
| 125 | unix_shared_memory_queue_t *q; |
| 126 | application_t *app = application_get (s->app_index); |
| 127 | |
| 128 | q = vl_api_client_index_to_input_queue (app->api_client_index); |
| 129 | |
| 130 | if (!q) |
| 131 | return; |
| 132 | |
| 133 | mp = vl_msg_api_alloc (sizeof (*mp)); |
| 134 | memset (mp, 0, sizeof (*mp)); |
| 135 | mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_DISCONNECT_SESSION); |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 136 | mp->handle = session_handle (s); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 137 | vl_msg_api_send_shmem (q, (u8 *) & mp); |
| 138 | } |
| 139 | |
Florin Coras | d79b41e | 2017-03-04 05:37:52 -0800 | [diff] [blame] | 140 | static void |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 141 | send_session_reset_callback (stream_session_t * s) |
Florin Coras | d79b41e | 2017-03-04 05:37:52 -0800 | [diff] [blame] | 142 | { |
| 143 | vl_api_reset_session_t *mp; |
| 144 | unix_shared_memory_queue_t *q; |
| 145 | application_t *app = application_get (s->app_index); |
| 146 | |
| 147 | q = vl_api_client_index_to_input_queue (app->api_client_index); |
| 148 | |
| 149 | if (!q) |
| 150 | return; |
| 151 | |
| 152 | mp = vl_msg_api_alloc (sizeof (*mp)); |
| 153 | memset (mp, 0, sizeof (*mp)); |
| 154 | mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_RESET_SESSION); |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 155 | mp->handle = session_handle (s); |
Florin Coras | d79b41e | 2017-03-04 05:37:52 -0800 | [diff] [blame] | 156 | vl_msg_api_send_shmem (q, (u8 *) & mp); |
| 157 | } |
| 158 | |
Dave Barach | 0194f1a | 2017-05-15 10:11:39 -0400 | [diff] [blame] | 159 | int |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 160 | send_session_connected_callback (u32 app_index, u32 api_context, |
| 161 | stream_session_t * s, u8 is_fail) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 162 | { |
Dave Wallace | 33e002b | 2017-09-06 01:20:02 -0400 | [diff] [blame] | 163 | vl_api_connect_session_reply_t *mp; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 164 | unix_shared_memory_queue_t *q; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 165 | application_t *app; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 166 | unix_shared_memory_queue_t *vpp_queue; |
Florin Coras | ade70e4 | 2017-10-14 18:56:41 -0700 | [diff] [blame] | 167 | transport_connection_t *tc; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 168 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 169 | app = application_get (app_index); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 170 | q = vl_api_client_index_to_input_queue (app->api_client_index); |
| 171 | |
| 172 | if (!q) |
| 173 | return -1; |
| 174 | |
| 175 | mp = vl_msg_api_alloc (sizeof (*mp)); |
Dave Wallace | 33e002b | 2017-09-06 01:20:02 -0400 | [diff] [blame] | 176 | mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_CONNECT_SESSION_REPLY); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 177 | mp->context = api_context; |
Dave Wallace | 965fec9 | 2017-10-17 16:19:41 -0400 | [diff] [blame] | 178 | |
| 179 | if (is_fail) |
| 180 | goto done; |
| 181 | |
| 182 | tc = session_get_transport (s); |
| 183 | if (!tc) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 184 | { |
Dave Wallace | 965fec9 | 2017-10-17 16:19:41 -0400 | [diff] [blame] | 185 | is_fail = 1; |
| 186 | goto done; |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 187 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 188 | |
Dave Wallace | 965fec9 | 2017-10-17 16:19:41 -0400 | [diff] [blame] | 189 | vpp_queue = session_manager_get_vpp_event_queue (s->thread_index); |
| 190 | mp->server_rx_fifo = pointer_to_uword (s->server_rx_fifo); |
| 191 | mp->server_tx_fifo = pointer_to_uword (s->server_tx_fifo); |
| 192 | mp->handle = session_handle (s); |
| 193 | mp->vpp_event_queue_address = pointer_to_uword (vpp_queue); |
| 194 | clib_memcpy (mp->lcl_ip, &tc->lcl_ip, sizeof (tc->lcl_ip)); |
| 195 | mp->is_ip4 = tc->is_ip4; |
| 196 | mp->lcl_port = tc->lcl_port; |
| 197 | |
| 198 | done: |
| 199 | mp->retval = is_fail ? |
| 200 | clib_host_to_net_u32 (VNET_API_ERROR_SESSION_CONNECT) : 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 201 | vl_msg_api_send_shmem (q, (u8 *) & mp); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Redirect a connect_uri message to the indicated server. |
| 207 | * Only sent if the server has bound the related port with |
| 208 | * URI_OPTIONS_FLAGS_USE_FIFO |
| 209 | */ |
| 210 | static int |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 211 | redirect_connect_callback (u32 server_api_client_index, void *mp_arg) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 212 | { |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 213 | vl_api_connect_sock_t *mp = mp_arg; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 214 | unix_shared_memory_queue_t *server_q, *client_q; |
Florin Coras | ad0c77f | 2017-11-09 18:00:15 -0800 | [diff] [blame] | 215 | segment_manager_properties_t *props; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 216 | vlib_main_t *vm = vlib_get_main (); |
| 217 | f64 timeout = vlib_time_now (vm) + 0.5; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 218 | application_t *app; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 219 | int rv = 0; |
| 220 | |
| 221 | server_q = vl_api_client_index_to_input_queue (server_api_client_index); |
| 222 | |
| 223 | if (!server_q) |
| 224 | { |
| 225 | rv = VNET_API_ERROR_INVALID_VALUE; |
| 226 | goto out; |
| 227 | } |
| 228 | |
| 229 | client_q = vl_api_client_index_to_input_queue (mp->client_index); |
| 230 | if (!client_q) |
| 231 | { |
| 232 | rv = VNET_API_ERROR_INVALID_VALUE_2; |
| 233 | goto out; |
| 234 | } |
| 235 | |
| 236 | /* Tell the server the client's API queue address, so it can reply */ |
Damjan Marion | 7bee80c | 2017-04-26 15:32:12 +0200 | [diff] [blame] | 237 | mp->client_queue_address = pointer_to_uword (client_q); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 238 | app = application_lookup (mp->client_index); |
Florin Coras | 82b13a8 | 2017-04-25 11:58:06 -0700 | [diff] [blame] | 239 | if (!app) |
| 240 | { |
| 241 | clib_warning ("no client application"); |
| 242 | return -1; |
| 243 | } |
| 244 | |
Florin Coras | ad0c77f | 2017-11-09 18:00:15 -0800 | [diff] [blame] | 245 | props = segment_manager_properties_get (app->sm_properties); |
| 246 | mp->options[SESSION_OPTIONS_RX_FIFO_SIZE] = props->rx_fifo_size; |
| 247 | mp->options[SESSION_OPTIONS_TX_FIFO_SIZE] = props->tx_fifo_size; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 248 | |
| 249 | /* |
| 250 | * Bounce message handlers MUST NOT block the data-plane. |
| 251 | * Spin waiting for the queue lock, but |
| 252 | */ |
| 253 | |
| 254 | while (vlib_time_now (vm) < timeout) |
| 255 | { |
| 256 | rv = |
| 257 | unix_shared_memory_queue_add (server_q, (u8 *) & mp, 1 /*nowait */ ); |
| 258 | switch (rv) |
| 259 | { |
| 260 | /* correctly enqueued */ |
| 261 | case 0: |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 262 | return VNET_API_ERROR_SESSION_REDIRECT; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 263 | |
| 264 | /* continue spinning, wait for pthread_mutex_trylock to work */ |
| 265 | case -1: |
| 266 | continue; |
| 267 | |
| 268 | /* queue stuffed, drop the msg */ |
| 269 | case -2: |
| 270 | rv = VNET_API_ERROR_QUEUE_FULL; |
| 271 | goto out; |
| 272 | } |
| 273 | } |
| 274 | out: |
| 275 | /* Dispose of the message */ |
| 276 | vl_msg_api_free (mp); |
| 277 | return rv; |
| 278 | } |
| 279 | |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 280 | static session_cb_vft_t session_cb_vft = { |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 281 | .session_accept_callback = send_session_accept_callback, |
| 282 | .session_disconnect_callback = send_session_disconnect_callback, |
| 283 | .session_connected_callback = send_session_connected_callback, |
Florin Coras | d79b41e | 2017-03-04 05:37:52 -0800 | [diff] [blame] | 284 | .session_reset_callback = send_session_reset_callback, |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 285 | .add_segment_callback = send_add_segment_callback, |
| 286 | .redirect_connect_callback = redirect_connect_callback |
| 287 | }; |
| 288 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 289 | static void |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 290 | vl_api_session_enable_disable_t_handler (vl_api_session_enable_disable_t * mp) |
| 291 | { |
| 292 | vl_api_session_enable_disable_reply_t *rmp; |
| 293 | vlib_main_t *vm = vlib_get_main (); |
| 294 | int rv = 0; |
| 295 | |
| 296 | vnet_session_enable_disable (vm, mp->is_enable); |
| 297 | REPLY_MACRO (VL_API_SESSION_ENABLE_DISABLE_REPLY); |
| 298 | } |
| 299 | |
| 300 | static void |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 301 | vl_api_application_attach_t_handler (vl_api_application_attach_t * mp) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 302 | { |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 303 | vl_api_application_attach_reply_t *rmp; |
| 304 | vnet_app_attach_args_t _a, *a = &_a; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 305 | clib_error_t *error = 0; |
| 306 | int rv = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 307 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 308 | if (session_manager_is_enabled () == 0) |
| 309 | { |
| 310 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 311 | goto done; |
| 312 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 313 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 314 | STATIC_ASSERT (sizeof (u64) * SESSION_OPTIONS_N_OPTIONS <= |
| 315 | sizeof (mp->options), |
| 316 | "Out of options, fix api message definition"); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 317 | |
| 318 | memset (a, 0, sizeof (*a)); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 319 | a->api_client_index = mp->client_index; |
| 320 | a->options = mp->options; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 321 | a->session_cb_vft = &session_cb_vft; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 322 | |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 323 | if (mp->namespace_id_len > 64) |
| 324 | { |
| 325 | rv = VNET_API_ERROR_INVALID_VALUE; |
| 326 | goto done; |
| 327 | } |
| 328 | |
| 329 | if (mp->namespace_id_len) |
| 330 | { |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 331 | vec_validate (a->namespace_id, mp->namespace_id_len - 1); |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 332 | clib_memcpy (a->namespace_id, mp->namespace_id, mp->namespace_id_len); |
| 333 | } |
| 334 | |
| 335 | if ((error = vnet_application_attach (a))) |
| 336 | { |
| 337 | rv = clib_error_get_code (error); |
| 338 | clib_error_report (error); |
| 339 | } |
| 340 | vec_free (a->namespace_id); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 341 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 342 | done: |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 343 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 344 | /* *INDENT-OFF* */ |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 345 | REPLY_MACRO2 (VL_API_APPLICATION_ATTACH_REPLY, ({ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 346 | if (!rv) |
| 347 | { |
| 348 | rmp->segment_name_length = 0; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 349 | rmp->segment_size = a->segment_size; |
| 350 | if (a->segment_name_length) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 351 | { |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 352 | memcpy (rmp->segment_name, a->segment_name, |
| 353 | a->segment_name_length); |
| 354 | rmp->segment_name_length = a->segment_name_length; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 355 | } |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 356 | rmp->app_event_queue_address = a->app_event_queue_address; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 357 | } |
| 358 | })); |
| 359 | /* *INDENT-ON* */ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | static void |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 363 | vl_api_application_detach_t_handler (vl_api_application_detach_t * mp) |
| 364 | { |
| 365 | vl_api_application_detach_reply_t *rmp; |
| 366 | int rv = VNET_API_ERROR_INVALID_VALUE_2; |
| 367 | vnet_app_detach_args_t _a, *a = &_a; |
| 368 | application_t *app; |
| 369 | |
| 370 | if (session_manager_is_enabled () == 0) |
| 371 | { |
| 372 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 373 | goto done; |
| 374 | } |
| 375 | |
| 376 | app = application_lookup (mp->client_index); |
| 377 | if (app) |
| 378 | { |
| 379 | a->app_index = app->index; |
| 380 | rv = vnet_application_detach (a); |
| 381 | } |
| 382 | |
| 383 | done: |
| 384 | REPLY_MACRO (VL_API_APPLICATION_DETACH_REPLY); |
| 385 | } |
| 386 | |
| 387 | static void |
| 388 | vl_api_bind_uri_t_handler (vl_api_bind_uri_t * mp) |
| 389 | { |
| 390 | vl_api_bind_uri_reply_t *rmp; |
| 391 | vnet_bind_args_t _a, *a = &_a; |
| 392 | application_t *app; |
| 393 | int rv; |
| 394 | |
| 395 | if (session_manager_is_enabled () == 0) |
| 396 | { |
| 397 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 398 | goto done; |
| 399 | } |
| 400 | |
| 401 | app = application_lookup (mp->client_index); |
| 402 | if (app) |
| 403 | { |
| 404 | memset (a, 0, sizeof (*a)); |
| 405 | a->uri = (char *) mp->uri; |
| 406 | a->app_index = app->index; |
| 407 | rv = vnet_bind_uri (a); |
| 408 | } |
| 409 | else |
| 410 | { |
| 411 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 412 | } |
| 413 | |
| 414 | done: |
| 415 | REPLY_MACRO (VL_API_BIND_URI_REPLY); |
| 416 | } |
| 417 | |
| 418 | static void |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 419 | vl_api_unbind_uri_t_handler (vl_api_unbind_uri_t * mp) |
| 420 | { |
| 421 | vl_api_unbind_uri_reply_t *rmp; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 422 | application_t *app; |
| 423 | vnet_unbind_args_t _a, *a = &_a; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 424 | int rv; |
| 425 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 426 | if (session_manager_is_enabled () == 0) |
| 427 | { |
| 428 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 429 | goto done; |
| 430 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 431 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 432 | app = application_lookup (mp->client_index); |
| 433 | if (app) |
| 434 | { |
| 435 | a->uri = (char *) mp->uri; |
| 436 | a->app_index = app->index; |
| 437 | rv = vnet_unbind_uri (a); |
| 438 | } |
| 439 | else |
| 440 | { |
| 441 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 442 | } |
| 443 | |
| 444 | done: |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 445 | REPLY_MACRO (VL_API_UNBIND_URI_REPLY); |
| 446 | } |
| 447 | |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 448 | static void |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 449 | vl_api_connect_uri_t_handler (vl_api_connect_uri_t * mp) |
| 450 | { |
Dave Wallace | 33e002b | 2017-09-06 01:20:02 -0400 | [diff] [blame] | 451 | vl_api_connect_session_reply_t *rmp; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 452 | vnet_connect_args_t _a, *a = &_a; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 453 | application_t *app; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 454 | clib_error_t *error = 0; |
| 455 | int rv = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 456 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 457 | if (session_manager_is_enabled () == 0) |
| 458 | { |
| 459 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 460 | goto done; |
| 461 | } |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 462 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 463 | app = application_lookup (mp->client_index); |
| 464 | if (app) |
| 465 | { |
| 466 | a->uri = (char *) mp->uri; |
| 467 | a->api_context = mp->context; |
| 468 | a->app_index = app->index; |
| 469 | a->mp = mp; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 470 | if ((error = vnet_connect_uri (a))) |
| 471 | { |
| 472 | rv = clib_error_get_code (error); |
| 473 | if (rv != VNET_API_ERROR_SESSION_REDIRECT) |
| 474 | clib_error_report (error); |
| 475 | } |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 476 | } |
| 477 | else |
| 478 | { |
| 479 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 480 | } |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 481 | |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 482 | /* |
| 483 | * Don't reply to stream (tcp) connects. The reply will come once |
| 484 | * the connection is established. In case of the redirects, the reply |
| 485 | * will come from the server app. |
| 486 | */ |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 487 | if (rv == 0 || rv == VNET_API_ERROR_SESSION_REDIRECT) |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 488 | return; |
| 489 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 490 | done: |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 491 | /* *INDENT-OFF* */ |
Dave Wallace | 33e002b | 2017-09-06 01:20:02 -0400 | [diff] [blame] | 492 | REPLY_MACRO (VL_API_CONNECT_SESSION_REPLY); |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 493 | /* *INDENT-ON* */ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | static void |
| 497 | vl_api_disconnect_session_t_handler (vl_api_disconnect_session_t * mp) |
| 498 | { |
| 499 | vl_api_disconnect_session_reply_t *rmp; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 500 | vnet_disconnect_args_t _a, *a = &_a; |
| 501 | application_t *app; |
| 502 | int rv = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 503 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 504 | if (session_manager_is_enabled () == 0) |
| 505 | { |
| 506 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 507 | goto done; |
| 508 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 509 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 510 | app = application_lookup (mp->client_index); |
| 511 | if (app) |
| 512 | { |
| 513 | a->handle = mp->handle; |
| 514 | a->app_index = app->index; |
| 515 | rv = vnet_disconnect_session (a); |
| 516 | } |
| 517 | else |
| 518 | { |
| 519 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 520 | } |
| 521 | |
| 522 | done: |
Dave Wallace | de5fec9 | 2017-11-11 22:41:34 -0500 | [diff] [blame] | 523 | REPLY_MACRO2 (VL_API_DISCONNECT_SESSION_REPLY, rmp->handle = mp->handle); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | static void |
| 527 | vl_api_disconnect_session_reply_t_handler (vl_api_disconnect_session_reply_t * |
| 528 | mp) |
| 529 | { |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 530 | vnet_disconnect_args_t _a, *a = &_a; |
| 531 | application_t *app; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 532 | |
| 533 | /* Client objected to disconnecting the session, log and continue */ |
| 534 | if (mp->retval) |
| 535 | { |
| 536 | clib_warning ("client retval %d", mp->retval); |
| 537 | return; |
| 538 | } |
| 539 | |
| 540 | /* Disconnect has been confirmed. Confirm close to transport */ |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 541 | app = application_lookup (mp->client_index); |
| 542 | if (app) |
| 543 | { |
| 544 | a->handle = mp->handle; |
| 545 | a->app_index = app->index; |
| 546 | vnet_disconnect_session (a); |
| 547 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | static void |
| 551 | vl_api_reset_session_reply_t_handler (vl_api_reset_session_reply_t * mp) |
| 552 | { |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 553 | application_t *app; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 554 | stream_session_t *s; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 555 | u32 index, thread_index; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 556 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 557 | app = application_lookup (mp->client_index); |
| 558 | if (!app) |
| 559 | return; |
| 560 | |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 561 | session_parse_handle (mp->handle, &index, &thread_index); |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 562 | s = session_get_if_valid (index, thread_index); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 563 | if (s == 0 || app->index != s->app_index) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 564 | { |
| 565 | clib_warning ("Invalid session!"); |
| 566 | return; |
| 567 | } |
| 568 | |
| 569 | /* Client objected to resetting the session, log and continue */ |
| 570 | if (mp->retval) |
| 571 | { |
| 572 | clib_warning ("client retval %d", mp->retval); |
| 573 | return; |
| 574 | } |
| 575 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 576 | /* This comes as a response to a reset, transport only waiting for |
| 577 | * confirmation to remove connection state, no need to disconnect */ |
| 578 | stream_session_cleanup (s); |
| 579 | } |
| 580 | |
| 581 | static void |
| 582 | vl_api_accept_session_reply_t_handler (vl_api_accept_session_reply_t * mp) |
| 583 | { |
| 584 | stream_session_t *s; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 585 | u32 session_index, thread_index; |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 586 | vnet_disconnect_args_t _a, *a = &_a; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 587 | |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 588 | /* Server isn't interested, kill the session */ |
| 589 | if (mp->retval) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 590 | { |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 591 | a->app_index = mp->context; |
| 592 | a->handle = mp->handle; |
| 593 | vnet_disconnect_session (a); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 594 | } |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 595 | else |
| 596 | { |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 597 | session_parse_handle (mp->handle, &session_index, &thread_index); |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 598 | s = session_get_if_valid (session_index, thread_index); |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 599 | if (!s) |
| 600 | { |
| 601 | clib_warning ("session doesn't exist"); |
| 602 | return; |
| 603 | } |
| 604 | if (s->app_index != mp->context) |
| 605 | { |
| 606 | clib_warning ("app doesn't own session"); |
| 607 | return; |
| 608 | } |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 609 | s->session_state = SESSION_STATE_READY; |
| 610 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 611 | } |
| 612 | |
| 613 | static void |
| 614 | vl_api_map_another_segment_reply_t_handler (vl_api_map_another_segment_reply_t |
| 615 | * mp) |
| 616 | { |
| 617 | clib_warning ("not implemented"); |
| 618 | } |
| 619 | |
| 620 | static void |
| 621 | vl_api_bind_sock_t_handler (vl_api_bind_sock_t * mp) |
| 622 | { |
| 623 | vl_api_bind_sock_reply_t *rmp; |
| 624 | vnet_bind_args_t _a, *a = &_a; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 625 | int rv = 0; |
| 626 | clib_error_t *error; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 627 | application_t *app; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 628 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 629 | if (session_manager_is_enabled () == 0) |
| 630 | { |
| 631 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 632 | goto done; |
| 633 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 634 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 635 | app = application_lookup (mp->client_index); |
| 636 | if (app) |
| 637 | { |
Dave Wallace | 33e002b | 2017-09-06 01:20:02 -0400 | [diff] [blame] | 638 | ip46_address_t *ip46 = (ip46_address_t *) mp->ip; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 639 | memset (a, 0, sizeof (*a)); |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 640 | a->sep.is_ip4 = mp->is_ip4; |
| 641 | a->sep.ip = *ip46; |
| 642 | a->sep.port = mp->port; |
| 643 | a->sep.fib_index = mp->vrf; |
| 644 | a->sep.sw_if_index = ENDPOINT_INVALID_INDEX; |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 645 | a->sep.transport_proto = mp->proto; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 646 | a->app_index = app->index; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 647 | |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 648 | if ((error = vnet_bind (a))) |
| 649 | { |
| 650 | rv = clib_error_get_code (error); |
| 651 | clib_error_report (error); |
| 652 | } |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 653 | } |
| 654 | done: |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 655 | /* *INDENT-OFF* */ |
| 656 | REPLY_MACRO2 (VL_API_BIND_SOCK_REPLY,({ |
| 657 | if (!rv) |
| 658 | rmp->handle = a->handle; |
| 659 | })); |
| 660 | /* *INDENT-ON* */ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | static void |
| 664 | vl_api_unbind_sock_t_handler (vl_api_unbind_sock_t * mp) |
| 665 | { |
| 666 | vl_api_unbind_sock_reply_t *rmp; |
| 667 | vnet_unbind_args_t _a, *a = &_a; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 668 | application_t *app; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 669 | clib_error_t *error; |
| 670 | int rv = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 671 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 672 | if (session_manager_is_enabled () == 0) |
| 673 | { |
| 674 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 675 | goto done; |
| 676 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 677 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 678 | app = application_lookup (mp->client_index); |
| 679 | if (app) |
| 680 | { |
Florin Coras | ef24d42 | 2017-11-09 10:05:42 -0800 | [diff] [blame] | 681 | a->app_index = app->index; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 682 | a->handle = mp->handle; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 683 | if ((error = vnet_unbind (a))) |
| 684 | { |
| 685 | rv = clib_error_get_code (error); |
| 686 | clib_error_report (error); |
| 687 | } |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 688 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 689 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 690 | done: |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 691 | REPLY_MACRO (VL_API_UNBIND_SOCK_REPLY); |
| 692 | } |
| 693 | |
| 694 | static void |
| 695 | vl_api_connect_sock_t_handler (vl_api_connect_sock_t * mp) |
| 696 | { |
Dave Wallace | 33e002b | 2017-09-06 01:20:02 -0400 | [diff] [blame] | 697 | vl_api_connect_session_reply_t *rmp; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 698 | vnet_connect_args_t _a, *a = &_a; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 699 | application_t *app; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 700 | clib_error_t *error = 0; |
| 701 | int rv = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 702 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 703 | if (session_manager_is_enabled () == 0) |
| 704 | { |
| 705 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 706 | goto done; |
| 707 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 708 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 709 | app = application_lookup (mp->client_index); |
| 710 | if (app) |
| 711 | { |
Dave Wallace | b2d5ff3 | 2017-06-14 12:38:28 -0400 | [diff] [blame] | 712 | unix_shared_memory_queue_t *client_q; |
Dave Wallace | 33e002b | 2017-09-06 01:20:02 -0400 | [diff] [blame] | 713 | ip46_address_t *ip46 = (ip46_address_t *) mp->ip; |
Dave Wallace | b2d5ff3 | 2017-06-14 12:38:28 -0400 | [diff] [blame] | 714 | |
| 715 | client_q = vl_api_client_index_to_input_queue (mp->client_index); |
| 716 | mp->client_queue_address = pointer_to_uword (client_q); |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 717 | a->sep.is_ip4 = mp->is_ip4; |
| 718 | a->sep.ip = *ip46; |
| 719 | a->sep.port = mp->port; |
| 720 | a->sep.transport_proto = mp->proto; |
| 721 | a->sep.fib_index = mp->vrf; |
| 722 | a->sep.sw_if_index = ENDPOINT_INVALID_INDEX; |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 723 | a->api_context = mp->context; |
| 724 | a->app_index = app->index; |
| 725 | a->mp = mp; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 726 | if ((error = vnet_connect (a))) |
| 727 | { |
| 728 | rv = clib_error_get_code (error); |
| 729 | if (rv != VNET_API_ERROR_SESSION_REDIRECT) |
| 730 | clib_error_report (error); |
| 731 | } |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 732 | } |
| 733 | else |
| 734 | { |
| 735 | rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED; |
| 736 | } |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 737 | |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 738 | if (rv == 0 || rv == VNET_API_ERROR_SESSION_REDIRECT) |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 739 | return; |
| 740 | |
| 741 | /* Got some error, relay it */ |
| 742 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 743 | done: |
Dave Wallace | 33e002b | 2017-09-06 01:20:02 -0400 | [diff] [blame] | 744 | REPLY_MACRO (VL_API_CONNECT_SESSION_REPLY); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 745 | } |
| 746 | |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 747 | static void |
| 748 | vl_api_app_namespace_add_del_t_handler (vl_api_app_namespace_add_del_t * mp) |
| 749 | { |
| 750 | vl_api_app_namespace_add_del_reply_t *rmp; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 751 | clib_error_t *error = 0; |
Florin Coras | 6e8c667 | 2017-11-10 09:03:54 -0800 | [diff] [blame] | 752 | u32 appns_index = 0; |
| 753 | u8 *ns_id = 0; |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 754 | int rv = 0; |
| 755 | if (!session_manager_is_enabled ()) |
| 756 | { |
| 757 | rv = VNET_API_ERROR_FEATURE_DISABLED; |
| 758 | goto done; |
| 759 | } |
| 760 | |
| 761 | if (mp->namespace_id_len > ARRAY_LEN (mp->namespace_id)) |
| 762 | { |
| 763 | rv = VNET_API_ERROR_INVALID_VALUE; |
| 764 | goto done; |
| 765 | } |
| 766 | |
| 767 | vec_validate (ns_id, mp->namespace_id_len - 1); |
| 768 | clib_memcpy (ns_id, mp->namespace_id, mp->namespace_id_len); |
| 769 | vnet_app_namespace_add_del_args_t args = { |
| 770 | .ns_id = ns_id, |
Florin Coras | 9a9adb2 | 2017-10-26 08:16:59 -0700 | [diff] [blame] | 771 | .secret = clib_net_to_host_u64 (mp->secret), |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 772 | .sw_if_index = clib_net_to_host_u32 (mp->sw_if_index), |
| 773 | .ip4_fib_id = clib_net_to_host_u32 (mp->ip4_fib_id), |
| 774 | .ip6_fib_id = clib_net_to_host_u32 (mp->ip6_fib_id), |
| 775 | .is_add = 1 |
| 776 | }; |
| 777 | error = vnet_app_namespace_add_del (&args); |
| 778 | if (error) |
| 779 | { |
| 780 | rv = clib_error_get_code (error); |
| 781 | clib_error_report (error); |
| 782 | } |
Florin Coras | 6e8c667 | 2017-11-10 09:03:54 -0800 | [diff] [blame] | 783 | else |
| 784 | { |
| 785 | appns_index = app_namespace_index_from_id (ns_id); |
| 786 | if (appns_index == APP_NAMESPACE_INVALID_INDEX) |
| 787 | { |
| 788 | clib_warning ("app ns lookup failed"); |
| 789 | rv = VNET_API_ERROR_UNSPECIFIED; |
| 790 | } |
| 791 | } |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 792 | vec_free (ns_id); |
Florin Coras | 6e8c667 | 2017-11-10 09:03:54 -0800 | [diff] [blame] | 793 | |
| 794 | /* *INDENT-OFF* */ |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 795 | done: |
Florin Coras | 6e8c667 | 2017-11-10 09:03:54 -0800 | [diff] [blame] | 796 | REPLY_MACRO2 (VL_API_APP_NAMESPACE_ADD_DEL_REPLY, ({ |
| 797 | if (!rv) |
| 798 | rmp->appns_index = clib_host_to_net_u32 (appns_index); |
| 799 | })); |
| 800 | /* *INDENT-ON* */ |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 801 | } |
| 802 | |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 803 | static void |
| 804 | vl_api_session_rule_add_del_t_handler (vl_api_session_rule_add_del_t * mp) |
| 805 | { |
| 806 | vl_api_session_rule_add_del_reply_t *rmp; |
| 807 | session_rule_add_del_args_t args; |
| 808 | session_rule_table_add_del_args_t *table_args = &args.table_args; |
| 809 | clib_error_t *error; |
| 810 | u8 fib_proto; |
| 811 | int rv = 0; |
| 812 | |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 813 | memset (&args, 0, sizeof (args)); |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 814 | fib_proto = mp->is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6; |
| 815 | |
| 816 | table_args->lcl.fp_len = mp->lcl_plen; |
| 817 | table_args->lcl.fp_proto = fib_proto; |
| 818 | table_args->rmt.fp_len = mp->rmt_plen; |
| 819 | table_args->rmt.fp_proto = fib_proto; |
| 820 | table_args->lcl_port = clib_net_to_host_u16 (mp->lcl_port); |
| 821 | table_args->rmt_port = clib_net_to_host_u16 (mp->rmt_port); |
| 822 | table_args->action_index = clib_net_to_host_u32 (mp->action_index); |
| 823 | table_args->is_add = mp->is_add; |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 824 | mp->tag[sizeof (mp->tag) - 1] = 0; |
| 825 | table_args->tag = format (0, "%s", mp->tag); |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 826 | args.appns_index = clib_net_to_host_u32 (mp->appns_index); |
| 827 | args.scope = mp->scope; |
| 828 | |
| 829 | memset (&table_args->lcl.fp_addr, 0, sizeof (table_args->lcl.fp_addr)); |
| 830 | memset (&table_args->rmt.fp_addr, 0, sizeof (table_args->rmt.fp_addr)); |
| 831 | ip_set (&table_args->lcl.fp_addr, mp->lcl_ip, mp->is_ip4); |
| 832 | ip_set (&table_args->rmt.fp_addr, mp->rmt_ip, mp->is_ip4); |
| 833 | error = vnet_session_rule_add_del (&args); |
| 834 | if (error) |
| 835 | { |
| 836 | rv = clib_error_get_code (error); |
| 837 | clib_error_report (error); |
| 838 | } |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 839 | vec_free (table_args->tag); |
Florin Coras | 1c71045 | 2017-10-17 00:03:13 -0700 | [diff] [blame] | 840 | REPLY_MACRO (VL_API_SESSION_RULE_ADD_DEL_REPLY); |
| 841 | } |
| 842 | |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 843 | static void |
| 844 | send_session_rule_details4 (mma_rule_16_t * rule, u8 is_local, |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 845 | u8 transport_proto, u32 appns_index, u8 * tag, |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 846 | unix_shared_memory_queue_t * q, u32 context) |
| 847 | { |
| 848 | vl_api_session_rules_details_t *rmp = 0; |
| 849 | session_mask_or_match_4_t *match = |
| 850 | (session_mask_or_match_4_t *) & rule->match; |
| 851 | session_mask_or_match_4_t *mask = |
| 852 | (session_mask_or_match_4_t *) & rule->mask; |
| 853 | |
| 854 | rmp = vl_msg_api_alloc (sizeof (*rmp)); |
| 855 | memset (rmp, 0, sizeof (*rmp)); |
| 856 | rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS); |
| 857 | rmp->context = context; |
| 858 | |
| 859 | rmp->is_ip4 = 1; |
| 860 | clib_memcpy (rmp->lcl_ip, &match->lcl_ip, sizeof (match->lcl_ip)); |
| 861 | clib_memcpy (rmp->rmt_ip, &match->rmt_ip, sizeof (match->rmt_ip)); |
| 862 | rmp->lcl_plen = ip4_mask_to_preflen (&mask->lcl_ip); |
| 863 | rmp->rmt_plen = ip4_mask_to_preflen (&mask->rmt_ip); |
| 864 | rmp->lcl_port = clib_host_to_net_u16 (match->lcl_port); |
| 865 | rmp->rmt_port = clib_host_to_net_u16 (match->rmt_port); |
| 866 | rmp->action_index = clib_host_to_net_u32 (rule->action_index); |
| 867 | rmp->scope = |
| 868 | is_local ? SESSION_RULE_SCOPE_LOCAL : SESSION_RULE_SCOPE_GLOBAL; |
| 869 | rmp->transport_proto = transport_proto; |
| 870 | rmp->appns_index = clib_host_to_net_u32 (appns_index); |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 871 | if (tag) |
| 872 | { |
| 873 | clib_memcpy (rmp->tag, tag, vec_len (tag)); |
| 874 | rmp->tag[vec_len (tag)] = 0; |
| 875 | } |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 876 | |
| 877 | vl_msg_api_send_shmem (q, (u8 *) & rmp); |
| 878 | } |
| 879 | |
| 880 | static void |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 881 | send_session_rule_details6 (mma_rule_40_t * rule, u8 is_local, |
| 882 | u8 transport_proto, u32 appns_index, u8 * tag, |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 883 | unix_shared_memory_queue_t * q, u32 context) |
| 884 | { |
| 885 | vl_api_session_rules_details_t *rmp = 0; |
| 886 | session_mask_or_match_6_t *match = |
| 887 | (session_mask_or_match_6_t *) & rule->match; |
| 888 | session_mask_or_match_6_t *mask = |
| 889 | (session_mask_or_match_6_t *) & rule->mask; |
| 890 | |
| 891 | rmp = vl_msg_api_alloc (sizeof (*rmp)); |
| 892 | memset (rmp, 0, sizeof (*rmp)); |
| 893 | rmp->_vl_msg_id = ntohs (VL_API_SESSION_RULES_DETAILS); |
| 894 | rmp->context = context; |
| 895 | |
| 896 | rmp->is_ip4 = 0; |
| 897 | clib_memcpy (rmp->lcl_ip, &match->lcl_ip, sizeof (match->lcl_ip)); |
| 898 | clib_memcpy (rmp->rmt_ip, &match->rmt_ip, sizeof (match->rmt_ip)); |
| 899 | rmp->lcl_plen = ip6_mask_to_preflen (&mask->lcl_ip); |
| 900 | rmp->rmt_plen = ip6_mask_to_preflen (&mask->rmt_ip); |
| 901 | rmp->lcl_port = clib_host_to_net_u16 (match->lcl_port); |
| 902 | rmp->rmt_port = clib_host_to_net_u16 (match->rmt_port); |
| 903 | rmp->action_index = clib_host_to_net_u32 (rule->action_index); |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 904 | rmp->scope = |
| 905 | is_local ? SESSION_RULE_SCOPE_LOCAL : SESSION_RULE_SCOPE_GLOBAL; |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 906 | rmp->transport_proto = transport_proto; |
| 907 | rmp->appns_index = clib_host_to_net_u32 (appns_index); |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 908 | if (tag) |
| 909 | { |
| 910 | clib_memcpy (rmp->tag, tag, vec_len (tag)); |
| 911 | rmp->tag[vec_len (tag)] = 0; |
| 912 | } |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 913 | |
| 914 | vl_msg_api_send_shmem (q, (u8 *) & rmp); |
| 915 | } |
| 916 | |
| 917 | static void |
| 918 | send_session_rules_table_details (session_rules_table_t * srt, u8 fib_proto, |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 919 | u8 tp, u8 is_local, u32 appns_index, |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 920 | unix_shared_memory_queue_t * q, u32 context) |
| 921 | { |
| 922 | mma_rule_16_t *rule16; |
| 923 | mma_rule_40_t *rule40; |
| 924 | mma_rules_table_16_t *srt16; |
| 925 | mma_rules_table_40_t *srt40; |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 926 | u32 ri; |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 927 | |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 928 | if (is_local || fib_proto == FIB_PROTOCOL_IP4) |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 929 | { |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 930 | u8 *tag = 0; |
| 931 | /* *INDENT-OFF* */ |
| 932 | srt16 = &srt->session_rules_tables_16; |
| 933 | pool_foreach (rule16, srt16->rules, ({ |
| 934 | ri = mma_rules_table_rule_index_16 (srt16, rule16); |
| 935 | tag = session_rules_table_rule_tag (srt, ri, 1); |
| 936 | send_session_rule_details4 (rule16, is_local, tp, appns_index, tag, |
| 937 | q, context); |
| 938 | })); |
| 939 | /* *INDENT-ON* */ |
| 940 | } |
| 941 | if (is_local || fib_proto == FIB_PROTOCOL_IP6) |
| 942 | { |
| 943 | u8 *tag = 0; |
| 944 | /* *INDENT-OFF* */ |
| 945 | srt40 = &srt->session_rules_tables_40; |
| 946 | pool_foreach (rule40, srt40->rules, ({ |
| 947 | ri = mma_rules_table_rule_index_40 (srt40, rule40); |
| 948 | tag = session_rules_table_rule_tag (srt, ri, 1); |
| 949 | send_session_rule_details6 (rule40, is_local, tp, appns_index, tag, |
| 950 | q, context); |
| 951 | })); |
| 952 | /* *INDENT-ON* */ |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 953 | } |
| 954 | } |
| 955 | |
| 956 | static void |
| 957 | vl_api_session_rules_dump_t_handler (vl_api_one_map_server_dump_t * mp) |
| 958 | { |
| 959 | unix_shared_memory_queue_t *q = NULL; |
| 960 | session_table_t *st; |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 961 | u8 tp; |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 962 | |
| 963 | q = vl_api_client_index_to_input_queue (mp->client_index); |
| 964 | if (q == 0) |
| 965 | return; |
| 966 | |
| 967 | /* *INDENT-OFF* */ |
| 968 | session_table_foreach (st, ({ |
Florin Coras | c97a739 | 2017-11-05 23:07:07 -0800 | [diff] [blame] | 969 | for (tp = 0; tp < TRANSPORT_N_PROTO; tp++) |
| 970 | { |
| 971 | send_session_rules_table_details (&st->session_rules[tp], |
| 972 | st->active_fib_proto, tp, |
| 973 | st->is_local, st->appns_index, q, |
| 974 | mp->context); |
| 975 | } |
Florin Coras | 6c36f53 | 2017-11-03 18:32:34 -0700 | [diff] [blame] | 976 | })); |
| 977 | /* *INDENT-ON* */ |
| 978 | } |
| 979 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 980 | static clib_error_t * |
| 981 | application_reaper_cb (u32 client_index) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 982 | { |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 983 | application_t *app = application_lookup (client_index); |
| 984 | vnet_app_detach_args_t _a, *a = &_a; |
| 985 | if (app) |
| 986 | { |
| 987 | a->app_index = app->index; |
| 988 | vnet_application_detach (a); |
| 989 | } |
| 990 | return 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 991 | } |
| 992 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 993 | VL_MSG_API_REAPER_FUNCTION (application_reaper_cb); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 994 | |
| 995 | #define vl_msg_name_crc_list |
| 996 | #include <vnet/vnet_all_api_h.h> |
| 997 | #undef vl_msg_name_crc_list |
| 998 | |
| 999 | static void |
| 1000 | setup_message_id_table (api_main_t * am) |
| 1001 | { |
| 1002 | #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); |
| 1003 | foreach_vl_msg_name_crc_session; |
| 1004 | #undef _ |
| 1005 | } |
| 1006 | |
| 1007 | /* |
| 1008 | * session_api_hookup |
| 1009 | * Add uri's API message handlers to the table. |
| 1010 | * vlib has alread mapped shared memory and |
| 1011 | * added the client registration handlers. |
| 1012 | * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process() |
| 1013 | */ |
| 1014 | static clib_error_t * |
| 1015 | session_api_hookup (vlib_main_t * vm) |
| 1016 | { |
| 1017 | api_main_t *am = &api_main; |
| 1018 | |
| 1019 | #define _(N,n) \ |
| 1020 | vl_msg_api_set_handlers(VL_API_##N, #n, \ |
| 1021 | vl_api_##n##_t_handler, \ |
| 1022 | vl_noop_handler, \ |
| 1023 | vl_api_##n##_t_endian, \ |
| 1024 | vl_api_##n##_t_print, \ |
| 1025 | sizeof(vl_api_##n##_t), 1); |
| 1026 | foreach_session_api_msg; |
| 1027 | #undef _ |
| 1028 | |
| 1029 | /* |
| 1030 | * Messages which bounce off the data-plane to |
| 1031 | * an API client. Simply tells the message handling infra not |
| 1032 | * to free the message. |
| 1033 | * |
| 1034 | * Bounced message handlers MUST NOT block the data plane |
| 1035 | */ |
| 1036 | am->message_bounce[VL_API_CONNECT_URI] = 1; |
| 1037 | am->message_bounce[VL_API_CONNECT_SOCK] = 1; |
| 1038 | |
| 1039 | /* |
| 1040 | * Set up the (msg_name, crc, message-id) table |
| 1041 | */ |
| 1042 | setup_message_id_table (am); |
| 1043 | |
| 1044 | return 0; |
| 1045 | } |
| 1046 | |
| 1047 | VLIB_API_INIT_FUNCTION (session_api_hookup); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame] | 1048 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1049 | /* |
| 1050 | * fd.io coding-style-patch-verification: ON |
| 1051 | * |
| 1052 | * Local Variables: |
| 1053 | * eval: (c-set-style "gnu") |
| 1054 | * End: |
| 1055 | */ |