RPL native border router: use logging module
This commit is contained in:
parent
aa8d4d0320
commit
3bd6c67e64
@ -46,8 +46,11 @@
|
||||
#include "shell.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ipv6/uip-debug.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "BR"
|
||||
#define LOG_LEVEL LOG_LEVEL_NONE
|
||||
|
||||
uint8_t command_context;
|
||||
|
||||
@ -115,7 +118,7 @@ border_router_cmd_handler(const uint8_t *data, int len)
|
||||
{
|
||||
/* handle global repair, etc here */
|
||||
if(data[0] == '!') {
|
||||
PRINTF("Got configuration message of type %c\n", data[1]);
|
||||
LOG_DBG("Got configuration message of type %c\n", data[1]);
|
||||
if(command_context == CMD_CONTEXT_STDIO) {
|
||||
switch(data[1]) {
|
||||
case 'G':
|
||||
@ -151,7 +154,7 @@ border_router_cmd_handler(const uint8_t *data, int len)
|
||||
/* We need to know that this is from the slip-radio here. */
|
||||
switch(data[1]) {
|
||||
case 'M':
|
||||
PRINTF("Setting MAC address\n");
|
||||
LOG_DBG("Setting MAC address\n");
|
||||
border_router_set_mac(&data[2]);
|
||||
return 1;
|
||||
case 'V':
|
||||
@ -163,7 +166,7 @@ border_router_cmd_handler(const uint8_t *data, int len)
|
||||
}
|
||||
return 1;
|
||||
case 'R':
|
||||
PRINTF("Packet data report for sid:%d st:%d tx:%d\n",
|
||||
LOG_DBG("Packet data report for sid:%d st:%d tx:%d\n",
|
||||
data[2], data[3], data[4]);
|
||||
packet_sent(data[2], data[3], data[4]);
|
||||
return 1;
|
||||
@ -172,7 +175,7 @@ border_router_cmd_handler(const uint8_t *data, int len)
|
||||
}
|
||||
}
|
||||
} else if(data[0] == '?') {
|
||||
PRINTF("Got request message of type %c\n", data[1]);
|
||||
LOG_DBG("Got request message of type %c\n", data[1]);
|
||||
if(data[1] == 'M' && command_context == CMD_CONTEXT_STDIO) {
|
||||
uint8_t buf[20];
|
||||
char *hexchar = "0123456789abcdef";
|
||||
@ -226,15 +229,14 @@ PROCESS_THREAD(border_router_cmd_process, ev, data)
|
||||
{
|
||||
static struct pt shell_input_pt;
|
||||
PROCESS_BEGIN();
|
||||
PRINTF("Started br-cmd process\n");
|
||||
|
||||
shell_init();
|
||||
|
||||
while(1) {
|
||||
PROCESS_YIELD();
|
||||
if(ev == serial_line_event_message && data != NULL) {
|
||||
PRINTF("Got serial data!!! %s of len: %lu\n",
|
||||
(char *)data, strlen((char *)data));
|
||||
LOG_DBG("Got serial data!!! %s of len: %u\n",
|
||||
(char *)data, (unsigned)strlen((char *)data));
|
||||
command_context = CMD_CONTEXT_STDIO;
|
||||
if(cmd_input(data, strlen((char *)data))) {
|
||||
/* Commnand executed - all is fine */
|
||||
|
@ -44,13 +44,11 @@
|
||||
#include "border-router.h"
|
||||
#include <string.h>
|
||||
|
||||
#define DEBUG 0
|
||||
#if DEBUG
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "BR"
|
||||
#define LOG_LEVEL LOG_LEVEL_NONE
|
||||
|
||||
#define MAX_CALLBACKS 16
|
||||
static int callback_pos;
|
||||
@ -76,7 +74,7 @@ packet_sent(uint8_t sessionid, uint8_t status, uint8_t tx)
|
||||
packetbuf_attr_copyfrom(callback->attrs, callback->addrs);
|
||||
mac_call_sent_callback(callback->cback, callback->ptr, status, tx);
|
||||
} else {
|
||||
PRINTF("*** ERROR: too high session id %d\n", sessionid);
|
||||
LOG_ERR("Session id to high (%d)\n", sessionid);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -117,7 +115,7 @@ send_packet(mac_callback_t sent, void *ptr)
|
||||
|
||||
if(NETSTACK_FRAMER.create() < 0) {
|
||||
/* Failed to allocate space for headers */
|
||||
PRINTF("br-rdc: send failed, too large header\n");
|
||||
LOG_WARN("br-rdc: send failed, too large header\n");
|
||||
mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1);
|
||||
} else {
|
||||
/* here we send the data over SLIP to the radio-chip */
|
||||
@ -126,7 +124,7 @@ send_packet(mac_callback_t sent, void *ptr)
|
||||
size = packetutils_serialize_atts(&buf[3], sizeof(buf) - 3);
|
||||
#endif
|
||||
if(size < 0 || size + packetbuf_totlen() + 3 > sizeof(buf)) {
|
||||
PRINTF("br-rdc: send failed, too large header\n");
|
||||
LOG_WARN("br-rdc: send failed, too large header\n");
|
||||
mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1);
|
||||
} else {
|
||||
sid = setup_callback(sent, ptr);
|
||||
@ -147,7 +145,7 @@ static void
|
||||
packet_input(void)
|
||||
{
|
||||
if(NETSTACK_FRAMER.parse() < 0) {
|
||||
PRINTF("br-rdc: failed to parse %u\n", packetbuf_datalen());
|
||||
LOG_DBG("br-rdc: failed to parse %u\n", packetbuf_datalen());
|
||||
} else {
|
||||
NETSTACK_NETWORK.input();
|
||||
}
|
||||
|
@ -47,8 +47,11 @@
|
||||
#include "border-router.h"
|
||||
#include "border-router-cmds.h"
|
||||
|
||||
#define DEBUG DEBUG_FULL
|
||||
#include "net/ipv6/uip-debug.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "BR"
|
||||
#define LOG_LEVEL LOG_LEVEL_INFO
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -106,7 +109,7 @@ PROCESS_THREAD(border_router_process, ev, data)
|
||||
|
||||
process_start(&border_router_cmd_process, NULL);
|
||||
|
||||
PRINTF("RPL-Border router started\n");
|
||||
LOG_INFO("RPL-Border router started\n");
|
||||
|
||||
slip_config_handle_arguments(contiki_argc, contiki_argv);
|
||||
|
||||
@ -123,12 +126,12 @@ PROCESS_THREAD(border_router_process, ev, data)
|
||||
uip_ipaddr_t prefix;
|
||||
|
||||
if(uiplib_ipaddrconv((const char *)slip_config_ipaddr, &prefix)) {
|
||||
PRINTF("Setting prefix ");
|
||||
PRINT6ADDR(&prefix);
|
||||
PRINTF("\n");
|
||||
LOG_INFO("Setting prefix ");
|
||||
LOG_INFO_6ADDR(&prefix);
|
||||
LOG_INFO_("\n");
|
||||
set_prefix_64(&prefix);
|
||||
} else {
|
||||
PRINTF("Parse error: %s\n", slip_config_ipaddr);
|
||||
LOG_ERR("Parse error: %s\n", slip_config_ipaddr);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +50,11 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#define DEBUG DEBUG_FULL
|
||||
#include "net/ipv6/uip-debug.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Log configuration */
|
||||
#include "sys/log.h"
|
||||
#define LOG_MODULE "BR"
|
||||
#define LOG_LEVEL LOG_LEVEL_NONE
|
||||
|
||||
#ifdef linux
|
||||
#include <linux/if.h>
|
||||
@ -202,7 +205,7 @@ tun_init()
|
||||
|
||||
slip_init();
|
||||
|
||||
PRINTF("Opening tun interface:%s\n", slip_config_tundev);
|
||||
LOG_INFO("Opening tun interface:%s\n", slip_config_tundev);
|
||||
|
||||
tunfd = tun_alloc(slip_config_tundev);
|
||||
|
||||
@ -251,7 +254,7 @@ init(void)
|
||||
static int
|
||||
output(void)
|
||||
{
|
||||
PRINTF("SUT: %u\n", uip_len);
|
||||
LOG_DBG("SUT: %u\n", uip_len);
|
||||
if(uip_len > 0) {
|
||||
return tun_output(&uip_buf[UIP_LLH_LEN], uip_len);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user