diff --git a/extras/libmemif/examples/CMakeLists.txt b/extras/libmemif/examples/CMakeLists.txt
index 4f120e5..6adacaa 100644
--- a/extras/libmemif/examples/CMakeLists.txt
+++ b/extras/libmemif/examples/CMakeLists.txt
@@ -13,18 +13,14 @@
 
 cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
 
-set(HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/icmp_responder)
+set(HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 
 set(COMMON_SOURCE_FILES
-    icmp_responder/icmp_proto.c)
+
+)
 
 list(APPEND EXAMPLES_LIST
-  icmp_responder/main.c
-  icmp_responder-epoll/main.c
-  icmp_responder-mt/main.c
-  icmp_responder-mt_3-1/main.c
-  icmp_responder-eb/main.c
-  icmp_responder-zero-copy-slave/main.c
+
 )
 
 foreach (EXAMPLE_SRC ${EXAMPLES_LIST})
diff --git a/extras/libmemif/examples/icmp_responder-eb/main.c b/extras/libmemif/examples/icmp_responder-eb/main.c
deleted file mode 100644
index 86a49da..0000000
--- a/extras/libmemif/examples/icmp_responder-eb/main.c
+++ /dev/null
@@ -1,1069 +0,0 @@
-/*
- *------------------------------------------------------------------
- * Copyright (c) 2018 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.
- *------------------------------------------------------------------
- */
-
-#define _GNU_SOURCE
-#include <stdlib.h>
-#include <stdint.h>
-#include <net/if.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/uio.h>
-#include <sys/mman.h>
-#include <sys/prctl.h>
-#include <inttypes.h>
-#include <string.h>
-#include <stdio.h>
-#include <netdb.h>
-#include <linux/ip.h>
-#include <linux/icmp.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-#include <netinet/if_ether.h>
-#include <net/if_arp.h>
-#include <asm/byteorder.h>
-#include <byteswap.h>
-#include <string.h>
-#include <sys/epoll.h>
-#include <errno.h>
-#include <unistd.h>
-#include <signal.h>
-#include <pthread.h>
-#include <time.h>
-
-#ifndef TIME_UTC
-#define TIME_UTC 1
-#endif /* TIME_UTC */
-
-#include <libmemif.h>
-#include <icmp_proto.h>
-
-#define APP_NAME	"ICMP_Responder"
-#define IF_NAME		"memif_connection"
-
-#ifdef ICMP_DBG
-#define DBG(...) do {						\
-			printf(APP_NAME":%s:%d",__func__,__LINE__);	\
-			printf(__VA_ARGS__);				\
-			printf("\n");					\
-		} while (0)
-#else
-#define DBG(...)
-#endif /* ICMP_DBG */
-
-#define INFO(...) do {					\
-			printf("INFO: "__VA_ARGS__);	\
-			printf("\n");			\
-		} while (0)
-
-#define MAX_MEMIF_BUFS	256
-#define MAX_CONNS	50
-
-
-#ifndef __NR_memfd_create
-#if defined __x86_64__
-#define __NR_memfd_create 319
-#elif defined __arm__
-#define __NR_memfd_create 385
-#elif defined __aarch64__
-#define __NR_memfd_create 279
-#else
-#error "__NR_memfd_create unknown for this architecture"
-#endif
-#endif
-
-#ifndef HAVE_MEMFD_CREATE
-static inline int
-memfd_create (const char *name, unsigned int flags)
-{
-  return syscall (__NR_memfd_create, name, flags);
-}
-#endif
-
-#ifndef F_LINUX_SPECIFIC_BASE
-#define F_LINUX_SPECIFIC_BASE 1024
-#endif
-
-#ifndef MFD_ALLOW_SEALING
-#define MFD_ALLOW_SEALING       0x0002U
-#endif
-
-#ifndef F_ADD_SEALS
-#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
-#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
-
-#define F_SEAL_SEAL     0x0001	/* prevent further seals from being set */
-#define F_SEAL_SHRINK   0x0002	/* prevent file from shrinking */
-#define F_SEAL_GROW     0x0004	/* prevent file from growing */
-#define F_SEAL_WRITE    0x0008	/* prevent writes */
-#endif
-
-typedef struct
-{
-  uint16_t index;
-
-  memif_conn_handle_t conn;
-
-  uint16_t tx_buf_num;
-  uint16_t rx_buf_num;
-  memif_buffer_t *tx_bufs;
-  memif_buffer_t *rx_bufs;
-
-  uint8_t ip_addr[4];
-  uint64_t tx_counter, rx_counter, tx_err_counter;
-  uint64_t t_sec, t_nsec;
-} memif_connection_t;
-
-typedef struct
-{
-  uint16_t index;
-  uint64_t packet_num;
-  uint8_t ip_daddr[4];
-  uint8_t hw_daddr[6];
-} icmpr_thread_data_t;
-
-icmpr_thread_data_t icmpr_thread_data[MAX_CONNS];
-pthread_t thread[MAX_CONNS];
-int epfd;
-long ctx[MAX_CONNS];
-memif_connection_t memif_connection[MAX_CONNS];
-
-static void
-print_help ()
-{
-  printf ("LIBMEMIF EXAMPLE APP: %s", APP_NAME);
-#ifdef ICMP_DBG
-  printf (" (debug)");
-#endif
-  printf ("\n");
-  printf ("==============================\n");
-  printf ("libmemif version: %s", LIBMEMIF_VERSION);
-#ifdef MEMIF_DBG
-  printf (" (debug)");
-#endif
-  printf ("\n");
-  printf ("memif version: %d\n", memif_get_version ());
-  printf ("commands:\n");
-  printf ("\thelp - prints this help\n");
-  printf ("\texit - exit app\n");
-  printf
-    ("\tconn <index> <mode> <interrupt> - create memif. index used as interface id. mode: 0 = slave | 1 = master. interrupt: none = default | 1 = handle ARP only\n");
-  printf ("\tdel <index> - delete memif\n");
-  printf ("\tshow - show connection details\n");
-  printf ("\tsend <index> <tx> <ip> <mac> - send icmp\n");
-}
-
-static void
-print_memif_details ()
-{
-  memif_details_t md;
-  ssize_t buflen;
-  char *buf;
-  int err, i, e;
-  buflen = 2048;
-  buf = malloc (buflen);
-  printf ("MEMIF DETAILS\n");
-  printf ("==============================\n");
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-
-      memset (&md, 0, sizeof (md));
-      memset (buf, 0, buflen);
-
-      err = memif_get_details (c->conn, &md, buf, buflen);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  if (err != MEMIF_ERR_NOCONN)
-	    INFO ("%s", memif_strerror (err));
-	  continue;
-	}
-
-      printf ("interface index: %d\n", i);
-
-      printf ("\tinterface ip: %u.%u.%u.%u\n",
-	      c->ip_addr[0], c->ip_addr[1], c->ip_addr[2], c->ip_addr[3]);
-      printf ("\tinterface name: %s\n", (char *) md.if_name);
-      printf ("\tapp name: %s\n", (char *) md.inst_name);
-      printf ("\tremote interface name: %s\n", (char *) md.remote_if_name);
-      printf ("\tremote app name: %s\n", (char *) md.remote_inst_name);
-      printf ("\tid: %u\n", md.id);
-      printf ("\tsecret: %s\n", (char *) md.secret);
-      printf ("\trole: ");
-      if (md.role)
-	printf ("slave\n");
-      else
-	printf ("master\n");
-      printf ("\tmode: ");
-      switch (md.mode)
-	{
-	case 0:
-	  printf ("ethernet\n");
-	  break;
-	case 1:
-	  printf ("ip\n");
-	  break;
-	case 2:
-	  printf ("punt/inject\n");
-	  break;
-	default:
-	  printf ("unknown\n");
-	  break;
-	}
-      printf ("\tsocket filename: %s\n", (char *) md.socket_filename);
-      printf ("\tregions:\n");
-      for (e = 0; e < md.regions_num; e++)
-	{
-	  printf ("\t\tindex: %u\n", md.regions[e].index);
-	  printf ("\t\taddress: %p\n", md.regions[e].addr);
-	  printf ("\t\tsize: %u\n", md.regions[e].size);
-	  printf ("\t\tfd: %d\n", md.regions[e].fd);
-	  if (md.regions[e].is_external)
-	    printf ("\t\texternal\n");
-	}
-      printf ("\trx queues:\n");
-      for (e = 0; e < md.rx_queues_num; e++)
-	{
-	  printf ("\t\tqueue id: %u\n", md.rx_queues[e].qid);
-	  printf ("\t\tring size: %u\n", md.rx_queues[e].ring_size);
-	  printf ("\t\tring rx mode: %s\n",
-		  md.rx_queues[e].flags ? "polling" : "interrupt");
-	  printf ("\t\tring head: %u\n", md.rx_queues[e].head);
-	  printf ("\t\tring tail: %u\n", md.rx_queues[e].tail);
-	  printf ("\t\tbuffer size: %u\n", md.rx_queues[e].buffer_size);
-	}
-      printf ("\ttx queues:\n");
-      for (e = 0; e < md.tx_queues_num; e++)
-	{
-	  printf ("\t\tqueue id: %u\n", md.tx_queues[e].qid);
-	  printf ("\t\tring size: %u\n", md.tx_queues[e].ring_size);
-	  printf ("\t\tring rx mode: %s\n",
-		  md.tx_queues[e].flags ? "polling" : "interrupt");
-	  printf ("\t\tring head: %u\n", md.tx_queues[e].head);
-	  printf ("\t\tring tail: %u\n", md.tx_queues[e].tail);
-	  printf ("\t\tbuffer size: %u\n", md.tx_queues[e].buffer_size);
-	}
-      printf ("\tlink: ");
-      if (md.link_up_down)
-	printf ("up\n");
-      else
-	printf ("down\n");
-    }
-  free (buf);
-}
-
-void
-icmpr_print_counters ()
-{
-  int i;
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-      if (c->conn == NULL)
-	continue;
-      printf ("===============================\n");
-      printf ("interface index: %d\n", c->index);
-      printf ("\trx: %lu\n", c->rx_counter);
-      printf ("\ttx: %lu\n", c->tx_counter);
-      printf ("\ttx_err: %lu\n", c->tx_err_counter);
-    }
-}
-
-void
-icmpr_reset_counters ()
-{
-  int i;
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-      if (c->conn == NULL)
-	continue;
-      c->tx_err_counter = c->tx_counter = c->rx_counter = 0;
-    }
-}
-
-int
-add_epoll_fd (int fd, uint32_t events)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = events;
-  evt.data.fd = fd;
-  if (epoll_ctl (epfd, EPOLL_CTL_ADD, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d added to epoll", fd);
-  return 0;
-}
-
-int
-mod_epoll_fd (int fd, uint32_t events)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = events;
-  evt.data.fd = fd;
-  if (epoll_ctl (epfd, EPOLL_CTL_MOD, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d modified on epoll", fd);
-  return 0;
-}
-
-int
-del_epoll_fd (int fd)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  if (epoll_ctl (epfd, EPOLL_CTL_DEL, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d removed from epoll", fd);
-  return 0;
-}
-
-int
-on_connect (memif_conn_handle_t conn, void *private_ctx)
-{
-  INFO ("memif connected!");
-  memif_refill_queue (conn, 0, -1, 0);
-  return 0;
-}
-
-int
-on_disconnect (memif_conn_handle_t conn, void *private_ctx)
-{
-  INFO ("memif disconnected!");
-  return 0;
-}
-
-int
-control_fd_update (int fd, uint8_t events, void *ctx)
-{
-  /* convert memif event definitions to epoll events */
-  if (events & MEMIF_FD_EVENT_DEL)
-    return del_epoll_fd (fd);
-
-  uint32_t evt = 0;
-  if (events & MEMIF_FD_EVENT_READ)
-    evt |= EPOLLIN;
-  if (events & MEMIF_FD_EVENT_WRITE)
-    evt |= EPOLLOUT;
-
-  if (events & MEMIF_FD_EVENT_MOD)
-    return mod_epoll_fd (fd, evt);
-
-  return add_epoll_fd (fd, evt);
-}
-
-int
-icmpr_memif_delete (long index)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("don't even try...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-
-  if (c->rx_bufs)
-    free (c->rx_bufs);
-  c->rx_bufs = NULL;
-  c->rx_buf_num = 0;
-  if (c->tx_bufs)
-    free (c->tx_bufs);
-  c->tx_bufs = NULL;
-  c->tx_buf_num = 0;
-
-  int err;
-  /* disconnect then delete memif connection */
-  err = memif_delete (&c->conn);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_delete: %s", memif_strerror (err));
-  if (c->conn != NULL)
-    INFO ("memif delete fail");
-  return 0;
-}
-
-int
-icmpr_free ()
-{
-  /* application cleanup */
-  int err;
-  long i;
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-      if (c->conn)
-	icmpr_memif_delete (i);
-    }
-
-  err = memif_cleanup ();
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_delete: %s", memif_strerror (err));
-
-  return 0;
-}
-
-int
-icmpr_add_external_region (void * *addr, uint32_t size, int *fd,
-			   void *private_ctx)
-{
-
-  int rfd;
-  void *raddr;
-  int err;
-
-  rfd = memfd_create ("memif region 1", MFD_ALLOW_SEALING);
-
-  fcntl (rfd, F_ADD_SEALS, F_SEAL_SHRINK);
-
-  err = ftruncate (rfd, size);
-
-  if (err)
-    return err;
-
-  raddr = mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, rfd, 0);
-
-  *addr = raddr;
-  *fd = rfd;
-
-  return 0;
-}
-
-void *
-icmpr_get_external_region_addr (uint32_t size, int fd, void *private_ctx)
-{
-  return mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-}
-
-int
-icmpr_del_external_region (void *addr, uint32_t size, int fd,
-			   void *private_ctx)
-{
-  munmap (addr, size);
-  if (fd > 0)
-    close (fd);
-  fd = -1;
-  return 0;
-}
-
-int
-on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
-{
-  long index = *((long *) private_ctx);
-  memif_connection_t *c = &memif_connection[index];
-  if (c->index != index)
-    {
-      INFO ("invalid context: %ld/%u", index, c->index);
-      return 0;
-    }
-
-  int err = MEMIF_ERR_SUCCESS, ret_val;
-  uint16_t rx = 0, tx = 0;
-  int i = 0;
-  int j = 0;
-
-  do
-    {
-      err = memif_rx_burst (c->conn, qid, c->rx_bufs, MAX_MEMIF_BUFS, &rx);
-      ret_val = err;
-      c->rx_counter += rx;
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF))
-	{
-	  INFO ("memif_rx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-      i = 0;
-      memset (c->tx_bufs, 0, sizeof (memif_buffer_t) * rx);
-      err = memif_buffer_alloc (c->conn, qid, c->tx_bufs, rx, &tx, 128);
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
-	{
-	  INFO ("memif_buffer_alloc: %s", memif_strerror (err));
-	  goto error;
-	}
-      j = 0;
-      c->tx_err_counter += rx - tx;
-
-      while (tx)
-	{
-	  resolve_packet ((void *) (c->rx_bufs + i)->data,
-			  (c->rx_bufs + i)->len,
-			  (void *) (c->tx_bufs + j)->data,
-			  &(c->tx_bufs + j)->len, c->ip_addr);
-	  i++;
-	  j++;
-	  tx--;
-	}
-
-      err = memif_refill_queue (c->conn, qid, rx, 0);
-      if (err != MEMIF_ERR_SUCCESS)
-	INFO ("memif_buffer_free: %s", memif_strerror (err));
-      rx -= rx;
-
-      DBG ("%u/%u alloc/free buffers", rx, MAX_MEMIF_BUFS - rx);
-
-      err = memif_tx_burst (c->conn, qid, c->tx_bufs, j, &tx);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  INFO ("memif_tx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-      c->tx_counter += tx;
-    }
-  while (ret_val == MEMIF_ERR_NOBUF);
-
-  return 0;
-
-error:
-  err = memif_refill_queue (c->conn, qid, rx, 0);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_buffer_free: %s", memif_strerror (err));
-  c->rx_buf_num -= rx;
-  DBG ("freed %d buffers. %u/%u alloc/free buffers", rx, c->rx_buf_num,
-       MAX_MEMIF_BUFS - c->rx_buf_num);
-  return 0;
-}
-
-int
-on_interrupt1 (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
-{
-  long index = *((long *) private_ctx);
-  memif_connection_t *c = &memif_connection[index];
-  if (c->index != index)
-    {
-      INFO ("invalid context: %ld/%u", index, c->index);
-      return 0;
-    }
-
-  int err = MEMIF_ERR_SUCCESS, ret_val;
-  int i;
-  uint16_t rx, tx;
-
-  do
-    {
-      /* receive data from shared memory buffers */
-      err = memif_rx_burst (c->conn, qid, c->rx_bufs, MAX_MEMIF_BUFS, &rx);
-      ret_val = err;
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF))
-	{
-	  INFO ("memif_rx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-      c->rx_buf_num += rx;
-      c->rx_counter += rx;
-
-      for (i = 0; i < rx; i++)
-	{
-	  if (((struct ether_header *) (c->rx_bufs + i)->data)->ether_type ==
-	      0x0608)
-	    {
-	      err =
-		memif_buffer_alloc (c->conn, qid, c->tx_bufs, 1, &tx, 128);
-	      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
-		{
-		  INFO ("memif_buffer_alloc: %s", memif_strerror (err));
-		  goto error;
-		}
-	      resolve_packet ((void *) (c->rx_bufs + i)->data,
-			      (c->rx_bufs + i)->len,
-			      (void *) (c->tx_bufs + i)->data,
-			      &(c->tx_bufs + i)->len, c->ip_addr);
-	      err =
-		memif_tx_burst (c->conn, qid, c->tx_bufs, c->tx_buf_num, &tx);
-	      if (err != MEMIF_ERR_SUCCESS)
-		INFO ("memif_tx_burst: %s", memif_strerror (err));
-	      c->tx_buf_num -= tx;
-	      c->tx_counter += tx;
-	    }
-	}
-
-      err = memif_refill_queue (c->conn, qid, rx, 0);
-      if (err != MEMIF_ERR_SUCCESS)
-	INFO ("memif_buffer_free: %s", memif_strerror (err));
-      c->rx_buf_num -= rx;
-
-
-    }
-  while (ret_val == MEMIF_ERR_NOBUF);
-
-  return 0;
-
-error:
-  err = memif_refill_queue (c->conn, qid, rx, 0);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_buffer_free: %s", memif_strerror (err));
-  c->rx_buf_num -= rx;
-  DBG ("freed %d buffers. %u/%u alloc/free buffers",
-       rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
-  return 0;
-}
-
-int
-icmpr_memif_create (long index, long mode, char *s)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-
-  memif_conn_args_t args;
-  memset (&args, 0, sizeof (args));
-  args.is_master = mode;
-  args.log2_ring_size = 11;
-  args.buffer_size = 2048;
-  args.num_s2m_rings = 1;
-  args.num_m2s_rings = 1;
-  strncpy ((char *) args.interface_name, IF_NAME, strlen (IF_NAME));
-  args.mode = 0;
-  args.interface_id = index;
-
-  int err;
-  if (s == NULL)
-    {
-      err = memif_create (&c->conn,
-			  &args, on_connect, on_disconnect, on_interrupt,
-			  &ctx[index]);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  INFO ("memif_create: %s", memif_strerror (err));
-	  return 0;
-	}
-    }
-  else
-    {
-      if (strncmp (s, "1", 1) == 0)
-	{
-	  err = memif_create (&c->conn,
-			      &args, on_connect, on_disconnect, on_interrupt1,
-			      &ctx[index]);
-	  if (err != MEMIF_ERR_SUCCESS)
-	    {
-	      INFO ("memif_create: %s", memif_strerror (err));
-	      return 0;
-	    }
-	}
-      else
-	{
-	  INFO ("Unknown interrupt descriptor");
-	  goto done;
-	}
-    }
-
-  c->index = index;
-  c->rx_buf_num = 0;
-  c->rx_bufs =
-    (memif_buffer_t *) malloc (sizeof (memif_buffer_t) * MAX_MEMIF_BUFS);
-  c->tx_buf_num = 0;
-  c->tx_bufs =
-    (memif_buffer_t *) malloc (sizeof (memif_buffer_t) * MAX_MEMIF_BUFS);
-
-  c->ip_addr[0] = 192;
-  c->ip_addr[1] = 168;
-  c->ip_addr[2] = c->index + 1;
-  c->ip_addr[3] = 2;
-
-done:
-  return 0;
-}
-
-void *
-icmpr_send_proc (void *data)
-{
-  icmpr_thread_data_t *d = (icmpr_thread_data_t *) data;
-  int index = d->index;
-  uint64_t count = d->packet_num;
-  memif_connection_t *c = &memif_connection[index];
-  if (c->conn == NULL)
-    {
-      INFO ("No connection at index %d.", index);
-      goto error;
-    }
-  uint16_t tx, i;
-  int err = MEMIF_ERR_SUCCESS;
-  uint32_t seq = 0;
-  struct timespec start, end;
-  memset (&start, 0, sizeof (start));
-  memset (&end, 0, sizeof (end));
-
-  timespec_get (&start, TIME_UTC);
-  while (count)
-    {
-      i = 0;
-      err =
-	memif_buffer_alloc (c->conn, 0, c->tx_bufs,
-			    MAX_MEMIF_BUFS > count ? count : MAX_MEMIF_BUFS,
-			    &tx, 128);
-
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
-	{
-	  INFO ("memif_buffer_alloc: %s", memif_strerror (err));
-	  goto error;
-	}
-      c->tx_buf_num += tx;
-
-      while (tx)
-	{
-	  while (tx > 4)
-	    {
-	      generate_packet ((void *) c->tx_bufs[i].data,
-			       &c->tx_bufs[i].len, c->ip_addr, d->ip_daddr,
-			       d->hw_daddr, seq++);
-	      generate_packet ((void *) c->tx_bufs[i + 1].data,
-			       &c->tx_bufs[i + 1].len, c->ip_addr,
-			       d->ip_daddr, d->hw_daddr, seq++);
-	      generate_packet ((void *) c->tx_bufs[i + 2].data,
-			       &c->tx_bufs[i + 2].len, c->ip_addr,
-			       d->ip_daddr, d->hw_daddr, seq++);
-	      generate_packet ((void *) c->tx_bufs[i + 3].data,
-			       &c->tx_bufs[i + 3].len, c->ip_addr,
-			       d->ip_daddr, d->hw_daddr, seq++);
-	      i += 4;
-	      tx -= 4;
-	    }
-	  generate_packet ((void *) c->tx_bufs[i].data, &c->tx_bufs[i].len,
-			   c->ip_addr, d->ip_daddr, d->hw_daddr, seq++);
-	  i++;
-	  tx--;
-	}
-
-      err = memif_tx_burst (c->conn, 0, c->tx_bufs, c->tx_buf_num, &tx);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  INFO ("memif_tx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-      c->tx_buf_num -= tx;
-      c->tx_counter += tx;
-      count -= tx;
-    }
-
-  timespec_get (&end, TIME_UTC);
-  INFO ("\n\nPacket sequence finished!\nSeq len: %u", seq);
-  uint64_t t1 = end.tv_sec - start.tv_sec;
-  uint64_t t2;
-  if (end.tv_nsec > start.tv_nsec)
-    {
-      t2 = end.tv_nsec - start.tv_nsec;
-    }
-  else
-    {
-      t2 = start.tv_nsec - end.tv_nsec;
-      t1--;
-    }
-  c->t_sec = t1;
-  c->t_nsec = t2;
-  double tmp = t1;
-  tmp += t2 / 1e+9;
-  tmp = seq / tmp;
-  INFO ("Seq time: %lus %luns\nAverage pps: %f", t1, t2, tmp);
-
-error:
-  INFO ("Thread exiting...");
-  pthread_exit (NULL);
-}
-
-
-int
-icmpr_send (long index, long packet_num, char *hw, char *ip)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-  if (c->conn == NULL)
-    return -1;
-  char *end, *ui;
-  uint8_t tmp[6];
-  icmpr_thread_data_t *data = &icmpr_thread_data[index];
-  data->index = index;
-  data->packet_num = packet_num;
-
-  ui = strtok (ip, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[0] = strtol (ui, &end, 10);
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[1] = strtol (ui, &end, 10);
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[2] = strtol (ui, &end, 10);
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[3] = strtol (ui, &end, 10);
-
-  data->ip_daddr[0] = tmp[0];
-  data->ip_daddr[1] = tmp[1];
-  data->ip_daddr[2] = tmp[2];
-  data->ip_daddr[3] = tmp[3];
-
-  ui = strtok (hw, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[0] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[1] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[2] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[3] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[4] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[5] = strtol (ui, &end, 16);
-
-  pthread_create (&thread[index], NULL, icmpr_send_proc, (void *) data);
-  return 0;
-
-error:
-  INFO ("Invalid input\n");
-  return 0;
-}
-
-int
-user_input_handler ()
-{
-  char *in = (char *) malloc (256);
-  char *ui = fgets (in, 256, stdin);
-  char *end;
-  long a;
-
-  if (in[0] == '\n')
-    goto done;
-
-  ui = strtok (in, " ");
-
-  if (strncmp (ui, "exit", 4) == 0)
-    {
-      free (in);
-      icmpr_free ();
-      exit (EXIT_SUCCESS);
-    }
-  else if (strncmp (ui, "help", 4) == 0)
-    {
-      print_help ();
-      goto done;
-    }
-  else if (strncmp (ui, "conn", 4) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	a = strtol (ui, &end, 10);
-      else
-	{
-	  INFO ("expected id");
-	  goto done;
-	}
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_memif_create (a, strtol (ui, &end, 10), strtok (NULL, " "));
-      else
-	INFO ("expected mode <0|1>");
-      goto done;
-    }
-  else if (strncmp (ui, "del", 3) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_memif_delete (strtol (ui, &end, 10));
-      else
-	{
-	  INFO ("expected id");
-	  goto done;
-	}
-    }
-  else if (strncmp (ui, "send", 4) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	a = strtol (ui, &end, 10);
-      else
-	{
-	  INFO ("expected id");
-	  goto done;
-	}
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_send (a, strtol (ui, &end, 10), strtok (NULL, " "),
-		    strtok (NULL, " "));
-      else
-	INFO ("expected count");
-      goto done;
-    }
-  else if (strncmp (ui, "show", 4) == 0)
-    {
-      print_memif_details ();
-      goto done;
-    }
-
-done:
-  free (in);
-  return 0;
-}
-
-int
-poll_event (int timeout)
-{
-  struct epoll_event evt;
-  int app_err = 0, memif_err = 0, en = 0;
-  uint32_t events = 0;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = EPOLLIN | EPOLLOUT;
-  sigset_t sigset;
-  sigemptyset (&sigset);
-  en = epoll_pwait (epfd, &evt, 1, timeout, &sigset);
-  /* id event polled */
-  if (en < 0)
-    {
-      DBG ("epoll_pwait: %s", strerror (errno));
-      return -1;
-    }
-  if (en > 0)
-    {
-      /* this app does not use any other file descriptors than stds and memif control fds */
-      if (evt.data.fd > 2)
-	{
-	  /* event of memif control fd */
-	  /* convert epoll events to memif events */
-	  if (evt.events & EPOLLIN)
-	    events |= MEMIF_FD_EVENT_READ;
-	  if (evt.events & EPOLLOUT)
-	    events |= MEMIF_FD_EVENT_WRITE;
-	  if (evt.events & EPOLLERR)
-	    events |= MEMIF_FD_EVENT_ERROR;
-	  memif_err = memif_control_fd_handler (evt.data.fd, events);
-	  if (memif_err != MEMIF_ERR_SUCCESS)
-	    INFO ("memif_control_fd_handler: %s", memif_strerror (memif_err));
-	}
-      else if (evt.data.fd == 0)
-	{
-	  app_err = user_input_handler ();
-	}
-      else
-	{
-	  DBG ("unexpected event at memif_epfd. fd %d", evt.data.fd);
-	}
-    }
-
-  if ((app_err < 0) || (memif_err < 0))
-    {
-      if (app_err < 0)
-	DBG ("user input handler error");
-      if (memif_err < 0)
-	DBG ("memif control fd handler error");
-      return -1;
-    }
-
-  return 0;
-}
-
-int
-main ()
-{
-  epfd = epoll_create (1);
-  add_epoll_fd (0, EPOLLIN);
-
-  /* initialize memory interface */
-  int err, i;
-  /* if valid callback is passed as argument, fd event polling will be done by user
-     all file descriptors and events will be passed to user in this callback */
-  /* if callback is set to NULL libmemif will handle fd event polling */
-  err = memif_init (control_fd_update, APP_NAME, NULL, NULL, NULL);
-  if (err != MEMIF_ERR_SUCCESS)
-    {
-      INFO ("memif_init: %s", memif_strerror (err));
-      icmpr_free ();
-      exit (-1);
-    }
-
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memset (&memif_connection[i], 0, sizeof (memif_connection_t));
-      ctx[i] = i;
-    }
-
-  memif_register_external_region (icmpr_add_external_region,
-				  icmpr_get_external_region_addr,
-				  icmpr_del_external_region, NULL);
-
-  print_help ();
-
-  /* main loop */
-  while (1)
-    {
-      if (poll_event (-1) < 0)
-	{
-	  DBG ("poll_event error!");
-	}
-    }
-}
diff --git a/extras/libmemif/examples/icmp_responder-epoll/main.c b/extras/libmemif/examples/icmp_responder-epoll/main.c
deleted file mode 100644
index c2ea348..0000000
--- a/extras/libmemif/examples/icmp_responder-epoll/main.c
+++ /dev/null
@@ -1,1320 +0,0 @@
-/*
- *------------------------------------------------------------------
- * 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.
- *------------------------------------------------------------------
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <net/if.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/uio.h>
-#include <sys/mman.h>
-#include <sys/prctl.h>
-#include <inttypes.h>
-#include <string.h>
-#include <stdio.h>
-#include <netdb.h>
-#include <linux/ip.h>
-#include <linux/icmp.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-#include <netinet/if_ether.h>
-#include <net/if_arp.h>
-#include <asm/byteorder.h>
-#include <byteswap.h>
-#include <string.h>
-#include <sys/epoll.h>
-#include <errno.h>
-#include <unistd.h>
-#include <signal.h>
-#include <pthread.h>
-
-#include <time.h>
-
-#ifndef TIME_UTC
-#define TIME_UTC 1
-#endif
-
-#include <libmemif.h>
-#include <icmp_proto.h>
-
-#define APP_NAME "ICMP_Responder"
-#define IF_NAME  "memif_connection"
-
-
-#ifdef ICMP_DBG
-#define DBG(...) do {                                               \
-                    printf (APP_NAME":%s:%d: ", __func__, __LINE__);         \
-                    printf (__VA_ARGS__);                           \
-                    printf ("\n");                                  \
-                } while (0)
-#define LOG(...) do {                                               \
-                    if (enable_log) {                               \
-                        dprintf (out_fd, __VA_ARGS__);              \
-                        dprintf (out_fd, "\n");                     \
-                    }                                               \
-                } while (0)
-#define LOG_FILE "/tmp/memif_time_test.txt"
-#else
-#define DBG(...)
-#define LOG(...)
-#endif
-
-#define INFO(...) do {                                              \
-                    printf ("INFO: "__VA_ARGS__);                   \
-                    printf ("\n");                                  \
-                } while (0)
-
-
-/* maximum tx/rx memif buffers */
-#define MAX_MEMIF_BUFS  256
-#define MAX_CONNS       50
-
-#define ICMPR_HEADROOM	64
-
-int epfd;
-int out_fd;
-uint8_t enable_log;
-
-typedef struct
-{
-  uint16_t index;
-  /* memif connection handle */
-  memif_conn_handle_t conn;
-  /* tx buffers */
-  memif_buffer_t *tx_bufs;
-  /* allocated tx buffers counter */
-  /* number of tx buffers pointing to shared memory */
-  uint16_t tx_buf_num;
-  /* rx buffers */
-  memif_buffer_t *rx_bufs;
-  /* allocated rx buffers counter */
-  /* number of rx buffers pointing to shared memory */
-  uint16_t rx_buf_num;
-  /* interface ip address */
-  uint8_t ip_addr[4];
-  uint16_t seq;
-  uint64_t tx_counter, rx_counter, tx_err_counter;
-  uint64_t t_sec, t_nsec;
-} memif_connection_t;
-
-typedef struct
-{
-  uint16_t index;
-  uint64_t packet_num;
-  uint8_t ip_daddr[4];
-  uint8_t hw_daddr[6];
-} icmpr_thread_data_t;
-
-memif_connection_t memif_connection[MAX_CONNS];
-icmpr_thread_data_t icmpr_thread_data[MAX_CONNS];
-pthread_t thread[MAX_CONNS];
-long ctx[MAX_CONNS];
-
-/* print details for all memif connections */
-static void
-print_memif_details ()
-{
-  memif_details_t md;
-  ssize_t buflen;
-  char *buf;
-  int err, i, e;
-  buflen = 2048;
-  buf = malloc (buflen);
-  printf ("MEMIF DETAILS\n");
-  printf ("==============================\n");
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-
-      memset (&md, 0, sizeof (md));
-      memset (buf, 0, buflen);
-
-      err = memif_get_details (c->conn, &md, buf, buflen);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  if (err != MEMIF_ERR_NOCONN)
-	    INFO ("%s", memif_strerror (err));
-	  continue;
-	}
-
-      printf ("interface index: %d\n", i);
-
-      printf ("\tinterface ip: %u.%u.%u.%u\n",
-	      c->ip_addr[0], c->ip_addr[1], c->ip_addr[2], c->ip_addr[3]);
-      printf ("\tinterface name: %s\n", (char *) md.if_name);
-      printf ("\tapp name: %s\n", (char *) md.inst_name);
-      printf ("\tremote interface name: %s\n", (char *) md.remote_if_name);
-      printf ("\tremote app name: %s\n", (char *) md.remote_inst_name);
-      printf ("\tid: %u\n", md.id);
-      printf ("\tsecret: %s\n", (char *) md.secret);
-      printf ("\trole: ");
-      if (md.role)
-	printf ("slave\n");
-      else
-	printf ("master\n");
-      printf ("\tmode: ");
-      switch (md.mode)
-	{
-	case 0:
-	  printf ("ethernet\n");
-	  break;
-	case 1:
-	  printf ("ip\n");
-	  break;
-	case 2:
-	  printf ("punt/inject\n");
-	  break;
-	default:
-	  printf ("unknown\n");
-	  break;
-	}
-      printf ("\tsocket filename: %s\n", (char *) md.socket_filename);
-      printf ("\trx queues:\n");
-      for (e = 0; e < md.rx_queues_num; e++)
-	{
-	  printf ("\t\tqueue id: %u\n", md.rx_queues[e].qid);
-	  printf ("\t\tring size: %u\n", md.rx_queues[e].ring_size);
-	  printf ("\t\tring rx mode: %s\n",
-		  md.rx_queues[e].flags ? "polling" : "interrupt");
-	  printf ("\t\tring head: %u\n", md.rx_queues[e].head);
-	  printf ("\t\tring tail: %u\n", md.rx_queues[e].tail);
-	  printf ("\t\tbuffer size: %u\n", md.rx_queues[e].buffer_size);
-	}
-      printf ("\ttx queues:\n");
-      for (e = 0; e < md.tx_queues_num; e++)
-	{
-	  printf ("\t\tqueue id: %u\n", md.tx_queues[e].qid);
-	  printf ("\t\tring size: %u\n", md.tx_queues[e].ring_size);
-	  printf ("\t\tring rx mode: %s\n",
-		  md.tx_queues[e].flags ? "polling" : "interrupt");
-	  printf ("\t\tring head: %u\n", md.tx_queues[e].head);
-	  printf ("\t\tring tail: %u\n", md.tx_queues[e].tail);
-	  printf ("\t\tbuffer size: %u\n", md.tx_queues[e].buffer_size);
-	}
-      printf ("\tlink: ");
-      if (md.link_up_down)
-	printf ("up\n");
-      else
-	{
-	  printf ("down\n");
-	  printf ("\treason: %s\n", md.error);
-	}
-    }
-  free (buf);
-}
-
-int
-add_epoll_fd (int fd, uint32_t events)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = events;
-  evt.data.fd = fd;
-  if (epoll_ctl (epfd, EPOLL_CTL_ADD, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d added to epoll", fd);
-  return 0;
-}
-
-int
-mod_epoll_fd (int fd, uint32_t events)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = events;
-  evt.data.fd = fd;
-  if (epoll_ctl (epfd, EPOLL_CTL_MOD, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d modified on epoll", fd);
-  return 0;
-}
-
-int
-del_epoll_fd (int fd)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  if (epoll_ctl (epfd, EPOLL_CTL_DEL, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d removed from epoll", fd);
-  return 0;
-}
-
-/* informs user about connected status. private_ctx is used by user to identify connection
-    (multiple connections WIP) */
-int
-on_connect (memif_conn_handle_t conn, void *private_ctx)
-{
-  INFO ("memif connected!");
-  memif_refill_queue (conn, 0, -1, ICMPR_HEADROOM);
-  enable_log = 1;
-  return 0;
-}
-
-/* informs user about disconnected status. private_ctx is used by user to identify connection
-    (multiple connections WIP) */
-int
-on_disconnect (memif_conn_handle_t conn, void *private_ctx)
-{
-  INFO ("memif disconnected!");
-  return 0;
-}
-
-/* user needs to watch new fd or stop watching fd that is about to be closed.
-    control fd will be modified during connection establishment to minimize CPU usage */
-int
-control_fd_update (int fd, uint8_t events, void *ctx)
-{
-  /* convert memif event definitions to epoll events */
-  if (events & MEMIF_FD_EVENT_DEL)
-    return del_epoll_fd (fd);
-
-  uint32_t evt = 0;
-  if (events & MEMIF_FD_EVENT_READ)
-    evt |= EPOLLIN;
-  if (events & MEMIF_FD_EVENT_WRITE)
-    evt |= EPOLLOUT;
-
-  if (events & MEMIF_FD_EVENT_MOD)
-    return mod_epoll_fd (fd, evt);
-
-  return add_epoll_fd (fd, evt);
-}
-
-int
-icmpr_buffer_alloc (long index, long n, uint16_t * r, uint16_t i,
-		    uint16_t qid)
-{
-  memif_connection_t *c = &memif_connection[index];
-  int err;
-  /* set data pointer to shared memory and set buffer_len to shared memory buffer len */
-  err = memif_buffer_alloc (c->conn, qid, c->tx_bufs + i, n, r, 128);
-  if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
-    {
-      INFO ("memif_buffer_alloc: %s", memif_strerror (err));
-      return -1;
-    }
-  c->tx_buf_num += *r;
-  DBG ("allocated %d/%ld buffers, %u free buffers", *r, n,
-       MAX_MEMIF_BUFS - c->tx_buf_num);
-  return 0;
-}
-
-int
-icmpr_tx_burst (long index, uint16_t qid)
-{
-  memif_connection_t *c = &memif_connection[index];
-  int err;
-  uint16_t r;
-  /* inform peer memif interface about data in shared memory buffers */
-  /* mark memif buffers as free */
-  err = memif_tx_burst (c->conn, qid, c->tx_bufs, c->tx_buf_num, &r);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_tx_burst: %s", memif_strerror (err));
-  c->tx_buf_num -= r;
-  c->tx_counter += r;
-  return 0;
-}
-
-/* called when event is polled on interrupt file descriptor.
-    there are packets in shared memory ready to be received */
-int
-on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
-{
-  long index = *((long *) private_ctx);
-  memif_connection_t *c = &memif_connection[index];
-  if (c->index != index)
-    {
-      INFO ("invalid context: %ld/%u", index, c->index);
-      return 0;
-    }
-
-  int err = MEMIF_ERR_SUCCESS, ret_val;
-  uint16_t rx = 0, tx = 0;
-  int i = 0;			/* rx buffer iterator */
-  int j = 0;			/* tx buffer iterator */
-
-  /* loop while there are packets in shm */
-  do
-    {
-      /* receive data from shared memory buffers */
-      err = memif_rx_burst (c->conn, qid, c->rx_bufs, MAX_MEMIF_BUFS, &rx);
-      ret_val = err;
-      c->rx_counter += rx;
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF))
-	{
-	  INFO ("memif_rx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-
-      i = 0;
-      memset (c->tx_bufs, 0, sizeof (memif_buffer_t) * rx);
-      err = memif_buffer_alloc (c->conn, qid, c->tx_bufs, rx, &tx, 128);
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
-	{
-	  INFO ("memif_buffer_alloc: %s", memif_strerror (err));
-	  goto error;
-	}
-      j = 0;
-      c->tx_err_counter += rx - tx;
-
-      while (tx)
-	{
-	  resolve_packet ((void *) (c->rx_bufs + i)->data,
-			  (c->rx_bufs + i)->len,
-			  (void *) (c->tx_bufs + j)->data,
-			  &(c->tx_bufs + j)->len, c->ip_addr);
-	  i++;
-	  j++;
-	  tx--;
-	}
-
-      err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
-      if (err != MEMIF_ERR_SUCCESS)
-	INFO ("memif_buffer_free: %s", memif_strerror (err));
-      rx -= rx;
-
-      DBG ("%u/%u alloc/free buffers", rx, MAX_MEMIF_BUFS - rx);
-
-      err = memif_tx_burst (c->conn, qid, c->tx_bufs, j, &tx);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  INFO ("memif_tx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-      c->tx_counter += tx;
-
-    }
-  while (ret_val == MEMIF_ERR_NOBUF);
-
-  return 0;
-
-error:
-  err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_buffer_free: %s", memif_strerror (err));
-  c->rx_buf_num -= rx;
-  DBG ("freed %d buffers. %u/%u alloc/free buffers",
-       rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
-  return 0;
-}
-
-/* called when event is polled on interrupt file descriptor.
-    there are packets in shared memory ready to be received */
-/* dev test modification: loop until TX == RX (don't drop buffers) */
-int
-on_interrupt0 (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
-{
-  long index = *((long *) private_ctx);
-  memif_connection_t *c = &memif_connection[index];
-  if (c->index != index)
-    {
-      INFO ("invalid context: %ld/%u", index, c->index);
-      return 0;
-    }
-
-  int err = MEMIF_ERR_SUCCESS, ret_val;
-  uint16_t rx = 0, tx = 0;
-  int i;			/* rx buffer iterator */
-  int j;			/* tx bufferiterator */
-
-  /* loop while there are packets in shm */
-  do
-    {
-      /* receive data from shared memory buffers */
-      err = memif_rx_burst (c->conn, qid, c->rx_bufs, MAX_MEMIF_BUFS, &rx);
-      ret_val = err;
-      c->rx_counter += rx;
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF))
-	{
-	  INFO ("memif_rx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-
-      i = 0;
-
-      /* loop while there are RX buffers to be processed */
-      while (rx)
-	{
-
-	  /* try to alloc required number of buffers buffers */
-	  err = memif_buffer_alloc (c->conn, qid, c->tx_bufs, rx, &tx, 128);
-	  if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
-	    {
-	      INFO ("memif_buffer_alloc: %s", memif_strerror (err));
-	      goto error;
-	    }
-	  j = 0;
-
-	  /* process buffers */
-	  while (tx)
-	    {
-	      while (tx > 2)
-		{
-		  resolve_packet ((void *) (c->rx_bufs + i)->data,
-				  (c->rx_bufs + i)->len,
-				  (void *) (c->tx_bufs + j)->data,
-				  &(c->tx_bufs + j)->len, c->ip_addr);
-		  resolve_packet ((void *) (c->rx_bufs + i + 1)->data,
-				  (c->rx_bufs + i + 1)->len,
-				  (void *) (c->tx_bufs + j + 1)->data,
-				  &(c->tx_bufs + j + 1)->len, c->ip_addr);
-
-		  i += 2;
-		  j += 2;
-		  tx -= 2;
-		}
-	      resolve_packet ((void *) (c->rx_bufs + i)->data,
-			      (c->rx_bufs + i)->len,
-			      (void *) (c->tx_bufs + j)->data,
-			      &(c->tx_bufs + j)->len, c->ip_addr);
-	      i++;
-	      j++;
-	      tx--;
-	    }
-	  /* mark memif buffers and shared memory buffers as free */
-	  /* free processed buffers */
-	  err = memif_refill_queue (c->conn, qid, j, ICMPR_HEADROOM);
-	  if (err != MEMIF_ERR_SUCCESS)
-	    INFO ("memif_buffer_free: %s", memif_strerror (err));
-	  rx -= j;
-
-	  DBG ("freed %d buffers. %u/%u alloc/free buffers",
-	       rx, rx, MAX_MEMIF_BUFS - rx);
-
-	  /* transmit allocated buffers */
-	  err = memif_tx_burst (c->conn, qid, c->tx_bufs, j, &tx);
-	  if (err != MEMIF_ERR_SUCCESS)
-	    {
-	      INFO ("memif_tx_burst: %s", memif_strerror (err));
-	      goto error;
-	    }
-	  c->tx_counter += tx;
-
-	}
-
-    }
-  while (ret_val == MEMIF_ERR_NOBUF);
-
-  return 0;
-
-error:
-  err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_buffer_free: %s", memif_strerror (err));
-  c->rx_buf_num -= rx;
-  DBG ("freed %d buffers. %u/%u alloc/free buffers",
-       rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
-  return 0;
-}
-
-/* called when event is polled on interrupt file descriptor.
-    there are packets in shared memory ready to be received */
-/* dev test modification: handle only ARP requests */
-int
-on_interrupt1 (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
-{
-  long index = *((long *) private_ctx);
-  memif_connection_t *c = &memif_connection[index];
-  if (c->index != index)
-    {
-      INFO ("invalid context: %ld/%u", index, c->index);
-      return 0;
-    }
-
-  int err = MEMIF_ERR_SUCCESS, ret_val;
-  int i;
-  uint16_t rx, tx;
-
-  do
-    {
-      /* receive data from shared memory buffers */
-      err = memif_rx_burst (c->conn, qid, c->rx_bufs, MAX_MEMIF_BUFS, &rx);
-      ret_val = err;
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF))
-	{
-	  INFO ("memif_rx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-      c->rx_buf_num += rx;
-      c->rx_counter += rx;
-
-      for (i = 0; i < rx; i++)
-	{
-	  if (((struct ether_header *) (c->rx_bufs + i)->data)->ether_type ==
-	      0x0608)
-	    {
-	      if (icmpr_buffer_alloc (c->index, 1, &tx, i, qid) < 0)
-		break;
-	      resolve_packet ((void *) (c->rx_bufs + i)->data,
-			      (c->rx_bufs + i)->len,
-			      (void *) (c->tx_bufs + i)->data,
-			      &(c->tx_bufs + i)->len, c->ip_addr);
-	      icmpr_tx_burst (c->index, qid);
-	    }
-	}
-
-      err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
-      if (err != MEMIF_ERR_SUCCESS)
-	INFO ("memif_buffer_free: %s", memif_strerror (err));
-      c->rx_buf_num -= rx;
-
-
-    }
-  while (ret_val == MEMIF_ERR_NOBUF);
-
-  return 0;
-
-error:
-  err = memif_refill_queue (c->conn, qid, rx, ICMPR_HEADROOM);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_buffer_free: %s", memif_strerror (err));
-  c->rx_buf_num -= rx;
-  DBG ("freed %d buffers. %u/%u alloc/free buffers",
-       rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
-  return 0;
-}
-
-int
-icmpr_memif_create (long index, long mode, char *s)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("don't even try...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-
-  /* setting memif connection arguments */
-  memif_conn_args_t args;
-  memset (&args, 0, sizeof (args));
-  args.is_master = mode;
-  args.log2_ring_size = 11;
-  args.buffer_size = 2048;
-  args.num_s2m_rings = 1;
-  args.num_m2s_rings = 1;
-  strncpy ((char *) args.interface_name, IF_NAME, strlen (IF_NAME));
-  args.mode = 0;
-  /* socket filename is not specified, because this app is supposed to
-     connect to VPP over memif. so default socket filename will be used */
-  /* default socketfile = /run/vpp/memif.sock */
-
-  args.interface_id = index;
-  /* last argument for memif_create (void * private_ctx) is used by user
-     to identify connection. this context is returned with callbacks */
-  int err;
-  /* default interrupt */
-  if (s == NULL)
-    {
-      err = memif_create (&c->conn,
-			  &args, on_connect, on_disconnect, on_interrupt,
-			  &ctx[index]);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  INFO ("memif_create: %s", memif_strerror (err));
-	  return 0;
-	}
-    }
-  else
-    {
-      if (strncmp (s, "0", 1) == 0)
-	{
-	  err = memif_create (&c->conn,
-			      &args, on_connect, on_disconnect, on_interrupt0,
-			      &ctx[index]);
-	  if (err != MEMIF_ERR_SUCCESS)
-	    {
-	      INFO ("memif_create: %s", memif_strerror (err));
-	      return 0;
-	    }
-	}
-      else if (strncmp (s, "1", 1) == 0)
-	{
-	  err = memif_create (&c->conn,
-			      &args, on_connect, on_disconnect, on_interrupt1,
-			      &ctx[index]);
-	  if (err != MEMIF_ERR_SUCCESS)
-	    {
-	      INFO ("memif_create: %s", memif_strerror (err));
-	      return 0;
-	    }
-	}
-      else
-	{
-	  INFO ("Unknown interrupt descriptor");
-	  goto done;
-	}
-    }
-
-  c->index = index;
-  /* alloc memif buffers */
-  c->rx_buf_num = 0;
-  c->rx_bufs =
-    (memif_buffer_t *) malloc (sizeof (memif_buffer_t) * MAX_MEMIF_BUFS);
-  c->tx_buf_num = 0;
-  c->tx_bufs =
-    (memif_buffer_t *) malloc (sizeof (memif_buffer_t) * MAX_MEMIF_BUFS);
-
-  c->ip_addr[0] = 192;
-  c->ip_addr[1] = 168;
-  c->ip_addr[2] = c->index + 1;
-  c->ip_addr[3] = 2;
-
-  c->seq = c->tx_err_counter = c->tx_counter = c->rx_counter = 0;
-
-done:
-  return 0;
-}
-
-int
-icmpr_memif_delete (long index)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("don't even try...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-
-  if (c->rx_bufs)
-    free (c->rx_bufs);
-  c->rx_bufs = NULL;
-  c->rx_buf_num = 0;
-  if (c->tx_bufs)
-    free (c->tx_bufs);
-  c->tx_bufs = NULL;
-  c->tx_buf_num = 0;
-
-  int err;
-  /* disconnect then delete memif connection */
-  err = memif_delete (&c->conn);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_delete: %s", memif_strerror (err));
-  if (c->conn != NULL)
-    INFO ("memif delete fail");
-  return 0;
-}
-
-void
-print_help ()
-{
-  printf ("LIBMEMIF EXAMPLE APP: %s", APP_NAME);
-#ifdef ICMP_DBG
-  printf (" (debug)");
-#endif
-  printf ("\n");
-  printf ("==============================\n");
-  printf ("libmemif version: %s", LIBMEMIF_VERSION);
-#ifdef MEMIF_DBG
-  printf (" (debug)");
-#endif
-  printf ("\n");
-  printf ("memif version: %d\n", memif_get_version ());
-  printf ("commands:\n");
-  printf ("\thelp - prints this help\n");
-  printf ("\texit - exit app\n");
-  printf
-    ("\tconn <index> <mode> [<interrupt-desc>] - create memif. index is also used as interface id, mode 0 = slave 1 = master, interrupt-desc none = default 0 = if ring is full wait 1 = handle only ARP requests\n");
-  printf ("\tdel  <index> - delete memif\n");
-  printf ("\tshow - show connection details\n");
-  printf ("\tip-set <index> <ip-addr> - set interface ip address\n");
-  printf
-    ("\trx-mode <index> <qid> <polling|interrupt> - set queue rx mode\n");
-  printf ("\tsh-count - print counters\n");
-  printf ("\tcl-count - clear counters\n");
-  printf ("\tsend <index> <tx> <ip> <mac> - send icmp\n");
-}
-
-int
-icmpr_free ()
-{
-  /* application cleanup */
-  int err;
-  long i;
-  if (out_fd > 0)
-    close (out_fd);
-  out_fd = -1;
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-      if (c->conn)
-	icmpr_memif_delete (i);
-    }
-
-  err = memif_cleanup ();
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_delete: %s", memif_strerror (err));
-
-  return 0;
-}
-
-int
-icmpr_set_ip (long index, char *ip)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("don't even try...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-  if (c->conn == NULL)
-    {
-      INFO ("no connection at index %ld", index);
-      return 0;
-    }
-
-  char *end;
-  char *ui;
-  uint8_t tmp[4];
-  ui = strtok (ip, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[0] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[1] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[2] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[3] = strtol (ui, &end, 10);
-
-  c->ip_addr[0] = tmp[0];
-  c->ip_addr[1] = tmp[1];
-  c->ip_addr[2] = tmp[2];
-  c->ip_addr[3] = tmp[3];
-
-  INFO ("memif %ld ip address set to %u.%u.%u.%u",
-	index, c->ip_addr[0], c->ip_addr[1], c->ip_addr[2], c->ip_addr[3]);
-
-  return 0;
-
-error:
-  INFO ("invalid ip address");
-  return 0;
-}
-
-int
-icmpr_set_rx_mode (long index, long qid, char *mode)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("don't even try...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-
-  if (c->conn == NULL)
-    {
-      INFO ("no connection at index %ld", index);
-      return 0;
-    }
-
-  if (strncmp (mode, "interrupt", 9) == 0)
-    {
-      memif_set_rx_mode (c->conn, MEMIF_RX_MODE_INTERRUPT, qid);
-    }
-
-  else if (strncmp (mode, "polling", 7) == 0)
-    {
-      memif_set_rx_mode (c->conn, MEMIF_RX_MODE_POLLING, qid);
-    }
-  else
-    INFO ("expected rx mode <interrupt|polling>");
-  return 0;
-}
-
-void
-icmpr_print_counters ()
-{
-  int i;
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-      if (c->conn == NULL)
-	continue;
-      printf ("===============================\n");
-      printf ("interface index: %d\n", c->index);
-      printf ("\trx: %lu\n", c->rx_counter);
-      printf ("\ttx: %lu\n", c->tx_counter);
-      printf ("\ttx_err: %lu\n", c->tx_err_counter);
-      printf ("\tts: %lus %luns\n", c->t_sec, c->t_nsec);
-    }
-}
-
-void
-icmpr_reset_counters ()
-{
-  int i;
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-      if (c->conn == NULL)
-	continue;
-      c->t_sec = c->t_nsec = c->tx_err_counter = c->tx_counter =
-	c->rx_counter = 0;
-    }
-}
-
-void *
-icmpr_send_proc (void *data)
-{
-  icmpr_thread_data_t *d = (icmpr_thread_data_t *) data;
-  int index = d->index;
-  uint64_t count = d->packet_num;
-  memif_connection_t *c = &memif_connection[index];
-  if (c->conn == NULL)
-    {
-      INFO ("No connection at index %d. Thread exiting...\n", index);
-      pthread_exit (NULL);
-    }
-  uint16_t tx, i;
-  int err = MEMIF_ERR_SUCCESS;
-  uint32_t seq = 0;
-  struct timespec start, end;
-  memset (&start, 0, sizeof (start));
-  memset (&end, 0, sizeof (end));
-
-  timespec_get (&start, TIME_UTC);
-  while (count)
-    {
-      i = 0;
-      err = memif_buffer_alloc (c->conn, 0, c->tx_bufs,
-				MAX_MEMIF_BUFS >
-				count ? count : MAX_MEMIF_BUFS, &tx, 128);
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
-	{
-	  INFO ("memif_buffer_alloc: %s Thread exiting...\n",
-		memif_strerror (err));
-	  pthread_exit (NULL);
-	}
-      c->tx_buf_num += tx;
-
-      while (tx)
-	{
-	  while (tx > 2)
-	    {
-	      generate_packet ((void *) c->tx_bufs[i].data,
-			       &c->tx_bufs[i].len, c->ip_addr,
-			       d->ip_daddr, d->hw_daddr, seq++);
-	      generate_packet ((void *) c->tx_bufs[i + 1].data,
-			       &c->tx_bufs[i + 1].len, c->ip_addr,
-			       d->ip_daddr, d->hw_daddr, seq++);
-	      i += 2;
-	      tx -= 2;
-	    }
-	  generate_packet ((void *) c->tx_bufs[i].data,
-			   &c->tx_bufs[i].len, c->ip_addr,
-			   d->ip_daddr, d->hw_daddr, seq++);
-	  i++;
-	  tx--;
-	}
-      err = memif_tx_burst (c->conn, 0, c->tx_bufs, c->tx_buf_num, &tx);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  INFO ("memif_tx_burst: %s Thread exiting...\n",
-		memif_strerror (err));
-	  pthread_exit (NULL);
-	}
-      c->tx_buf_num -= tx;
-      c->tx_counter += tx;
-      count -= tx;
-    }
-  timespec_get (&end, TIME_UTC);
-  printf ("\n\n");
-  INFO ("Packet sequence finished!");
-  INFO ("Seq len: %u", seq);
-  uint64_t t1 = end.tv_sec - start.tv_sec;
-  uint64_t t2;
-  if (end.tv_nsec > start.tv_nsec)
-    {
-      t2 = end.tv_nsec - start.tv_nsec;
-    }
-  else
-    {
-      t2 = start.tv_nsec - end.tv_nsec;
-      t1--;
-    }
-  c->t_sec = t1;
-  c->t_nsec = t2;
-  INFO ("Seq time: %lus %luns", t1, t2);
-  double tmp = t1;
-  tmp += t2 / 1e+9;
-  tmp = seq / tmp;
-  INFO ("Average pps: %f", tmp);
-  INFO ("Thread exiting...");
-  pthread_exit (NULL);
-}
-
-int
-icmpr_send (long index, long packet_num, char *hw, char *ip)
-{
-  memif_connection_t *c = &memif_connection[index];
-  char *end;
-  char *ui;
-  uint8_t tmp[6];
-  if (c->conn == NULL)
-    return -1;
-  c->seq = 0;
-  icmpr_thread_data_t *data = &icmpr_thread_data[index];
-  data->index = index;
-  data->packet_num = packet_num;
-  INFO ("PN: %lu", data->packet_num);
-  printf ("%s\n", ip);
-  printf ("%s\n", hw);
-
-  ui = strtok (ip, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[0] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[1] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[2] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[3] = strtol (ui, &end, 10);
-
-  data->ip_daddr[0] = tmp[0];
-  data->ip_daddr[1] = tmp[1];
-  data->ip_daddr[2] = tmp[2];
-  data->ip_daddr[3] = tmp[3];
-
-  ui = strtok (hw, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[0] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[1] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[2] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[3] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[4] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[5] = strtol (ui, &end, 16);
-
-  data->hw_daddr[0] = tmp[0];
-  data->hw_daddr[1] = tmp[1];
-  data->hw_daddr[2] = tmp[2];
-  data->hw_daddr[3] = tmp[3];
-  data->hw_daddr[4] = tmp[4];
-  data->hw_daddr[5] = tmp[5];
-
-  pthread_create (&thread[index], NULL, icmpr_send_proc, (void *) data);
-  return 0;
-
-error:
-  INFO ("Invalid input\n");
-  return 0;
-}
-
-int
-user_input_handler ()
-{
-  char *in = (char *) malloc (256);
-  char *ui = fgets (in, 256, stdin);
-  char *end;
-  long a;
-  if (in[0] == '\n')
-    goto done;
-  ui = strtok (in, " ");
-  if (strncmp (ui, "exit", 4) == 0)
-    {
-      free (in);
-      icmpr_free ();
-      exit (EXIT_SUCCESS);
-    }
-  else if (strncmp (ui, "help", 4) == 0)
-    {
-      print_help ();
-      goto done;
-    }
-  else if (strncmp (ui, "conn", 4) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	a = strtol (ui, &end, 10);
-      else
-	{
-	  INFO ("expected id");
-	  goto done;
-	}
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_memif_create (a, strtol (ui, &end, 10), strtok (NULL, " "));
-      else
-	INFO ("expected mode <0|1>");
-      goto done;
-    }
-  else if (strncmp (ui, "del", 3) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_memif_delete (strtol (ui, &end, 10));
-      else
-	INFO ("expected id");
-      goto done;
-    }
-  else if (strncmp (ui, "show", 4) == 0)
-    {
-      print_memif_details ();
-      goto done;
-    }
-  else if (strncmp (ui, "ip-set", 6) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_set_ip (strtol (ui, &end, 10), strtok (NULL, " "));
-      else
-	INFO ("expected id");
-      goto done;
-    }
-  else if (strncmp (ui, "rx-mode", 7) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	a = strtol (ui, &end, 10);
-      else
-	{
-	  INFO ("expected id");
-	  goto done;
-	}
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_set_rx_mode (a, strtol (ui, &end, 10), strtok (NULL, " "));
-      else
-	INFO ("expected qid");
-      goto done;
-    }
-  else if (strncmp (ui, "sh-count", 8) == 0)
-    {
-      icmpr_print_counters ();
-    }
-  else if (strncmp (ui, "cl-count", 8) == 0)
-    {
-      icmpr_reset_counters ();
-    }
-  else if (strncmp (ui, "send", 4) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	a = strtol (ui, &end, 10);
-      else
-	{
-	  INFO ("expected id");
-	  goto done;
-	}
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_send (a, strtol (ui, &end, 10), strtok (NULL, " "),
-		    strtok (NULL, " "));
-      else
-	INFO ("expected count");
-      goto done;
-    }
-  else
-    {
-      INFO ("unknown command: %s", ui);
-      goto done;
-    }
-
-  return 0;
-done:
-  free (in);
-  return 0;
-}
-
-int
-poll_event (int timeout)
-{
-  struct epoll_event evt;
-  int app_err = 0, memif_err = 0, en = 0;
-  uint32_t events = 0;
-  struct timespec start, end;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = EPOLLIN | EPOLLOUT;
-  sigset_t sigset;
-  sigemptyset (&sigset);
-  en = epoll_pwait (epfd, &evt, 1, timeout, &sigset);
-  /* id event polled */
-  timespec_get (&start, TIME_UTC);
-  if (en < 0)
-    {
-      DBG ("epoll_pwait: %s", strerror (errno));
-      return -1;
-    }
-  if (en > 0)
-    {
-      /* this app does not use any other file descriptors than stds and memif control fds */
-      if (evt.data.fd > 2)
-	{
-	  /* event of memif control fd */
-	  /* convert epoll events to memif events */
-	  if (evt.events & EPOLLIN)
-	    events |= MEMIF_FD_EVENT_READ;
-	  if (evt.events & EPOLLOUT)
-	    events |= MEMIF_FD_EVENT_WRITE;
-	  if (evt.events & EPOLLERR)
-	    events |= MEMIF_FD_EVENT_ERROR;
-	  memif_err = memif_control_fd_handler (evt.data.fd, events);
-	  if (memif_err != MEMIF_ERR_SUCCESS)
-	    INFO ("memif_control_fd_handler: %s", memif_strerror (memif_err));
-	}
-      else if (evt.data.fd == 0)
-	{
-	  app_err = user_input_handler ();
-	}
-      else
-	{
-	  DBG ("unexpected event at memif_epfd. fd %d", evt.data.fd);
-	}
-    }
-
-  timespec_get (&end, TIME_UTC);
-  LOG ("interrupt: %ld", end.tv_nsec - start.tv_nsec);
-
-  if ((app_err < 0) || (memif_err < 0))
-    {
-      if (app_err < 0)
-	DBG ("user input handler error");
-      if (memif_err < 0)
-	DBG ("memif control fd handler error");
-      return -1;
-    }
-
-  return 0;
-}
-
-int
-main ()
-{
-  epfd = epoll_create (1);
-  add_epoll_fd (0, EPOLLIN);
-
-#ifdef LOG_FILE
-  remove (LOG_FILE);
-  enable_log = 0;
-
-  out_fd = open (LOG_FILE, O_WRONLY | O_CREAT, S_IRWXO);
-  if (out_fd < 0)
-    INFO ("Error opening log file: %s", strerror (errno));
-#endif /* LOG_FILE */
-
-  /* initialize memory interface */
-  int err, i;
-  /* if valid callback is passed as argument, fd event polling will be done by user
-     all file descriptors and events will be passed to user in this callback */
-  /* if callback is set to NULL libmemif will handle fd event polling */
-  err = memif_init (control_fd_update, APP_NAME, NULL, NULL, NULL);
-  if (err != MEMIF_ERR_SUCCESS)
-    {
-      INFO ("memif_init: %s", memif_strerror (err));
-      icmpr_free ();
-      exit (-1);
-    }
-
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memset (&memif_connection[i], 0, sizeof (memif_connection_t));
-      ctx[i] = i;
-    }
-
-  print_help ();
-
-  /* main loop */
-  while (1)
-    {
-      if (poll_event (-1) < 0)
-	{
-	  DBG ("poll_event error!");
-	}
-    }
-}
diff --git a/extras/libmemif/examples/icmp_responder-mt/main.c b/extras/libmemif/examples/icmp_responder-mt/main.c
deleted file mode 100644
index f37c6a0..0000000
--- a/extras/libmemif/examples/icmp_responder-mt/main.c
+++ /dev/null
@@ -1,914 +0,0 @@
-/*
- *------------------------------------------------------------------
- * 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.
- *------------------------------------------------------------------
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <net/if.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/uio.h>
-#include <sys/mman.h>
-#include <sys/prctl.h>
-#include <inttypes.h>
-#include <string.h>
-#include <stdio.h>
-#include <netdb.h>
-#include <linux/ip.h>
-#include <linux/icmp.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-#include <netinet/if_ether.h>
-#include <net/if_arp.h>
-#include <asm/byteorder.h>
-#include <byteswap.h>
-#include <string.h>
-#include <sys/epoll.h>
-#include <errno.h>
-#include <unistd.h>
-#include <signal.h>
-#include <pthread.h>
-
-#include <libmemif.h>
-#include <icmp_proto.h>
-
-#define APP_NAME "ICMP_Responder"
-#define IF_NAME  "memif_connection"
-
-
-#ifdef ICMP_DBG
-#define DBG(...) do {                                               \
-                    printf (APP_NAME":%s:%d: ", __func__, __LINE__);         \
-                    printf (__VA_ARGS__);                           \
-                    printf ("\n");                                  \
-                } while (0)
-#else
-#define DBG(...)
-#endif
-
-#define INFO(...) do {                                              \
-                    printf ("INFO: "__VA_ARGS__);                   \
-                    printf ("\n");                                  \
-                } while (0)
-
-/* maximum tx/rx memif buffers */
-#define MAX_MEMIF_BUFS  256
-#define MAX_CONNS       50
-#define MAX_QUEUES      2
-#define MAX_THREADS     ((MAX_CONNS) * (MAX_QUEUES))
-
-int main_epfd;
-
-typedef struct
-{
-  /* thread id */
-  uint8_t id;
-  /* memif connection index */
-  uint16_t index;
-  /* id of queue to be handled by thread */
-  uint8_t qid;
-  uint8_t isRunning;
-
-  uint16_t rx_buf_num;
-  uint16_t tx_buf_num;
-  memif_buffer_t *rx_bufs;
-  memif_buffer_t *tx_bufs;
-} memif_thread_data_t;
-
-typedef struct
-{
-  uint16_t index;
-  /* memif connection handle */
-  memif_conn_handle_t conn;
-  /* interface ip address */
-  uint8_t ip_addr[4];
-  /* inform pthread about connection termination */
-  uint8_t pending_del;
-} memif_connection_t;
-
-memif_connection_t memif_connection[MAX_CONNS];
-long ctx[MAX_CONNS];
-
-/* thread data specific for each thread */
-memif_thread_data_t thread_data[MAX_THREADS];
-pthread_t thread[MAX_THREADS];
-
-void
-user_signal_handler (int sig)
-{
-}
-
-static void
-print_memif_details ()
-{
-  memif_details_t md;
-  ssize_t buflen;
-  char *buf;
-  int err, i, e, ti;
-  buflen = 2048;
-  buf = malloc (buflen);
-  printf ("MEMIF DETAILS\n");
-  printf ("==============================\n");
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-
-      memset (&md, 0, sizeof (md));
-      memset (buf, 0, buflen);
-
-      err = memif_get_details (c->conn, &md, buf, buflen);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  if (err != MEMIF_ERR_NOCONN)
-	    INFO ("%s", memif_strerror (err));
-	  continue;
-	}
-
-      printf ("interface index: %d\n", i);
-
-      printf ("\tinterface ip: %u.%u.%u.%u\n",
-	      c->ip_addr[0], c->ip_addr[1], c->ip_addr[2], c->ip_addr[3]);
-      printf ("\tinterface name: %s\n", (char *) md.if_name);
-      printf ("\tapp name: %s\n", (char *) md.inst_name);
-      printf ("\tremote interface name: %s\n", (char *) md.remote_if_name);
-      printf ("\tremote app name: %s\n", (char *) md.remote_inst_name);
-      printf ("\tid: %u\n", md.id);
-      printf ("\tsecret: %s\n", (char *) md.secret);
-      printf ("\trole: ");
-      if (md.role)
-	printf ("slave\n");
-      else
-	printf ("master\n");
-      printf ("\tmode: ");
-      switch (md.mode)
-	{
-	case 0:
-	  printf ("ethernet\n");
-	  break;
-	case 1:
-	  printf ("ip\n");
-	  break;
-	case 2:
-	  printf ("punt/inject\n");
-	  break;
-	default:
-	  printf ("unknown\n");
-	  break;
-	}
-      printf ("\tsocket filename: %s\n", (char *) md.socket_filename);
-      printf ("\trx queues:\n");
-      for (e = 0; e < md.rx_queues_num; e++)
-	{
-	  ti = (i * MAX_QUEUES) + e;
-	  printf ("\tqueue id: %u\n", md.rx_queues[e].qid);
-	  printf ("\t\tring size: %u\n", md.rx_queues[e].ring_size);
-	  printf ("\t\tbuffer size: %u\n", md.rx_queues[e].buffer_size);
-	  printf ("\t\tthread id: %u\n", thread_data[ti].id);
-	  printf ("\t\tthread connection index: %u\n", thread_data[ti].index);
-	  printf ("\t\tthread running: ");
-	  if (thread_data[ti].isRunning)
-	    printf ("yes\n");
-	  else
-	    printf ("no");
-	}
-      printf ("\ttx queues:\n");
-      for (e = 0; e < md.tx_queues_num; e++)
-	{
-	  printf ("\tqueue id: %u\n", md.tx_queues[e].qid);
-	  printf ("\t\tring size: %u\n", md.tx_queues[e].ring_size);
-	  printf ("\t\tbuffer size: %u\n", md.tx_queues[e].buffer_size);
-	}
-      printf ("\tlink: ");
-      if (md.link_up_down)
-	printf ("up\n");
-      else
-	printf ("down\n");
-    }
-  free (buf);
-}
-
-int
-add_epoll_fd (int epfd, int fd, uint32_t events)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = events;
-  evt.data.fd = fd;
-  if (epoll_ctl (epfd, EPOLL_CTL_ADD, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d added to epoll", fd);
-  return 0;
-}
-
-int
-mod_epoll_fd (int epfd, int fd, uint32_t events)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = events;
-  evt.data.fd = fd;
-  if (epoll_ctl (epfd, EPOLL_CTL_MOD, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d modified on epoll", fd);
-  return 0;
-}
-
-int
-del_epoll_fd (int epfd, int fd)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  if (epoll_ctl (epfd, EPOLL_CTL_DEL, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d removed from epoll", fd);
-  return 0;
-}
-
-void *
-memif_rx_poll (void *ptr)
-{
-  memif_thread_data_t *data = (memif_thread_data_t *) ptr;
-  memif_connection_t *c = &memif_connection[data->index];
-  int err;
-  uint16_t rx = 0, tx = 0, fb = 0;
-
-  data->rx_bufs = malloc (sizeof (memif_buffer_t) * MAX_MEMIF_BUFS);
-  data->tx_bufs = malloc (sizeof (memif_buffer_t) * MAX_MEMIF_BUFS);
-  data->rx_buf_num = 0;
-  data->tx_buf_num = 0;
-
-  data->isRunning = 1;
-  INFO ("pthread id %u starts in polling mode", data->id);
-
-  while (1)
-    {
-      if (c->pending_del)
-	goto close;
-
-      /* receive data from shared memory buffers */
-      err =
-	memif_rx_burst (c->conn, data->qid, data->rx_bufs, MAX_MEMIF_BUFS,
-			&rx);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  INFO ("memif_rx_burst: %s", memif_strerror (err));
-	  data->rx_buf_num += rx;
-	  goto error;
-	}
-      data->rx_buf_num += rx;
-      if (rx == 0)
-	{
-	  continue;
-	}
-
-      DBG ("thread id: %u", data->id);
-
-      DBG ("received %d buffers. %u/%u alloc/free buffers",
-	   rx, data->rx_buf_num, MAX_MEMIF_BUFS - data->rx_buf_num);
-
-      err =
-	memif_buffer_alloc (c->conn, data->qid, data->tx_bufs,
-			    data->rx_buf_num, &tx, 0);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  INFO ("memif_buffer_alloc: %s", memif_strerror (err));
-	  data->tx_buf_num += tx;
-	  goto error;
-	}
-      data->tx_buf_num += tx;
-      DBG ("allocated %d/%d buffers, %u free buffers",
-	   tx, data->rx_buf_num, MAX_MEMIF_BUFS - data->tx_buf_num);
-
-      int i;
-      for (i = 0; i < rx; i++)
-	{
-	  resolve_packet ((void *) (data->rx_bufs + i)->data,
-			  (data->rx_bufs + i)->len,
-			  (void *) (data->tx_bufs + i)->data,
-			  &(data->tx_bufs + i)->len, c->ip_addr);
-	}
-
-      /* mark memif buffers and shared memory buffers as free */
-      err = memif_refill_queue (c->conn, data->qid, rx, 0);
-      if (err != MEMIF_ERR_SUCCESS)
-	INFO ("memif_buffer_free: %s", memif_strerror (err));
-      data->rx_buf_num -= fb;
-
-      DBG ("freed %d buffers. %u/%u alloc/free buffers",
-	   fb, data->rx_buf_num, MAX_MEMIF_BUFS - data->rx_buf_num);
-
-      err =
-	memif_tx_burst (c->conn, data->qid, data->tx_bufs, data->tx_buf_num,
-			&tx);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  INFO ("memif_tx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-      DBG ("tx: %d/%u", tx, data->tx_buf_num);
-      data->tx_buf_num -= tx;
-    }
-
-error:
-  INFO ("thread %u error!", data->id);
-  goto close;
-
-close:
-  err = memif_refill_queue (c->conn, data->qid, rx, 0);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_buffer_free: %s", memif_strerror (err));
-  data->rx_buf_num -= fb;
-  DBG ("freed %d buffers. %u/%u alloc/free buffers",
-       fb, data->rx_buf_num, MAX_MEMIF_BUFS - data->rx_buf_num);
-  free (data->rx_bufs);
-  free (data->tx_bufs);
-  data->isRunning = 0;
-  INFO ("pthread id %u exit", data->id);
-  pthread_exit (NULL);
-}
-
-void *
-memif_rx_interrupt (void *ptr)
-{
-  memif_thread_data_t *data = (memif_thread_data_t *) ptr;
-  memif_connection_t *c = &memif_connection[data->index];
-  int err;
-  uint16_t rx = 0, tx = 0, fb = 0;
-  struct epoll_event evt;
-  int en = 0;
-  sigset_t sigset;
-
-  signal (SIGUSR1, user_signal_handler);
-
-  data->rx_bufs = malloc (sizeof (memif_buffer_t) * MAX_MEMIF_BUFS);
-  data->tx_bufs = malloc (sizeof (memif_buffer_t) * MAX_MEMIF_BUFS);
-  data->rx_buf_num = 0;
-  data->tx_buf_num = 0;
-
-  data->isRunning = 1;
-  INFO ("pthread id %u starts in interrupt mode", data->id);
-  int thread_epfd = epoll_create (1);
-
-  /* get interrupt queue id */
-  int fd = -1;
-  err = memif_get_queue_efd (c->conn, data->qid, &fd);
-  if (err != MEMIF_ERR_SUCCESS)
-    {
-      INFO ("memif_get_queue_efd: %s", memif_strerror (err));
-      goto error;
-    }
-  add_epoll_fd (thread_epfd, fd, EPOLLIN);
-
-  while (1)
-    {
-      memset (&evt, 0, sizeof (evt));
-      evt.events = EPOLLIN | EPOLLOUT;
-      sigemptyset (&sigset);
-      en = epoll_pwait (thread_epfd, &evt, 1, -1, &sigset);
-      if (en < 0)
-	{
-	  if (errno == EINTR)
-	    goto close;
-	  DBG ("epoll_pwait: %s", strerror (errno));
-	  goto error;
-	}
-      else if (en > 0)
-	{
-	  /* receive data from shared memory buffers */
-	  err =
-	    memif_rx_burst (c->conn, data->qid, data->rx_bufs, MAX_MEMIF_BUFS,
-			    &rx);
-	  if (err != MEMIF_ERR_SUCCESS)
-	    {
-	      INFO ("memif_rx_burst: %s", memif_strerror (err));
-	      data->rx_buf_num += rx;
-	      goto error;
-	    }
-	  data->rx_buf_num += rx;
-	  if (rx == 0)
-	    {
-	      continue;
-	    }
-
-	  DBG ("thread id: %u", data->id);
-
-	  DBG ("received %d buffers. %u/%u alloc/free buffers",
-	       rx, data->rx_buf_num, MAX_MEMIF_BUFS - data->rx_buf_num);
-
-	  err =
-	    memif_buffer_alloc (c->conn, data->qid, data->tx_bufs,
-				data->rx_buf_num, &tx, 0);
-	  if (err != MEMIF_ERR_SUCCESS)
-	    {
-	      INFO ("memif_buffer_alloc: %s", memif_strerror (err));
-	      data->tx_buf_num += tx;
-	      goto error;
-	    }
-	  data->tx_buf_num += tx;
-	  DBG ("allocated %d/%d buffers, %u free buffers",
-	       tx, data->rx_buf_num, MAX_MEMIF_BUFS - data->tx_buf_num);
-
-	  int i;
-	  for (i = 0; i < rx; i++)
-	    {
-	      resolve_packet ((void *) (data->rx_bufs + i)->data,
-			      (data->rx_bufs + i)->len,
-			      (void *) (data->tx_bufs + i)->data,
-			      &(data->tx_bufs + i)->len, c->ip_addr);
-	    }
-
-	  /* mark memif buffers and shared memory buffers as free */
-	  err = memif_refill_queue (c->conn, data->qid, rx, 0);
-	  if (err != MEMIF_ERR_SUCCESS)
-	    INFO ("memif_buffer_free: %s", memif_strerror (err));
-	  data->rx_buf_num -= fb;
-
-	  DBG ("freed %d buffers. %u/%u alloc/free buffers",
-	       fb, data->rx_buf_num, MAX_MEMIF_BUFS - data->rx_buf_num);
-
-	  err =
-	    memif_tx_burst (c->conn, data->qid, data->tx_bufs,
-			    data->tx_buf_num, &tx);
-	  if (err != MEMIF_ERR_SUCCESS)
-	    {
-	      INFO ("memif_tx_burst: %s", memif_strerror (err));
-	      goto error;
-	    }
-	  DBG ("tx: %d/%u", tx, data->tx_buf_num);
-	  data->tx_buf_num -= tx;
-	}
-    }
-
-error:
-  INFO ("thread %u error!", data->id);
-  goto close;
-
-close:
-  err = memif_refill_queue (c->conn, data->qid, rx, 0);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_buffer_free: %s", memif_strerror (err));
-  data->rx_buf_num -= fb;
-  DBG ("freed %d buffers. %u/%u alloc/free buffers",
-       fb, data->rx_buf_num, MAX_MEMIF_BUFS - data->rx_buf_num);
-  free (data->rx_bufs);
-  free (data->tx_bufs);
-  data->isRunning = 0;
-  INFO ("pthread id %u exit", data->id);
-  pthread_exit (NULL);
-
-}
-
-/* informs user about connected status. private_ctx is used by user to identify connection
-    (multiple connections WIP) */
-int
-on_connect (memif_conn_handle_t conn, void *private_ctx)
-{
-  long index = (*(long *) private_ctx);
-  int err, i, ti;
-  INFO ("memif connected! index %ld", index);
-  memif_connection_t *c = &memif_connection[index];
-  c->pending_del = 0;
-
-  for (i = 0; i < MAX_QUEUES; i++)
-    {
-      err = memif_set_rx_mode (c->conn, MEMIF_RX_MODE_POLLING, i);
-      if (err != MEMIF_ERR_SUCCESS)
-	INFO ("memif_set_rx_mode: %s qid: %u", memif_strerror (err), i);
-      else
-	{
-	  ti = (index * MAX_QUEUES) + i;
-	  if (thread_data[ti].isRunning)
-	    {
-	      INFO ("thread id: %d already running!", ti);
-	      continue;
-	    }
-	  thread_data[ti].index = index;
-	  thread_data[ti].qid = i;
-	  thread_data[ti].id = ti;
-	  if ((i % 2) == 0)
-	    pthread_create (&thread[ti],
-			    NULL, memif_rx_poll, (void *) &thread_data[ti]);
-	  else
-	    pthread_create (&thread[ti],
-			    NULL, memif_rx_interrupt,
-			    (void *) &thread_data[ti]);
-	}
-
-    }
-  return 0;
-}
-
-/* informs user about disconnected status. private_ctx is used by user to identify connection
-    (multiple connections WIP) */
-int
-on_disconnect (memif_conn_handle_t conn, void *private_ctx)
-{
-  void *ptr;
-  long index = (*(long *) private_ctx);
-  memif_connection_t *c = &memif_connection[index];
-  int i, ti;
-  INFO ("memif disconnected!");
-  /* inform thread in polling mode about memif disconnection */
-  c->pending_del = 1;
-  for (i = 0; i < MAX_QUEUES; i++)
-    {
-      ti = (index * MAX_QUEUES) + i;
-      if (!thread_data[ti].isRunning)
-	continue;
-      if ((i % 2) != 0)
-	pthread_kill (thread[ti], SIGUSR1);	/* interrupt thread in interrupt mode */
-      pthread_join (thread[ti], &ptr);
-    }
-  return 0;
-}
-
-/* user needs to watch new fd or stop watching fd that is about to be closed.
-    control fd will be modified during connection establishment to minimize CPU usage */
-int
-control_fd_update (int fd, uint8_t events, void *ctx)
-{
-  /* convert memif event definitions to epoll events */
-  if (events & MEMIF_FD_EVENT_DEL)
-    return del_epoll_fd (main_epfd, fd);
-
-  uint32_t evt = 0;
-  if (events & MEMIF_FD_EVENT_READ)
-    evt |= EPOLLIN;
-  if (events & MEMIF_FD_EVENT_WRITE)
-    evt |= EPOLLOUT;
-
-  if (events & MEMIF_FD_EVENT_MOD)
-    return mod_epoll_fd (main_epfd, fd, evt);
-
-  return add_epoll_fd (main_epfd, fd, evt);
-}
-
-int
-icmpr_memif_create (long index)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("don't even try...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-
-  /* setting memif connection arguments */
-  memif_conn_args_t args;
-  memset (&args, 0, sizeof (args));
-  args.is_master = 0;
-  args.log2_ring_size = 10;
-  args.buffer_size = 2048;
-  args.num_s2m_rings = 2;
-  args.num_m2s_rings = 2;
-  strncpy ((char *) args.interface_name, IF_NAME, strlen (IF_NAME));
-  args.mode = 0;
-  /* socket filename is not specified, because this app is supposed to
-     connect to VPP over memif. so default socket filename will be used */
-  /* default socketfile = /run/vpp/memif.sock */
-
-  args.interface_id = index;
-  /* last argument for memif_create (void * private_ctx) is used by user
-     to identify connection. this context is returned with callbacks */
-  int err = memif_create (&c->conn,
-			  &args, on_connect, on_disconnect, NULL,
-			  &ctx[index]);
-  if (err != MEMIF_ERR_SUCCESS)
-    {
-      INFO ("memif_create: %s", memif_strerror (err));
-      return 0;
-    }
-
-  c->index = index;
-
-  c->ip_addr[0] = 192;
-  c->ip_addr[1] = 168;
-  c->ip_addr[2] = c->index + 1;
-  c->ip_addr[3] = 2;
-  return 0;
-}
-
-int
-icmpr_memif_delete (long index)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("don't even try...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-
-  int err;
-  /* disconnect then delete memif connection */
-  err = memif_delete (&c->conn);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_delete: %s", memif_strerror (err));
-  return 0;
-}
-
-void
-print_help ()
-{
-  printf ("LIBMEMIF EXAMPLE APP: %s", APP_NAME);
-#ifdef ICMP_DBG
-  printf (" (debug)");
-#endif
-  printf ("\n");
-  printf ("==============================\n");
-  printf ("libmemif version: %s", LIBMEMIF_VERSION);
-#ifdef MEMIF_DBG
-  printf (" (debug)");
-#endif
-  printf ("\n");
-  printf ("memif version: %d\n", memif_get_version ());
-  printf ("commands:\n");
-  printf ("\thelp - prints this help\n");
-  printf ("\texit - exit app\n");
-  printf ("\tconn <index> - create memif (slave-mode)\n");
-  printf ("\tdel  <index> - delete memif\n");
-  printf ("\tshow - show connection details\n");
-  printf ("\tip-set <index> <ip-addr> - set interface ip address\n");
-}
-
-int
-icmpr_free ()
-{
-  /* application cleanup */
-  int err;
-  long i;
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-      if (c->conn)
-	icmpr_memif_delete (i);
-    }
-
-  err = memif_cleanup ();
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_delete: %s", memif_strerror (err));
-
-  return 0;
-}
-
-int
-icmpr_set_ip (long index, char *ip)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("don't even try...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-  if (c->conn == NULL)
-    {
-      INFO ("no connection at index %ld", index);
-      return 0;
-    }
-
-  char *end;
-  char *ui;
-  uint8_t tmp[4];
-  ui = strtok (ip, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[0] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[1] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[2] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[3] = strtol (ui, &end, 10);
-
-  c->ip_addr[0] = tmp[0];
-  c->ip_addr[1] = tmp[1];
-  c->ip_addr[2] = tmp[2];
-  c->ip_addr[3] = tmp[3];
-
-  INFO ("memif %ld ip address set to %u.%u.%u.%u",
-	index, c->ip_addr[0], c->ip_addr[1], c->ip_addr[2], c->ip_addr[3]);
-
-  return 0;
-
-error:
-  INFO ("invalid ip address");
-  return 0;
-}
-
-
-int
-user_input_handler ()
-{
-  char *in = (char *) malloc (256);
-  char *ui = fgets (in, 256, stdin);
-  char *end;
-  if (in[0] == '\n')
-    goto done;
-  ui = strtok (in, " ");
-  if (strncmp (ui, "exit", 4) == 0)
-    {
-      free (in);
-      icmpr_free ();
-      exit (EXIT_SUCCESS);
-    }
-  else if (strncmp (ui, "help", 4) == 0)
-    {
-      print_help ();
-      goto done;
-    }
-  else if (strncmp (ui, "conn", 4) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_memif_create (strtol (ui, &end, 10));
-      else
-	INFO ("expected id");
-      goto done;
-    }
-  else if (strncmp (ui, "del", 3) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_memif_delete (strtol (ui, &end, 10));
-      else
-	INFO ("expected id");
-      goto done;
-    }
-  else if (strncmp (ui, "show", 4) == 0)
-    {
-      print_memif_details ();
-      goto done;
-    }
-  else if (strncmp (ui, "ip-set", 6) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_set_ip (strtol (ui, &end, 10), strtok (NULL, " "));
-      else
-	INFO ("expected id");
-      goto done;
-    }
-  else
-    {
-      DBG ("unknown command: %s", ui);
-      goto done;
-    }
-
-  return 0;
-done:
-  free (in);
-  return 0;
-}
-
-int
-poll_event (int timeout)
-{
-  struct epoll_event evt;
-  int app_err = 0, memif_err = 0, en = 0;
-  uint32_t events = 0;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = EPOLLIN | EPOLLOUT;
-  sigset_t sigset;
-  sigemptyset (&sigset);
-  en = epoll_pwait (main_epfd, &evt, 1, timeout, &sigset);
-  if (en < 0)
-    {
-      DBG ("epoll_pwait: %s", strerror (errno));
-      return -1;
-    }
-  if (en > 0)
-    {
-      /* this app does not use any other file descriptors than stds and memif control fds */
-      if (evt.data.fd > 2)
-	{
-	  /* event of memif control fd */
-	  /* convert epoll events to memif events */
-	  if (evt.events & EPOLLIN)
-	    events |= MEMIF_FD_EVENT_READ;
-	  if (evt.events & EPOLLOUT)
-	    events |= MEMIF_FD_EVENT_WRITE;
-	  if (evt.events & EPOLLERR)
-	    events |= MEMIF_FD_EVENT_ERROR;
-	  memif_err = memif_control_fd_handler (evt.data.fd, events);
-	  if (memif_err != MEMIF_ERR_SUCCESS)
-	    INFO ("memif_control_fd_handler: %s", memif_strerror (memif_err));
-	}
-      else if (evt.data.fd == 0)
-	{
-	  app_err = user_input_handler ();
-	}
-      else
-	{
-	  DBG ("unexpected event at memif_epfd. fd %d", evt.data.fd);
-	}
-    }
-
-  if ((app_err < 0) || (memif_err < 0))
-    {
-      if (app_err < 0)
-	DBG ("user input handler error");
-      if (memif_err < 0)
-	DBG ("memif control fd handler error");
-      return -1;
-    }
-
-  return 0;
-}
-
-int
-main ()
-{
-  main_epfd = epoll_create (1);
-  add_epoll_fd (main_epfd, 0, EPOLLIN);
-
-  /* initialize memory interface */
-  int err, i;
-  /* if valid callback is passed as argument, fd event polling will be done by user
-     all file descriptors and events will be passed to user in this callback */
-  /* if callback is set to NULL libmemif will handle fd event polling */
-  err = memif_init (control_fd_update, APP_NAME, NULL, NULL, NULL);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_init: %s", memif_strerror (err));
-
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection[i].conn = NULL;
-      ctx[i] = i;
-    }
-
-  memset (&thread_data, 0, sizeof (memif_thread_data_t) * MAX_THREADS);
-
-  print_help ();
-
-  /* main loop */
-  while (1)
-    {
-      if (poll_event (-1) < 0)
-	{
-	  DBG ("poll_event error!");
-	}
-    }
-}
diff --git a/extras/libmemif/examples/icmp_responder-mt_3-1/main.c b/extras/libmemif/examples/icmp_responder-mt_3-1/main.c
deleted file mode 100644
index 86c57d1..0000000
--- a/extras/libmemif/examples/icmp_responder-mt_3-1/main.c
+++ /dev/null
@@ -1,549 +0,0 @@
-/*
- *------------------------------------------------------------------
- * Copyright (c) 2019 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 <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <getopt.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <stdbool.h>
-#include <unistd.h>
-
-#include <sys/epoll.h>
-#include <sys/eventfd.h>
-
-#include <libmemif.h>
-#include <icmp_proto.h>
-
-
-#define APP_NAME "ICMP_Responder_mt_v3.1"
-#define IF_NAME  "memif_connection"
-
-#ifdef ICMP_DBG
-#define DBG(...) do {                                               \
-                    printf (APP_NAME":%s:%d: ", __func__, __LINE__);         \
-                    printf (__VA_ARGS__);                           \
-                    printf ("\n");                                  \
-                } while (0)
-#else
-#define DBG(...)
-#endif
-
-#define ICMPR_BUFFER_LENGTH		32
-#define ICMPR_SOCKET_FILENAME_LEN	256
-#define ICMPR_MEMIF_BUFFER_NUM		256
-
-static struct option options[] = {
-  {"threads", required_argument, 0, 't'},
-  {"if_num", required_argument, 0, 'i'}
-};
-
-struct memif_connection
-{
-  uint16_t id;			/* unique interface id */
-  bool connected;		/* is connected */
-  struct per_thread_data *ptd;	/* per thread data */
-  memif_conn_handle_t handle;	/* memif connection handle */
-  uint8_t ip_addr[4];		/* ip4 address */
-};
-
-struct per_thread_data
-{
-  bool running;			/* is thread main loop running */
-  uint8_t index;		/* thread index */
-  int epfd;			/* epoll file descriptor */
-  int pcfd;			/* poll cancel file descriptor */
-  uint16_t if_num;		/* number of interfaces on this thread */
-  struct memif_connection *conns;	/* memif connections pool */
-  memif_per_thread_main_handle_t pt_main;	/* memif per thread main handle */
-  memif_socket_handle_t socket_handle;		/* memif socket handle */
-};
-
-struct icmpr_main
-{
-  uint8_t threads;		/* number of threads */
-  uint16_t per_thread_if_num;	/* number of interfaces per thread */
-  struct per_thread_data *ptd;	/* per thread data pool */
-  pthread_t *pthread;		/* thread pool */
-};
-
-struct icmpr_main icmpr_main;
-
-int
-add_epoll_fd (int epfd, int fd, uint32_t events)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = events;
-  evt.data.fd = fd;
-  if (epoll_ctl (epfd, EPOLL_CTL_ADD, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d added to epoll", fd);
-  return 0;
-}
-
-int
-mod_epoll_fd (int epfd, int fd, uint32_t events)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = events;
-  evt.data.fd = fd;
-  if (epoll_ctl (epfd, EPOLL_CTL_MOD, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d modified on epoll", fd);
-  return 0;
-}
-
-int
-del_epoll_fd (int epfd, int fd)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  if (epoll_ctl (epfd, EPOLL_CTL_DEL, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d removed from epoll", fd);
-  return 0;
-}
-
-/* Called when libmemif requests an update on any of its file descriptors */
-static int
-control_fd_update (int fd, uint8_t events, void *private_ctx)
-{
-  struct per_thread_data *ptd = (struct per_thread_data *) private_ctx;
-  uint32_t evt = 0;
-
-  if (ptd == NULL)
-    return -1;
-
-  /* convert memif event definitions to epoll events */
-  if (events & MEMIF_FD_EVENT_DEL)
-    return del_epoll_fd (ptd->epfd, fd);
-
-  if (events & MEMIF_FD_EVENT_READ)
-    evt |= EPOLLIN;
-  if (events & MEMIF_FD_EVENT_WRITE)
-    evt |= EPOLLOUT;
-
-  if (events & MEMIF_FD_EVENT_MOD)
-    return mod_epoll_fd (ptd->epfd, fd, evt);
-
-  return add_epoll_fd (ptd->epfd, fd, evt);
-}
-
-static int
-on_connect (memif_conn_handle_t conn, void *private_ctx)
-{
-  struct per_thread_data *ptd = (struct per_thread_data *) private_ctx;
-  struct memif_connection *c;
-  int i = 0;
-
-  while (i < ptd->if_num && ptd->conns[i].handle != conn)
-    i++;
-  c = &ptd->conns[i];
-
-  c->connected = true;
-  DBG ("Connected: %u", c->id);
-
-  memif_refill_queue (conn, 0, -1, 0);
-
-  return 0;
-}
-
-static int
-on_disconnect (memif_conn_handle_t conn, void *private_ctx)
-{
-  struct per_thread_data *ptd = (struct per_thread_data *) private_ctx;
-  struct memif_connection *c;
-  int i = 0;
-
-  while (i < ptd->if_num && ptd->conns[i].handle != conn)
-    i++;
-  c = &ptd->conns[i];
-
-  c->connected = false;
-  DBG ("Disconnected: %u", c->id);
-
-  return 0;
-}
-
-static int
-on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
-{
-  struct per_thread_data *ptd = (struct per_thread_data *) private_ctx;
-  struct memif_connection *c;
-  memif_buffer_t mbufs[ICMPR_MEMIF_BUFFER_NUM];
-  uint16_t rx = 0;
-  uint16_t tx = 0;
-  uint16_t ret;
-  memif_err_t err;
-  int i = 0;
-
-  memset (mbufs, 0, sizeof (memif_buffer_t) * ICMPR_MEMIF_BUFFER_NUM);
-
-  while (i < ptd->if_num && ptd->conns[i].handle != conn)
-    i++;
-  c = &ptd->conns[i];
-
-  /* receive data from shared memory buffers */
-  err = memif_rx_burst (conn, qid, mbufs, ICMPR_MEMIF_BUFFER_NUM, &rx);
-  if (err != MEMIF_ERR_SUCCESS)
-  {
-    printf ("memif_rx_burst: %s\n", memif_strerror (err));
-    goto error;
-  }
-
-  /* resolve packet in place (zer-copy slave) */
-  for (i = 0; i < rx; i++)
-    resolve_packet2 (mbufs[i].data, &mbufs[i].len, c->ip_addr);
-
-  /* enqueue received buffers */
-  err = memif_buffer_enq_tx (conn, qid, mbufs, i, &tx);
-  if (err != MEMIF_ERR_SUCCESS)
-  {
-    printf ("memif_rx_burst: %s\n", memif_strerror (err));
-    goto error;
-  }
-
-  /* mark shared memory buffers as free */
-  err = memif_refill_queue (conn, qid, rx, 0);
-  if (err != MEMIF_ERR_SUCCESS)
-  {
-    printf ("memif_rx_burst: %s\n", memif_strerror (err));
-    goto error;
-  }
-
-  err = memif_tx_burst (conn, qid, mbufs, tx, &ret);
-  if (err != MEMIF_ERR_SUCCESS)
-  {
-    printf ("memif_rx_burst: %s\n", memif_strerror (err));
-    goto error;
-  }
-
-  return 0;
-
-error:
-  memif_refill_queue (conn, qid, -1, 0);
-  return -1;
-}
-
-int
-poll_event (memif_per_thread_main_handle_t pt_main, int pcfd, int epfd,
-	    int timeout)
-{
-  struct epoll_event evt;
-  int en = 0;
-  uint8_t events = 0;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = EPOLLIN | EPOLLOUT;
-
-  en = epoll_pwait (epfd, &evt, 1, timeout, NULL);
-  if (en < 0)
-    {
-      printf ("epoll_pwait: %s\n", strerror (errno));
-      return -1;
-    }
-
-  if (en > 0)
-    {
-      /* Cancel event polling */
-      if (evt.data.fd == pcfd)
-	return 1;
-
-      if (evt.events & EPOLLIN)
-	events |= MEMIF_FD_EVENT_READ;
-      if (evt.events & EPOLLOUT)
-	events |= MEMIF_FD_EVENT_WRITE;
-      if (evt.events & EPOLLERR)
-	events |= MEMIF_FD_EVENT_ERROR;
-
-      /* No need to use locks, as the database is separated */
-      memif_per_thread_control_fd_handler (pt_main, evt.data.fd, events);
-    }
-
-  return 0;
-}
-
-static void *
-icmpr_thread_fn (void *data)
-{
-  struct per_thread_data *ptd = (struct per_thread_data *) data;
-  int rv;
-  uint16_t i;
-  char socket_filename[ICMPR_SOCKET_FILENAME_LEN] = "/run/vpp/memif";
-  memif_conn_args_t args;
-
-  ptd->epfd = epoll_create (1);
-
-  ptd->conns = malloc (sizeof (struct memif_connection) * ptd->if_num);
-  if (ptd->conns == NULL)
-    {
-      printf ("%s\n", strerror (errno));
-      return NULL;
-    }
-
-  memset (ptd->conns, 0, sizeof (struct memif_connection) * ptd->if_num);
-
-  /* Initialize memif database (per thread). */
-  rv =
-    memif_per_thread_init (&ptd->pt_main, ptd, control_fd_update, APP_NAME,
-			   NULL, NULL, NULL);
-  if (rv != MEMIF_ERR_SUCCESS)
-    {
-      printf ("memif_per_thread_init: %s\n", memif_strerror (rv));
-      return NULL;
-    }
-
-  /*  Create unique socket. Each thread requires a unique socket. Interfaces created
-   *  on the same thread can share one socket.
-   */
-  socket_filename[strlen (socket_filename)] = '0' + ptd->index;
-  strncpy (socket_filename + strlen (socket_filename), ".sock", 5);
-  DBG ("socket_filename: %s", socket_filename);
-
-  rv = memif_per_thread_create_socket (ptd->pt_main, &ptd->socket_handle,
-				       socket_filename, ptd);
-  if (rv != MEMIF_ERR_SUCCESS)
-    {
-      printf ("memif_per_thread_create_socket: %s\n", memif_strerror (rv));
-      return NULL;
-    }
-
-  /* Create interfaces on this thread */
-  for (i = 0; i < ptd->if_num; i++)
-    {
-      ptd->conns[i].ip_addr[0] = 192;
-      ptd->conns[i].ip_addr[1] = 168;
-      ptd->conns[i].ip_addr[2] = ptd->index + 1;
-      ptd->conns[i].ip_addr[3] = i * 2 + 2;
-
-      memset (&args, 0, sizeof (args));
-
-      args.socket = ptd->socket_handle;
-      ptd->conns[i].id = i;
-      args.interface_id = i;
-
-      rv = memif_create (&ptd->conns[i].handle, &args, on_connect,
-			 on_disconnect, on_interrupt, ptd);
-      if (rv < 0)
-	{
-	  printf ("%s\n", memif_strerror (rv));
-	  return NULL;
-	}
-    }
-
-  /* Poll cancel file descriptor. When an event is received on this fd, exit thread
-   * loop in respective thread.
-   */
-  ptd->pcfd = eventfd (0, EFD_NONBLOCK);
-  if (ptd->pcfd < 0)
-    {
-      printf ("eventfd: %s\n", strerror (errno));
-      return NULL;
-    }
-  if (add_epoll_fd (ptd->epfd, ptd->pcfd, EPOLLIN) < 0)
-    {
-      printf ("Failed to add poll cancel fd to epfd.");
-      return NULL;
-    }
-
-  /* Thread loop */
-  ptd->running = true;
-  while (ptd->running)
-    {
-      rv = poll_event (ptd->pt_main, ptd->pcfd, ptd->epfd, -1);
-      if (rv != 0)
-	ptd->running = false;
-    }
-
-  /* Clean up */
-  for (i = 0; i < ptd->if_num; i++)
-    memif_delete (&ptd->conns[i].handle);
-
-  memif_delete_socket (&ptd->socket_handle);
-
-  memif_per_thread_cleanup (&ptd->pt_main);
-
-  free (ptd->conns);
-  close (ptd->pcfd);
-
-  return NULL;
-}
-
-static void
-icmpr_print_help ()
-{
-  printf
-    ("exit - Exits the application.\nhelp - Print this help.\nshow - Show memif interfaces\n");
-}
-
-static void
-icmpr_show_memifs ()
-{
-  struct icmpr_main *im = &icmpr_main;
-  int i, j;
-  memif_socket_handle_t sh;
-
-  printf ("%u Threads %u Memifs (per thread)\n", im->threads,
-	  im->per_thread_if_num);
-  printf ("=================================\n");
-
-  for (i = 0; i < im->threads; i++)
-    {
-      sh = im->ptd[i].socket_handle;
-      printf ("Thread %u %s\n", i, memif_get_socket_filename (sh));
-      for (j = 0; j < im->per_thread_if_num; j++)
-	{
-	  printf ("\tMemif id %u\n\t%s\n", im->ptd[i].conns[j].id,
-		  im->ptd[i].conns[j].connected ? "Link up" : "Link down");
-	}
-    }
-}
-
-int
-main (int argc, char **argv)
-{
-  struct icmpr_main *im = &icmpr_main;
-  int rv, i;
-  int option_index = 0;
-  bool running;
-  char buffer[ICMPR_BUFFER_LENGTH];
-  uint64_t b = 1;
-
-  memset (im, 0, sizeof (struct icmpr_main));
-
-  /* Default args */
-  im->threads = 4;
-  im->per_thread_if_num = 1;
-
-  /* Parse args */
-  while ((rv =
-	  getopt_long (argc, argv, "t:i:", options, &option_index)) != (-1))
-    {
-      switch (rv)
-	{
-	case 't':
-	  im->threads = strtoul (optarg, NULL, 10);
-	  break;
-	case 'i':
-	  im->per_thread_if_num = strtoul (optarg, NULL, 10);
-	  break;
-	default:
-	  break;
-	}
-    }
-
-  /* Check args */
-  if (im->threads < 1)
-    {
-      printf ("threads < 1\n");
-      exit (EXIT_FAILURE);
-    }
-
-  if (im->per_thread_if_num < 1)
-    {
-      printf ("if_num < 1\n");
-      exit (EXIT_FAILURE);
-    }
-
-  /* Allocate memory */
-  im->ptd = malloc (sizeof (struct per_thread_data) * im->threads);
-  if (im->ptd == NULL)
-    {
-      printf ("%s\n", strerror (errno));
-      return -1;
-    }
-  im->pthread = malloc (sizeof (pthread_t) * im->threads);
-  if (im->pthread == NULL)
-    {
-      printf ("%s\n", strerror (errno));
-      return -1;
-    }
-
-  /* Initialize and create threads */
-  for (i = 0; i < im->threads; i++)
-    {
-      im->ptd[i].index = i;
-      im->ptd[i].if_num = im->per_thread_if_num;
-      pthread_create (&im->pthread[i], NULL, icmpr_thread_fn, &im->ptd[i]);
-    }
-
-  icmpr_print_help ();
-
-  /* Main loop */
-  running = true;
-  while (running)
-    {
-      printf ("cmd: ");
-      memset (buffer, 0, ICMPR_BUFFER_LENGTH);
-      if (fgets (buffer, ICMPR_BUFFER_LENGTH, stdin) != buffer)
-	{
-	  printf ("%s\n", strerror (errno));
-	  running = false;
-	}
-
-      if (strncmp (buffer, "exit", 4) == 0)
-	running = false;
-      else if (strncmp (buffer, "help", 4) == 0)
-	icmpr_print_help ();
-      else if (strncmp (buffer, "show", 4) == 0)
-	icmpr_show_memifs ();
-    }
-
-  for (i = 0; i < im->threads; i++)
-    {
-      /* Stop polling */
-      rv = write (im->ptd[i].pcfd, &b, sizeof (b));
-      if (rv < 0)
-	{
-	  printf ("Failed to cancel polling. %s\n", strerror (errno));
-	  exit (EXIT_FAILURE);
-	}
-      pthread_join (im->pthread[i], NULL);
-    }
-
-  free (im->pthread);
-  free (im->ptd);
-
-  return 0;
-}
diff --git a/extras/libmemif/examples/icmp_responder-zero-copy-slave/main.c b/extras/libmemif/examples/icmp_responder-zero-copy-slave/main.c
deleted file mode 100644
index 3f871d7..0000000
--- a/extras/libmemif/examples/icmp_responder-zero-copy-slave/main.c
+++ /dev/null
@@ -1,1270 +0,0 @@
-/*
- *------------------------------------------------------------------
- * 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.
- *------------------------------------------------------------------
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <net/if.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/uio.h>
-#include <sys/mman.h>
-#include <sys/prctl.h>
-#include <inttypes.h>
-#include <string.h>
-#include <stdio.h>
-#include <netdb.h>
-#include <linux/ip.h>
-#include <linux/icmp.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-#include <netinet/if_ether.h>
-#include <net/if_arp.h>
-#include <asm/byteorder.h>
-#include <byteswap.h>
-#include <string.h>
-#include <sys/epoll.h>
-#include <errno.h>
-#include <unistd.h>
-#include <signal.h>
-
-#include <time.h>
-
-#include <libmemif.h>
-#include <icmp_proto.h>
-
-#define APP_NAME "ICMP_Responder"
-#define IF_NAME  "memif_connection"
-
-#define HEADROOM 0x80		/* 128b */
-#define ENCAP 0x60
-
-#ifdef ICMP_DBG
-#define DBG(...) do {                                               \
-                    printf (APP_NAME":%s:%d: ", __func__, __LINE__);         \
-                    printf (__VA_ARGS__);                           \
-                    printf ("\n");                                  \
-                } while (0)
-#define LOG(...) do {                                               \
-                    if (enable_log) {                               \
-                        dprintf (out_fd, __VA_ARGS__);              \
-                        dprintf (out_fd, "\n");                     \
-                    }                                               \
-                } while (0)
-#define LOG_FILE "/tmp/memif_time_test.txt"
-#else
-#define DBG(...)
-#define LOG(...)
-#endif
-
-#define INFO(...) do {                                              \
-                    printf ("INFO: "__VA_ARGS__);                   \
-                    printf ("\n");                                  \
-                } while (0)
-
-
-/* maximum tx/rx memif buffers */
-#define MAX_MEMIF_BUFS  256
-#define MAX_CONNS       50
-
-int epfd;
-int out_fd;
-uint8_t enable_log;
-
-typedef struct
-{
-  uint16_t index;
-  /* memif connection handle */
-  memif_conn_handle_t conn;
-  /* buffers */
-  memif_buffer_t *bufs;
-  /* allocated tx buffers counter */
-  /* number of tx buffers pointing to shared memory */
-  uint16_t tx_buf_num;
-  /* allocated rx buffers counter */
-  /* number of rx buffers pointing to shared memory */
-  uint16_t rx_buf_num;
-  /* interface ip address */
-  uint8_t ip_addr[4];
-  uint64_t tx_counter, rx_counter, tx_err_counter;
-  uint64_t t_sec, t_nsec;
-} memif_connection_t;
-
-typedef struct
-{
-  uint16_t index;
-  icmpr_flow_mode_t mode;
-  uint64_t packet_count;
-  uint16_t sequence;
-  uint64_t tx;
-  uint8_t ip_daddr[4];
-  uint8_t hw_daddr[6];
-  struct timespec *start, end;
-} icmpr_flow_t;
-
-memif_connection_t memif_connection[MAX_CONNS];
-long ctx[MAX_CONNS];
-icmpr_flow_t *flow;
-
-/* print details for all memif connections */
-static void
-print_memif_details ()
-{
-  memif_details_t md;
-  ssize_t buflen;
-  char *buf;
-  int err, i, e;
-  buflen = 2048;
-  buf = malloc (buflen);
-  printf ("MEMIF DETAILS\n");
-  printf ("==============================\n");
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-
-      memset (&md, 0, sizeof (md));
-      memset (buf, 0, buflen);
-
-      err = memif_get_details (c->conn, &md, buf, buflen);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  if (err != MEMIF_ERR_NOCONN)
-	    INFO ("%s", memif_strerror (err));
-	  continue;
-	}
-
-      printf ("interface index: %d\n", i);
-
-      printf ("\tinterface ip: %u.%u.%u.%u\n",
-	      c->ip_addr[0], c->ip_addr[1], c->ip_addr[2], c->ip_addr[3]);
-      printf ("\tinterface name: %s\n", (char *) md.if_name);
-      printf ("\tapp name: %s\n", (char *) md.inst_name);
-      printf ("\tremote interface name: %s\n", (char *) md.remote_if_name);
-      printf ("\tremote app name: %s\n", (char *) md.remote_inst_name);
-      printf ("\tid: %u\n", md.id);
-      printf ("\tsecret: %s\n", (char *) md.secret);
-      printf ("\trole: ");
-      if (md.role)
-	printf ("slave\n");
-      else
-	printf ("master\n");
-      printf ("\tmode: ");
-      switch (md.mode)
-	{
-	case 0:
-	  printf ("ethernet\n");
-	  break;
-	case 1:
-	  printf ("ip\n");
-	  break;
-	case 2:
-	  printf ("punt/inject\n");
-	  break;
-	default:
-	  printf ("unknown\n");
-	  break;
-	}
-      printf ("\tsocket filename: %s\n", (char *) md.socket_filename);
-      printf ("\trx queues:\n");
-      for (e = 0; e < md.rx_queues_num; e++)
-	{
-	  printf ("\t\tqueue id: %u\n", md.rx_queues[e].qid);
-	  printf ("\t\tring size: %u\n", md.rx_queues[e].ring_size);
-	  printf ("\t\tring rx mode: %s\n",
-		  md.rx_queues[e].flags ? "polling" : "interrupt");
-	  printf ("\t\tring head: %u\n", md.rx_queues[e].head);
-	  printf ("\t\tring tail: %u\n", md.rx_queues[e].tail);
-	  printf ("\t\tbuffer size: %u\n", md.rx_queues[e].buffer_size);
-	}
-      printf ("\ttx queues:\n");
-      for (e = 0; e < md.tx_queues_num; e++)
-	{
-	  printf ("\t\tqueue id: %u\n", md.tx_queues[e].qid);
-	  printf ("\t\tring size: %u\n", md.tx_queues[e].ring_size);
-	  printf ("\t\tring rx mode: %s\n",
-		  md.tx_queues[e].flags ? "polling" : "interrupt");
-	  printf ("\t\tring head: %u\n", md.tx_queues[e].head);
-	  printf ("\t\tring tail: %u\n", md.tx_queues[e].tail);
-	  printf ("\t\tbuffer size: %u\n", md.tx_queues[e].buffer_size);
-	}
-      printf ("\tlink: ");
-      if (md.link_up_down)
-	printf ("up\n");
-      else
-	printf ("down\n");
-    }
-  free (buf);
-}
-
-int
-add_epoll_fd (int fd, uint32_t events)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = events;
-  evt.data.fd = fd;
-  if (epoll_ctl (epfd, EPOLL_CTL_ADD, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d added to epoll", fd);
-  return 0;
-}
-
-int
-mod_epoll_fd (int fd, uint32_t events)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = events;
-  evt.data.fd = fd;
-  if (epoll_ctl (epfd, EPOLL_CTL_MOD, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d modified on epoll", fd);
-  return 0;
-}
-
-int
-del_epoll_fd (int fd)
-{
-  if (fd < 0)
-    {
-      DBG ("invalid fd %d", fd);
-      return -1;
-    }
-  struct epoll_event evt;
-  memset (&evt, 0, sizeof (evt));
-  if (epoll_ctl (epfd, EPOLL_CTL_DEL, fd, &evt) < 0)
-    {
-      DBG ("epoll_ctl: %s fd %d", strerror (errno), fd);
-      return -1;
-    }
-  DBG ("fd %d removed from epoll", fd);
-  return 0;
-}
-
-/* informs user about connected status. private_ctx is used by user to identify connection
-    (multiple connections WIP) */
-int
-on_connect (memif_conn_handle_t conn, void *private_ctx)
-{
-  INFO ("memif connected!");
-  memif_refill_queue (conn, 0, -1, HEADROOM);
-  enable_log = 1;
-  return 0;
-}
-
-/* informs user about disconnected status. private_ctx is used by user to identify connection
-    (multiple connections WIP) */
-int
-on_disconnect (memif_conn_handle_t conn, void *private_ctx)
-{
-  INFO ("memif disconnected!");
-  return 0;
-}
-
-/* user needs to watch new fd or stop watching fd that is about to be closed.
-    control fd will be modified during connection establishment to minimize CPU usage */
-int
-control_fd_update (int fd, uint8_t events, void *ctx)
-{
-  /* convert memif event definitions to epoll events */
-  if (events & MEMIF_FD_EVENT_DEL)
-    return del_epoll_fd (fd);
-
-  uint32_t evt = 0;
-  if (events & MEMIF_FD_EVENT_READ)
-    evt |= EPOLLIN;
-  if (events & MEMIF_FD_EVENT_WRITE)
-    evt |= EPOLLOUT;
-
-  if (events & MEMIF_FD_EVENT_MOD)
-    return mod_epoll_fd (fd, evt);
-
-  return add_epoll_fd (fd, evt);
-}
-
-/* called when event is polled on interrupt file descriptor.
-    there are packets in shared memory ready to be received */
-/* handle packet processing in rx buffer then enqueue this buffer to tx and transmit */
-int
-on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
-{
-  long index = *((long *) private_ctx);
-  memif_connection_t *c = &memif_connection[index];
-  if (c->index != index)
-    {
-      INFO ("invalid context: %ld/%u", index, c->index);
-      return 0;
-    }
-
-  int err = MEMIF_ERR_SUCCESS, ret_val;
-  uint16_t rx = 0, tx = 0;
-  int i = 0;			/* rx buffer iterator */
-
-  /* loop while there are packets in shm */
-  do
-    {
-      /* receive data from shared memory buffers (dequeue rx buffers) */
-      err = memif_rx_burst (c->conn, qid, c->bufs, MAX_MEMIF_BUFS, &rx);
-      ret_val = err;
-      c->rx_counter += rx;
-      c->rx_buf_num += rx;
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF))
-	{
-	  INFO ("memif_rx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-
-      /* process buffers in place */
-      for (i = 0; i < rx; i++)
-	{
-	  resolve_packet2 ((void *) (c->bufs + i)->data,
-			   &(c->bufs + i)->len, c->ip_addr);
-	}
-
-      /* enqueue processed buffers to tx ring */
-      err = memif_buffer_enq_tx (c->conn, qid, c->bufs, i, &tx);
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
-	{
-	  INFO ("memif_buffer_alloc: %s", memif_strerror (err));
-	  goto error;
-	}
-      c->rx_buf_num -= tx;
-      c->tx_buf_num += tx;
-      c->tx_err_counter += i - tx;
-
-      /* mark memif buffers and shared memory buffers as free */
-      err = memif_refill_queue (c->conn, qid, rx, HEADROOM);
-      if (err != MEMIF_ERR_SUCCESS)
-	INFO ("memif_buffer_free: %s", memif_strerror (err));
-      c->rx_buf_num -= rx;
-
-      DBG ("freed %d buffers. %u/%u alloc/free buffers",
-	   rx, rx, MAX_MEMIF_BUFS - rx);
-
-      /* transmit allocated buffers */
-      err = memif_tx_burst (c->conn, qid, c->bufs, rx, &tx);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  INFO ("memif_tx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-      c->tx_counter += tx;
-
-    }
-  while (ret_val == MEMIF_ERR_NOBUF);
-
-  return 0;
-
-error:
-  err = memif_refill_queue (c->conn, qid, -1, HEADROOM);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_buffer_free: %s", memif_strerror (err));
-  c->rx_buf_num = 0;
-  DBG ("freed %d buffers. %u/%u alloc/free buffers",
-       rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
-  return 0;
-}
-
-/* add ethernet encap to packet in rx buffer then enqueue this buffer to tx and transmit */
-int
-on_interrupt0 (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
-{
-  long index = *((long *) private_ctx);
-  memif_connection_t *c = &memif_connection[index];
-  if (c->index != index)
-    {
-      INFO ("invalid context: %ld/%u", index, c->index);
-      return 0;
-    }
-
-  int err = MEMIF_ERR_SUCCESS, ret_val;
-  uint16_t rx = 0, tx = 0;
-  int i = 0;			/* rx buffer iterator */
-
-  /* loop while there are packets in shm */
-  do
-    {
-      /* receive data from shared memory buffers (dequeue rx buffers) */
-      err = memif_rx_burst (c->conn, qid, c->bufs, MAX_MEMIF_BUFS, &rx);
-      ret_val = err;
-      c->rx_counter += rx;
-      c->rx_buf_num += rx;
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF))
-	{
-	  INFO ("memif_rx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-
-      /* process bufers in place */
-      for (i = 0; i < rx; i++)
-	{
-	  resolve_packet3 (&c->bufs[i].data, &c->bufs[i].len, c->ip_addr);
-	}
-      /* enque processed buffers to tx ring */
-      err = memif_buffer_enq_tx (c->conn, qid, c->bufs, rx, &tx);
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
-	{
-	  INFO ("memif_buffer_alloc: %s", memif_strerror (err));
-	  goto error;
-	}
-      c->rx_buf_num -= tx;
-      c->tx_buf_num += tx;
-      c->tx_err_counter += i - tx;
-
-      /* mark memif buffers and shared memory buffers as free */
-      err = memif_refill_queue (c->conn, qid, rx, HEADROOM);
-      if (err != MEMIF_ERR_SUCCESS)
-	INFO ("memif_buffer_free: %s", memif_strerror (err));
-      c->rx_buf_num -= rx;
-
-      DBG ("freed %d buffers. %u/%u alloc/free buffers",
-	   rx, rx, MAX_MEMIF_BUFS - rx);
-
-      /* transmit allocated buffers */
-      err = memif_tx_burst (c->conn, qid, c->bufs, i, &tx);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  INFO ("memif_tx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-      c->tx_counter += tx;
-
-    }
-  while (ret_val == MEMIF_ERR_NOBUF);
-
-  return 0;
-
-error:
-  err = memif_refill_queue (c->conn, qid, -1, HEADROOM);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_buffer_free: %s", memif_strerror (err));
-  c->rx_buf_num = 0;
-  DBG ("freed %d buffers. %u/%u alloc/free buffers",
-       rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
-  return 0;
-}
-
-/* called when event is polled on interrupt file descriptor.
-    there are packets in shared memory ready to be received */
-/* dev test modification: handle only ARP requests */
-int
-on_interrupt1 (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
-{
-  long index = *((long *) private_ctx);
-  memif_connection_t *c = &memif_connection[index];
-  if (c->index != index)
-    {
-      INFO ("invalid context: %ld/%u", index, c->index);
-      return 0;
-    }
-
-  int err = MEMIF_ERR_SUCCESS, ret_val;
-  int i;
-  uint16_t rx, tx;
-
-  do
-    {
-      /* receive data from shared memory buffers */
-      err = memif_rx_burst (c->conn, qid, c->bufs, MAX_MEMIF_BUFS, &rx);
-      ret_val = err;
-      c->rx_buf_num += rx;
-      c->rx_counter += rx;
-      if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF))
-	{
-	  INFO ("memif_rx_burst: %s", memif_strerror (err));
-	  goto error;
-	}
-
-      for (i = 0; i < rx; i++)
-	{
-	  if (((struct ether_header *) (c->bufs + i)->data)->ether_type ==
-	      0x0608)
-	    {
-	      /* process data in place */
-	      resolve_packet2 ((void *) (c->bufs + i)->data,
-			       &(c->bufs + i)->len, c->ip_addr);
-	      /* enque buffer to tx ring */
-	      memif_buffer_enq_tx (c->conn, qid, c->bufs, 1, &tx);
-	      c->rx_buf_num -= tx;
-	      memif_tx_burst (c->conn, qid, c->bufs, 1, &tx);
-	    }
-	}
-
-      err = memif_refill_queue (c->conn, qid, -1, HEADROOM);
-      if (err != MEMIF_ERR_SUCCESS)
-	INFO ("memif_buffer_free: %s", memif_strerror (err));
-      c->rx_buf_num -= rx;
-
-    }
-  while (ret_val == MEMIF_ERR_NOBUF);
-
-  return 0;
-
-error:
-  err = memif_refill_queue (c->conn, qid, -1, HEADROOM);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_buffer_free: %s", memif_strerror (err));
-  c->rx_buf_num = 0;
-  DBG ("freed %d buffers. %u/%u alloc/free buffers",
-       rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
-  return 0;
-}
-
-int
-icmpr_memif_create (long index, long mode, char *s)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("don't even try...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-
-  /* setting memif connection arguments */
-  memif_conn_args_t args;
-  memset (&args, 0, sizeof (args));
-  args.is_master = mode;
-  args.log2_ring_size = 11;
-  args.buffer_size = 2048;
-  args.num_s2m_rings = 1;
-  args.num_m2s_rings = 1;
-  strncpy ((char *) args.interface_name, IF_NAME, strlen (IF_NAME));
-  args.mode = 0;
-  /* socket filename is not specified, because this app is supposed to
-     connect to VPP over memif. so default socket filename will be used */
-  /* default socketfile = /run/vpp/memif.sock */
-
-  args.interface_id = index;
-  /* last argument for memif_create (void * private_ctx) is used by user
-     to identify connection. this context is returned with callbacks */
-  int err;
-  /* default interrupt */
-  if (s == NULL)
-    {
-      err = memif_create (&c->conn,
-			  &args, on_connect, on_disconnect, on_interrupt,
-			  &ctx[index]);
-      if (err != MEMIF_ERR_SUCCESS)
-	{
-	  INFO ("memif_create: %s", memif_strerror (err));
-	  return 0;
-	}
-    }
-  else
-    {
-      if (strncmp (s, "0", 1) == 0)
-	{
-	  err = memif_create (&c->conn,
-			      &args, on_connect, on_disconnect, on_interrupt0,
-			      &ctx[index]);
-	  if (err != MEMIF_ERR_SUCCESS)
-	    {
-	      INFO ("memif_create: %s", memif_strerror (err));
-	      return 0;
-	    }
-	}
-      else if (strncmp (s, "1", 1) == 0)
-	{
-	  err = memif_create (&c->conn,
-			      &args, on_connect, on_disconnect, on_interrupt1,
-			      &ctx[index]);
-	  if (err != MEMIF_ERR_SUCCESS)
-	    {
-	      INFO ("memif_create: %s", memif_strerror (err));
-	      return 0;
-	    }
-	}
-      else
-	{
-	  INFO ("Unknown interrupt descriptor");
-	  goto done;
-	}
-    }
-
-  c->index = index;
-  /* alloc memif buffers */
-  c->rx_buf_num = 0;
-  c->tx_buf_num = 0;
-  c->bufs =
-    (memif_buffer_t *) malloc (sizeof (memif_buffer_t) * MAX_MEMIF_BUFS);
-
-  c->ip_addr[0] = 192;
-  c->ip_addr[1] = 168;
-  c->ip_addr[2] = c->index + 1;
-  c->ip_addr[3] = 2;
-
-  c->tx_err_counter = c->tx_counter = c->rx_counter = 0;
-
-done:
-  return 0;
-}
-
-int
-icmpr_memif_delete (long index)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("don't even try...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-
-  if (c->bufs)
-    free (c->bufs);
-  c->bufs = NULL;
-  c->tx_buf_num = 0;
-  c->rx_buf_num = 0;
-
-  int err;
-  /* disconnect then delete memif connection */
-  err = memif_delete (&c->conn);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_delete: %s", memif_strerror (err));
-  if (c->conn != NULL)
-    INFO ("memif delete fail");
-  return 0;
-}
-
-void
-print_help ()
-{
-  printf ("LIBMEMIF EXAMPLE APP: %s", APP_NAME);
-#ifdef ICMP_DBG
-  printf (" (debug)");
-#endif
-  printf ("\n");
-  printf ("==============================\n");
-  printf ("libmemif version: %s", LIBMEMIF_VERSION);
-#ifdef MEMIF_DBG
-  printf (" (debug)");
-#endif
-  printf ("\n");
-  printf ("memif version: %d\n", memif_get_version ());
-  printf ("commands:\n");
-  printf ("\thelp - prints this help\n");
-  printf ("\texit - exit app\n");
-  printf
-    ("\tconn <index> <mode> [<interrupt-desc>] - create memif. index is also used as interface id, mode 0 = slave 1 = master, interrupt-desc none = default 0 = if ring is full wait 1 = handle only ARP requests\n");
-  printf ("\tdel  <index> - delete memif\n");
-  printf ("\tshow - show connection details\n");
-  printf ("\tip-set <index> <ip-addr> - set interface ip address\n");
-  printf
-    ("\trx-mode <index> <qid> <polling|interrupt> - set queue rx mode\n");
-  printf ("\tsh-count - print counters\n");
-  printf ("\tcl-count - clear counters\n");
-  printf
-    ("\tsend <index> <tx> <ip> <mac> - send icmp, ommit mac to transmit on ip layer\n");
-}
-
-int
-icmpr_free ()
-{
-  /* application cleanup */
-  int err;
-  long i;
-  if (out_fd > 0)
-    close (out_fd);
-  out_fd = -1;
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-      if (c->conn)
-	icmpr_memif_delete (i);
-    }
-
-  err = memif_cleanup ();
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_delete: %s", memif_strerror (err));
-
-  return 0;
-}
-
-int
-icmpr_set_ip (long index, char *ip)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("don't even try...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-  if (c->conn == NULL)
-    {
-      INFO ("no connection at index %ld", index);
-      return 0;
-    }
-
-  char *end;
-  char *ui;
-  uint8_t tmp[4];
-  ui = strtok (ip, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[0] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[1] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[2] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[3] = strtol (ui, &end, 10);
-
-  c->ip_addr[0] = tmp[0];
-  c->ip_addr[1] = tmp[1];
-  c->ip_addr[2] = tmp[2];
-  c->ip_addr[3] = tmp[3];
-
-  INFO ("memif %ld ip address set to %u.%u.%u.%u",
-	index, c->ip_addr[0], c->ip_addr[1], c->ip_addr[2], c->ip_addr[3]);
-
-  return 0;
-
-error:
-  INFO ("invalid ip address");
-  return 0;
-}
-
-int
-icmpr_set_rx_mode (long index, long qid, char *mode)
-{
-  if (index >= MAX_CONNS)
-    {
-      INFO ("connection array overflow");
-      return 0;
-    }
-  if (index < 0)
-    {
-      INFO ("don't even try...");
-      return 0;
-    }
-  memif_connection_t *c = &memif_connection[index];
-
-  if (c->conn == NULL)
-    {
-      INFO ("no connection at index %ld", index);
-      return 0;
-    }
-
-  if (strncmp (mode, "interrupt", 9) == 0)
-    {
-      memif_set_rx_mode (c->conn, MEMIF_RX_MODE_INTERRUPT, qid);
-    }
-
-  else if (strncmp (mode, "polling", 7) == 0)
-    {
-      memif_set_rx_mode (c->conn, MEMIF_RX_MODE_POLLING, qid);
-    }
-  else
-    INFO ("expected rx mode <interrupt|polling>");
-  return 0;
-}
-
-void
-icmpr_print_counters ()
-{
-  int i;
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-      if (c->conn == NULL)
-	continue;
-      printf ("===============================\n");
-      printf ("interface index: %d\n", c->index);
-      printf ("\trx: %lu\n", c->rx_counter);
-      printf ("\ttx: %lu\n", c->tx_counter);
-      printf ("\ttx_err: %lu\n", c->tx_err_counter);
-      printf ("\tts: %lus %luns\n", c->t_sec, c->t_nsec);
-    }
-}
-
-void
-icmpr_reset_counters ()
-{
-  int i;
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection_t *c = &memif_connection[i];
-      if (c->conn == NULL)
-	continue;
-      c->t_sec = c->t_nsec = c->tx_err_counter = c->tx_counter =
-	c->rx_counter = 0;
-    }
-}
-
-void
-icmpr_send_proc ()
-{
-  memif_connection_t *c = &memif_connection[flow->index];
-  if (c->conn == NULL)
-    {
-      INFO ("No connection at index %d. Stopping flow...\n", flow->index);
-      goto stop_flow;
-    }
-  uint16_t tx, i;
-  int err = MEMIF_ERR_SUCCESS;
-
-  if (!flow->start)
-    {
-      flow->start = malloc (sizeof (struct timespec));
-      memset (flow->start, 0, sizeof (struct timespec));
-      timespec_get (flow->start, TIME_UTC);
-    }
-
-  i = 0;
-  err = memif_buffer_alloc (c->conn, 0, c->bufs,
-			    MAX_MEMIF_BUFS >
-			    flow->packet_count ? flow->packet_count :
-			    MAX_MEMIF_BUFS, &tx, 64);
-  if ((err != MEMIF_ERR_SUCCESS) && (err != MEMIF_ERR_NOBUF_RING))
-    {
-      INFO ("memif_buffer_alloc: %s Stopping flow...\n",
-	    memif_strerror (err));
-      goto stop_flow;
-    }
-  c->tx_buf_num += tx;
-
-  while (tx)
-    {
-      generate_packet2 ((void *) c->bufs[i].data,
-			&c->bufs[i].len, c->ip_addr,
-			flow->ip_daddr, flow->hw_daddr, (flow->sequence)++,
-			flow->mode);
-      i++;
-      tx--;
-    }
-  err = memif_tx_burst (c->conn, 0, c->bufs, i, &tx);
-  if (err != MEMIF_ERR_SUCCESS)
-    {
-      INFO ("memif_tx_burst: %s Stopping flow...\n", memif_strerror (err));
-      goto stop_flow;
-    }
-  c->tx_buf_num -= tx;
-  c->tx_counter += tx;
-  flow->tx += tx;
-  flow->packet_count -= tx;
-
-  if (flow->packet_count == 0)
-    {
-      timespec_get (&flow->end, TIME_UTC);
-      INFO ("Flow finished!");
-      INFO ("Flow length: %lu", flow->tx);
-      uint64_t t1 = flow->end.tv_sec - flow->start->tv_sec;
-      uint64_t t2;
-      if (flow->end.tv_nsec > flow->start->tv_nsec)
-	{
-	  t2 = flow->end.tv_nsec - flow->start->tv_nsec;
-	}
-      else
-	{
-	  t2 = flow->start->tv_nsec - flow->end.tv_nsec;
-	  t1--;
-	}
-      c->t_sec = t1;
-      c->t_nsec = t2;
-      INFO ("Flow time: %lus %luns", t1, t2);
-      double tmp = t1;
-      tmp += t2 / 1e+9;
-      tmp = flow->tx / tmp;
-      INFO ("Average pps: %f", tmp);
-      INFO ("Stopping flow...");
-      goto stop_flow;
-    }
-
-  return;
-
-stop_flow:
-  if (flow)
-    {
-      if (flow->start)
-	free (flow->start);
-      free (flow);
-    }
-  flow = NULL;
-  return;
-}
-
-int
-icmpr_send (long index, long packet_num, char *input)
-{
-  if (flow)
-    {
-      printf ("only one flow allowed\n");
-      return 0;
-    }
-
-  memif_connection_t *c = &memif_connection[index];
-  char *end;
-  char *ui;
-  uint8_t tmp[6];
-  if (c->conn == NULL)
-    return -1;
-
-  flow = malloc (sizeof (icmpr_flow_t));
-  flow->index = index;
-  flow->packet_count = packet_num;
-  flow->sequence = 0;
-  flow->tx = 0;
-  flow->start = NULL;
-  memset (&flow->end, 0, sizeof (struct timespec));
-
-  INFO ("packet count: %lu", flow->packet_count);
-  printf ("%s\n", input);
-
-  ui = strtok (input, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[0] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[1] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[2] = strtol (ui, &end, 10);
-
-  ui = strtok (NULL, ".");
-  if (ui == NULL)
-    goto error;
-  tmp[3] = strtol (ui, &end, 10);
-
-  flow->ip_daddr[0] = tmp[0];
-  flow->ip_daddr[1] = tmp[1];
-  flow->ip_daddr[2] = tmp[2];
-  flow->ip_daddr[3] = tmp[3];
-
-  ui = strtok (NULL, " ");
-  if (ui == NULL)
-    {
-      flow->mode = ICMPR_FLOW_MODE_IP;
-      return 0;
-    }
-
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[0] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[1] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[2] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[3] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[4] = strtol (ui, &end, 16);
-  ui = strtok (NULL, ":");
-  if (ui == NULL)
-    goto error;
-  tmp[5] = strtol (ui, &end, 16);
-
-  flow->hw_daddr[0] = tmp[0];
-  flow->hw_daddr[1] = tmp[1];
-  flow->hw_daddr[2] = tmp[2];
-  flow->hw_daddr[3] = tmp[3];
-  flow->hw_daddr[4] = tmp[4];
-  flow->hw_daddr[5] = tmp[5];
-
-  flow->mode = ICMPR_FLOW_MODE_ETH;
-
-  return 0;
-
-error:
-  INFO ("Invalid input\n");
-  if (flow)
-    free (flow);
-  flow = NULL;
-  return 0;
-}
-
-int
-user_input_handler ()
-{
-  char *in = (char *) malloc (256);
-  char *ui = fgets (in, 256, stdin);
-  char *end;
-  long a;
-  if (in[0] == '\n')
-    goto done;
-  ui = strtok (in, " ");
-  if (strncmp (ui, "exit", 4) == 0)
-    {
-      free (in);
-      icmpr_free ();
-      exit (EXIT_SUCCESS);
-    }
-  else if (strncmp (ui, "help", 4) == 0)
-    {
-      print_help ();
-      goto done;
-    }
-  else if (strncmp (ui, "conn", 4) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	a = strtol (ui, &end, 10);
-      else
-	{
-	  INFO ("expected id");
-	  goto done;
-	}
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_memif_create (a, strtol (ui, &end, 10), strtok (NULL, " "));
-      else
-	INFO ("expected mode <0|1>");
-      goto done;
-    }
-  else if (strncmp (ui, "del", 3) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_memif_delete (strtol (ui, &end, 10));
-      else
-	INFO ("expected id");
-      goto done;
-    }
-  else if (strncmp (ui, "show", 4) == 0)
-    {
-      print_memif_details ();
-      goto done;
-    }
-  else if (strncmp (ui, "ip-set", 6) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_set_ip (strtol (ui, &end, 10), strtok (NULL, " "));
-      else
-	INFO ("expected id");
-      goto done;
-    }
-  else if (strncmp (ui, "rx-mode", 7) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	a = strtol (ui, &end, 10);
-      else
-	{
-	  INFO ("expected id");
-	  goto done;
-	}
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_set_rx_mode (a, strtol (ui, &end, 10), strtok (NULL, " "));
-      else
-	INFO ("expected qid");
-      goto done;
-    }
-  else if (strncmp (ui, "sh-count", 8) == 0)
-    {
-      icmpr_print_counters ();
-    }
-  else if (strncmp (ui, "cl-count", 8) == 0)
-    {
-      icmpr_reset_counters ();
-    }
-  else if (strncmp (ui, "send", 4) == 0)
-    {
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	a = strtol (ui, &end, 10);
-      else
-	{
-	  INFO ("expected id");
-	  goto done;
-	}
-      ui = strtok (NULL, " ");
-      if (ui != NULL)
-	icmpr_send (a, strtol (ui, &end, 10), strtok (NULL, " "));
-      else
-	INFO ("expected count");
-      goto done;
-    }
-  else
-    {
-      INFO ("unknown command: %s", ui);
-      goto done;
-    }
-
-  return 0;
-done:
-  free (in);
-  return 0;
-}
-
-int
-poll_event (int timeout)
-{
-  struct epoll_event evt;
-  int app_err = 0, memif_err = 0, en = 0;
-  uint32_t events = 0;
-  struct timespec start, end;
-  memset (&evt, 0, sizeof (evt));
-  evt.events = EPOLLIN | EPOLLOUT;
-  sigset_t sigset;
-  sigemptyset (&sigset);
-  en = epoll_pwait (epfd, &evt, 1, timeout, &sigset);
-  /* id event polled */
-  timespec_get (&start, TIME_UTC);
-  if (en < 0)
-    {
-      DBG ("epoll_pwait: %s", strerror (errno));
-      return -1;
-    }
-  if (en > 0)
-    {
-      /* this app does not use any other file descriptors than stds and memif control fds */
-      if (evt.data.fd > 2)
-	{
-	  /* event of memif control fd */
-	  /* convert epoll events to memif events */
-	  if (evt.events & EPOLLIN)
-	    events |= MEMIF_FD_EVENT_READ;
-	  if (evt.events & EPOLLOUT)
-	    events |= MEMIF_FD_EVENT_WRITE;
-	  if (evt.events & EPOLLERR)
-	    events |= MEMIF_FD_EVENT_ERROR;
-	  memif_err = memif_control_fd_handler (evt.data.fd, events);
-	  if (memif_err != MEMIF_ERR_SUCCESS)
-	    INFO ("memif_control_fd_handler: %s", memif_strerror (memif_err));
-	}
-      else if (evt.data.fd == 0)
-	{
-	  app_err = user_input_handler ();
-	}
-      else
-	{
-	  DBG ("unexpected event at memif_epfd. fd %d", evt.data.fd);
-	}
-    }
-
-  timespec_get (&end, TIME_UTC);
-  LOG ("interrupt: %ld", end.tv_nsec - start.tv_nsec);
-
-  if ((app_err < 0) || (memif_err < 0))
-    {
-      if (app_err < 0)
-	DBG ("user input handler error");
-      if (memif_err < 0)
-	DBG ("memif control fd handler error");
-      return -1;
-    }
-
-  return 0;
-}
-
-int
-main ()
-{
-  epfd = epoll_create (1);
-  add_epoll_fd (0, EPOLLIN);
-
-  flow = NULL;
-
-#ifdef LOG_FILE
-  remove (LOG_FILE);
-  enable_log = 0;
-
-  out_fd = open (LOG_FILE, O_WRONLY | O_CREAT, S_IRWXO);
-  if (out_fd < 0)
-    INFO ("Error opening log file: %s", strerror (errno));
-#endif /* LOG_FILE */
-
-  /* initialize memory interface */
-  int err, i;
-  /* if valid callback is passed as argument, fd event polling will be done by user
-     all file descriptors and events will be passed to user in this callback */
-  /* if callback is set to NULL libmemif will handle fd event polling */
-  err = memif_init (control_fd_update, APP_NAME, NULL, NULL, NULL);
-  if (err != MEMIF_ERR_SUCCESS)
-    {
-      INFO ("memif_init: %s", memif_strerror (err));
-      icmpr_free ();
-      exit (-1);
-    }
-
-  for (i = 0; i < MAX_CONNS; i++)
-    {
-      memif_connection[i].conn = NULL;
-      ctx[i] = i;
-    }
-
-  print_help ();
-
-  /* main loop */
-  while (1)
-    {
-      if (poll_event (0) < 0)
-	{
-	  DBG ("poll_event error!");
-	}
-      if (flow)
-	{
-	  icmpr_send_proc ();
-	}
-    }
-}
diff --git a/extras/libmemif/examples/icmp_responder/icmp_proto.c b/extras/libmemif/examples/icmp_responder/icmp_proto.c
deleted file mode 100644
index 785aebd..0000000
--- a/extras/libmemif/examples/icmp_responder/icmp_proto.c
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- *------------------------------------------------------------------
- * 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.
- *------------------------------------------------------------------
- */
-
-#include <stdint.h>
-#include <net/if.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/uio.h>
-#include <sys/mman.h>
-#include <sys/prctl.h>
-#include <inttypes.h>
-#include <string.h>
-#include <stdio.h>
-#include <netdb.h>
-#include <linux/ip.h>
-#include <linux/icmp.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-#include <netinet/if_ether.h>
-#include <net/if_arp.h>
-#include <asm/byteorder.h>
-#include <byteswap.h>
-#include <assert.h>
-
-#include <icmp_proto.h>
-
-static uint16_t
-cksum (void *addr, ssize_t len)
-{
-  char *data = (char *) addr;
-
-  uint32_t acc = 0xffff;
-
-  ssize_t i;
-  for (i = 0; (i + 1) < len; i += 2)
-    {
-      uint16_t word;
-      memcpy (&word, data + i, 2);
-      acc += ntohs (word);
-      if (acc > 0xffff)
-	acc -= 0xffff;
-    }
-
-  if (len & 1)
-    {
-      uint16_t word = 0;
-      memcpy (&word, data + len - 1, 1);
-      acc += ntohs (word);
-      if (acc > 0xffff)
-	acc -= 0xffff;
-    }
-  return htons (~acc);
-}
-
-int
-print_packet (void *pck)
-{
-  if (pck == NULL)
-    {
-      printf ("ICMP_PROTO: no data\n");
-      return -1;
-    }
-  struct iphdr *ip;
-  struct icmphdr *icmp;
-  ip = (struct iphdr *) pck;
-  icmp = (struct icmphdr *) (pck + sizeof (struct iphdr));
-  printf ("received packet:\n");
-  printf ("\tiphdr:\n");
-  printf ("\t\tihl: %u\n\t\tversion: %u\n\t\tlen: %u\n\t\tid: %u\n",
-	  ip->ihl, ip->version, __bswap_16 (ip->tot_len), ip->id);
-  printf ("\t\tprotocol: %u\n", ip->protocol);
-
-  printf ("\t\tsaddr: ");
-  int i;
-  for (i = 0; i < 4; i++)
-    {
-      printf ("%u.", ((uint8_t *) & ip->saddr)[i]);
-    }
-  printf ("\n");
-
-  printf ("\t\tdaddr: ");
-  for (i = 0; i < 4; i++)
-    {
-      printf ("%u.", ((uint8_t *) & ip->daddr)[i]);
-    }
-  printf ("\n");
-  printf ("\ticmphdr:\n");
-  printf ("\t\ttype: %s\n",
-	  (icmp->type == ICMP_ECHO) ? "ICMP_ECHO" : "ICMP_ECHOREPLY");
-
-  return 0;
-}
-
-static ssize_t
-resolve_arp (void *arp)
-{
-  struct arphdr *resp = (struct arphdr *) arp;
-
-  resp->ar_hrd = __bswap_16 (ARPHRD_ETHER);
-
-  resp->ar_pro = __bswap_16 (0x0800);
-
-  resp->ar_hln = 6;
-  resp->ar_pln = 4;
-
-  resp->ar_op = __bswap_16 (ARPOP_REPLY);
-
-  return sizeof (struct arphdr);
-}
-
-static ssize_t
-resolve_eth_arp (struct ether_arp *eth_arp, void *eth_arp_resp,
-		 uint8_t ip_addr[4])
-{
-  struct ether_arp *resp = (struct ether_arp *) eth_arp_resp;
-
-  resolve_arp (&resp->ea_hdr);
-
-  memcpy (resp->arp_tha, eth_arp->arp_sha, 6);
-  memcpy (resp->arp_tpa, eth_arp->arp_spa, 4);
-
-  memcpy (resp->arp_sha,
-	  (((struct ether_header *) (eth_arp_resp -
-				     sizeof (struct
-					     ether_header)))->ether_shost),
-	  6);
-
-  memcpy (resp->arp_spa, ip_addr, 4);
-
-  return sizeof (struct ether_arp);
-}
-
-static ssize_t
-resolve_eth (struct ether_header *eth, void *eth_resp)
-{
-  struct ether_header *resp = (struct ether_header *) eth_resp;
-  memcpy (resp->ether_dhost, eth->ether_shost, 6);
-
-  uint8_t hw_addr[6];
-  int i;
-  for (i = 0; i < 6; i++)
-    {
-      hw_addr[i] = 'a';
-    }
-  memcpy (resp->ether_shost, hw_addr, 6);
-
-  resp->ether_type = eth->ether_type;
-
-  return sizeof (struct ether_header);
-}
-
-static ssize_t
-resolve_ip (struct iphdr *ip, void *ip_resp, uint8_t ip_addr[4])
-{
-  struct iphdr *resp = (struct iphdr *) ip_resp;
-  resp->ihl = 5;
-  resp->version = 4;
-  resp->tos = 0;
-  /*len updated later */
-  resp->tot_len = 0x0000;
-  resp->id = 0;
-  resp->frag_off = 0;
-  resp->ttl = 0x40;
-  resp->protocol = 1;
-  ((uint8_t *) & resp->saddr)[0] = ip_addr[0];
-  ((uint8_t *) & resp->saddr)[1] = ip_addr[1];
-  ((uint8_t *) & resp->saddr)[2] = ip_addr[2];
-  ((uint8_t *) & resp->saddr)[3] = ip_addr[3];
-  resp->daddr = ip->saddr;
-
-  /* resp->check =  cksum (resp, sizeof (struct iphdr)); */
-
-  return sizeof (struct iphdr);
-}
-
-static ssize_t
-resolve_icmp (struct icmphdr *icmp, void *icmp_resp)
-{
-  struct icmphdr *resp = (struct icmphdr *) icmp_resp;
-  resp->type = 0x00;
-  resp->code = 0;
-  resp->un.echo.id = icmp->un.echo.id;
-  resp->un.echo.sequence = icmp->un.echo.sequence;
-
-  /*resp->checksum = cksum (resp, sizeof (struct icmphdr)); */
-
-  return sizeof (struct icmphdr);
-}
-
-int
-resolve_packet (void *in_pck, ssize_t in_size,
-		void *out_pck, uint32_t * out_size, uint8_t ip_addr[4])
-{
-  struct ether_header *eh;
-  struct ether_arp *eah;
-  struct iphdr *ip, *ip_out;
-  struct icmphdr *icmp;
-  *out_size = 0;
-
-  if ((in_pck == NULL) || (out_pck == NULL))
-    return -1;
-
-  eh = (struct ether_header *) in_pck;
-  *out_size = resolve_eth (eh, out_pck);
-
-  if (eh->ether_type == 0x0608)
-    {
-      eah = (struct ether_arp *) (in_pck + *out_size);
-      *out_size += resolve_eth_arp (eah, out_pck + *out_size, ip_addr);
-
-    }
-  else if (eh->ether_type == 0x0008)
-    {
-#ifdef ICMP_DBG
-      print_packet (in_pck + *out_size);
-#endif
-      ip = (struct iphdr *) (in_pck + *out_size);
-      ip_out = (struct iphdr *) (out_pck + *out_size);
-      *out_size += resolve_ip (ip, out_pck + *out_size, ip_addr);
-      if (ip->protocol == 1)
-	{
-	  icmp = (struct icmphdr *) (in_pck + *out_size);
-	  *out_size += resolve_icmp (icmp, out_pck + *out_size);
-	  ((struct icmphdr *) (out_pck + *out_size -
-			       sizeof (struct icmphdr)))->checksum =
-	    cksum (out_pck + *out_size - sizeof (struct icmphdr),
-		   sizeof (struct icmphdr));
-	  /* payload */
-	  memcpy (out_pck + *out_size, in_pck + *out_size,
-		  in_size - *out_size);
-	  *out_size = in_size;
-	  ip_out->tot_len =
-	    __bswap_16 (*out_size - sizeof (struct ether_header));
-	  ip_out->check = cksum (ip_out, sizeof (struct iphdr));
-	}
-    }
-  return 0;
-}
-
-static ssize_t
-generate_eth (struct ether_header *eh, uint8_t hw_daddr[6])
-{
-  uint8_t hw_addr[6];
-  int i;
-  for (i = 0; i < 6; i++)
-    {
-      hw_addr[i] = 'a';
-    }
-  memcpy (eh->ether_shost, hw_addr, 6);
-  memcpy (eh->ether_dhost, hw_daddr, 6);
-
-  eh->ether_type = 0x0008;
-
-  return sizeof (struct ether_header);
-}
-
-static ssize_t
-generate_ip (struct iphdr *ip, uint8_t saddr[4], uint8_t daddr[4])
-{
-  ip->ihl = 5;
-  ip->version = 4;
-  ip->tos = 0;
-  /*len updated later */
-  ip->tot_len = 0x5400;
-  ip->id = 0;
-  ip->frag_off = 0;
-  ip->ttl = 0x40;
-  ip->protocol = 1;
-  /* saddr */
-  ((uint8_t *) & ip->saddr)[0] = saddr[0];
-  ((uint8_t *) & ip->saddr)[1] = saddr[1];
-  ((uint8_t *) & ip->saddr)[2] = saddr[2];
-  ((uint8_t *) & ip->saddr)[3] = saddr[3];
-  /* daddr */
-  ((uint8_t *) & ip->daddr)[0] = daddr[0];
-  ((uint8_t *) & ip->daddr)[1] = daddr[1];
-  ((uint8_t *) & ip->daddr)[2] = daddr[2];
-  ((uint8_t *) & ip->daddr)[3] = daddr[3];
-
-  ip->check = cksum (ip, sizeof (struct iphdr));
-
-  return sizeof (struct iphdr);
-}
-
-static ssize_t
-generate_icmp (struct icmphdr *icmp, uint32_t seq)
-{
-  icmp->type = ICMP_ECHO;
-  icmp->code = 0;
-  icmp->un.echo.id = 0;
-  icmp->un.echo.sequence = seq;
-
-  return sizeof (struct icmphdr);
-}
-
-int
-generate_packet (void *pck, uint32_t * size, uint8_t saddr[4],
-		 uint8_t daddr[4], uint8_t hw_daddr[6], uint32_t seq)
-{
-  struct ether_header *eh;
-  struct iphdr *ip;
-  struct icmphdr *icmp;
-
-  *size = 0;
-
-  eh = (struct ether_header *) pck;
-  *size += generate_eth (eh, hw_daddr);
-
-  ip = (struct iphdr *) (pck + *size);
-  *size += generate_ip (ip, saddr, daddr);
-
-  icmp = (struct icmphdr *) (pck + *size);
-  *size += generate_icmp (icmp, seq);
-
-  ((struct icmphdr *) (pck + *size - sizeof (struct icmphdr)))->checksum =
-    cksum (pck + *size - sizeof (struct icmphdr), sizeof (struct icmphdr));
-
-  ip->tot_len = __bswap_16 (*size - sizeof (struct ether_header));
-  ip->check = 0;
-  ip->check = cksum (ip, sizeof (struct iphdr));
-
-  return 0;
-}
-
-int
-generate_packet2 (void *pck, uint32_t * size, uint8_t saddr[4],
-		  uint8_t daddr[4], uint8_t hw_daddr[6], uint32_t seq,
-		  icmpr_flow_mode_t mode)
-{
-  struct ether_header *eh;
-  struct iphdr *ip;
-  struct icmphdr *icmp;
-
-  *size = 0;
-
-  if (mode == ICMPR_FLOW_MODE_ETH)
-    {
-      eh = (struct ether_header *) pck;
-      *size += generate_eth (eh, hw_daddr);
-    }
-
-  ip = (struct iphdr *) (pck + *size);
-  *size += generate_ip (ip, saddr, daddr);
-
-  icmp = (struct icmphdr *) (pck + *size);
-  *size += generate_icmp (icmp, seq);
-
-  ((struct icmphdr *) (pck + *size - sizeof (struct icmphdr)))->checksum =
-    cksum (pck + *size - sizeof (struct icmphdr), sizeof (struct icmphdr));
-
-  ip->tot_len = __bswap_16 (*size - sizeof (struct ether_header));
-  ip->check = 0;
-  ip->check = cksum (ip, sizeof (struct iphdr));
-
-  return 0;
-}
-
-#define GET_HEADER(out,hdr,src,off) do {	\
-					out = (hdr*)(src + off); \
-					off += sizeof (hdr); \
-				} while (0)
-
-int
-resolve_packet2 (void *pck, uint32_t * size, uint8_t ip_addr[4])
-{
-  struct ether_header *eh;
-  struct ether_arp *eah;
-  struct iphdr *ip;
-  struct icmphdr *icmp;
-  uint32_t offset = 0;
-
-  if (pck == NULL)
-    return 0;
-
-  GET_HEADER (eh, struct ether_header, pck, offset);
-
-  memcpy (eh->ether_dhost, eh->ether_shost, 6);
-  memcpy (eh->ether_shost, "aaaaaa", 6);
-
-  if (eh->ether_type == 0x0608)
-    {
-      GET_HEADER (eah, struct ether_arp, pck, offset);
-      struct arphdr *arp = &eah->ea_hdr;
-
-      arp->ar_hrd = __bswap_16 (ARPHRD_ETHER);
-      arp->ar_pro = __bswap_16 (0x0800);
-
-      arp->ar_hln = 6;
-      arp->ar_pln = 4;
-
-      arp->ar_op = __bswap_16 (ARPOP_REPLY);
-
-      memcpy (eah->arp_tha, eah->arp_sha, 6);
-      memcpy (eah->arp_tpa, eah->arp_spa, 4);
-
-      memcpy (eah->arp_sha, eh->ether_shost, 6);
-      memcpy (eah->arp_spa, ip_addr, 4);
-    }
-
-  else if (eh->ether_type == 0x0008)
-    {
-      GET_HEADER (ip, struct iphdr, pck, offset);
-
-      if (ip->protocol == 1)
-	{
-	  ip->ihl = 5;
-	  ip->version = 4;
-	  ip->tos = 0;
-	  ip->tot_len = 0x0000;
-	  ip->id = 0;
-	  ip->frag_off = 0;
-	  ip->ttl = 0x40;
-	  ip->protocol = 1;
-	  ip->check = 0x0000;
-	  ip->daddr = ip->saddr;
-	  ((uint8_t *) & ip->saddr)[0] = ip_addr[0];
-	  ((uint8_t *) & ip->saddr)[1] = ip_addr[1];
-	  ((uint8_t *) & ip->saddr)[2] = ip_addr[2];
-	  ((uint8_t *) & ip->saddr)[3] = ip_addr[3];
-
-	  GET_HEADER (icmp, struct icmphdr, pck, offset);
-
-	  icmp->type = 0x00;
-	  icmp->code = 0;
-	  icmp->checksum = cksum (icmp, sizeof (struct icmphdr));
-
-	  /* rest is payload */
-	  offset = *size;
-
-	  ip->tot_len = __bswap_16 (offset - sizeof (struct ether_header));
-	  ip->check = cksum (ip, sizeof (struct iphdr));
-	}
-    }
-
-  assert (offset == *size && "unsupported protocol");
-  return 0;
-}
-
-
-int
-resolve_packet3 (void **pck_, uint32_t * size, uint8_t ip_addr[4])
-{
-  struct ether_header *eh;
-  struct iphdr *ip;
-  struct icmphdr *icmp;
-  int32_t offset = 0;
-  uint16_t encap_size = sizeof (struct ether_header);
-  void *pck = *pck_;
-
-  if (pck == NULL)
-    return 0;
-
-  *pck_ -= encap_size;
-  offset -= encap_size;
-
-  GET_HEADER (eh, struct ether_header, pck, offset);
-
-  uint8_t hw_daddr[6];
-  memset (hw_daddr, 0, sizeof (uint8_t) * 6);
-
-  generate_eth (eh, hw_daddr);
-
-  if (eh->ether_type == 0x0008)
-    {
-      GET_HEADER (ip, struct iphdr, pck, offset);
-
-      if (ip->protocol == 1)
-	{
-	  ip->ihl = 5;
-	  ip->version = 4;
-	  ip->tos = 0;
-	  ip->tot_len = 0x0000;
-	  ip->id = 0;
-	  ip->frag_off = 0;
-	  ip->ttl = 0x40;
-	  ip->protocol = 1;
-	  ip->check = 0x0000;
-	  ip->daddr = ip->saddr;
-	  ((uint8_t *) & ip->saddr)[0] = ip_addr[0];
-	  ((uint8_t *) & ip->saddr)[1] = ip_addr[1];
-	  ((uint8_t *) & ip->saddr)[2] = ip_addr[2];
-	  ((uint8_t *) & ip->saddr)[3] = ip_addr[3];
-
-	  GET_HEADER (icmp, struct icmphdr, pck, offset);
-
-	  icmp->type = 0x00;
-	  icmp->code = 0;
-	  icmp->checksum = cksum (icmp, sizeof (struct icmphdr));
-
-	  /* rest is payload */
-	  offset = *size;
-
-	  ip->tot_len = __bswap_16 (offset - sizeof (struct ether_header));
-	  ip->check = cksum (ip, sizeof (struct iphdr));
-	}
-    }
-
-  offset += encap_size;
-
-  assert (offset != *size &&
-	  "new packet length must be increased by encap size");
-
-  /* overwrite packet size */
-  *size = offset;
-
-  return 0;
-}
diff --git a/extras/libmemif/examples/icmp_responder/icmp_proto.h b/extras/libmemif/examples/icmp_responder/icmp_proto.h
deleted file mode 100644
index 1575719..0000000
--- a/extras/libmemif/examples/icmp_responder/icmp_proto.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *------------------------------------------------------------------
- * 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 _ICMP_PROTO_H_
-#define _ICMP_PROTO_H_
-
-typedef enum
-{
-  ICMPR_FLOW_MODE_ETH = 0,
-  ICMPR_FLOW_MODE_IP,
-} icmpr_flow_mode_t;
-
-int resolve_packet (void *in_pck, ssize_t in_size, void *out_pck,
-		    uint32_t * out_size, uint8_t ip_addr[4]);
-
-/* resolve packet in place */
-int resolve_packet2 (void *pck, uint32_t * size, uint8_t ip_addr[4]);
-
-/* resolve packet in place and add eth encap */
-int resolve_packet3 (void **pck, uint32_t * size, uint8_t ip_addr[4]);
-
-int generate_packet (void *pck, uint32_t * size, uint8_t saddr[4],
-		     uint8_t daddr[4], uint8_t hw_daddr[6], uint32_t seq);
-
-int generate_packet2 (void *pck, uint32_t * size, uint8_t saddr[4],
-		      uint8_t daddr[4], uint8_t hw_daddr[6], uint32_t seq,
-		      icmpr_flow_mode_t);
-
-int print_packet (void *pck);
-
-#endif /* _ICMP_PROTO_H_ */
diff --git a/extras/libmemif/examples/icmp_responder/main.c b/extras/libmemif/examples/icmp_responder/main.c
deleted file mode 100644
index 5175123..0000000
--- a/extras/libmemif/examples/icmp_responder/main.c
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- *------------------------------------------------------------------
- * 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.
- *------------------------------------------------------------------
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <net/if.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/uio.h>
-#include <sys/mman.h>
-#include <sys/prctl.h>
-#include <inttypes.h>
-#include <string.h>
-#include <stdio.h>
-#include <netdb.h>
-#include <linux/ip.h>
-#include <linux/icmp.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-#include <netinet/if_ether.h>
-#include <net/if_arp.h>
-#include <asm/byteorder.h>
-#include <byteswap.h>
-#include <string.h>
-#include <sys/epoll.h>
-#include <errno.h>
-#include <unistd.h>
-#include <signal.h>
-
-#include <libmemif.h>
-#include <icmp_proto.h>
-
-#define APP_NAME "ICMP_Responder"
-#define IF_NAME  "memif_connection"
-
-
-#ifdef ICMP_DBG
-#define DBG(...) do {                                               \
-                    printf (APP_NAME":%s:%d: ", __func__, __LINE__);         \
-                    printf (__VA_ARGS__);                           \
-                    printf ("\n");                                  \
-                } while (0)
-#else
-#define DBG(...)
-#endif
-
-#define INFO(...) do {                                              \
-                    printf ("INFO: "__VA_ARGS__);                   \
-                    printf ("\n");                                  \
-                } while (0)
-
-/* maximum tx/rx memif buffers */
-#define MAX_MEMIF_BUFS 256
-
-typedef struct
-{
-  uint16_t index;
-  /* memif conenction handle */
-  memif_conn_handle_t conn;
-  /* transmit queue id */
-  uint16_t tx_qid;
-  /* tx buffers */
-  memif_buffer_t *tx_bufs;
-  /* allocated tx buffers counter */
-  /* number of tx buffers pointing to shared memory */
-  uint16_t tx_buf_num;
-  /* rx buffers */
-  memif_buffer_t *rx_bufs;
-  /* allcoated rx buffers counter */
-  /* number of rx buffers pointing to shared memory */
-  uint16_t rx_buf_num;
-  /* interface ip address */
-  uint8_t ip_addr[4];
-} memif_connection_t;
-
-memif_connection_t memif_connection;
-int epfd;
-
-static void
-print_memif_details ()
-{
-  memif_connection_t *c = &memif_connection;
-  printf ("MEMIF DETAILS\n");
-  printf ("==============================\n");
-
-
-  memif_details_t md;
-  memset (&md, 0, sizeof (md));
-  ssize_t buflen = 2048;
-  char *buf = malloc (buflen);
-  memset (buf, 0, buflen);
-  int err, e;
-
-  err = memif_get_details (c->conn, &md, buf, buflen);
-  if (err != MEMIF_ERR_SUCCESS)
-    {
-      INFO ("%s", memif_strerror (err));
-      if (err == MEMIF_ERR_NOCONN)
-	{
-	  free (buf);
-	  return;
-	}
-    }
-
-  printf ("\tinterface name: %s\n", (char *) md.if_name);
-  printf ("\tapp name: %s\n", (char *) md.inst_name);
-  printf ("\tremote interface name: %s\n", (char *) md.remote_if_name);
-  printf ("\tremote app name: %s\n", (char *) md.remote_inst_name);
-  printf ("\tid: %u\n", md.id);
-  printf ("\tsecret: %s\n", (char *) md.secret);
-  printf ("\trole: ");
-  if (md.role)
-    printf ("slave\n");
-  else
-    printf ("master\n");
-  printf ("\tmode: ");
-  switch (md.mode)
-    {
-    case 0:
-      printf ("ethernet\n");
-      break;
-    case 1:
-      printf ("ip\n");
-      break;
-    case 2:
-      printf ("punt/inject\n");
-      break;
-    default:
-      printf ("unknown\n");
-      break;
-    }
-  printf ("\tsocket filename: %s\n", (char *) md.socket_filename);
-  printf ("\tsocket filename: %s\n", (char *) md.socket_filename);
-  printf ("\trx queues:\n");
-  for (e = 0; e < md.rx_queues_num; e++)
-    {
-      printf ("\t\tqueue id: %u\n", md.rx_queues[e].qid);
-      printf ("\t\tring size: %u\n", md.rx_queues[e].ring_size);
-      printf ("\t\tbuffer size: %u\n", md.rx_queues[e].buffer_size);
-    }
-  printf ("\ttx queues:\n");
-  for (e = 0; e < md.tx_queues_num; e++)
-    {
-      printf ("\t\tqueue id: %u\n", md.tx_queues[e].qid);
-      printf ("\t\tring size: %u\n", md.tx_queues[e].ring_size);
-      printf ("\t\tbuffer size: %u\n", md.tx_queues[e].buffer_size);
-    }
-  printf ("\tlink: ");
-  if (md.link_up_down)
-    printf ("up\n");
-  else
-    printf ("down\n");
-
-  free (buf);
-}
-
-/* informs user about connected status. private_ctx is used by user to identify connection
-    (multiple connections WIP) */
-int
-on_connect (memif_conn_handle_t conn, void *private_ctx)
-{
-  INFO ("memif connected!");
-  return 0;
-}
-
-/* informs user about disconnected status. private_ctx is used by user to identify connection
-    (multiple connections WIP) */
-int
-on_disconnect (memif_conn_handle_t conn, void *private_ctx)
-{
-  INFO ("memif disconnected!");
-  return 0;
-}
-
-int
-icmpr_memif_delete ()
-{
-  int err;
-  /* disconnect then delete memif connection */
-  err = memif_delete (&(&memif_connection)->conn);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_delete: %s", memif_strerror (err));
-  return 0;
-}
-
-void
-print_help ()
-{
-  printf ("LIBMEMIF EXAMPLE APP: %s", APP_NAME);
-#ifdef ICMP_DBG
-  printf (" (debug)");
-#endif
-  printf ("\n");
-  printf ("==============================\n");
-  printf ("libmemif version: %s", LIBMEMIF_VERSION);
-#ifdef MEMIF_DBG
-  printf (" (debug)");
-#endif
-  printf ("\n");
-  printf ("memif version: %d\n", memif_get_version ());
-  printf ("\tuse CTRL+C to exit\n");
-}
-
-int
-icmpr_buffer_alloc (long n, uint16_t qid)
-{
-  memif_connection_t *c = &memif_connection;
-  int err;
-  uint16_t r;
-  /* set data pointer to shared memory and set buffer_len to shared memory buffer len */
-  err = memif_buffer_alloc (c->conn, qid, c->tx_bufs, n, &r, 0);
-  if (err != MEMIF_ERR_SUCCESS)
-    {
-      INFO ("memif_buffer_alloc: %s", memif_strerror (err));
-      c->tx_buf_num += r;
-      return -1;
-    }
-  c->tx_buf_num += r;
-  DBG ("allocated %d/%ld buffers, %u free buffers", r, n,
-       MAX_MEMIF_BUFS - c->tx_buf_num);
-  return 0;
-}
-
-int
-icmpr_tx_burst (uint16_t qid)
-{
-  memif_connection_t *c = &memif_connection;
-  int err;
-  uint16_t r;
-  /* inform peer memif interface about data in shared memory buffers */
-  /* mark memif buffers as free */
-  err = memif_tx_burst (c->conn, qid, c->tx_bufs, c->tx_buf_num, &r);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_tx_burst: %s", memif_strerror (err));
-  DBG ("tx: %d/%u", r, c->tx_buf_num);
-  c->tx_buf_num -= r;
-  return 0;
-}
-
-int
-icmpr_free ()
-{
-  /* application cleanup */
-  int err;
-  memif_connection_t *c = &memif_connection;
-  free (c->tx_bufs);
-  c->tx_bufs = NULL;
-  free (c->rx_bufs);
-  c->rx_bufs = NULL;
-
-  err = memif_cleanup ();
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_delete: %s", memif_strerror (err));
-
-  return 0;
-}
-
-void
-icmpr_exit (int sig)
-{
-  printf ("\n");
-  icmpr_memif_delete ();
-  icmpr_free ();
-  exit (EXIT_SUCCESS);
-}
-
-/* called when event is polled on interrupt file descriptor.
-    there are packets in shared memory ready to be received */
-int
-on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
-{
-  DBG ("interrupted");
-  memif_connection_t *c = &memif_connection;
-  int err;
-  uint16_t rx;
-  /* receive data from shared memory buffers */
-  err = memif_rx_burst (c->conn, qid, c->rx_bufs, MAX_MEMIF_BUFS, &rx);
-  c->rx_buf_num += rx;
-
-  DBG ("received %d buffers. %u/%u alloc/free buffers",
-       rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
-
-  if (icmpr_buffer_alloc (rx, c->tx_qid) < 0)
-    {
-      INFO ("buffer_alloc error");
-      goto error;
-    }
-  int i;
-  for (i = 0; i < rx; i++)
-    {
-      resolve_packet ((void *) (c->rx_bufs + i)->data,
-		      (c->rx_bufs + i)->len,
-		      (void *) (c->tx_bufs + i)->data,
-		      &(c->tx_bufs + i)->len, c->ip_addr);
-    }
-
-  /* mark memif buffers and shared memory buffers as free */
-  err = memif_refill_queue (c->conn, qid, rx, 0);
-  /*
-   * In this example we can assert that c->conn points to valid connection
-   * and 'rx <= c->rx_buf_num'.
-   */
-  c->rx_buf_num -= rx;
-
-  DBG ("freed %d buffers. %u/%u alloc/free buffers",
-       rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
-
-  icmpr_tx_burst (c->tx_qid);
-
-  return 0;
-
-error:
-  err = memif_refill_queue (c->conn, qid, rx, 0);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_buffer_free: %s", memif_strerror (err));
-  c->rx_buf_num -= rx;
-  DBG ("freed %d buffers. %u/%u alloc/free buffers",
-       rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
-  return 0;
-}
-
-int
-icmpr_memif_create (int is_master)
-{
-  /* setting memif connection arguments */
-  memif_conn_args_t args;
-  memset (&args, 0, sizeof (args));
-  args.is_master = is_master;
-  args.log2_ring_size = 10;
-  args.buffer_size = 2048;
-  args.num_s2m_rings = 2;
-  args.num_m2s_rings = 2;
-  strncpy ((char *) args.interface_name, IF_NAME, strlen (IF_NAME));
-  args.mode = 0;
-  /* socket filename is not specified, because this app is supposed to
-     connect to VPP over memif. so default socket filename will be used */
-  /* default socketfile = /run/vpp/memif.sock */
-
-  args.interface_id = 0;
-  /* last argument for memif_create (void * private_ctx) is used by user
-     to identify connection. this context is returned with callbacks */
-  int err = memif_create (&(&memif_connection)->conn,
-			  &args, on_connect, on_disconnect, on_interrupt,
-			  NULL);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_create: %s", memif_strerror (err));
-  return 0;
-}
-
-int
-main (int argc, char *argv[])
-{
-  memif_connection_t *c = &memif_connection;
-
-  signal (SIGINT, icmpr_exit);
-
-  /* initialize global memif connection handle */
-  c->conn = NULL;
-  if (argc == 1)
-    c->tx_qid = 0;
-  else
-    {
-      char *end;
-      c->tx_qid = strtol (argv[1], &end, 10);
-    }
-  INFO ("tx qid: %u", c->tx_qid);
-  /* alloc memif buffers */
-  c->rx_buf_num = 0;
-  c->rx_bufs =
-    (memif_buffer_t *) malloc (sizeof (memif_buffer_t) * MAX_MEMIF_BUFS);
-  c->tx_buf_num = 0;
-  c->tx_bufs =
-    (memif_buffer_t *) malloc (sizeof (memif_buffer_t) * MAX_MEMIF_BUFS);
-  c->ip_addr[0] = 192;
-  c->ip_addr[1] = 168;
-  c->ip_addr[2] = 1;
-  c->ip_addr[3] = 2;
-  /* initialize memory interface */
-  int err;
-  /* if valid callback is passed as argument, fd event polling will be done by user
-     all file descriptors and events will be passed to user in this callback */
-  /* if callback is set to NULL libmemif will handle fd event polling */
-  err = memif_init (NULL, APP_NAME, NULL, NULL, NULL);
-  if (err != MEMIF_ERR_SUCCESS)
-    INFO ("memif_init: %s", memif_strerror (err));
-
-  print_help ();
-
-  icmpr_memif_create (0);
-  print_memif_details ();
-
-  /* main loop */
-  while (1)
-    {
-      if (memif_poll_event (-1) < 0)
-	{
-	  DBG ("poll_event error!");
-	}
-    }
-}
