llsec: Replaced bootstrap function with a simple init function
This commit is contained in:
parent
2059b6559e
commit
b522c042ec
|
@ -48,10 +48,6 @@
|
||||||
* for incoming packets. Likewise, all NETSTACK_NETWORK protocols
|
* for incoming packets. Likewise, all NETSTACK_NETWORK protocols
|
||||||
* invoke NETSTACK_LLSEC.send(...) for outgoing packets.
|
* 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"
|
#include "net/mac/mac.h"
|
||||||
|
|
||||||
typedef void (* llsec_on_bootstrapped_t)(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The structure of a link layer security driver.
|
* The structure of a link layer security driver.
|
||||||
*/
|
*/
|
||||||
struct llsec_driver {
|
struct llsec_driver {
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
/** Bootstraps link layer security and thereafter starts upper layers. */
|
/** Inits link layer security. */
|
||||||
void (* bootstrap)(llsec_on_bootstrapped_t on_bootstrapped);
|
void (* init)(void);
|
||||||
|
|
||||||
/** Secures outgoing frames before passing them to NETSTACK_MAC. */
|
/** Secures outgoing frames before passing them to NETSTACK_MAC. */
|
||||||
void (* send)(mac_callback_t sent_callback, void *ptr);
|
void (* send)(mac_callback_t sent_callback, void *ptr);
|
||||||
|
|
|
@ -214,18 +214,15 @@ length(void)
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
bootstrap(llsec_on_bootstrapped_t on_bootstrapped)
|
init(void)
|
||||||
{
|
{
|
||||||
CCM_STAR.set_key(key);
|
CCM_STAR.set_key(key);
|
||||||
nbr_table_register(anti_replay_table, NULL);
|
nbr_table_register(anti_replay_table, NULL);
|
||||||
if(on_bootstrapped) {
|
|
||||||
on_bootstrapped();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
const struct llsec_driver noncoresec_driver = {
|
const struct llsec_driver noncoresec_driver = {
|
||||||
"noncoresec",
|
"noncoresec",
|
||||||
bootstrap,
|
init,
|
||||||
send,
|
send,
|
||||||
input
|
input
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,11 +49,9 @@
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
bootstrap(llsec_on_bootstrapped_t on_bootstrapped)
|
init(void)
|
||||||
{
|
{
|
||||||
if(on_bootstrapped) {
|
|
||||||
on_bootstrapped();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
|
@ -71,7 +69,7 @@ input(void)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
const struct llsec_driver nullsec_driver = {
|
const struct llsec_driver nullsec_driver = {
|
||||||
"nullsec",
|
"nullsec",
|
||||||
bootstrap,
|
init,
|
||||||
send,
|
send,
|
||||||
input
|
input
|
||||||
};
|
};
|
||||||
|
|
|
@ -189,65 +189,6 @@ set_gateway(void)
|
||||||
}
|
}
|
||||||
#endif /* NETSTACK_CONF_WITH_IPV4 */
|
#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
|
#if WITH_TINYOS_AUTO_IDS
|
||||||
uint16_t TOS_NODE_ID = 0x1234; /* non-zero */
|
uint16_t TOS_NODE_ID = 0x1234; /* non-zero */
|
||||||
uint16_t TOS_LOCAL_ADDRESS = 0x1234; /* non-zero */
|
uint16_t TOS_LOCAL_ADDRESS = 0x1234; /* non-zero */
|
||||||
|
@ -360,6 +301,8 @@ main(int argc, char **argv)
|
||||||
queuebuf_init();
|
queuebuf_init();
|
||||||
NETSTACK_RDC.init();
|
NETSTACK_RDC.init();
|
||||||
NETSTACK_MAC.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",
|
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,
|
NETSTACK_LLSEC.name, NETSTACK_MAC.name, NETSTACK_RDC.name,
|
||||||
|
@ -368,10 +311,41 @@ main(int argc, char **argv)
|
||||||
CC2420_CONF_CHANNEL,
|
CC2420_CONF_CHANNEL,
|
||||||
CC2420_CONF_CCA_THRESH);
|
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 */
|
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||||
|
|
||||||
NETSTACK_RDC.init();
|
NETSTACK_RDC.init();
|
||||||
NETSTACK_MAC.init();
|
NETSTACK_MAC.init();
|
||||||
|
NETSTACK_LLSEC.init();
|
||||||
NETSTACK_NETWORK.init();
|
NETSTACK_NETWORK.init();
|
||||||
|
|
||||||
PRINTF("%s %s %s, channel check rate %lu Hz, radio channel %u\n",
|
PRINTF("%s %s %s, channel check rate %lu Hz, radio channel %u\n",
|
||||||
|
@ -424,7 +398,10 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
watchdog_start();
|
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.
|
* This is the scheduler loop.
|
||||||
|
|
Loading…
Reference in a new issue