Example #1
0
/*-----------------------------------------------------------------------------------*/
static void
tapif_thread(void *arg)
{
  struct netif *netif;
  struct tapif *tapif;
  fd_set fdset;
  int ret;

  netif = (struct netif *)arg;
  tapif = (struct tapif *)netif->state;

  while(1) {
    FD_ZERO(&fdset);
    FD_SET(tapif->fd, &fdset);

    /* Wait for a packet to arrive. */
    ret = select(tapif->fd + 1, &fdset, NULL, NULL, NULL);

    if(ret == 1) {
      /* Handle incoming packet. */
      tapif_input(netif);
    } else if(ret == -1) {
      perror("tapif_thread: select");
    }
  }
}
Example #2
0
/*-----------------------------------------------------------------------------------*/
void 
tapif_interrupt(struct netif *netif)
{
  struct tapif *tapif;
  fd_set fdset;
  int ret;
  
  tapif = netif->state;
  
  FD_ZERO(&fdset);
  FD_SET(tapif->fd, &fdset);

  /* Wait for a packet to arrive. */
  ret = select(tapif->fd + 1, &fdset, NULL, NULL, NULL);

  if(ret == 1) {
    /* Handle incoming packet. */
    tapif_input(netif);
  } else if(ret == -1) {
    perror("tapif_interrupt: select");
  }
}