update llayer

This commit is contained in:
Harald Pichler 2014-11-20 13:43:53 +01:00
parent d8e0dd7005
commit e58322260f

View file

@ -50,14 +50,11 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "dev/leds.h"
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
uint16_t dag_id[] = {0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011};
static uip_ipaddr_t prefix;
static uint8_t prefix_set;
@ -103,7 +100,7 @@ PROCESS_THREAD(webserver_nogui_process, ev, data)
PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
httpd_appcall(data);
}
PROCESS_END();
}
AUTOSTART_PROCESSES(&border_router_process,&webserver_nogui_process);
@ -147,7 +144,6 @@ ipaddr_add(const uip_ipaddr_t *addr)
static
PT_THREAD(generate_routes(struct httpd_state *s))
{
static int i;
static uip_ds6_route_t *r;
static uip_ds6_nbr_t *nbr;
#if BUF_USES_STACK
@ -180,7 +176,7 @@ PT_THREAD(generate_routes(struct httpd_state *s))
switch (nbr->state) {
case NBR_INCOMPLETE: ADD(" INCOMPLETE");break;
case NBR_REACHABLE: ADD(" REACHABLE");break;
case NBR_STALE: ADD(" STALE");break;
case NBR_STALE: ADD(" STALE");break;
case NBR_DELAY: ADD(" DELAY");break;
case NBR_PROBE: ADD(" NBR_PROBE");break;
}
@ -192,7 +188,7 @@ PT_THREAD(generate_routes(struct httpd_state *s))
switch (nbr->state) {
case NBR_INCOMPLETE: ADD(" INCOMPLETE");break;
case NBR_REACHABLE: ADD(" REACHABLE");break;
case NBR_STALE: ADD(" STALE");break;
case NBR_STALE: ADD(" STALE");break;
case NBR_DELAY: ADD(" DELAY");break;
case NBR_PROBE: ADD(" NBR_PROBE");break;
}
@ -251,7 +247,7 @@ PT_THREAD(generate_routes(struct httpd_state *s))
ADD("/%u (via ", r->length);
ipaddr_add(uip_ds6_route_nexthop(r));
if(1 || (r->state.lifetime < 600)) {
ADD(") %lus\n", r->state.lifetime);
ADD(") %lus\n", (unsigned long)r->state.lifetime);
} else {
ADD(")\n");
}
@ -322,23 +318,30 @@ request_prefix(void)
void
set_prefix_64(uip_ipaddr_t *prefix_64)
{
rpl_dag_t *dag;
uip_ipaddr_t ipaddr;
memcpy(&prefix, prefix_64, 16);
memcpy(&ipaddr, prefix_64, 16);
prefix_set = 1;
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &ipaddr);
if(dag != NULL) {
rpl_set_prefix(dag, &prefix, 64);
PRINTF("created a new RPL dag\n");
}
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(border_router_process, ev, data)
{
static struct etimer et;
rpl_dag_t *dag;
PROCESS_BEGIN();
leds_off(LEDS_RED);
/* While waiting for the prefix to be sent through the SLIP connection, the future
* border router can join an existing DAG as a parent or child, or acquire a default
* border router can join an existing DAG as a parent or child, or acquire a default
* router that will later take precedence over the SLIP fallback interface.
* Prevent that by turning the radio off until we are initialized as a DAG root.
*/
@ -357,7 +360,7 @@ PROCESS_THREAD(border_router_process, ev, data)
cpu will interfere with establishing the SLIP connection */
NETSTACK_MAC.off(1);
#endif
/* Request prefix until it has been received */
while(!prefix_set) {
etimer_set(&et, CLOCK_SECOND);
@ -365,17 +368,11 @@ PROCESS_THREAD(border_router_process, ev, data)
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
}
dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id);
if(dag != NULL) {
rpl_set_prefix(dag, &prefix, 64);
PRINTF("created a new RPL dag\n");
}
/* Now turn the radio on, but disable radio duty cycling.
* Since we are the DAG root, reception delays would constrain mesh throughbut.
*/
NETSTACK_MAC.off(1);
#if DEBUG || 1
print_local_addresses();
#endif