Esempio n. 1
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(eth_drv_process, ev, data)
{
  PROCESS_BEGIN();

#if !CETIC_6LBR_ONE_ITF
  if(!sixlbr_config_use_raw_ethernet) {
    //We must create our own Ethernet MAC address
    while(!radio_ready) {
      PROCESS_PAUSE();
    }
    mac_createEthernetAddr((uint8_t *) eth_mac_addr, &wsn_mac_addr);
    eth_mac_addr[0] &= ~TRANSLATE_BIT_MASK;
    eth_mac_addr_ready = 1;
  }
#else
  //TODO: Ethernet Bridge bullshit !
  eth_mac_addr[5] += 1;
  mac_createSicslowpanLongAddr((uint8_t *)eth_mac_addr, &wsn_mac_addr);
  memcpy(uip_lladdr.addr, wsn_mac_addr.addr, sizeof(uip_lladdr.addr));
  linkaddr_set_node_addr((linkaddr_t *) &wsn_mac_addr);
#endif
  LOG6LBR_ETHADDR(INFO, &eth_mac_addr, "Eth MAC address : ");
  ethernet_ready = 1;

  PROCESS_END();
}
Esempio n. 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
}
Esempio n. 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
}
Esempio n. 4
0
/*---------------------------------------------------------------------------*/
void
eth_drv_init()
{
  LOG6LBR_INFO("ENC28J60 init\n");

  linkaddr_copy((linkaddr_t *) & wsn_mac_addr, &linkaddr_node_addr);
  mac_createEthernetAddr((uint8_t *) eth_mac_addr, &wsn_mac_addr);
  LOG6LBR_ETHADDR(INFO, &eth_mac_addr, "Eth MAC address : ");
  eth_mac_addr_ready = 1;

  enc28j60_init(eth_mac_addr);
  process_start(&eth_drv_process, NULL);
  ethernet_ready = 1;
}