RPL-lite: use logging module
This commit is contained in:
parent
250707c2d7
commit
395e6dc819
@ -883,7 +883,7 @@ ext_hdr_options_process(void)
|
||||
#if UIP_CONF_IPV6_RPL
|
||||
LOG_DBG("Processing RPL option\n");
|
||||
if(!rpl_ext_header_hbh_update(uip_ext_opt_offset)) {
|
||||
LOG_DBG("RPL Option Error: Dropping Packet\n");
|
||||
LOG_ERR("RPL Option Error: Dropping Packet\n");
|
||||
return 1;
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6_RPL */
|
||||
|
@ -35,10 +35,10 @@
|
||||
#include "net/rpl-lite/rpl.h"
|
||||
#include "net/ipv6/uip-ds6-route.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "RPL"
|
||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
||||
|
||||
#define RPL_DAG_GRACE_PERIOD (CLOCK_SECOND * 20 * 1)
|
||||
|
||||
@ -62,12 +62,9 @@ create_dag_callback(void *ptr)
|
||||
to_become_root = 0;
|
||||
}
|
||||
} else {
|
||||
#if DEBUG
|
||||
printf("Found a network we did not create\n");
|
||||
printf("version %d grounded %d preference %d rank %d\n",
|
||||
LOG_WARN("found a network we did not create: version %d grounded %d preference %d rank %d\n",
|
||||
curr_instance.dag.version, curr_instance.dag.grounded,
|
||||
curr_instance.dag.preference, curr_instance.dag.rank);
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* We found a RPL network that we did not create so we just join
|
||||
it without becoming root. But if the network has an infinite
|
||||
@ -108,12 +105,12 @@ set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
|
||||
|
||||
uip_ds6_addr_add(&root_ipaddr, 0, ADDR_AUTOCONF);
|
||||
|
||||
printf("IPv6 addresses: ");
|
||||
LOG_INFO("IPv6 addresses: ");
|
||||
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
|
||||
state = uip_ds6_if.addr_list[i].state;
|
||||
if(uip_ds6_if.addr_list[i].isused &&
|
||||
(state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) {
|
||||
uip_debug_ipaddr_print(&uip_ds6_if.addr_list[i].ipaddr);
|
||||
LOG_INFO_6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
@ -157,10 +154,10 @@ rpl_dag_root_init_dag_immediately(void)
|
||||
(uip_ipaddr_t *)rpl_get_global_address(), 64, UIP_ND6_RA_FLAG_AUTONOMOUS);
|
||||
rpl_dag_update_state();
|
||||
|
||||
PRINTF("rpl_dag_root_init_dag: created a new RPL dag\n");
|
||||
LOG_INFO("created a new RPL DAG\n");
|
||||
return 0;
|
||||
} else {
|
||||
PRINTF("rpl_dag_root_init_dag: failed to create a new RPL DAG\n");
|
||||
LOG_ERR("failed to create a new RPL DAG\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,10 @@
|
||||
#include "net/rpl-lite/rpl.h"
|
||||
#include "net/nbr-table.h"
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "RPL"
|
||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
extern rpl_of_t rpl_of0, rpl_mrhof;
|
||||
@ -78,9 +80,9 @@ rpl_dag_periodic(unsigned seconds)
|
||||
static void
|
||||
leave_dag(void)
|
||||
{
|
||||
PRINTF("RPL: leaving DAG \n");
|
||||
PRINT6ADDR(&curr_instance.dag.dag_id);
|
||||
PRINTF(", instance %u\n", curr_instance.instance_id);
|
||||
LOG_INFO("leaving DAG \n");
|
||||
LOG_INFO_6ADDR(&curr_instance.dag.dag_id);
|
||||
LOG_INFO(", instance %u\n", curr_instance.instance_id);
|
||||
|
||||
/* Issue a no-path DAO */
|
||||
RPL_LOLLIPOP_INCREMENT(curr_instance.dag.dao_curr_seqno);
|
||||
@ -135,11 +137,11 @@ void
|
||||
rpl_global_repair(void)
|
||||
{
|
||||
if(rpl_dag_root_is_root()) {
|
||||
PRINTF("RPL: initiating global repair (version=%u, rank=%u)\n",
|
||||
LOG_WARN("initiating global repair (version=%u, rank=%u)\n",
|
||||
curr_instance.dag.version, curr_instance.dag.rank);
|
||||
#if DEBUG
|
||||
#if LOG_INFO_ENABLED
|
||||
rpl_neighbor_print_list("Global repair");
|
||||
#endif
|
||||
#endif /* LOG_INFO_ENABLED */
|
||||
|
||||
/* Initiate global repair */
|
||||
RPL_LOLLIPOP_INCREMENT(curr_instance.dag.version); /* New DAG version */
|
||||
@ -152,11 +154,11 @@ static void
|
||||
global_repair_non_root(rpl_dio_t *dio)
|
||||
{
|
||||
if(!rpl_dag_root_is_root()) {
|
||||
PRINTF("RPL: participating in global repair (version=%u, rank=%u)\n",
|
||||
LOG_WARN("participating in global repair (version=%u, rank=%u)\n",
|
||||
curr_instance.dag.version, curr_instance.dag.rank);
|
||||
#if DEBUG
|
||||
#if LOG_INFO_ENABLED
|
||||
rpl_neighbor_print_list("Global repair");
|
||||
#endif
|
||||
#endif /* LOG_INFO_ENABLED */
|
||||
/* Re-initialize configuration from DIO */
|
||||
init_dag_from_dio(dio);
|
||||
rpl_local_repair("Global repair");
|
||||
@ -167,7 +169,7 @@ void
|
||||
rpl_local_repair(const char *str)
|
||||
{
|
||||
if(curr_instance.used) { /* Check needed because this is a public function */
|
||||
PRINTF("RPL: local repair (%s)\n", str);
|
||||
LOG_WARN("local repair (%s)\n", str);
|
||||
curr_instance.of->reset(); /* Reset OF */
|
||||
rpl_neighbor_remove_all(); /* Remove all neighbors */
|
||||
rpl_timers_dio_reset("Local repair"); /* Reset Trickle timer */
|
||||
@ -201,13 +203,13 @@ rpl_dag_update_state(void)
|
||||
/* if new parent, schedule DAO */
|
||||
if(curr_instance.dag.preferred_parent != old_parent) {
|
||||
rpl_timers_schedule_dao();
|
||||
#if DEBUG
|
||||
#if LOG_INFO_ENABLED
|
||||
rpl_neighbor_print_list("Parent switch");
|
||||
#endif
|
||||
#endif /* LOG_INFO_ENABLED */
|
||||
}
|
||||
|
||||
if(curr_instance.dag.rank != old_rank && curr_instance.dag.rank == RPL_INFINITE_RANK) {
|
||||
PRINTF("RPL: intinite rank, trigger local repair\n");
|
||||
LOG_WARN("intinite rank, trigger local repair\n");
|
||||
rpl_local_repair("Infinite rank");
|
||||
}
|
||||
}
|
||||
@ -237,7 +239,7 @@ update_nbr_from_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
nbr = nbr_table_add_lladdr(rpl_neighbors, (linkaddr_t *)lladdr,
|
||||
NBR_TABLE_REASON_RPL_DIO, dio);
|
||||
if(nbr == NULL) {
|
||||
PRINTF("RPL: failed to add neighbor\n");
|
||||
LOG_ERR("failed to add neighbor\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -281,12 +283,12 @@ process_dio_from_current_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
* to re-add this source of the DIO to the neighbor table */
|
||||
if(rpl_lollipop_greater_than(dio->version, curr_instance.dag.version)) {
|
||||
if(curr_instance.dag.rank == ROOT_RANK) { /* The root should not hear newer versions */
|
||||
PRINTF("RPL: inconsistent DIO version (current: %u, received: %u), initiate global repair\n",
|
||||
LOG_ERR("inconsistent DIO version (current: %u, received: %u), initiate global repair\n",
|
||||
curr_instance.dag.version, dio->version);
|
||||
curr_instance.dag.version = dio->version; /* Update version and trigger global repair */
|
||||
rpl_global_repair();
|
||||
} else {
|
||||
PRINTF("RPL: new DIO version (current: %u, received: %u), apply global repair\n",
|
||||
LOG_WARN("new DIO version (current: %u, received: %u), apply global repair\n",
|
||||
curr_instance.dag.version, dio->version);
|
||||
global_repair_non_root(dio);
|
||||
}
|
||||
@ -294,7 +296,7 @@ process_dio_from_current_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
|
||||
/* Update IPv6 neighbor cache */
|
||||
if(!rpl_icmp6_update_nbr_table(from, NBR_TABLE_REASON_RPL_DIO, dio)) {
|
||||
PRINTF("RPL: IPv6 cache full, dropping DIO\n");
|
||||
LOG_ERR("IPv6 cache full, dropping DIO\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -303,7 +305,7 @@ process_dio_from_current_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
last_dtsn = p != NULL ? p->dtsn : RPL_LOLLIPOP_INIT;
|
||||
|
||||
if(!update_nbr_from_dio(from, dio)) {
|
||||
PRINTF("RPL: neighbor table full, dropping DIO\n");
|
||||
LOG_ERR("neighbor table full, dropping DIO\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -334,13 +336,13 @@ init_dag(uint8_t instance_id, uip_ipaddr_t *dag_id, rpl_ocp_t ocp,
|
||||
/* OF */
|
||||
of = find_objective_function(ocp);
|
||||
if(of == NULL) {
|
||||
PRINTF("RPL: ignoring DIO with an unsupported OF: %u\n", ocp);
|
||||
LOG_ERR("ignoring DIO with an unsupported OF: %u\n", ocp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Prefix */
|
||||
if(!rpl_set_prefix_from_addr(prefix, prefix_len, prefix_flags)) {
|
||||
PRINTF("RPL: failed to set prefix");
|
||||
LOG_ERR("failed to set prefix");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -397,13 +399,13 @@ process_dio_join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
{
|
||||
/* Check MOP */
|
||||
if(dio->mop != RPL_MOP_NO_DOWNWARD_ROUTES && dio->mop != RPL_MOP_NON_STORING) {
|
||||
PRINTF("RPL: ignoring DIO with an unsupported MOP: %d\n", dio->mop);
|
||||
LOG_WARN("ignoring DIO with an unsupported MOP: %d\n", dio->mop);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Initialize instance and DAG data structures */
|
||||
if(!init_dag_from_dio(dio)) {
|
||||
PRINTF("RPL: failed to initialize DAG\n");
|
||||
LOG_WARN("failed to initialize DAG\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -414,12 +416,12 @@ process_dio_join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
rpl_schedule_probing();
|
||||
#endif /* RPL_WITH_PROBING */
|
||||
|
||||
PRINTF("RPL: joined DAG with instance ID %u, DAG ID ",
|
||||
LOG_INFO("joined DAG with instance ID %u, DAG ID ",
|
||||
curr_instance.instance_id);
|
||||
PRINT6ADDR(&curr_instance.dag.dag_id);
|
||||
PRINTF(", rank %u\n", curr_instance.dag.rank);
|
||||
LOG_INFO_6ADDR(&curr_instance.dag.dag_id);
|
||||
LOG_INFO(", rank %u\n", curr_instance.dag.rank);
|
||||
|
||||
ANNOTATE("#A join=%u\n", curr_instance.dag.dag_id.u8[sizeof(curr_instance.dag.dag_id) - 1]);
|
||||
LOG_ANNOTATE("#A join=%u\n", curr_instance.dag.dag_id.u8[sizeof(curr_instance.dag.dag_id) - 1]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -430,7 +432,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
if(!curr_instance.used && !rpl_dag_root_is_root()) {
|
||||
/* Attempt to join on this DIO */
|
||||
if(!process_dio_join_dag(from, dio)) {
|
||||
PRINTF("RPL: failed to join DAG");
|
||||
LOG_WARN("failed to join DAG");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -451,7 +453,7 @@ rpl_process_dis(uip_ipaddr_t *from, int is_multicast)
|
||||
} else {
|
||||
/* Add neighbor to cache and reply to the unicast DIS with a unicast DIO*/
|
||||
if(rpl_icmp6_update_nbr_table(from, NBR_TABLE_REASON_RPL_DIS, NULL) != NULL) {
|
||||
PRINTF("RPL: unicast DIS, reply to sender\n");
|
||||
LOG_INFO("unicast DIS, reply to sender\n");
|
||||
rpl_icmp6_dio_output(from);
|
||||
}
|
||||
}
|
||||
@ -464,7 +466,7 @@ rpl_process_dao(uip_ipaddr_t *from, rpl_dao_t *dao)
|
||||
rpl_ns_expire_parent(from, &dao->parent_addr);
|
||||
} else {
|
||||
if(!rpl_ns_update_node(from, &dao->parent_addr, RPL_LIFETIME(dao->lifetime))) {
|
||||
PRINTF("RPL: failed to add link on incoming DAO\n");
|
||||
LOG_ERR("failed to add link on incoming DAO\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -507,7 +509,7 @@ rpl_process_hbh(rpl_nbr_t *sender, uint16_t sender_rank, int loop_detected, int
|
||||
#if RPL_LOOP_ERROR_DROP
|
||||
/* Drop packet and reset trickle timer, as per RFC6550 - 11.2.2.2 */
|
||||
rpl_timers_dio_reset("HBH error");
|
||||
PRINTF("RPL: rank error and loop detected, dropping\n");
|
||||
LOG_WARN("rank error and loop detected, dropping\n");
|
||||
drop = 1;
|
||||
#endif /* RPL_LOOP_ERROR_DROP */
|
||||
}
|
||||
@ -569,12 +571,12 @@ rpl_dag_init_root(uint8_t instance_id, uip_ipaddr_t *dag_id,
|
||||
|
||||
rpl_timers_dio_reset("Init root");
|
||||
|
||||
PRINTF("RPL: created DAG with instance ID %u, DAG ID ",
|
||||
LOG_INFO("created DAG with instance ID %u, DAG ID ",
|
||||
curr_instance.instance_id);
|
||||
PRINT6ADDR(&curr_instance.dag.dag_id);
|
||||
PRINTF(", rank %u\n", curr_instance.dag.rank);
|
||||
LOG_INFO_6ADDR(&curr_instance.dag.dag_id);
|
||||
LOG_INFO(", rank %u\n", curr_instance.dag.rank);
|
||||
|
||||
ANNOTATE("#A root=%u\n", curr_instance.dag.dag_id.u8[sizeof(curr_instance.dag.dag_id) - 1]);
|
||||
LOG_ANNOTATE("#A root=%u\n", curr_instance.dag.dag_id.u8[sizeof(curr_instance.dag.dag_id) - 1]);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
|
@ -48,8 +48,10 @@
|
||||
#include "net/rpl-lite/rpl.h"
|
||||
#include "net/packetbuf.h"
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "RPL"
|
||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||
@ -113,7 +115,7 @@ rpl_ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr)
|
||||
return 1;
|
||||
}
|
||||
|
||||
PRINTF("RPL: packet needs multi-hop downward routing but SRH not found\n");
|
||||
LOG_ERR("packet needs multi-hop downward routing but SRH not found\n");
|
||||
uip_ext_len = last_uip_ext_len;
|
||||
return 0;
|
||||
}
|
||||
@ -153,7 +155,7 @@ rpl_ext_header_srh_update(void)
|
||||
|
||||
if(uip_next_hdr == NULL || *uip_next_hdr != UIP_PROTO_ROUTING
|
||||
|| UIP_RH_BUF->routing_type != RPL_RH_TYPE_SRH) {
|
||||
PRINTF("RPL: SRH not found\n");
|
||||
LOG_INFO("SRH not found\n");
|
||||
uip_ext_len = last_uip_ext_len;
|
||||
return 0;
|
||||
}
|
||||
@ -167,7 +169,7 @@ rpl_ext_header_srh_update(void)
|
||||
path_len = ((ext_len - padding - RPL_RH_LEN - RPL_SRH_LEN - (16 - cmpre)) / (16 - cmpri)) + 1;
|
||||
(void)path_len;
|
||||
|
||||
PRINTF("RPL: read SRH, path len %u, segments left %u, Cmpri %u, Cmpre %u, ext len %u (padding %u)\n",
|
||||
LOG_INFO("read SRH, path len %u, segments left %u, Cmpri %u, Cmpre %u, ext len %u (padding %u)\n",
|
||||
path_len, segments_left, cmpri, cmpre, ext_len, padding);
|
||||
|
||||
/* Update SRH in-place */
|
||||
@ -190,9 +192,9 @@ rpl_ext_header_srh_update(void)
|
||||
/* Update segments left field */
|
||||
UIP_RH_BUF->seg_left--;
|
||||
|
||||
PRINTF("RPL: SRH next hop ");
|
||||
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
|
||||
PRINTF("\n");
|
||||
LOG_INFO("SRH next hop ");
|
||||
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
|
||||
LOG_INFO("\n");
|
||||
}
|
||||
|
||||
uip_ext_len = last_uip_ext_len;
|
||||
@ -232,16 +234,16 @@ insert_srh_header(void)
|
||||
rpl_ns_node_t *node;
|
||||
uip_ipaddr_t node_addr;
|
||||
|
||||
PRINTF("RPL: SRH creating source routing header with destination ");
|
||||
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
|
||||
PRINTF(" \n");
|
||||
LOG_INFO("SRH creating source routing header with destination ");
|
||||
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
|
||||
LOG_INFO(" \n");
|
||||
|
||||
/* Construct source route. We do not do this recursively to keep the runtime stack usage constant. */
|
||||
|
||||
/* Get link of the destination and root */
|
||||
|
||||
if(!rpl_is_addr_in_our_dag(&UIP_IP_BUF->destipaddr)) {
|
||||
PRINTF("RPL: SRH DAG not found\n");
|
||||
LOG_ERR("SRH destination not in our DAG\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -253,12 +255,12 @@ insert_srh_header(void)
|
||||
|
||||
root_node = rpl_ns_get_node(&curr_instance.dag.dag_id);
|
||||
if(root_node == NULL) {
|
||||
PRINTF("RPL: SRH root node not found\n");
|
||||
LOG_ERR("SRH root node not found\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!rpl_ns_is_addr_reachable(&UIP_IP_BUF->destipaddr)) {
|
||||
PRINTF("RPL: SRH no path found to destination\n");
|
||||
LOG_ERR("SRH no path found to destination\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -270,7 +272,7 @@ insert_srh_header(void)
|
||||
cmpre = 15;
|
||||
|
||||
if(node == root_node) {
|
||||
PRINTF("RPL: SRH no need to insert SRH\n");
|
||||
LOG_INFO("SRH no need to insert SRH\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -282,9 +284,9 @@ insert_srh_header(void)
|
||||
cmpri = MIN(cmpri, count_matching_bytes(&node_addr, &UIP_IP_BUF->destipaddr, 16));
|
||||
cmpre = cmpri;
|
||||
|
||||
PRINTF("RPL: SRH Hop ");
|
||||
PRINT6ADDR(&node_addr);
|
||||
PRINTF("\n");
|
||||
LOG_INFO("SRH Hop ");
|
||||
LOG_INFO_6ADDR(&node_addr);
|
||||
LOG_INFO("\n");
|
||||
node = node->parent;
|
||||
path_len++;
|
||||
}
|
||||
@ -297,12 +299,12 @@ insert_srh_header(void)
|
||||
padding = ext_len % 8 == 0 ? 0 : (8 - (ext_len % 8));
|
||||
ext_len += padding;
|
||||
|
||||
PRINTF("RPL: SRH path len: %u, ComprI %u, ComprE %u, ext len %u (padding %u)\n",
|
||||
LOG_INFO("SRH path len: %u, ComprI %u, ComprE %u, ext len %u (padding %u)\n",
|
||||
path_len, cmpri, cmpre, ext_len, padding);
|
||||
|
||||
/* Check if there is enough space to store the extension header */
|
||||
if(uip_len + ext_len > UIP_BUFSIZE) {
|
||||
PRINTF("RPL: packet too long: impossible to add source routing header (%u bytes)\n", ext_len);
|
||||
LOG_ERR("packet too long: impossible to add source routing header (%u bytes)\n", ext_len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -369,20 +371,20 @@ rpl_ext_header_hbh_update(int uip_ext_opt_offset)
|
||||
|| UIP_EXT_HDR_OPT_RPL_BUF->opt_type != UIP_EXT_HDR_OPT_RPL
|
||||
|| UIP_EXT_HDR_OPT_RPL_BUF->opt_len != RPL_HDR_OPT_LEN) {
|
||||
|
||||
PRINTF("RPL: hop-by-hop extension header has wrong size or type (%u %u %u)\n",
|
||||
LOG_ERR("hop-by-hop extension header has wrong size or type (%u %u %u)\n",
|
||||
UIP_HBHO_BUF->len, UIP_EXT_HDR_OPT_RPL_BUF->opt_type,
|
||||
UIP_EXT_HDR_OPT_RPL_BUF->opt_len);
|
||||
return 0; /* Drop */
|
||||
}
|
||||
|
||||
if(!curr_instance.used || curr_instance.instance_id != UIP_EXT_HDR_OPT_RPL_BUF->instance) {
|
||||
PRINTF("RPL: unknown instance: %u\n",
|
||||
LOG_ERR("unknown instance: %u\n",
|
||||
UIP_EXT_HDR_OPT_RPL_BUF->instance);
|
||||
return 0; /* Drop */
|
||||
}
|
||||
|
||||
if(UIP_EXT_HDR_OPT_RPL_BUF->flags & RPL_HDR_OPT_FWD_ERR) {
|
||||
PRINTF("RPL: forward error!\n");
|
||||
LOG_ERR("forward error!\n");
|
||||
return 0; /* Drop */
|
||||
}
|
||||
|
||||
@ -393,7 +395,7 @@ rpl_ext_header_hbh_update(int uip_ext_opt_offset)
|
||||
sender_closer = sender_rank < curr_instance.dag.rank;
|
||||
loop_detected = (down && !sender_closer) || (!down && sender_closer);
|
||||
|
||||
PRINTF("RPL: packet going %s, sender closer %d (%d < %d), rank error %u, loop detected %u\n",
|
||||
LOG_INFO("packet going %s, sender closer %d (%d < %d), rank error %u, loop detected %u\n",
|
||||
down == 1 ? "down" : "up", sender_closer, sender_rank,
|
||||
curr_instance.dag.rank, rank_error_signaled, loop_detected);
|
||||
|
||||
@ -422,13 +424,13 @@ update_hbh_header(void)
|
||||
if(UIP_HBHO_BUF->len != ((RPL_HOP_BY_HOP_LEN - 8) / 8)
|
||||
|| UIP_EXT_HDR_OPT_RPL_BUF->opt_len != RPL_HDR_OPT_LEN) {
|
||||
|
||||
PRINTF("RPL: hop-by-hop extension header has wrong size (%u %u)\n",
|
||||
LOG_ERR("hop-by-hop extension header has wrong size (%u %u)\n",
|
||||
UIP_EXT_HDR_OPT_RPL_BUF->opt_len, uip_ext_len);
|
||||
return 0; /* Drop */
|
||||
}
|
||||
|
||||
if(!curr_instance.used || curr_instance.instance_id != UIP_EXT_HDR_OPT_RPL_BUF->instance) {
|
||||
PRINTF("RPL: unable to add/update hop-by-hop extension header: incorrect instance\n");
|
||||
LOG_ERR("unable to add/update hop-by-hop extension header: incorrect instance\n");
|
||||
uip_ext_len = last_uip_ext_len;
|
||||
return 0; /* Drop */
|
||||
}
|
||||
@ -458,9 +460,9 @@ insert_hbh_header(void)
|
||||
uip_ext_opt_offset = 2;
|
||||
|
||||
/* Insert hop-by-hop header */
|
||||
PRINTF("RPL: creating hop-by-hop option\n");
|
||||
LOG_INFO("creating hop-by-hop option\n");
|
||||
if(uip_len + RPL_HOP_BY_HOP_LEN > UIP_BUFSIZE) {
|
||||
PRINTF("RPL: packet too long: impossible to add hop-by-hop option\n");
|
||||
LOG_ERR("packet too long: impossible to add hop-by-hop option\n");
|
||||
uip_ext_len = last_uip_ext_len;
|
||||
return 0;
|
||||
}
|
||||
@ -511,7 +513,7 @@ rpl_ext_header_update(void)
|
||||
if(curr_instance.mop != RPL_MOP_NO_DOWNWARD_ROUTES) {
|
||||
return insert_srh_header();
|
||||
} else {
|
||||
PRINTF("RPL: packet going down at root, but no support for downward routing\n");
|
||||
LOG_ERR("packet going down at root, but no support for downward routing\n");
|
||||
return 0; /* No support for downward routes */
|
||||
}
|
||||
} else {
|
||||
@ -555,7 +557,7 @@ rpl_ext_header_remove(void)
|
||||
if(UIP_IP_BUF->len[1] > temp_len) {
|
||||
UIP_IP_BUF->len[0]--;
|
||||
}
|
||||
PRINTF("RPL: removing RPL extension header (type %u, len %u)\n", *uip_next_hdr, rpl_ext_hdr_len);
|
||||
LOG_INFO("removing RPL extension header (type %u, len %u)\n", *uip_next_hdr, rpl_ext_hdr_len);
|
||||
memmove(UIP_EXT_BUF, ((uint8_t *)UIP_EXT_BUF) + rpl_ext_hdr_len, uip_len - UIP_IPH_LEN);
|
||||
break;
|
||||
case UIP_PROTO_DESTO:
|
||||
|
@ -53,8 +53,10 @@
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "RPL"
|
||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define RPL_DIO_GROUNDED 0x80
|
||||
@ -121,11 +123,11 @@ rpl_icmp6_update_nbr_table(uip_ipaddr_t *from, nbr_table_reason_t reason, void *
|
||||
if((nbr = uip_ds6_nbr_add(from, (uip_lladdr_t *)
|
||||
packetbuf_addr(PACKETBUF_ADDR_SENDER),
|
||||
0, NBR_REACHABLE, reason, data)) == NULL) {
|
||||
PRINTF("RPL: could not add neighbor to cache ");
|
||||
PRINT6ADDR(from);
|
||||
PRINTF(", ");
|
||||
PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||
PRINTF("\n");
|
||||
LOG_ERR("could not add neighbor to cache ");
|
||||
LOG_ERR_6ADDR(from);
|
||||
LOG_ERR(", ");
|
||||
LOG_ERR_LLADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||
LOG_ERR("\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,13 +138,13 @@ static void
|
||||
dis_input(void)
|
||||
{
|
||||
if(!curr_instance.used) {
|
||||
PRINTF("RPL: dis_input: not in an instance yet, discard\n");
|
||||
LOG_WARN("dis_input: not in an instance yet, discard\n");
|
||||
goto discard;
|
||||
}
|
||||
|
||||
PRINTF("RPL: received a DIS from ");
|
||||
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
|
||||
PRINTF("\n");
|
||||
LOG_INFO("received a DIS from ");
|
||||
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
|
||||
LOG_INFO("\n");
|
||||
|
||||
rpl_process_dis(&UIP_IP_BUF->srcipaddr, uip_is_addr_mcast(&UIP_IP_BUF->destipaddr));
|
||||
|
||||
@ -165,9 +167,9 @@ rpl_icmp6_dis_output(uip_ipaddr_t *addr)
|
||||
addr = &rpl_multicast_addr;
|
||||
}
|
||||
|
||||
PRINTF("RPL: sending a DIS to ");
|
||||
PRINT6ADDR(addr);
|
||||
PRINTF("\n");
|
||||
LOG_INFO("sending a DIS to ");
|
||||
LOG_INFO_6ADDR(addr);
|
||||
LOG_INFO("\n");
|
||||
|
||||
uip_icmp6_send(addr, ICMP6_RPL, RPL_CODE_DIS, 2);
|
||||
}
|
||||
@ -230,14 +232,14 @@ dio_input(void)
|
||||
}
|
||||
|
||||
if(len + i > buffer_length) {
|
||||
PRINTF("RPL: dio_input: malformed packet, discard\n");
|
||||
LOG_ERR("dio_input: malformed packet, discard\n");
|
||||
goto discard;
|
||||
}
|
||||
|
||||
switch(subopt_type) {
|
||||
case RPL_OPTION_DAG_METRIC_CONTAINER:
|
||||
if(len < 6) {
|
||||
PRINTF("RPL: dio_input: invalid DAG MC, len %u, discard\n", len);
|
||||
LOG_WARN("dio_input: invalid DAG MC, len %u, discard\n", len);
|
||||
goto discard;
|
||||
}
|
||||
dio.mc.type = buffer[i + 2];
|
||||
@ -255,13 +257,13 @@ dio_input(void)
|
||||
dio.mc.obj.energy.flags = buffer[i + 6];
|
||||
dio.mc.obj.energy.energy_est = buffer[i + 7];
|
||||
} else {
|
||||
PRINTF("RPL: dio_input: unsupported DAG MC type %u, discard\n", (unsigned)dio.mc.type);
|
||||
LOG_WARN("dio_input: unsupported DAG MC type %u, discard\n", (unsigned)dio.mc.type);
|
||||
goto discard;
|
||||
}
|
||||
break;
|
||||
case RPL_OPTION_ROUTE_INFO:
|
||||
if(len < 9) {
|
||||
PRINTF("RPL: dio_input: invalid destination prefix option, len %u, discard\n", len);
|
||||
LOG_WARN("dio_input: invalid destination prefix option, len %u, discard\n", len);
|
||||
goto discard;
|
||||
}
|
||||
|
||||
@ -275,14 +277,14 @@ dio_input(void)
|
||||
memcpy(&dio.destination_prefix.prefix, &buffer[i + 8],
|
||||
(dio.destination_prefix.length + 7) / 8);
|
||||
} else {
|
||||
PRINTF("RPL: dio_input: invalid route info option, len %u, discard\n", len);
|
||||
LOG_WARN("dio_input: invalid route info option, len %u, discard\n", len);
|
||||
goto discard;
|
||||
}
|
||||
|
||||
break;
|
||||
case RPL_OPTION_DAG_CONF:
|
||||
if(len != 16) {
|
||||
PRINTF("RPL: dio_input: invalid DAG configuration option, len %u, discard\n", len);
|
||||
LOG_WARN("dio_input: invalid DAG configuration option, len %u, discard\n", len);
|
||||
goto discard;
|
||||
}
|
||||
|
||||
@ -299,7 +301,7 @@ dio_input(void)
|
||||
break;
|
||||
case RPL_OPTION_PREFIX_INFO:
|
||||
if(len != 32) {
|
||||
PRINTF("RPL: dio_input: invalid DAG prefix info, len %u, discard\n", len);
|
||||
LOG_WARN("dio_input: invalid DAG prefix info, len %u, discard\n", len);
|
||||
goto discard;
|
||||
}
|
||||
dio.prefix_info.length = buffer[i + 2];
|
||||
@ -311,17 +313,17 @@ dio_input(void)
|
||||
memcpy(&dio.prefix_info.prefix, &buffer[i + 16], 16);
|
||||
break;
|
||||
default:
|
||||
PRINTF("RPL: dio_input: unsupported suboption type in DIO: %u, discard\n", (unsigned)subopt_type);
|
||||
LOG_WARN("dio_input: unsupported suboption type in DIO: %u, discard\n", (unsigned)subopt_type);
|
||||
goto discard;
|
||||
}
|
||||
}
|
||||
|
||||
PRINTF("RPL: received a %s-DIO from ",
|
||||
LOG_INFO("received a %s-DIO from ",
|
||||
uip_is_addr_mcast(&UIP_IP_BUF->destipaddr) ? "multicast" : "unicast");
|
||||
PRINT6ADDR(&from);
|
||||
PRINTF(", instance_id %u, DAG ID ", (unsigned)dio.instance_id);
|
||||
PRINT6ADDR(&dio.dag_id);
|
||||
PRINTF(", version %u, rank %u\n",
|
||||
LOG_INFO_6ADDR(&from);
|
||||
LOG_INFO(", instance_id %u, DAG ID ", (unsigned)dio.instance_id);
|
||||
LOG_INFO_6ADDR(&dio.dag_id);
|
||||
LOG_INFO(", version %u, rank %u\n",
|
||||
(unsigned)dio.version,
|
||||
(unsigned)dio.rank);
|
||||
|
||||
@ -345,7 +347,7 @@ rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr)
|
||||
/* In leaf mode, we only send DIO messages as unicasts in response to
|
||||
unicast DIS messages. */
|
||||
if(uc_addr == NULL) {
|
||||
PRINTF("RPL: leaf-only mode: will not send multicast DIO\n");
|
||||
/* Do not send multicast DIO in leaf mode */
|
||||
return;
|
||||
}
|
||||
#endif /* RPL_LEAF_ONLY */
|
||||
@ -399,7 +401,7 @@ rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr)
|
||||
buffer[pos++] = curr_instance.mc.obj.energy.flags;
|
||||
buffer[pos++] = curr_instance.mc.obj.energy.energy_est;
|
||||
} else {
|
||||
PRINTF("RPL: unable to send DIO because of unsupported DAG MC type %u\n",
|
||||
LOG_ERR("unable to send DIO because of unsupported DAG MC type %u\n",
|
||||
(unsigned)curr_instance.mc.type);
|
||||
return;
|
||||
}
|
||||
@ -445,11 +447,11 @@ rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr)
|
||||
addr = addr != NULL ? addr : &rpl_multicast_addr;
|
||||
#endif /* RPL_LEAF_ONLY */
|
||||
|
||||
PRINTF("RPL: sending a %s-DIO with rank %u to ",
|
||||
LOG_INFO("sending a %s-DIO with rank %u to ",
|
||||
uc_addr != NULL ? "unicast" : "multicast",
|
||||
(unsigned)curr_instance.dag.rank);
|
||||
PRINT6ADDR(addr);
|
||||
PRINTF("\n");
|
||||
LOG_INFO_6ADDR(addr);
|
||||
LOG_INFO("\n");
|
||||
|
||||
uip_icmp6_send(addr, ICMP6_RPL, RPL_CODE_DIO, pos);
|
||||
}
|
||||
@ -470,7 +472,7 @@ dao_input(void)
|
||||
|
||||
dao.instance_id = UIP_ICMP_PAYLOAD[0];
|
||||
if(!curr_instance.used || curr_instance.instance_id != dao.instance_id) {
|
||||
PRINTF("RPL: dao_input: unknown RPL instance %u, discard\n", dao.instance_id);
|
||||
LOG_ERR("dao_input: unknown RPL instance %u, discard\n", dao.instance_id);
|
||||
goto discard;
|
||||
}
|
||||
|
||||
@ -490,9 +492,9 @@ dao_input(void)
|
||||
/* Is the DAG ID present? */
|
||||
if(dao.flags & RPL_DAO_D_FLAG) {
|
||||
if(memcmp(&curr_instance.dag.dag_id, &buffer[pos], sizeof(curr_instance.dag.dag_id))) {
|
||||
PRINTF("RPL: dao_input: different DAG ID ");
|
||||
PRINT6ADDR((uip_ipaddr_t *)&buffer[pos]);
|
||||
PRINTF(", discard\n");
|
||||
LOG_ERR("dao_input: different DAG ID ");
|
||||
LOG_ERR_6ADDR((uip_ipaddr_t *)&buffer[pos]);
|
||||
LOG_ERR(", discard\n");
|
||||
goto discard;
|
||||
}
|
||||
pos += 16;
|
||||
@ -528,13 +530,13 @@ dao_input(void)
|
||||
}
|
||||
|
||||
/* Destination Advertisement Object */
|
||||
PRINTF("RPL: received a %sDAO from ", dao.lifetime == 0 ? "No-path " : "");
|
||||
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
|
||||
PRINTF(", lifetime %u, prefix ", dao.lifetime);
|
||||
PRINT6ADDR(&dao.prefix);
|
||||
PRINTF(", prefix length %u, parent ", dao.prefixlen);
|
||||
PRINT6ADDR(&dao.parent_addr);
|
||||
PRINTF(" \n");
|
||||
LOG_INFO("received a %sDAO from ", dao.lifetime == 0 ? "No-path " : "");
|
||||
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
|
||||
LOG_INFO(", lifetime %u, prefix ", dao.lifetime);
|
||||
LOG_INFO_6ADDR(&dao.prefix);
|
||||
LOG_INFO(", prefix length %u, parent ", dao.prefixlen);
|
||||
LOG_INFO_6ADDR(&dao.parent_addr);
|
||||
LOG_INFO(" \n");
|
||||
|
||||
rpl_process_dao(&from, &dao);
|
||||
|
||||
@ -556,7 +558,7 @@ rpl_icmp6_dao_output(uint8_t lifetime)
|
||||
|
||||
if(!curr_instance.used || curr_instance.dag.preferred_parent == NULL
|
||||
|| prefix == NULL || parent_ipaddr == NULL || curr_instance.mop == RPL_MOP_NO_DOWNWARD_ROUTES) {
|
||||
PRINTF("RPL: rpl_icmp6_dao_output: node not ready to send a DAO (used %u, pref parent %p, prefix %p, parent_ipaddr %p, mop %u)\n",
|
||||
LOG_WARN("rpl_icmp6_dao_output: node not ready to send a DAO (used %u, pref parent %p, prefix %p, parent_ipaddr %p, mop %u)\n",
|
||||
curr_instance.used, curr_instance.dag.preferred_parent, prefix, parent_ipaddr, curr_instance.mop);
|
||||
return;
|
||||
}
|
||||
@ -598,15 +600,15 @@ rpl_icmp6_dao_output(uint8_t lifetime)
|
||||
memcpy(buffer + pos, ((const unsigned char *)parent_ipaddr) + 8, 8); /* Interface identifier */
|
||||
pos += 8;
|
||||
|
||||
PRINTF("RPL: sending a %sDAO seqno %u, tx count %u, lifetime %u, prefix ",
|
||||
LOG_INFO("sending a %sDAO seqno %u, tx count %u, lifetime %u, prefix ",
|
||||
lifetime == 0 ? "No-path " : "",
|
||||
curr_instance.dag.dao_curr_seqno, curr_instance.dag.dao_transmissions, lifetime);
|
||||
PRINT6ADDR(prefix);
|
||||
PRINTF(" to ");
|
||||
PRINT6ADDR(&curr_instance.dag.dag_id);
|
||||
PRINTF(" , parent ");
|
||||
PRINT6ADDR(parent_ipaddr);
|
||||
PRINTF("\n");
|
||||
LOG_INFO_6ADDR(prefix);
|
||||
LOG_INFO(" to ");
|
||||
LOG_INFO_6ADDR(&curr_instance.dag.dag_id);
|
||||
LOG_INFO(" , parent ");
|
||||
LOG_INFO_6ADDR(parent_ipaddr);
|
||||
LOG_INFO("\n");
|
||||
|
||||
/* Send DAO to root (IPv6 address is DAG ID) */
|
||||
uip_icmp6_send(&curr_instance.dag.dag_id, ICMP6_RPL, RPL_CODE_DAO, pos);
|
||||
@ -628,15 +630,15 @@ dao_ack_input(void)
|
||||
status = buffer[3];
|
||||
|
||||
if(!curr_instance.used || curr_instance.instance_id != instance_id) {
|
||||
PRINTF("RPL: dao_ack_input: unknown instance, discard\n");
|
||||
LOG_ERR("dao_ack_input: unknown instance, discard\n");
|
||||
goto discard;
|
||||
}
|
||||
|
||||
PRINTF("RPL: received a DAO-%s with seqno %d (%d %d) and status %d from ",
|
||||
LOG_INFO("received a DAO-%s with seqno %d (%d %d) and status %d from ",
|
||||
status < RPL_DAO_ACK_UNABLE_TO_ACCEPT ? "ACK" : "NACK", sequence,
|
||||
curr_instance.dag.dao_curr_seqno, curr_instance.dag.dao_curr_seqno, status);
|
||||
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
|
||||
PRINTF("\n");
|
||||
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
|
||||
LOG_INFO("\n");
|
||||
|
||||
rpl_process_dao_ack(sequence, status);
|
||||
|
||||
@ -658,10 +660,10 @@ rpl_icmp6_dao_ack_output(uip_ipaddr_t *dest, uint8_t sequence, uint8_t status)
|
||||
buffer[2] = sequence;
|
||||
buffer[3] = status;
|
||||
|
||||
PRINTF("RPL: sending a DAO-%s seqno %d to ",
|
||||
LOG_INFO("sending a DAO-%s seqno %d to ",
|
||||
status < RPL_DAO_ACK_UNABLE_TO_ACCEPT ? "ACK" : "NACK", sequence);
|
||||
PRINT6ADDR(dest);
|
||||
PRINTF(" with status %d\n", status);
|
||||
LOG_INFO_6ADDR(dest);
|
||||
LOG_INFO(" with status %d\n", status);
|
||||
|
||||
uip_icmp6_send(dest, ICMP6_RPL, RPL_CODE_DAO_ACK, 4);
|
||||
}
|
||||
|
@ -51,8 +51,10 @@
|
||||
#include "net/nbr-table.h"
|
||||
#include "net/link-stats.h"
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "RPL"
|
||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
||||
|
||||
/* RFC6551 and RFC6719 do not mandate the use of a specific formula to
|
||||
* compute the ETX value. This MRHOF implementation relies on the value
|
||||
@ -92,7 +94,7 @@ to the threshold of 96 in the non-squared case) */
|
||||
static void
|
||||
reset(void)
|
||||
{
|
||||
PRINTF("RPL: Reset MRHOF\n");
|
||||
LOG_INFO("Reset MRHOF\n");
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint16_t
|
||||
@ -218,8 +220,8 @@ update_metric_container(void)
|
||||
uint16_t path_cost;
|
||||
uint8_t type;
|
||||
|
||||
if(curr_instance.used) {
|
||||
PRINTF("RPL: cannot update the metric container when not joined\n");
|
||||
if(!curr_instance.used) {
|
||||
LOG_WARN("cannot update the metric container when not joined\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -254,7 +256,7 @@ update_metric_container(void)
|
||||
curr_instance.mc.obj.energy.energy_est = path_cost >> 8;
|
||||
break;
|
||||
default:
|
||||
PRINTF("RPL: MRHOF, non-supported MC %u\n", curr_instance.mc.type);
|
||||
LOG_WARN("MRHOF, non-supported MC %u\n", curr_instance.mc.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,10 @@
|
||||
#include "net/rpl-lite/rpl.h"
|
||||
#include "net/nbr-table.h"
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "RPL"
|
||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
||||
|
||||
/*
|
||||
* Policy for neighbor adds
|
||||
@ -161,7 +163,7 @@ update_nbr(void)
|
||||
/* how many more IP neighbors can be have? */
|
||||
num_free = NBR_TABLE_MAX_NEIGHBORS - num_used;
|
||||
|
||||
PRINTF("RPL nbr-policy: free: %d, children: %d, parents: %d routes: %d\n",
|
||||
LOG_INFO("nbr-policy: free: %d, children: %d, parents: %d routes: %d\n",
|
||||
num_free, num_children, num_parents, uip_ds6_route_num_routes());
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -183,19 +185,19 @@ find_removable_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
update_nbr();
|
||||
|
||||
if(!curr_instance.used || curr_instance.instance_id != dio->instance_id) {
|
||||
PRINTF("RPL nbr-policy: did not find instance id: %d\n", dio->instance_id);
|
||||
LOG_WARN("nbr-policy: did not find instance id: %d\n", dio->instance_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Add the new neighbor only if it is better than the current worst. */
|
||||
if(dio->rank + curr_instance.min_hoprankinc < worst_rank - curr_instance.min_hoprankinc / 2) {
|
||||
/* Found *great* neighbor - add! */
|
||||
PRINTF("RPL nbr-policy: DIO rank %u, worse_rank %u -- add to cache\n",
|
||||
LOG_INFO("nbr-policy: DIO rank %u, worse_rank %u -- add to cache\n",
|
||||
dio->rank, worst_rank);
|
||||
return worst_rank_nbr;
|
||||
}
|
||||
|
||||
PRINTF("RPL nbr-policy: DIO rank %u, worse_rank %u -- do not add to cache\n",
|
||||
LOG_INFO("nbr-policy: DIO rank %u, worse_rank %u -- do not add to cache\n",
|
||||
dio->rank, worst_rank);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -43,14 +43,15 @@
|
||||
* \addtogroup uip6
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/rpl-lite/rpl.h"
|
||||
#include "net/link-stats.h"
|
||||
#include "net/nbr-table.h"
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "RPL"
|
||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
||||
|
||||
/* A configurable function called after every RPL parent switch */
|
||||
#ifdef RPL_CALLBACK_PARENT_SWITCH
|
||||
@ -82,12 +83,12 @@ rpl_neighbor_print_list(const char *str)
|
||||
rpl_nbr_t *nbr = nbr_table_head(rpl_neighbors);
|
||||
clock_time_t clock_now = clock_time();
|
||||
|
||||
printf("RPL nbr: MOP %u OCP %u rank %u dioint %u, DS6 nbr count %u (%s)\n",
|
||||
printf("nbr: MOP %u OCP %u rank %u dioint %u, DS6 nbr count %u (%s)\n",
|
||||
curr_instance.mop, curr_instance.of->ocp, curr_rank,
|
||||
curr_dio_interval, uip_ds6_nbr_num(), str);
|
||||
while(nbr != NULL) {
|
||||
const struct link_stats *stats = rpl_neighbor_get_link_stats(nbr);
|
||||
printf("RPL nbr: %3u %5u, %5u => %5u -- %2u %c%c%c (last tx %u min ago)\n",
|
||||
printf("nbr: %3u %5u, %5u => %5u -- %2u %c%c%c (last tx %u min ago)\n",
|
||||
rpl_neighbor_get_ipaddr(nbr)->u8[15],
|
||||
nbr->rank,
|
||||
rpl_neighbor_get_link_metric(nbr),
|
||||
@ -100,7 +101,7 @@ rpl_neighbor_print_list(const char *str)
|
||||
);
|
||||
nbr = nbr_table_next(rpl_neighbors, nbr);
|
||||
}
|
||||
printf("RPL nbr: end of list\n");
|
||||
printf("nbr: end of list\n");
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -211,19 +212,19 @@ void
|
||||
rpl_neighbor_set_preferred(rpl_nbr_t *nbr)
|
||||
{
|
||||
if(curr_instance.dag.preferred_parent != nbr) {
|
||||
PRINTF("RPL: parent switch ");
|
||||
LOG_INFO("parent switch ");
|
||||
if(nbr != NULL) {
|
||||
PRINT6ADDR(rpl_neighbor_get_ipaddr(nbr));
|
||||
LOG_INFO_6ADDR(rpl_neighbor_get_ipaddr(nbr));
|
||||
} else {
|
||||
PRINTF("NULL");
|
||||
LOG_INFO("NULL");
|
||||
}
|
||||
PRINTF(" used to be ");
|
||||
LOG_INFO(" used to be ");
|
||||
if(curr_instance.dag.preferred_parent != NULL) {
|
||||
PRINT6ADDR(rpl_neighbor_get_ipaddr(curr_instance.dag.preferred_parent));
|
||||
LOG_INFO_6ADDR(rpl_neighbor_get_ipaddr(curr_instance.dag.preferred_parent));
|
||||
} else {
|
||||
PRINTF("NULL");
|
||||
LOG_INFO("NULL");
|
||||
}
|
||||
PRINTF("\n");
|
||||
LOG_INFO("\n");
|
||||
|
||||
#ifdef RPL_CALLBACK_PARENT_SWITCH
|
||||
RPL_CALLBACK_PARENT_SWITCH(curr_instance.dag.preferred_parent, nbr);
|
||||
@ -249,7 +250,7 @@ rpl_neighbor_remove_all(void)
|
||||
{
|
||||
rpl_nbr_t *nbr;
|
||||
|
||||
PRINTF("RPL: removing all neighbors\n");
|
||||
LOG_INFO("removing all neighbors\n");
|
||||
|
||||
nbr = nbr_table_head(rpl_neighbors);
|
||||
while(nbr != NULL) {
|
||||
|
@ -41,8 +41,10 @@
|
||||
#include "lib/list.h"
|
||||
#include "lib/memb.h"
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "RPL"
|
||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
||||
|
||||
/* Total number of nodes */
|
||||
static int num_nodes;
|
||||
@ -115,7 +117,7 @@ rpl_ns_update_node(const uip_ipaddr_t *child, const uip_ipaddr_t *parent, uint32
|
||||
if(parent_node == NULL) {
|
||||
parent_node = rpl_ns_update_node(parent, NULL, RPL_ROUTE_INFINITE_LIFETIME);
|
||||
if(parent_node == NULL) {
|
||||
PRINTF("RPL NS: no space left for root node!\n");
|
||||
LOG_ERR("NS: no space left for root node!\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -126,9 +128,9 @@ rpl_ns_update_node(const uip_ipaddr_t *child, const uip_ipaddr_t *parent, uint32
|
||||
child_node = memb_alloc(&nodememb);
|
||||
/* No space left, abort */
|
||||
if(child_node == NULL) {
|
||||
PRINTF("RPL NS: no space left for child ");
|
||||
PRINT6ADDR(child);
|
||||
PRINTF("\n");
|
||||
LOG_ERR("NS: no space left for child ");
|
||||
LOG_ERR_6ADDR(child);
|
||||
LOG_ERR("\n");
|
||||
return NULL;
|
||||
}
|
||||
child_node->parent = NULL;
|
||||
@ -156,11 +158,11 @@ rpl_ns_update_node(const uip_ipaddr_t *child, const uip_ipaddr_t *parent, uint32
|
||||
child_node->parent = parent_node;
|
||||
}
|
||||
|
||||
PRINTF("RPL NS: updating link, child ");
|
||||
PRINT6ADDR(child);
|
||||
PRINTF(", parent ");
|
||||
PRINT6ADDR(parent);
|
||||
PRINTF(", lifetime %u, num_nodes %u\n", (unsigned)lifetime, num_nodes);
|
||||
LOG_INFO("NS: updating link, child ");
|
||||
LOG_INFO_6ADDR(child);
|
||||
LOG_INFO(", parent ");
|
||||
LOG_INFO_6ADDR(parent);
|
||||
LOG_INFO(", lifetime %u, num_nodes %u\n", (unsigned)lifetime, num_nodes);
|
||||
|
||||
return child_node;
|
||||
}
|
||||
@ -217,13 +219,13 @@ rpl_ns_periodic(unsigned seconds)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if DEBUG
|
||||
#if LOG_INFO_ENABLED
|
||||
uip_ipaddr_t node_addr;
|
||||
rpl_ns_get_node_global_addr(&node_addr, l);
|
||||
PRINTF("RPL NS: removing expired node ");
|
||||
PRINT6ADDR(&node_addr);
|
||||
PRINTF("\n");
|
||||
#endif
|
||||
LOG_INFO("NS: removing expired node ");
|
||||
LOG_INFO_6ADDR(&node_addr);
|
||||
LOG_INFO("\n");
|
||||
#endif /* LOG_INFO_ENABLED */
|
||||
/* No child found, deallocate node */
|
||||
list_remove(nodelist, l);
|
||||
memb_free(&nodememb, l);
|
||||
|
@ -47,8 +47,10 @@
|
||||
#include "net/nbr-table.h"
|
||||
#include "net/link-stats.h"
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "RPL"
|
||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
||||
|
||||
/* Constants from RFC6552. We use the default values. */
|
||||
#define RANK_STRETCH 0 /* Must be in the range [0;5] */
|
||||
@ -87,7 +89,7 @@
|
||||
static void
|
||||
reset(void)
|
||||
{
|
||||
PRINTF("RPL: Reset OF0\n");
|
||||
LOG_INFO("Reset OF0\n");
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uint16_t
|
||||
|
@ -48,8 +48,10 @@
|
||||
#include "lib/random.h"
|
||||
#include "sys/ctimer.h"
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "RPL"
|
||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
||||
|
||||
/* A configurable function called after update of the RPL DIO interval */
|
||||
#ifdef RPL_CALLBACK_NEW_DIO_INTERVAL
|
||||
@ -144,7 +146,7 @@ void
|
||||
rpl_timers_dio_reset(const char *str)
|
||||
{
|
||||
if(curr_instance.used) {
|
||||
PRINTF("RPL: reset DIO timer (%s)\n", str);
|
||||
LOG_INFO("reset DIO timer (%s)\n", str);
|
||||
#if !RPL_LEAF_ONLY
|
||||
curr_instance.dag.dio_counter = 0;
|
||||
curr_instance.dag.dio_intcurrent = curr_instance.dio_intmin;
|
||||
@ -410,7 +412,7 @@ handle_probing_timer(void *ptr)
|
||||
if(target_ipaddr != NULL) {
|
||||
const struct link_stats *stats = rpl_neighbor_get_link_stats(probing_target);
|
||||
(void)stats;
|
||||
PRINTF("RPL: probing %u %s last tx %u min ago\n",
|
||||
LOG_INFO("probing %u %s last tx %u min ago\n",
|
||||
rpl_neighbor_get_lladdr(probing_target)->u8[7],
|
||||
curr_instance.dag.urgent_probing_target != NULL ? "(urgent)" : "",
|
||||
probing_target != NULL ?
|
||||
@ -460,9 +462,9 @@ handle_periodic_timer(void *ptr)
|
||||
|
||||
ctimer_reset(&periodic_timer);
|
||||
|
||||
#if DEBUG
|
||||
#if LOG_INFO_ENABLED
|
||||
rpl_neighbor_print_list("Periodic");
|
||||
#endif
|
||||
#endif /* LOG_INFO_ENABLED */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
|
@ -45,8 +45,10 @@
|
||||
|
||||
#include "net/rpl-lite/rpl.h"
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "RPL"
|
||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
||||
|
||||
uip_ipaddr_t rpl_multicast_addr;
|
||||
|
||||
@ -118,9 +120,9 @@ rpl_reset_prefix(rpl_prefix_t *last_prefix)
|
||||
set_ip_from_prefix(&ipaddr, last_prefix);
|
||||
rep = uip_ds6_addr_lookup(&ipaddr);
|
||||
if(rep != NULL) {
|
||||
PRINTF("RPL: removing global IP address ");
|
||||
PRINT6ADDR(&ipaddr);
|
||||
PRINTF("\n");
|
||||
LOG_INFO("removing global IP address ");
|
||||
LOG_INFO_6ADDR(&ipaddr);
|
||||
LOG_INFO("\n");
|
||||
uip_ds6_addr_rm(rep);
|
||||
}
|
||||
curr_instance.dag.prefix_info.length = 0;
|
||||
@ -132,7 +134,7 @@ rpl_set_prefix_from_addr(uip_ipaddr_t *addr, unsigned len, uint8_t flags)
|
||||
uip_ipaddr_t ipaddr;
|
||||
|
||||
if(addr == NULL || len == 0 || len > 128 || !(flags & UIP_ND6_RA_FLAG_AUTONOMOUS)) {
|
||||
PRINTF("RPL: ignoring DIO with no, not-supported, or invalid prefix\n");
|
||||
LOG_WARN("not-supported or invalid prefix\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -146,9 +148,9 @@ rpl_set_prefix_from_addr(uip_ipaddr_t *addr, unsigned len, uint8_t flags)
|
||||
/* Add global address if not already there */
|
||||
set_ip_from_prefix(&ipaddr, &curr_instance.dag.prefix_info);
|
||||
if(uip_ds6_addr_lookup(&ipaddr) == NULL) {
|
||||
PRINTF("RPL: adding global IP address ");
|
||||
PRINT6ADDR(&ipaddr);
|
||||
PRINTF("\n");
|
||||
LOG_INFO("adding global IP address ");
|
||||
LOG_INFO_6ADDR(&ipaddr);
|
||||
LOG_INFO("\n");
|
||||
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
|
||||
}
|
||||
return 1;
|
||||
@ -167,7 +169,7 @@ rpl_set_prefix(rpl_prefix_t *prefix)
|
||||
void
|
||||
rpl_init(void)
|
||||
{
|
||||
PRINTF("RPL: initializing\n");
|
||||
LOG_INFO("initializing\n");
|
||||
|
||||
/* Initialize multicast address and register it */
|
||||
uip_create_linklocal_rplnodes_mcast(&rpl_multicast_addr);
|
||||
|
@ -48,6 +48,14 @@
|
||||
|
||||
/* A list of currently supported modules */
|
||||
|
||||
#ifndef RPL_LOG_LEVEL
|
||||
#define RPL_LOG_LEVEL LOG_LEVEL_NONE /* Only for rpl-lite */
|
||||
#endif /* RPL_LOG_LEVEL */
|
||||
|
||||
#ifndef TCPIP_LOG_LEVEL
|
||||
#define TCPIP_LOG_LEVEL LOG_LEVEL_NONE
|
||||
#endif /* TCPIP_LOG_LEVEL */
|
||||
|
||||
#ifndef IPV6_LOG_LEVEL
|
||||
#define IPV6_LOG_LEVEL LOG_LEVEL_NONE
|
||||
#endif /* IPV6_LOG_LEVEL */
|
||||
@ -56,10 +64,6 @@
|
||||
#define SICSLOWPAN_LOG_LEVEL LOG_LEVEL_NONE
|
||||
#endif /* SICSLOWPAN_LOG_LEVEL */
|
||||
|
||||
#ifndef TCPIP_LOG_LEVEL
|
||||
#define TCPIP_LOG_LEVEL LOG_LEVEL_NONE
|
||||
#endif /* TCPIP_LOG_LEVEL */
|
||||
|
||||
#ifndef MAC_LOG_LEVEL
|
||||
#define MAC_LOG_LEVEL LOG_LEVEL_NONE
|
||||
#endif /* MAC_LOG_LEVELL */
|
||||
|
Loading…
Reference in New Issue
Block a user