udp/session: refactor to support dgram mode
[vpp.git] / src / vnet / session / transport.c
index c31964c..20b9129 100644 (file)
@@ -57,6 +57,9 @@ format_transport_proto (u8 * s, va_list * args)
     case TRANSPORT_PROTO_SCTP:
       s = format (s, "SCTP");
       break;
+    case TRANSPORT_PROTO_UDPC:
+      s = format (s, "UDPC");
+      break;
     }
   return s;
 }
@@ -76,6 +79,9 @@ format_transport_proto_short (u8 * s, va_list * args)
     case TRANSPORT_PROTO_SCTP:
       s = format (s, "S");
       break;
+    case TRANSPORT_PROTO_UDPC:
+      s = format (s, "U");
+      break;
     }
   return s;
 }
@@ -96,6 +102,14 @@ unformat_transport_proto (unformat_input_t * input, va_list * args)
     *proto = TRANSPORT_PROTO_SCTP;
   else if (unformat (input, "SCTP"))
     *proto = TRANSPORT_PROTO_SCTP;
+  else if (unformat (input, "tls"))
+    *proto = TRANSPORT_PROTO_TLS;
+  else if (unformat (input, "TLS"))
+    *proto = TRANSPORT_PROTO_TLS;
+  else if (unformat (input, "udpc"))
+    *proto = TRANSPORT_PROTO_UDPC;
+  else if (unformat (input, "UDPC"))
+    *proto = TRANSPORT_PROTO_UDPC;
   else
     return 0;
   return 1;
@@ -181,6 +195,12 @@ transport_protocol_get_vft (transport_proto_t transport_proto)
   return &tp_vfts[transport_proto];
 }
 
+transport_service_type_t
+transport_protocol_service_type (transport_proto_t tp)
+{
+  return tp_vfts[tp].service_type;
+}
+
 #define PORT_MASK ((1 << 16)- 1)
 
 void
@@ -310,6 +330,13 @@ transport_alloc_local_endpoint (u8 proto, transport_endpoint_t * rmt,
     {
       ip4_address_t *ip4;
       ip4 = ip_interface_get_first_ip (sw_if_index, 1);
+      if (!ip4)
+       {
+         clib_warning ("no routable ip4 address on %U",
+                       format_vnet_sw_if_index_name, vnet_get_main (),
+                       sw_if_index);
+         return -1;
+       }
       lcl_addr->ip4.as_u32 = ip4->as_u32;
     }
   else