Skip to content
Snippets Groups Projects
Commit d09c54fe authored by George Oikonomou's avatar George Oikonomou
Browse files

Use logging

parent 3656d2f9
No related branches found
No related tags found
No related merge requests found
...@@ -51,15 +51,18 @@ ...@@ -51,15 +51,18 @@
#include "net/netstack.h" #include "net/netstack.h"
#include "dev/button-sensor.h" #include "dev/button-sensor.h"
#include "dev/slip.h" #include "dev/slip.h"
#include "net/ipv6/uip-debug.h"
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
/*---------------------------------------------------------------------------*/
#define DEBUG DEBUG_NONE /* Log configuration */
#include "net/ipv6/uip-debug.h" #include "sys/log.h"
#define LOG_MODULE "BR"
#define LOG_LEVEL LOG_LEVEL_NONE
/*---------------------------------------------------------------------------*/
static uip_ipaddr_t prefix; static uip_ipaddr_t prefix;
static uint8_t prefix_set; static uint8_t prefix_set;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
...@@ -352,14 +355,14 @@ print_local_addresses(void) ...@@ -352,14 +355,14 @@ print_local_addresses(void)
int i; int i;
uint8_t state; uint8_t state;
PRINTA("Server IPv6 addresses:\n"); printf("Server IPv6 addresses:\n");
for(i = 0; i < UIP_DS6_ADDR_NB; i++) { for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
state = uip_ds6_if.addr_list[i].state; state = uip_ds6_if.addr_list[i].state;
if(uip_ds6_if.addr_list[i].isused && if(uip_ds6_if.addr_list[i].isused &&
(state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) { (state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) {
PRINTA(" "); printf(" ");
uip_debug_ipaddr_print(&uip_ds6_if.addr_list[i].ipaddr); uip_debug_ipaddr_print(&uip_ds6_if.addr_list[i].ipaddr);
PRINTA("\n"); printf("\n");
} }
} }
} }
...@@ -402,13 +405,14 @@ PROCESS_THREAD(border_router_process, ev, data) ...@@ -402,13 +405,14 @@ PROCESS_THREAD(border_router_process, ev, data)
SENSORS_ACTIVATE(button_sensor); SENSORS_ACTIVATE(button_sensor);
PRINTF("RPL-Border router started\n"); printf("RPL-Border router started\n");
/* Request prefix until it has been received */ /* Request prefix until it has been received */
while(!prefix_set) { while(!prefix_set) {
etimer_set(&et, CLOCK_SECOND); etimer_set(&et, CLOCK_SECOND);
request_prefix(); request_prefix();
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
LOG_INFO("Waiting for prefix\n");
} }
NETSTACK_MAC.on(); NETSTACK_MAC.on();
...@@ -420,7 +424,7 @@ PROCESS_THREAD(border_router_process, ev, data) ...@@ -420,7 +424,7 @@ PROCESS_THREAD(border_router_process, ev, data)
while(1) { while(1) {
PROCESS_YIELD(); PROCESS_YIELD();
if (ev == sensors_event && data == &button_sensor) { if (ev == sensors_event && data == &button_sensor) {
PRINTF("Initiating global repair\n"); LOG_INFO("Initiating global repair\n");
#if UIP_CONF_IPV6_RPL_LITE #if UIP_CONF_IPV6_RPL_LITE
rpl_global_repair(); rpl_global_repair();
#else #else
......
...@@ -37,17 +37,19 @@ ...@@ -37,17 +37,19 @@
* Joel Hoglund <joel@sics.se> * Joel Hoglund <joel@sics.se>
* Nicolas Tsiftes <nvt@sics.se> * Nicolas Tsiftes <nvt@sics.se>
*/ */
/*---------------------------------------------------------------------------*/
#include "net/ipv6/uip.h" #include "net/ipv6/uip.h"
#include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-ds6.h"
#include "dev/slip.h" #include "dev/slip.h"
#include <string.h> #include <string.h>
/*---------------------------------------------------------------------------*/
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) #define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
/*---------------------------------------------------------------------------*/
#define DEBUG DEBUG_PRINT /* Log configuration */
#include "net/ipv6/uip-debug.h" #include "sys/log.h"
#define LOG_MODULE "SLIP"
#define LOG_LEVEL LOG_LEVEL_NONE
/*---------------------------------------------------------------------------*/
void set_prefix_64(uip_ipaddr_t *); void set_prefix_64(uip_ipaddr_t *);
static uip_ipaddr_t last_sender; static uip_ipaddr_t last_sender;
...@@ -55,22 +57,22 @@ static uip_ipaddr_t last_sender; ...@@ -55,22 +57,22 @@ static uip_ipaddr_t last_sender;
static void static void
slip_input_callback(void) slip_input_callback(void)
{ {
PRINTF("SIN: %u\n", uip_len); LOG_DBG("SIN: %u\n", uip_len);
if(uip_buf[0] == '!') { if(uip_buf[0] == '!') {
PRINTF("Got configuration message of type %c\n", uip_buf[1]); LOG_INFO("Got configuration message of type %c\n", uip_buf[1]);
uip_clear_buf(); uip_clear_buf();
if(uip_buf[1] == 'P') { if(uip_buf[1] == 'P') {
uip_ipaddr_t prefix; uip_ipaddr_t prefix;
/* Here we set a prefix !!! */ /* Here we set a prefix !!! */
memset(&prefix, 0, 16); memset(&prefix, 0, 16);
memcpy(&prefix, &uip_buf[2], 8); memcpy(&prefix, &uip_buf[2], 8);
PRINTF("Setting prefix "); LOG_INFO("Setting prefix ");
PRINT6ADDR(&prefix); LOG_INFO_6ADDR(&prefix);
PRINTF("\n"); LOG_INFO_("\n");
set_prefix_64(&prefix); set_prefix_64(&prefix);
} }
} else if(uip_buf[0] == '?') { } else if(uip_buf[0] == '?') {
PRINTF("Got request message of type %c\n", uip_buf[1]); LOG_INFO("Got request message of type %c\n", uip_buf[1]);
if(uip_buf[1] == 'M') { if(uip_buf[1] == 'M') {
char *hexchar = "0123456789abcdef"; char *hexchar = "0123456789abcdef";
int j; int j;
...@@ -104,13 +106,13 @@ output(void) ...@@ -104,13 +106,13 @@ output(void)
if(uip_ipaddr_cmp(&last_sender, &UIP_IP_BUF->srcipaddr)) { if(uip_ipaddr_cmp(&last_sender, &UIP_IP_BUF->srcipaddr)) {
/* Do not bounce packets back over SLIP if the packet was received /* Do not bounce packets back over SLIP if the packet was received
over SLIP */ over SLIP */
PRINTF("slip-bridge: Destination off-link but no route src="); LOG_ERR("slip-bridge: Destination off-link but no route src=");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr); LOG_ERR_6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(" dst="); LOG_ERR_(" dst=");
PRINT6ADDR(&UIP_IP_BUF->destipaddr); LOG_ERR_6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF("\n"); LOG_ERR_("\n");
} else { } else {
PRINTF("SUT: %u\n", uip_len); LOG_DBG("SUT: %u\n", uip_len);
slip_send(); slip_send();
} }
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment