diff --git a/extras/vcl-ldpreload/src/.gitignore b/extras/vcl-ldpreload/src/.gitignore
new file mode 100644
index 0000000..9578123
--- /dev/null
+++ b/extras/vcl-ldpreload/src/.gitignore
@@ -0,0 +1,17 @@
+*.m4
+autom4te.cache
+compile
+config.*
+configure
+depcomp
+install-sh
+ltmain.sh
+missing
+Makefile.in
+Makefile
+*.o
+*.l[oa]*
+*.Plo
+*.dirstamp
+*.so*
+libtool
diff --git a/extras/vcl-ldpreload/src/Makefile.am b/extras/vcl-ldpreload/src/Makefile.am
new file mode 100644
index 0000000..a131769
--- /dev/null
+++ b/extras/vcl-ldpreload/src/Makefile.am
@@ -0,0 +1,62 @@
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+###############################################################################
+# Global Defines
+###############################################################################
+
+AUTOMAKE_OPTIONS = foreign subdir-objects
+ACLOCAL_AMFLAGS = -I m4
+AM_LIBTOOLFLAGS = --quiet
+
+AM_CFLAGS = -Wall -fstack-protector -fPIC -Werror -g -DFORTIFY_SOURCE=2
+AM_LDFLAGS = -shared
+
+if VPP_DEBUG
+AM_CFLAGS += -O0 -DCLIB_DEBUG
+vpp_build = vpp_debug-native
+else
+AM_CFLAGS += -O2
+vpp_build = vpp-native
+endif
+
+if VCL_LDPRELOAD_DEBUG
+AM_CFLAGS += -ggdb '-DVCOM_DEBUG=1'
+else
+AM_CFLAGS += -Wall '-DVCOM_DEBUG=0'
+endif
+
+if VPP_DIR_SET
+vpp_install_dir = @VPP_DIR@/build-root/install-$(vpp_build)/vpp
+AM_CFLAGS += -I$(vpp_install_dir)/include/
+AM_LDFLAGS += -L$(vpp_install_dir)/lib64/
+endif
+
+
+AM_LDFLAGS += -lvppcom -lvppinfra
+
+SUBDIRS = .
+noinst_HEADERS =
+dist_bin_SCRIPTS =
+lib_LTLIBRARIES =
+BUILT_SOURCES =
+CLEANFILES =
+
+
+###############################################################################
+# Components
+###############################################################################
+
+include libvcl-ldpreload.am
+
+
diff --git a/extras/vcl-ldpreload/src/configure.ac b/extras/vcl-ldpreload/src/configure.ac
new file mode 100644
index 0000000..cee7c95
--- /dev/null
+++ b/extras/vcl-ldpreload/src/configure.ac
@@ -0,0 +1,151 @@
+AC_INIT([vcl-ldpreload], [1.0], [vpp-dev@fd.io])
+LT_INIT
+AC_CONFIG_AUX_DIR([.])
+AM_INIT_AUTOMAKE([subdir-objects])
+AM_SILENT_RULES([yes])
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_MACRO_DIR([m4])
+
+AC_PROG_CC
+AM_PROG_AS
+AM_PROG_LIBTOOL
+AC_PROG_YACC
+AM_PATH_PYTHON
+
+AC_ARG_VAR(VPP_DIR,[ vpp build directory ])
+AM_CONDITIONAL([VPP_DIR_SET], [test ! -z "$VPP_DIR"])
+
+###############################################################################
+# Macros
+###############################################################################
+
+AC_DEFUN([ENABLE_ARG],
+[
+  AC_ARG_ENABLE($1,
+    AC_HELP_STRING(patsubst([--enable-$1],[_],[-]), $2),
+    [enable_$1=yes n_enable_$1=1],
+    [enable_$1=no n_enable_$1=0])
+  AM_CONDITIONAL(m4_toupper(ENABLE_$1), test "$enable_$1" = "yes")
+  m4_append([list_of_enabled], [$1], [, ])
+])
+
+AC_DEFUN([DISABLE_ARG],
+[
+  AC_ARG_ENABLE($1,
+    AC_HELP_STRING(patsubst([--disable-$1],[_],[-]), $2),
+    [enable_$1=no n_enable_$1=0],
+    [enable_$1=yes n_enable_$1=1])
+  AM_CONDITIONAL(m4_toupper(ENABLE_$1), test "$enable_$1" = "yes")
+  m4_append([list_of_enabled], [$1], [, ])
+])
+
+AC_DEFUN([WITH_ARG],
+[
+  AC_ARG_WITH($1,
+    AC_HELP_STRING(patsubst([--with-$1],[_],[-]), $2),
+    [with_$1=yes n_with_$1=1],
+    [with_$1=no n_with_$1=0])
+  AM_CONDITIONAL(m4_toupper(WITH_$1), test "$with_$1" = "yes")
+  m4_append([list_of_with], [$1], [, ])
+])
+
+AC_DEFUN([WITHOUT_ARG],
+[
+  AC_ARG_WITH($1,
+    AC_HELP_STRING(patsubst([--without-$1],[_],[-]), $2),
+    [with_$1=no n_with_$1=0],
+    [with_$1=yes n_with_$1=1])
+  AM_CONDITIONAL(m4_toupper(WITH_$1), test "$with_$1" = "yes")
+  m4_append([list_of_with], [$1], [, ])
+])
+
+
+AC_DEFUN([PRINT_VAL], [ AC_MSG_RESULT(AC_HELP_STRING($1,$2)) ])
+
+
+###############################################################################
+# configure arguments
+###############################################################################
+
+# --enable-X
+
+AC_ARG_ENABLE([vpp-debug],
+[  --enable-vpp-debug    Use vpp debug native build libraries],
+ [if test x$enableval = xyes; then
+    AC_DEFINE(VPP_DEBUG, 1, [Define this to use vpp debug native build libraries.])
+    vpp_debug=true
+ fi], [vpp_debug=false])
+AM_CONDITIONAL([VPP_DEBUG], [test x$vpp_debug = xtrue])
+
+AC_ARG_ENABLE([vcl-ldpreload-debug],
+[  --enable-vcl-ldpreload-debug    Turn on vcl-ldpreload debugging],
+ [if test x$enableval = xyes; then
+    AC_DEFINE(VCL_LDPRELOAD_DEBUG, 1, [Define this to enable vcl-ldpreload debug.])
+    vcl_ldpreload_debug=true
+ fi], [vcl_ldpreload_debug=false])
+AM_CONDITIONAL([VCL_LDPRELOAD_DEBUG], [test x$vcl_ldpreload_debug = xtrue])
+
+# --disable-X
+
+# --with-X
+
+# --without-X
+
+AC_ARG_WITH(unix,
+            AC_HELP_STRING([--with-unix],[Compile unix version of clib]),
+	    [],
+	    [case $host_os in
+	      darwin* | linux*) with_unix=yes;;
+	      *) with_unix=no;;
+	      esac])
+
+AM_CONDITIONAL(WITH_UNIX, test "$with_unix" = "yes")
+
+
+###############################################################################
+# Substitutions and defines
+###############################################################################
+
+
+# Silence following noise:
+# ar: `u' modifier ignored since `D' is the default (see `U')
+AR_FLAGS=cr
+AC_SUBST(AR_FLAGS)
+
+
+###############################################################################
+# Dependency checks
+###############################################################################
+
+###############################################################################
+# Output
+###############################################################################
+
+AC_OUTPUT
+
+AC_MSG_RESULT([==============================================================================])
+PRINT_VAL([version], $PACKAGE $VERSION)
+PRINT_VAL([prefix], ${prefix})
+PRINT_VAL([exec_prefix], ${exec_prefix})
+PRINT_VAL([libdir], ${libdir})
+PRINT_VAL([includedir], ${includedir})
+PRINT_VAL([CFLAGS], ${CFLAGS})
+PRINT_VAL([CPPFLAGS], ${CPPFLAGS})
+PRINT_VAL([LDFLAGS], ${LDFLAGS})
+
+AC_MSG_RESULT([])
+AC_MSG_RESULT([with:])
+m4_foreach([x], m4_dquote(list_of_with), [
+  AC_MSG_RESULT(AC_HELP_STRING(x, m4_join([], [${with_], x, [}])))
+])
+
+AC_MSG_RESULT([])
+AC_MSG_RESULT([enabled:])
+m4_foreach([x], m4_dquote(list_of_enabled), [
+  AC_MSG_RESULT(AC_HELP_STRING(x, m4_join([], [${enable_], x, [}])))
+])
+
+AC_MSG_RESULT([])
+AC_MSG_RESULT([==============================================================================])
+
+
diff --git a/extras/vcl-ldpreload/src/libvcl-ldpreload.am b/extras/vcl-ldpreload/src/libvcl-ldpreload.am
new file mode 100644
index 0000000..0d2fcb5
--- /dev/null
+++ b/extras/vcl-ldpreload/src/libvcl-ldpreload.am
@@ -0,0 +1,31 @@
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+lib_LTLIBRARIES += libvcl_ldpreload.la
+
+libvcl_ldpreload_la_SOURCES =
+nobase_include_HEADERS =
+
+libvcl_ldpreload_la_LIBADD = -lvppinfra -lvppcom  -lpthread
+
+libvcl_ldpreload_la_SOURCES +=                   \
+  libvcl-ldpreload/vcom_socket_wrapper.c         \
+  libvcl-ldpreload/vcom.c                        \
+  libvcl-ldpreload/vcom_socket.c
+
+nobase_include_HEADERS +=                        \
+  libvcl-ldpreload/vcom_socket_wrapper.h         \
+  libvcl-ldpreload/vcom_glibc_socket.h           \
+  libvcl-ldpreload/vcom.h                        \
+  libvcl-ldpreload/vcom_socket.h
+
diff --git a/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.c b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.c
new file mode 100644
index 0000000..6245c5d
--- /dev/null
+++ b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.c
@@ -0,0 +1,2980 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <unistd.h>
+#include <stdio.h>
+#include <signal.h>
+#include <dlfcn.h>
+#include <pthread.h>
+#include <time.h>
+#include <stdarg.h>
+
+#include <libvcl-ldpreload/vcom_socket_wrapper.h>
+#include <libvcl-ldpreload/vcom.h>
+#include <sys/time.h>
+
+#include <uri/vppcom.h>
+#include <libvcl-ldpreload/vcom_socket.h>
+
+/* GCC have printf type attribute check. */
+#ifdef HAVE_FUNCTION_ATTRIBUTE_FORMAT
+#define PRINTF_ATTRIBUTE(a,b)                       \
+    __attribute__ ((__format__ (__printf__, a, b)))
+#else
+#define PRINTF_ATTRIBUTE(a,b)
+#endif /* HAVE_FUNCTION_ATTRIBUTE_FORMAT */
+
+#define HAVE_CONSTRUCTOR_ATTRIBUTE
+#ifdef HAVE_CONSTRUCTOR_ATTRIBUTE
+#define CONSTRUCTOR_ATTRIBUTE                       \
+    __attribute__ ((constructor))
+#else
+#define CONSTRUCTOR_ATTRIBUTE
+#endif /* HAVE_CONSTRUCTOR_ATTRIBUTE */
+
+#define HAVE_DESTRUCTOR_ATTRIBUTE
+#ifdef HAVE_DESTRUCTOR_ATTRIBUTE
+#define DESTRUCTOR_ATTRIBUTE                        \
+    __attribute__ ((destructor))
+#else
+#define DESTRUCTOR_ATTRIBUTE
+#endif
+
+#define HAVE_ADDRESS_SANITIZER_ATTRIBUTE
+#ifdef HAVE_ADDRESS_SANITIZER_ATTRIBUTE
+#define DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE           \
+    __attribute__((no_sanitize_address))
+#else
+#define DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE
+#endif
+
+#define VCOM_SOCKET_FD_MAX  0x10000
+
+static char vcom_app_name[MAX_VCOM_APP_NAME];
+
+/*
+ * RETURN:  0 on success or -1 on error.
+ * */
+int
+vcom_set_app_name (char *__app_name)
+{
+  return snprintf (vcom_app_name, MAX_VCOM_APP_NAME, "vcom-%s-%d",
+		   __app_name, getpid ()) < 0 ? -1 : 0;
+}
+
+static char *
+vcom_get_app_name ()
+{
+  if (vcom_app_name[0] == '\0')
+    {
+      snprintf (vcom_app_name, MAX_VCOM_APP_NAME, "vcom-app-%d", getpid ());
+    }
+  return vcom_app_name;
+}
+
+/*
+ * 1 if init, 0 otherwise
+ */
+static int is_vcom_init;
+
+/*
+ * TBD: Make it thread safe
+ */
+
+/*
+ * constructor function called before main is called
+ * RETURN: 0 on success -1 on failure
+ * */
+static inline int
+vcom_init ()
+{
+  pid_t pid = getpid ();
+
+  if (!is_vcom_init)
+    {
+      if (vppcom_app_create (vcom_get_app_name ()) != 0)
+	{
+	  printf ("\n[%d] vcom_init...failed!\n", pid);
+	  if (VCOM_DEBUG > 0)
+	    fprintf (stderr,
+		     "[%d] vcom_init: vppcom_app_create failed!\n", pid);
+	  return -1;
+	}
+      if (vcom_socket_main_init () != 0)
+	{
+	  printf ("\n[%d] vcom_init...failed!\n", pid);
+	  if (VCOM_DEBUG > 0)
+	    fprintf (stderr,
+		     "[%d] vcom_init: vcom_socket_main_init failed!\n", pid);
+	  return -1;
+	}
+
+      is_vcom_init = 1;
+      printf ("\n[%d] vcom_init...done!\n", pid);
+    }
+  return 0;
+}
+
+static inline void
+vcom_destroy (void)
+{
+  pid_t pid = getpid ();
+
+  if (is_vcom_init)
+    {
+      vcom_socket_main_destroy ();
+      vppcom_app_destroy ();
+      is_vcom_init = 0;
+      fprintf (stderr, "\n[%d] vcom_destroy...done!\n", pid);
+    }
+}
+
+static inline int
+is_vcom_socket_fd (int fd)
+{
+  return vcom_socket_is_vcom_fd (fd);
+}
+
+static inline int
+is_vcom_epfd (int epfd)
+{
+  return vcom_socket_is_vcom_epfd (epfd);
+}
+
+
+/*
+ *
+ * Generic glibc fd api
+ *
+ */
+
+/* Close the file descriptor FD.
+
+   This function is a cancellation point and therefore
+   not marked with __THROW.  */
+/*
+ * PRE:     is_vcom_socket_fd(__fd) == 1
+ * RETURN:  0 on success and -1 for errors.
+ * */
+int
+vcom_close (int __fd)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  if (vcom_socket_close (__fd) != 0)
+    {
+      return -1;
+    }
+
+  return 0;
+}
+
+/*
+ * RETURN:  0 on success, or -1 on error
+ */
+int
+close (int __fd)
+{
+  int rv;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd) || is_vcom_epfd (__fd))
+    {
+      if (VCOM_DEBUG > 0)
+	vcom_socket_main_show ();
+      rv = vcom_close (__fd);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr, "[%d] close: " "'%04d'='%04d'\n", pid, rv, __fd);
+      if (VCOM_DEBUG > 0)
+	vcom_socket_main_show ();
+      if (rv != 0)
+	{
+	  errno = -rv;
+	  return -1;
+	}
+      return 0;
+    }
+  return libc_close (__fd);
+}
+
+/* Read NBYTES into BUF from FD.  Return the
+   number read, -1 for errors or 0 for EOF.
+
+   This function is a cancellation point and therefore
+   not marked with __THROW.  */
+ssize_t
+vcom_read (int __fd, void *__buf, size_t __nbytes)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_read (__fd, __buf, __nbytes);
+}
+
+ssize_t
+read (int __fd, void *__buf, size_t __nbytes)
+{
+  ssize_t size = 0;
+  pid_t pid = getpid ();
+  pthread_t tid = pthread_self ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d][%lu (0x%lx)] read:1 "
+		 "'%04d'='%04d', '%p', '%04d'\n",
+		 pid, (unsigned long) tid, (unsigned long) tid,
+		 (int) size, __fd, __buf, (int) __nbytes);
+      size = vcom_read (__fd, __buf, __nbytes);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d][%lu (0x%lx)] read:2 "
+		 "'%04d'='%04d', '%p', '%04d'\n",
+		 pid, (unsigned long) tid, (unsigned long) tid,
+		 (int) size, __fd, __buf, (int) __nbytes);
+      if (size < 0)
+	{
+	  errno = -size;
+	  return -1;
+	}
+      return size;
+    }
+  return libc_read (__fd, __buf, __nbytes);
+}
+
+ssize_t
+vcom_readv (int __fd, const struct iovec * __iov, int __iovcnt)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_readv (__fd, __iov, __iovcnt);
+}
+
+ssize_t
+readv (int __fd, const struct iovec * __iov, int __iovcnt)
+{
+  ssize_t size = 0;
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      size = vcom_readv (__fd, __iov, __iovcnt);
+      if (size < 0)
+	{
+	  errno = -size;
+	  return -1;
+	}
+      return size;
+    }
+  else
+    return libc_readv (__fd, __iov, __iovcnt);
+}
+
+/* Write N bytes of BUF to FD.  Return the number written, or -1.
+
+   This function is a cancellation point and therefore
+   not marked with __THROW.  */
+ssize_t
+vcom_write (int __fd, const void *__buf, size_t __n)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_write (__fd, (void *) __buf, __n);
+}
+
+ssize_t
+write (int __fd, const void *__buf, size_t __n)
+{
+  ssize_t size = 0;
+  pid_t pid = getpid ();
+  pthread_t tid = pthread_self ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d][%lu (0x%lx)] write:1 "
+		 "'%04d'='%04d', '%p', '%04d'\n",
+		 pid, (unsigned long) tid, (unsigned long) tid,
+		 (int) size, __fd, __buf, (int) __n);
+      size = vcom_write (__fd, __buf, __n);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d][%lu (0x%lx)] write:2 "
+		 "'%04d'='%04d', '%p', '%04d'\n",
+		 pid, (unsigned long) tid, (unsigned long) tid,
+		 (int) size, __fd, __buf, (int) __n);
+      if (size < 0)
+	{
+	  errno = -size;
+	  return -1;
+	}
+      return size;
+    }
+  return libc_write (__fd, __buf, __n);
+}
+
+ssize_t
+vcom_writev (int __fd, const struct iovec * __iov, int __iovcnt)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_writev (__fd, __iov, __iovcnt);
+}
+
+ssize_t
+writev (int __fd, const struct iovec * __iov, int __iovcnt)
+{
+  ssize_t size = 0;
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      size = vcom_writev (__fd, __iov, __iovcnt);
+      if (size < 0)
+	{
+	  errno = -size;
+	  return -1;
+	}
+      return size;
+    }
+  else
+    return libc_writev (__fd, __iov, __iovcnt);
+}
+
+/* Do the file control operation described by CMD on FD.
+   The remaining arguments are interpreted depending on CMD.
+
+   This function is a cancellation point and therefore
+   not marked with __THROW.  */
+int
+vcom_fcntl_va (int __fd, int __cmd, va_list __ap)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_fcntl_va (__fd, __cmd, __ap);
+}
+
+int
+vcom_fcntl (int __fd, int __cmd, ...)
+{
+  int rv = -1;
+  va_list ap;
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      va_start (ap, __cmd);
+      rv = vcom_fcntl_va (__fd, __cmd, ap);
+      va_end (ap);
+    }
+  return rv;
+}
+
+int
+fcntl (int __fd, int __cmd, ...)
+{
+  int rv;
+  va_list ap;
+  pid_t pid = getpid ();
+
+  va_start (ap, __cmd);
+  if (is_vcom_socket_fd (__fd))
+    {
+      rv = vcom_fcntl_va (__fd, __cmd, ap);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] fcntl: "
+		 "'%04d'='%04d', '%04d'\n", pid, rv, __fd, __cmd);
+      if (rv < 0)
+	{
+	  errno = -rv;
+	  rv = -1;
+	}
+      goto out;
+    }
+  rv = libc_vfcntl (__fd, __cmd, ap);
+
+out:
+  va_end (ap);
+  return rv;
+}
+
+/*
+ * Check the first NFDS descriptors each in READFDS (if not NULL) for
+ *  read readiness, in WRITEFDS (if not NULL) for write readiness,
+ *  and in EXCEPTFDS (if not NULL) for exceptional conditions.
+ *  If TIMEOUT is not NULL, time out after waiting the interval
+ *  specified therein.  Returns the number of ready descriptors,
+ *  or -1 for errors.
+ *
+ * This function is a cancellation point and therefore not marked
+ * with __THROW.
+ * */
+
+/*
+ * clear all vcom FDs from fd_sets __readfds, __writefds and
+ * __exceptfds and update the new nfds
+ *
+ * new nfds is the highest-numbered file descriptor
+ * in any of the three sets, plus 1
+ *
+ * Return the number of file descriptors contained in the
+ * three descriptor sets. ie. the total number of the bits
+ * that are set in  __readfds, __writefds and __exceptfds
+ */
+static inline int
+vcom_fd_clear (int __nfds,
+	       int *__new_nfds,
+	       fd_set * __restrict __readfds,
+	       fd_set * __restrict __writefds,
+	       fd_set * __restrict __exceptfds)
+{
+  int fd;
+  /* invalid max_fd is -1 */
+  int max_fd = -1;
+  int nfd = 0;
+
+
+  /* clear all vcom fd from the sets */
+  for (fd = 0; fd < __nfds; fd++)
+    {
+
+      /* clear vcom fd from set */
+      /*
+       * F fd set
+       */
+#define _(F)                                    \
+      if ((F) && FD_ISSET (fd, (F)))            \
+        {                                       \
+          if (is_vcom_socket_fd (fd))           \
+            {                                   \
+              FD_CLR (fd, (F));                 \
+            }                                   \
+        }
+
+
+      _(__readfds);
+      _(__writefds);
+      _(__exceptfds);
+#undef _
+    }
+
+  /*
+   *  compute nfd and __new_nfds
+   */
+  for (fd = 0; fd < __nfds; fd++)
+    {
+
+      /*
+       * F fd set
+       */
+#define _(F)                                    \
+      if ((F) && FD_ISSET (fd, (F)))            \
+        {                                       \
+          if (fd > max_fd)                      \
+            {                                   \
+              max_fd = fd;                      \
+            }                                   \
+          ++nfd;                                \
+        }
+
+
+      _(__readfds);
+      _(__writefds);
+      _(__exceptfds);
+#undef _
+    }
+
+  *__new_nfds = max_fd != -1 ? max_fd + 1 : 0;
+  return nfd;
+}
+
+/*
+ * Return the number of file descriptors contained in the
+ * three descriptor sets. ie. the total number of the bits
+ * that are set in  __readfds, __writefds and __exceptfds
+ */
+static inline int
+vcom_fd_set (int __nfds,
+	     /* dest */
+	     int *__new_nfds,
+	     fd_set * __restrict __readfds,
+	     fd_set * __restrict __writefds, fd_set * __restrict __exceptfds,
+	     /* src */
+	     fd_set * __restrict __saved_readfds,
+	     fd_set * __restrict __saved_writefds,
+	     fd_set * __restrict __saved_exceptfds)
+{
+  int fd;
+  /* invalid max_fd is -1 */
+  int max_fd = -1;
+  int nfd = 0;
+
+  for (fd = 0; fd < __nfds; fd++)
+    {
+      /*
+       * F fd set
+       * S saved fd set
+       */
+#define _(S,F)                                  \
+      if ((F) && (S) && FD_ISSET (fd, (S)))     \
+        {                                       \
+          if (is_vcom_socket_fd (fd))           \
+            {                                   \
+              FD_SET (fd, (F));                 \
+            }                                   \
+        }
+
+
+      _(__saved_readfds, __readfds);
+      _(__saved_writefds, __writefds);
+#undef _
+    }
+
+
+  /*
+   *  compute nfd and __new_nfds
+   */
+  for (fd = 0; fd < __nfds; fd++)
+    {
+
+      /*
+       * F fd set
+       */
+#define _(F)                                    \
+      if ((F) && FD_ISSET (fd, (F)))            \
+        {                                       \
+          if (fd > max_fd)                      \
+            {                                   \
+              max_fd = fd;                      \
+            }                                   \
+          ++nfd;                                \
+        }
+
+
+      _(__readfds);
+      _(__writefds);
+      _(__exceptfds);
+#undef _
+    }
+
+  *__new_nfds = max_fd != -1 ? max_fd + 1 : 0;
+  return nfd;
+}
+
+/*
+ * split select sets(src) into
+ * vcom sets(dest1) and libc sets(dest2)
+ */
+static inline void
+vcom_fd_set_split (
+		    /* src, select sets */
+		    int nfds,
+		    fd_set * __restrict readfds,
+		    fd_set * __restrict writefds,
+		    fd_set * __restrict exceptfds,
+		    /* dest1, vcom sets */
+		    int *vcom_nfds,
+		    fd_set * __restrict vcom_readfds,
+		    fd_set * __restrict vcom_writefds,
+		    fd_set * __restrict vcom_exceptfds, int *vcom_nfd,
+		    /* dest2, libc sets */
+		    int *libc_nfds,
+		    fd_set * __restrict libc_readfds,
+		    fd_set * __restrict libc_writefds,
+		    fd_set * __restrict libc_exceptfds, int *libc_nfd)
+{
+  int fd;
+
+  /* vcom */
+  /* invalid max_fd is -1 */
+  int vcom_max_fd = -1;
+  int vcom_nfd2 = 0;
+
+  /* libc */
+  /* invalid max_fd is -1 */
+  int libc_max_fd = -1;
+  int libc_nfd2 = 0;
+
+
+  for (fd = 0; fd < nfds; fd++)
+    {
+      /*
+       * S select fd set
+       * V vcom fd set
+       * L libc fd set
+       */
+#define _(S,V,L)                            \
+      if ((S) && FD_ISSET (fd, (S)))        \
+        {                                   \
+          if (is_vcom_socket_fd (fd))       \
+            {                               \
+              if ((V))                      \
+                {                           \
+                  FD_SET(fd, (V));          \
+                  if (fd > vcom_max_fd)     \
+                    {                       \
+                      vcom_max_fd = fd;     \
+                    }                       \
+                  ++vcom_nfd2;              \
+                }                           \
+            }                               \
+          else                              \
+            {                               \
+              if ((L))                      \
+                {                           \
+                  FD_SET(fd, (L));          \
+                  if (fd > libc_max_fd)     \
+                    {                       \
+                      libc_max_fd = fd;     \
+                    }                       \
+                  ++libc_nfd2;              \
+                }                           \
+            }                               \
+        }
+
+
+      _(readfds, vcom_readfds, libc_readfds);
+      _(writefds, vcom_writefds, libc_writefds);
+      _(exceptfds, vcom_exceptfds, libc_exceptfds);
+#undef _
+    }
+
+  if (vcom_nfds)
+    *vcom_nfds = vcom_max_fd != -1 ? vcom_max_fd + 1 : 0;
+  if (vcom_nfd)
+    *vcom_nfd = vcom_nfd2;
+  if (libc_nfds)
+    *libc_nfds = libc_max_fd != -1 ? libc_max_fd + 1 : 0;
+  if (libc_nfd)
+    *libc_nfd = libc_nfd2;
+}
+
+/*
+ * merge vcom sets(src1) and libc sets(src2)
+ * into select sets(dest)
+ */
+static inline void
+vcom_fd_set_merge (
+		    /* dest, select sets */
+		    int *nfds,
+		    fd_set * __restrict readfds,
+		    fd_set * __restrict writefds,
+		    fd_set * __restrict exceptfds, int *nfd,
+		    /* src1, vcom sets */
+		    int vcom_nfds,
+		    fd_set * __restrict vcom_readfds,
+		    fd_set * __restrict vcom_writefds,
+		    fd_set * __restrict vcom_exceptfds, int vcom_nfd,
+		    /* src2, libc sets */
+		    int libc_nfds,
+		    fd_set * __restrict libc_readfds,
+		    fd_set * __restrict libc_writefds,
+		    fd_set * __restrict libc_exceptfds, int libc_nfd)
+{
+  int fd;
+  /* invalid max_fd is -1 */
+  int max_fd = -1;
+  int nfd2 = 0;
+
+
+  /* FD_BIT_OR
+   *
+   * dest |= src at current bit index
+   * update MAX and NFD of dest fd set
+   *
+   *
+   * FS source fd set
+   * FD dest fd set
+   * BI bit index
+   * MAX current max_fd of dest fd sets
+   * NFD current nfd of dest fd sets
+   * N  nfds of source fd set
+   */
+#define FD_BIT_OR(FD,FS,BI,          \
+                  MAX,NFD)           \
+  if ((FS) && (FD) && FD_ISSET ((BI), (FS)))    \
+    {                                           \
+      FD_SET ((BI), (FD));                      \
+      if ((BI) > (MAX))                         \
+        {                                       \
+          (MAX) = (BI);                         \
+        }                                       \
+      ++(NFD);                                  \
+    }
+
+
+  /* FD_RWE_SET_OR */
+  /*
+   * SR,SW,SE source RWE fd sets
+   * DR,DW,DE dest RWE fd sets
+   * BI bit index
+   * NFDS  nfds of source fd sets
+   * MAX current max_fd of dest fd sets
+   * NFD current nfd of dest fd sets
+   */
+#define FD_RWE_SETS_OR(DR,DW,DE,      \
+                      SR,SW,SE,       \
+                      BI,NFDS,        \
+                      MAX,NFD)        \
+  do                                                      \
+    {                                                     \
+      for ((BI) = 0; (BI) < (NFDS); (BI)++)               \
+        {                                                 \
+          FD_BIT_OR((DR), (SR), (BI), (MAX), (NFD));      \
+          FD_BIT_OR((DW), (SW), (BI), (MAX), (NFD));      \
+          FD_BIT_OR((DE), (SE), (BI), (MAX), (NFD));      \
+        }                                                 \
+      }                                                   \
+    while (0);
+
+
+  /* source(vcom) to dest(select) rwe fd sets */
+  FD_RWE_SETS_OR (readfds, writefds, exceptfds,
+		  vcom_readfds, vcom_writefds, vcom_exceptfds,
+		  fd, vcom_nfds, max_fd, nfd2);
+
+  /* source(libc) to dest(select) rwe fd sets */
+  FD_RWE_SETS_OR (readfds, writefds, exceptfds,
+		  libc_readfds, libc_writefds, libc_exceptfds,
+		  fd, libc_nfds, max_fd, nfd2);
+
+#undef FD_RWE_SETS_OR
+#undef FD_BIT_OR
+
+  if (nfds)
+    *nfds = max_fd != -1 ? max_fd + 1 : 0;
+  if (nfd)
+    *nfd = nfd2;
+}
+
+/*
+ * RETURN 1 if fds is NULL or empty. 0 otherwise
+ */
+static inline int
+fd_set_iszero (fd_set * __restrict fds)
+{
+  int fd;
+
+  /* NULL fds */
+  if (!fds)
+    return 1;
+
+  for (fd = 0; fd < FD_SETSIZE; fd++)
+    {
+      if (FD_ISSET (fd, fds))
+	{
+	  /* non-empty fds */
+	  return 0;
+	}
+    }
+  /* empty fds */
+  return 1;
+}
+
+
+/*
+ * ################
+ * kernel time64.h
+ * ################
+ * */
+typedef long int s64;
+typedef unsigned long int u64;
+
+typedef long long int __s64;
+typedef unsigned long long int __u64;
+
+typedef __s64 time64_t;
+typedef __u64 timeu64_t;
+
+/* Parameters used to convert the timespec values: */
+#define MSEC_PER_SEC    1000L
+#define USEC_PER_MSEC   1000L
+#define NSEC_PER_USEC   1000L
+#define NSEC_PER_MSEC   1000000L
+#define USEC_PER_SEC    1000000L
+#define NSEC_PER_SEC    1000000000L
+#define FSEC_PER_SEC    1000000000000000LL
+
+
+/*
+ * ################
+ * kernel time.h
+ * ################
+ * */
+
+
+#define TIME_T_MAX      (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1)
+
+static inline int
+timespec_equal (const struct timespec *a, const struct timespec *b)
+{
+  return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);
+}
+
+/*
+ * lhs < rhs:  return <0
+ * lhs == rhs: return 0
+ * lhs > rhs:  return >0
+ */
+static inline int
+timespec_compare (const struct timespec *lhs, const struct timespec *rhs)
+{
+  if (lhs->tv_sec < rhs->tv_sec)
+    return -1;
+  if (lhs->tv_sec > rhs->tv_sec)
+    return 1;
+  return lhs->tv_nsec - rhs->tv_nsec;
+}
+
+static inline int
+timeval_compare (const struct timeval *lhs, const struct timeval *rhs)
+{
+  if (lhs->tv_sec < rhs->tv_sec)
+    return -1;
+  if (lhs->tv_sec > rhs->tv_sec)
+    return 1;
+  return lhs->tv_usec - rhs->tv_usec;
+}
+
+extern void set_normalized_timespec (struct timespec *ts, time_t sec,
+				     s64 nsec);
+
+
+static inline struct timespec
+timespec_add (struct timespec lhs, struct timespec rhs)
+{
+  struct timespec ts_delta;
+  set_normalized_timespec (&ts_delta, lhs.tv_sec + rhs.tv_sec,
+			   lhs.tv_nsec + rhs.tv_nsec);
+  return ts_delta;
+}
+
+/*
+ * sub = lhs - rhs, in normalized form
+ */
+static inline struct timespec
+timespec_sub (struct timespec lhs, struct timespec rhs)
+{
+  struct timespec ts_delta;
+  set_normalized_timespec (&ts_delta, lhs.tv_sec - rhs.tv_sec,
+			   lhs.tv_nsec - rhs.tv_nsec);
+  return ts_delta;
+}
+
+/*
+ * ################
+ * kernel time.c
+ * ################
+ * */
+
+
+/**
+ * set_normalized_timespec - set timespec sec and nsec parts and normalize
+ *
+ * @ts:         pointer to timespec variable to be set
+ * @sec:        seconds to set
+ * @nsec:       nanoseconds to set
+ *
+ * Set seconds and nanoseconds field of a timespec variable and
+ * normalize to the timespec storage format
+ *
+ * Note: The tv_nsec part is always in the range of
+ *      0 <= tv_nsec < NSEC_PER_SEC
+ * For negative values only the tv_sec field is negative !
+ */
+void
+set_normalized_timespec (struct timespec *ts, time_t sec, s64 nsec)
+{
+  while (nsec >= NSEC_PER_SEC)
+    {
+      /*
+       * The following asm() prevents the compiler from
+       * optimising this loop into a modulo operation. See
+       * also __iter_div_u64_rem() in include/linux/time.h
+       */
+    asm ("":"+rm" (nsec));
+      nsec -= NSEC_PER_SEC;
+      ++sec;
+    }
+  while (nsec < 0)
+    {
+    asm ("":"+rm" (nsec));
+      nsec += NSEC_PER_SEC;
+      --sec;
+    }
+  ts->tv_sec = sec;
+  ts->tv_nsec = nsec;
+}
+
+#define vcom_timerisvalid(tvp)        (!((tvp)->tv_sec < 0 || (tvp)->tv_usec < 0))
+
+/* Macros for converting between `struct timeval' and `struct timespec'.  */
+#define VCOM_TIMEVAL_TO_TIMESPEC(tv, ts) {                             \
+        (ts)->tv_sec = (tv)->tv_sec;                                    \
+        (ts)->tv_nsec = (tv)->tv_usec * 1000;                           \
+}
+#define VCOM_TIMESPEC_TO_TIMEVAL(tv, ts) {                             \
+        (tv)->tv_sec = (ts)->tv_sec;                                    \
+        (tv)->tv_usec = (ts)->tv_nsec / 1000;                           \
+}
+
+static inline int
+vcom_select_impl (int vcom_nfds, fd_set * __restrict vcom_readfds,
+		  fd_set * __restrict vcom_writefds,
+		  fd_set * __restrict vcom_exceptfds,
+		  struct timeval *__restrict timeout)
+{
+  return vcom_socket_select (vcom_nfds, vcom_readfds,
+			     vcom_writefds, vcom_exceptfds, timeout);
+}
+
+int
+vcom_select (int __nfds, fd_set * __restrict __readfds,
+	     fd_set * __restrict __writefds,
+	     fd_set * __restrict __exceptfds,
+	     struct timeval *__restrict __timeout)
+{
+  int rv;
+  int rv2 = 0;
+  pid_t pid = getpid ();
+
+  int timedout = 0;
+  /* block indefinitely */
+  int no_timeout = 0;
+  int first_clock_gettime_failed = 0;
+  /* timeout value in units of timespec */
+  struct timespec timeout_ts;
+  struct timespec start_time, now, end_time;
+
+  /* select sets attributes - after merge */
+  int new_nfds = 0;
+  int new_nfd = -1;
+
+  /* vcom */
+  int vcom_nfds = 0;
+  fd_set vcom_readfds;
+  fd_set vcom_writefds;
+  fd_set vcom_exceptfds;
+  int vcom_nfd = -1;
+
+  /* libc */
+  int libc_nfds = 0;
+  fd_set libc_readfds;
+  fd_set libc_writefds;
+  fd_set libc_exceptfds;
+  int libc_nfd = -1;
+
+  /* for polling */
+  struct timeval tv = {.tv_sec = 0,.tv_usec = 0 };
+
+  /* validate __timeout */
+  if (__timeout)
+    {
+      /* validate tv_sec */
+      /* bogus */
+      if (!vcom_timerisvalid (__timeout))
+	{
+	  rv = -EINVAL;
+	  goto select_done;
+	}
+
+      /* validate tv_usec */
+      /* TBD: */
+      /* init timeout_ts */
+      VCOM_TIMEVAL_TO_TIMESPEC (__timeout, &timeout_ts);
+      set_normalized_timespec (&timeout_ts,
+			       timeout_ts.tv_sec, timeout_ts.tv_nsec);
+    }
+
+  rv = clock_gettime (CLOCK_MONOTONIC, &start_time);
+  if (rv == -1)
+    {
+      rv = -errno;
+      first_clock_gettime_failed = 1;
+      goto select_done;
+    }
+
+  /* init end_time */
+  if (__timeout)
+    {
+      if (timerisset (__timeout))
+	{
+	  end_time = timespec_add (start_time, timeout_ts);
+	}
+      else
+	{
+	  /*
+	   * if both fields of the timeout structure are zero,
+	   * then select returns immediately
+	   * */
+	  end_time = start_time;
+	}
+    }
+  else
+    {
+      /* block indefinitely */
+      no_timeout = 1;
+    }
+
+
+
+  if (vcom_init () != 0)
+    {
+      rv = -1;
+      goto select_done;
+    }
+
+  /* validate __nfds */
+  if (__nfds < 0 || __nfds > FD_SETSIZE)
+    {
+      rv = -EINVAL;
+      goto select_done;
+    }
+
+
+  /*
+   * usleep(3) emulation
+   * */
+
+  /* call libc_select() with a finite timeout and
+   * no file descriptors or empty fd sets and
+   * zero nfds */
+  if (__nfds == 0 &&
+      (!__readfds || fd_set_iszero (__readfds)) &&
+      (!__writefds || fd_set_iszero (__writefds)) &&
+      (!__exceptfds || fd_set_iszero (__exceptfds)))
+    {
+      if (__timeout)
+	{
+	  rv = libc_select (__nfds,
+			    __readfds, __writefds, __exceptfds, __timeout);
+	  if (rv == -1)
+	    rv = -errno;
+	}
+      else
+	{
+	  /* TBD: block indefinitely or return -EINVAL */
+	  rv = -EINVAL;
+	}
+      goto select_done;
+    }
+
+  /* init once before the polling loop */
+
+  /* zero vcom and libc fd sets */
+  /*
+   * S select fd set
+   * V vcom fd set
+   * L libc fd set
+   */
+#define _(S,V,L)      \
+  if ((S))            \
+    {                 \
+      FD_ZERO ((V));  \
+      FD_ZERO ((L));  \
+    }
+
+
+  _(__readfds, &vcom_readfds, &libc_readfds);
+  _(__writefds, &vcom_writefds, &libc_writefds);
+  _(__exceptfds, &vcom_exceptfds, &libc_exceptfds);
+#undef _
+  new_nfds = 0;
+  new_nfd = -1;
+
+  vcom_nfds = 0;
+  vcom_nfd = -1;
+  libc_nfds = 0;
+  libc_nfd = -1;
+
+  vcom_fd_set_split (
+		      /* src, select sets */
+		      __nfds, __readfds, __writefds, __exceptfds,
+		      /* dest1, vcom sets */
+		      __readfds || __writefds || __exceptfds ?
+		      &vcom_nfds : NULL,
+		      __readfds ? &vcom_readfds : NULL,
+		      __writefds ? &vcom_writefds : NULL,
+		      __exceptfds ? &vcom_exceptfds : NULL,
+		      __readfds || __writefds || __exceptfds ?
+		      &vcom_nfd : NULL,
+		      /* dest2, libc sets */
+		      __readfds || __writefds || __exceptfds ?
+		      &libc_nfds : NULL,
+		      __readfds ? &libc_readfds : NULL,
+		      __writefds ? &libc_writefds : NULL,
+		      __exceptfds ? &libc_exceptfds : NULL,
+		      __readfds || __writefds || __exceptfds ?
+		      &libc_nfd : NULL);
+
+  /*
+   * polling loop
+   * */
+  do
+    {
+      new_nfd = -1;
+      vcom_nfd = -1;
+      libc_nfd = -1;
+
+      /*
+       * if both fields of timeval structure are zero,
+       * vcom_select_impl and libc_select returns immediately.
+       * useful for polling and ensure fairness among
+       * file descriptors watched.
+       */
+
+      /* for polling */
+      tv.tv_sec = 0;
+      tv.tv_usec = 0;
+
+      /* select on vcom fds */
+      if (vcom_nfds)
+	{
+	  vcom_nfd = vcom_select_impl (vcom_nfds,
+				       __readfds ? &vcom_readfds : NULL,
+				       __writefds ? &vcom_writefds : NULL,
+				       __exceptfds ? &vcom_exceptfds : NULL,
+				       &tv);
+	  if (VCOM_DEBUG > 0)
+	    fprintf (stderr,
+		     "[%d] select vcom: "
+		     "'%04d'='%04d'\n", pid, vcom_nfd, vcom_nfds);
+
+	  if (vcom_nfd < 0)
+	    {
+	      rv = vcom_nfd;
+	      goto select_done;
+	    }
+	}
+      /* select on libc fds */
+      if (libc_nfds)
+	{
+	  libc_nfd = libc_select (libc_nfds,
+				  __readfds ? &libc_readfds : NULL,
+				  __writefds ? &libc_writefds : NULL,
+				  __exceptfds ? &libc_exceptfds : NULL, &tv);
+	  if (VCOM_DEBUG > 0)
+	    fprintf (stderr,
+		     "[%d] select libc: "
+		     "'%04d'='%04d'\n", pid, libc_nfd, libc_nfds);
+
+	  if (libc_nfd < 0)
+	    {
+	      /* tv becomes undefined */
+	      libc_nfd = errno;
+	      rv = libc_nfd;
+	      goto select_done;
+	    }
+	}
+
+      /* check if any file descriptors changed status */
+      if ((vcom_nfds && vcom_nfd > 0) || (libc_nfds && libc_nfd > 0))
+	{
+	  /* zero the sets before merge and exit */
+
+	  /*
+	   * F fd set
+	   */
+#define _(F)                  \
+          if ((F))            \
+            {                 \
+              FD_ZERO ((F));  \
+            }
+
+
+	  _(__readfds);
+	  _(__writefds);
+	  _(__exceptfds);
+#undef _
+	  new_nfds = 0;
+	  new_nfd = -1;
+
+	  /*
+	   * on exit, sets are modified in place to indicate which
+	   * file descriptors actually changed status
+	   * */
+	  vcom_fd_set_merge (
+			      /* dest, select sets */
+			      __readfds || __writefds || __exceptfds ?
+			      &new_nfds : NULL,
+			      __readfds,
+			      __writefds,
+			      __exceptfds,
+			      __readfds || __writefds || __exceptfds ?
+			      &new_nfd : NULL,
+			      /* src1, vcom sets */
+			      vcom_nfds,
+			      __readfds ? &vcom_readfds : NULL,
+			      __writefds ? &vcom_writefds : NULL,
+			      __exceptfds ? &vcom_exceptfds : NULL, vcom_nfd,
+			      /* src2, libc sets */
+			      libc_nfds,
+			      __readfds ? &libc_readfds : NULL,
+			      __writefds ? &libc_writefds : NULL,
+			      __exceptfds ? &libc_exceptfds : NULL, libc_nfd);
+	  /*
+	   * return the number of file descriptors contained in the
+	   * three returned sets
+	   * */
+	  rv = 0;
+	  /*
+	   * for documentation
+	   *
+	   * if(vcom_nfd > 0)
+	   *   rv += vcom_nfd;
+	   * if(libc_nfd > 0)
+	   *   rv += libc_nfd;
+	   */
+
+	  rv = new_nfd == -1 ? 0 : new_nfd;
+	  goto select_done;
+	}
+
+      rv = clock_gettime (CLOCK_MONOTONIC, &now);
+      if (rv == -1)
+	{
+	  rv = -errno;
+	  goto select_done;
+	}
+    }
+  while (no_timeout || timespec_compare (&now, &end_time) < 0);
+
+  /* timeout expired before anything interesting happened */
+  timedout = 1;
+  rv = 0;
+
+select_done:
+  if (VCOM_DEBUG > 0)
+    fprintf (stderr, "[%d] vselect1: " "'%04d'='%04d'\n", pid, rv, __nfds);
+  /*
+   * modify timeout parameter to reflect the amount of time not slept
+   * */
+  if (__timeout)
+    {
+      if (vcom_timerisvalid (__timeout))
+	{
+	  /* timeout expired */
+	  if (timedout)
+	    {
+	      timerclear (__timeout);
+	    }
+	  else if (!first_clock_gettime_failed)
+	    {
+	      rv2 = clock_gettime (CLOCK_MONOTONIC, &now);
+	      if (rv2 == -1)
+		{
+		  rv = -errno;
+		}
+	      else
+		{
+		  struct timespec ts_delta;
+		  ts_delta = timespec_sub (end_time, now);
+		  VCOM_TIMESPEC_TO_TIMEVAL (__timeout, &ts_delta);
+		}
+	    }
+	}
+    }
+  if (VCOM_DEBUG > 0)
+    fprintf (stderr, "[%d] vselect2: " "'%04d',='%04d'\n", pid, rv, __nfds);
+
+  return rv;
+}
+
+int
+vcom_select_internal (int __nfds, fd_set * __restrict __readfds,
+		      fd_set * __restrict __writefds,
+		      fd_set * __restrict __exceptfds,
+		      struct timeval *__restrict __timeout)
+{
+  int rv;
+  int new_nfds = 0;
+  int nfd = 0;
+  pid_t pid = getpid ();
+
+  fd_set saved_readfds;
+  fd_set saved_writefds;
+  fd_set saved_exceptfds;
+
+  /* validate __nfds */
+  if (__nfds < 0)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
+  /* validate __timeout */
+  if (__timeout)
+    {
+      /* validate tv_sec */
+      /* bogus */
+      if (__timeout->tv_sec < 0 || __timeout->tv_usec < 0)
+	{
+	  errno = EINVAL;
+	  return -1;
+	}
+
+      /* validate tv_usec */
+      /* TBD: */
+    }
+
+  /* init saved_x fds */
+  if (__readfds)
+    {
+      saved_readfds = *__readfds;
+      /*
+         memcpy (&saved_readfds, __readfds, sizeof (*__readfds));
+       */
+    }
+  else
+    {
+      FD_ZERO (&saved_readfds);
+    }
+
+  if (__writefds)
+    {
+      saved_writefds = *__writefds;
+      /*
+         memcpy (&saved_writefds, __writefds, sizeof (*__writefds));
+       */
+
+    }
+  else
+    {
+      FD_ZERO (&saved_writefds);
+    }
+
+  if (__exceptfds)
+    {
+      saved_exceptfds = *__exceptfds;
+      /*
+         memcpy (&saved_exceptfds, __exceptfds, sizeof (*__exceptfds));
+       */
+
+    }
+  else
+    {
+      FD_ZERO (&saved_exceptfds);
+    }
+
+  /* clear vcom fds */
+  nfd = vcom_fd_clear (__nfds, &new_nfds, __readfds, __writefds, __exceptfds);
+
+  /* set to an invalid value */
+  rv = -2;
+  /* have kernel fds */
+  if (new_nfds)
+    rv = libc_select (new_nfds, __readfds,
+		      __writefds, __exceptfds, __timeout);
+
+  if (new_nfds && rv == -1)
+    {
+      /* on error, the file descriptor sets are unmodified */
+      if (__readfds)
+	*__readfds = saved_readfds;
+      if (__writefds)
+	*__writefds = saved_writefds;
+      if (__exceptfds)
+	*__exceptfds = saved_exceptfds;
+      return rv;
+    }
+  else if ((new_nfds && rv != -1) || (rv == -2))
+    {
+      /* restore vcom fds */
+      nfd = vcom_fd_set (__nfds,
+			 &new_nfds,
+			 __readfds,
+			 __writefds,
+			 __exceptfds,
+			 &saved_readfds, &saved_writefds, &saved_exceptfds);
+      rv = nfd;
+    }
+
+  if (VCOM_DEBUG > 0)
+    fprintf (stderr, "[%d] select: " "'%04d'='%04d'\n", pid, rv, __nfds);
+  return rv;
+}
+
+int
+select (int __nfds, fd_set * __restrict __readfds,
+	fd_set * __restrict __writefds,
+	fd_set * __restrict __exceptfds, struct timeval *__restrict __timeout)
+{
+  int rv = 0;
+  pid_t pid = getpid ();
+
+  if (VCOM_DEBUG > 0)
+    fprintf (stderr, "[%d] select1: " "'%04d'='%04d'\n", pid, rv, __nfds);
+  rv = vcom_select (__nfds, __readfds, __writefds, __exceptfds, __timeout);
+  if (VCOM_DEBUG > 0)
+    fprintf (stderr, "[%d] select2: " "'%04d'='%04d'\n", pid, rv, __nfds);
+  if (rv < 0)
+    {
+      errno = -rv;
+      return -1;
+    }
+  return rv;
+}
+
+#ifdef __USE_XOPEN2K
+/*
+ * Same as above only that the TIMEOUT value is given with higher
+ * resolution and a sigmask which is been set temporarily.  This
+ * version should be used.
+ *
+ * This function is a cancellation point and therefore not marked
+ * with __THROW.
+ * */
+int
+vcom_pselect (int __nfds, fd_set * __restrict __readfds,
+	      fd_set * __restrict __writefds,
+	      fd_set * __restrict __exceptfds,
+	      const struct timespec *__restrict __timeout,
+	      const __sigset_t * __restrict __sigmask)
+{
+  int fd;
+  int vcom_nfds = 0;
+
+  for (fd = 0; fd < __nfds; fd++)
+    {
+      if (__readfds && FD_ISSET (fd, __readfds))
+	{
+	  if (is_vcom_socket_fd (fd))
+	    {
+	      vcom_nfds++;
+	    }
+	}
+
+      if (__writefds && FD_ISSET (fd, __writefds))
+	{
+	  if (is_vcom_socket_fd (fd))
+	    {
+	      vcom_nfds++;
+	    }
+	}
+      if (__exceptfds && FD_ISSET (fd, __exceptfds))
+	{
+	  if (is_vcom_socket_fd (fd))
+	    {
+	      FD_CLR (fd, __exceptfds);
+	    }
+	}
+    }
+  return vcom_nfds;
+}
+
+int
+pselect (int __nfds, fd_set * __restrict __readfds,
+	 fd_set * __restrict __writefds,
+	 fd_set * __restrict __exceptfds,
+	 const struct timespec *__restrict __timeout,
+	 const __sigset_t * __restrict __sigmask)
+{
+  int rv;
+  int new_nfds = 0;
+  int nfd = 0;
+  pid_t pid = getpid ();
+
+  fd_set saved_readfds;
+  fd_set saved_writefds;
+  fd_set saved_exceptfds;
+
+  /* validate __nfds */
+  if (__nfds < 0)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
+  /* validate __timeout */
+  if (__timeout)
+    {
+      /* validate tv_sec */
+      /* bogus */
+      if (__timeout->tv_sec < 0 || __timeout->tv_nsec < 0)
+	{
+	  errno = EINVAL;
+	  return -1;
+	}
+
+      /* validate tv_usec */
+      /* TBD: */
+    }
+
+  /* init saved fds */
+  if (__readfds)
+    {
+      saved_readfds = *__readfds;
+      /*
+         memcpy (&saved_readfds, __readfds, sizeof (*__readfds));
+       */
+    }
+  else
+    {
+      FD_ZERO (&saved_readfds);
+    }
+
+  if (__writefds)
+    {
+      saved_writefds = *__writefds;
+      /*
+         memcpy (&saved_writefds, __writefds, sizeof (*__writefds));
+       */
+
+    }
+  else
+    {
+      FD_ZERO (&saved_writefds);
+    }
+
+  if (__exceptfds)
+    {
+      saved_exceptfds = *__exceptfds;
+      /*
+         memcpy (&saved_exceptfds, __exceptfds, sizeof (*__exceptfds));
+       */
+
+    }
+  else
+    {
+      FD_ZERO (&saved_exceptfds);
+    }
+
+  /* clear vcom fds */
+  nfd = vcom_fd_clear (__nfds, &new_nfds, __readfds, __writefds, __exceptfds);
+
+  /* set to an invalid value */
+  rv = -2;
+  if (new_nfds)
+    rv = libc_pselect (new_nfds,
+		       __readfds,
+		       __writefds, __exceptfds, __timeout, __sigmask);
+
+  if (new_nfds && rv == -1)
+    {
+      /* on error, the file descriptor sets are unmodified */
+      if (__readfds)
+	*__readfds = saved_readfds;
+      if (__writefds)
+	*__writefds = saved_writefds;
+      if (__exceptfds)
+	*__exceptfds = saved_exceptfds;
+      return rv;
+    }
+  else if ((new_nfds && rv != -1) || (rv == -2))
+    {
+      /* restore vcom fds */
+      nfd = vcom_fd_set (__nfds,
+			 &new_nfds,
+			 __readfds,
+			 __writefds,
+			 __exceptfds,
+			 &saved_readfds, &saved_writefds, &saved_exceptfds);
+      rv = nfd;
+    }
+
+  if (VCOM_DEBUG > 0)
+    fprintf (stderr, "[%d] pselect: " "'%04d'='%04d'\n", pid, rv, __nfds);
+  return rv;
+}
+#endif
+
+/*
+ *
+ * Socket specific glibc api
+ *
+ */
+
+/* Create a new socket of type TYPE in domain DOMAIN, using
+ * protocol PROTOCOL.  If PROTOCOL is zero, one is chosen
+ * automatically. Returns a file descriptor for the new socket,
+ * or -1 for errors.
+ * RETURN:  a valid file descriptor for the new socket,
+ * or -1 for errors.
+ * */
+
+int
+vcom_socket (int __domain, int __type, int __protocol)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_socket (__domain, __type, __protocol);
+}
+
+int
+socket (int __domain, int __type, int __protocol)
+{
+  int rv;
+  pid_t pid = getpid ();
+  pthread_t tid = pthread_self ();
+
+  /* handle domains implemented by vpp */
+  switch (__domain)
+    {
+    case AF_INET:
+    case AF_INET6:
+      /* handle types implemented by vpp */
+      switch (__type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK))
+	{
+	case SOCK_STREAM:
+	case SOCK_DGRAM:
+	  if (VCOM_DEBUG > 0)
+	    vcom_socket_main_show ();
+	  rv = vcom_socket (__domain, __type, __protocol);
+	  if (VCOM_DEBUG > 0)
+	    fprintf (stderr,
+		     "[%d][%lu (0x%lx)] socket: "
+		     "'%04d'= D='%04d', T='%04d', P='%04d'\n",
+		     pid, (unsigned long) tid, (unsigned long) tid,
+		     rv, __domain, __type, __protocol);
+	  if (VCOM_DEBUG > 0)
+	    vcom_socket_main_show ();
+	  if (rv < 0)
+	    {
+	      errno = -rv;
+	      return -1;
+	    }
+	  return rv;
+	  break;
+
+	default:
+	  goto CALL_GLIBC_SOCKET_API;
+	  break;
+	}
+
+      break;
+
+    default:
+      goto CALL_GLIBC_SOCKET_API;
+      break;
+    }
+
+CALL_GLIBC_SOCKET_API:
+  return libc_socket (__domain, __type, __protocol);
+}
+
+/*
+ * Create two new sockets, of type TYPE in domain DOMAIN and using
+ * protocol PROTOCOL, which are connected to each other, and put file
+ * descriptors for them in FDS[0] and FDS[1].  If PROTOCOL is zero,
+ * one will be chosen automatically.
+ * Returns 0 on success, -1 for errors.
+ * */
+int
+vcom_socketpair (int __domain, int __type, int __protocol, int __fds[2])
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_socketpair (__domain, __type, __protocol, __fds);
+}
+
+int
+socketpair (int __domain, int __type, int __protocol, int __fds[2])
+{
+  int rv;
+  pid_t pid = getpid ();
+
+  /* handle domains implemented by vpp */
+  switch (__domain)
+    {
+    case AF_INET:
+    case AF_INET6:
+      /* handle types implemented by vpp */
+      switch (__type)
+	{
+	case SOCK_STREAM:
+	case SOCK_DGRAM:
+	  rv = vcom_socketpair (__domain, __type, __protocol, __fds);
+	  if (VCOM_DEBUG > 0)
+	    fprintf (stderr,
+		     "[%d] socketpair: "
+		     "'%04d'= D='%04d', T='%04d', P='%04d'\n",
+		     pid, rv, __domain, __type, __protocol);
+	  if (rv < 0)
+	    {
+	      errno = -rv;
+	      return -1;
+	    }
+	  return 0;
+	  break;
+
+	default:
+	  goto CALL_GLIBC_SOCKET_API;
+	  break;
+	}
+
+      break;
+
+    default:
+      goto CALL_GLIBC_SOCKET_API;
+      break;
+    }
+
+CALL_GLIBC_SOCKET_API:
+  return libc_socketpair (__domain, __type, __protocol, __fds);
+}
+
+/*
+ * Give the socket FD the local address ADDR
+ * (which is LEN bytes long).
+ * */
+int
+vcom_bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
+{
+  int rv;
+
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  /* validate __len */
+  switch (__addr->sa_family)
+    {
+    case AF_INET:
+      if (__len != sizeof (struct sockaddr_in))
+	return -EINVAL;
+      break;
+    case AF_INET6:
+      if (__len != sizeof (struct sockaddr_in6))
+	return -EINVAL;
+      break;
+
+    default:
+      return -1;
+      break;
+    }
+
+  /* handle domains implemented by vpp */
+  switch (__addr->sa_family)
+    {
+    case AF_INET:
+    case AF_INET6:
+      rv = vcom_socket_bind (__fd, __addr, __len);
+      return rv;
+      break;
+
+    default:
+      return -1;
+      break;
+    }
+
+  return -1;
+}
+
+int
+bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
+{
+  int rv;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+
+      rv = vcom_bind (__fd, __addr, __len);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] bind: "
+		 "'%04d'='%04d', '%p', '%04d'\n",
+		 pid, rv, __fd, __addr, __len);
+      if (rv != 0)
+	{
+	  errno = -rv;
+	  return -1;
+	}
+      return 0;
+    }
+  return libc_bind (__fd, __addr, __len);
+}
+
+/*
+ * Put the local address of FD into *ADDR and its length in *LEN.
+ * */
+int
+vcom_getsockname (int __fd, __SOCKADDR_ARG __addr,
+		  socklen_t * __restrict __len)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_getsockname (__fd, __addr, __len);
+}
+
+int
+getsockname (int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __len)
+{
+  int rv;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      rv = vcom_getsockname (__fd, __addr, __len);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] getsockname: "
+		 "'%04d'='%04d', '%p', '%p'\n", pid, rv, __fd, __addr, __len);
+      if (rv != 0)
+	{
+	  errno = -rv;
+	  return -1;
+	}
+      return 0;
+    }
+  return libc_getsockname (__fd, __addr, __len);
+}
+
+/*
+ * Open a connection on socket FD to peer at ADDR
+ * (which LEN bytes long). For connectionless socket types, just set
+ * the default address to send to and the only address from which to
+ * accept transmissions. Return 0 on success, -1 for errors.
+ * This function is a cancellation point and therefore not marked
+ * with __THROW.
+ * */
+int
+vcom_connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
+{
+  int rv = -1;
+
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  /* validate __len */
+  switch (__addr->sa_family)
+    {
+    case AF_INET:
+      if (__len != INET_ADDRSTRLEN)
+	return -1;
+      break;
+    case AF_INET6:
+      if (__len != INET6_ADDRSTRLEN)
+	return -1;
+      break;
+
+    default:
+      return -1;
+      break;
+    }
+
+  /* handle domains implemented by vpp */
+  switch (__addr->sa_family)
+    {
+    case AF_INET:
+    case AF_INET6:
+      rv = vcom_socket_connect (__fd, __addr, __len);
+      break;
+
+    default:
+      return -1;
+      break;
+    }
+
+  return rv;
+}
+
+int
+connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
+{
+  int rv;
+  pid_t pid = getpid ();
+  pthread_t tid = pthread_self ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      rv = vcom_connect (__fd, __addr, __len);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d][%lu (0x%lx)] connect: "
+		 "'%04d'='%04d', '%p', '%04d'\n",
+		 pid, (unsigned long) tid, (unsigned long) tid,
+		 rv, __fd, __addr, __len);
+      if (rv != 0)
+	{
+	  errno = -rv;
+	  return -1;
+	}
+      return 0;
+    }
+
+  return libc_connect (__fd, __addr, __len);
+}
+
+/*
+ * Put the address of the peer connected to socket FD into *ADDR
+ * (which is *LEN bytes long), and its actual length into *LEN.
+ * */
+int
+vcom_getpeername (int __fd, __SOCKADDR_ARG __addr,
+		  socklen_t * __restrict __len)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_getpeername (__fd, __addr, __len);
+}
+
+int
+getpeername (int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __len)
+{
+  int rv;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      rv = vcom_getpeername (__fd, __addr, __len);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] getpeername: "
+		 "'%04d'='%04d', '%p', '%p'\n", pid, rv, __fd, __addr, __len);
+      if (rv != 0)
+	{
+	  errno = -rv;
+	  return -1;
+	}
+      return 0;
+    }
+  return libc_getpeername (__fd, __addr, __len);
+}
+
+/*
+ * Send N bytes of BUF to socket FD.  Returns the number sent or -1.
+ * This function is a cancellation point and therefore not marked
+ * with __THROW.
+ * */
+ssize_t
+vcom_send (int __fd, const void *__buf, size_t __n, int __flags)
+{
+
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_send (__fd, (void *) __buf, (int) __n, __flags);
+}
+
+ssize_t
+send (int __fd, const void *__buf, size_t __n, int __flags)
+{
+  ssize_t size;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      size = vcom_send (__fd, __buf, __n, __flags);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] send: "
+		 "'%04d'='%04d', '%p', '%04d', '%04x'\n",
+		 pid, (int) size, __fd, __buf, (int) __n, __flags);
+      if (size < 0)
+	{
+	  errno = -size;
+	  return -1;
+	}
+      return size;
+    }
+  return libc_send (__fd, __buf, __n, __flags);
+}
+
+/*
+ * Read N bytes into BUF from socket FD.
+ * Returns the number read or -1 for errors.
+ * This function is a cancellation point and therefore not marked
+ *  with __THROW.
+ *  */
+ssize_t
+vcom_recv (int __fd, void *__buf, size_t __n, int __flags)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_recv (__fd, __buf, __n, __flags);
+}
+
+ssize_t
+recv (int __fd, void *__buf, size_t __n, int __flags)
+{
+  ssize_t size;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      size = vcom_recv (__fd, __buf, __n, __flags);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] recv: "
+		 "'%04d'='%04d', '%p', '%04d', '%04x'\n",
+		 pid, (int) size, __fd, __buf, (int) __n, __flags);
+      if (size < 0)
+	{
+	  errno = -size;
+	  return -1;
+	}
+      return size;
+    }
+  return libc_recv (__fd, __buf, __n, __flags);
+}
+
+/*
+ * Send N bytes of BUF on socket FD to peer at address ADDR (which is
+ * ADDR_LEN bytes long).  Returns the number sent, or -1 for errors.
+ * This function is a cancellation point and therefore not marked
+ * with __THROW.
+ * */
+ssize_t
+vcom_sendto (int __fd, const void *__buf, size_t __n, int __flags,
+	     __CONST_SOCKADDR_ARG __addr, socklen_t __addr_len)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_sendto (__fd, __buf, __n, __flags, __addr, __addr_len);
+}
+
+ssize_t
+sendto (int __fd, const void *__buf, size_t __n, int __flags,
+	__CONST_SOCKADDR_ARG __addr, socklen_t __addr_len)
+{
+  ssize_t size;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      size = vcom_sendto (__fd, __buf, __n, __flags, __addr, __addr_len);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] sendto: "
+		 "'%04d'='%04d', '%p', '%04d', '%04x', "
+		 "'%p', '%04d'\n",
+		 pid, (int) size, __fd, __buf, (int) __n, __flags,
+		 __addr, __addr_len);
+      if (size < 0)
+	{
+	  errno = -size;
+	  return -1;
+	}
+      return size;
+    }
+  return libc_sendto (__fd, __buf, __n, __flags, __addr, __addr_len);
+}
+
+/*
+ * Read N bytes into BUF through socket FD.
+ * If ADDR is not NULL, fill in *ADDR_LEN bytes of it with the
+ * address of the sender, and store the actual size of the address
+ * in *ADDR_LEN.
+ * Returns the number of bytes read or -1 for errors.
+ * This function is a cancellation point and therefore not marked
+ * with __THROW.
+ * */
+ssize_t
+vcom_recvfrom (int __fd, void *__restrict __buf, size_t __n,
+	       int __flags,
+	       __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_recvfrom (__fd, __buf, __n, __flags, __addr, __addr_len);
+}
+
+ssize_t
+recvfrom (int __fd, void *__restrict __buf, size_t __n,
+	  int __flags,
+	  __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len)
+{
+  ssize_t size;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      size = vcom_recvfrom (__fd, __buf, __n, __flags, __addr, __addr_len);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] recvfrom: "
+		 "'%04d'='%04d', '%p', '%04d', '%04x', "
+		 "'%p', '%p'\n",
+		 pid, (int) size, __fd, __buf, (int) __n, __flags,
+		 __addr, __addr_len);
+      if (size < 0)
+	{
+	  errno = -size;
+	  return -1;
+	}
+      return size;
+    }
+  return libc_recvfrom (__fd, __buf, __n, __flags, __addr, __addr_len);
+}
+
+/*
+ * Send a message described MESSAGE on socket FD.
+ * Returns the number of bytes sent, or -1 for errors.
+ * This function is a cancellation point and therefore not marked
+ * with __THROW.
+ * */
+ssize_t
+vcom_sendmsg (int __fd, const struct msghdr * __message, int __flags)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_sendmsg (__fd, __message, __flags);
+}
+
+ssize_t
+sendmsg (int __fd, const struct msghdr * __message, int __flags)
+{
+  ssize_t size;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      size = vcom_sendmsg (__fd, __message, __flags);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] sendmsg: "
+		 "'%04d'='%04d', '%p', '%04x'\n",
+		 pid, (int) size, __fd, __message, __flags);
+      if (size < 0)
+	{
+	  errno = -size;
+	  return -1;
+	}
+      return size;
+    }
+  return libc_sendmsg (__fd, __message, __flags);
+}
+
+#ifdef __USE_GNU
+/*
+ * Send a VLEN messages as described by VMESSAGES to socket FD.
+ * Returns the number of datagrams successfully written
+ * or -1 for errors.
+ * This function is a cancellation point and therefore not marked
+ * with __THROW.
+ * */
+int
+vcom_sendmmsg (int __fd, struct mmsghdr *__vmessages,
+	       unsigned int __vlen, int __flags)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_sendmmsg (__fd, __message, __vlen, __flags);
+}
+
+int
+sendmmsg (int __fd, struct mmsghdr *__vmessages,
+	  unsigned int __vlen, int __flags)
+{
+  ssize_t size;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      size = vcom_sendmmsg (__fd, __message, __vlen, __flags);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] sendmmsg: "
+		 "'%04d'='%04d', '%p', '%04d', '%04x'\n",
+		 pid, (int) size, __fd, __vmessages, __vlen, __flags);
+      if (size < 0)
+	{
+	  errno = -size;
+	  return -1;
+	}
+      return size;
+    }
+  return libc_sendmmsg (__fd, __message, __vlen, __flags);
+}
+
+#endif
+
+/*
+ * Receive a message as described by MESSAGE from socket FD.
+ * Returns the number of bytes read or -1 for errors.
+ * This function is a cancellation point and therefore not marked
+ * with __THROW.
+ * */
+ssize_t
+vcom_recvmsg (int __fd, struct msghdr * __message, int __flags)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_recvmsg (__fd, __message, __flags);
+}
+
+ssize_t
+recvmsg (int __fd, struct msghdr * __message, int __flags)
+{
+  ssize_t size;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      size = vcom_recvmsg (__fd, __message, __flags);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] recvmsg: "
+		 "'%04d'='%04d', '%p', '%04x'\n",
+		 pid, (int) size, __fd, __message, __flags);
+      if (size < 0)
+	{
+	  errno = -size;
+	  return -1;
+	}
+      return size;
+    }
+  return libc_recvmsg (__fd, __message, __flags);
+}
+
+#ifdef __USE_GNU
+/*
+ * Receive up to VLEN messages as described by VMESSAGES from socket FD.
+ * Returns the number of messages received or -1 for errors.
+ * This function is a cancellation point and therefore not marked
+ * with __THROW.
+ * */
+int
+vcom_recvmmsg (int __fd, struct mmsghdr *__vmessages,
+	       unsigned int __vlen, int __flags, struct timespec *__tmo)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_recvmmsg (__fd, __message, __vlen, __flags, __tmo);
+}
+
+int
+recvmmsg (int __fd, struct mmsghdr *__vmessages,
+	  unsigned int __vlen, int __flags, struct timespec *__tmo)
+{
+  ssize_t size;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      size = vcom_recvmmsg (__fd, __message, __vlen, __flags, __tmo);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] recvmmsg: "
+		 "'%04d'='%04d', '%p', "
+		 "'%04d', '%04x', '%p'\n",
+		 pid, (int) size, __fd, __vmessages, __vlen, __flags, __tmo);
+      if (size < 0)
+	{
+	  errno = -size;
+	  return -1;
+	}
+      return size;
+    }
+  return libc_recvmmsg (__fd, __message, __vlen, __flags, __tmo);
+}
+
+#endif
+
+/*
+ * Put the current value for socket FD's option OPTNAME
+ * at protocol level LEVEL into OPTVAL (which is *OPTLEN bytes long),
+ * and set *OPTLEN to the value's actual length.
+ * Returns 0 on success, -1 for errors.
+ * */
+int
+vcom_getsockopt (int __fd, int __level, int __optname,
+		 void *__restrict __optval, socklen_t * __restrict __optlen)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_getsockopt (__fd, __level, __optname,
+				 __optval, __optlen);
+}
+
+int
+getsockopt (int __fd, int __level, int __optname,
+	    void *__restrict __optval, socklen_t * __restrict __optlen)
+{
+  int rv;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      rv = vcom_getsockopt (__fd, __level, __optname, __optval, __optlen);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] getsockopt: "
+		 "'%04d'='%04d', '%04d', '%04d', "
+		 "'%p', '%p'\n",
+		 pid, rv, __fd, __level, __optname, __optval, __optlen);
+      if (rv != 0)
+	{
+	  errno = -rv;
+	  return -1;
+	}
+      return 0;
+    }
+  return libc_getsockopt (__fd, __level, __optname, __optval, __optlen);
+}
+
+/*
+ * Set socket FD's option OPTNAME at protocol level LEVEL
+ * to *OPTVAL (which is OPTLEN bytes long).
+ * Returns 0 on success, -1 for errors.
+ * */
+int
+vcom_setsockopt (int __fd, int __level, int __optname,
+		 const void *__optval, socklen_t __optlen)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_setsockopt (__fd, __level, __optname,
+				 __optval, __optlen);
+}
+
+int
+setsockopt (int __fd, int __level, int __optname,
+	    const void *__optval, socklen_t __optlen)
+{
+  int rv;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      rv = vcom_setsockopt (__fd, __level, __optname, __optval, __optlen);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] setsockopt: "
+		 "'%04d'='%04d', '%04d', '%04d', "
+		 "'%p', '%04d'\n",
+		 pid, rv, __fd, __level, __optname, __optval, __optlen);
+      if (rv != 0)
+	{
+	  errno = -rv;
+	  return -1;
+	}
+      return 0;
+    }
+  return libc_setsockopt (__fd, __level, __optname, __optval, __optlen);
+}
+
+/*
+ * Prepare to accept connections on socket FD.
+ * N connection requests will be queued before further
+ * requests are refused.
+ * Returns 0 on success, -1 for errors.
+ * */
+int
+vcom_listen (int __fd, int __n)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_listen (__fd, __n);
+}
+
+int
+listen (int __fd, int __n)
+{
+  int rv;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      rv = vcom_listen (__fd, __n);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] listen: "
+		 "'%04d'='%04d', '%04d'\n", pid, rv, __fd, __n);
+      if (rv != 0)
+	{
+	  errno = -rv;
+	  return -1;
+	}
+      return 0;
+    }
+  return libc_listen (__fd, __n);
+}
+
+/*
+ * Await a connection on socket FD.
+ * When a connection arrives, open a new socket to communicate
+ * with it, set *ADDR (which is *ADDR_LEN bytes long) to the address
+ * of the connecting peer and *ADDR_LEN to the address's actual
+ * length, and return the new socket's descriptor, or -1 for errors.
+ * This function is a cancellation point and therefore not marked
+ * with __THROW.
+ * */
+int
+vcom_accept (int __fd, __SOCKADDR_ARG __addr,
+	     socklen_t * __restrict __addr_len)
+{
+
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+  return vcom_socket_accept (__fd, __addr, __addr_len);
+}
+
+int
+accept (int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len)
+{
+  int rv = -1;
+  pid_t pid = getpid ();
+  pthread_t tid = pthread_self ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      if (VCOM_DEBUG > 0)
+	vcom_socket_main_show ();
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d][%lu (0x%lx)] accept1: "
+		 "'%04d'='%04d', '%p', '%p'\n",
+		 pid, (unsigned long) tid, (unsigned long) tid,
+		 rv, __fd, __addr, __addr_len);
+      rv = vcom_accept (__fd, __addr, __addr_len);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d][%lu (0x%lx)] accept2: "
+		 "'%04d'='%04d', '%p', '%p'\n",
+		 pid, (unsigned long) tid, (unsigned long) tid,
+		 rv, __fd, __addr, __addr_len);
+      if (VCOM_DEBUG > 0)
+	vcom_socket_main_show ();
+      if (rv < 0)
+	{
+	  errno = -rv;
+	  return -1;
+	}
+      return rv;
+    }
+  return libc_accept (__fd, __addr, __addr_len);
+}
+
+#ifdef __USE_GNU
+/*
+ * Similar to 'accept' but takes an additional parameter to specify
+ * flags.
+ * This function is a cancellation point and therefore not marked
+ * with __THROW.
+ * */
+int
+vcom_accept4 (int __fd, __SOCKADDR_ARG __addr,
+	      socklen_t * __restrict __addr_len, int __flags)
+{
+
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_socket_accept4 (__fd, __addr, __addr_len, __flags);
+}
+
+int
+accept4 (int __fd, __SOCKADDR_ARG __addr,
+	 socklen_t * __restrict __addr_len, int __flags)
+{
+  int rv;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      if (VCOM_DEBUG > 0)
+	vcom_socket_main_show ();
+      rv = vcom_accept4 (__fd, __addr, __addr_len, __flags);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] accept4: "
+		 "'%04d'='%04d', '%p', '%p', '%04x'\n",
+		 pid, rv, __fd, __addr, __addr_len, __flags);
+      if (VCOM_DEBUG > 0)
+	vcom_socket_main_show ();
+      if (rv < 0)
+	{
+	  errno = -rv;
+	  return -1;
+	}
+      return rv;
+    }
+  return libc_accept4 (__fd, __addr, __addr_len, __flags);
+}
+
+#endif
+
+/*
+ * Shut down all or part of the connection open on socket FD.
+ * HOW determines what to shut down:
+ *   SHUT_RD   = No more receptions;
+ *   SHUT_WR   = No more transmissions;
+ *   SHUT_RDWR = No more receptions or transmissions.
+ * Returns 0 on success, -1 for errors.
+ * */
+int
+vcom_shutdown (int __fd, int __how)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+  return vcom_socket_shutdown (__fd, __how);
+}
+
+int
+shutdown (int __fd, int __how)
+{
+  int rv;
+  pid_t pid = getpid ();
+
+  if (is_vcom_socket_fd (__fd))
+    {
+      rv = vcom_shutdown (__fd, __how);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] shutdown: "
+		 "'%04d'='%04d', '%04d'\n", pid, rv, __fd, __how);
+      if (rv != 0)
+	{
+	  errno = -rv;
+	  return -1;
+	}
+      return 0;
+    }
+  return libc_shutdown (__fd, __how);
+}
+
+int
+vcom_epoll_create (int __size)
+{
+
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  if (__size <= 0)
+    {
+      return -EINVAL;
+    }
+
+  /* __size argument is ignored "thereafter" */
+  return vcom_epoll_create1 (0);
+}
+
+/*
+ * __size argument is ignored, but must be greater than zero
+ */
+int
+epoll_create (int __size)
+{
+  int rv = 0;
+  pid_t pid = getpid ();
+
+  rv = vcom_epoll_create (__size);
+  if (VCOM_DEBUG > 0)
+    fprintf (stderr,
+	     "[%d] epoll_create: " "'%04d'='%04d'\n", pid, rv, __size);
+  if (rv < 0)
+    {
+      errno = -rv;
+      return -1;
+    }
+  return rv;
+}
+
+int
+vcom_epoll_create1 (int __flags)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  if (__flags < 0)
+    {
+      return -EINVAL;
+    }
+  if (__flags & ~EPOLL_CLOEXEC)
+    {
+      return -EINVAL;
+    }
+  /* __flags can be either zero or EPOLL_CLOEXEC */
+  /* implementation */
+  return vcom_socket_epoll_create1 (__flags);
+}
+
+/*
+ * __flags can be either zero or EPOLL_CLOEXEC
+ * */
+int
+epoll_create1 (int __flags)
+{
+  int rv = 0;
+  pid_t pid = getpid ();
+
+  rv = vcom_epoll_create1 (__flags);
+  if (VCOM_DEBUG > 0)
+    fprintf (stderr,
+	     "[%d] epoll_create: " "'%04d'='%08x'\n", pid, rv, __flags);
+  if (rv < 0)
+    {
+      errno = -rv;
+      return -1;
+    }
+  return rv;
+}
+
+static inline int
+ep_op_has_event (int op)
+{
+  return op != EPOLL_CTL_DEL;
+}
+
+int
+vcom_epoll_ctl (int __epfd, int __op, int __fd, struct epoll_event *__event)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  /*
+   * the requested operation __op is not supported
+   * by this interface */
+  if (!((__op == EPOLL_CTL_ADD) ||
+	(__op == EPOLL_CTL_MOD) || (__op == EPOLL_CTL_DEL)))
+    {
+      return -EINVAL;
+    }
+
+  /* op is ADD or MOD but event parameter is NULL */
+  if ((ep_op_has_event (__op) && !__event))
+    {
+      return -EFAULT;
+    }
+
+  /* fd is same as epfd */
+  /* do not permit adding an epoll file descriptor inside itself */
+  if (__epfd == __fd)
+    {
+      return -EINVAL;
+    }
+
+  /* implementation */
+  return vcom_socket_epoll_ctl (__epfd, __op, __fd, __event);
+}
+
+/*
+ * implement the controller interface for epoll
+ * that enables the insertion/removal/change of
+ * file descriptors inside the interest set.
+ */
+int
+epoll_ctl (int __epfd, int __op, int __fd, struct epoll_event *__event)
+{
+  int rv;
+  pid_t pid = getpid ();
+
+  if (is_vcom_epfd (__epfd))
+    {
+      /* TBD: currently limiting epoll to support only vcom fds */
+      if (is_vcom_socket_fd (__fd))
+	{
+	  rv = vcom_epoll_ctl (__epfd, __op, __fd, __event);
+	  if (VCOM_DEBUG > 0)
+	    fprintf (stderr,
+		     "[%d] epoll_ctl: "
+		     "'%04d'='%04d', '%04d', '%04d'\n",
+		     pid, rv, __epfd, __op, __fd);
+	  if (rv != 0)
+	    {
+	      errno = -rv;
+	      return -1;
+	    }
+	  return 0;
+	}
+      else
+	{
+	  /*
+	   * TBD: currently epoll does not support kernel fds
+	   * or epoll fds */
+	  errno = EBADF;
+	  return -1;
+	}
+    }
+  else
+    {
+      /* epfd is not an epoll file descriptor */
+      errno = EINVAL;
+      return -1;
+    }
+  return 0;
+}
+
+int
+vcom_epoll_wait (int __epfd, struct epoll_event *__events,
+		 int __maxevents, int __timeout)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return vcom_epoll_pwait (__epfd, __events, __maxevents, __timeout, NULL);
+}
+
+int
+epoll_wait (int __epfd, struct epoll_event *__events,
+	    int __maxevents, int __timeout)
+{
+  int rv;
+  pid_t pid = getpid ();
+
+  if (__maxevents <= 0 || __maxevents > EP_MAX_EVENTS)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
+  if (is_vcom_epfd (__epfd))
+    {
+      rv = vcom_epoll_wait (__epfd, __events, __maxevents, __timeout);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] epoll_wait: "
+		 "'%04d'='%04d', '%p', "
+		 "'%04d', '%04d'\n",
+		 pid, rv, __epfd, __events, __maxevents, __timeout);
+      if (rv < 0)
+	{
+	  errno = -rv;
+	  return -1;
+	}
+      return rv;
+    }
+  else
+    {
+      errno = EINVAL;
+      return -1;
+    }
+  return 0;
+}
+
+
+int
+vcom_epoll_pwait (int __epfd, struct epoll_event *__events,
+		  int __maxevents, int __timeout, const __sigset_t * __ss)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  /* implementation */
+  return vcom_socket_epoll_pwait (__epfd, __events,
+				  __maxevents, __timeout, __ss);
+}
+
+int
+epoll_pwait (int __epfd, struct epoll_event *__events,
+	     int __maxevents, int __timeout, const __sigset_t * __ss)
+{
+  int rv;
+  pid_t pid = getpid ();
+
+  if (__maxevents <= 0 || __maxevents > EP_MAX_EVENTS)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
+  if (is_vcom_epfd (__epfd))
+    {
+      rv = vcom_epoll_pwait (__epfd, __events, __maxevents, __timeout, __ss);
+      if (VCOM_DEBUG > 0)
+	fprintf (stderr,
+		 "[%d] epoll_pwait: "
+		 "'%04d'='%04d', '%p', "
+		 "'%04d', '%04d', "
+		 "'%p'\n",
+		 pid, rv, __epfd, __events, __maxevents, __timeout, __ss);
+      if (rv < 0)
+	{
+	  errno = -rv;
+	  return -1;
+	}
+      return rv;
+    }
+  else
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
+  return 0;
+}
+
+/* Poll the file descriptors described by the NFDS structures starting at
+   FDS.  If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
+   an event to occur; if TIMEOUT is -1, block until an event occurs.
+   Returns the number of file descriptors with events, zero if timed out,
+   or -1 for errors.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+int
+vcom_poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return -EOPNOTSUPP;
+}
+
+int
+poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
+{
+  int rv = 0;
+
+  errno = EOPNOTSUPP;
+  rv = -1;
+  return rv;
+}
+
+#ifdef __USE_GNU
+/* Like poll, but before waiting the threads signal mask is replaced
+   with that specified in the fourth parameter.  For better usability,
+   the timeout value is specified using a TIMESPEC object.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+int
+vcom_ppoll (struct pollfd *__fds, nfds_t __nfds,
+	    const struct timespec *__timeout, const __sigset_t * __ss)
+{
+  if (vcom_init () != 0)
+    {
+      return -1;
+    }
+
+  return -EOPNOTSUPP;
+}
+
+int
+ppoll (struct pollfd *__fds, nfds_t __nfds,
+       const struct timespec *__timeout, const __sigset_t * __ss)
+{
+  int rv = 0;
+
+  errno = EOPNOTSUPP;
+  rv = -1;
+  return rv;
+}
+#endif
+
+void CONSTRUCTOR_ATTRIBUTE vcom_constructor (void);
+
+void DESTRUCTOR_ATTRIBUTE vcom_destructor (void);
+
+void
+vcom_constructor (void)
+{
+  pid_t pid = getpid ();
+
+  swrap_constructor ();
+  if (vcom_init () != 0)
+    {
+      printf ("\n[%d] vcom_constructor...failed!\n", pid);
+    }
+  else
+    {
+      printf ("\n[%d] vcom_constructor...done!\n", pid);
+    }
+}
+
+/*
+ * This function is called when the library is unloaded
+ */
+void
+vcom_destructor (void)
+{
+  pid_t pid = getpid ();
+
+  vcom_destroy ();
+  swrap_destructor ();
+  printf ("\n[%d] vcom_destructor...done!\n", pid);
+}
+
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.h b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.h
new file mode 100644
index 0000000..f6ee8a2
--- /dev/null
+++ b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.h
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef included_vcom_h
+#define included_vcom_h
+
+/* VCOM DEBUG flag.  Setting this to 1 or 0 turns off
+   ASSERT & other debugging code. */
+#ifndef VCOM_DEBUG
+#define VCOM_DEBUG 0
+#endif
+
+#include <libvcl-ldpreload/vcom_glibc_socket.h>
+
+#define MAX_VCOM_APP_NAME  256
+
+/* Returns 0 on success or -1 on error. */
+extern int vcom_set_app_name (char *__app_name);
+
+/*
+ *
+ * File descriptor based APIs
+ *
+ */
+
+/*
+ * vpp implementation of glibc APIs from <unistd.h>
+ */
+extern int vcom_close (int __fd);
+
+extern ssize_t __wur vcom_read (int __fd, void *__buf, size_t __nbytes);
+
+extern ssize_t __wur vcom_write (int __fd, const void *__buf, size_t __n);
+
+extern ssize_t __wur vcom_readv (int __fd, const struct iovec *__iov,
+				 int __iovcnt);
+
+extern ssize_t __wur vcom_writev (int __fd, const struct iovec *__iov,
+				  int __iovcnt);
+
+/*
+ * vpp implementation of glibc APIs from <fcntl.h>
+ */
+extern int vcom_fcntl (int __fd, int __cmd, ...);
+
+/*
+ * vpp implementation of glibc APIs from <sys/select.h>
+ */
+extern int
+vcom_select (int __nfds, fd_set * __restrict __readfds,
+	     fd_set * __restrict __writefds,
+	     fd_set * __restrict __exceptfds,
+	     struct timeval *__restrict __timeout);
+
+#ifdef __USE_XOPEN2K
+extern int
+vcom_pselect (int __nfds, fd_set * __restrict __readfds,
+	      fd_set * __restrict __writefds,
+	      fd_set * __restrict __exceptfds,
+	      const struct timespec *__restrict __timeout,
+	      const __sigset_t * __restrict __sigmask);
+#endif
+
+/*
+ * vpp implementation of glibc APIs from <sys/socket.h>
+ */
+extern int __THROW vcom_socket (int __domain, int __type, int __protocol);
+
+/* On Linux, the only supported domain for this call is AF_UNIX
+* (or synonymously, AF_LOCAL). Most implementations have the
+* same restriction.
+* vpp does not implement AF_UNIX domain in this release.
+* */
+extern int __THROW
+vcom_socketpair (int __domain, int __type, int __protocol, int __fds[2]);
+
+extern int __THROW
+vcom_bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
+
+extern int __THROW
+vcom_getsockname (int __fd, __SOCKADDR_ARG __addr,
+		  socklen_t * __restrict __len);
+
+extern int
+vcom_connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
+
+extern int __THROW
+vcom_getpeername (int __fd, __SOCKADDR_ARG __addr,
+		  socklen_t * __restrict __len);
+
+extern ssize_t
+vcom_send (int __fd, const void *__buf, size_t __n, int __flags);
+
+extern ssize_t vcom_recv (int __fd, void *__buf, size_t __n, int __flags);
+
+extern ssize_t
+vcom_sendto (int __fd, const void *__buf, size_t __n,
+	     int __flags, __CONST_SOCKADDR_ARG __addr, socklen_t __addr_len);
+
+extern ssize_t
+vcom_recvfrom (int __fd, void *__restrict __buf,
+	       size_t __n, int __flags,
+	       __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len);
+
+extern ssize_t
+vcom_sendmsg (int __fd, const struct msghdr *__message, int __flags);
+
+#ifdef __USE_GNU
+extern int
+sendmmsg (int __fd, struct mmsghdr *__vmessages,
+	  unsigned int __vlen, int __flags);
+#endif
+
+extern ssize_t vcom_recvmsg (int __fd, struct msghdr *__message, int __flags);
+
+#ifdef __USE_GNU
+extern int
+vcom_recvmmsg (int __fd, struct mmsghdr *__vmessages,
+	       unsigned int __vlen, int __flags, struct timespec *__tmo);
+#endif
+
+extern int __THROW
+vcom_getsockopt (int __fd, int __level, int __optname,
+		 void *__restrict __optval, socklen_t * __restrict __optlen);
+
+extern int __THROW
+vcom_setsockopt (int __fd, int __level, int __optname,
+		 const void *__optval, socklen_t __optlen);
+
+extern int __THROW vcom_listen (int __fd, int __n);
+
+extern int
+vcom_accept (int __fd, __SOCKADDR_ARG __addr,
+	     socklen_t * __restrict __addr_len);
+
+#ifdef __USE_GNU
+/*
+ * Similar to 'accept' but takes an additional parameter to specify
+ * flags.
+ * */
+/* TBD: implemented later */
+extern int
+vcom_accept4 (int __fd, __SOCKADDR_ARG __addr,
+	      socklen_t * __restrict __addr_len, int __flags);
+#endif
+
+extern int __THROW vcom_shutdown (int __fd, int __how);
+
+extern int __THROW vcom_epoll_create (int __size);
+
+extern int __THROW vcom_epoll_create1 (int __flags);
+
+extern int __THROW
+vcom_epoll_ctl (int __epfd, int __op, int __fd, struct epoll_event *__event);
+
+extern int
+vcom_epoll_wait (int __epfd, struct epoll_event *__events,
+		 int __maxevents, int __timeout);
+
+extern int
+vcom_epoll_pwait (int __epfd, struct epoll_event *__events,
+		  int __maxevents, int __timeout, const __sigset_t * __ss);
+
+extern int vcom_poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
+
+#ifdef __USE_GNU
+extern int
+vcom_ppoll (struct pollfd *__fds, nfds_t __nfds,
+	    const struct timespec *__timeout, const __sigset_t * __ss);
+#endif
+
+
+#endif /* included_vcom_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_glibc_socket.h b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_glibc_socket.h
new file mode 100644
index 0000000..0f1b174
--- /dev/null
+++ b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_glibc_socket.h
@@ -0,0 +1,349 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef included_vcom_glibc_socket_h
+#define included_vcom_glibc_socket_h
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/select.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+
+#include <sys/epoll.h>
+#include <poll.h>
+
+/*
+ *
+ * Generic glibc fd api
+ *
+ */
+/*
+ * glibc APIs from <unistd.h>
+ */
+
+/* Close the file descriptor FD.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int close (int __fd);
+
+/* Read NBYTES into BUF from FD.  Return the
+   number read, -1 for errors or 0 for EOF.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern ssize_t __wur read (int __fd, void *__buf, size_t __nbytes);
+
+/* Write N bytes of BUF to FD.  Return the number written, or -1.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern ssize_t __wur write (int __fd, const void *__buf, size_t __n);
+
+
+/*
+ * glibc APIs from <fcntl.h>
+ */
+
+/* Do the file control operation described by CMD on FD.
+   The remaining arguments are interpreted depending on CMD.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int fcntl (int __fd, int __cmd, ...);
+
+
+/*
+ * glibc APIs from <sys/select.h>
+ */
+
+/* Check the first NFDS descriptors each in READFDS (if not NULL) for read
+   readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
+   (if not NULL) for exceptional conditions.  If TIMEOUT is not NULL, time out
+   after waiting the interval specified therein.  Returns the number of ready
+   descriptors, or -1 for errors.
+
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int
+select (int __nfds, fd_set * __restrict __readfds,
+	fd_set * __restrict __writefds,
+	fd_set * __restrict __exceptfds,
+	struct timeval *__restrict __timeout);
+
+#ifdef __USE_XOPEN2K
+/* Same as above only that the TIMEOUT value is given with higher
+   resolution and a sigmask which is been set temporarily.  This version
+   should be used.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int
+pselect (int __nfds, fd_set * __restrict __readfds,
+	 fd_set * __restrict __writefds,
+	 fd_set * __restrict __exceptfds,
+	 const struct timespec *__restrict __timeout,
+	 const __sigset_t * __restrict __sigmask);
+#endif
+
+
+/*
+ *
+ * Socket specific glibc api
+ *
+ */
+
+/*
+ * glibc APIs from <sys/socket.h>
+ */
+
+/* Create a new socket of type TYPE in domain DOMAIN, using
+   protocol PROTOCOL.  If PROTOCOL is zero, one is chosen automatically.
+   Returns a file descriptor for the new socket, or -1 for errors.  */
+extern int __THROW socket (int __domain, int __type, int __protocol);
+
+/* Create two new sockets, of type TYPE in domain DOMAIN and using
+   protocol PROTOCOL, which are connected to each other, and put file
+   descriptors for them in FDS[0] and FDS[1].  If PROTOCOL is zero,
+   one will be chosen automatically.  Returns 0 on success, -1 for errors.  */
+extern int __THROW
+socketpair (int __domain, int __type, int __protocol, int __fds[2]);
+
+/* Give the socket FD the local address ADDR (which is LEN bytes long).  */
+extern int __THROW
+bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
+
+/* Put the local address of FD into *ADDR and its length in *LEN.  */
+extern int __THROW
+getsockname (int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __len);
+
+/* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
+   For connectionless socket types, just set the default address to send to
+   and the only address from which to accept transmissions.
+   Return 0 on success, -1 for errors.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
+
+/* Put the address of the peer connected to socket FD into *ADDR
+   (which is *LEN bytes long), and its actual length into *LEN.  */
+extern int __THROW
+getpeername (int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __len);
+
+/* Send N bytes of BUF to socket FD.  Returns the number sent or -1.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern ssize_t send (int __fd, const void *__buf, size_t __n, int __flags);
+
+/* Read N bytes into BUF from socket FD.
+   Returns the number read or -1 for errors.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags);
+
+/* Send N bytes of BUF on socket FD to peer at address ADDR (which is
+   ADDR_LEN bytes long).  Returns the number sent, or -1 for errors.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern ssize_t
+sendto (int __fd, const void *__buf, size_t __n,
+	int __flags, __CONST_SOCKADDR_ARG __addr, socklen_t __addr_len);
+
+/* Read N bytes into BUF through socket FD.
+   If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
+   the sender, and store the actual size of the address in *ADDR_LEN.
+   Returns the number of bytes read or -1 for errors.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern ssize_t
+recvfrom (int __fd, void *__restrict __buf,
+	  size_t __n, int __flags,
+	  __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len);
+
+/* Send a message described MESSAGE on socket FD.
+   Returns the number of bytes sent, or -1 for errors.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern ssize_t
+sendmsg (int __fd, const struct msghdr *__message, int __flags);
+
+#ifdef __USE_GNU
+/* Send a VLEN messages as described by VMESSAGES to socket FD.
+   Returns the number of datagrams successfully written or -1 for errors.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int
+sendmmsg (int __fd, struct mmsghdr *__vmessages,
+	  unsigned int __vlen, int __flags);
+#endif
+
+/* Receive a message as described by MESSAGE from socket FD.
+   Returns the number of bytes read or -1 for errors.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
+
+#ifdef __USE_GNU
+/* Receive up to VLEN messages as described by VMESSAGES from socket FD.
+   Returns the number of messages received or -1 for errors.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int
+recvmmsg (int __fd, struct mmsghdr *__vmessages,
+	  unsigned int __vlen, int __flags, struct timespec *__tmo);
+#endif
+
+
+/* Put the current value for socket FD's option OPTNAME at protocol level LEVEL
+   into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's
+   actual length.  Returns 0 on success, -1 for errors.  */
+extern int __THROW
+getsockopt (int __fd, int __level, int __optname,
+	    void *__restrict __optval, socklen_t * __restrict __optlen);
+
+/* Set socket FD's option OPTNAME at protocol level LEVEL
+   to *OPTVAL (which is OPTLEN bytes long).
+   Returns 0 on success, -1 for errors.  */
+extern int __THROW
+setsockopt (int __fd, int __level, int __optname,
+	    const void *__optval, socklen_t __optlen);
+
+/* Prepare to accept connections on socket FD.
+   N connection requests will be queued before further requests are refused.
+   Returns 0 on success, -1 for errors.  */
+extern int __THROW listen (int __fd, int __n);
+
+/* Await a connection on socket FD.
+   When a connection arrives, open a new socket to communicate with it,
+   set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting
+   peer and *ADDR_LEN to the address's actual length, and return the
+   new socket's descriptor, or -1 for errors.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int
+accept (int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len);
+
+#ifdef __USE_GNU
+/* Similar to 'accept' but takes an additional parameter to specify flags.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+     /* TBD: implemented later */
+extern int
+accept4 (int __fd, __SOCKADDR_ARG __addr,
+	 socklen_t * __restrict __addr_len, int __flags);
+#endif
+
+/* Shut down all or part of the connection open on socket FD.
+   HOW determines what to shut down:
+     SHUT_RD   = No more receptions;
+     SHUT_WR   = No more transmissions;
+     SHUT_RDWR = No more receptions or transmissions.
+   Returns 0 on success, -1 for errors.  */
+extern int __THROW shutdown (int __fd, int __how);
+
+
+/*
+ * glibc APIs from <sys/epoll.h>
+ */
+
+/* Creates an epoll instance.  Returns an fd for the new instance.
+   The "size" parameter is a hint specifying the number of file
+   descriptors to be associated with the new instance.  The fd
+   returned by epoll_create() should be closed with close().  */
+extern int __THROW epoll_create (int __size);
+
+/* Same as epoll_create but with an FLAGS parameter.  The unused SIZE
+   parameter has been dropped.  */
+extern int __THROW epoll_create1 (int __flags);
+
+/* Manipulate an epoll instance "epfd". Returns 0 in case of success,
+   -1 in case of error ( the "errno" variable will contain the
+   specific error code ) The "op" parameter is one of the EPOLL_CTL_*
+   constants defined above. The "fd" parameter is the target of the
+   operation. The "event" parameter describes which events the caller
+   is interested in and any associated user data.  */
+extern int __THROW
+epoll_ctl (int __epfd, int __op, int __fd, struct epoll_event *__event);
+
+#define EP_INT_MAX ((int)(~0U>>1))
+#define EP_MAX_EVENTS (EP_INT_MAX / sizeof(struct epoll_event))
+
+/* Wait for events on an epoll instance "epfd". Returns the number of
+   triggered events returned in "events" buffer. Or -1 in case of
+   error with the "errno" variable set to the specific error code. The
+   "events" parameter is a buffer that will contain triggered
+   events. The "maxevents" is the maximum number of events to be
+   returned ( usually size of "events" ). The "timeout" parameter
+   specifies the maximum wait time in milliseconds (-1 == infinite).
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int
+epoll_wait (int __epfd, struct epoll_event *__events,
+	    int __maxevents, int __timeout);
+
+/* Same as epoll_wait, but the thread's signal mask is temporarily
+   and atomically replaced with the one provided as parameter.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int
+epoll_pwait (int __epfd, struct epoll_event *__events,
+	     int __maxevents, int __timeout, const __sigset_t * __ss);
+
+/* Poll the file descriptors described by the NFDS structures starting at
+   FDS.  If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
+   an event to occur; if TIMEOUT is -1, block until an event occurs.
+   Returns the number of file descriptors with events, zero if timed out,
+   or -1 for errors.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
+
+#ifdef __USE_GNU
+/* Like poll, but before waiting the threads signal mask is replaced
+   with that specified in the fourth parameter.  For better usability,
+   the timeout value is specified using a TIMESPEC object.
+
+   This function is a cancellation point and therefore not marked with
+   __THROW.  */
+extern int ppoll (struct pollfd *__fds, nfds_t __nfds,
+		  const struct timespec *__timeout, const __sigset_t * __ss);
+#endif
+
+
+#endif /* included_vcom_glibc_socket_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c
new file mode 100644
index 0000000..86b923c
--- /dev/null
+++ b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c
@@ -0,0 +1,2944 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/uio.h>
+#include <limits.h>
+#define __need_IOV_MAX
+#include <bits/stdio_lim.h>
+
+#include <vppinfra/types.h>
+#include <vppinfra/hash.h>
+#include <vppinfra/pool.h>
+
+#include <libvcl-ldpreload/vcom_socket.h>
+#include <libvcl-ldpreload/vcom_socket_wrapper.h>
+#include <libvcl-ldpreload/vcom.h>
+
+#include <uri/vppcom.h>
+
+
+/*
+ * VCOM_SOCKET Private definitions and functions.
+ */
+
+typedef struct vcom_socket_main_t_
+{
+  u8 init;
+
+  /* vcom_socket pool */
+  vcom_socket_t *vsockets;
+
+  /* Hash table for socketidx to fd mapping */
+  uword *sockidx_by_fd;
+
+  /* vcom_epoll pool */
+  vcom_epoll_t *vepolls;
+
+  /* Hash table for epollidx to epfd mapping */
+  uword *epollidx_by_epfd;
+
+
+  /* common epitem poll for all epfd */
+  /* TBD: epitem poll per epfd */
+  /* vcom_epitem pool */
+  vcom_epitem_t *vepitems;
+
+  /* Hash table for epitemidx to epfdfd mapping */
+  uword *epitemidx_by_epfdfd;
+
+  /* Hash table - key:epfd, value:vec of epitemidx */
+  uword *epitemidxs_by_epfd;
+  /* Hash table - key:fd, value:vec of epitemidx */
+  uword *epitemidxs_by_fd;
+
+} vcom_socket_main_t;
+
+vcom_socket_main_t vcom_socket_main;
+
+
+static int
+vcom_socket_open_socket (int domain, int type, int protocol)
+{
+  int rv = -1;
+
+  /* handle domains implemented by vpp */
+  switch (domain)
+    {
+    case AF_INET:
+    case AF_INET6:
+      /* get socket type and
+       * handle the socket types supported by vpp */
+      switch (type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK))
+	{
+	case SOCK_STREAM:
+	case SOCK_DGRAM:
+	  /* the type argument serves a second purpose,
+	   * in addition to specifying a socket type,
+	   * it may include the bitwise OR of any of
+	   * SOCK_NONBLOCK and SOCK_CLOEXEC, to modify
+	   * the behavior of socket. */
+	  rv = libc_socket (domain, type, protocol);
+	  if (rv == -1)
+	    rv = -errno;
+	  break;
+
+	default:
+	  break;
+	}
+
+      break;
+
+    default:
+      break;
+    }
+
+  return rv;
+}
+
+static int
+vcom_socket_open_epoll (int flags)
+{
+  int rv = -1;
+
+  if (flags < 0)
+    {
+      return -EINVAL;
+    }
+  if (flags && (flags & ~EPOLL_CLOEXEC))
+    {
+      return -EINVAL;
+    }
+
+  /* flags can be either zero or EPOLL_CLOEXEC */
+  rv = libc_epoll_create1 (flags);
+  if (rv == -1)
+    rv = -errno;
+
+  return rv;
+}
+
+static int
+vcom_socket_close_socket (int fd)
+{
+  int rv;
+
+  rv = libc_close (fd);
+  if (rv == -1)
+    rv = -errno;
+
+  return rv;
+}
+
+static int
+vcom_socket_close_epoll (int epfd)
+{
+  int rv;
+
+  rv = libc_close (epfd);
+  if (rv == -1)
+    rv = -errno;
+
+  return rv;
+}
+
+/*
+ * Public API functions
+ */
+
+
+int
+vcom_socket_is_vcom_fd (int fd)
+{
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, fd);
+
+  if (p)
+    {
+      vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+      if (vsock && vsock->type == SOCKET_TYPE_VPPCOM_BOUND)
+	return 1;
+    }
+  return 0;
+}
+
+int
+vcom_socket_is_vcom_epfd (int epfd)
+{
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_epoll_t *vepoll;
+
+  p = hash_get (vsm->epollidx_by_epfd, epfd);
+
+  if (p)
+    {
+      vepoll = pool_elt_at_index (vsm->vepolls, p[0]);
+      if (vepoll && vepoll->type == EPOLL_TYPE_VPPCOM_BOUND)
+	return 1;
+    }
+  return 0;
+}
+
+static inline int
+vcom_socket_get_sid (int fd)
+{
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, fd);
+
+  if (p)
+    {
+      vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+      if (vsock && vsock->type == SOCKET_TYPE_VPPCOM_BOUND)
+	return vsock->sid;
+    }
+  return INVALID_SESSION_ID;
+}
+
+static inline int
+vcom_socket_get_vep_idx (int epfd)
+{
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_epoll_t *vepoll;
+
+  p = hash_get (vsm->epollidx_by_epfd, epfd);
+
+  if (p)
+    {
+      vepoll = pool_elt_at_index (vsm->vepolls, p[0]);
+      if (vepoll && vepoll->type == EPOLL_TYPE_VPPCOM_BOUND)
+	return vepoll->vep_idx;
+    }
+  return INVALID_VEP_IDX;
+}
+
+static inline int
+vcom_socket_get_sid_and_vsock (int fd, vcom_socket_t ** vsockp)
+{
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, fd);
+
+  if (p)
+    {
+      vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+      if (vsock && vsock->type == SOCKET_TYPE_VPPCOM_BOUND)
+	{
+	  *vsockp = vsock;
+	  return vsock->sid;
+	}
+    }
+  return INVALID_SESSION_ID;
+}
+
+static inline int
+vcom_socket_get_vep_idx_and_vepoll (int epfd, vcom_epoll_t ** vepollp)
+{
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_epoll_t *vepoll;
+
+  p = hash_get (vsm->epollidx_by_epfd, epfd);
+
+  if (p)
+    {
+      vepoll = pool_elt_at_index (vsm->vepolls, p[0]);
+      if (vepoll && vepoll->type == EPOLL_TYPE_VPPCOM_BOUND)
+	{
+	  *vepollp = vepoll;
+	  return vepoll->vep_idx;
+	}
+    }
+  return INVALID_VEP_IDX;
+}
+
+
+static int
+vcom_socket_close_vepoll (int epfd)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_epoll_t *vepoll;
+
+  p = hash_get (vsm->epollidx_by_epfd, epfd);
+  if (!p)
+    return -EBADF;
+
+  vepoll = pool_elt_at_index (vsm->vepolls, p[0]);
+  if (!vepoll)
+    return -EBADF;
+
+  if (vepoll->type != EPOLL_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  if (vepoll->count)
+    {
+      if (!vepoll->close)
+	{
+	  vepoll->close = 1;
+	  return 0;
+	}
+      else
+	{
+	  return -EBADF;
+	}
+    }
+
+  /* count is zero */
+  rv = vppcom_session_close (vepoll->vep_idx);
+  rv = vcom_socket_close_epoll (vepoll->epfd);
+
+  vepoll_init (vepoll);
+  hash_unset (vsm->epollidx_by_epfd, epfd);
+  pool_put (vsm->vepolls, vepoll);
+
+  return rv;
+}
+
+static int
+vcom_socket_close_vsock (int fd)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  vcom_epitem_t *vepitem;
+
+  i32 *vepitemidxs = 0;
+  i32 *vepitemidxs_var = 0;
+
+  p = hash_get (vsm->sockidx_by_fd, fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  rv = vppcom_session_close (vsock->sid);
+  rv = vcom_socket_close_socket (vsock->fd);
+
+  vsocket_init (vsock);
+  hash_unset (vsm->sockidx_by_fd, fd);
+  pool_put (vsm->vsockets, vsock);
+
+  /*
+   * NOTE:
+   * Before calling close(), user should remove
+   * this fd from the epoll-set of all epoll instances,
+   * otherwise resource(epitems) leaks ensues.
+   */
+
+  /*
+   * 00. close all epoll instances that are marked as "close"
+   *     of which this fd is the "last" remaining member.
+   * 01. epitems associated with this fd are intentionally
+   *     not removed, see NOTE: above.
+   * */
+
+  /* does this fd participate in epoll */
+  p = hash_get (vsm->epitemidxs_by_fd, fd);
+  if (p)
+    {
+      vepitemidxs = *(i32 **) p;
+      vec_foreach (vepitemidxs_var, vepitemidxs)
+      {
+	vepitem = pool_elt_at_index (vsm->vepitems, vepitemidxs_var[0]);
+	if (vepitem && vepitem->fd == fd &&
+	    vepitem->type == FD_TYPE_VCOM_SOCKET)
+	  {
+	    i32 vep_idx;
+	    vcom_epoll_t *vepoll;
+	    if ((vep_idx =
+		 vcom_socket_get_vep_idx_and_vepoll (vepitem->epfd,
+						     &vepoll)) !=
+		INVALID_VEP_IDX)
+	      {
+		if (vepoll->close)
+		  {
+		    if (vepoll->count == 1)
+		      {
+			/*
+			 * force count to zero and
+			 * close this epoll instance
+			 * */
+			vepoll->count = 0;
+			vcom_socket_close_vepoll (vepoll->epfd);
+		      }
+		    else
+		      {
+			vepoll->count -= 1;
+		      }
+		  }
+	      }
+	  }
+
+      }
+    }
+
+  return rv;
+}
+
+int
+vcom_socket_close (int __fd)
+{
+  int rv;
+
+  if (vcom_socket_is_vcom_fd (__fd))
+    {
+      rv = vcom_socket_close_vsock (__fd);
+    }
+  else if (vcom_socket_is_vcom_epfd (__fd))
+    {
+      rv = vcom_socket_close_vepoll (__fd);
+    }
+  else
+    {
+      rv = -EBADF;
+    }
+
+  return rv;
+}
+
+ssize_t
+vcom_socket_read (int __fd, void *__buf, size_t __nbytes)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  if (!__buf || __nbytes < 0)
+    {
+      return -EINVAL;
+    }
+
+  rv = vcom_fcntl (__fd, F_GETFL, 0);
+  if (rv < 0)
+    {
+      return rv;
+
+    }
+
+  /* is blocking */
+  if (!(rv & O_NONBLOCK))
+    {
+      do
+	{
+	  rv = vppcom_session_read (vsock->sid, __buf, __nbytes);
+	}
+      while (rv == -EAGAIN || rv == -EWOULDBLOCK);
+      return rv;
+    }
+  /* The file descriptor refers to a socket and has been
+   * marked nonblocking(O_NONBLOCK) and the read would
+   * block.
+   * */
+  /* is non blocking */
+  rv = vppcom_session_read (vsock->sid, __buf, __nbytes);
+  return rv;
+}
+
+ssize_t
+vcom_socket_readv (int __fd, const struct iovec * __iov, int __iovcnt)
+{
+  int rv;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+  ssize_t total = 0, len = 0;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  if (__iov == 0 || __iovcnt == 0 || __iovcnt > IOV_MAX)
+    return -EINVAL;
+
+  /* Sanity check */
+  for (int i = 0; i < __iovcnt; ++i)
+    {
+      if (SSIZE_MAX - len < __iov[i].iov_len)
+	return -EINVAL;
+      len += __iov[i].iov_len;
+    }
+
+  rv = vcom_fcntl (__fd, F_GETFL, 0);
+  if (rv < 0)
+    {
+      return rv;
+    }
+
+  /* is blocking */
+  if (!(rv & O_NONBLOCK))
+    {
+      do
+	{
+	  for (int i = 0; i < __iovcnt; ++i)
+	    {
+	      rv = vppcom_session_read (vsock->sid, __iov[i].iov_base,
+					__iov[i].iov_len);
+	      if (rv < 0)
+		break;
+	      else
+		{
+		  total += rv;
+		  if (rv < __iov[i].iov_len)
+		    /* Read less than buffer provided, no point to continue */
+		    break;
+		}
+	    }
+	}
+      while ((rv == -EAGAIN || rv == -EWOULDBLOCK) && total == 0);
+      return total;
+    }
+
+  /* is non blocking */
+  for (int i = 0; i < __iovcnt; ++i)
+    {
+      rv = vppcom_session_read (vsock->sid, __iov[i].iov_base,
+				__iov[i].iov_len);
+      if (rv < 0)
+	{
+	  if (total > 0)
+	    break;
+	  else
+	    {
+	      errno = rv;
+	      return rv;
+	    }
+	}
+      else
+	{
+	  total += rv;
+	  if (rv < __iov[i].iov_len)
+	    /* Read less than buffer provided, no point to continue */
+	    break;
+	}
+    }
+  return total;
+}
+
+ssize_t
+vcom_socket_write (int __fd, const void *__buf, size_t __n)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  if (!__buf || __n < 0)
+    {
+      return -EINVAL;
+    }
+
+  rv = vppcom_session_write (vsock->sid, (void *) __buf, __n);
+  return rv;
+}
+
+ssize_t
+vcom_socket_writev (int __fd, const struct iovec * __iov, int __iovcnt)
+{
+  int rv = -1;
+  ssize_t total = 0;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  if (__iov == 0 || __iovcnt == 0 || __iovcnt > IOV_MAX)
+    return -EINVAL;
+
+  for (int i = 0; i < __iovcnt; ++i)
+    {
+      rv = vppcom_session_write (vsock->sid, __iov[i].iov_base,
+				 __iov[i].iov_len);
+      if (rv < 0)
+	{
+	  if (total > 0)
+	    break;
+	  else
+	    return rv;
+	}
+      else
+	total += rv;
+    }
+  return total;
+}
+
+/*
+ * RETURN:  0 - invalid cmd
+ *          1 - cmd not handled by vcom and vppcom
+ *          2 - cmd handled by vcom socket resource
+ *          3 - cmd handled by vppcom
+ * */
+/* TBD: incomplete list of cmd */
+static int
+vcom_socket_check_fcntl_cmd (int __cmd)
+{
+  switch (__cmd)
+    {
+      /*cmd not handled by vcom and vppcom */
+      /* Fallthrough */
+    case F_DUPFD:
+    case F_DUPFD_CLOEXEC:
+      return 1;
+
+      /* cmd handled by vcom socket resource */
+      /* Fallthrough */
+    case F_GETFD:
+    case F_SETFD:
+    case F_GETFL:
+    case F_SETFL:
+    case F_GETLK:
+    case F_SETLK:
+    case F_SETLKW:
+    case F_GETOWN:
+    case F_SETOWN:
+      return 2;
+
+#if 0
+      /* cmd handled by vppcom */
+    case F_XXXXX:
+      return 3;
+#endif
+      /* invalid cmd */
+    default:
+      return 0;
+    }
+  return 0;
+}
+
+/* TBD: move it to vppcom */
+static int
+vppcom_session_fcntl_va (int __fd, int __cmd, va_list __ap)
+{
+  int rv;
+
+  rv = -EINVAL;
+
+  return rv;
+}
+
+int
+vcom_socket_fcntl_va (int __fd, int __cmd, va_list __ap)
+{
+  int rv = -EBADF;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  switch (vcom_socket_check_fcntl_cmd (__cmd))
+    {
+      /* invalid cmd */
+    case 0:
+      rv = -EBADF;
+      break;
+      /*cmd not handled by vcom and vppcom */
+    case 1:
+      rv = -EBADF;
+      break;
+      /* cmd handled by vcom socket resource */
+    case 2:
+      rv = libc_vfcntl (vsock->fd, __cmd, __ap);
+      break;
+      /* cmd handled by vppcom */
+    case 3:
+      rv = vppcom_session_fcntl_va (vsock->sid, __cmd, __ap);
+      break;
+
+    default:
+      rv = -EINVAL;
+      break;
+    }
+
+  return rv;
+}
+
+static inline int
+vcom_socket_fds_2_sid_fds (
+			    /* dest */
+			    int *vcom_nsid_fds,
+			    fd_set * __restrict vcom_rd_sid_fds,
+			    fd_set * __restrict vcom_wr_sid_fds,
+			    fd_set * __restrict vcom_ex_sid_fds,
+			    /* src */
+			    int vcom_nfds,
+			    fd_set * __restrict vcom_readfds,
+			    fd_set * __restrict vcom_writefds,
+			    fd_set * __restrict vcom_exceptfds)
+{
+  int rv = 0;
+  int fd;
+  int sid;
+  /* invalid max_sid is -1 */
+  int max_sid = -1;
+  int nsid = 0;
+
+  /*
+   *  set sid in sid sets corresponding to fd's in fd sets
+   *  compute nsid and vcom_nsid_fds from sid sets
+   */
+
+  for (fd = 0; fd < vcom_nfds; fd++)
+    {
+      /*
+       * F fd set, src
+       * S sid set, dest
+       */
+#define _(S,F)                              \
+      if ((F) && (S) && FD_ISSET (fd, (F))) \
+        {                                   \
+          sid = vcom_socket_get_sid (fd);   \
+          if (sid != INVALID_SESSION_ID)    \
+            {                               \
+              FD_SET (sid, (S));            \
+              if (sid > max_sid)            \
+                {                           \
+                  max_sid = sid;            \
+                }                           \
+              ++nsid;                       \
+            }                               \
+          else                              \
+            {                               \
+              rv = -EBADFD;                 \
+              goto done;                    \
+            }                               \
+        }
+
+
+      _(vcom_rd_sid_fds, vcom_readfds);
+      _(vcom_wr_sid_fds, vcom_writefds);
+      _(vcom_ex_sid_fds, vcom_exceptfds);
+#undef _
+    }
+
+  *vcom_nsid_fds = max_sid != -1 ? max_sid + 1 : 0;
+  rv = nsid;
+
+done:
+  return rv;
+}
+
+/*
+ * PRE: 00. sid sets were derived from fd sets
+ *      01. sid sets were updated with sids that actually changed
+ *          status
+ *      02. fd sets still has watched fds
+ *
+ * This function will modify in place fd sets to indicate which fd's
+ * actually changed status(inferred from sid sets)
+ */
+static inline int
+vcom_socket_sid_fds_2_fds (
+			    /* dest */
+			    int *new_vcom_nfds,
+			    int vcom_nfds,
+			    fd_set * __restrict vcom_readfds,
+			    fd_set * __restrict vcom_writefds,
+			    fd_set * __restrict vcom_exceptfds,
+			    /* src */
+			    int vcom_nsid_fds,
+			    fd_set * __restrict vcom_rd_sid_fds,
+			    fd_set * __restrict vcom_wr_sid_fds,
+			    fd_set * __restrict vcom_ex_sid_fds)
+{
+  int rv = 0;
+  int fd;
+  int sid;
+  /* invalid max_fd is -1 */
+  int max_fd = -1;
+  int nfd = 0;
+
+
+  /*
+   *  modify in place fd sets to indicate which fd's
+   * actually changed status(inferred from sid sets)
+   */
+  for (fd = 0; fd < vcom_nfds; fd++)
+    {
+      /*
+       * F fd set, dest
+       * S sid set, src
+       */
+#define _(S,F)                              \
+      if ((F) && (S) && FD_ISSET (fd, (F))) \
+        {                                   \
+          sid = vcom_socket_get_sid (fd);   \
+          if (sid != INVALID_SESSION_ID)    \
+            {                               \
+              if (!FD_ISSET (sid, (S)))     \
+                {                           \
+                   FD_CLR(fd, (F));         \
+                }                           \
+            }                               \
+          else                              \
+            {                               \
+              rv = -EBADFD;                 \
+              goto done;                    \
+            }                               \
+        }
+
+
+      _(vcom_rd_sid_fds, vcom_readfds);
+      _(vcom_wr_sid_fds, vcom_writefds);
+      _(vcom_ex_sid_fds, vcom_exceptfds);
+#undef _
+    }
+
+  /*
+   *  compute nfd and new_vcom_nfds from fd sets
+   */
+  for (fd = 0; fd < vcom_nfds; fd++)
+    {
+
+#define _(F)                                \
+      if ((F) && FD_ISSET (fd, (F)))        \
+        {                                   \
+          if (fd > max_fd)                  \
+            {                               \
+              max_fd = fd;                  \
+            }                               \
+          ++nfd;                            \
+        }
+
+
+      _(vcom_readfds);
+      _(vcom_writefds);
+      _(vcom_exceptfds);
+#undef _
+
+    }
+
+  *new_vcom_nfds = max_fd != -1 ? max_fd + 1 : 0;
+  rv = nfd;
+
+done:
+  return rv;
+}
+
+/*
+ * PRE:
+ * vom_socket_select is always called with
+ * timeout->tv_sec and timeout->tv_usec set to zero.
+ * hence vppcom_select return immediately.
+ */
+/*
+ * TBD: do{body;} while(timeout conditional); timeout loop
+ */
+int
+vcom_socket_select (int vcom_nfds, fd_set * __restrict vcom_readfds,
+		    fd_set * __restrict vcom_writefds,
+		    fd_set * __restrict vcom_exceptfds,
+		    struct timeval *__restrict timeout)
+{
+  int rv = -EBADF;
+  pid_t pid = getpid ();
+
+  int new_vcom_nfds = 0;
+  int new_vcom_nfd = 0;
+
+  /* vcom sid fds */
+  fd_set vcom_rd_sid_fds;
+  fd_set vcom_wr_sid_fds;
+  fd_set vcom_ex_sid_fds;
+  unsigned long vcom_nsid_fds = 0;
+  int vcom_nsid = 0;
+
+  /* in seconds eg. 3.123456789 seconds */
+  double time_to_wait = (double) 0;
+
+  /* validate inputs */
+  if (vcom_nfds < 0)
+    {
+      return -EINVAL;
+    }
+
+  /* convert timeval timeout to double time_to_wait */
+  if (timeout)
+    {
+      if (timeout->tv_sec == 0 && timeout->tv_usec == 0)
+	{
+	  /* polling: vppcom_select returns immediately */
+	  time_to_wait = (double) 0;
+	}
+      else
+	{
+	  /*TBD:  use timeval api */
+	  time_to_wait = (double) timeout->tv_sec +
+	    (double) timeout->tv_usec / (double) 1000000 +
+	    (double) (timeout->tv_usec % 1000000) / (double) 1000000;
+	}
+    }
+  else
+    {
+      /*
+       * no timeout: vppcom_select can block indefinitely
+       * waiting for a file descriptor to become ready
+       * */
+      /* set to a phantom value */
+      time_to_wait = ~0;
+    }
+
+  /* zero the sid_sets */
+  /*
+   * F fd set
+   * S sid set
+   */
+#define _(S,F)                          \
+  if ((F))                              \
+    {                                   \
+      FD_ZERO ((S));                    \
+    }
+
+
+  _(&vcom_rd_sid_fds, vcom_readfds);
+  _(&vcom_wr_sid_fds, vcom_writefds);
+  _(&vcom_ex_sid_fds, vcom_exceptfds);
+#undef _
+
+  /* populate read, write and except sid_sets */
+  vcom_nsid = vcom_socket_fds_2_sid_fds (
+					  /* dest */
+					  vcom_readfds || vcom_writefds
+					  || vcom_exceptfds ? (int *)
+					  &vcom_nsid_fds : NULL,
+					  vcom_readfds ? &vcom_rd_sid_fds :
+					  NULL,
+					  vcom_writefds ? &vcom_wr_sid_fds :
+					  NULL,
+					  vcom_exceptfds ? &vcom_ex_sid_fds :
+					  NULL,
+					  /* src */
+					  vcom_nfds,
+					  vcom_readfds,
+					  vcom_writefds, vcom_exceptfds);
+  if (vcom_nsid < 0)
+    {
+      return vcom_nsid;
+    }
+  if (vcom_nsid_fds < 0)
+    {
+      return -EINVAL;
+    }
+
+  rv = vppcom_select (vcom_nsid_fds,
+		      vcom_readfds ? (unsigned long *) &vcom_rd_sid_fds :
+		      NULL,
+		      vcom_writefds ? (unsigned long *) &vcom_wr_sid_fds :
+		      NULL,
+		      vcom_exceptfds ? (unsigned long *) &vcom_ex_sid_fds :
+		      NULL, time_to_wait);
+  if (VCOM_DEBUG > 0)
+    fprintf (stderr, "[%d] vppcom_select: "
+	     "'%04d'='%04d'\n", pid, rv, (int) vcom_nsid_fds);
+
+  /* check if any file descriptors changed status */
+  if (rv > 0)
+    {
+      /*
+       * on exit, sets are modified in place to indicate which
+       * file descriptors actually changed status
+       * */
+
+      /*
+       * comply with pre-condition
+       * do not clear vcom fd sets befor calling
+       * vcom_socket_sid_fds_2_fds
+       */
+      new_vcom_nfd = vcom_socket_sid_fds_2_fds (
+						 /* dest */
+						 &new_vcom_nfds,
+						 vcom_nfds,
+						 vcom_readfds,
+						 vcom_writefds,
+						 vcom_exceptfds,
+						 /* src */
+						 vcom_nsid_fds,
+						 vcom_readfds ?
+						 &vcom_rd_sid_fds : NULL,
+						 vcom_writefds ?
+						 &vcom_wr_sid_fds : NULL,
+						 vcom_exceptfds ?
+						 &vcom_ex_sid_fds : NULL);
+      if (new_vcom_nfd < 0)
+	{
+	  return new_vcom_nfd;
+	}
+      if (new_vcom_nfds < 0)
+	{
+	  return -EINVAL;
+	}
+      rv = new_vcom_nfd;
+    }
+  return rv;
+}
+
+
+int
+vcom_socket_socket (int __domain, int __type, int __protocol)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  vcom_socket_t *vsock;
+
+  i32 fd;
+  i32 sid;
+  i32 sockidx;
+  u8 is_nonblocking = __type & SOCK_NONBLOCK ? 1 : 0;
+  int type = __type & ~(SOCK_NONBLOCK | SOCK_CLOEXEC);
+
+  fd = vcom_socket_open_socket (__domain, __type, __protocol);
+  if (fd < 0)
+    {
+      rv = fd;
+      goto out;
+    }
+
+  sid = vppcom_session_create (VPPCOM_VRF_DEFAULT,
+			       (type == SOCK_DGRAM) ?
+			       VPPCOM_PROTO_UDP : VPPCOM_PROTO_TCP,
+			       is_nonblocking);
+  if (sid < 0)
+    {
+      rv = sid;
+      goto out_close_socket;
+    }
+
+  pool_get (vsm->vsockets, vsock);
+  vsocket_init (vsock);
+
+  sockidx = vsock - vsm->vsockets;
+  hash_set (vsm->sockidx_by_fd, fd, sockidx);
+
+  vsocket_set (vsock, fd, sid, SOCKET_TYPE_VPPCOM_BOUND);
+  return fd;
+
+out_close_socket:
+  vcom_socket_close_socket (fd);
+out:
+  return rv;
+}
+
+int
+vcom_socket_socketpair (int __domain, int __type, int __protocol,
+			int __fds[2])
+{
+/* TBD: */
+  return 0;
+}
+
+int
+vcom_socket_bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  vppcom_endpt_t ep;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  if (!__addr)
+    {
+      return -EINVAL;
+    }
+
+  ep.vrf = VPPCOM_VRF_DEFAULT;
+  switch (__addr->sa_family)
+    {
+    case AF_INET:
+      if (__len != sizeof (struct sockaddr_in))
+	{
+	  return -EINVAL;
+	}
+      ep.is_ip4 = VPPCOM_IS_IP4;
+      ep.ip = (u8 *) & ((const struct sockaddr_in *) __addr)->sin_addr;
+      ep.port = (u16) ((const struct sockaddr_in *) __addr)->sin_port;
+      break;
+
+    case AF_INET6:
+      if (__len != sizeof (struct sockaddr_in6))
+	{
+	  return -EINVAL;
+	}
+      ep.is_ip4 = VPPCOM_IS_IP6;
+      ep.ip = (u8 *) & ((const struct sockaddr_in6 *) __addr)->sin6_addr;
+      ep.port = (u16) ((const struct sockaddr_in6 *) __addr)->sin6_port;
+      break;
+
+    default:
+      return -1;
+      break;
+    }
+
+  rv = vppcom_session_bind (vsock->sid, &ep);
+  /* TBD: remove libc_bind code snippet
+   * once vppcom implements vppcom_session_getsockname */
+  if (rv == 0)
+    {
+      rv = libc_bind (__fd, __addr, __len);
+      if (rv != 0)
+	{
+	  rv = -errno;
+	}
+    }
+  return rv;
+}
+
+int
+vppcom_session_getsockname (int sid, vppcom_endpt_t * ep)
+{
+  /* TBD: move it to vppcom */
+  return 0;
+}
+
+int
+vcom_socket_getsockname (int __fd, __SOCKADDR_ARG __addr,
+			 socklen_t * __restrict __len)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  if (!__addr || !__len)
+    return -EFAULT;
+
+  if (*__len < 0)
+    {
+      return -EINVAL;
+    }
+
+  /* TBD: remove libc_getsockname code snippet
+   * once vppcom implements vppcom_session_getsockname */
+  rv = libc_getsockname (__fd, __addr, __len);
+  if (rv != 0)
+    {
+      rv = -errno;
+      return rv;
+    }
+
+  /* TBD: use the below code snippet when vppcom
+   * implements vppcom_session_getsockname */
+#if 0
+  vppcom_endpt_t ep;
+  ep.ip = (u8 *) & ((const struct sockaddr_in *) __addr)->sin_addr;
+  rv = vppcom_session_getsockname (vsock->sid, &ep);
+  if (rv == 0)
+    {
+      if (ep.vrf == VPPCOM_VRF_DEFAULT)
+	{
+	  __addr->sa_family = ep.is_ip4 == VPPCOM_IS_IP4 ? AF_INET : AF_INET6;
+	  switch (__addr->sa_family)
+	    {
+	    case AF_INET:
+	      ((struct sockaddr_in *) __addr)->sin_port = ep.port;
+	      *__len = sizeof (struct sockaddr_in);
+	      break;
+
+	    case AF_INET6:
+	      ((struct sockaddr_in6 *) __addr)->sin6_port = ep.port;
+	      *__len = sizeof (struct sockaddr_in6);
+	      break;
+
+	    default:
+	      break;
+	    }
+	}
+    }
+#endif
+
+  return rv;
+}
+
+int
+vcom_socket_connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  vppcom_endpt_t ep;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (p)
+    {
+      vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+
+      ep.vrf = VPPCOM_VRF_DEFAULT;
+      switch (__addr->sa_family)
+	{
+	case AF_INET:
+	  ep.is_ip4 = VPPCOM_IS_IP4;
+	  ep.ip =
+	    (uint8_t *) & ((const struct sockaddr_in *) __addr)->sin_addr;
+	  ep.port =
+	    (uint16_t) ((const struct sockaddr_in *) __addr)->sin_port;
+	  break;
+
+	case AF_INET6:
+	  ep.is_ip4 = VPPCOM_IS_IP6;
+	  ep.ip =
+	    (uint8_t *) & ((const struct sockaddr_in6 *) __addr)->sin6_addr;
+	  ep.port =
+	    (uint16_t) ((const struct sockaddr_in6 *) __addr)->sin6_port;
+	  break;
+
+	default:
+	  return -1;
+	  break;
+	}
+
+      rv = vppcom_session_connect (vsock->sid, &ep);
+    }
+  return rv;
+}
+
+int
+vppcom_session_getpeername (int sid, vppcom_endpt_t * ep)
+{
+  /* TBD: move it to vppcom */
+  return 0;
+}
+
+int
+vcom_socket_getpeername (int __fd, __SOCKADDR_ARG __addr,
+			 socklen_t * __restrict __len)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  if (!__addr || !__len)
+    return -EFAULT;
+
+  if (*__len < 0)
+    {
+      return -EINVAL;
+    }
+
+  /* DAW: hack to allow iperf3 to be happy w/ getpeername output */
+  {
+    uint8_t *a;
+    ((struct sockaddr_in *) __addr)->sin_family = AF_INET;
+    ((struct sockaddr_in *) __addr)->sin_port = 0x1000;
+    a = (uint8_t *) & ((struct sockaddr_in *) __addr)->sin_addr;
+    a[0] = 0x7f;
+    a[1] = 0x00;
+    a[2] = 0x00;
+    a[3] = 0x01;
+    *__len = sizeof (struct sockaddr_in);
+    return 0;
+  }
+
+  /* TBD: remove libc_getpeername code snippet
+   * once vppcom implements vppcom_session_getpeername */
+  rv = libc_getpeername (__fd, __addr, __len);
+  if (rv != 0)
+    {
+      rv = -errno;
+      return rv;
+    }
+
+  /* TBD: use the below code snippet when vppcom
+   * implements vppcom_session_getpeername */
+#if 0
+  vppcom_endpt_t ep;
+  ep.ip = (u8 *) & ((const struct sockaddr_in *) __addr)->sin_addr;
+  rv = vppcom_session_getpeername (vsock->sid, &ep);
+  if (rv == 0)
+    {
+      if (ep.vrf == VPPCOM_VRF_DEFAULT)
+	{
+	  __addr->sa_family = ep.is_ip4 == VPPCOM_IS_IP4 ? AF_INET : AF_INET6;
+	  switch (__addr->sa_family)
+	    {
+	    case AF_INET:
+	      ((struct sockaddr_in *) __addr)->sin_port = ep.port;
+	      *__len = sizeof (struct sockaddr_in);
+	      break;
+
+	    case AF_INET6:
+	      ((struct sockaddr_in6 *) __addr)->sin6_port = ep.port;
+	      *__len = sizeof (struct sockaddr_in6);
+	      break;
+
+	    default:
+	      break;
+	    }
+	}
+    }
+#endif
+
+  return rv;
+}
+
+ssize_t
+vcom_socket_send (int __fd, const void *__buf, size_t __n, int __flags)
+{
+  return vcom_socket_sendto (__fd, __buf, __n, __flags, NULL, 0);
+}
+
+ssize_t
+vcom_socket_recv (int __fd, void *__buf, size_t __n, int __flags)
+{
+  int rv = -1;
+  rv = vcom_socket_recvfrom (__fd, __buf, __n, __flags, NULL, 0);
+  return rv;
+}
+
+/*
+ * RETURN   1 if __fd is (SOCK_STREAM, SOCK_SEQPACKET),
+ * 0 otherwise
+ * */
+int
+vcom_socket_is_connection_mode_socket (int __fd)
+{
+  int rv = -1;
+  /* TBD define new vppcom api */
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  int type;
+  socklen_t optlen;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+
+  if (p)
+    {
+      vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+      if (vsock && vsock->type == SOCKET_TYPE_VPPCOM_BOUND)
+	{
+	  optlen = sizeof (type);
+	  rv = libc_getsockopt (__fd, SOL_SOCKET, SO_TYPE, &type, &optlen);
+	  if (rv != 0)
+	    {
+	      return 0;
+	    }
+	  /* get socket type */
+	  switch (type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK))
+	    {
+	    case SOCK_STREAM:
+	    case SOCK_SEQPACKET:
+	      return 1;
+	      break;
+
+	    default:
+	      return 0;
+	      break;
+	    }
+	}
+    }
+  return 0;
+}
+
+ssize_t
+vvppcom_session_sendto (int __sid, const void *__buf, size_t __n,
+			int __flags, __CONST_SOCKADDR_ARG __addr,
+			socklen_t __addr_len)
+{
+  int rv = -1;
+  /* TBD add new vpp api  */
+  /* TBD add flags parameter */
+  rv = vppcom_session_write (__sid, (void *) __buf, (int) __n);
+  return rv;
+}
+
+ssize_t
+vcom_socket_sendto (int __fd, const void *__buf, size_t __n,
+		    int __flags, __CONST_SOCKADDR_ARG __addr,
+		    socklen_t __addr_len)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  if (!__buf || __n < 0)
+    {
+      return -EINVAL;
+    }
+
+  if (vcom_socket_is_connection_mode_socket (__fd))
+    {
+      /* ignore __addr and _addr_len */
+      /* and EISCONN may be returned when they are not NULL and 0 */
+      if ((__addr != NULL) || (__addr_len != 0))
+	{
+	  return -EISCONN;
+	}
+    }
+  else
+    {
+      if (!__addr || __addr_len < 0)
+	{
+	  return -EDESTADDRREQ;
+	}
+      /* not a vppcom supported address family */
+      if ((__addr->sa_family != AF_INET) || (__addr->sa_family != AF_INET6))
+	{
+	  return -EINVAL;
+	}
+    }
+
+  rv = vvppcom_session_sendto (vsock->sid, (void *) __buf, (int) __n,
+			       __flags, __addr, __addr_len);
+  return rv;
+}
+
+/* TBD: move it to vppcom */
+static ssize_t
+vppcom_session_recvfrom (int __sid, void *__restrict __buf, size_t __n,
+			 int __flags, __SOCKADDR_ARG __addr,
+			 socklen_t * __restrict __addr_len)
+{
+  int rv = -1;
+
+  /* TBD add flags parameter */
+  rv = vppcom_session_read (__sid, __buf, __n);
+  return rv;
+}
+
+ssize_t
+vcom_socket_recvfrom (int __fd, void *__restrict __buf, size_t __n,
+		      int __flags, __SOCKADDR_ARG __addr,
+		      socklen_t * __restrict __addr_len)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  if (!__buf || __n < 0)
+    {
+      return -EINVAL;
+    }
+
+  if (__addr || __addr_len < 0)
+    {
+      return -EINVAL;
+    }
+
+  rv = vppcom_session_recvfrom (vsock->sid, __buf, __n,
+				__flags, __addr, __addr_len);
+  return rv;
+}
+
+/* TBD: move it to vppcom */
+static ssize_t
+vppcom_sendmsg (int __sid, const struct msghdr *__message, int __flags)
+{
+  int rv = -1;
+  /* rv = vppcom_session_write (__sid, (void *) __message->__buf,
+     (int)__n); */
+  return rv;
+}
+
+ssize_t
+vcom_socket_sendmsg (int __fd, const struct msghdr * __message, int __flags)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vcom_socket_is_connection_mode_socket (__fd))
+    {
+      /* ignore __addr and _addr_len */
+      /* and EISCONN may be returned when they are not NULL and 0 */
+      if ((__message->msg_name != NULL) || (__message->msg_namelen != 0))
+	{
+	  return -EISCONN;
+	}
+    }
+  else
+    {
+      /* TBD: validate __message->msg_name and __message->msg_namelen
+       * and return -EINVAL on validation error
+       * */
+      ;
+    }
+
+  rv = vppcom_sendmsg (vsock->sid, __message, __flags);
+
+  return rv;
+}
+
+#ifdef __USE_GNU
+int
+vcom_socket_sendmmsg (int __fd, struct mmsghdr *__vmessages,
+		      unsigned int __vlen, int __flags)
+{
+
+  /* TBD: define a new vppcom api */
+  return 0;
+}
+#endif
+
+/* TBD: move it to vppcom */
+static ssize_t
+vppcom_recvmsg (int __sid, struct msghdr *__message, int __flags)
+{
+  int rv = -1;
+  /* rv = vppcom_session_read (__sid, (void *) __message->__buf,
+     (int)__n); */
+  rv = -EOPNOTSUPP;
+  return rv;
+}
+
+ssize_t
+vcom_socket_recvmsg (int __fd, struct msghdr * __message, int __flags)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  if (!__message)
+    {
+      return -EINVAL;
+    }
+
+  /* validate __flags */
+
+  rv = vppcom_recvmsg (vsock->sid, __message, __flags);
+  return rv;
+}
+
+#ifdef __USE_GNU
+int
+vcom_socket_recvmmsg (int __fd, struct mmsghdr *__vmessages,
+		      unsigned int __vlen, int __flags,
+		      struct timespec *__tmo)
+{
+  /* TBD: define a new vppcom api */
+  return 0;
+}
+#endif
+
+/* TBD: move it to vppcom */
+static int
+vppcom_getsockopt (int __sid, int __level, int __optname,
+		   void *__restrict __optval, socklen_t * __restrict __optlen)
+{
+  /* 1. for socket level options that are NOT socket attributes
+   *    and that has corresponding vpp options get from vppcom */
+#if 0
+  return 0;
+#endif
+
+  /* 2. unhandled options */
+  return -ENOPROTOOPT;
+}
+
+int
+vcom_socket_getsockopt (int __fd, int __level, int __optname,
+			void *__restrict __optval,
+			socklen_t * __restrict __optlen)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  if (!__optval && !__optlen)
+    return -EFAULT;
+
+  if (*__optlen < 0)
+    {
+      return -EINVAL;
+    }
+
+  switch (__level)
+    {
+      /* handle options at socket level */
+    case SOL_SOCKET:
+      switch (__optname)
+	{
+/*
+ *  1. for socket level options that are socket attributes,
+ *     get from libc_getsockopt.
+ *  2. for socket level options that are NOT socket
+ *     attributes and that has corresponding vpp options
+ *     get from vppcom.
+ *  3. for socket level options unimplemented
+ *     return -ENOPROTOOPT */
+	case SO_DEBUG:
+	case SO_DONTROUTE:
+	case SO_BROADCAST:
+	case SO_SNDBUF:
+	case SO_RCVBUF:
+	case SO_REUSEADDR:
+	case SO_REUSEPORT:
+	case SO_KEEPALIVE:
+	case SO_TYPE:
+	case SO_PROTOCOL:
+	case SO_DOMAIN:
+	case SO_ERROR:
+	case SO_OOBINLINE:
+	case SO_NO_CHECK:
+	case SO_PRIORITY:
+	case SO_LINGER:
+	case SO_BSDCOMPAT:
+	case SO_TIMESTAMP:
+	case SO_TIMESTAMPNS:
+	case SO_TIMESTAMPING:
+	case SO_RCVTIMEO:
+	case SO_SNDTIMEO:
+	case SO_RCVLOWAT:
+	case SO_SNDLOWAT:
+	case SO_PASSCRED:
+	case SO_PEERCRED:
+	case SO_PEERNAME:
+	case SO_ACCEPTCONN:
+	case SO_PASSSEC:
+	case SO_PEERSEC:
+	case SO_MARK:
+	case SO_RXQ_OVFL:
+	case SO_WIFI_STATUS:
+	case SO_PEEK_OFF:
+	case SO_NOFCS:
+	case SO_BINDTODEVICE:
+	case SO_GET_FILTER:
+	case SO_LOCK_FILTER:
+	case SO_BPF_EXTENSIONS:
+	case SO_SELECT_ERR_QUEUE:
+#ifdef CONFIG_NET_RX_BUSY_POLL
+	case SO_BUSY_POLL:
+#endif
+	case SO_MAX_PACING_RATE:
+	case SO_INCOMING_CPU:
+	  rv = libc_getsockopt (__fd, __level, __optname, __optval, __optlen);
+	  if (rv != 0)
+	    {
+	      rv = -errno;
+	      return rv;
+	    }
+	  break;
+
+	default:
+	  /* We implement the SO_SNDLOWAT etc to not be settable
+	   * (1003.1g 7).
+	   */
+	  return -ENOPROTOOPT;
+	}
+
+      break;
+
+    default:
+      /* 1. handle options that are NOT socket level options,
+       *    but have corresponding vpp otions. */
+      rv = vppcom_getsockopt (vsock->sid, __level, __optname,
+			      __optval, __optlen);
+
+      return rv;
+#if 0
+      /* 2. unhandled options */
+      return -ENOPROTOOPT;
+#endif
+    }
+
+  return rv;
+}
+
+/* TBD: move it to vppcom */
+int
+vppcom_setsockopt (int __fd, int __level, int __optname,
+		   const void *__optval, socklen_t __optlen)
+{
+  /* 1. for socket level options that are NOT socket attributes
+   *    and that has corresponding vpp options set it from vppcom */
+#if 0
+  return 0;
+#endif
+
+  /* 2. unhandled options */
+  return -ENOPROTOOPT;
+}
+
+int
+vcom_socket_setsockopt (int __fd, int __level, int __optname,
+			const void *__optval, socklen_t __optlen)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (!p)
+    return -EBADF;
+
+  vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+  if (!vsock)
+    return -ENOTSOCK;
+
+  if (vsock->type != SOCKET_TYPE_VPPCOM_BOUND)
+    return -EINVAL;
+
+  /*
+   *      Options without arguments
+   */
+
+  if (__optname == SO_BINDTODEVICE)
+    {
+      rv = libc_setsockopt (__fd, __level, __optname, __optval, __optlen);
+      if (rv != 0)
+	{
+	  rv = -errno;
+	}
+      return rv;
+    }
+
+  if (!__optval)
+    return -EFAULT;
+
+  if ((__optlen < 0) || (__optlen < sizeof (int)))
+    return -EINVAL;
+
+  switch (__level)
+    {
+      /* handle options at socket level */
+    case SOL_SOCKET:
+      switch (__optname)
+	{
+	  /*
+	   * 1. for socket level options that are socket attributes,
+	   *    set it from libc_getsockopt
+	   * 2. for socket level options that are NOT socket
+	   *    attributes and that has corresponding vpp options
+	   *    set it from vppcom
+	   * 3. for socket level options unimplemented
+	   *    return -ENOPROTOOPT */
+	case SO_DEBUG:
+	case SO_DONTROUTE:
+	case SO_BROADCAST:
+	case SO_SNDBUF:
+	case SO_RCVBUF:
+	case SO_REUSEADDR:
+	case SO_REUSEPORT:
+	case SO_KEEPALIVE:
+	case SO_TYPE:
+	case SO_PROTOCOL:
+	case SO_DOMAIN:
+	case SO_ERROR:
+	case SO_OOBINLINE:
+	case SO_NO_CHECK:
+	case SO_PRIORITY:
+	case SO_LINGER:
+	case SO_BSDCOMPAT:
+	case SO_TIMESTAMP:
+	case SO_TIMESTAMPNS:
+	case SO_TIMESTAMPING:
+	case SO_RCVTIMEO:
+	case SO_SNDTIMEO:
+	case SO_RCVLOWAT:
+	case SO_SNDLOWAT:
+	case SO_PASSCRED:
+	case SO_PEERCRED:
+	case SO_PEERNAME:
+	case SO_ACCEPTCONN:
+	case SO_PASSSEC:
+	case SO_PEERSEC:
+	case SO_MARK:
+	case SO_RXQ_OVFL:
+	case SO_WIFI_STATUS:
+	case SO_PEEK_OFF:
+	case SO_NOFCS:
+	  /*
+	   * SO_BINDTODEVICE already handled as
+	   * "Options without arguments" */
+	  /* case SO_BINDTODEVICE: */
+	case SO_GET_FILTER:
+	case SO_LOCK_FILTER:
+	case SO_BPF_EXTENSIONS:
+	case SO_SELECT_ERR_QUEUE:
+#ifdef CONFIG_NET_RX_BUSY_POLL
+	case SO_BUSY_POLL:
+#endif
+	case SO_MAX_PACING_RATE:
+	case SO_INCOMING_CPU:
+	  rv = libc_setsockopt (__fd, __level, __optname, __optval, __optlen);
+	  if (rv != 0)
+	    {
+	      rv = -errno;
+	      return rv;
+	    }
+	  break;
+
+	default:
+	  /* We implement the SO_SNDLOWAT etc to not be settable
+	   * (1003.1g 7).
+	   */
+	  return -ENOPROTOOPT;
+	}
+
+      break;
+
+    default:
+      /* 1. handle options that are NOT socket level options,
+       *    but have corresponding vpp otions. */
+      rv = vppcom_setsockopt (vsock->sid, __level, __optname,
+			      __optval, __optlen);
+      return rv;
+#if 0
+      /* 2. unhandled options */
+      return -ENOPROTOOPT;
+#endif
+    }
+
+  return rv;
+}
+
+int
+vcom_socket_listen (int __fd, int __n)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (p)
+    {
+      vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+
+      /* TBD vppcom to accept __n parameter */
+      rv = vppcom_session_listen (vsock->sid, __n);
+    }
+
+  return rv;
+}
+
+static int
+vcom_socket_connected_socket (int __fd, int __sid,
+			      int *__domain,
+			      int *__type, int *__protocol, int flags)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  vcom_socket_t *vsock;
+
+  i32 fd;
+  i32 sockidx;
+
+  socklen_t optlen;
+
+  optlen = sizeof (*__domain);
+  rv = libc_getsockopt (__fd, SOL_SOCKET, SO_DOMAIN, __domain, &optlen);
+  if (rv != 0)
+    {
+      rv = -errno;
+      goto out;
+    }
+
+  optlen = sizeof (*__type);
+  rv = libc_getsockopt (__fd, SOL_SOCKET, SO_TYPE, __type, &optlen);
+  if (rv != 0)
+    {
+      rv = -errno;
+      goto out;
+    }
+
+  optlen = sizeof (*__protocol);
+  rv = libc_getsockopt (__fd, SOL_SOCKET, SO_PROTOCOL, __protocol, &optlen);
+  if (rv != 0)
+    {
+      rv = -errno;
+      goto out;
+    }
+
+  fd = vcom_socket_open_socket (*__domain, *__type | flags, *__protocol);
+  if (fd < 0)
+    {
+      rv = fd;
+      goto out;
+    }
+
+  pool_get (vsm->vsockets, vsock);
+  vsocket_init (vsock);
+
+  sockidx = vsock - vsm->vsockets;
+  hash_set (vsm->sockidx_by_fd, fd, sockidx);
+
+  vsocket_set (vsock, fd, __sid, SOCKET_TYPE_VPPCOM_BOUND);
+  return fd;
+
+out:
+  return rv;
+}
+
+/* If flag is 0, then accept4() is the same as accept().
+ * SOCK_NONBLOCK and SOCK_CLOEXEC can be bitwise ORed in flags
+ */
+static int
+vcom_socket_accept_flags (int __fd, __SOCKADDR_ARG __addr,
+			  socklen_t * __restrict __addr_len, int flags)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  int fd;
+  int sid;
+  int domain;
+  int type;
+  int protocol;
+
+  uint8_t addr8[sizeof (struct in6_addr)];
+  vppcom_endpt_t ep;
+
+  ep.ip = addr8;
+
+  /* validate flags */
+
+  /*
+   * for documentation
+   *  switch (flags)
+   *   {
+   *   case 0:
+   *   case SOCK_NONBLOCK:
+   *   case SOCK_CLOEXEC:
+   *   case SOCK_NONBLOCK | SOCK_CLOEXEC:
+   *     break;
+   *
+   *   default:
+   *     return -1;
+   *   }
+   */
+  /* flags can be 0 or can be bitwise OR
+   * of any of SOCK_NONBLOCK and SOCK_CLOEXEC */
+
+  if (!(!flags || (flags & (SOCK_NONBLOCK | SOCK_CLOEXEC))))
+    {
+      /* TBD: return proper error code */
+      return -1;
+    }
+
+  /* TBD: return proper error code */
+
+  if (!vcom_socket_is_connection_mode_socket (__fd))
+    {
+      return -EOPNOTSUPP;
+    }
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (p)
+    {
+      vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+
+
+      rv = vcom_fcntl (vsock->fd, F_GETFL, 0);
+      if (rv < 0)
+	{
+	  return rv;
+	}
+
+      /* is blocking */
+      if (!(rv & O_NONBLOCK))
+	{
+	  /* socket is not marked as nonblocking
+	   * and no pending connections are present
+	   * on the queue, accept () blocks the caller
+	   * until a connection is present.
+	   */
+	  rv = vppcom_session_accept (vsock->sid, &ep,
+				      -1.0 /* wait forever */ );
+	}
+      else
+	{
+	  /* The file descriptor refers to a socket and has been
+	   * marked nonblocking(O_NONBLOCK) and the accept would
+	   * block.
+	   * */
+	  /* is non blocking */
+	  rv = vppcom_session_accept (vsock->sid, &ep, 0);
+	  /* If the socket is marked nonblocking and
+	   * no pending connections are present on the
+	   * queue, accept fails with the error
+	   * EAGAIN or EWOULDBLOCK
+	   */
+	  if (rv == VPPCOM_ETIMEDOUT)
+	    {
+	      rv = VPPCOM_EAGAIN;
+	    }
+	}
+      if (rv < 0)
+	{
+	  return rv;
+	}
+
+      sid = rv;
+
+      /* create a new connected socket resource and set flags
+       * on the new file descriptor.
+       * update vsockets and sockidx_by_fd table
+       * */
+      fd = vcom_socket_connected_socket (__fd, sid,
+					 &domain, &type, &protocol, flags);
+      if (fd < 0)
+	{
+	  return fd;
+	}
+
+      rv = fd;
+
+      /* TBD populate __addr and __addr_len */
+      /* TBD: The returned address is truncated if the buffer
+       * provided is too small, in this case, __addr_len will
+       * return a value greater than was supplied to the call.*/
+      if (__addr)
+	{
+	  if (ep.is_cut_thru)
+	    {
+	      /* TBD populate __addr and __addr_len */
+	      switch (domain)
+		{
+		case AF_INET:
+		  ((struct sockaddr_in *) __addr)->sin_family = AF_INET;
+		  ((struct sockaddr_in *) __addr)->sin_port = ep.port;
+		  memcpy (&((struct sockaddr_in *) __addr)->sin_addr,
+			  addr8, sizeof (struct in_addr));
+		  /* TBD: populate __addr_len */
+		  if (__addr_len)
+		    {
+		      *__addr_len = sizeof (struct sockaddr_in);
+		    }
+		  break;
+
+		case AF_INET6:
+		  ((struct sockaddr_in6 *) __addr)->sin6_family = AF_INET6;
+		  ((struct sockaddr_in6 *) __addr)->sin6_port = ep.port;
+		  memcpy (((struct sockaddr_in6 *) __addr)->sin6_addr.
+			  __in6_u.__u6_addr8, addr8,
+			  sizeof (struct in6_addr));
+		  /* TBD: populate __addr_len */
+		  if (__addr_len)
+		    {
+		      *__addr_len = sizeof (struct sockaddr_in6);
+		    }
+		  break;
+
+		default:
+		  return -EAFNOSUPPORT;
+		}
+	    }
+	  else
+	    {
+	      switch (ep.is_ip4)
+		{
+		case VPPCOM_IS_IP4:
+		  ((struct sockaddr_in *) __addr)->sin_family = AF_INET;
+		  ((struct sockaddr_in *) __addr)->sin_port = ep.port;
+		  memcpy (&((struct sockaddr_in *) __addr)->sin_addr,
+			  addr8, sizeof (struct in_addr));
+		  /* TBD: populate __addr_len */
+		  if (__addr_len)
+		    {
+		      *__addr_len = sizeof (struct sockaddr_in);
+		    }
+		  break;
+
+		case VPPCOM_IS_IP6:
+		  ((struct sockaddr_in6 *) __addr)->sin6_family = AF_INET6;
+		  ((struct sockaddr_in6 *) __addr)->sin6_port = ep.port;
+		  memcpy (((struct sockaddr_in6 *) __addr)->sin6_addr.
+			  __in6_u.__u6_addr8, addr8,
+			  sizeof (struct in6_addr));
+		  /* TBD: populate __addr_len */
+		  if (__addr_len)
+		    {
+		      *__addr_len = sizeof (struct sockaddr_in6);
+		    }
+		  break;
+
+		default:
+		  return -EAFNOSUPPORT;
+		}
+	    }
+	}
+      else
+	{
+	  /* when __addr is NULL, nothing is filled in,
+	   * in this case, __addr_len is not used,
+	   * and should also be null
+	   * */
+	  if (__addr_len)
+	    {
+	      /* TBD: return proper error code */
+	      return -1;
+	    }
+	}
+    }
+
+  return rv;
+}
+
+int
+vcom_socket_accept (int __fd, __SOCKADDR_ARG __addr,
+		    socklen_t * __restrict __addr_len)
+{
+  /* set flags to 0 for accept() */
+  return vcom_socket_accept_flags (__fd, __addr, __addr_len, 0);
+}
+
+#ifdef __USE_GNU
+int
+vcom_socket_accept4 (int __fd, __SOCKADDR_ARG __addr,
+		     socklen_t * __restrict __addr_len, int __flags)
+{
+  /*  SOCK_NONBLOCK and SOCK_CLOEXEC can be bitwise ORed in flags */
+  return vcom_socket_accept_flags (__fd, __addr, __addr_len, __flags);
+}
+#endif
+
+/* TBD: move it to vppcom */
+int
+vppcom_session_shutdown (int __fd, int __how)
+{
+  return 0;
+}
+
+int
+vcom_socket_shutdown (int __fd, int __how)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  uword *p;
+  vcom_socket_t *vsock;
+
+  p = hash_get (vsm->sockidx_by_fd, __fd);
+  if (p)
+    {
+      vsock = pool_elt_at_index (vsm->vsockets, p[0]);
+      switch (__how)
+	{
+	case SHUT_RD:
+	case SHUT_WR:
+	case SHUT_RDWR:
+	  rv = vppcom_session_shutdown (vsock->sid, __how);
+	  return rv;
+	  break;
+
+	default:
+	  return -EINVAL;
+	  break;
+	}
+    }
+
+  return rv;
+}
+
+int
+vcom_socket_epoll_create1 (int __flags)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  vcom_epoll_t *vepoll;
+
+  i32 epfd;
+  i32 vep_idx;
+  i32 epollidx;
+
+  epfd = vcom_socket_open_epoll (__flags);
+  if (epfd < 0)
+    {
+      rv = epfd;
+      goto out;
+    }
+
+  vep_idx = vppcom_epoll_create ();
+  if (vep_idx < 0)
+    {
+      rv = vep_idx;
+      goto out_close_epoll;
+    }
+
+  pool_get (vsm->vepolls, vepoll);
+  vepoll_init (vepoll);
+
+  epollidx = vepoll - vsm->vepolls;
+  hash_set (vsm->epollidx_by_epfd, epfd, epollidx);
+
+  vepoll_set (vepoll, epfd, vep_idx, EPOLL_TYPE_VPPCOM_BOUND, __flags, 0, 0);
+
+  return epfd;
+
+out_close_epoll:
+  vcom_socket_close_epoll (epfd);
+out:
+  return rv;
+}
+
+/*
+ * PRE: vppcom_epoll_ctl() is successful
+ * free_vepitem_on_del : 0 - no_pool_put, 1 - pool_put
+ */
+int
+vcom_socket_ctl_vepitem (int __epfd, int __op, int __fd,
+			 struct epoll_event *__event,
+			 i32 vep_idx, vcom_epoll_t * vepoll,
+			 i32 vfd_id, void *vfd, vcom_fd_type_t type,
+			 int free_vepitem_on_del)
+{
+  int rv = -1;
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  vcom_epitem_t *vepitem;
+
+  vcom_epitem_key_t epfdfd = {.epfd = __epfd,.fd = __fd };
+  uword *p;
+  i32 vepitemidx;
+
+  i32 *vepitemidxs = 0;
+
+  struct epoll_event revent = {.events = 0,.data.fd = INVALID_FD };
+
+  i32 vec_idx;
+
+  /* perform control operations on the epoll instance */
+  switch (__op)
+    {
+    case EPOLL_CTL_ADD:
+      /*
+       * supplied file descriptor is already
+       * registered with this epoll instance
+       * */
+      /* vepitem exists */
+      p = hash_get (vsm->epitemidx_by_epfdfd, epfdfd.key);
+      if (p)
+	{
+	  rv = -EEXIST;
+	  goto out;
+	}
+
+      /* add a new vepitem */
+      pool_get (vsm->vepitems, vepitem);
+      vepitem_init (vepitem);
+
+      vepitemidx = vepitem - vsm->vepitems;
+      hash_set (vsm->epitemidx_by_epfdfd, epfdfd.key, vepitemidx);
+      vepitem_set (vepitem, __epfd, __fd, __fd, __fd, type, *__event, revent);
+
+      /* update epitemidxs */
+      /* by_epfd */
+      p = hash_get (vsm->epitemidxs_by_epfd, __epfd);
+      if (!p)			/*  not exist */
+	{
+	  vepitemidxs = 0;
+	  vec_add1 (vepitemidxs, vepitemidx);
+	  hash_set (vsm->epitemidxs_by_epfd, __epfd, vepitemidxs);
+	}
+      else			/*  exists */
+	{
+	  vepitemidxs = *(i32 **) p;
+	  vec_add1 (vepitemidxs, vepitemidx);
+	  hash_set3 (vsm->epitemidxs_by_epfd, __epfd, vepitemidxs, 0);
+	}
+      /* update epitemidxs */
+      /* by_fd */
+      p = hash_get (vsm->epitemidxs_by_fd, __fd);
+      if (!p)			/*  not exist */
+	{
+	  vepitemidxs = 0;
+	  vec_add1 (vepitemidxs, vepitemidx);
+	  hash_set (vsm->epitemidxs_by_fd, __fd, vepitemidxs);
+	}
+      else			/*  exists */
+	{
+	  vepitemidxs = *(i32 **) p;
+	  vec_add1 (vepitemidxs, vepitemidx);
+	  hash_set3 (vsm->epitemidxs_by_fd, __fd, vepitemidxs, 0);
+	}
+
+      /* increment vepoll fd count by 1 */
+      vepoll->count += 1;
+
+      rv = 0;
+      goto out;
+      break;
+
+    case EPOLL_CTL_MOD:
+      /*
+       * supplied file descriptor is not
+       * registered with this epoll instance
+       * */
+      /* vepitem not exist */
+      p = hash_get (vsm->epitemidx_by_epfdfd, epfdfd.key);
+      if (!p)
+	{
+	  rv = -ENOENT;
+	  goto out;
+	}
+      vepitem = pool_elt_at_index (vsm->vepitems, p[0]);
+      if (vepitem)
+	{
+	  vepitem->event = *__event;
+	  vepitem->revent = revent;
+	}
+
+      rv = 0;
+      goto out;
+      break;
+
+    case EPOLL_CTL_DEL:
+      /*
+       * supplied file descriptor is not
+       * registered with this epoll instance
+       * */
+      /* vepitem not exist */
+      p = hash_get (vsm->epitemidx_by_epfdfd, epfdfd.key);
+      if (!p)
+	{
+	  rv = -ENOENT;
+	  goto out;
+	}
+      vepitemidx = *(i32 *) p;
+      hash_unset (vsm->epitemidx_by_epfdfd, epfdfd.key);
+
+      /* update epitemidxs */
+      /* by_epfd */
+      p = hash_get (vsm->epitemidxs_by_epfd, __epfd);
+      if (!p)			/*  not exist */
+	{
+	  rv = -ENOENT;
+	  goto out;
+	}
+      else			/*  exists */
+	{
+	  vepitemidxs = *(i32 **) p;
+	  vec_idx = vec_search (vepitemidxs, vepitemidx);
+	  if (vec_idx != ~0)
+	    {
+	      vec_del1 (vepitemidxs, vec_idx);
+	      if (!vec_len (vepitemidxs))
+		{
+		  vec_free (vepitemidxs);
+		  hash_unset (vsm->epitemidxs_by_epfd, __epfd);
+		}
+	    }
+	}
+
+      /* update epitemidxs */
+      /* by_fd */
+      p = hash_get (vsm->epitemidxs_by_fd, __fd);
+      if (!p)			/*  not exist */
+	{
+	  rv = -ENOENT;
+	  goto out;
+	}
+      else			/*  exists */
+	{
+	  vepitemidxs = *(i32 **) p;
+	  vec_idx = vec_search (vepitemidxs, vepitemidx);
+	  if (vec_idx != ~0)
+	    {
+	      vec_del1 (vepitemidxs, vec_idx);
+	      if (!vec_len (vepitemidxs))
+		{
+		  vec_free (vepitemidxs);
+		  hash_unset (vsm->epitemidxs_by_fd, __fd);
+		}
+	    }
+	}
+
+      /* pool put vepitem */
+      vepitem = pool_elt_at_index (vsm->vepitems, vepitemidx);
+      if (free_vepitem_on_del)
+	{
+	  if (!vepitem)
+	    {
+	      rv = -ENOENT;
+	      goto out;
+	    }
+	  vepitem_init (vepitem);
+	  pool_put (vsm->vepitems, vepitem);
+	}
+      else
+	{
+	  if (!vepitem)
+	    {
+	      vepitem_init (vepitem);
+	    }
+	}
+
+      /* decrement vepoll fd count by 1 */
+      vepoll->count -= 1;
+
+      rv = 0;
+      goto out;
+      break;
+
+    default:
+      rv = -EINVAL;
+      goto out;
+      break;
+    }
+
+out:
+  return rv;
+}
+
+/*
+ * PRE: 00. null pointer check on __event
+ *      01. all other parameters are validated
+ */
+
+static int
+vcom_socket_epoll_ctl_internal (int __epfd, int __op, int __fd,
+				struct epoll_event *__event,
+				int free_vepitem_on_del)
+{
+  int rv = -1;
+
+  /* vcom_socket_main_t *vsm = &vcom_socket_main; */
+  vcom_epoll_t *vepoll;
+
+  /*__fd could could be vcom socket or vcom epoll or kernel fd */
+  void *vfd;
+  vcom_epoll_t *vfd_vepoll;
+  vcom_socket_t *vfd_vsock;
+
+  i32 vep_idx;
+  i32 vfd_id;
+
+  vcom_fd_type_t type = FD_TYPE_INVALID;
+
+  /* validate __event */
+
+  /* get vep_idx and vepoll */
+  vep_idx = vcom_socket_get_vep_idx_and_vepoll (__epfd, &vepoll);
+  if (vep_idx == INVALID_VEP_IDX)
+    {
+      return -EBADF;
+    }
+
+  /* get vcom fd type, vfd_id and vfd */
+  vfd_id = vcom_socket_get_sid_and_vsock (__fd, &vfd_vsock);
+  if (vfd_id != INVALID_SESSION_ID)
+    {
+      type = FD_TYPE_VCOM_SOCKET;
+      vfd = vfd_vsock;
+    }
+  else if ((vfd_id = vcom_socket_get_vep_idx_and_vepoll (__fd, &vfd_vepoll))
+	   != INVALID_VEP_IDX)
+    {
+      type = FD_TYPE_EPOLL;
+      vfd = vfd_vepoll;
+    }
+  else
+    {
+      /* FD_TYPE_KERNEL not supported by epoll instance */
+      type = FD_TYPE_INVALID;
+      return -EBADF;
+    }
+
+
+  /* vepoll and vsock are now valid */
+  rv = vppcom_epoll_ctl (vep_idx, __op, vfd_id, __event);
+  if (rv < 0)
+    {
+      return rv;
+    }
+
+  rv = vcom_socket_ctl_vepitem (__epfd, __op, __fd,
+				__event,
+				vep_idx, vepoll,
+				vfd_id, vfd, type, free_vepitem_on_del);
+  return rv;
+}
+
+int
+vcom_socket_epoll_ctl (int __epfd, int __op, int __fd,
+		       struct epoll_event *__event)
+{
+  int rv = -1;
+
+  rv = vcom_socket_epoll_ctl_internal (__epfd, __op, __fd, __event, 1);
+  return rv;
+}
+
+static int
+vcom_socket_epoll_ctl1 (int __epfd, int __op, int __fd,
+			struct epoll_event *__event)
+{
+  int rv = -1;
+
+  rv = vcom_socket_epoll_ctl_internal (__epfd, __op, __fd, __event, 0);
+  return rv;
+}
+
+int
+vcom_socket_epoll_pwait (int __epfd, struct epoll_event *__events,
+			 int __maxevents, int __timeout,
+			 const __sigset_t * __ss)
+{
+  int rv = -EBADF;
+
+  /* in seconds eg. 3.123456789 seconds */
+  double time_to_wait = (double) 0;
+
+  i32 vep_idx;
+
+  /* validate __event */
+  if (!__events)
+    {
+      rv = -EFAULT;
+      goto out;
+    }
+
+  /* validate __timeout */
+  if (__timeout > 0)
+    {
+      time_to_wait = (double) __timeout / (double) 1000;
+    }
+  else if (__timeout == 0)
+    {
+      time_to_wait = (double) 0;
+    }
+  else if (__timeout == -1)
+    {
+      time_to_wait = ~0;
+    }
+  else
+    {
+      rv = -EBADF;
+      goto out;
+    }
+
+  /* get vep_idx */
+  vep_idx = vcom_socket_get_vep_idx (__epfd);
+  if (vep_idx != INVALID_VEP_IDX)
+    {
+      rv = vppcom_epoll_wait (vep_idx, __events, __maxevents, time_to_wait);
+    }
+out:
+  return rv;
+}
+
+int
+vcom_socket_main_init (void)
+{
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+
+  if (VCOM_DEBUG > 0)
+    printf ("vcom_socket_main_init\n");
+
+  if (!vsm->init)
+    {
+      /* TBD: define FD_MAXSIZE and use it here */
+      pool_alloc (vsm->vsockets, FD_SETSIZE);
+      vsm->sockidx_by_fd = hash_create (0, sizeof (i32));
+
+      pool_alloc (vsm->vepolls, FD_SETSIZE);
+      vsm->epollidx_by_epfd = hash_create (0, sizeof (i32));
+
+      pool_alloc (vsm->vepitems, FD_SETSIZE);
+      vsm->epitemidx_by_epfdfd = hash_create (0, sizeof (i32));
+
+      vsm->epitemidxs_by_epfd = hash_create (0, sizeof (i32 *));
+      vsm->epitemidxs_by_fd = hash_create (0, sizeof (i32 *));
+
+      vsm->init = 1;
+    }
+
+  return 0;
+}
+
+
+void
+vcom_socket_main_show (void)
+{
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  vcom_socket_t *vsock;
+
+  vcom_epoll_t *vepoll;
+
+  vcom_epitem_t *vepitem;
+
+  i32 epfd;
+  i32 fd;
+  i32 *vepitemidxs, *vepitemidxs_var;
+
+  if (vsm->init)
+    {
+      /* from active list of vsockets show vsock */
+
+      /* *INDENT-OFF* */
+      pool_foreach (vsock, vsm->vsockets,
+        ({
+          printf(
+                 "fd='%04d', sid='%08x',type='%-30s'\n",
+                 vsock->fd, vsock->sid,
+                 vcom_socket_type_str (vsock->type));
+        }));
+      /* *INDENT-ON* */
+
+      /* from active list of vepolls, show vepoll */
+
+      /* *INDENT-OFF* */
+      pool_foreach (vepoll, vsm->vepolls,
+        ({
+          printf(
+                 "epfd='%04d', vep_idx='%08x', "
+                 "type='%-30s', "
+                 "flags='%d', count='%d', close='%d'\n",
+                 vepoll->epfd, vepoll->vep_idx,
+                 vcom_socket_epoll_type_str (vepoll->type),
+                 vepoll->flags, vepoll->count, vepoll->close);
+        }));
+      /* *INDENT-ON* */
+
+      /* from active list of vepitems, show vepitem */
+
+      /* *INDENT-OFF* */
+      pool_foreach (vepitem, vsm->vepitems,
+        ({
+          printf(
+                 "epfd='%04d', fd='%04d', "
+                 "next_fd='%04d', prev_fd='%04d', "
+                 "type='%-30s', "
+                 "events='%04x', revents='%04x'\n",
+                 vepitem->epfd, vepitem->fd,
+                 vepitem->next_fd, vepitem->prev_fd,
+                 vcom_socket_vcom_fd_type_str (vepitem->type),
+                 vepitem->event.events, vepitem->revent.events);
+        }));
+
+      /* *INDENT-ON* */
+
+      /* show epitemidxs for epfd */
+      /* *INDENT-OFF* */
+      hash_foreach (epfd, vepitemidxs,
+                    vsm->epitemidxs_by_epfd,
+      ({
+        printf("\n[ '%04d': ", epfd);
+        vec_foreach (vepitemidxs_var,vepitemidxs)
+        {
+          printf("'%04d' ", (int)vepitemidxs_var[0]);
+        }
+        printf("]\n");
+      }));
+      /* *INDENT-ON* */
+
+      /* show epitemidxs for fd */
+      /* *INDENT-OFF* */
+      hash_foreach (fd, vepitemidxs,
+                    vsm->epitemidxs_by_fd,
+      ({
+        printf("\n{ '%04d': ", fd);
+        vec_foreach (vepitemidxs_var,vepitemidxs)
+        {
+          printf("'%04d' ", (int)vepitemidxs_var[0]);
+        }
+        printf("}\n");
+      }));
+      /* *INDENT-ON* */
+
+    }
+}
+
+void
+vcom_socket_main_destroy (void)
+{
+  vcom_socket_main_t *vsm = &vcom_socket_main;
+  vcom_socket_t *vsock;
+
+  vcom_epoll_t *vepoll;
+
+  vcom_epitem_t *vepitem;
+
+  i32 epfd;
+  i32 fd;
+  i32 *vepitemidxs;
+
+
+  if (VCOM_DEBUG > 0)
+    printf ("vcom_socket_main_destroy\n");
+
+  if (vsm->init)
+    {
+
+      /*
+       * from active list of vepitems,
+       * remove all "vepitem" elements from the pool in a safe way
+       * */
+
+      /* *INDENT-OFF* */
+      pool_flush (vepitem, vsm->vepitems,
+        ({
+          if (vepitem->type == FD_TYPE_EPOLL || FD_TYPE_VCOM_SOCKET)
+          {
+              vcom_socket_epoll_ctl1 (vepitem->epfd, EPOLL_CTL_DEL,
+                                     vepitem->fd, NULL);
+             vepitem_init (vepitem);
+          }
+        }));
+      /* *INDENT-ON* */
+
+      pool_free (vsm->vepitems);
+      hash_free (vsm->epitemidx_by_epfdfd);
+
+      /* free vepitemidxs for each epfd */
+      /* *INDENT-OFF* */
+      hash_foreach (epfd, vepitemidxs,
+                    vsm->epitemidxs_by_epfd,
+      ({
+        vec_free (vepitemidxs);
+      }));
+      /* *INDENT-ON* */
+      hash_free (vsm->epitemidxs_by_epfd);
+
+      /* free vepitemidxs for each fd */
+      /* *INDENT-OFF* */
+      hash_foreach (fd, vepitemidxs,
+                    vsm->epitemidxs_by_fd,
+      ({
+        vec_free (vepitemidxs);
+      }));
+      /* *INDENT-ON* */
+      hash_free (vsm->epitemidxs_by_fd);
+
+
+      /*
+       * from active list of vsockets,
+       * close socket and vppcom session
+       * */
+
+      /* *INDENT-OFF* */
+      pool_foreach (vsock, vsm->vsockets,
+        ({
+          if (vsock->type == SOCKET_TYPE_VPPCOM_BOUND)
+            {
+              vppcom_session_close (vsock->sid);
+              vcom_socket_close_socket (vsock->fd);
+              vsocket_init (vsock);
+            }
+        }));
+      /* *INDENT-ON* */
+
+      /*
+       * return vsocket element to the pool
+       * */
+
+      /* *INDENT-OFF* */
+      pool_flush (vsock, vsm->vsockets,
+        ({
+          // vsocket_init(vsock);
+          ;
+        }));
+      /* *INDENT-ON* */
+
+      pool_free (vsm->vsockets);
+      hash_free (vsm->sockidx_by_fd);
+
+      /*
+       * from active list of vepolls,
+       * close epoll and vppcom_epoll
+       * */
+
+      /* *INDENT-OFF* */
+      pool_foreach (vepoll, vsm->vepolls,
+        ({
+          if (vepoll->type == EPOLL_TYPE_VPPCOM_BOUND)
+            {
+              vppcom_session_close (vepoll->vep_idx);
+              vcom_socket_close_epoll (vepoll->epfd); /* TBD: */
+              vepoll_init (vepoll);
+            }
+        }));
+      /* *INDENT-ON* */
+
+      /*
+       * return vepoll element to the pool
+       * */
+
+      /* *INDENT-OFF* */
+      pool_flush (vepoll, vsm->vepolls,
+        ({
+          // vepoll_init(vepoll);
+          ;
+        }));
+      /* *INDENT-ON* */
+
+      pool_free (vsm->vepolls);
+      hash_free (vsm->epollidx_by_epfd);
+
+      vsm->init = 0;
+    }
+}
+
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.h b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.h
new file mode 100644
index 0000000..7170e20
--- /dev/null
+++ b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.h
@@ -0,0 +1,457 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef included_vcom_socket_h
+#define included_vcom_socket_h
+
+#include <string.h>
+
+#include <libvcl-ldpreload/vcom_glibc_socket.h>
+#include <vppinfra/types.h>
+
+#define INVALID_SESSION_ID (~0)
+#define INVALID_FD (~0)
+
+#define INVALID_VEP_IDX INVALID_SESSION_ID
+#define INVALID_EPFD INVALID_FD
+
+typedef enum
+{
+  SOCKET_TYPE_UNBOUND = 0,
+  SOCKET_TYPE_KERNEL_BOUND,
+  SOCKET_TYPE_VPPCOM_BOUND
+} vcom_socket_type_t;
+
+typedef enum
+{
+  EPOLL_TYPE_UNBOUND = 0,
+  EPOLL_TYPE_KERNEL_BOUND,
+  EPOLL_TYPE_VPPCOM_BOUND
+} vcom_epoll_type_t;
+
+typedef enum
+{
+  FD_TYPE_INVALID = 0,
+  FD_TYPE_KERNEL,
+  FD_TYPE_EPOLL,
+  FD_TYPE_VCOM_SOCKET,
+  /* add new types here */
+  /* FD_TYPE_MAX should be the last entry */
+  FD_TYPE_MAX
+} vcom_fd_type_t;
+
+typedef struct
+{
+  /* file descriptor -
+   * fd 0, 1, 2 have special meaning and are reserved,
+   * -1 denote invalid fd */
+  i32 fd;
+
+  /* session id - -1 denote invalid sid */
+  i32 sid;
+
+  /* socket type */
+  vcom_socket_type_t type;
+
+  /* vcom socket attributes here */
+
+} vcom_socket_t;
+
+typedef struct
+{
+  /* epoll file descriptor -
+   * epfd 0, 1, 2 have special meaning and are reserved,
+   * -1 denote invalid epfd */
+  i32 epfd;
+
+  /* vep idx - -1 denote invalid vep_idx */
+  i32 vep_idx;
+
+  /* epoll type */
+  vcom_epoll_type_t type;
+
+  /* flags - 0 or EPOLL_CLOEXEC */
+  i32 flags;
+
+  /* vcom epoll attributes here */
+
+  /*
+   * 00. count of file descriptors currently registered
+   *     on this epoll instance.
+   * 01. number of file descriptors in the epoll set.
+   * 02. EPOLL_CTL_ADD, EPOLL_CTL_MOD, EPOLL_CTL_DEL
+   *     update the count.
+   * 03. cached for frequent access.
+   * */
+  i32 count;
+
+  /* close( ) called on this epoll instance */
+  /* 0 - close ( ) not called, 1 - close( ) called. */
+  u32 close;
+
+} vcom_epoll_t;
+
+typedef struct
+{
+  /* "container" of this item */
+  i32 epfd;
+
+  /* fd - file descriptor information this item refers to */
+  i32 fd;
+  /* next and prev fd in the "epoll set" of epfd */
+  i32 next_fd;
+  i32 prev_fd;
+
+  /* vcom fd type */
+  vcom_fd_type_t type;
+
+  /* interested events and the source fd */
+  struct epoll_event event;
+
+  /* ready events and the source fd */
+  struct epoll_event revent;
+
+  /* epitem attributes here */
+
+} vcom_epitem_t;
+
+typedef union vcom_epitem_key
+{
+  struct
+  {
+    i32 fd;
+    i32 epfd;
+  };
+  i64 key;
+} __EPOLL_PACKED vcom_epitem_key_t;
+
+static inline char *
+vcom_socket_type_str (vcom_socket_type_t t)
+{
+  switch (t)
+    {
+    case SOCKET_TYPE_UNBOUND:
+      return "SOCKET_TYPE_UNBOUND";
+
+    case SOCKET_TYPE_KERNEL_BOUND:
+      return "SOCKET_TYPE_KERNEL_BOUND";
+
+    case SOCKET_TYPE_VPPCOM_BOUND:
+      return "SOCKET_TYPE_VPPCOM_BOUND";
+
+    default:
+      return "SOCKET_TYPE_UNKNOWN";
+    }
+}
+
+static inline char *
+vcom_socket_epoll_type_str (vcom_epoll_type_t t)
+{
+  switch (t)
+    {
+    case EPOLL_TYPE_UNBOUND:
+      return "EPOLL_TYPE_UNBOUND";
+
+    case EPOLL_TYPE_KERNEL_BOUND:
+      return "EPOLL_TYPE_KERNEL_BOUND";
+
+    case EPOLL_TYPE_VPPCOM_BOUND:
+      return "EPOLL_TYPE_VPPCOM_BOUND";
+
+    default:
+      return "EPOLL_TYPE_UNKNOWN";
+    }
+}
+
+static inline char *
+vcom_socket_vcom_fd_type_str (vcom_fd_type_t t)
+{
+  switch (t)
+    {
+    case FD_TYPE_KERNEL:
+      return "FD_TYPE_KERNEL";
+
+    case FD_TYPE_EPOLL:
+      return "FD_TYPE_EPOLL";
+
+    case FD_TYPE_VCOM_SOCKET:
+      return "FD_TYPE_VCOM_SOCKET";
+
+    default:
+      return "FD_TYPE_UNKNOWN";
+    }
+}
+
+static inline int
+vcom_socket_type_is_vppcom_bound (vcom_socket_type_t t)
+{
+  return t == SOCKET_TYPE_VPPCOM_BOUND;
+}
+
+static inline int
+vcom_socket_epoll_type_is_vppcom_bound (vcom_epoll_type_t t)
+{
+  return t == EPOLL_TYPE_VPPCOM_BOUND;
+}
+
+static inline void
+vsocket_init (vcom_socket_t * vsock)
+{
+  memset (vsock, 0, sizeof (*vsock));
+
+  vsock->fd = INVALID_FD;
+  vsock->sid = INVALID_SESSION_ID;
+  vsock->type = SOCKET_TYPE_UNBOUND;
+  /* vcom socket attributes init here */
+}
+
+static inline void
+vepoll_init (vcom_epoll_t * vepoll)
+{
+  memset (vepoll, 0, sizeof (*vepoll));
+
+  vepoll->epfd = INVALID_EPFD;
+  vepoll->vep_idx = INVALID_VEP_IDX;
+  vepoll->type = EPOLL_TYPE_UNBOUND;
+  vepoll->flags = 0;
+
+  vepoll->count = 0;
+  vepoll->close = 0;
+  /* vcom epoll attributes init here */
+}
+
+static inline void
+vepitem_init (vcom_epitem_t * vepitem)
+{
+  struct epoll_event event = {.events = 0,.data.fd = INVALID_FD };
+
+  memset (vepitem, 0, sizeof (*vepitem));
+
+  vepitem->epfd = INVALID_EPFD;
+
+  vepitem->fd = INVALID_FD;
+  vepitem->next_fd = INVALID_FD;
+  vepitem->prev_fd = INVALID_FD;
+
+  vepitem->type = FD_TYPE_INVALID;
+
+  vepitem->event = event;
+  vepitem->revent = event;
+  /* vepoll attributes init here */
+}
+
+static inline void
+vepitemkey_init (vcom_epitem_key_t * epfdfd)
+{
+  memset (epfdfd, 0, sizeof (*epfdfd));
+
+  epfdfd->epfd = INVALID_EPFD;
+  epfdfd->fd = INVALID_FD;
+}
+
+static inline void
+vsocket_set (vcom_socket_t * vsock, i32 fd, i32 sid, vcom_socket_type_t type)
+{
+  vsock->fd = fd;
+  vsock->sid = sid;
+  vsock->type = type;
+  /* vcom socket attributes set here */
+}
+
+static inline void
+vepoll_set (vcom_epoll_t * vepoll,
+	    i32 epfd, i32 vep_idx,
+	    vcom_epoll_type_t type, i32 flags, i32 count, u32 close)
+{
+  vepoll->epfd = epfd;
+  vepoll->vep_idx = vep_idx;
+  vepoll->type = type;
+  vepoll->flags = flags;
+
+  vepoll->count = count;
+  vepoll->close = close;
+  /* vcom epoll attributes set here */
+}
+
+static inline void
+vepitem_set (vcom_epitem_t * vepitem,
+	     i32 epfd,
+	     i32 fd, i32 next_fd, i32 prev_fd,
+	     vcom_fd_type_t type,
+	     struct epoll_event event, struct epoll_event revent)
+{
+  vepitem->epfd = epfd;
+
+  vepitem->fd = fd;
+  vepitem->next_fd = next_fd;
+  vepitem->prev_fd = prev_fd;
+
+  vepitem->type = type;
+
+  vepitem->event = event;
+  vepitem->revent = revent;
+  /* vcom epitem attributes set here */
+}
+
+static inline void
+vepitemkey_set (vcom_epitem_key_t * epfdfd, i32 epfd, i32 fd)
+{
+  epfdfd->epfd = epfd;
+  epfdfd->fd = fd;
+}
+
+static inline int
+vsocket_is_vppcom_bound (vcom_socket_t * vsock)
+{
+  return vcom_socket_type_is_vppcom_bound (vsock->type);
+}
+
+static inline int
+vepoll_is_vppcom_bound (vcom_epoll_t * vepoll)
+{
+  return vcom_socket_epoll_type_is_vppcom_bound (vepoll->type);
+}
+
+int vcom_socket_main_init (void);
+
+void vcom_socket_main_destroy (void);
+
+void vcom_socket_main_show (void);
+
+int vcom_socket_is_vcom_fd (int fd);
+
+int vcom_socket_is_vcom_epfd (int epfd);
+
+int vcom_socket_close (int __fd);
+
+ssize_t vcom_socket_read (int __fd, void *__buf, size_t __nbytes);
+
+ssize_t vcom_socket_readv (int __fd, const struct iovec *__iov, int __iovcnt);
+
+ssize_t vcom_socket_write (int __fd, const void *__buf, size_t __n);
+
+ssize_t vcom_socket_writev (int __fd, const struct iovec *__iov,
+			    int __iovcnt);
+
+int vcom_socket_fcntl_va (int __fd, int __cmd, va_list __ap);
+
+int
+vcom_socket_select (int vcom_nfds, fd_set * __restrict vcom_readfds,
+		    fd_set * __restrict vcom_writefds,
+		    fd_set * __restrict vcom_exceptfds,
+		    struct timeval *__restrict timeout);
+
+
+int vcom_socket_socket (int __domain, int __type, int __protocol);
+
+int
+vcom_socket_socketpair (int __domain, int __type, int __protocol,
+			int __fds[2]);
+
+int vcom_socket_bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
+
+int
+vcom_socket_getsockname (int __fd, __SOCKADDR_ARG __addr,
+			 socklen_t * __restrict __len);
+
+int
+vcom_socket_connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
+
+int
+vcom_socket_getpeername (int __fd, __SOCKADDR_ARG __addr,
+			 socklen_t * __restrict __len);
+
+ssize_t
+vcom_socket_send (int __fd, const void *__buf, size_t __n, int __flags);
+
+ssize_t vcom_socket_recv (int __fd, void *__buf, size_t __n, int __flags);
+
+/*
+ * RETURN   1 if __fd is (SOCK_STREAM, SOCK_SEQPACKET),
+ * 0 otherwise
+ * */
+int vcom_socket_is_connection_mode_socket (int __fd);
+
+ssize_t
+vcom_socket_sendto (int __fd, const void *__buf, size_t __n,
+		    int __flags, __CONST_SOCKADDR_ARG __addr,
+		    socklen_t __addr_len);
+
+ssize_t
+vcom_socket_recvfrom (int __fd, void *__restrict __buf, size_t __n,
+		      int __flags, __SOCKADDR_ARG __addr,
+		      socklen_t * __restrict __addr_len);
+
+ssize_t
+vcom_socket_sendmsg (int __fd, const struct msghdr *__message, int __flags);
+
+#ifdef __USE_GNU
+int
+vcom_socket_sendmmsg (int __fd, struct mmsghdr *__vmessages,
+		      unsigned int __vlen, int __flags);
+#endif
+
+ssize_t vcom_socket_recvmsg (int __fd, struct msghdr *__message, int __flags);
+
+#ifdef __USE_GNU
+int
+vcom_socket_recvmmsg (int __fd, struct mmsghdr *__vmessages,
+		      unsigned int __vlen, int __flags,
+		      struct timespec *__tmo);
+#endif
+
+int
+vcom_socket_getsockopt (int __fd, int __level, int __optname,
+			void *__restrict __optval,
+			socklen_t * __restrict __optlen);
+
+int
+vcom_socket_setsockopt (int __fd, int __level, int __optname,
+			const void *__optval, socklen_t __optlen);
+
+int vcom_socket_listen (int __fd, int __n);
+
+int
+vcom_socket_accept (int __fd, __SOCKADDR_ARG __addr,
+		    socklen_t * __restrict __addr_len);
+
+#ifdef __USE_GNU
+int
+vcom_socket_accept4 (int __fd, __SOCKADDR_ARG __addr,
+		     socklen_t * __restrict __addr_len, int __flags);
+#endif
+
+int vcom_socket_shutdown (int __fd, int __how);
+
+int vcom_socket_epoll_create1 (int __flags);
+
+int
+vcom_socket_epoll_ctl (int __epfd, int __op, int __fd,
+		       struct epoll_event *__event);
+
+int
+vcom_socket_epoll_pwait (int __epfd, struct epoll_event *__events,
+			 int __maxevents, int __timeout,
+			 const __sigset_t * __ss);
+
+#endif /* included_vcom_socket_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket_wrapper.c b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket_wrapper.c
new file mode 100644
index 0000000..74a0dcf
--- /dev/null
+++ b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket_wrapper.c
@@ -0,0 +1,853 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright (c) 2005-2008 Jelmer Vernooij <jelmer@samba.org>
+ * Copyright (C) 2006-2014 Stefan Metzmacher <metze@samba.org>
+ * Copyright (C) 2013-2014 Andreas Schneider <asn@samba.org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the author nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+/*
+   Socket wrapper library. Passes all socket communication over
+   unix domain sockets if the environment variable SOCKET_WRAPPER_DIR
+   is set.
+*/
+
+#include <signal.h>
+#include <dlfcn.h>
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <pthread.h>
+
+#include <libvcl-ldpreload/vcom_socket_wrapper.h>
+
+
+enum swrap_dbglvl_e
+{
+  SWRAP_LOG_ERROR = 0,
+  SWRAP_LOG_WARN,
+  SWRAP_LOG_DEBUG,
+  SWRAP_LOG_TRACE
+};
+
+
+/* Macros for accessing mutexes */
+#define SWRAP_LOCK(m) do { \
+        pthread_mutex_lock(&(m ## _mutex)); \
+} while(0)
+
+#define SWRAP_UNLOCK(m) do { \
+        pthread_mutex_unlock(&(m ## _mutex)); \
+} while(0)
+
+/* Add new global locks here please */
+#define SWRAP_LOCK_ALL \
+        SWRAP_LOCK(libc_symbol_binding); \
+
+#define SWRAP_UNLOCK_ALL \
+        SWRAP_UNLOCK(libc_symbol_binding); \
+
+
+
+/* The mutex for accessing the global libc.symbols */
+static pthread_mutex_t libc_symbol_binding_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* Function prototypes */
+
+#ifdef NDEBUG
+#define SWRAP_LOG(...)
+#else
+static void
+swrap_log (enum swrap_dbglvl_e dbglvl, const char *func,
+	   const char *format, ...)
+PRINTF_ATTRIBUTE (3, 4);
+#define SWRAP_LOG(dbglvl, ...) swrap_log((dbglvl), __func__, __VA_ARGS__)
+
+     static void
+       swrap_log (enum swrap_dbglvl_e dbglvl,
+		  const char *func, const char *format, ...)
+{
+  char buffer[1024];
+  va_list va;
+  unsigned int lvl = SWRAP_LOG_WARN;
+
+  va_start (va, format);
+  vsnprintf (buffer, sizeof (buffer), format, va);
+  va_end (va);
+
+  if (lvl >= dbglvl)
+    {
+      switch (dbglvl)
+	{
+	case SWRAP_LOG_ERROR:
+	  fprintf (stderr,
+		   "SWRAP_ERROR(%d) - %s: %s\n",
+		   (int) getpid (), func, buffer);
+	  break;
+	case SWRAP_LOG_WARN:
+	  fprintf (stderr,
+		   "SWRAP_WARN(%d) - %s: %s\n",
+		   (int) getpid (), func, buffer);
+	  break;
+	case SWRAP_LOG_DEBUG:
+	  fprintf (stderr,
+		   "SWRAP_DEBUG(%d) - %s: %s\n",
+		   (int) getpid (), func, buffer);
+	  break;
+	case SWRAP_LOG_TRACE:
+	  fprintf (stderr,
+		   "SWRAP_TRACE(%d) - %s: %s\n",
+		   (int) getpid (), func, buffer);
+	  break;
+	}
+    }
+}
+#endif
+
+
+/*********************************************************
+ * SWRAP LOADING LIBC FUNCTIONS
+ *********************************************************/
+
+#ifdef HAVE_ACCEPT4
+typedef int (*__libc_accept4) (int sockfd,
+			       struct sockaddr * addr,
+			       socklen_t * addrlen, int flags);
+#else
+typedef int (*__libc_accept) (int sockfd,
+			      struct sockaddr * addr, socklen_t * addrlen);
+#endif
+typedef int (*__libc_bind) (int sockfd,
+			    const struct sockaddr * addr, socklen_t addrlen);
+typedef int (*__libc_close) (int fd);
+typedef int (*__libc_connect) (int sockfd,
+			       const struct sockaddr * addr,
+			       socklen_t addrlen);
+
+#if 0
+/* TBD: dup and dup2 to be implemented later */
+typedef int (*__libc_dup) (int fd);
+typedef int (*__libc_dup2) (int oldfd, int newfd);
+#endif
+
+typedef int (*__libc_fcntl) (int fd, int cmd, ...);
+typedef FILE *(*__libc_fopen) (const char *name, const char *mode);
+#ifdef HAVE_FOPEN64
+typedef FILE *(*__libc_fopen64) (const char *name, const char *mode);
+#endif
+#ifdef HAVE_EVENTFD
+typedef int (*__libc_eventfd) (int count, int flags);
+#endif
+typedef int (*__libc_getpeername) (int sockfd,
+				   struct sockaddr * addr,
+				   socklen_t * addrlen);
+typedef int (*__libc_getsockname) (int sockfd,
+				   struct sockaddr * addr,
+				   socklen_t * addrlen);
+typedef int (*__libc_getsockopt) (int sockfd,
+				  int level,
+				  int optname,
+				  void *optval, socklen_t * optlen);
+typedef int (*__libc_ioctl) (int d, unsigned long int request, ...);
+typedef int (*__libc_listen) (int sockfd, int backlog);
+typedef int (*__libc_open) (const char *pathname, int flags, mode_t mode);
+#ifdef HAVE_OPEN64
+typedef int (*__libc_open64) (const char *pathname, int flags, mode_t mode);
+#endif /* HAVE_OPEN64 */
+typedef int (*__libc_openat) (int dirfd, const char *path, int flags, ...);
+typedef int (*__libc_pipe) (int pipefd[2]);
+typedef int (*__libc_read) (int fd, void *buf, size_t count);
+typedef ssize_t (*__libc_readv) (int fd, const struct iovec * iov,
+				 int iovcnt);
+typedef int (*__libc_recv) (int sockfd, void *buf, size_t len, int flags);
+typedef int (*__libc_recvfrom) (int sockfd,
+				void *buf,
+				size_t len,
+				int flags,
+				struct sockaddr * src_addr,
+				socklen_t * addrlen);
+typedef int (*__libc_recvmsg) (int sockfd, const struct msghdr * msg,
+			       int flags);
+typedef int (*__libc_send) (int sockfd, const void *buf, size_t len,
+			    int flags);
+typedef int (*__libc_sendmsg) (int sockfd, const struct msghdr * msg,
+			       int flags);
+typedef int (*__libc_sendto) (int sockfd, const void *buf, size_t len,
+			      int flags, const struct sockaddr * dst_addr,
+			      socklen_t addrlen);
+typedef int (*__libc_setsockopt) (int sockfd, int level, int optname,
+				  const void *optval, socklen_t optlen);
+#ifdef HAVE_SIGNALFD
+typedef int (*__libc_signalfd) (int fd, const sigset_t * mask, int flags);
+#endif
+typedef int (*__libc_socket) (int domain, int type, int protocol);
+typedef int (*__libc_socketpair) (int domain, int type, int protocol,
+				  int sv[2]);
+#ifdef HAVE_TIMERFD_CREATE
+typedef int (*__libc_timerfd_create) (int clockid, int flags);
+#endif
+typedef ssize_t (*__libc_write) (int fd, const void *buf, size_t count);
+typedef ssize_t (*__libc_writev) (int fd, const struct iovec * iov,
+				  int iovcnt);
+
+typedef int (*__libc_shutdown) (int fd, int how);
+
+typedef int (*__libc_select) (int __nfds, fd_set * __restrict __readfds,
+			      fd_set * __restrict __writefds,
+			      fd_set * __restrict __exceptfds,
+			      struct timeval * __restrict __timeout);
+
+#ifdef __USE_XOPEN2K
+typedef int (*__libc_pselect) (int __nfds, fd_set * __restrict __readfds,
+			       fd_set * __restrict __writefds,
+			       fd_set * __restrict __exceptfds,
+			       const struct timespec * __restrict __timeout,
+			       const __sigset_t * __restrict __sigmask);
+#endif
+
+typedef int (*__libc_epoll_create) (int __size);
+
+typedef int (*__libc_epoll_create1) (int __flags);
+
+typedef int (*__libc_epoll_ctl) (int __epfd, int __op, int __fd,
+				 struct epoll_event * __event);
+
+typedef int (*__libc_epoll_wait) (int __epfd, struct epoll_event * __events,
+				  int __maxevents, int __timeout);
+
+typedef int (*__libc_epoll_pwait) (int __epfd, struct epoll_event * __events,
+				   int __maxevents, int __timeout,
+				   const __sigset_t * __ss);
+
+
+#define SWRAP_SYMBOL_ENTRY(i) \
+        union { \
+                __libc_##i f; \
+                void *obj; \
+        } _libc_##i
+
+struct swrap_libc_symbols
+{
+#ifdef HAVE_ACCEPT4
+  SWRAP_SYMBOL_ENTRY (accept4);
+#else
+  SWRAP_SYMBOL_ENTRY (accept);
+#endif
+  SWRAP_SYMBOL_ENTRY (bind);
+  SWRAP_SYMBOL_ENTRY (close);
+  SWRAP_SYMBOL_ENTRY (connect);
+#if 0
+  /* TBD: dup and dup2 to be implemented later */
+  SWRAP_SYMBOL_ENTRY (dup);
+  SWRAP_SYMBOL_ENTRY (dup2);
+#endif
+  SWRAP_SYMBOL_ENTRY (fcntl);
+  SWRAP_SYMBOL_ENTRY (fopen);
+#ifdef HAVE_FOPEN64
+  SWRAP_SYMBOL_ENTRY (fopen64);
+#endif
+#ifdef HAVE_EVENTFD
+  SWRAP_SYMBOL_ENTRY (eventfd);
+#endif
+  SWRAP_SYMBOL_ENTRY (getpeername);
+  SWRAP_SYMBOL_ENTRY (getsockname);
+  SWRAP_SYMBOL_ENTRY (getsockopt);
+  SWRAP_SYMBOL_ENTRY (ioctl);
+  SWRAP_SYMBOL_ENTRY (listen);
+  SWRAP_SYMBOL_ENTRY (open);
+#ifdef HAVE_OPEN64
+  SWRAP_SYMBOL_ENTRY (open64);
+#endif
+  SWRAP_SYMBOL_ENTRY (openat);
+  SWRAP_SYMBOL_ENTRY (pipe);
+  SWRAP_SYMBOL_ENTRY (read);
+  SWRAP_SYMBOL_ENTRY (readv);
+  SWRAP_SYMBOL_ENTRY (recv);
+  SWRAP_SYMBOL_ENTRY (recvfrom);
+  SWRAP_SYMBOL_ENTRY (recvmsg);
+  SWRAP_SYMBOL_ENTRY (send);
+  SWRAP_SYMBOL_ENTRY (sendmsg);
+  SWRAP_SYMBOL_ENTRY (sendto);
+  SWRAP_SYMBOL_ENTRY (setsockopt);
+#ifdef HAVE_SIGNALFD
+  SWRAP_SYMBOL_ENTRY (signalfd);
+#endif
+  SWRAP_SYMBOL_ENTRY (socket);
+  SWRAP_SYMBOL_ENTRY (socketpair);
+#ifdef HAVE_TIMERFD_CREATE
+  SWRAP_SYMBOL_ENTRY (timerfd_create);
+#endif
+  SWRAP_SYMBOL_ENTRY (write);
+  SWRAP_SYMBOL_ENTRY (writev);
+
+  SWRAP_SYMBOL_ENTRY (shutdown);
+  SWRAP_SYMBOL_ENTRY (select);
+#ifdef __USE_XOPEN2K
+  SWRAP_SYMBOL_ENTRY (pselect);
+#endif
+  SWRAP_SYMBOL_ENTRY (epoll_create);
+  SWRAP_SYMBOL_ENTRY (epoll_create1);
+  SWRAP_SYMBOL_ENTRY (epoll_ctl);
+  SWRAP_SYMBOL_ENTRY (epoll_wait);
+  SWRAP_SYMBOL_ENTRY (epoll_pwait);
+};
+
+struct swrap
+{
+  struct
+  {
+    void *handle;
+    void *socket_handle;
+    struct swrap_libc_symbols symbols;
+  } libc;
+};
+
+static struct swrap swrap;
+
+#define LIBC_NAME "libc.so"
+
+enum swrap_lib
+{
+  SWRAP_LIBC,
+};
+
+#ifndef NDEBUG
+static const char *
+swrap_str_lib (enum swrap_lib lib)
+{
+  switch (lib)
+    {
+    case SWRAP_LIBC:
+      return "libc";
+    }
+
+  /* Compiler would warn us about unhandled enum value if we get here */
+  return "unknown";
+}
+#endif
+
+static void *
+swrap_load_lib_handle (enum swrap_lib lib)
+{
+  int flags = RTLD_LAZY;
+  void *handle = NULL;
+  int i;
+
+#ifdef RTLD_DEEPBIND
+  flags |= RTLD_DEEPBIND;
+#endif
+
+  switch (lib)
+    {
+    case SWRAP_LIBC:
+      handle = swrap.libc.handle;
+#ifdef LIBC_SO
+      if (handle == NULL)
+	{
+	  handle = dlopen (LIBC_SO, flags);
+
+	  swrap.libc.handle = handle;
+	}
+#endif
+      if (handle == NULL)
+	{
+	  for (i = 10; i >= 0; i--)
+	    {
+	      char soname[256] = { 0 };
+
+	      snprintf (soname, sizeof (soname), "libc.so.%d", i);
+	      handle = dlopen (soname, flags);
+	      if (handle != NULL)
+		{
+		  break;
+		}
+	    }
+
+	  swrap.libc.handle = handle;
+	}
+      break;
+    }
+
+  if (handle == NULL)
+    {
+      SWRAP_LOG (SWRAP_LOG_ERROR,
+		 "Failed to dlopen library: %s\n", dlerror ());
+      exit (-1);
+    }
+
+  return handle;
+}
+
+static void *
+_swrap_bind_symbol (enum swrap_lib lib, const char *fn_name)
+{
+  void *handle;
+  void *func;
+
+  handle = swrap_load_lib_handle (lib);
+
+  func = dlsym (handle, fn_name);
+  if (func == NULL)
+    {
+      SWRAP_LOG (SWRAP_LOG_ERROR,
+		 "Failed to find %s: %s\n", fn_name, dlerror ());
+      exit (-1);
+    }
+
+  SWRAP_LOG (SWRAP_LOG_TRACE,
+	     "Loaded %s from %s", fn_name, swrap_str_lib (lib));
+
+  return func;
+}
+
+#define swrap_bind_symbol_libc(sym_name) \
+        SWRAP_LOCK(libc_symbol_binding); \
+        if (swrap.libc.symbols._libc_##sym_name.obj == NULL) { \
+                swrap.libc.symbols._libc_##sym_name.obj = \
+                        _swrap_bind_symbol(SWRAP_LIBC, #sym_name); \
+        } \
+        SWRAP_UNLOCK(libc_symbol_binding)
+
+/*
+ * IMPORTANT
+ *
+ * Functions especially from libc need to be loaded individually, you can't load
+ * all at once or gdb will segfault at startup. The same applies to valgrind and
+ * has probably something todo with with the linker.
+ * So we need load each function at the point it is called the first time.
+ */
+#ifdef HAVE_ACCEPT4
+int
+libc_accept4 (int sockfd,
+	      struct sockaddr *addr, socklen_t * addrlen, int flags)
+{
+  swrap_bind_symbol_libc (accept4);
+
+  return swrap.libc.symbols._libc_accept4.f (sockfd, addr, addrlen, flags);
+}
+
+#else /* HAVE_ACCEPT4 */
+
+int
+libc_accept (int sockfd, struct sockaddr *addr, socklen_t * addrlen)
+{
+  swrap_bind_symbol_libc (accept);
+
+  return swrap.libc.symbols._libc_accept.f (sockfd, addr, addrlen);
+}
+#endif /* HAVE_ACCEPT4 */
+
+int
+libc_bind (int sockfd, const struct sockaddr *addr, socklen_t addrlen)
+{
+  swrap_bind_symbol_libc (bind);
+
+  return swrap.libc.symbols._libc_bind.f (sockfd, addr, addrlen);
+}
+
+int
+libc_close (int fd)
+{
+  swrap_bind_symbol_libc (close);
+
+  return swrap.libc.symbols._libc_close.f (fd);
+}
+
+int
+libc_connect (int sockfd, const struct sockaddr *addr, socklen_t addrlen)
+{
+  swrap_bind_symbol_libc (connect);
+
+  return swrap.libc.symbols._libc_connect.f (sockfd, addr, addrlen);
+}
+
+#if 0
+/* TBD: dup and dup2 to be implemented later */
+int
+libc_dup (int fd)
+{
+  swrap_bind_symbol_libc (dup);
+
+  return swrap.libc.symbols._libc_dup.f (fd);
+}
+
+int
+libc_dup2 (int oldfd, int newfd)
+{
+  swrap_bind_symbol_libc (dup2);
+
+  return swrap.libc.symbols._libc_dup2.f (oldfd, newfd);
+}
+#endif
+
+#ifdef HAVE_EVENTFD
+int
+libc_eventfd (int count, int flags)
+{
+  swrap_bind_symbol_libc (eventfd);
+
+  return swrap.libc.symbols._libc_eventfd.f (count, flags);
+}
+#endif
+
+DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE int
+libc_vfcntl (int fd, int cmd, va_list ap)
+{
+  long int args[4];
+  int rc;
+  int i;
+
+  swrap_bind_symbol_libc (fcntl);
+
+  for (i = 0; i < 4; i++)
+    {
+      args[i] = va_arg (ap, long int);
+    }
+
+  rc = swrap.libc.symbols._libc_fcntl.f (fd,
+					 cmd,
+					 args[0], args[1], args[2], args[3]);
+
+  return rc;
+}
+
+int
+libc_getpeername (int sockfd, struct sockaddr *addr, socklen_t * addrlen)
+{
+  swrap_bind_symbol_libc (getpeername);
+
+  return swrap.libc.symbols._libc_getpeername.f (sockfd, addr, addrlen);
+}
+
+int
+libc_getsockname (int sockfd, struct sockaddr *addr, socklen_t * addrlen)
+{
+  swrap_bind_symbol_libc (getsockname);
+
+  return swrap.libc.symbols._libc_getsockname.f (sockfd, addr, addrlen);
+}
+
+int
+libc_getsockopt (int sockfd,
+		 int level, int optname, void *optval, socklen_t * optlen)
+{
+  swrap_bind_symbol_libc (getsockopt);
+
+  return swrap.libc.symbols._libc_getsockopt.f (sockfd,
+						level,
+						optname, optval, optlen);
+}
+
+int
+libc_listen (int sockfd, int backlog)
+{
+  swrap_bind_symbol_libc (listen);
+
+  return swrap.libc.symbols._libc_listen.f (sockfd, backlog);
+}
+
+int
+libc_read (int fd, void *buf, size_t count)
+{
+  swrap_bind_symbol_libc (read);
+
+  return swrap.libc.symbols._libc_read.f (fd, buf, count);
+}
+
+ssize_t
+libc_readv (int fd, const struct iovec * iov, int iovcnt)
+{
+  swrap_bind_symbol_libc (readv);
+
+  return swrap.libc.symbols._libc_readv.f (fd, iov, iovcnt);
+}
+
+int
+libc_recv (int sockfd, void *buf, size_t len, int flags)
+{
+  swrap_bind_symbol_libc (recv);
+
+  return swrap.libc.symbols._libc_recv.f (sockfd, buf, len, flags);
+}
+
+int
+libc_recvfrom (int sockfd,
+	       void *buf,
+	       size_t len,
+	       int flags, struct sockaddr *src_addr, socklen_t * addrlen)
+{
+  swrap_bind_symbol_libc (recvfrom);
+
+  return swrap.libc.symbols._libc_recvfrom.f (sockfd,
+					      buf,
+					      len, flags, src_addr, addrlen);
+}
+
+int
+libc_recvmsg (int sockfd, struct msghdr *msg, int flags)
+{
+  swrap_bind_symbol_libc (recvmsg);
+
+  return swrap.libc.symbols._libc_recvmsg.f (sockfd, msg, flags);
+}
+
+int
+libc_send (int sockfd, const void *buf, size_t len, int flags)
+{
+  swrap_bind_symbol_libc (send);
+
+  return swrap.libc.symbols._libc_send.f (sockfd, buf, len, flags);
+}
+
+int
+libc_sendmsg (int sockfd, const struct msghdr *msg, int flags)
+{
+  swrap_bind_symbol_libc (sendmsg);
+
+  return swrap.libc.symbols._libc_sendmsg.f (sockfd, msg, flags);
+}
+
+int
+libc_sendto (int sockfd,
+	     const void *buf,
+	     size_t len,
+	     int flags, const struct sockaddr *dst_addr, socklen_t addrlen)
+{
+  swrap_bind_symbol_libc (sendto);
+
+  return swrap.libc.symbols._libc_sendto.f (sockfd,
+					    buf,
+					    len, flags, dst_addr, addrlen);
+}
+
+int
+libc_setsockopt (int sockfd,
+		 int level, int optname, const void *optval, socklen_t optlen)
+{
+  swrap_bind_symbol_libc (setsockopt);
+
+  return swrap.libc.symbols._libc_setsockopt.f (sockfd,
+						level,
+						optname, optval, optlen);
+}
+
+int
+libc_socket (int domain, int type, int protocol)
+{
+  swrap_bind_symbol_libc (socket);
+
+  return swrap.libc.symbols._libc_socket.f (domain, type, protocol);
+}
+
+int
+libc_socketpair (int domain, int type, int protocol, int sv[2])
+{
+  swrap_bind_symbol_libc (socketpair);
+
+  return swrap.libc.symbols._libc_socketpair.f (domain, type, protocol, sv);
+}
+
+ssize_t
+libc_write (int fd, const void *buf, size_t count)
+{
+  swrap_bind_symbol_libc (write);
+
+  return swrap.libc.symbols._libc_write.f (fd, buf, count);
+}
+
+ssize_t
+libc_writev (int fd, const struct iovec * iov, int iovcnt)
+{
+  swrap_bind_symbol_libc (writev);
+
+  return swrap.libc.symbols._libc_writev.f (fd, iov, iovcnt);
+}
+
+int
+libc_shutdown (int fd, int how)
+{
+  swrap_bind_symbol_libc (shutdown);
+
+  return swrap.libc.symbols._libc_shutdown.f (fd, how);
+}
+
+int
+libc_select (int __nfds, fd_set * __restrict __readfds,
+	     fd_set * __restrict __writefds,
+	     fd_set * __restrict __exceptfds,
+	     struct timeval *__restrict __timeout)
+{
+  swrap_bind_symbol_libc (select);
+
+  return swrap.libc.symbols._libc_select.f (__nfds, __readfds,
+					    __writefds,
+					    __exceptfds, __timeout);
+}
+
+#ifdef __USE_XOPEN2K
+int
+libc_pselect (int __nfds, fd_set * __restrict __readfds,
+	      fd_set * __restrict __writefds,
+	      fd_set * __restrict __exceptfds,
+	      const struct timespec *__restrict __timeout,
+	      const __sigset_t * __restrict __sigmask)
+{
+  swrap_bind_symbol_libc (pselect);
+
+  return swrap.libc.symbols._libc_pselect.f (__nfds, __readfds,
+					     __writefds,
+					     __exceptfds,
+					     __timeout, __sigmask);
+}
+#endif
+
+int
+libc_epoll_create (int __size)
+{
+  swrap_bind_symbol_libc (epoll_create);
+
+  return swrap.libc.symbols._libc_epoll_create.f (__size);
+}
+
+int
+libc_epoll_create1 (int __flags)
+{
+  swrap_bind_symbol_libc (epoll_create1);
+
+  return swrap.libc.symbols._libc_epoll_create1.f (__flags);
+}
+
+int
+libc_epoll_ctl (int __epfd, int __op, int __fd, struct epoll_event *__event)
+{
+  swrap_bind_symbol_libc (epoll_ctl);
+
+  return swrap.libc.symbols._libc_epoll_ctl.f (__epfd, __op, __fd, __event);
+}
+
+int
+libc_epoll_wait (int __epfd, struct epoll_event *__events,
+		 int __maxevents, int __timeout)
+{
+  swrap_bind_symbol_libc (epoll_wait);
+
+  return swrap.libc.symbols._libc_epoll_wait.f (__epfd, __events,
+						__maxevents, __timeout);
+}
+
+int
+libc_epoll_pwait (int __epfd, struct epoll_event *__events,
+		  int __maxevents, int __timeout, const __sigset_t * __ss)
+{
+  swrap_bind_symbol_libc (epoll_pwait);
+
+  return swrap.libc.symbols._libc_epoll_pwait.f (__epfd, __events,
+						 __maxevents, __timeout,
+						 __ss);
+}
+
+static void
+swrap_thread_prepare (void)
+{
+  SWRAP_LOCK_ALL;
+}
+
+static void
+swrap_thread_parent (void)
+{
+  SWRAP_UNLOCK_ALL;
+}
+
+static void
+swrap_thread_child (void)
+{
+  SWRAP_UNLOCK_ALL;
+}
+
+/****************************
+ * CONSTRUCTOR
+ ***************************/
+void
+swrap_constructor (void)
+{
+  /*
+   * If we hold a lock and the application forks, then the child
+   * is not able to unlock the mutex and we are in a deadlock.
+   * This should prevent such deadlocks.
+   */
+  pthread_atfork (&swrap_thread_prepare,
+		  &swrap_thread_parent, &swrap_thread_child);
+}
+
+/****************************
+ * DESTRUCTOR
+ ***************************/
+
+/*
+ * This function is called when the library is unloaded and makes sure that
+ * sockets get closed and the unix file for the socket are unlinked.
+ */
+void
+swrap_destructor (void)
+{
+  if (swrap.libc.handle != NULL)
+    {
+      dlclose (swrap.libc.handle);
+    }
+  if (swrap.libc.socket_handle)
+    {
+      dlclose (swrap.libc.socket_handle);
+    }
+}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket_wrapper.h b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket_wrapper.h
new file mode 100644
index 0000000..ef3ece0
--- /dev/null
+++ b/extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket_wrapper.h
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright (c) 2005-2008 Jelmer Vernooij <jelmer@samba.org>
+ * Copyright (C) 2006-2014 Stefan Metzmacher <metze@samba.org>
+ * Copyright (C) 2013-2014 Andreas Schneider <asn@samba.org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the author nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+/*
+   Socket wrapper library. Passes all socket communication over
+   unix domain sockets if the environment variable SOCKET_WRAPPER_DIR
+   is set.
+*/
+
+#ifndef included_vcom_socket_wrapper_h
+#define included_vcom_socket_wrapper_h
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/select.h>
+#include <sys/epoll.h>
+#include <sys/uio.h>
+#include <stdlib.h>
+
+
+/* GCC have printf type attribute check. */
+#ifdef HAVE_FUNCTION_ATTRIBUTE_FORMAT
+#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
+#else
+#define PRINTF_ATTRIBUTE(a,b)
+#endif /* HAVE_FUNCTION_ATTRIBUTE_FORMAT */
+
+#define HAVE_CONSTRUCTOR_ATTRIBUTE
+#ifdef HAVE_CONSTRUCTOR_ATTRIBUTE
+#define CONSTRUCTOR_ATTRIBUTE __attribute__ ((constructor))
+#else
+#define CONSTRUCTOR_ATTRIBUTE
+#endif /* HAVE_CONSTRUCTOR_ATTRIBUTE */
+
+#define HAVE_DESTRUCTOR_ATTRIBUTE
+#ifdef HAVE_DESTRUCTOR_ATTRIBUTE
+#define DESTRUCTOR_ATTRIBUTE __attribute__ ((destructor))
+#else
+#define DESTRUCTOR_ATTRIBUTE
+#endif
+
+#define HAVE_ADDRESS_SANITIZER_ATTRIBUTE
+#ifdef HAVE_ADDRESS_SANITIZER_ATTRIBUTE
+#define DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE __attribute__((no_sanitize_address))
+#else
+#define DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE
+#endif
+
+/*
+ * IMPORTANT
+ *
+ * Functions especially from libc need to be loaded individually, you can't load
+ * all at once or gdb will segfault at startup. The same applies to valgrind and
+ * has probably something todo with with the linker.
+ * So we need load each function at the point it is called the first time.
+ */
+#ifdef HAVE_ACCEPT4
+int
+libc_accept4 (int sockfd,
+	      struct sockaddr *addr, socklen_t * addrlen, int flags);
+#else /* HAVE_ACCEPT4 */
+int libc_accept (int sockfd, struct sockaddr *addr, socklen_t * addrlen);
+#endif /* HAVE_ACCEPT4 */
+
+int libc_bind (int sockfd, const struct sockaddr *addr, socklen_t addrlen);
+
+int libc_close (int fd);
+
+int libc_connect (int sockfd, const struct sockaddr *addr, socklen_t addrlen);
+
+#if 0
+/* TBD: dup and dup2 to be implemented later */
+int libc_dup (int fd);
+
+int libc_dup2 (int oldfd, int newfd);
+#endif
+
+#ifdef HAVE_EVENTFD
+int libc_eventfd (int count, int flags);
+#endif
+
+DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE int
+libc_vfcntl (int fd, int cmd, va_list ap);
+
+int libc_getpeername (int sockfd, struct sockaddr *addr, socklen_t * addrlen);
+
+int libc_getsockname (int sockfd, struct sockaddr *addr, socklen_t * addrlen);
+
+int
+libc_getsockopt (int sockfd,
+		 int level, int optname, void *optval, socklen_t * optlen);
+
+int libc_listen (int sockfd, int backlog);
+
+int libc_read (int fd, void *buf, size_t count);
+
+ssize_t libc_readv (int fd, const struct iovec *iov, int iovcnt);
+
+int libc_recv (int sockfd, void *buf, size_t len, int flags);
+
+int
+libc_recvfrom (int sockfd,
+	       void *buf,
+	       size_t len,
+	       int flags, struct sockaddr *src_addr, socklen_t * addrlen);
+
+int libc_recvmsg (int sockfd, struct msghdr *msg, int flags);
+
+int libc_send (int sockfd, const void *buf, size_t len, int flags);
+
+int libc_sendmsg (int sockfd, const struct msghdr *msg, int flags);
+
+int
+libc_sendto (int sockfd,
+	     const void *buf,
+	     size_t len,
+	     int flags, const struct sockaddr *dst_addr, socklen_t addrlen);
+
+int
+libc_setsockopt (int sockfd,
+		 int level, int optname, const void *optval,
+		 socklen_t optlen);
+
+int libc_socket (int domain, int type, int protocol);
+
+int libc_socketpair (int domain, int type, int protocol, int sv[2]);
+
+ssize_t libc_write (int fd, const void *buf, size_t count);
+
+ssize_t libc_writev (int fd, const struct iovec *iov, int iovcnt);
+
+int libc_shutdown (int fd, int how);
+
+int
+libc_select (int __nfds, fd_set * __restrict __readfds,
+	     fd_set * __restrict __writefds,
+	     fd_set * __restrict __exceptfds,
+	     struct timeval *__restrict __timeout);
+
+#ifdef __USE_XOPEN2K
+int
+libc_pselect (int __nfds, fd_set * __restrict __readfds,
+	      fd_set * __restrict __writefds,
+	      fd_set * __restrict __exceptfds,
+	      const struct timespec *__restrict __timeout,
+	      const __sigset_t * __restrict __sigmask);
+#endif
+
+int libc_epoll_create (int __size);
+
+int libc_epoll_create1 (int __flags);
+
+int libc_epoll_ctl (int __epfd, int __op, int __fd,
+		    struct epoll_event *__event);
+
+int libc_epoll_wait (int __epfd, struct epoll_event *__events,
+		     int __maxevents, int __timeout);
+
+int libc_epoll_pwait (int __epfd, struct epoll_event *__events,
+		      int __maxevents, int __timeout,
+		      const __sigset_t * __ss);
+
+void swrap_constructor (void);
+
+void swrap_destructor (void);
+
+#endif /* included_vcom_socket_wrapper_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/extras/vcl-ldpreload/src/vcl-ldpreload.mk b/extras/vcl-ldpreload/src/vcl-ldpreload.mk
new file mode 100644
index 0000000..001308a
--- /dev/null
+++ b/extras/vcl-ldpreload/src/vcl-ldpreload.mk
@@ -0,0 +1,9 @@
+vcl_ldpreload_configure_depend = vpp-install
+
+vcl_ldpreload_CPPFLAGS = $(call installed_includes_fn, \
+	vppinfra                                \
+	uri)
+
+vcl_ldpreload_LDFLAGS = $(call installed_libs_fn,      \
+	vppinfra                                \
+	uri)
