diff --git a/core/net/llsec/llsec.h b/core/net/llsec/llsec.h index e5f6a3a2b..b0d983cc3 100644 --- a/core/net/llsec/llsec.h +++ b/core/net/llsec/llsec.h @@ -48,10 +48,6 @@ * for incoming packets. Likewise, all NETSTACK_NETWORK protocols * invoke NETSTACK_LLSEC.send(...) for outgoing packets. * - * The bootstrap function of llsec_drivers can be used to defer the start - * of upper layers so as to bootstrap pairwise keys. Only contiki-sky-main.c - * supports this at the moment. - * * @{ */ @@ -60,16 +56,14 @@ #include "net/mac/mac.h" -typedef void (* llsec_on_bootstrapped_t)(void); - /** * The structure of a link layer security driver. */ struct llsec_driver { char *name; - /** Bootstraps link layer security and thereafter starts upper layers. */ - void (* bootstrap)(llsec_on_bootstrapped_t on_bootstrapped); + /** Inits link layer security. */ + void (* init)(void); /** Secures outgoing frames before passing them to NETSTACK_MAC. */ void (* send)(mac_callback_t sent_callback, void *ptr); diff --git a/core/net/llsec/noncoresec/noncoresec.c b/core/net/llsec/noncoresec/noncoresec.c index bfa70aba6..ec66c172f 100644 --- a/core/net/llsec/noncoresec/noncoresec.c +++ b/core/net/llsec/noncoresec/noncoresec.c @@ -214,18 +214,15 @@ length(void) } /*---------------------------------------------------------------------------*/ static void -bootstrap(llsec_on_bootstrapped_t on_bootstrapped) +init(void) { CCM_STAR.set_key(key); nbr_table_register(anti_replay_table, NULL); - if(on_bootstrapped) { - on_bootstrapped(); - } } /*---------------------------------------------------------------------------*/ const struct llsec_driver noncoresec_driver = { "noncoresec", - bootstrap, + init, send, input }; diff --git a/core/net/llsec/nullsec.c b/core/net/llsec/nullsec.c index b28ea72f4..e4bd4ca2d 100644 --- a/core/net/llsec/nullsec.c +++ b/core/net/llsec/nullsec.c @@ -49,11 +49,9 @@ /*---------------------------------------------------------------------------*/ static void -bootstrap(llsec_on_bootstrapped_t on_bootstrapped) +init(void) { - if(on_bootstrapped) { - on_bootstrapped(); - } + } /*---------------------------------------------------------------------------*/ static void @@ -71,7 +69,7 @@ input(void) /*---------------------------------------------------------------------------*/ const struct llsec_driver nullsec_driver = { "nullsec", - bootstrap, + init, send, input }; diff --git a/platform/sky/contiki-sky-main.c b/platform/sky/contiki-sky-main.c index a099778c6..ea3afd93a 100644 --- a/platform/sky/contiki-sky-main.c +++ b/platform/sky/contiki-sky-main.c @@ -189,65 +189,6 @@ set_gateway(void) } #endif /* NETSTACK_CONF_WITH_IPV4 */ /*---------------------------------------------------------------------------*/ -static void -start_autostart_processes() -{ -#if !PROCESS_CONF_NO_PROCESS_NAMES - print_processes(autostart_processes); -#endif /* !PROCESS_CONF_NO_PROCESS_NAMES */ - autostart_start(autostart_processes); -} -/*---------------------------------------------------------------------------*/ -#if NETSTACK_CONF_WITH_IPV6 -static void -start_uip6() -{ - NETSTACK_NETWORK.init(); - - process_start(&tcpip_process, NULL); - -#if DEBUG - PRINTF("Tentative link-local IPv6 address "); - { - uip_ds6_addr_t *lladdr; - int i; - lladdr = uip_ds6_get_link_local(-1); - for(i = 0; i < 7; ++i) { - PRINTF("%02x%02x:", lladdr->ipaddr.u8[i * 2], - lladdr->ipaddr.u8[i * 2 + 1]); - } - PRINTF("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]); - } -#endif /* DEBUG */ - - if(!UIP_CONF_IPV6_RPL) { - uip_ipaddr_t ipaddr; - int i; - uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); - uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); - uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE); - PRINTF("Tentative global IPv6 address "); - for(i = 0; i < 7; ++i) { - PRINTF("%02x%02x:", - ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]); - } - PRINTF("%02x%02x\n", - ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]); - } -} -#endif /* NETSTACK_CONF_WITH_IPV6 */ -/*---------------------------------------------------------------------------*/ -static void -start_network_layer() -{ -#if NETSTACK_CONF_WITH_IPV6 - start_uip6(); -#endif /* NETSTACK_CONF_WITH_IPV6 */ - start_autostart_processes(); - /* To support link layer security in combination with NETSTACK_CONF_WITH_IPV4 and - * TIMESYNCH_CONF_ENABLED further things may need to be moved here */ -} -/*---------------------------------------------------------------------------*/ #if WITH_TINYOS_AUTO_IDS uint16_t TOS_NODE_ID = 0x1234; /* non-zero */ uint16_t TOS_LOCAL_ADDRESS = 0x1234; /* non-zero */ @@ -360,6 +301,8 @@ main(int argc, char **argv) queuebuf_init(); NETSTACK_RDC.init(); NETSTACK_MAC.init(); + NETSTACK_LLSEC.init(); + NETSTACK_NETWORK.init(); PRINTF("%s %s %s, channel check rate %lu Hz, radio channel %u, CCA threshold %i\n", NETSTACK_LLSEC.name, NETSTACK_MAC.name, NETSTACK_RDC.name, @@ -367,11 +310,42 @@ main(int argc, char **argv) NETSTACK_RDC.channel_check_interval()), CC2420_CONF_CHANNEL, CC2420_CONF_CCA_THRESH); + + process_start(&tcpip_process, NULL); +#if DEBUG + PRINTF("Tentative link-local IPv6 address "); + { + uip_ds6_addr_t *lladdr; + int i; + lladdr = uip_ds6_get_link_local(-1); + for(i = 0; i < 7; ++i) { + PRINTF("%02x%02x:", lladdr->ipaddr.u8[i * 2], + lladdr->ipaddr.u8[i * 2 + 1]); + } + PRINTF("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]); + } +#endif /* DEBUG */ + + if(!UIP_CONF_IPV6_RPL) { + uip_ipaddr_t ipaddr; + int i; + uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); + uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); + uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE); + PRINTF("Tentative global IPv6 address "); + for(i = 0; i < 7; ++i) { + PRINTF("%02x%02x:", + ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]); + } + PRINTF("%02x%02x\n", + ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]); + } #else /* NETSTACK_CONF_WITH_IPV6 */ NETSTACK_RDC.init(); NETSTACK_MAC.init(); + NETSTACK_LLSEC.init(); NETSTACK_NETWORK.init(); PRINTF("%s %s %s, channel check rate %lu Hz, radio channel %u\n", @@ -421,10 +395,13 @@ main(int argc, char **argv) uip_ipaddr_to_quad(&hostaddr)); } #endif /* NETSTACK_CONF_WITH_IPV4 */ - + watchdog_start(); - NETSTACK_LLSEC.bootstrap(start_network_layer); +#if !PROCESS_CONF_NO_PROCESS_NAMES + print_processes(autostart_processes); +#endif /* !PROCESS_CONF_NO_PROCESS_NAMES */ + autostart_start(autostart_processes); /* * This is the scheduler loop.