Add get_endpoint in transport vft
[vpp.git] / src / vnet / session / transport.h
index 8500e9d..73d7fba 100644 (file)
@@ -45,6 +45,8 @@ typedef struct _transport_proto_vft
   u32 (*tx_fifo_offset) (transport_connection_t * tc);
   void (*update_time) (f64 time_now, u8 thread_index);
   void (*flush_data) (transport_connection_t *tconn);
+  int (*custom_tx) (void *session);
+  int (*app_rx_evt) (transport_connection_t *tconn);
 
   /*
    * Connection retrieval
@@ -60,6 +62,11 @@ typedef struct _transport_proto_vft
   u8 *(*format_listener) (u8 * s, va_list * args);
   u8 *(*format_half_open) (u8 * s, va_list * args);
 
+  /* External API response */
+
+  void (*get_transport_endpoint) (u32 conn_index, u32 thread_index, ip46_address_t * ip, u16 * port, u8 * is_ip4, u8 is_lcl);
+  void (*get_transport_listener_endpoint) (u32 conn_index, ip46_address_t * ip, u16 * port, u8 * is_ip4, u8 is_lcl);
+
   /*
    * Properties
    */
@@ -84,6 +91,12 @@ u32 transport_start_listen (transport_proto_t tp, u32 session_index,
 u32 transport_stop_listen (transport_proto_t tp, u32 conn_index);
 void transport_cleanup (transport_proto_t tp, u32 conn_index,
                        u8 thread_index);
+void transport_get_endpoint (transport_proto_t tp, u32 conn_index,
+                            u32 thread_index, ip46_address_t * ip,
+                            u16 * port, u8 * is_ip4, u8 is_lcl);
+void transport_get_listener_endpoint (transport_proto_t tp, u32 conn_index,
+                                     ip46_address_t * ip, u16 * port,
+                                     u8 * is_ip4, u8 is_lcl);
 
 static inline transport_connection_t *
 transport_get_connection (transport_proto_t tp, u32 conn_index,
@@ -104,6 +117,22 @@ transport_get_half_open (transport_proto_t tp, u32 conn_index)
   return tp_vfts[tp].get_half_open (conn_index);
 }
 
+static inline int
+transport_custom_tx (transport_proto_t tp, void *s)
+{
+  return tp_vfts[tp].custom_tx (s);
+}
+
+static inline int
+transport_app_rx_evt (transport_proto_t tp, u32 conn_index, u32 thread_index)
+{
+  transport_connection_t *tc;
+  if (!tp_vfts[tp].app_rx_evt)
+    return 0;
+  tc = transport_get_connection (tp, conn_index, thread_index);
+  return tp_vfts[tp].app_rx_evt (tc);
+}
+
 void transport_register_protocol (transport_proto_t transport_proto,
                                  const transport_proto_vft_t * vft,
                                  fib_protocol_t fib_proto, u32 output_node);