update builtin UDP server to new vnet_session API

* app_index has to be valid
* vnet_session needs to be enabled before binding

Change-Id: I410a25153e650d8bc332131a81bf46a0175566d4
Signed-off-by: Andreas Schultz <aschultz@warp10.net>
diff --git a/src/vnet/udp/builtin_server.c b/src/vnet/udp/builtin_server.c
index 8f8cb40..29c33be 100644
--- a/src/vnet/udp/builtin_server.c
+++ b/src/vnet/udp/builtin_server.c
@@ -23,6 +23,7 @@
 
 /** per-worker built-in server copy buffers */
 u8 **copy_buffers;
+static int app_index = ~0;
 
 static int
 builtin_session_create_callback (stream_session_t * s)
@@ -38,6 +39,21 @@
   stream_session_disconnect (s);
 }
 
+static void
+builtin_session_reset_callback (stream_session_t * s)
+{
+  clib_warning ("Reset session %U", format_stream_session, s, 2);
+  stream_session_cleanup (s);
+}
+
+static int
+builtin_session_connected_callback (u32 app_index, u32 api_context,
+				    stream_session_t * s, u8 is_fail)
+{
+  clib_warning ("called...");
+  return -1;
+}
+
 static int
 builtin_server_rx_callback (stream_session_t * s)
 {
@@ -84,8 +100,10 @@
 /* *INDENT-OFF* */
 static session_cb_vft_t builtin_server = {
     .session_accept_callback = builtin_session_create_callback,
+    .session_connected_callback = builtin_session_connected_callback,
     .session_disconnect_callback = builtin_session_disconnect_callback,
-    .builtin_server_rx_callback = builtin_server_rx_callback
+    .builtin_server_rx_callback = builtin_server_rx_callback,
+    .session_reset_callback = builtin_session_reset_callback
 };
 /* *INDENT-ON* */
 
@@ -116,6 +134,8 @@
 
   if (vnet_application_attach (a))
     return -1;
+
+  app_index = a->app_index;
   return 0;
 }
 
@@ -131,7 +151,7 @@
 
   memset (a, 0, sizeof (*a));
   a->uri = (char *) uri;
-  a->app_index = ~0;		/* built-in server */
+  a->app_index = app_index;
 
   rv = vnet_bind_uri (a);
 
@@ -143,7 +163,7 @@
 {
   vnet_unbind_args_t _a, *a = &_a;
 
-  a->app_index = ~0;
+  a->app_index = app_index;
   a->uri = (char *) uri;
 
   return vnet_unbind_uri (a);
@@ -182,6 +202,8 @@
   if (uri == 0)
     return clib_error_return (0, "uri to bind not specified...");
 
+  vnet_session_enable_disable (vm, 1 /* turn on UDP, etc. */ );
+
   rv = bind_builtin_uri_server (uri);
 
   vec_free (uri);