sixtop: use LOG APIs instead of PRINTF from net-debug.h
This commit is contained in:
parent
7530c560c5
commit
57263042ae
@ -45,8 +45,10 @@
|
||||
|
||||
#include "sixp.h"
|
||||
|
||||
#define DEBUG DEBUG_PRINT
|
||||
#include "net/net-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "6top"
|
||||
#define LOG_LEVEL LOG_LEVEL_6TOP
|
||||
|
||||
/**
|
||||
* \brief 6P Neighbor Data Structure (for internal use)
|
||||
@ -82,14 +84,14 @@ sixp_nbr_alloc(const linkaddr_t *addr)
|
||||
|
||||
assert(addr != NULL);
|
||||
if(addr == NULL) {
|
||||
PRINTF("6P-nbr: sixp_nbr_alloc() fails because of invalid argument\n");
|
||||
LOG_ERR("6P-nbr: sixp_nbr_alloc() fails because of invalid argument\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(sixp_nbr_find(addr) != NULL) {
|
||||
PRINTF("6P-nbr: sixp_nbr_alloc() fails because of duplication [peer_addr:");
|
||||
PRINTLLADDR((const uip_lladdr_t *)addr);
|
||||
PRINTF("]\n");
|
||||
LOG_ERR("6P-nbr: sixp_nbr_alloc() fails because of duplication [peer_addr:");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)addr);
|
||||
LOG_ERR_("]\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -97,7 +99,7 @@ sixp_nbr_alloc(const linkaddr_t *addr)
|
||||
addr,
|
||||
NBR_TABLE_REASON_SIXTOP,
|
||||
NULL)) == NULL) {
|
||||
PRINTF("6P-nbr: sixp_nbr_alloc() fails to add nbr because of no memory\n");
|
||||
LOG_ERR("6P-nbr: sixp_nbr_alloc() fails to add nbr because of no memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -122,7 +124,7 @@ sixp_nbr_get_gen(sixp_nbr_t *nbr)
|
||||
{
|
||||
assert(nbr != NULL);
|
||||
if(nbr == NULL) {
|
||||
PRINTF("6P-nbr: sixp_nbr_get_gtx() fails because of invalid argument\n");
|
||||
LOG_ERR("6P-nbr: sixp_nbr_get_gtx() fails because of invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
return nbr->gen;
|
||||
@ -133,7 +135,7 @@ sixp_nbr_advance_gen(sixp_nbr_t *nbr)
|
||||
{
|
||||
assert(nbr != NULL);
|
||||
if(nbr == NULL) {
|
||||
PRINTF("6P-nbr: sixp_nbr_advance_gen() fails because of invalid arg\n");
|
||||
LOG_ERR("6P-nbr: sixp_nbr_advance_gen() fails because of invalid arg\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -143,8 +145,8 @@ sixp_nbr_advance_gen(sixp_nbr_t *nbr)
|
||||
nbr->gen++;
|
||||
} else {
|
||||
/* unexpected condition */
|
||||
PRINTF("6P-nbr: nbr %p has an invalid generation number %02x\n",
|
||||
nbr, nbr->gen);
|
||||
LOG_ERR("6P-nbr: nbr %p has an invalid generation number %02x\n",
|
||||
nbr, nbr->gen);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -155,7 +157,7 @@ sixp_nbr_get_next_seqno(sixp_nbr_t *nbr)
|
||||
{
|
||||
assert(nbr != NULL);
|
||||
if(nbr == NULL) {
|
||||
PRINTF("6P-nbr: sixp_nbr_get_next_seqno() fails because of invalid arg\n");
|
||||
LOG_ERR("6P-nbr: sixp_nbr_get_next_seqno() fails because of invalid arg\n");
|
||||
return -1;
|
||||
}
|
||||
return nbr->next_seqno;
|
||||
@ -166,7 +168,7 @@ sixp_nbr_increment_next_seqno(sixp_nbr_t *nbr)
|
||||
{
|
||||
assert(nbr != NULL);
|
||||
if(nbr == NULL) {
|
||||
PRINTF("6P-nbr: sixp_nbr_increment_next_seqno() fails; invalid arg\n");
|
||||
LOG_ERR("6P-nbr: sixp_nbr_increment_next_seqno() fails; invalid arg\n");
|
||||
return -1;
|
||||
}
|
||||
nbr->next_seqno++;
|
||||
|
@ -49,8 +49,10 @@
|
||||
#include "sixp.h"
|
||||
#include "sixp-pkt.h"
|
||||
|
||||
#define DEBUG DEBUG_PRINT
|
||||
#include "net/net-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "6top"
|
||||
#define LOG_LEVEL LOG_LEVEL_6TOP
|
||||
|
||||
static int32_t get_metadata_offset(sixp_pkt_type_t type, sixp_pkt_code_t code);
|
||||
static int32_t get_cell_options_offset(sixp_pkt_type_t type,
|
||||
@ -182,19 +184,19 @@ sixp_pkt_set_metadata(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(body == NULL) {
|
||||
PRINTF("6P-pkt: cannot set metadata; body is null\n");
|
||||
LOG_ERR("6P-pkt: cannot set metadata; body is null\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_metadata_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot set metadata [type=%u, code=%u], invalid type\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot set metadata [type=%u, code=%u], invalid type\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(body_len < (offset + sizeof(metadata))) {
|
||||
PRINTF("6P-pkt: cannot set metadata, body is too short [body_len=%u]\n",
|
||||
body_len);
|
||||
LOG_ERR("6P-pkt: cannot set metadata, body is too short [body_len=%u]\n",
|
||||
body_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -215,19 +217,20 @@ sixp_pkt_get_metadata(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(metadata == NULL || body == NULL) {
|
||||
PRINTF("6P-pkt: cannot get metadata; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot get metadata; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_metadata_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot get metadata [type=%u, code=%u], invalid type\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot get metadata [type=%u, code=%u], invalid type\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(body_len < (offset + sizeof(*metadata))) {
|
||||
PRINTF("6P-pkt: cannot get metadata [type=%u, code=%u], body is too short\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot get metadata [type=%u, code=%u], ",
|
||||
type, code.value);
|
||||
LOG_ERR_("body is too short\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -248,19 +251,20 @@ sixp_pkt_set_cell_options(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(body == NULL) {
|
||||
PRINTF("6P-pkt: cannot set cell_options; body is null\n");
|
||||
LOG_ERR("6P-pkt: cannot set cell_options; body is null\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_cell_options_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot set cell_options [type=%u, code=%u], invalid type\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot set cell_options [type=%u, code=%u], ",
|
||||
type, code.value);
|
||||
LOG_ERR_("invalid type\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(body_len < (offset + sizeof(cell_options))) {
|
||||
PRINTF("6P-pkt: cannot set cell_options, body is too short [body_len=%u]\n",
|
||||
body_len);
|
||||
LOG_ERR("6P-pkt: cannot set cell_options, ");
|
||||
LOG_ERR_("body is too short [body_len=%u]\n", body_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -278,19 +282,20 @@ sixp_pkt_get_cell_options(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(cell_options == NULL || body == NULL) {
|
||||
PRINTF("6P-pkt: cannot get cell_options; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot get cell_options; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_cell_options_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot get cell_options [type=%u, code=%u], invalid type\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot get cell_options [type=%u, code=%u]",
|
||||
type, code.value);
|
||||
LOG_ERR_("invalid type\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(body_len < (offset + sizeof(*cell_options))) {
|
||||
PRINTF("6P-pkt: cannot get cell_options, body is too short [body_len=%u]\n",
|
||||
body_len);
|
||||
LOG_ERR("6P-pkt: cannot get cell_options, ");
|
||||
LOG_ERR_("body is too short [body_len=%u]\n", body_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -308,14 +313,14 @@ sixp_pkt_set_num_cells(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(body == NULL) {
|
||||
PRINTF("6P-pkt: cannot set num_cells; body is null\n");
|
||||
LOG_ERR("6P-pkt: cannot set num_cells; body is null\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_num_cells_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot set num_cells; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have NumCells\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot set num_cells; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have NumCells\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -332,19 +337,19 @@ sixp_pkt_get_num_cells(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(num_cells == NULL || body == NULL) {
|
||||
PRINTF("6P-pkt: cannot get num_cells; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot get num_cells; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_num_cells_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot get num_cells; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have NumCells\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot get num_cells; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have NumCells\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(body_len < (offset + sizeof(*num_cells))) {
|
||||
PRINTF("6P-pkt: cannot get num_cells; body is too short\n");
|
||||
LOG_ERR("6P-pkt: cannot get num_cells; body is too short\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -362,19 +367,19 @@ sixp_pkt_set_reserved(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(body == NULL) {
|
||||
PRINTF("6P-pkt: cannot set reserved; body is null\n");
|
||||
LOG_ERR("6P-pkt: cannot set reserved; body is null\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_reserved_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot set reserved; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have Reserved\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot set reserved; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have Reserved\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(body_len < (offset + sizeof(reserved))) {
|
||||
PRINTF("6P-pkt: cannot set reserved; body is too short\n");
|
||||
LOG_ERR("6P-pkt: cannot set reserved; body is too short\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -392,14 +397,14 @@ sixp_pkt_get_reserved(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(reserved == NULL || body == NULL) {
|
||||
PRINTF("6P-pkt: cannot get reserved; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot get reserved; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_reserved_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot get reserved; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have Reserved\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot get reserved; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have Reserved\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -417,19 +422,19 @@ sixp_pkt_set_offset(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(body == NULL) {
|
||||
PRINTF("6P-pkt: cannot set offset; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot set offset; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_offset_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot set offset; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have Offset\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot set offset; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have Offset\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(body_len < (offset + sizeof(cell_offset))) {
|
||||
PRINTF("6P-pkt: cannot set offset; body is too short\n");
|
||||
LOG_ERR("6P-pkt: cannot set offset; body is too short\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -452,19 +457,19 @@ sixp_pkt_get_offset(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
const uint8_t *p;
|
||||
|
||||
if(cell_offset == NULL || body == NULL) {
|
||||
PRINTF("6P-pkt: cannot get offset; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot get offset; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_offset_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot get offset; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have Offset\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot get offset; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have Offset\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(body_len < (offset + sizeof(*cell_offset))) {
|
||||
PRINTF("6P-pkt: cannot get offset; body is too short\n");
|
||||
LOG_ERR("6P-pkt: cannot get offset; body is too short\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -486,19 +491,19 @@ sixp_pkt_set_max_num_cells(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(body == NULL) {
|
||||
PRINTF("6P-pkt: cannot set max_num_cells; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot set max_num_cells; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_max_num_cells_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot set max_num_cells; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have MaxNumCells\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot set max_num_cells; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have MaxNumCells\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(body_len < (offset + sizeof(max_num_cells))) {
|
||||
PRINTF("6P-pkt: cannot set max_num_cells; body is too short\n");
|
||||
LOG_ERR("6P-pkt: cannot set max_num_cells; body is too short\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -521,19 +526,19 @@ sixp_pkt_get_max_num_cells(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
const uint8_t *p;
|
||||
|
||||
if(max_num_cells == NULL || body == NULL) {
|
||||
PRINTF("6P-pkt: cannot get max_num_cells; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot get max_num_cells; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_max_num_cells_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot get max_num_cells; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have MaxNumCells\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot get max_num_cells; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have MaxNumCells\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(body_len < (offset + sizeof(*max_num_cells))) {
|
||||
PRINTF("6P-pkt: cannot get max_num_cells; body is too short\n");
|
||||
LOG_ERR("6P-pkt: cannot get max_num_cells; body is too short\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -557,24 +562,24 @@ sixp_pkt_set_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(cell_list == NULL || body == NULL) {
|
||||
PRINTF("6P-pkt: cannot set cell_list; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot set cell_list; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_cell_list_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot set cell_list; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have CellList\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot set cell_list; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have CellList\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
offset += cell_offset;
|
||||
|
||||
if(body_len < (offset + cell_list_len)) {
|
||||
PRINTF("6P-pkt: cannot set cell_list; body is too short\n");
|
||||
LOG_ERR("6P-pkt: cannot set cell_list; body is too short\n");
|
||||
return -1;
|
||||
} else if((cell_list_len % sizeof(sixp_pkt_cell_t)) != 0) {
|
||||
PRINTF("6P-pkt: cannot set cell_list; invalid {body, cell_list}_len\n");
|
||||
LOG_ERR("6P-pkt: cannot set cell_list; invalid {body, cell_list}_len\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -592,22 +597,22 @@ sixp_pkt_get_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(cell_list_len == NULL || body == NULL) {
|
||||
PRINTF("6P-pkt: cannot get cell_list\n");
|
||||
LOG_ERR("6P-pkt: cannot get cell_list\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_cell_list_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot get cell_list; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have CellList\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot get cell_list; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have CellList\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(body_len < offset) {
|
||||
PRINTF("6P-pkt: cannot set cell_list; body is too short\n");
|
||||
LOG_ERR("6P-pkt: cannot set cell_list; body is too short\n");
|
||||
return -1;
|
||||
} else if(((body_len - offset) % sizeof(sixp_pkt_cell_t)) != 0) {
|
||||
PRINTF("6P-pkt: cannot set cell_list; invalid {body, cell_list}_len\n");
|
||||
LOG_ERR("6P-pkt: cannot set cell_list; invalid {body, cell_list}_len\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -631,33 +636,33 @@ sixp_pkt_set_rel_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_num_cells_t num_cells;
|
||||
|
||||
if(rel_cell_list == NULL || body == NULL) {
|
||||
PRINTF("6P-pkt: cannot set rel_cell_list; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot set rel_cell_list; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(sixp_pkt_get_num_cells(type, code, &num_cells, body, body_len) < 0) {
|
||||
PRINTF("6P-pkt: cannot set rel_cell_list; no NumCells field\n");
|
||||
LOG_ERR("6P-pkt: cannot set rel_cell_list; no NumCells field\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_rel_cell_list_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot set rel_cell_list; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have RelCellList\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot set rel_cell_list; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have RelCellList\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
offset += cell_offset;
|
||||
|
||||
if(body_len < (offset + rel_cell_list_len)) {
|
||||
PRINTF("6P-pkt: cannot set rel_cell_list; body is too short\n");
|
||||
LOG_ERR("6P-pkt: cannot set rel_cell_list; body is too short\n");
|
||||
return -1;
|
||||
} else if((offset + rel_cell_list_len) >
|
||||
(offset + num_cells * sizeof(sixp_pkt_cell_t))) {
|
||||
PRINTF("6P-pkt: cannot set rel_cell_list; RelCellList is too long\n");
|
||||
LOG_ERR("6P-pkt: cannot set rel_cell_list; RelCellList is too long\n");
|
||||
return -1;
|
||||
} else if((rel_cell_list_len % sizeof(sixp_pkt_cell_t)) != 0) {
|
||||
PRINTF("6P-pkt: cannot set rel_cell_list; invalid body_len\n");
|
||||
LOG_ERR("6P-pkt: cannot set rel_cell_list; invalid body_len\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -676,27 +681,27 @@ sixp_pkt_get_rel_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_num_cells_t num_cells;
|
||||
|
||||
if(rel_cell_list_len == NULL || body == NULL) {
|
||||
PRINTF("6P-pkt: cannot get rel_cell_list; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot get rel_cell_list; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(sixp_pkt_get_num_cells(type, code, &num_cells, body, body_len) < 0) {
|
||||
PRINTF("6P-pkt: cannot get rel_cell_list; no NumCells field\n");
|
||||
LOG_ERR("6P-pkt: cannot get rel_cell_list; no NumCells field\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_rel_cell_list_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot get rel_cell_list; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have RelCellList\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot get rel_cell_list; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have RelCellList\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(body_len < (offset + (num_cells * sizeof(sixp_pkt_cell_t)))) {
|
||||
PRINTF("6P-pkt: cannot set rel_cell_list; body is too short\n");
|
||||
LOG_ERR("6P-pkt: cannot set rel_cell_list; body is too short\n");
|
||||
return -1;
|
||||
} else if(((body_len - offset) % sizeof(sixp_pkt_cell_t)) != 0) {
|
||||
PRINTF("6P-pkt: cannot set rel_cell_list; invalid body_len\n");
|
||||
LOG_ERR("6P-pkt: cannot set rel_cell_list; invalid body_len\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -720,29 +725,29 @@ sixp_pkt_set_cand_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
sixp_pkt_num_cells_t num_cells;
|
||||
|
||||
if(cand_cell_list == NULL || body == NULL) {
|
||||
PRINTF("6P-pkt: cannot set cand_cell_list; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot set cand_cell_list; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(sixp_pkt_get_num_cells(type, code, &num_cells, body, body_len) < 0) {
|
||||
PRINTF("6P-pkt: cannot set cand_cell_list; no NumCells field\n");
|
||||
LOG_ERR("6P-pkt: cannot set cand_cell_list; no NumCells field\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_rel_cell_list_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot set cand_cell_list; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have RelCellList\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot set cand_cell_list; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have RelCellList\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
offset += cell_offset + num_cells * sizeof(sixp_pkt_cell_t);
|
||||
|
||||
if(body_len < (offset + cand_cell_list_len)) {
|
||||
PRINTF("6P-pkt: cannot set cand_cell_list; body is too short\n");
|
||||
LOG_ERR("6P-pkt: cannot set cand_cell_list; body is too short\n");
|
||||
return -1;
|
||||
} else if((cand_cell_list_len % sizeof(sixp_pkt_cell_t)) != 0) {
|
||||
PRINTF("6P-pkt: cannot set cand_cell_list; invalid body_len\n");
|
||||
LOG_ERR("6P-pkt: cannot set cand_cell_list; invalid body_len\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -753,37 +758,37 @@ sixp_pkt_set_cand_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
sixp_pkt_get_cand_cell_list(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
const uint8_t **cand_cell_list,
|
||||
sixp_pkt_offset_t *cand_cell_list_len,
|
||||
const uint8_t *body, uint16_t body_len)
|
||||
const uint8_t **cand_cell_list,
|
||||
sixp_pkt_offset_t *cand_cell_list_len,
|
||||
const uint8_t *body, uint16_t body_len)
|
||||
{
|
||||
int32_t offset;
|
||||
sixp_pkt_num_cells_t num_cells;
|
||||
|
||||
if(cand_cell_list_len == NULL || body == NULL) {
|
||||
PRINTF("6P-pkt: cannot get cand_cell_list; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot get cand_cell_list; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(sixp_pkt_get_num_cells(type, code, &num_cells, body, body_len) < 0) {
|
||||
PRINTF("6P-pkt: cannot get cand_cell_list; no NumCells field\n");
|
||||
LOG_ERR("6P-pkt: cannot get cand_cell_list; no NumCells field\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_rel_cell_list_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot get cand_cell_list; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have RelCellList\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot get cand_cell_list; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have RelCellList\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
offset += num_cells * sizeof(sixp_pkt_cell_t);
|
||||
|
||||
if(body_len < offset) {
|
||||
PRINTF("6P-pkt: cannot set cand_cell_list; body is too short\n");
|
||||
LOG_ERR("6P-pkt: cannot set cand_cell_list; body is too short\n");
|
||||
return -1;
|
||||
} else if(((body_len - offset) % sizeof(sixp_pkt_cell_t)) != 0) {
|
||||
PRINTF("6P-pkt: cannot set cand_cell_list; invalid body_len\n");
|
||||
LOG_ERR("6P-pkt: cannot set cand_cell_list; invalid body_len\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -804,14 +809,14 @@ sixp_pkt_set_total_num_cells(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(body == NULL) {
|
||||
PRINTF("6P-pkt: cannot set num_cells; body is null\n");
|
||||
LOG_ERR("6P-pkt: cannot set num_cells; body is null\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_total_num_cells_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot set total_num_cells; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have TotalNumCells\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot set total_num_cells; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have TotalNumCells\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -832,19 +837,19 @@ sixp_pkt_get_total_num_cells(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
int32_t offset;
|
||||
|
||||
if(total_num_cells == NULL || body == NULL) {
|
||||
PRINTF("6P-pkt: cannot get num_cells; invalid argument\n");
|
||||
LOG_ERR("6P-pkt: cannot get num_cells; invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((offset = get_total_num_cells_offset(type, code)) < 0) {
|
||||
PRINTF("6P-pkt: cannot get num_cells; ");
|
||||
PRINTF("packet [type=%u, code=%u] won't have TotalNumCells\n",
|
||||
type, code.value);
|
||||
LOG_ERR("6P-pkt: cannot get num_cells; ");
|
||||
LOG_ERR_("packet [type=%u, code=%u] won't have TotalNumCells\n",
|
||||
type, code.value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(body_len < (offset + sizeof(sixp_pkt_total_num_cells_t))) {
|
||||
PRINTF("6P-pkt: cannot get num_cells; body is too short\n");
|
||||
LOG_ERR("6P-pkt: cannot get num_cells; body is too short\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -861,19 +866,19 @@ sixp_pkt_parse(const uint8_t *buf, uint16_t len,
|
||||
{
|
||||
assert(buf != NULL && pkt != NULL);
|
||||
if(buf == NULL || pkt == NULL) {
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid argument\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because of invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* read the first 4 octets */
|
||||
if(len < 4) {
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because it's a too short packet\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because it's a too short packet\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((buf[0] & 0x0f) != SIXP_PKT_VERSION) {
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid version [%u]\n",
|
||||
buf[0] & 0x0f);
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because of invalid version [%u]\n",
|
||||
buf[0] & 0x0f);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -887,8 +892,8 @@ sixp_pkt_parse(const uint8_t *buf, uint16_t len,
|
||||
buf += 4;
|
||||
len -= 4;
|
||||
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() is processing [type:%u, code:%u, len:%u]\n",
|
||||
pkt->type, pkt->code.value, len);
|
||||
LOG_INFO("6P-pkt: sixp_pkt_parse() is processing [type:%u, code:%u, len:%u]\n",
|
||||
pkt->type, pkt->code.value, len);
|
||||
|
||||
/* the rest is message body called "Other Fields" */
|
||||
if(pkt->type == SIXP_PKT_TYPE_REQUEST) {
|
||||
@ -900,7 +905,7 @@ sixp_pkt_parse(const uint8_t *buf, uint16_t len,
|
||||
sizeof(sixp_pkt_cell_options_t) +
|
||||
sizeof(sixp_pkt_num_cells_t)) ||
|
||||
(len % sizeof(uint32_t)) != 0) {
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
@ -909,14 +914,14 @@ sixp_pkt_parse(const uint8_t *buf, uint16_t len,
|
||||
sizeof(sixp_pkt_cell_options_t) +
|
||||
sizeof(sixp_pkt_num_cells_t)) ||
|
||||
(len % sizeof(uint32_t)) != 0) {
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case SIXP_PKT_CMD_COUNT:
|
||||
if(len != (sizeof(sixp_pkt_metadata_t) +
|
||||
sizeof(sixp_pkt_cell_options_t))) {
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
@ -926,18 +931,18 @@ sixp_pkt_parse(const uint8_t *buf, uint16_t len,
|
||||
sizeof(sixp_pkt_reserved_t) +
|
||||
sizeof(sixp_pkt_offset_t) +
|
||||
sizeof(sixp_pkt_max_num_cells_t))) {
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case SIXP_PKT_CMD_CLEAR:
|
||||
if(len != sizeof(sixp_pkt_metadata_t)) {
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because of unsupported cmd\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because of unsupported cmd\n");
|
||||
return -1;
|
||||
}
|
||||
} else if(pkt->type == SIXP_PKT_TYPE_RESPONSE ||
|
||||
@ -953,13 +958,13 @@ sixp_pkt_parse(const uint8_t *buf, uint16_t len,
|
||||
if(len != 0 &&
|
||||
len != sizeof(sixp_pkt_total_num_cells_t) &&
|
||||
(len % sizeof(uint32_t)) != 0) {
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case SIXP_PKT_RC_EOL:
|
||||
if((len % sizeof(uint32_t)) != 0) {
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
@ -972,16 +977,16 @@ sixp_pkt_parse(const uint8_t *buf, uint16_t len,
|
||||
case SIXP_PKT_RC_NORES:
|
||||
case SIXP_PKT_RC_CELLLIST:
|
||||
if(len != 0) {
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because of invalid length\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because of unsupported code\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because of unsupported code\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
PRINTF("6P-pkt: sixp_pkt_parse() fails because of unsupported type\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_parse() fails because of unsupported type\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1000,7 +1005,7 @@ sixp_pkt_create(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
|
||||
assert((body == NULL && body_len == 0) || (body != NULL && body_len > 0));
|
||||
if((body == NULL && body_len > 0) || (body != NULL && body_len == 0)) {
|
||||
PRINTF("6P-pkt: sixp_pkt_create() fails because of invalid argument\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_create() fails because of invalid argument\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1011,12 +1016,12 @@ sixp_pkt_create(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
* (body_len octets).
|
||||
*/
|
||||
if(PACKETBUF_SIZE < (packetbuf_totlen() + body_len)) {
|
||||
PRINTF("6P-pkt: sixp_pkt_create() fails because body is too long\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_create() fails because body is too long\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(packetbuf_hdralloc(4) != 1) {
|
||||
PRINTF("6P-pkt: sixp_pkt_create fails to allocate header space\n");
|
||||
LOG_ERR("6P-pkt: sixp_pkt_create fails to allocate header space\n");
|
||||
return -1;
|
||||
}
|
||||
hdr = packetbuf_hdrptr();
|
||||
|
@ -45,8 +45,10 @@
|
||||
#include "sixtop-conf.h"
|
||||
#include "sixp-trans.h"
|
||||
|
||||
#define DEBUG DEBUG_PRINT
|
||||
#include "net/net-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "6top"
|
||||
#define LOG_LEVEL LOG_LEVEL_6TOP
|
||||
|
||||
/**
|
||||
* \brief 6P Transaction Data Structure (for internal use)
|
||||
@ -111,9 +113,9 @@ process_trans(void *ptr)
|
||||
/* state-specific operation */
|
||||
if(trans->state == SIXP_TRANS_STATE_TERMINATING) {
|
||||
/* handle the terminating state first */
|
||||
PRINTF("6P-trans: trans [peer_addr:");
|
||||
PRINTLLADDR((const uip_lladdr_t *)&trans->peer_addr);
|
||||
PRINTF(", seqno:%u] is going to be freed\n", trans->seqno);
|
||||
LOG_INFO("6P-trans: trans [peer_addr:");
|
||||
LOG_INFO_LLADDR((const linkaddr_t *)&trans->peer_addr);
|
||||
LOG_INFO_(", seqno:%u] is going to be freed\n", trans->seqno);
|
||||
free_trans(trans);
|
||||
return;
|
||||
}
|
||||
@ -198,7 +200,7 @@ sixp_trans_transit_state(sixp_trans_t *trans, sixp_trans_state_t new_state)
|
||||
{
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
PRINTF("6top: invalid argument, trans is NULL\n");
|
||||
LOG_ERR("6top: invalid argument, trans is NULL\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -218,16 +220,16 @@ sixp_trans_transit_state(sixp_trans_t *trans, sixp_trans_state_t new_state)
|
||||
(new_state == SIXP_TRANS_STATE_CONFIRMATION_SENT &&
|
||||
trans->state == SIXP_TRANS_STATE_RESPONSE_RECEIVED &&
|
||||
trans->mode == SIXP_TRANS_MODE_3_STEP)) {
|
||||
PRINTF("6P-trans: trans %p state changes from %u to %u\n",
|
||||
trans, trans->state, new_state);
|
||||
LOG_INFO("6P-trans: trans %p state changes from %u to %u\n",
|
||||
trans, trans->state, new_state);
|
||||
trans->state = new_state;
|
||||
schedule_trans_process(trans);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* invalid transition */
|
||||
PRINTF("6P-trans: invalid transaction, from %u to %u, detected on trans %p\n",
|
||||
trans->state, new_state, trans);
|
||||
LOG_ERR("6P-trans: invalid transaction, from %u to %u, detected on trans %p\n",
|
||||
trans->state, new_state, trans);
|
||||
return -1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -256,7 +258,7 @@ sixp_trans_get_seqno(sixp_trans_t *trans)
|
||||
{
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
PRINTF("6P-trans: sixp_trans_get_seqno() fails because trans is NULL\n");
|
||||
LOG_ERR("6P-trans: sixp_trans_get_seqno() fails because trans is NULL\n");
|
||||
return -1;
|
||||
}
|
||||
return trans->seqno;
|
||||
@ -267,7 +269,7 @@ sixp_trans_get_mode(sixp_trans_t *trans)
|
||||
{
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
PRINTF("6P-trans: sixp_trans_get_mode() fails because trans is NULL\n");
|
||||
LOG_ERR("6P-trans: sixp_trans_get_mode() fails because trans is NULL\n");
|
||||
return SIXP_TRANS_STATE_UNAVAILABLE;
|
||||
}
|
||||
return trans->mode;
|
||||
@ -306,25 +308,25 @@ sixp_trans_alloc(const sixp_pkt_t *pkt, const linkaddr_t *peer_addr)
|
||||
|
||||
assert(pkt != NULL && peer_addr != NULL);
|
||||
if(pkt == NULL || peer_addr == NULL) {
|
||||
PRINTF("6P-trans: sixp_trans_alloc() fails because of invalid argument\n");
|
||||
LOG_ERR("6P-trans: sixp_trans_alloc() fails because of invalid argument\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if((sf = sixtop_find_sf(pkt->sfid)) == NULL) {
|
||||
PRINTF("6P-trans: sixp_trans_alloc() fails; no suitable SF [sfid:%u]\n",
|
||||
pkt->sfid);
|
||||
LOG_ERR("6P-trans: sixp_trans_alloc() fails; no suitable SF [sfid:%u]\n",
|
||||
pkt->sfid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(sixp_trans_find(peer_addr) != NULL) {
|
||||
PRINTF("6P-trans: sixp_trans_alloc() fails because another trans with ");
|
||||
PRINTLLADDR((const uip_lladdr_t *)peer_addr);
|
||||
PRINTF("is in process\n");
|
||||
LOG_ERR("6P-trans: sixp_trans_alloc() fails because another trans with ");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)peer_addr);
|
||||
LOG_ERR_("is in process\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if((trans = memb_alloc(&trans_memb)) == NULL) {
|
||||
PRINTF("6P-trans: sixp_trans_alloc() fails because of lack of memory\n");
|
||||
LOG_ERR("6P-trans: sixp_trans_alloc() fails because of lack of memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,10 @@
|
||||
#include "sixp-pkt.h"
|
||||
#include "sixp-trans.h"
|
||||
|
||||
#define DEBUG DEBUG_PRINT
|
||||
#include "net/net-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "6top"
|
||||
#define LOG_LEVEL LOG_LEVEL_6TOP
|
||||
|
||||
static void mac_callback(void *ptr, int status, int transmissions);
|
||||
static int send_back_error(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
@ -62,7 +64,7 @@ mac_callback(void *ptr, int status, int transmissions)
|
||||
|
||||
assert(trans != NULL);
|
||||
if(trans == NULL) {
|
||||
PRINTF("6P: mac_callback() fails because trans is NULL\n");
|
||||
LOG_ERR("6P: mac_callback() fails because trans is NULL\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -79,8 +81,8 @@ mac_callback(void *ptr, int status, int transmissions)
|
||||
new_state = SIXP_TRANS_STATE_CONFIRMATION_SENT;
|
||||
break;
|
||||
default:
|
||||
PRINTF("6P: mac_callback() fails because of an unexpected state (%u)\n",
|
||||
current_state);
|
||||
LOG_ERR("6P: mac_callback() fails because of an unexpected state (%u)\n",
|
||||
current_state);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -101,8 +103,8 @@ mac_callback(void *ptr, int status, int transmissions)
|
||||
|
||||
if(new_state != current_state &&
|
||||
sixp_trans_transit_state(trans, new_state) != 0) {
|
||||
PRINTF("6P: mac_callback() fails because of state transition failure\n");
|
||||
PRINTF("6P: something wrong; we're terminating the trans %p\n", trans);
|
||||
LOG_ERR("6P: mac_callback() fails because of state transition failure\n");
|
||||
LOG_ERR("6P: something wrong; we're terminating the trans %p\n", trans);
|
||||
(void)sixp_trans_transit_state(trans, SIXP_TRANS_STATE_TERMINATING);
|
||||
return;
|
||||
}
|
||||
@ -121,8 +123,8 @@ send_back_error(sixp_pkt_type_t type, sixp_pkt_code_t code,
|
||||
{
|
||||
/* create a 6P packet within packetbuf */
|
||||
if(sixp_pkt_create(type, code, sfid, seqno, 0, NULL, 0, NULL) < 0) {
|
||||
PRINTF("6P: failed to create a 6P packet to return an error [rc:%u]\n",
|
||||
code.value);
|
||||
LOG_ERR("6P: failed to create a 6P packet to return an error [rc:%u]\n",
|
||||
code.value);
|
||||
return -1;
|
||||
}
|
||||
/* we don't care about how the transmission goes; no need to set callback */
|
||||
@ -148,21 +150,21 @@ sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr)
|
||||
}
|
||||
|
||||
if(sixp_pkt_parse(buf, len, &pkt) < 0) {
|
||||
PRINTF("6P: sixp_input() fails because off a malformed 6P packet\n");
|
||||
LOG_ERR("6P: sixp_input() fails because off a malformed 6P packet\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(pkt.type != SIXP_PKT_TYPE_REQUEST &&
|
||||
pkt.type != SIXP_PKT_TYPE_RESPONSE &&
|
||||
pkt.type != SIXP_PKT_TYPE_CONFIRMATION) {
|
||||
PRINTF("6P: sixp_input() fails because of unsupported type [type:%u]\n",
|
||||
pkt.type);
|
||||
LOG_ERR("6P: sixp_input() fails because of unsupported type [type:%u]\n",
|
||||
pkt.type);
|
||||
return;
|
||||
}
|
||||
|
||||
if((sf = sixtop_find_sf(pkt.sfid)) == NULL) {
|
||||
PRINTF("6P: sixp_input() fails because SF [sfid:%u] is unavailable\n",
|
||||
pkt.sfid);
|
||||
LOG_ERR("6P: sixp_input() fails because SF [sfid:%u] is unavailable\n",
|
||||
pkt.sfid);
|
||||
/*
|
||||
* XXX: what if the incoming packet is a response? confirmation should be
|
||||
* sent back?
|
||||
@ -170,7 +172,7 @@ sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr)
|
||||
if(send_back_error(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_SFID,
|
||||
pkt.sfid, pkt.seqno, src_addr) < 0) {
|
||||
PRINTF("6P: sixp_input() fails to return an error response\n");
|
||||
LOG_ERR("6P: sixp_input() fails to return an error response\n");
|
||||
};
|
||||
return;
|
||||
}
|
||||
@ -184,16 +186,16 @@ sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr)
|
||||
if(pkt.gen == 0) {
|
||||
invalid_schedule_generation = 0; /* valid combination */
|
||||
} else {
|
||||
PRINTF("6P: GEN should be 0 because of no corresponding nbr\n");
|
||||
LOG_ERR("6P: GEN should be 0 because of no corresponding nbr\n");
|
||||
invalid_schedule_generation = 1;
|
||||
}
|
||||
} else {
|
||||
if((gen = sixp_nbr_get_gen(nbr)) < 0) {
|
||||
PRINTF("6P: unexpected error; cannot get our GEN\n");
|
||||
LOG_ERR("6P: unexpected error; cannot get our GEN\n");
|
||||
return;
|
||||
}
|
||||
PRINTF("6P: received GEN %u, our GEN: %u\n",
|
||||
pkt.gen, sixp_nbr_get_gen(nbr));
|
||||
LOG_ERR("6P: received GEN %u, our GEN: %u\n",
|
||||
pkt.gen, sixp_nbr_get_gen(nbr));
|
||||
if(pkt.gen == gen) {
|
||||
invalid_schedule_generation = 0; /* valid combination */
|
||||
} else {
|
||||
@ -201,7 +203,7 @@ sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr)
|
||||
}
|
||||
}
|
||||
if(invalid_schedule_generation) {
|
||||
PRINTF("6P: sixp_input() fails because of schedule generation mismatch\n");
|
||||
LOG_ERR("6P: sixp_input() fails because of schedule generation mismatch\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -211,21 +213,21 @@ sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr)
|
||||
if(pkt.type == SIXP_PKT_TYPE_REQUEST) {
|
||||
if(trans != NULL) {
|
||||
/* Error: not supposed to have another transaction with the peer. */
|
||||
PRINTF("6P: sixp_input() fails because another request [peer_addr:");
|
||||
PRINTLLADDR((const uip_lladdr_t *)src_addr);
|
||||
PRINTF(" seqno:%u] is in process\n", sixp_trans_get_seqno(trans));
|
||||
LOG_ERR("6P: sixp_input() fails because another request [peer_addr:");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)src_addr);
|
||||
LOG_ERR_(" seqno:%u] is in process\n", sixp_trans_get_seqno(trans));
|
||||
if(send_back_error(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_BUSY,
|
||||
pkt.sfid, pkt.seqno, src_addr) < 0) {
|
||||
PRINTF("6P: sixp_input() fails to return an error response");
|
||||
LOG_ERR("6P: sixp_input() fails to return an error response");
|
||||
}
|
||||
return;
|
||||
} else if((trans = sixp_trans_alloc(&pkt, src_addr)) == NULL) {
|
||||
PRINTF("6P: sixp_input() fails because of lack of memory\n");
|
||||
LOG_ERR("6P: sixp_input() fails because of lack of memory\n");
|
||||
if(send_back_error(SIXP_PKT_TYPE_RESPONSE,
|
||||
(sixp_pkt_code_t)(uint8_t)SIXP_PKT_RC_NORES,
|
||||
pkt.sfid, pkt.seqno, src_addr) < 0) {
|
||||
PRINTF("6P: sixp_input() fails to return an error response\n");
|
||||
LOG_ERR("6P: sixp_input() fails to return an error response\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -233,14 +235,14 @@ sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr)
|
||||
pkt.type == SIXP_PKT_TYPE_CONFIRMATION) {
|
||||
if(trans == NULL) {
|
||||
/* Error: should have a transaction for incoming packet */
|
||||
PRINTF("6P: sixp_input() fails because of no trans [peer_addr:");
|
||||
PRINTLLADDR((const uip_lladdr_t *)src_addr);
|
||||
PRINTF("]\n");
|
||||
LOG_ERR("6P: sixp_input() fails because of no trans [peer_addr:");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)src_addr);
|
||||
LOG_ERR_("]\n");
|
||||
return;
|
||||
} else if((seqno = sixp_trans_get_seqno(trans)) < 0 ||
|
||||
seqno != pkt.seqno) {
|
||||
PRINTF("6P: sixp_input() fails because of invalid seqno [seqno:%u, %u]\n",
|
||||
seqno, pkt.seqno);
|
||||
LOG_ERR("6P: sixp_input() fails because of invalid seqno [seqno:%u, %u]\n",
|
||||
seqno, pkt.seqno);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -261,13 +263,13 @@ sixp_input(const uint8_t *buf, uint16_t len, const linkaddr_t *src_addr)
|
||||
SIXP_TRANS_STATE_CONFIRMATION_RECEIVED);
|
||||
break;
|
||||
default:
|
||||
PRINTF("6P: sixp_input() fails because of unsupported type [type:%u]\n",
|
||||
pkt.type);
|
||||
LOG_ERR("6P: sixp_input() fails because of unsupported type [type:%u]\n",
|
||||
pkt.type);
|
||||
return;
|
||||
}
|
||||
if(ret < 0) {
|
||||
PRINTF("6P: sixp_input() fails because of state transition failure\n");
|
||||
PRINTF("6P: something wrong; we're terminating the trans %p\n", trans);
|
||||
LOG_ERR("6P: sixp_input() fails because of state transition failure\n");
|
||||
LOG_ERR("6P: something wrong; we're terminating the trans %p\n", trans);
|
||||
(void)sixp_trans_transit_state(trans, SIXP_TRANS_STATE_TERMINATING);
|
||||
return;
|
||||
}
|
||||
@ -297,9 +299,9 @@ sixp_output(sixp_pkt_type_t type, sixp_pkt_code_t code, uint8_t sfid,
|
||||
trans = sixp_trans_find(dest_addr);
|
||||
if(type == SIXP_PKT_TYPE_REQUEST) {
|
||||
if(trans != NULL) {
|
||||
PRINTF("6P: sixp_output() fails because another trans for [peer_addr:");
|
||||
PRINTLLADDR((const uip_lladdr_t *)dest_addr);
|
||||
PRINTF("] is in process\n");
|
||||
LOG_ERR("6P: sixp_output() fails because another trans for [peer_addr:");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)dest_addr);
|
||||
LOG_ERR_("] is in process\n");
|
||||
return -1;
|
||||
} else {
|
||||
/* ready to send a request */
|
||||
@ -307,33 +309,33 @@ sixp_output(sixp_pkt_type_t type, sixp_pkt_code_t code, uint8_t sfid,
|
||||
}
|
||||
} else if(type == SIXP_PKT_TYPE_RESPONSE) {
|
||||
if(trans == NULL) {
|
||||
PRINTF("6P: sixp_output() fails because of no transaction [peer_addr:");
|
||||
PRINTLLADDR((const uip_lladdr_t *)dest_addr);
|
||||
PRINTF("]\n");
|
||||
LOG_ERR("6P: sixp_output() fails because of no transaction [peer_addr:");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)dest_addr);
|
||||
LOG_ERR_("]\n");
|
||||
return -1;
|
||||
} else if(sixp_trans_get_state(trans) !=
|
||||
SIXP_TRANS_STATE_REQUEST_RECEIVED) {
|
||||
PRINTF("6P: sixp_output() fails because of invalid transaction state\n");
|
||||
LOG_ERR("6P: sixp_output() fails because of invalid transaction state\n");
|
||||
return -1;
|
||||
} else {
|
||||
/* ready to send a response */
|
||||
}
|
||||
} else if(type == SIXP_PKT_TYPE_CONFIRMATION) {
|
||||
if(trans == NULL) {
|
||||
PRINTF("6P: sixp_output() fails because of no transaction [peer_addr:\n");
|
||||
PRINTLLADDR((const uip_lladdr_t *)dest_addr);
|
||||
PRINTF("\n");
|
||||
LOG_ERR("6P: sixp_output() fails because of no transaction [peer_addr:");
|
||||
LOG_ERR_LLADDR((const linkaddr_t *)dest_addr);
|
||||
LOG_ERR_("\n");
|
||||
return -1;
|
||||
} else if(sixp_trans_get_state(trans) !=
|
||||
SIXP_TRANS_STATE_RESPONSE_RECEIVED) {
|
||||
PRINTF("6P: sixp_output() fails because of invalid transaction state\n");
|
||||
LOG_ERR("6P: sixp_output() fails because of invalid transaction state\n");
|
||||
return -1;
|
||||
} else {
|
||||
/* ready to send a confirmation */
|
||||
}
|
||||
} else {
|
||||
PRINTF("6P: sixp_output() fails because of unsupported type [type:%u]\n",
|
||||
type);
|
||||
LOG_ERR("6P: sixp_output() fails because of unsupported type [type:%u]\n",
|
||||
type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -348,7 +350,7 @@ sixp_output(sixp_pkt_type_t type, sixp_pkt_code_t code, uint8_t sfid,
|
||||
((cmd = sixp_trans_get_cmd(trans)) == SIXP_PKT_CMD_ADD ||
|
||||
cmd == SIXP_PKT_CMD_DELETE) &&
|
||||
(nbr = sixp_nbr_alloc(dest_addr)) == NULL) {
|
||||
PRINTF("6P: sixp_output() fails because of no memory for another nbr\n");
|
||||
LOG_ERR("6P: sixp_output() fails because of no memory for another nbr\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -356,21 +358,21 @@ sixp_output(sixp_pkt_type_t type, sixp_pkt_code_t code, uint8_t sfid,
|
||||
if(type == SIXP_PKT_TYPE_REQUEST) {
|
||||
if(nbr == NULL &&
|
||||
(nbr = sixp_nbr_alloc(dest_addr)) == NULL) {
|
||||
PRINTF("6P: sixp_output() fails because it fails to allocate a nbr\n");
|
||||
LOG_ERR("6P: sixp_output() fails because it fails to allocate a nbr\n");
|
||||
return -1;
|
||||
}
|
||||
if((seqno = sixp_nbr_get_next_seqno(nbr)) < 0){
|
||||
PRINTF("6P: sixp_output() fails to get the next sequence number\n");
|
||||
LOG_ERR("6P: sixp_output() fails to get the next sequence number\n");
|
||||
return -1;
|
||||
}
|
||||
if(sixp_nbr_increment_next_seqno(nbr) < 0) {
|
||||
PRINTF("6P: sixp_output() fails to increment the next sequence number\n");
|
||||
LOG_ERR("6P: sixp_output() fails to increment the next sequence number\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
assert(trans != NULL);
|
||||
if((seqno = sixp_trans_get_seqno(trans)) < 0) {
|
||||
PRINTF("6P: sixp_output() fails because it fails to get seqno\n");
|
||||
LOG_ERR("6P: sixp_output() fails because it fails to get seqno\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -379,7 +381,7 @@ sixp_output(sixp_pkt_type_t type, sixp_pkt_code_t code, uint8_t sfid,
|
||||
if(nbr == NULL) {
|
||||
gen = 0;
|
||||
} else if((gen = sixp_nbr_get_gen(nbr)) < 0) {
|
||||
PRINTF("6P: sixp_output() fails to get GEN\n");
|
||||
LOG_ERR("6P: sixp_output() fails to get GEN\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -388,7 +390,7 @@ sixp_output(sixp_pkt_type_t type, sixp_pkt_code_t code, uint8_t sfid,
|
||||
(uint8_t)seqno, (uint8_t)gen,
|
||||
body, body_len,
|
||||
type == SIXP_PKT_TYPE_REQUEST ? &pkt : NULL) < 0) {
|
||||
PRINTF("6P: sixp_output() fails to create a 6P packet\n");
|
||||
LOG_ERR("6P: sixp_output() fails to create a 6P packet\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -396,7 +398,7 @@ sixp_output(sixp_pkt_type_t type, sixp_pkt_code_t code, uint8_t sfid,
|
||||
if(type == SIXP_PKT_TYPE_REQUEST) {
|
||||
assert(trans == NULL);
|
||||
if((trans = sixp_trans_alloc(&pkt, dest_addr)) == NULL) {
|
||||
PRINTF("6P: sixp_output() is aborted because of no memory\n");
|
||||
LOG_ERR("6P: sixp_output() is aborted because of no memory\n");
|
||||
return -1;
|
||||
} else {
|
||||
/* ready for proceed */
|
||||
|
@ -50,8 +50,10 @@
|
||||
#include "sixtop-conf.h"
|
||||
#include "sixp.h"
|
||||
|
||||
#define DEBUG DEBUG_PRINT
|
||||
#include "net/net-debug.h"
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "6top"
|
||||
#define LOG_LEVEL LOG_LEVEL_6TOP
|
||||
|
||||
const sixtop_sf_t *scheduling_functions[SIXTOP_MAX_SCHEDULING_FUNCTIONS];
|
||||
|
||||
@ -75,10 +77,10 @@ sixtop_add_sf(const sixtop_sf_t *sf)
|
||||
|
||||
assert(sf != NULL);
|
||||
|
||||
PRINTF("6top: sixtop_add_sf() is adding a SF [SFID:%u]\n", sf->sfid);
|
||||
LOG_INFO("6top: sixtop_add_sf() is adding a SF [SFID:%u]\n", sf->sfid);
|
||||
|
||||
if(sixtop_find_sf(sf->sfid) != NULL) {
|
||||
PRINTF("6top: sixtop_add_sf() fails because of duplicate SF\n");
|
||||
LOG_ERR("6top: sixtop_add_sf() fails because of duplicate SF\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -93,14 +95,14 @@ sixtop_add_sf(const sixtop_sf_t *sf)
|
||||
}
|
||||
|
||||
if(i == SIXTOP_MAX_SCHEDULING_FUNCTIONS) {
|
||||
PRINTF("6top: sixtop_add_sf() fails because of no memory\n");
|
||||
LOG_ERR("6top: sixtop_add_sf() fails because of no memory\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(sf->init != NULL) {
|
||||
sf->init();
|
||||
}
|
||||
PRINTF("6top: SF [SFID:%u] has been added and initialized\n", sf->sfid);
|
||||
LOG_INFO("6top: SF [SFID:%u] has been added and initialized\n", sf->sfid);
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -128,7 +130,7 @@ sixtop_output(const linkaddr_t *dest_addr, mac_callback_t callback, void *arg)
|
||||
|
||||
assert(dest_addr != NULL);
|
||||
if(dest_addr == NULL) {
|
||||
PRINTF("6top: sixtop_output() fails because dest_addr is NULL\n");
|
||||
LOG_ERR("6top: sixtop_output() fails because dest_addr is NULL\n");
|
||||
if(callback != NULL) {
|
||||
callback(arg, MAC_TX_ERR_FATAL, 0);
|
||||
}
|
||||
@ -137,7 +139,7 @@ sixtop_output(const linkaddr_t *dest_addr, mac_callback_t callback, void *arg)
|
||||
|
||||
/* prepend 6top Sub-IE ID */
|
||||
if(packetbuf_hdralloc(1) != 1) {
|
||||
PRINTF("6top: sixtop_output() fails because of no room for Sub-IE ID\n");
|
||||
LOG_ERR("6top: sixtop_output() fails because of no room for Sub-IE ID\n");
|
||||
return;
|
||||
}
|
||||
p = packetbuf_hdrptr();
|
||||
@ -153,7 +155,7 @@ sixtop_output(const linkaddr_t *dest_addr, mac_callback_t callback, void *arg)
|
||||
(len = frame80215e_create_ie_ietf(packetbuf_hdrptr(),
|
||||
2,
|
||||
&ies)) < 0) {
|
||||
PRINTF("6top: sixtop_output() fails because of Payload IE Header\n");
|
||||
LOG_ERR("6top: sixtop_output() fails because of Payload IE Header\n");
|
||||
if(callback != NULL) {
|
||||
callback(arg, MAC_TX_ERR_FATAL, 0);
|
||||
}
|
||||
@ -164,10 +166,10 @@ sixtop_output(const linkaddr_t *dest_addr, mac_callback_t callback, void *arg)
|
||||
/* append Payload Termination IE to the data field; 2 octets */
|
||||
memset(&ies, 0, sizeof(ies));
|
||||
if((len = frame80215e_create_ie_payload_list_termination(
|
||||
(uint8_t *)packetbuf_dataptr() + packetbuf_datalen(),
|
||||
PACKETBUF_SIZE - packetbuf_totlen(),
|
||||
&ies)) < 0) {
|
||||
PRINTF("6top: sixtop_output() fails because of Payload Termination IE\n");
|
||||
(uint8_t *)packetbuf_dataptr() + packetbuf_datalen(),
|
||||
PACKETBUF_SIZE - packetbuf_totlen(),
|
||||
&ies)) < 0) {
|
||||
LOG_ERR("6top: sixtop_output() fails because of Payload Termination IE\n");
|
||||
callback(arg, MAC_TX_ERR_FATAL, 0);
|
||||
return;
|
||||
}
|
||||
@ -180,7 +182,7 @@ sixtop_output(const linkaddr_t *dest_addr, mac_callback_t callback, void *arg)
|
||||
frame80215e_create_ie_header_list_termination_1(packetbuf_hdrptr(),
|
||||
2,
|
||||
&ies) < 0) {
|
||||
PRINTF("6top: sixtop_output() fails because of Header Termination 1 IE\n");
|
||||
LOG_ERR("6top: sixtop_output() fails because of Header Termination 1 IE\n");
|
||||
callback(arg, MAC_TX_ERR_FATAL, 0);
|
||||
return;
|
||||
}
|
||||
@ -223,7 +225,7 @@ sixtop_input(void)
|
||||
|
||||
if(frame802154_parse(hdr_ptr, hdr_len, &frame) == 0) {
|
||||
/* parse error; should not occur, anyway */
|
||||
PRINTF("6top: frame802154_parse error\n");
|
||||
LOG_ERR("6top: frame802154_parse error\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,10 @@
|
||||
#define LOG_CONF_LEVEL_FRAMER LOG_LEVEL_NONE
|
||||
#endif /* LOG_CONF_LEVEL_FRAMER */
|
||||
|
||||
#ifndef LOG_CONF_LEVEL_6TOP
|
||||
#define LOG_CONF_LEVEL_6TOP LOG_LEVEL_NONE
|
||||
#endif /* LOG_CONF_LEVEL_6TOP */
|
||||
|
||||
#endif /* __LOG_CONF_H__ */
|
||||
|
||||
/** @} */
|
||||
|
@ -60,6 +60,7 @@ int curr_log_level_ipv6 = LOG_CONF_LEVEL_IPV6;
|
||||
int curr_log_level_6lowpan = LOG_CONF_LEVEL_6LOWPAN;
|
||||
int curr_log_level_mac = LOG_CONF_LEVEL_MAC;
|
||||
int curr_log_level_framer = LOG_CONF_LEVEL_FRAMER;
|
||||
int curr_log_level_6top = LOG_CONF_LEVEL_6TOP;
|
||||
|
||||
struct log_module all_modules[] = {
|
||||
{"rpl", &curr_log_level_rpl, LOG_CONF_LEVEL_RPL},
|
||||
@ -68,6 +69,7 @@ struct log_module all_modules[] = {
|
||||
{"6lowpan", &curr_log_level_6lowpan, LOG_CONF_LEVEL_6LOWPAN},
|
||||
{"mac", &curr_log_level_mac, LOG_CONF_LEVEL_MAC},
|
||||
{"framer", &curr_log_level_framer, LOG_CONF_LEVEL_FRAMER},
|
||||
{"6top", &curr_log_level_6top, LOG_CONF_LEVEL_6TOP},
|
||||
{NULL, NULL, 0},
|
||||
};
|
||||
|
||||
|
@ -79,6 +79,7 @@ extern int curr_log_level_ipv6;
|
||||
extern int curr_log_level_6lowpan;
|
||||
extern int curr_log_level_mac;
|
||||
extern int curr_log_level_framer;
|
||||
extern int curr_log_level_6top;
|
||||
|
||||
extern struct log_module all_modules[];
|
||||
|
||||
@ -88,6 +89,7 @@ extern struct log_module all_modules[];
|
||||
#define LOG_LEVEL_6LOWPAN MIN((LOG_CONF_LEVEL_6LOWPAN), curr_log_level_6lowpan)
|
||||
#define LOG_LEVEL_MAC MIN((LOG_CONF_LEVEL_MAC), curr_log_level_mac)
|
||||
#define LOG_LEVEL_FRAMER MIN((LOG_CONF_LEVEL_FRAMER), curr_log_level_framer)
|
||||
#define LOG_LEVEL_6TOP MIN((LOG_CONF_LEVEL_6TOP), curr_log_level_6top)
|
||||
|
||||
/* Main log function */
|
||||
|
||||
|
@ -57,6 +57,8 @@
|
||||
#undef TSCH_LOG_CONF_PER_SLOT
|
||||
#define TSCH_LOG_CONF_PER_SLOT 1
|
||||
|
||||
#define LOG_CONF_LEVEL_6TOP LOG_LEVEL_DBG
|
||||
|
||||
#undef TSCH_CONF_AUTOSTART
|
||||
#define TSCH_CONF_AUTOSTART 0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user