session: use teps in accept/connect notifications
[vpp.git] / src / vnet / session / transport.c
index d83ecfb..0679eaa 100644 (file)
@@ -319,6 +319,54 @@ transport_protocol_is_cl (transport_proto_t tp)
   return (tp_vfts[tp].service_type == TRANSPORT_SERVICE_CL);
 }
 
+always_inline void
+default_get_transport_endpoint (transport_connection_t * tc,
+                               transport_endpoint_t * tep, u8 is_lcl)
+{
+  if (is_lcl)
+    {
+      tep->port = tc->lcl_port;
+      tep->is_ip4 = tc->is_ip4;
+      clib_memcpy_fast (&tep->ip, &tc->lcl_ip, sizeof (tc->lcl_ip));
+    }
+  else
+    {
+      tep->port = tc->rmt_port;
+      tep->is_ip4 = tc->is_ip4;
+      clib_memcpy_fast (&tep->ip, &tc->rmt_ip, sizeof (tc->rmt_ip));
+    }
+}
+
+void
+transport_get_endpoint (transport_proto_t tp, u32 conn_index,
+                       u32 thread_index, transport_endpoint_t * tep,
+                       u8 is_lcl)
+{
+  if (tp_vfts[tp].get_transport_endpoint)
+    tp_vfts[tp].get_transport_endpoint (conn_index, thread_index, tep,
+                                       is_lcl);
+  else
+    {
+      transport_connection_t *tc;
+      tc = transport_get_connection (tp, conn_index, thread_index);
+      default_get_transport_endpoint (tc, tep, is_lcl);
+    }
+}
+
+void
+transport_get_listener_endpoint (transport_proto_t tp, u32 conn_index,
+                                transport_endpoint_t * tep, u8 is_lcl)
+{
+  if (tp_vfts[tp].get_transport_listener_endpoint)
+    tp_vfts[tp].get_transport_listener_endpoint (conn_index, tep, is_lcl);
+  else
+    {
+      transport_connection_t *tc;
+      tc = transport_get_listener (tp, conn_index);
+      default_get_transport_endpoint (tc, tep, is_lcl);
+    }
+}
+
 #define PORT_MASK ((1 << 16)- 1)
 
 void