Exemple #1
0
void
cetic_6lbr_init_finalize(void)
{
#if CETIC_6LBR_WITH_RPL
  if(rpl_fast_startup) {
    cetic_6lbr_start_dodag_root();
  } else {
    cetic_6lbr_start_delayed_dodag_root(1);
  }
#endif
#if CETIC_6LBR_WITH_IP64
  if((nvm_data.global_flags & CETIC_GLOBAL_IP64) != 0) {
    LOG6LBR_INFO("Starting IP64\n");
    ip64_eth_addr_set((struct ip64_eth_addr *)eth_mac_addr);
    if((nvm_data.eth_ip64_flags & CETIC_6LBR_IP64_RFC6052_PREFIX) != 0) {
      uip_ip6addr_t ip64_prefix = {{ 0, 0x64, 0xff, 0x9b, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
      ip64_addr_set_prefix(&ip64_prefix, 96);
    }
    ip64_init();
    if((nvm_data.eth_ip64_flags & CETIC_6LBR_IP64_DHCP) == 0) {
      memcpy(&eth_ip64_addr, nvm_data.eth_ip64_addr, sizeof(nvm_data.eth_ip64_addr));
      memcpy(&eth_ip64_netmask, nvm_data.eth_ip64_netmask, sizeof(nvm_data.eth_ip64_netmask));
      memcpy(&eth_ip64_gateway, nvm_data.eth_ip64_gateway, sizeof(nvm_data.eth_ip64_gateway));
      ip64_set_ipv4_address(&eth_ip64_addr, &eth_ip64_netmask);
      ip64_set_draddr(&eth_ip64_gateway);
      LOG6LBR_4ADDR(INFO, &eth_ip64_addr, "IPv4 address : ");
    } else {
      ip64_ipv4_dhcp_init();
    }
  }
#endif

#if RESOLV_CONF_SUPPORTS_MDNS
  if((nvm_data.global_flags & CETIC_GLOBAL_MDNS) != 0) {
    LOG6LBR_INFO("Starting MDNS\n");
    process_start(&resolv_process, NULL);
    resolv_set_hostname((char *)nvm_data.dns_host_name);
#if RESOLV_CONF_SUPPORTS_DNS_SD
    if((nvm_data.dns_flags & CETIC_6LBR_DNS_DNS_SD) != 0) {
      resolv_add_service("_6lbr._tcp", "", nvm_data.webserver_port);
    }
#endif
  }
#endif

  LOG6LBR_INFO("Starting as " CETIC_6LBR_MODE "\n");

#if CONTIKI_TARGET_NATIVE
  cetic_6lbr_save_ip();
#endif
}
Exemple #2
0
/*---------------------------------------------------------------------------*/
void
ip64_dhcpc_configured(const struct ip64_dhcpc_state *s)
{
  uip_ip6addr_t ip6dnsaddr;
  printf("DHCP Configured with %d.%d.%d.%d\n",
	 s->ipaddr.u8[0], s->ipaddr.u8[1],
	 s->ipaddr.u8[2], s->ipaddr.u8[3]);

  ip64_set_hostaddr((uip_ip4addr_t *)&s->ipaddr);
  ip64_set_netmask((uip_ip4addr_t *)&s->netmask);
  ip64_set_draddr((uip_ip4addr_t *)&s->default_router);
  ip64_addr_4to6((uip_ip4addr_t *)&s->dnsaddr, &ip6dnsaddr);
  //  mdns_conf(&ip6dnsaddr);
}
Exemple #3
0
/*---------------------------------------------------------------------------*/
void
ip64_dhcpc_configured(const struct ip64_dhcpc_state *s)
{
  uip_ip6addr_t ip6dnsaddr;
  PRINTF("DHCP Configured with %d.%d.%d.%d\n",
	 s->ipaddr.u8[0], s->ipaddr.u8[1],
	 s->ipaddr.u8[2], s->ipaddr.u8[3]);

  ip64_set_hostaddr((uip_ip4addr_t *)&s->ipaddr);
  ip64_set_netmask((uip_ip4addr_t *)&s->netmask);
  ip64_set_draddr((uip_ip4addr_t *)&s->default_router);
  if(!uip_ip4addr_cmp((uip_ip4addr_t *)&s->dnsaddr, &uip_all_zeroes_addr)) {
    //Note: Currently we assume only one DNS server
    uip_ipaddr_t * dns = uip_nameserver_get(0);
    //Only update DNS entry if it is empty or already IPv4
    if(uip_is_addr_unspecified(dns) || ip64_addr_is_ip64(dns)) {
      ip64_addr_4to6((uip_ip4addr_t *)&s->dnsaddr, &ip6dnsaddr);
      uip_nameserver_update(&ip6dnsaddr, uip_ntohs(s->lease_time[0])*65536ul + uip_ntohs(s->lease_time[1]));
    }
  }
#if CETIC_6LBR
  cetic_6lbr_ip64_dhcpc_configured(s);
#endif
}