diff --git a/vlib-api/vlibsocket/socksvr_vlib.c b/vlib-api/vlibsocket/socksvr_vlib.c
index d65646a..e70124d 100644
--- a/vlib-api/vlibsocket/socksvr_vlib.c
+++ b/vlib-api/vlibsocket/socksvr_vlib.c
@@ -1,4 +1,4 @@
-/* 
+/*
  *------------------------------------------------------------------
  * socksvr_vlib.c
  *
@@ -17,7 +17,7 @@
  *------------------------------------------------------------------
  */
 
-#include <sys/types.h> 
+#include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <sys/ioctl.h>
@@ -29,42 +29,44 @@
 #include <vlibsocket/api.h>
 #include <vlibmemory/api.h>
 
-#include <vlibsocket/vl_socket_msg_enum.h> /* enumerate all vlib messages */
+#include <vlibsocket/vl_socket_msg_enum.h>	/* enumerate all vlib messages */
 
-#define vl_typedefs             /* define message structures */
-#include <vlibsocket/vl_socket_api_h.h> 
+#define vl_typedefs		/* define message structures */
+#include <vlibsocket/vl_socket_api_h.h>
 #undef vl_typedefs
 
 /* instantiate all the print functions we know about */
 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
 #define vl_printfun
-#include <vlibsocket/vl_socket_api_h.h> 
+#include <vlibsocket/vl_socket_api_h.h>
 #undef vl_printfun
 
 /* instantiate all the endian swap functions we know about */
 #define vl_endianfun
-#include <vlibsocket/vl_socket_api_h.h> 
+#include <vlibsocket/vl_socket_api_h.h>
 #undef vl_endianfun
 
 socket_main_t socket_main;
 
-void dump_socket_clients (vlib_main_t *vm, api_main_t *am)
+void
+dump_socket_clients (vlib_main_t * vm, api_main_t * am)
 {
-    vl_api_registration_t *reg;
-    socket_main_t *sm = &socket_main;
-    unix_main_t *um = &unix_main;
-    unix_file_t *f;
+  vl_api_registration_t *reg;
+  socket_main_t *sm = &socket_main;
+  unix_main_t *um = &unix_main;
+  unix_file_t *f;
 
-    /* 
-     * Must have at least one active client, not counting the
-     * REGISTRATION_TYPE_SOCKET_LISTEN bind/accept socket
-     */
-    if (pool_elts (sm->registration_pool) < 2)
-        return;
+  /*
+   * Must have at least one active client, not counting the
+   * REGISTRATION_TYPE_SOCKET_LISTEN bind/accept socket
+   */
+  if (pool_elts (sm->registration_pool) < 2)
+    return;
 
-    vlib_cli_output (vm, "TCP socket clients");
-    vlib_cli_output (vm, "%16s %8s", "Name", "Fildesc");
-    pool_foreach (reg, sm->registration_pool, 
+  vlib_cli_output (vm, "TCP socket clients");
+  vlib_cli_output (vm, "%16s %8s", "Name", "Fildesc");
+    /* *INDENT-OFF* */
+    pool_foreach (reg, sm->registration_pool,
     ({
         if (reg->registration_type == REGISTRATION_TYPE_SOCKET_SERVER) {
             f = pool_elt_at_index (um->file_pool, reg->unix_file_index);
@@ -72,450 +74,483 @@
                              reg->name, f->file_descriptor);
         }
     }));
+/* *INDENT-ON* */
 }
 
-void 
-vl_socket_api_send (vl_api_registration_t *rp, u8 *elem) 
+void
+vl_socket_api_send (vl_api_registration_t * rp, u8 * elem)
 {
-    u32 nbytes = 4; /* for the length... */
-    u16 msg_id = ntohs(*(u16 *)elem);
-    u32 msg_length;
-    u32 tmp;
-    api_main_t *am = &api_main;
+  u32 nbytes = 4;		/* for the length... */
+  u16 msg_id = ntohs (*(u16 *) elem);
+  u32 msg_length;
+  u32 tmp;
+  api_main_t *am = &api_main;
 
-    ASSERT(rp->registration_type > REGISTRATION_TYPE_SHMEM);
+  ASSERT (rp->registration_type > REGISTRATION_TYPE_SHMEM);
 
-    if (msg_id >= vec_len(am->api_trace_cfg)) {
-        clib_warning("id out of range: %d", msg_id);
-        vl_msg_api_free((void *)elem);
-        return;
+  if (msg_id >= vec_len (am->api_trace_cfg))
+    {
+      clib_warning ("id out of range: %d", msg_id);
+      vl_msg_api_free ((void *) elem);
+      return;
     }
 
-    msg_length = am->api_trace_cfg[msg_id].size;
-    nbytes += msg_length;
-    tmp = clib_host_to_net_u32 (nbytes);
+  msg_length = am->api_trace_cfg[msg_id].size;
+  nbytes += msg_length;
+  tmp = clib_host_to_net_u32 (nbytes);
 
-    vl_socket_add_pending_output (rp->unix_file_index 
-                                  + unix_main.file_pool, 
-                                  rp->vl_api_registration_pool_index
-                                  + socket_main.registration_pool,
-                                  (u8 *) &tmp, 
-                                  sizeof(tmp));
-    vl_socket_add_pending_output (rp->unix_file_index 
-                                  + unix_main.file_pool, 
-                                  rp->vl_api_registration_pool_index
-                                  + socket_main.registration_pool,
-                                  elem, msg_length);
-    vl_msg_api_free((void *)elem);
+  vl_socket_add_pending_output (rp->unix_file_index
+				+ unix_main.file_pool,
+				rp->vl_api_registration_pool_index
+				+ socket_main.registration_pool,
+				(u8 *) & tmp, sizeof (tmp));
+  vl_socket_add_pending_output (rp->unix_file_index
+				+ unix_main.file_pool,
+				rp->vl_api_registration_pool_index
+				+ socket_main.registration_pool,
+				elem, msg_length);
+  vl_msg_api_free ((void *) elem);
 }
 
-void vl_socket_api_send_with_data (vl_api_registration_t *rp, 
-                                   u8 *elem, u8 *data_vector)
+void
+vl_socket_api_send_with_data (vl_api_registration_t * rp,
+			      u8 * elem, u8 * data_vector)
 {
-    u32 nbytes = 4; /* for the length... */
-    u16 msg_id = ntohs(*(u16 *)elem);
-    u32 msg_length;
-    u32 tmp;
-    api_main_t *am = &api_main;
-        
-    ASSERT(rp->registration_type > REGISTRATION_TYPE_SHMEM);
+  u32 nbytes = 4;		/* for the length... */
+  u16 msg_id = ntohs (*(u16 *) elem);
+  u32 msg_length;
+  u32 tmp;
+  api_main_t *am = &api_main;
 
-    if (msg_id >= vec_len(am->api_trace_cfg)) {
-        clib_warning("id out of range: %d", msg_id);
-        vec_free(data_vector);
-        vl_msg_api_free((void *)elem);
-        return;
+  ASSERT (rp->registration_type > REGISTRATION_TYPE_SHMEM);
+
+  if (msg_id >= vec_len (am->api_trace_cfg))
+    {
+      clib_warning ("id out of range: %d", msg_id);
+      vec_free (data_vector);
+      vl_msg_api_free ((void *) elem);
+      return;
     }
 
-    msg_length = am->api_trace_cfg[msg_id].size;
-    nbytes += msg_length;
-    nbytes += vec_len(data_vector);
+  msg_length = am->api_trace_cfg[msg_id].size;
+  nbytes += msg_length;
+  nbytes += vec_len (data_vector);
 
-    /* Length in network byte order */
-    tmp = clib_host_to_net_u32(nbytes);
+  /* Length in network byte order */
+  tmp = clib_host_to_net_u32 (nbytes);
 
-    vl_socket_add_pending_output (rp->unix_file_index 
-                                  + unix_main.file_pool, 
-                                  rp->vl_api_registration_pool_index
-                                  + socket_main.registration_pool,
-                                  (u8 *) &tmp, 
-                                  sizeof(tmp));
-    vl_socket_add_pending_output (rp->unix_file_index 
-                                  + unix_main.file_pool, 
-                                  rp->vl_api_registration_pool_index
-                                  + socket_main.registration_pool,
-                                  elem, msg_length);
-    vl_socket_add_pending_output (rp->unix_file_index 
-                                  + unix_main.file_pool, 
-                                  rp->vl_api_registration_pool_index
-                                  + socket_main.registration_pool,
-                                  data_vector, vec_len(data_vector));
-    vl_msg_api_free((void *)elem);
-}
-
-static inline void 
-vl_socket_api_send_with_length_internal (vl_api_registration_t *rp, 
-                                         u8 *elem, u32 msg_length, int free)
-{
-    u32 nbytes = 4; /* for the length... */
-    u16 msg_id = ntohs(*(u16 *)elem);
-    u32 tmp;
-    api_main_t *am = &api_main;
-        
-    ASSERT(rp->registration_type > REGISTRATION_TYPE_SHMEM);
-
-    if (msg_id >= vec_len(am->api_trace_cfg)) {
-        clib_warning("id out of range: %d", msg_id);
-        if (free)
-            vl_msg_api_free((void *)elem);
-        return;
-    }
-
-    nbytes += msg_length;
-
-    /* Length in network byte order */
-    tmp = clib_host_to_net_u32(nbytes);
-
-    vl_socket_add_pending_output (rp->unix_file_index 
-                                  + unix_main.file_pool, 
-                                  rp->vl_api_registration_pool_index
-                                  + socket_main.registration_pool,
-                                  (u8 *) &tmp, 
-                                  sizeof(tmp));
-    vl_socket_add_pending_output (rp->unix_file_index 
-                                  + unix_main.file_pool, 
-                                  rp->vl_api_registration_pool_index
-                                  + socket_main.registration_pool,
-                                  elem, msg_length);
-    if (free)
-        vl_msg_api_free((void *)elem);
-}
-
-void vl_socket_api_send_with_length (vl_api_registration_t *rp, 
-                                     u8 *elem, u32 msg_length)
-{
-    vl_socket_api_send_with_length_internal(rp,elem,msg_length, 1 /* free */);
-}
-
-void vl_socket_api_send_with_length_no_free (vl_api_registration_t *rp, 
-                                             u8 *elem, u32 msg_length)
-{
-    vl_socket_api_send_with_length_internal(rp,elem,msg_length, 0 /* free */);
-}
-
-void vl_free_socket_registration_index (u32 pool_index)
-{
-    vl_api_registration_t *rp;
-    if (pool_is_free_index (socket_main.registration_pool, pool_index)) {
-        clib_warning ("main pool index %d already free", pool_index);
-        return;
-    }
-    rp = pool_elt_at_index (socket_main.registration_pool, pool_index);
-
-    ASSERT(rp->registration_type != REGISTRATION_TYPE_FREE);
-    vec_free (rp->name);
-    vec_free (rp->unprocessed_input);
-    vec_free (rp->output_vector);
-    rp->registration_type = REGISTRATION_TYPE_FREE;
-    pool_put (socket_main.registration_pool, rp);
+  vl_socket_add_pending_output (rp->unix_file_index
+				+ unix_main.file_pool,
+				rp->vl_api_registration_pool_index
+				+ socket_main.registration_pool,
+				(u8 *) & tmp, sizeof (tmp));
+  vl_socket_add_pending_output (rp->unix_file_index
+				+ unix_main.file_pool,
+				rp->vl_api_registration_pool_index
+				+ socket_main.registration_pool,
+				elem, msg_length);
+  vl_socket_add_pending_output (rp->unix_file_index
+				+ unix_main.file_pool,
+				rp->vl_api_registration_pool_index
+				+ socket_main.registration_pool,
+				data_vector, vec_len (data_vector));
+  vl_msg_api_free ((void *) elem);
 }
 
 static inline void
-socket_process_msg (unix_file_t *uf, vl_api_registration_t *rp, i8 *input_v)
+vl_socket_api_send_with_length_internal (vl_api_registration_t * rp,
+					 u8 * elem, u32 msg_length, int free)
 {
-    u8 *the_msg = (u8 *)(input_v+sizeof(u32));
-    socket_main.current_uf = uf;
-    socket_main.current_rp = rp;
-    vl_msg_api_socket_handler (the_msg);
-    socket_main.current_uf = 0;
-    socket_main.current_rp = 0;
+  u32 nbytes = 4;		/* for the length... */
+  u16 msg_id = ntohs (*(u16 *) elem);
+  u32 tmp;
+  api_main_t *am = &api_main;
+
+  ASSERT (rp->registration_type > REGISTRATION_TYPE_SHMEM);
+
+  if (msg_id >= vec_len (am->api_trace_cfg))
+    {
+      clib_warning ("id out of range: %d", msg_id);
+      if (free)
+	vl_msg_api_free ((void *) elem);
+      return;
+    }
+
+  nbytes += msg_length;
+
+  /* Length in network byte order */
+  tmp = clib_host_to_net_u32 (nbytes);
+
+  vl_socket_add_pending_output (rp->unix_file_index
+				+ unix_main.file_pool,
+				rp->vl_api_registration_pool_index
+				+ socket_main.registration_pool,
+				(u8 *) & tmp, sizeof (tmp));
+  vl_socket_add_pending_output (rp->unix_file_index
+				+ unix_main.file_pool,
+				rp->vl_api_registration_pool_index
+				+ socket_main.registration_pool,
+				elem, msg_length);
+  if (free)
+    vl_msg_api_free ((void *) elem);
 }
 
-clib_error_t * vl_socket_read_ready (unix_file_t * uf)
+void
+vl_socket_api_send_with_length (vl_api_registration_t * rp,
+				u8 * elem, u32 msg_length)
 {
-    unix_main_t * um = &unix_main;
-    vl_api_registration_t * rp;
-    int n;
-    i8 *msg_buffer=0;
-    u32 msg_len;
-    u32 save_input_buffer_length = vec_len(socket_main.input_buffer);
-    
-    rp = pool_elt_at_index (socket_main.registration_pool, uf->private_data);
-    
-    n = read (uf->file_descriptor, socket_main.input_buffer, 
-              vec_len(socket_main.input_buffer));
+  vl_socket_api_send_with_length_internal (rp, elem, msg_length,
+					   1 /* free */ );
+}
 
-    if (n <= 0 && errno != EAGAIN) {
-        unix_file_del (um, uf);
+void
+vl_socket_api_send_with_length_no_free (vl_api_registration_t * rp,
+					u8 * elem, u32 msg_length)
+{
+  vl_socket_api_send_with_length_internal (rp, elem, msg_length,
+					   0 /* free */ );
+}
 
-        if (!pool_is_free (socket_main.registration_pool, rp)) {
-            u32 index = rp - socket_main.registration_pool;
-            vl_free_socket_registration_index (index);
-        } else {
-            clib_warning("client index %d already free?", 
-                         rp->vl_api_registration_pool_index);
-        }
-        return 0;
+void
+vl_free_socket_registration_index (u32 pool_index)
+{
+  vl_api_registration_t *rp;
+  if (pool_is_free_index (socket_main.registration_pool, pool_index))
+    {
+      clib_warning ("main pool index %d already free", pool_index);
+      return;
     }
-  
-    _vec_len(socket_main.input_buffer) = n;
+  rp = pool_elt_at_index (socket_main.registration_pool, pool_index);
 
-    /* 
-     * Look for bugs here. This code is tricky because
-     * data read from a stream socket does honor message
-     * boundaries. In the case of a long message (>4K bytes)
-     * we have to do (at least) 2 reads, etc.
-     */
-    do {
-        if (vec_len(rp->unprocessed_input)) {
-            vec_append(rp->unprocessed_input, socket_main.input_buffer);
-            msg_buffer = rp->unprocessed_input;
-            msg_len = rp->unprocessed_msg_length;
-        } else {
-            msg_buffer = socket_main.input_buffer;
-            msg_len = 0;
-        }
+  ASSERT (rp->registration_type != REGISTRATION_TYPE_FREE);
+  vec_free (rp->name);
+  vec_free (rp->unprocessed_input);
+  vec_free (rp->output_vector);
+  rp->registration_type = REGISTRATION_TYPE_FREE;
+  pool_put (socket_main.registration_pool, rp);
+}
 
-        if (msg_len == 0) {
-            /* Length may be split across two reads */
-            if (vec_len(msg_buffer) < sizeof (u32))
-                goto save_and_split;
+static inline void
+socket_process_msg (unix_file_t * uf, vl_api_registration_t * rp,
+		    i8 * input_v)
+{
+  u8 *the_msg = (u8 *) (input_v + sizeof (u32));
+  socket_main.current_uf = uf;
+  socket_main.current_rp = rp;
+  vl_msg_api_socket_handler (the_msg);
+  socket_main.current_uf = 0;
+  socket_main.current_rp = 0;
+}
 
-            /* total length, including msg_len itself, in network byte order */
-            msg_len = clib_net_to_host_u32 (*((u32 *)msg_buffer));
-        }
+clib_error_t *
+vl_socket_read_ready (unix_file_t * uf)
+{
+  unix_main_t *um = &unix_main;
+  vl_api_registration_t *rp;
+  int n;
+  i8 *msg_buffer = 0;
+  u32 msg_len;
+  u32 save_input_buffer_length = vec_len (socket_main.input_buffer);
 
-        /* Happens if the client sent msg_len == 0 */
-        if (msg_len == 0) {
-            clib_warning ("msg_len == 0");
-            goto turf_it;
-        }
+  rp = pool_elt_at_index (socket_main.registration_pool, uf->private_data);
 
-        /* We don't have the entire message yet. */
-        if (msg_len > vec_len(msg_buffer)) {
-        save_and_split:
-            /*
-             * if we were using the shared input buffer, 
-             * save the fragment.
-             */
-            if (msg_buffer == socket_main.input_buffer) {
-                ASSERT(vec_len(rp->unprocessed_input) == 0);
-                vec_validate (rp->unprocessed_input, vec_len (msg_buffer)-1);
-                clib_memcpy (rp->unprocessed_input, msg_buffer, vec_len(msg_buffer));
-                _vec_len (rp->unprocessed_input) = vec_len (msg_buffer);
-            }
-            _vec_len(socket_main.input_buffer) = save_input_buffer_length;
-            rp->unprocessed_msg_length = msg_len;
-            return 0;
-        }
+  n = read (uf->file_descriptor, socket_main.input_buffer,
+	    vec_len (socket_main.input_buffer));
 
-        socket_process_msg (uf, rp, msg_buffer);
-        if (n > msg_len)
-            vec_delete(msg_buffer, msg_len, 0);
-        else
-            _vec_len(msg_buffer) = 0;
-        n -= msg_len;
-        msg_len = 0;
-        rp->unprocessed_msg_length = 0;
-    } while (n > 0);
+  if (n <= 0 && errno != EAGAIN)
+    {
+      unix_file_del (um, uf);
+
+      if (!pool_is_free (socket_main.registration_pool, rp))
+	{
+	  u32 index = rp - socket_main.registration_pool;
+	  vl_free_socket_registration_index (index);
+	}
+      else
+	{
+	  clib_warning ("client index %d already free?",
+			rp->vl_api_registration_pool_index);
+	}
+      return 0;
+    }
+
+  _vec_len (socket_main.input_buffer) = n;
+
+  /*
+   * Look for bugs here. This code is tricky because
+   * data read from a stream socket does honor message
+   * boundaries. In the case of a long message (>4K bytes)
+   * we have to do (at least) 2 reads, etc.
+   */
+  do
+    {
+      if (vec_len (rp->unprocessed_input))
+	{
+	  vec_append (rp->unprocessed_input, socket_main.input_buffer);
+	  msg_buffer = rp->unprocessed_input;
+	  msg_len = rp->unprocessed_msg_length;
+	}
+      else
+	{
+	  msg_buffer = socket_main.input_buffer;
+	  msg_len = 0;
+	}
+
+      if (msg_len == 0)
+	{
+	  /* Length may be split across two reads */
+	  if (vec_len (msg_buffer) < sizeof (u32))
+	    goto save_and_split;
+
+	  /* total length, including msg_len itself, in network byte order */
+	  msg_len = clib_net_to_host_u32 (*((u32 *) msg_buffer));
+	}
+
+      /* Happens if the client sent msg_len == 0 */
+      if (msg_len == 0)
+	{
+	  clib_warning ("msg_len == 0");
+	  goto turf_it;
+	}
+
+      /* We don't have the entire message yet. */
+      if (msg_len > vec_len (msg_buffer))
+	{
+	save_and_split:
+	  /*
+	   * if we were using the shared input buffer,
+	   * save the fragment.
+	   */
+	  if (msg_buffer == socket_main.input_buffer)
+	    {
+	      ASSERT (vec_len (rp->unprocessed_input) == 0);
+	      vec_validate (rp->unprocessed_input, vec_len (msg_buffer) - 1);
+	      clib_memcpy (rp->unprocessed_input, msg_buffer,
+			   vec_len (msg_buffer));
+	      _vec_len (rp->unprocessed_input) = vec_len (msg_buffer);
+	    }
+	  _vec_len (socket_main.input_buffer) = save_input_buffer_length;
+	  rp->unprocessed_msg_length = msg_len;
+	  return 0;
+	}
+
+      socket_process_msg (uf, rp, msg_buffer);
+      if (n > msg_len)
+	vec_delete (msg_buffer, msg_len, 0);
+      else
+	_vec_len (msg_buffer) = 0;
+      n -= msg_len;
+      msg_len = 0;
+      rp->unprocessed_msg_length = 0;
+    }
+  while (n > 0);
 
 turf_it:
-    _vec_len(socket_main.input_buffer) = save_input_buffer_length;
+  _vec_len (socket_main.input_buffer) = save_input_buffer_length;
 
-    return 0;
+  return 0;
 }
 
 void
 vl_socket_add_pending_output (unix_file_t * uf,
-                              vl_api_registration_t * rp,
-                              u8 * buffer,
-                              uword buffer_bytes)
+			      vl_api_registration_t * rp,
+			      u8 * buffer, uword buffer_bytes)
 {
-    unix_main_t * um = &unix_main;
+  unix_main_t *um = &unix_main;
 
-    vec_add (rp->output_vector, buffer, buffer_bytes);
-    if (vec_len (rp->output_vector) > 0) {
-        int skip_update = 0 != (uf->flags & UNIX_FILE_DATA_AVAILABLE_TO_WRITE);
-        uf->flags |= UNIX_FILE_DATA_AVAILABLE_TO_WRITE;
-        if (! skip_update)
-            um->file_update (uf, UNIX_FILE_UPDATE_MODIFY);
+  vec_add (rp->output_vector, buffer, buffer_bytes);
+  if (vec_len (rp->output_vector) > 0)
+    {
+      int skip_update = 0 != (uf->flags & UNIX_FILE_DATA_AVAILABLE_TO_WRITE);
+      uf->flags |= UNIX_FILE_DATA_AVAILABLE_TO_WRITE;
+      if (!skip_update)
+	um->file_update (uf, UNIX_FILE_UPDATE_MODIFY);
     }
 }
 
 static void
 socket_del_pending_output (unix_file_t * uf,
-                           vl_api_registration_t * rp,
-                           uword n_bytes)
+			   vl_api_registration_t * rp, uword n_bytes)
 {
-    unix_main_t * um = &unix_main;
+  unix_main_t *um = &unix_main;
 
-    vec_delete (rp->output_vector, n_bytes, 0);
-    if (vec_len (rp->output_vector) <= 0)
+  vec_delete (rp->output_vector, n_bytes, 0);
+  if (vec_len (rp->output_vector) <= 0)
     {
-        int skip_update = 0 == (uf->flags & UNIX_FILE_DATA_AVAILABLE_TO_WRITE);
-        uf->flags &= ~UNIX_FILE_DATA_AVAILABLE_TO_WRITE;
-        if (! skip_update)
-            um->file_update (uf, UNIX_FILE_UPDATE_MODIFY);
+      int skip_update = 0 == (uf->flags & UNIX_FILE_DATA_AVAILABLE_TO_WRITE);
+      uf->flags &= ~UNIX_FILE_DATA_AVAILABLE_TO_WRITE;
+      if (!skip_update)
+	um->file_update (uf, UNIX_FILE_UPDATE_MODIFY);
     }
 }
 
-clib_error_t * 
+clib_error_t *
 vl_socket_write_ready (unix_file_t * uf)
 {
-    unix_main_t * um = &unix_main;
-    vl_api_registration_t * rp;
-    int n;
+  unix_main_t *um = &unix_main;
+  vl_api_registration_t *rp;
+  int n;
 
-    rp = pool_elt_at_index (socket_main.registration_pool, uf->private_data);
-    
-    /* Flush output vector. */
-    n = write (uf->file_descriptor,
-               rp->output_vector, vec_len (rp->output_vector));
+  rp = pool_elt_at_index (socket_main.registration_pool, uf->private_data);
 
-    if (n < 0) {
+  /* Flush output vector. */
+  n = write (uf->file_descriptor,
+	     rp->output_vector, vec_len (rp->output_vector));
+
+  if (n < 0)
+    {
 #if DEBUG > 2
-        clib_warning ("write error, close the file...\n");
+      clib_warning ("write error, close the file...\n");
 #endif
-        unix_file_del (um, uf);
+      unix_file_del (um, uf);
 
-        vl_free_socket_registration_index (rp - socket_main.registration_pool);
-        return 0;
+      vl_free_socket_registration_index (rp - socket_main.registration_pool);
+      return 0;
     }
 
-    else if (n > 0)
-        socket_del_pending_output (uf, rp, n);
+  else if (n > 0)
+    socket_del_pending_output (uf, rp, n);
 
-    return 0;
+  return 0;
 }
 
-clib_error_t * vl_socket_error_ready (unix_file_t * uf)
+clib_error_t *
+vl_socket_error_ready (unix_file_t * uf)
 {
-    vl_api_registration_t * rp;
-    unix_main_t * um = &unix_main;
+  vl_api_registration_t *rp;
+  unix_main_t *um = &unix_main;
 
-    rp = pool_elt_at_index (socket_main.registration_pool, uf->private_data);
-    unix_file_del (um, uf);
-    vl_free_socket_registration_index (rp - socket_main.registration_pool);
+  rp = pool_elt_at_index (socket_main.registration_pool, uf->private_data);
+  unix_file_del (um, uf);
+  vl_free_socket_registration_index (rp - socket_main.registration_pool);
 
-    return 0;
+  return 0;
 }
 
-void socksvr_file_add (unix_main_t *um, int fd)
+void
+socksvr_file_add (unix_main_t * um, int fd)
 {
-    vl_api_registration_t *rp;
-    unix_file_t template = {0};
-    
-    pool_get (socket_main.registration_pool, rp);
-    memset(rp, 0, sizeof(*rp));
-    
-    template.read_function = vl_socket_read_ready;
-    template.write_function = vl_socket_write_ready;
-    template.error_function = vl_socket_error_ready;
-    template.file_descriptor = fd;
-    template.private_data = rp - socket_main.registration_pool;
-    
-    rp->registration_type = REGISTRATION_TYPE_SOCKET_SERVER;
-    rp->vl_api_registration_pool_index = rp - socket_main.registration_pool;
-    rp->unix_file_index = unix_file_add (um, &template);
+  vl_api_registration_t *rp;
+  unix_file_t template = { 0 };
+
+  pool_get (socket_main.registration_pool, rp);
+  memset (rp, 0, sizeof (*rp));
+
+  template.read_function = vl_socket_read_ready;
+  template.write_function = vl_socket_write_ready;
+  template.error_function = vl_socket_error_ready;
+  template.file_descriptor = fd;
+  template.private_data = rp - socket_main.registration_pool;
+
+  rp->registration_type = REGISTRATION_TYPE_SOCKET_SERVER;
+  rp->vl_api_registration_pool_index = rp - socket_main.registration_pool;
+  rp->unix_file_index = unix_file_add (um, &template);
 }
 
-static clib_error_t * socksvr_accept_ready (unix_file_t * uf)
+static clib_error_t *
+socksvr_accept_ready (unix_file_t * uf)
 {
-    unix_main_t * um = &unix_main;
-    struct sockaddr_in client_addr;
-    int client_fd;
-    int client_len;
+  unix_main_t *um = &unix_main;
+  struct sockaddr_in client_addr;
+  int client_fd;
+  int client_len;
 
-    client_len = sizeof(client_addr);
-    
-    /*
-     * Supposedly acquires the non-blocking attrib from the
-     * server socket. 
-     */
-    client_fd = accept (uf->file_descriptor, 
-                        (struct sockaddr *)&client_addr, 
-                        (socklen_t *)&client_len);
+  client_len = sizeof (client_addr);
 
-    if (client_fd < 0)
-        return clib_error_return_unix (0, "socksvr_accept_ready: accept");
+  /*
+   * Supposedly acquires the non-blocking attrib from the
+   * server socket.
+   */
+  client_fd = accept (uf->file_descriptor,
+		      (struct sockaddr *) &client_addr,
+		      (socklen_t *) & client_len);
 
-    socksvr_file_add (um, client_fd);
-    return 0;
+  if (client_fd < 0)
+    return clib_error_return_unix (0, "socksvr_accept_ready: accept");
+
+  socksvr_file_add (um, client_fd);
+  return 0;
 }
 
-static clib_error_t * socksvr_bogus_write (unix_file_t * uf)
+static clib_error_t *
+socksvr_bogus_write (unix_file_t * uf)
 {
-    clib_warning ("why am I here?");
-    return 0;
+  clib_warning ("why am I here?");
+  return 0;
 }
 
 /*
  * vl_api_sockclnt_create_t_handler
  */
-void vl_api_sockclnt_create_t_handler (vl_api_sockclnt_create_t *mp)
+void
+vl_api_sockclnt_create_t_handler (vl_api_sockclnt_create_t * mp)
 {
-    vl_api_registration_t *regp;
-    vl_api_sockclnt_create_reply_t *rp;
-    int rv = 1;
+  vl_api_registration_t *regp;
+  vl_api_sockclnt_create_reply_t *rp;
+  int rv = 1;
 
-    regp = socket_main.current_rp;
+  regp = socket_main.current_rp;
 
-    ASSERT(regp->registration_type == REGISTRATION_TYPE_SOCKET_SERVER);
+  ASSERT (regp->registration_type == REGISTRATION_TYPE_SOCKET_SERVER);
 
-    regp->name = format(0, "%s%c", mp->name, 0);
+  regp->name = format (0, "%s%c", mp->name, 0);
 
-    rp = vl_msg_api_alloc(sizeof(*rp));
-    rp->_vl_msg_id = htons(VL_API_SOCKCLNT_CREATE_REPLY);
-    rp->handle = (uword)regp;
-    rp->index = (uword)regp->vl_api_registration_pool_index;
-    rp->context = mp->context;
-    rp->response = htonl(rv);
+  rp = vl_msg_api_alloc (sizeof (*rp));
+  rp->_vl_msg_id = htons (VL_API_SOCKCLNT_CREATE_REPLY);
+  rp->handle = (uword) regp;
+  rp->index = (uword) regp->vl_api_registration_pool_index;
+  rp->context = mp->context;
+  rp->response = htonl (rv);
 
-    vl_msg_api_send (regp, (u8 *)rp);
+  vl_msg_api_send (regp, (u8 *) rp);
 }
 
 /*
  * vl_api_sockclnt_delete_t_handler
  */
-void vl_api_sockclnt_delete_t_handler (vl_api_sockclnt_delete_t *mp)
+void
+vl_api_sockclnt_delete_t_handler (vl_api_sockclnt_delete_t * mp)
 {
-    vl_api_registration_t *regp;
-    vl_api_sockclnt_delete_reply_t *rp;
+  vl_api_registration_t *regp;
+  vl_api_sockclnt_delete_reply_t *rp;
 
-    if (!pool_is_free_index(socket_main.registration_pool, mp->index)) {
-        regp = pool_elt_at_index(socket_main.registration_pool, mp->index);
+  if (!pool_is_free_index (socket_main.registration_pool, mp->index))
+    {
+      regp = pool_elt_at_index (socket_main.registration_pool, mp->index);
 
-        rp = vl_msg_api_alloc(sizeof(*rp));
-        rp->_vl_msg_id = htons(VL_API_SOCKCLNT_DELETE_REPLY);
-        rp->handle = mp->handle;
-        rp->response = htonl(1);
-        
-        vl_msg_api_send (regp, (u8 *)rp);
+      rp = vl_msg_api_alloc (sizeof (*rp));
+      rp->_vl_msg_id = htons (VL_API_SOCKCLNT_DELETE_REPLY);
+      rp->handle = mp->handle;
+      rp->response = htonl (1);
 
-        unix_file_del (&unix_main, 
-                       unix_main.file_pool + regp->unix_file_index);
+      vl_msg_api_send (regp, (u8 *) rp);
 
-        vl_free_socket_registration_index (mp->index);
-    } else {
-        clib_warning("unknown client ID %d", mp->index);
+      unix_file_del (&unix_main, unix_main.file_pool + regp->unix_file_index);
+
+      vl_free_socket_registration_index (mp->index);
+    }
+  else
+    {
+      clib_warning ("unknown client ID %d", mp->index);
     }
 }
 
 #define foreach_vlib_api_msg                    \
 _(SOCKCLNT_CREATE, sockclnt_create)             \
-_(SOCKCLNT_DELETE, sockclnt_delete)             
+_(SOCKCLNT_DELETE, sockclnt_delete)
 
-static clib_error_t *socksvr_api_init (vlib_main_t * vm)
+static clib_error_t *
+socksvr_api_init (vlib_main_t * vm)
 {
-    unix_main_t * um = &unix_main;
-    unix_file_t template = {0};
-    int sockfd;
-    int one = 1;
-    int rv;
-    struct sockaddr_in serv_addr;
-    vl_api_registration_t *rp;
-    u16 portno;
-    u32 bind_address;
+  unix_main_t *um = &unix_main;
+  unix_file_t template = { 0 };
+  int sockfd;
+  int one = 1;
+  int rv;
+  struct sockaddr_in serv_addr;
+  vl_api_registration_t *rp;
+  u16 portno;
+  u32 bind_address;
 
 #define _(N,n)                                                  \
     vl_msg_api_set_handlers(VL_API_##N, #n,                     \
@@ -523,85 +558,93 @@
                            vl_noop_handler,                     \
                            vl_api_##n##_t_endian,               \
                            vl_api_##n##_t_print,                \
-                           sizeof(vl_api_##n##_t), 1); 
-    foreach_vlib_api_msg;
+                           sizeof(vl_api_##n##_t), 1);
+  foreach_vlib_api_msg;
 #undef _
 
-    vec_resize(socket_main.input_buffer, 4096);
+  vec_resize (socket_main.input_buffer, 4096);
 
-    /* Set up non-blocking server socket on CLIENT_API_SERVER_PORT */
-    sockfd = socket(AF_INET, SOCK_STREAM, 0);
+  /* Set up non-blocking server socket on CLIENT_API_SERVER_PORT */
+  sockfd = socket (AF_INET, SOCK_STREAM, 0);
 
-    if (sockfd < 0) {
-        return clib_error_return_unix (0, "socket");
+  if (sockfd < 0)
+    {
+      return clib_error_return_unix (0, "socket");
     }
 
-    rv = ioctl (sockfd, FIONBIO, &one);
-    if (rv < 0) {
-        return clib_error_return_unix (0, "FIONBIO");
+  rv = ioctl (sockfd, FIONBIO, &one);
+  if (rv < 0)
+    {
+      return clib_error_return_unix (0, "FIONBIO");
     }
 
-    rv = setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
-    if (rv < 0) {
-        return clib_error_return_unix (0, "SO_REUSEADDR");
+  rv = setsockopt (sockfd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof (one));
+  if (rv < 0)
+    {
+      return clib_error_return_unix (0, "SO_REUSEADDR");
     }
 
-    bzero((char *) &serv_addr, sizeof(serv_addr));
-    serv_addr.sin_family = AF_INET;
+  bzero ((char *) &serv_addr, sizeof (serv_addr));
+  serv_addr.sin_family = AF_INET;
 
-    if (socket_main.bind_address)
-        bind_address = socket_main.bind_address;
-    else
-        bind_address = INADDR_LOOPBACK;
+  if (socket_main.bind_address)
+    bind_address = socket_main.bind_address;
+  else
+    bind_address = INADDR_LOOPBACK;
 
-    if (socket_main.portno) 
-        portno = socket_main.portno;
-    else
-        portno = SOCKSVR_DEFAULT_PORT;
+  if (socket_main.portno)
+    portno = socket_main.portno;
+  else
+    portno = SOCKSVR_DEFAULT_PORT;
 
-    serv_addr.sin_port = clib_host_to_net_u16 (portno);
-    serv_addr.sin_addr.s_addr = clib_host_to_net_u32(bind_address);
+  serv_addr.sin_port = clib_host_to_net_u16 (portno);
+  serv_addr.sin_addr.s_addr = clib_host_to_net_u32 (bind_address);
 
-    if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
-        return clib_error_return_unix (0, "bind");
-    }
-           
-    rv = listen(sockfd,5);
-    if (rv < 0) {
-        return clib_error_return_unix (0, "listen");
+  if (bind (sockfd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0)
+    {
+      return clib_error_return_unix (0, "bind");
     }
 
-    pool_get (socket_main.registration_pool, rp);
-    memset(rp, 0, sizeof(*rp));
-    
-    rp->registration_type = REGISTRATION_TYPE_SOCKET_LISTEN;
+  rv = listen (sockfd, 5);
+  if (rv < 0)
+    {
+      return clib_error_return_unix (0, "listen");
+    }
 
-    template.read_function = socksvr_accept_ready;
-    template.write_function = socksvr_bogus_write;
-    template.file_descriptor = sockfd;
-    template.private_data = rp - socket_main.registration_pool;
-    
-    rp->unix_file_index = unix_file_add (um, &template);
-    return 0;
+  pool_get (socket_main.registration_pool, rp);
+  memset (rp, 0, sizeof (*rp));
+
+  rp->registration_type = REGISTRATION_TYPE_SOCKET_LISTEN;
+
+  template.read_function = socksvr_accept_ready;
+  template.write_function = socksvr_bogus_write;
+  template.file_descriptor = sockfd;
+  template.private_data = rp - socket_main.registration_pool;
+
+  rp->unix_file_index = unix_file_add (um, &template);
+  return 0;
 }
 
 static clib_error_t *
 socket_exit (vlib_main_t * vm)
 {
-    unix_main_t * um = &unix_main;
-    vl_api_registration_t *rp;
+  unix_main_t *um = &unix_main;
+  vl_api_registration_t *rp;
 
-    /* Defensive driving in case something wipes out early */
-    if (socket_main.registration_pool) {
-        u32 index;
+  /* Defensive driving in case something wipes out early */
+  if (socket_main.registration_pool)
+    {
+      u32 index;
+        /* *INDENT-OFF* */
         pool_foreach (rp, socket_main.registration_pool, ({
             unix_file_del (um, um->file_pool + rp->unix_file_index);
             index = rp->vl_api_registration_pool_index;
             vl_free_socket_registration_index (index);
         }));
+/* *INDENT-ON* */
     }
 
-    return 0;
+  return 0;
 }
 
 VLIB_MAIN_LOOP_EXIT_FUNCTION (socket_exit);
@@ -609,38 +652,51 @@
 static clib_error_t *
 socksvr_config (vlib_main_t * vm, unformat_input_t * input)
 {
-    int portno;
+  int portno;
 
-    while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     {
-        if (unformat (input, "port %d", &portno)) {
-            socket_main.portno = portno;
-        } else {
-            return clib_error_return (0, "unknown input '%U'",
-                                      format_unformat_error, input);
-        }
+      if (unformat (input, "port %d", &portno))
+	{
+	  socket_main.portno = portno;
+	}
+      else
+	{
+	  return clib_error_return (0, "unknown input '%U'",
+				    format_unformat_error, input);
+	}
     }
-    return socksvr_api_init (vm);
+  return socksvr_api_init (vm);
 }
 
 VLIB_CONFIG_FUNCTION (socksvr_config, "socksvr");
 
 /* argument in host byte order */
-void socksvr_set_port (u16 port)
+void
+socksvr_set_port (u16 port)
 {
-    socket_main.portno = port;
+  socket_main.portno = port;
 }
 
 /* argument in host byte order */
-void socksvr_set_bind_address (u32 bind_address)
+void
+socksvr_set_bind_address (u32 bind_address)
 {
-    socket_main.bind_address = bind_address;
+  socket_main.bind_address = bind_address;
 }
 
 clib_error_t *
 vlibsocket_init (vlib_main_t * vm)
 {
-    return 0;
+  return 0;
 }
 
 VLIB_INIT_FUNCTION (vlibsocket_init);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
