session: generalize handling of network transports
[vpp.git] / src / vnet / session / session_api.c
index f15d2f6..57f55eb 100755 (executable)
@@ -69,7 +69,7 @@ send_add_segment_callback (u32 api_client_index, const u8 * segment_name,
   if (!q)
     return -1;
 
-  mp = vl_msg_api_alloc (sizeof (*mp));
+  mp = vl_msg_api_alloc_as_if_client (sizeof (*mp));
   memset (mp, 0, sizeof (*mp));
   mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_MAP_ANOTHER_SEGMENT);
   mp->segment_size = segment_size;
@@ -97,15 +97,25 @@ send_session_accept_callback (stream_session_t * s)
   if (!q)
     return -1;
 
-  mp = vl_msg_api_alloc (sizeof (*mp));
+  mp = vl_msg_api_alloc_as_if_client (sizeof (*mp));
   memset (mp, 0, sizeof (*mp));
 
   mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_ACCEPT_SESSION);
   mp->context = server->index;
   listener = listen_session_get (s->session_type, s->listener_index);
-  tp_vft = transport_protocol_get_vft (s->session_type);
+  tp_vft = transport_protocol_get_vft (session_get_transport_proto (s));
   tc = tp_vft->get_connection (s->connection_index, s->thread_index);
   mp->listener_handle = listen_session_get_handle (listener);
+
+  if (application_is_proxy (server))
+    {
+      listener =
+       application_first_listener (server,
+                                   transport_connection_fib_proto (tc),
+                                   tc->proto);
+      if (listener)
+       mp->listener_handle = listen_session_get_handle (listener);
+    }
   mp->handle = session_handle (s);
   mp->server_rx_fifo = pointer_to_uword (s->server_rx_fifo);
   mp->server_tx_fifo = pointer_to_uword (s->server_tx_fifo);
@@ -130,7 +140,7 @@ send_session_disconnect_callback (stream_session_t * s)
   if (!q)
     return;
 
-  mp = vl_msg_api_alloc (sizeof (*mp));
+  mp = vl_msg_api_alloc_as_if_client (sizeof (*mp));
   memset (mp, 0, sizeof (*mp));
   mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_DISCONNECT_SESSION);
   mp->handle = session_handle (s);
@@ -149,7 +159,7 @@ send_session_reset_callback (stream_session_t * s)
   if (!q)
     return;
 
-  mp = vl_msg_api_alloc (sizeof (*mp));
+  mp = vl_msg_api_alloc_as_if_client (sizeof (*mp));
   memset (mp, 0, sizeof (*mp));
   mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_RESET_SESSION);
   mp->handle = session_handle (s);
@@ -172,7 +182,7 @@ send_session_connected_callback (u32 app_index, u32 api_context,
   if (!q)
     return -1;
 
-  mp = vl_msg_api_alloc (sizeof (*mp));
+  mp = vl_msg_api_alloc_as_if_client (sizeof (*mp));
   mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_CONNECT_SESSION_REPLY);
   mp->context = api_context;