Merge pull request #137 from simonduq/pr/logging-fixes
Minor logging fixes
This commit is contained in:
commit
d9ae1118ef
@ -50,9 +50,10 @@
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
/* Log configuration */
|
||||||
#define DEBUG DEBUG_NONE
|
#include "sys/log.h"
|
||||||
#include "net/ipv6/uip-debug.h"
|
#define LOG_MODULE "Tun6"
|
||||||
|
#define LOG_LEVEL LOG_LEVEL_WARN
|
||||||
|
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
#include <linux/if.h>
|
#include <linux/if.h>
|
||||||
@ -92,7 +93,7 @@ static ssystem(const char *fmt, ...)
|
|||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsnprintf(cmd, sizeof(cmd), fmt, ap);
|
vsnprintf(cmd, sizeof(cmd), fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
printf("%s\n", cmd);
|
LOG_INFO("%s\n", cmd);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return system(cmd);
|
return system(cmd);
|
||||||
}
|
}
|
||||||
@ -144,9 +145,9 @@ tun_alloc(char *dev)
|
|||||||
{
|
{
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int fd, err;
|
int fd, err;
|
||||||
PRINTF("Opening: %s\n", dev);
|
LOG_INFO("Opening: %s\n", dev);
|
||||||
if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) {
|
if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) {
|
||||||
PRINTF("Failed to open tun device\n");
|
/* Error message handled by caller */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,14 +161,14 @@ tun_alloc(char *dev)
|
|||||||
strncpy(ifr.ifr_name, dev, IFNAMSIZ);
|
strncpy(ifr.ifr_name, dev, IFNAMSIZ);
|
||||||
}
|
}
|
||||||
if((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ) {
|
if((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ) {
|
||||||
PRINTF("Failed to do ioctl on fd\n");
|
/* Error message handled by caller */
|
||||||
close(fd);
|
close(fd);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINTF("Using '%s' vs '%s'\n", dev, ifr.ifr_name);
|
LOG_INFO("Using '%s' vs '%s'\n", dev, ifr.ifr_name);
|
||||||
strncpy(dev, ifr.ifr_name, strlen(dev));
|
strncpy(dev, ifr.ifr_name, strlen(dev));
|
||||||
PRINTF("Using %s\n", dev);
|
LOG_INFO("Using %s\n", dev);
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -183,7 +184,7 @@ devopen(const char *dev, int flags)
|
|||||||
static int
|
static int
|
||||||
tun_alloc(char *dev)
|
tun_alloc(char *dev)
|
||||||
{
|
{
|
||||||
PRINTF("Opening: %s\n", dev);
|
LOG_INFO("Opening: %s\n", dev);
|
||||||
return devopen(dev, O_RDWR);
|
return devopen(dev, O_RDWR);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -205,16 +206,16 @@ tun_init()
|
|||||||
{
|
{
|
||||||
setvbuf(stdout, NULL, _IOLBF, 0); /* Line buffered output. */
|
setvbuf(stdout, NULL, _IOLBF, 0); /* Line buffered output. */
|
||||||
|
|
||||||
PRINTF("Initializing tun interface\n");
|
LOG_INFO("Initializing tun interface\n");
|
||||||
|
|
||||||
tunfd = tun_alloc(config_tundev);
|
tunfd = tun_alloc(config_tundev);
|
||||||
if(tunfd == -1) {
|
if(tunfd == -1) {
|
||||||
printf("Warning: failed to open tun device (you may be lacking permission). Running without network.\n");
|
LOG_WARN("Failed to open tun device (you may be lacking permission). Running without network.\n");
|
||||||
/* err(1, "failed to allocate tun device ``%s''", config_tundev); */
|
/* err(1, "failed to allocate tun device ``%s''", config_tundev); */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINTF("Tun open:%d\n", tunfd);
|
LOG_INFO("Tun open:%d\n", tunfd);
|
||||||
|
|
||||||
select_set_callback(tunfd, &tun_select_callback);
|
select_set_callback(tunfd, &tun_select_callback);
|
||||||
|
|
||||||
@ -253,7 +254,7 @@ tun_input(unsigned char *data, int maxlen)
|
|||||||
static uint8_t
|
static uint8_t
|
||||||
output(const linkaddr_t *localdest)
|
output(const linkaddr_t *localdest)
|
||||||
{
|
{
|
||||||
PRINTF("SUT: %u\n", uip_len);
|
LOG_DBG("SUT: %u\n", uip_len);
|
||||||
if(uip_len > 0) {
|
if(uip_len > 0) {
|
||||||
return tun_output(&uip_buf[UIP_LLH_LEN], uip_len);
|
return tun_output(&uip_buf[UIP_LLH_LEN], uip_len);
|
||||||
}
|
}
|
||||||
@ -277,11 +278,11 @@ handle_fd(fd_set *rset, fd_set *wset)
|
|||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
PRINTF("Tun6-handle FD\n");
|
LOG_INFO("Tun6-handle FD\n");
|
||||||
|
|
||||||
if(FD_ISSET(tunfd, rset)) {
|
if(FD_ISSET(tunfd, rset)) {
|
||||||
size = tun_input(&uip_buf[UIP_LLH_LEN], sizeof(uip_buf));
|
size = tun_input(&uip_buf[UIP_LLH_LEN], sizeof(uip_buf));
|
||||||
PRINTF("TUN data incoming read:%d\n", size);
|
LOG_DBG("TUN data incoming read:%d\n", size);
|
||||||
uip_len = size;
|
uip_len = size;
|
||||||
tcpip_input();
|
tcpip_input();
|
||||||
}
|
}
|
||||||
@ -291,7 +292,7 @@ handle_fd(fd_set *rset, fd_set *wset)
|
|||||||
static void input(void)
|
static void input(void)
|
||||||
{
|
{
|
||||||
/* should not happen */
|
/* should not happen */
|
||||||
PRINTF("Tun6 - input\n");
|
LOG_DBG("Tun6 - input\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,9 +99,14 @@ uip_ds6_init(void)
|
|||||||
uip_ds6_neighbors_init();
|
uip_ds6_neighbors_init();
|
||||||
uip_ds6_route_init();
|
uip_ds6_route_init();
|
||||||
|
|
||||||
LOG_INFO("Init: %u neighbors\n%u default routers\n%u prefixes\n%u routes\n%u unicast addresses\n%u multicast addresses\n%u anycast addresses\n",
|
LOG_INFO("Init: %u neighbors\n", NBR_TABLE_MAX_NEIGHBORS);
|
||||||
NBR_TABLE_MAX_NEIGHBORS, UIP_DS6_DEFRT_NB, UIP_DS6_PREFIX_NB, UIP_DS6_ROUTE_NB,
|
LOG_INFO("%u default routers\n", UIP_DS6_DEFRT_NB);
|
||||||
UIP_DS6_ADDR_NB, UIP_DS6_MADDR_NB, UIP_DS6_AADDR_NB);
|
LOG_INFO("%u prefixes\n", UIP_DS6_PREFIX_NB);
|
||||||
|
LOG_INFO("%u routes\n", UIP_DS6_ROUTE_NB);
|
||||||
|
LOG_INFO("%u unicast addresses\n", UIP_DS6_ADDR_NB);
|
||||||
|
LOG_INFO("%u multicast addresses\n", UIP_DS6_MADDR_NB);
|
||||||
|
LOG_INFO("%u anycast addresses\n", UIP_DS6_AADDR_NB);
|
||||||
|
|
||||||
memset(uip_ds6_prefix_list, 0, sizeof(uip_ds6_prefix_list));
|
memset(uip_ds6_prefix_list, 0, sizeof(uip_ds6_prefix_list));
|
||||||
memset(&uip_ds6_if, 0, sizeof(uip_ds6_if));
|
memset(&uip_ds6_if, 0, sizeof(uip_ds6_if));
|
||||||
uip_ds6_addr_size = sizeof(struct uip_ds6_addr);
|
uip_ds6_addr_size = sizeof(struct uip_ds6_addr);
|
||||||
|
Loading…
Reference in New Issue
Block a user