Exemple #1
0
Fichier : tun.c Projet : nizox/hub
int
tnt_tun_open(struct tnt_tun *tun) {
  if (tun->handle == NULL)
    tun->handle = tapcfg_init();

  if (tapcfg_start(tun->handle, tun->interface, 0) < 0)
    return (-1);

  tun->fd = tapcfg_get_fd(tun->handle);
  tun->interface = strdup(tapcfg_get_ifname(tun->handle));
  if (tun->interface == NULL)
    return (-1);
  return (0);
}
Exemple #2
0
int create_tap()
{
 

  int fd=0;

  tapcfg = tapcfg_init();  
  tapcfg_start(tapcfg, "tap1", 0);
  fd = tapcfg_get_fd(tapcfg);

  printf("fd: %d\n",fd);

  return fd;

}