Пример #1
0
void
tun_init()
{
  setvbuf(stdout, NULL, _IOLBF, 0);     /* Line buffered output. */

  slip_init();

  if(use_raw_ethernet) {
    tunfd = eth_alloc(slip_config_tundev);
  } else {
    tunfd = tun_alloc(slip_config_tundev);
  }
  if(tunfd == -1)
    err(1, "main: open");

  select_set_callback(tunfd, &tun_select_callback);

  printf("opened device ``/dev/%s''\n", slip_config_tundev);

  atexit(cleanup);
  signal(SIGHUP, sigcleanup);
  signal(SIGTERM, sigcleanup);
  signal(SIGINT, sigcleanup);
  ifconf(slip_config_tundev);
  if(use_raw_ethernet) {
    fetch_mac(tunfd, slip_config_tundev, &eth_mac_addr);
    PRINTF("Eth MAC address : ");
    PRINTETHADDR(&eth_mac_addr);
    PRINTF("\n");
    eth_mac_addr_ready = 1;
  }
}
Пример #2
0
/*---------------------------------------------------------------------------*/
void
eth_dev_init()
{
  if(sixlbr_config_use_raw_ethernet) {
    eth_fd = eth_alloc(sixlbr_config_eth_device);
  } else {
    eth_fd = tap_alloc(sixlbr_config_eth_device);
  }
  if(eth_fd == -1) {
    LOG6LBR_FATAL("eth_dev_init() : %s\n", strerror(errno));
    exit(1);
  }

  select_set_callback(eth_fd, &eth_select_callback);

  LOG6LBR_INFO("opened device /dev/%s\n", sixlbr_config_eth_device);

  atexit(cleanup);
  signal(SIGHUP, sigcleanup);
  signal(SIGTERM, sigcleanup);
  signal(SIGINT, sigcleanup);
  ifconf(sixlbr_config_eth_device);
#if !CETIC_6LBR_ONE_ITF
  if(sixlbr_config_use_raw_ethernet) {
#endif
    fetch_mac(eth_fd, sixlbr_config_eth_device, &eth_mac_addr);
    LOG6LBR_ETHADDR(INFO, &eth_mac_addr, "Eth MAC address : ");
    eth_mac_addr_ready = 1;
#if !CETIC_6LBR_ONE_ITF
  }
#endif
}
Пример #3
0
void
tun_init()
{
  setvbuf(stdout, NULL, _IOLBF, 0);     /* Line buffered output. */

  if(use_raw_ethernet) {
    tunfd = eth_alloc(slip_config_tundev);
  } else {
    tunfd = tun_alloc(slip_config_tundev);
  }
  if(tunfd == -1) {
    LOG6LBR_FATAL("tun_alloc() : %s\n", strerror(errno));
    exit(1);
  }

  select_set_callback(tunfd, &tun_select_callback);

  LOG6LBR_INFO("opened device /dev/%s\n", slip_config_tundev);

  atexit(cleanup);
  signal(SIGHUP, sigcleanup);
  signal(SIGTERM, sigcleanup);
  signal(SIGINT, sigcleanup);
  ifconf(slip_config_tundev);
#if !CETIC_6LBR_ONE_ITF
  if(use_raw_ethernet) {
#endif
    fetch_mac(tunfd, slip_config_tundev, &eth_mac_addr);
    LOG6LBR_ETHADDR(INFO, &eth_mac_addr, "Eth MAC address : ");
    eth_mac_addr_ready = 1;
#if !CETIC_6LBR_ONE_ITF
  }
#endif
}