session: generalize handling of network transports
[vpp.git] / src / vnet / session / application.c
index 17770be..4523d5d 100644 (file)
@@ -523,7 +523,8 @@ application_first_listener (application_t * app, u8 fib_proto,
   /* *INDENT-OFF* */
    hash_foreach (handle, sm_index, app->listeners_table, ({
      listener = listen_session_get_from_handle (handle);
-     if (listener->session_type == sst)
+     if (listener->session_type == sst
+        && listener->listener_index != SESSION_PROXY_LISTENER_INDEX)
        return listener;
    }));
   /* *INDENT-ON* */
@@ -550,6 +551,7 @@ application_start_stop_proxy_fib_proto (application_t * app, u8 fib_proto,
       sep.transport_proto = transport_proto;
       application_start_listen (app, &sep, &handle);
       s = listen_session_get_from_handle (handle);
+      s->listener_index = SESSION_PROXY_LISTENER_INDEX;
     }
   else
     {
@@ -571,8 +573,8 @@ application_start_stop_proxy_fib_proto (application_t * app, u8 fib_proto,
 }
 
 void
-application_start_stop_proxy (application_t * app, u8 transport_proto,
-                             u8 is_start)
+application_start_stop_proxy (application_t * app,
+                             transport_proto_t transport_proto, u8 is_start)
 {
   if (application_has_local_scope (app))
     {
@@ -603,24 +605,34 @@ void
 application_setup_proxy (application_t * app)
 {
   u16 transports = app->proxied_transports;
+  transport_proto_t tp;
+
   ASSERT (application_is_proxy (app));
   if (application_is_builtin (app))
     return;
-  if (transports & (1 << TRANSPORT_PROTO_TCP))
-    application_start_stop_proxy (app, TRANSPORT_PROTO_TCP, 1);
-  if (transports & (1 << TRANSPORT_PROTO_UDP))
-    application_start_stop_proxy (app, TRANSPORT_PROTO_UDP, 1);
+
+  /* *INDENT-OFF* */
+  transport_proto_foreach (tp, ({
+    if (transports & (1 << tp))
+      application_start_stop_proxy (app, tp, 1);
+  }));
+  /* *INDENT-ON* */
 }
 
 void
 application_remove_proxy (application_t * app)
 {
   u16 transports = app->proxied_transports;
+  transport_proto_t tp;
+
   ASSERT (application_is_proxy (app));
-  if (transports & (1 << TRANSPORT_PROTO_TCP))
-    application_start_stop_proxy (app, TRANSPORT_PROTO_TCP, 0);
-  if (transports & (1 << TRANSPORT_PROTO_UDP))
-    application_start_stop_proxy (app, TRANSPORT_PROTO_UDP, 0);
+
+  /* *INDENT-OFF* */
+  transport_proto_foreach (tp, ({
+    if (transports & (1 << tp))
+      application_start_stop_proxy (app, tp, 0);
+  }));
+  /* *INDENT-ON* */
 }
 
 u8 *