Merge pull request #38 from simonduq/pr/log-levels

Logging module
This commit is contained in:
Nicolas Tsiftes 2017-06-21 17:52:14 +02:00 committed by GitHub
commit 5853121329
43 changed files with 985 additions and 854 deletions

View File

@ -51,16 +51,10 @@
#include <string.h>
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
#if UIP_LOGGING
#include <stdio.h>
void uip_log(char *msg);
#define UIP_LOG(m) uip_log(m)
#else
#define UIP_LOG(m)
#endif
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "TCP/IP"
#define LOG_LEVEL TCPIP_LOG_LEVEL
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[UIP_LLIPH_LEN + uip_ext_len])
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
@ -132,7 +126,7 @@ tcpip_output(const uip_lladdr_t *a)
ret = outputfunc(a);
return ret;
}
UIP_LOG("tcpip_output: Use tcpip_set_outputfunc() to set an output function");
LOG_INFO("output: Use tcpip_set_outputfunc() to set an output function");
return 0;
}
@ -451,7 +445,7 @@ static void
output_fallback(void)
{
#ifdef UIP_FALLBACK_INTERFACE
PRINTF("FALLBACK: removing ext hdrs & setting proto %d %d\n",
LOG_INFO("fallback: removing ext hdrs & setting proto %d %d\n",
uip_ext_len, *((uint8_t *)UIP_IP_BUF + 40));
if(uip_ext_len > 0) {
uint8_t proto = *((uint8_t *)UIP_IP_BUF + 40);
@ -463,14 +457,14 @@ output_fallback(void)
* not informed routes might get lost unexpectedly until there's a need
* to send a new packet to the peer */
if(UIP_FALLBACK_INTERFACE.output() < 0) {
PRINTF("FALLBACK: output error. Reporting DST UNREACH\n");
LOG_ERR("fallback: output error. Reporting DST UNREACH\n");
uip_icmp6_error_output(ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR, 0);
uip_flags = 0;
tcpip_ipv6_output();
return;
}
#else
PRINTF("tcpip_ipv6_output: Destination off-link but no route\n");
LOG_ERR("output: Destination off-link but no route\n");
#endif /* !UIP_FALLBACK_INTERFACE */
}
/*---------------------------------------------------------------------------*/
@ -533,7 +527,7 @@ get_nexthop(uip_ipaddr_t *addr)
/* No route was found - we send to the default route instead. */
if(route == NULL) {
PRINTF("tcpip_ipv6_output: no route found, using default route\n");
LOG_INFO("output: no route found, using default route\n");
nexthop = uip_ds6_defrt_choose();
if(nexthop == NULL) {
output_fallback();
@ -620,7 +614,7 @@ send_nd6_ns(uip_ipaddr_t *nexthop)
/* Send the first NS try from here (multicast destination IP address). */
}
#else
PRINTF("tcpip_ipv6_output: neighbor not in cache\n");
LOG_ERR("output: neighbor not in cache\n");
#endif
return err;
@ -639,19 +633,19 @@ tcpip_ipv6_output(void)
}
if(uip_len > UIP_LINK_MTU) {
UIP_LOG("tcpip_ipv6_output: Packet too big");
LOG_ERR("output: Packet too big");
goto exit;
}
if(uip_is_addr_unspecified(&UIP_IP_BUF->destipaddr)){
UIP_LOG("tcpip_ipv6_output: Destination address unspecified");
LOG_ERR("output: Destination address unspecified");
goto exit;
}
#if UIP_CONF_IPV6_RPL
if(!rpl_update_header()) {
/* Packet can not be forwarded */
PRINTF("tcpip_ipv6_output: RPL header update error\n");
LOG_ERR("output: RPL header update error\n");
uip_clear_buf();
return;
}
@ -679,9 +673,9 @@ tcpip_ipv6_output(void)
uip_ds6_set_lladdr_from_iid(&lladdr, nexthop);
if((nbr = uip_ds6_nbr_add(nexthop, &lladdr,
0, NBR_REACHABLE, NBR_TABLE_REASON_IPV6_ND_AUTOFILL, NULL)) == NULL) {
PRINTF("tcpip_ipv6_output: failed to autofill neighbor cache for host ");
PRINT6ADDR(nexthop);
PRINTF("\n");
LOG_ERR("output: failed to autofill neighbor cache for host ");
LOG_ERR_6ADDR(nexthop);
LOG_ERR("\n");
goto exit;
}
}
@ -689,7 +683,7 @@ tcpip_ipv6_output(void)
if(nbr == NULL) {
if(send_nd6_ns(nexthop)) {
PRINTF("tcpip_ipv6_output: failed to add neighbor to cache\n");
LOG_ERR("output: failed to add neighbor to cache\n");
goto exit;
} else {
/* We're sending NS here instead of original packet */
@ -699,7 +693,7 @@ tcpip_ipv6_output(void)
#if UIP_ND6_SEND_NS
if(nbr->state == NBR_INCOMPLETE) {
PRINTF("tcpip_ipv6_output: nbr cache entry incomplete\n");
LOG_ERR("output: nbr cache entry incomplete\n");
queue_packet(nbr);
goto exit;
}
@ -709,7 +703,7 @@ tcpip_ipv6_output(void)
nbr->state = NBR_DELAY;
stimer_set(&nbr->reachable, UIP_ND6_DELAY_FIRST_PROBE_TIME);
nbr->nscount = 0;
PRINTF("tcpip_ipv6_output: nbr cache entry stale moving to delay\n");
LOG_INFO("output: nbr cache entry stale moving to delay\n");
}
#endif /* UIP_ND6_SEND_NS */

View File

@ -71,28 +71,10 @@
#include "net/packetbuf.h"
#include "net/queuebuf.h"
#include <stdio.h>
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
#if DEBUG
/* PRINTFI and PRINTFO are defined for input and output to debug one without changing the timing of the other */
uint8_t p;
#include <stdio.h>
#define PRINTFI(...) PRINTF(__VA_ARGS__)
#define PRINTFO(...) PRINTF(__VA_ARGS__)
#else
#define PRINTFI(...)
#define PRINTFO(...)
#endif /* DEBUG == 1*/
#if UIP_LOGGING
#include <stdio.h>
void uip_log(char *msg);
#define UIP_LOG(m) uip_log(m)
#else
#define UIP_LOG(m)
#endif /* UIP_LOGGING == 1 */
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "6LoWPAN"
#define LOG_LEVEL SICSLOWPAN_LOG_LEVEL
#ifndef SICSLOWPAN_COMPRESSION
#ifdef SICSLOWPAN_CONF_COMPRESSION
@ -333,7 +315,7 @@ store_fragment(uint8_t index, uint8_t offset)
memcpy(frag_buf[i].data, packetbuf_ptr + packetbuf_hdr_len,
packetbuf_datalen() - packetbuf_hdr_len);
PRINTF("Fragsize: %d\n", frag_buf[i].len);
LOG_INFO("Fragsize: %d\n", frag_buf[i].len);
/* return the length of the stored fragment */
return frag_buf[i].len;
}
@ -367,7 +349,7 @@ add_fragment(uint16_t tag, uint16_t frag_size, uint8_t offset)
}
if(found < 0) {
PRINTF("*** Failed to store new fragment session - tag: %d\n", tag);
LOG_WARN("*** Failed to store new fragment session - tag: %d\n", tag);
return -1;
}
@ -394,7 +376,7 @@ add_fragment(uint16_t tag, uint16_t frag_size, uint8_t offset)
if(found < 0) {
/* no entry found for storing the new fragment */
PRINTF("*** Failed to store N-fragment - could not find session - tag: %d offset: %d\n", tag, offset);
LOG_WARN("*** Failed to store N-fragment - could not find session - tag: %d offset: %d\n", tag, offset);
return -1;
}
@ -409,7 +391,7 @@ add_fragment(uint16_t tag, uint16_t frag_size, uint8_t offset)
} else {
/* should we also clear all fragments since we failed to store
this fragment? */
PRINTF("*** Failed to store fragment - packet reassembly will fail tag:%d l\n", frag_info[i].tag);
LOG_WARN("*** Failed to store fragment - packet reassembly will fail tag:%d l\n", frag_info[i].tag);
return -1;
}
}
@ -606,7 +588,7 @@ uncompress_addr(uip_ipaddr_t *ipaddr, uint8_t const prefix[],
prefcount = prefcount == 15 ? 16 : prefcount;
postcount = postcount == 15 ? 16 : postcount;
PRINTF("Uncompressing %d + %d => ", prefcount, postcount);
LOG_INFO("Uncompressing %d + %d => ", prefcount, postcount);
if(prefcount > 0) {
memcpy(ipaddr, prefix, prefcount);
@ -627,8 +609,8 @@ uncompress_addr(uip_ipaddr_t *ipaddr, uint8_t const prefix[],
uip_ds6_set_addr_iid(ipaddr, lladdr);
}
PRINT6ADDR(ipaddr);
PRINTF("\n");
LOG_INFO_6ADDR(ipaddr);
LOG_INFO("\n");
}
/*--------------------------------------------------------------------*/
@ -670,16 +652,16 @@ static void
compress_hdr_iphc(linkaddr_t *link_destaddr)
{
uint8_t tmp, iphc0, iphc1;
#if DEBUG
#if LOG_DBG_ENABLED
{ uint16_t ndx;
PRINTF("before compression (%d): ", UIP_IP_BUF->len[1]);
LOG_DBG("before compression (%d): ", UIP_IP_BUF->len[1]);
for(ndx = 0; ndx < UIP_IP_BUF->len[1] + 40; ndx++) {
uint8_t data = ((uint8_t *) (UIP_IP_BUF))[ndx];
PRINTF("%02x", data);
LOG_DBG("%02x", data);
}
PRINTF("\n");
LOG_DBG("\n");
}
#endif
#endif /* LOG_DBG_ENABLED */
hc06_ptr = packetbuf_ptr + 2;
/*
@ -706,7 +688,7 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
if(addr_context_lookup_by_prefix(&UIP_IP_BUF->destipaddr) != NULL ||
addr_context_lookup_by_prefix(&UIP_IP_BUF->srcipaddr) != NULL) {
/* set context flag and increase hc06_ptr */
PRINTF("IPHC: compressing dest or src ipaddr - setting CID\n");
LOG_INFO("IPHC: compressing dest or src ipaddr - setting CID\n");
iphc1 |= SICSLOWPAN_IPHC_CID;
hc06_ptr++;
}
@ -794,13 +776,13 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
/* source address - cannot be multicast */
if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {
PRINTF("IPHC: compressing unspecified - setting SAC\n");
LOG_INFO("IPHC: compressing unspecified - setting SAC\n");
iphc1 |= SICSLOWPAN_IPHC_SAC;
iphc1 |= SICSLOWPAN_IPHC_SAM_00;
} else if((context = addr_context_lookup_by_prefix(&UIP_IP_BUF->srcipaddr))
!= NULL) {
/* elide the prefix - indicate by CID and set context + SAC */
PRINTF("IPHC: compressing src with context - setting CID & SAC ctx: %d\n",
LOG_INFO("IPHC: compressing src with context - setting CID & SAC ctx: %d\n",
context->number);
iphc1 |= SICSLOWPAN_IPHC_CID | SICSLOWPAN_IPHC_SAC;
PACKETBUF_IPHC_BUF[2] |= context->number << 4;
@ -880,14 +862,14 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
#if UIP_CONF_UDP || UIP_CONF_ROUTER
/* UDP header compression */
if(UIP_IP_BUF->proto == UIP_PROTO_UDP) {
PRINTF("IPHC: Uncompressed UDP ports on send side: %x, %x\n",
LOG_INFO("IPHC: Uncompressed UDP ports on send side: %x, %x\n",
UIP_HTONS(UIP_UDP_BUF->srcport), UIP_HTONS(UIP_UDP_BUF->destport));
/* Mask out the last 4 bits can be used as a mask */
if(((UIP_HTONS(UIP_UDP_BUF->srcport) & 0xfff0) == SICSLOWPAN_UDP_4_BIT_PORT_MIN) &&
((UIP_HTONS(UIP_UDP_BUF->destport) & 0xfff0) == SICSLOWPAN_UDP_4_BIT_PORT_MIN)) {
/* we can compress 12 bits of both source and dest */
*hc06_ptr = SICSLOWPAN_NHC_UDP_CS_P_11;
PRINTF("IPHC: remove 12 b of both source & dest with prefix 0xFOB\n");
LOG_INFO("IPHC: remove 12 b of both source & dest with prefix 0xFOB\n");
*(hc06_ptr + 1) =
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->srcport) -
SICSLOWPAN_UDP_4_BIT_PORT_MIN) << 4) +
@ -897,7 +879,7 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
} else if((UIP_HTONS(UIP_UDP_BUF->destport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) {
/* we can compress 8 bits of dest, leave source. */
*hc06_ptr = SICSLOWPAN_NHC_UDP_CS_P_01;
PRINTF("IPHC: leave source, remove 8 bits of dest with prefix 0xF0\n");
LOG_INFO("IPHC: leave source, remove 8 bits of dest with prefix 0xF0\n");
memcpy(hc06_ptr + 1, &UIP_UDP_BUF->srcport, 2);
*(hc06_ptr + 3) =
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->destport) -
@ -906,7 +888,7 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
} else if((UIP_HTONS(UIP_UDP_BUF->srcport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) {
/* we can compress 8 bits of src, leave dest. Copy compressed port */
*hc06_ptr = SICSLOWPAN_NHC_UDP_CS_P_10;
PRINTF("IPHC: remove 8 bits of source with prefix 0xF0, leave dest. hch: %i\n", *hc06_ptr);
LOG_INFO("IPHC: remove 8 bits of source with prefix 0xF0, leave dest. hch: %i\n", *hc06_ptr);
*(hc06_ptr + 1) =
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->srcport) -
SICSLOWPAN_UDP_8_BIT_PORT_MIN));
@ -915,7 +897,7 @@ compress_hdr_iphc(linkaddr_t *link_destaddr)
} else {
/* we cannot compress. Copy uncompressed ports, full checksum */
*hc06_ptr = SICSLOWPAN_NHC_UDP_CS_P_00;
PRINTF("IPHC: cannot compress headers\n");
LOG_INFO("IPHC: cannot compress headers\n");
memcpy(hc06_ptr + 1, &UIP_UDP_BUF->srcport, 4);
hc06_ptr += 5;
}
@ -965,7 +947,7 @@ uncompress_hdr_iphc(uint8_t *buf, uint16_t ip_len)
/* another if the CID flag is set */
if(iphc1 & SICSLOWPAN_IPHC_CID) {
PRINTF("IPHC: CID flag set - increase header with one\n");
LOG_INFO("IPHC: CID flag set - increase header with one\n");
hc06_ptr++;
}
@ -1013,7 +995,7 @@ uncompress_hdr_iphc(uint8_t *buf, uint16_t ip_len)
if((iphc0 & SICSLOWPAN_IPHC_NH_C) == 0) {
/* Next header is carried inline */
SICSLOWPAN_IP_BUF(buf)->proto = *hc06_ptr;
PRINTF("IPHC: next header inline: %d\n", SICSLOWPAN_IP_BUF(buf)->proto);
LOG_INFO("IPHC: next header inline: %d\n", SICSLOWPAN_IP_BUF(buf)->proto);
hc06_ptr += 1;
}
@ -1037,7 +1019,7 @@ uncompress_hdr_iphc(uint8_t *buf, uint16_t ip_len)
if (tmp != 0) {
context = addr_context_lookup_by_number(sci);
if(context == NULL) {
PRINTF("sicslowpan uncompress_hdr: error context not found\n");
LOG_ERR("uncompress_hdr: error context not found\n");
return;
}
}
@ -1084,7 +1066,7 @@ uncompress_hdr_iphc(uint8_t *buf, uint16_t ip_len)
/* all valid cases below need the context! */
if(context == NULL) {
PRINTF("sicslowpan uncompress_hdr: error context not found\n");
LOG_ERR("uncompress_hdr: error context not found\n");
return;
}
uncompress_addr(&SICSLOWPAN_IP_BUF(buf)->destipaddr, context->prefix,
@ -1106,13 +1088,13 @@ uncompress_hdr_iphc(uint8_t *buf, uint16_t ip_len)
uint8_t checksum_compressed;
SICSLOWPAN_IP_BUF(buf)->proto = UIP_PROTO_UDP;
checksum_compressed = *hc06_ptr & SICSLOWPAN_NHC_UDP_CHECKSUMC;
PRINTF("IPHC: Incoming header value: %i\n", *hc06_ptr);
LOG_INFO("IPHC: Incoming header value: %i\n", *hc06_ptr);
switch(*hc06_ptr & SICSLOWPAN_NHC_UDP_CS_P_11) {
case SICSLOWPAN_NHC_UDP_CS_P_00:
/* 1 byte for NHC, 4 byte for ports, 2 bytes chksum */
memcpy(&SICSLOWPAN_UDP_BUF(buf)->srcport, hc06_ptr + 1, 2);
memcpy(&SICSLOWPAN_UDP_BUF(buf)->destport, hc06_ptr + 3, 2);
PRINTF("IPHC: Uncompressed UDP ports (ptr+5): %x, %x\n",
LOG_INFO("IPHC: Uncompressed UDP ports (ptr+5): %x, %x\n",
UIP_HTONS(SICSLOWPAN_UDP_BUF(buf)->srcport),
UIP_HTONS(SICSLOWPAN_UDP_BUF(buf)->destport));
hc06_ptr += 5;
@ -1120,21 +1102,21 @@ uncompress_hdr_iphc(uint8_t *buf, uint16_t ip_len)
case SICSLOWPAN_NHC_UDP_CS_P_01:
/* 1 byte for NHC + source 16bit inline, dest = 0xF0 + 8 bit inline */
PRINTF("IPHC: Decompressing destination\n");
LOG_INFO("IPHC: Decompressing destination\n");
memcpy(&SICSLOWPAN_UDP_BUF(buf)->srcport, hc06_ptr + 1, 2);
SICSLOWPAN_UDP_BUF(buf)->destport = UIP_HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN + (*(hc06_ptr + 3)));
PRINTF("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n",
LOG_INFO("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n",
UIP_HTONS(SICSLOWPAN_UDP_BUF(buf)->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF(buf)->destport));
hc06_ptr += 4;
break;
case SICSLOWPAN_NHC_UDP_CS_P_10:
/* 1 byte for NHC + source = 0xF0 + 8bit inline, dest = 16 bit inline*/
PRINTF("IPHC: Decompressing source\n");
LOG_INFO("IPHC: Decompressing source\n");
SICSLOWPAN_UDP_BUF(buf)->srcport = UIP_HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN +
(*(hc06_ptr + 1)));
memcpy(&SICSLOWPAN_UDP_BUF(buf)->destport, hc06_ptr + 2, 2);
PRINTF("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n",
LOG_INFO("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n",
UIP_HTONS(SICSLOWPAN_UDP_BUF(buf)->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF(buf)->destport));
hc06_ptr += 4;
break;
@ -1145,21 +1127,21 @@ uncompress_hdr_iphc(uint8_t *buf, uint16_t ip_len)
(*(hc06_ptr + 1) >> 4));
SICSLOWPAN_UDP_BUF(buf)->destport = UIP_HTONS(SICSLOWPAN_UDP_4_BIT_PORT_MIN +
((*(hc06_ptr + 1)) & 0x0F));
PRINTF("IPHC: Uncompressed UDP ports (ptr+2): %x, %x\n",
LOG_INFO("IPHC: Uncompressed UDP ports (ptr+2): %x, %x\n",
UIP_HTONS(SICSLOWPAN_UDP_BUF(buf)->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF(buf)->destport));
hc06_ptr += 2;
break;
default:
PRINTF("sicslowpan uncompress_hdr: error unsupported UDP compression\n");
LOG_INFO("uncompress_hdr: error unsupported UDP compression\n");
return;
}
if(!checksum_compressed) { /* has_checksum, default */
memcpy(&SICSLOWPAN_UDP_BUF(buf)->udpchksum, hc06_ptr, 2);
hc06_ptr += 2;
PRINTF("IPHC: sicslowpan uncompress_hdr: checksum included\n");
LOG_INFO("IPHC: sicslowpan uncompress_hdr: checksum included\n");
} else {
PRINTF("IPHC: sicslowpan uncompress_hdr: checksum *NOT* included\n");
LOG_INFO("IPHC: sicslowpan uncompress_hdr: checksum *NOT* included\n");
}
uncomp_hdr_len += UIP_UDPH_LEN;
}
@ -1306,7 +1288,7 @@ output(const uip_lladdr_t *localdest)
linkaddr_copy(&dest, (const linkaddr_t *)localdest);
}
PRINTFO("sicslowpan output: sending packet len %d\n", uip_len);
LOG_INFO("output: sending packet len %d\n", uip_len);
if(uip_len >= COMPRESSION_THRESHOLD) {
/* Try to compress the headers */
@ -1319,7 +1301,7 @@ output(const uip_lladdr_t *localdest)
} else {
compress_hdr_ipv6(&dest);
}
PRINTFO("sicslowpan output: header of len %d\n", packetbuf_hdr_len);
LOG_INFO("output: header of len %d\n", packetbuf_hdr_len);
/* Calculate NETSTACK_FRAMER's header length, that will be added in the NETSTACK_MAC.
* We calculate it here only to make a better decision of whether the outgoing packet
@ -1353,16 +1335,16 @@ output(const uip_lladdr_t *localdest)
*/
int estimated_fragments = ((int)uip_len) / (max_payload - SICSLOWPAN_FRAGN_HDR_LEN) + 1;
int freebuf = queuebuf_numfree() - 1;
PRINTFO("uip_len: %d, fragments: %d, free bufs: %d\n", uip_len, estimated_fragments, freebuf);
LOG_INFO("uip_len: %d, fragments: %d, free bufs: %d\n", uip_len, estimated_fragments, freebuf);
if(freebuf < estimated_fragments) {
PRINTFO("Dropping packet, not enough free bufs\n");
LOG_WARN("Dropping packet, not enough free bufs\n");
return 0;
}
PRINTFO("Fragmentation sending packet len %d\n", uip_len);
LOG_INFO("Fragmentation sending packet len %d\n", uip_len);
/* Create 1st Fragment */
PRINTFO("sicslowpan output: 1rst fragment ");
LOG_INFO("output: 1rst fragment ");
/* Reset last tx status to ok in case the fragment transmissions are deferred */
last_tx_status = MAC_TX_OK;
@ -1384,13 +1366,13 @@ output(const uip_lladdr_t *localdest)
/* Copy payload and send */
packetbuf_hdr_len += SICSLOWPAN_FRAG1_HDR_LEN;
packetbuf_payload_len = (max_payload - packetbuf_hdr_len) & 0xfffffff8;
PRINTFO("(len %d, tag %d)\n", packetbuf_payload_len, frag_tag);
LOG_INFO("(len %d, tag %d)\n", packetbuf_payload_len, frag_tag);
memcpy(packetbuf_ptr + packetbuf_hdr_len,
(uint8_t *)UIP_IP_BUF + uncomp_hdr_len, packetbuf_payload_len);
packetbuf_set_datalen(packetbuf_payload_len + packetbuf_hdr_len);
q = queuebuf_new_from_packetbuf();
if(q == NULL) {
PRINTFO("could not allocate queuebuf for first fragment, dropping packet\n");
LOG_WARN("could not allocate queuebuf for first fragment, dropping packet\n");
return 0;
}
send_packet(&dest);
@ -1402,7 +1384,7 @@ output(const uip_lladdr_t *localdest)
if((last_tx_status == MAC_TX_COLLISION) ||
(last_tx_status == MAC_TX_ERR) ||
(last_tx_status == MAC_TX_ERR_FATAL)) {
PRINTFO("error in fragment tx, dropping subsequent fragments.\n");
LOG_ERR("error in fragment tx, dropping subsequent fragments.\n");
return 0;
}
@ -1421,7 +1403,7 @@ output(const uip_lladdr_t *localdest)
((SICSLOWPAN_DISPATCH_FRAGN << 8) | uip_len));
packetbuf_payload_len = (max_payload - packetbuf_hdr_len) & 0xfffffff8;
while(processed_ip_out_len < uip_len) {
PRINTFO("sicslowpan output: fragment ");
LOG_INFO("output: fragment ");
PACKETBUF_FRAG_PTR[PACKETBUF_FRAG_OFFSET] = processed_ip_out_len >> 3;
/* Copy payload and send */
@ -1429,14 +1411,14 @@ output(const uip_lladdr_t *localdest)
/* last fragment */
packetbuf_payload_len = uip_len - processed_ip_out_len;
}
PRINTFO("(offset %d, len %d, tag %d)\n",
LOG_INFO("(offset %d, len %d, tag %d)\n",
processed_ip_out_len >> 3, packetbuf_payload_len, frag_tag);
memcpy(packetbuf_ptr + packetbuf_hdr_len,
(uint8_t *)UIP_IP_BUF + processed_ip_out_len, packetbuf_payload_len);
packetbuf_set_datalen(packetbuf_payload_len + packetbuf_hdr_len);
q = queuebuf_new_from_packetbuf();
if(q == NULL) {
PRINTFO("could not allocate queuebuf, dropping fragment\n");
LOG_WARN("could not allocate queuebuf, dropping fragment\n");
return 0;
}
send_packet(&dest);
@ -1449,12 +1431,12 @@ output(const uip_lladdr_t *localdest)
if((last_tx_status == MAC_TX_COLLISION) ||
(last_tx_status == MAC_TX_ERR) ||
(last_tx_status == MAC_TX_ERR_FATAL)) {
PRINTFO("error in fragment tx, dropping subsequent fragments.\n");
LOG_ERR("error in fragment tx, dropping subsequent fragments.\n");
return 0;
}
}
#else /* SICSLOWPAN_CONF_FRAG */
PRINTFO("sicslowpan output: Packet too large to be sent without fragmentation support; dropping packet\n");
LOG_ERR("output: Packet too large to be sent without fragmentation support; dropping packet\n");
return 0;
#endif /* SICSLOWPAN_CONF_FRAG */
} else {
@ -1526,13 +1508,13 @@ input(void)
*/
switch((GET16(PACKETBUF_FRAG_PTR, PACKETBUF_FRAG_DISPATCH_SIZE) & 0xf800) >> 8) {
case SICSLOWPAN_DISPATCH_FRAG1:
PRINTFI("sicslowpan input: FRAG1 ");
LOG_INFO("input: FRAG1 ");
frag_offset = 0;
/* frag_size = (uip_ntohs(PACKETBUF_FRAG_BUF->dispatch_size) & 0x07ff); */
frag_size = GET16(PACKETBUF_FRAG_PTR, PACKETBUF_FRAG_DISPATCH_SIZE) & 0x07ff;
/* frag_tag = uip_ntohs(PACKETBUF_FRAG_BUF->tag); */
frag_tag = GET16(PACKETBUF_FRAG_PTR, PACKETBUF_FRAG_TAG);
PRINTFI("size %d, tag %d, offset %d)\n",
LOG_INFO("size %d, tag %d, offset %d)\n",
frag_size, frag_tag, frag_offset);
packetbuf_hdr_len += SICSLOWPAN_FRAG1_HDR_LEN;
/* printf("frag1 %d %d\n", reass_tag, frag_tag);*/
@ -1554,17 +1536,17 @@ input(void)
* set offset, tag, size
* Offset is in units of 8 bytes
*/
PRINTFI("sicslowpan input: FRAGN ");
LOG_INFO("input: FRAGN ");
frag_offset = PACKETBUF_FRAG_PTR[PACKETBUF_FRAG_OFFSET];
frag_tag = GET16(PACKETBUF_FRAG_PTR, PACKETBUF_FRAG_TAG);
frag_size = GET16(PACKETBUF_FRAG_PTR, PACKETBUF_FRAG_DISPATCH_SIZE) & 0x07ff;
PRINTFI("size %d, tag %d, offset %d)\n",
LOG_INFO("size %d, tag %d, offset %d)\n",
frag_size, frag_tag, frag_offset);
packetbuf_hdr_len += SICSLOWPAN_FRAGN_HDR_LEN;
/* If this is the last fragment, we may shave off any extrenous
bytes at the end. We must be liberal in what we accept. */
PRINTFI("last_fragment?: packetbuf_payload_len %d frag_size %d\n",
LOG_INFO("last_fragment?: packetbuf_payload_len %d frag_size %d\n",
packetbuf_datalen() - packetbuf_hdr_len, frag_size);
/* Add the fragment to the fragmentation context (this will also
@ -1597,13 +1579,13 @@ input(void)
/* Process next dispatch and headers */
#if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_HC06
if((PACKETBUF_HC1_PTR[PACKETBUF_HC1_DISPATCH] & 0xe0) == SICSLOWPAN_DISPATCH_IPHC) {
PRINTFI("sicslowpan input: IPHC\n");
LOG_INFO("input: IPHC\n");
uncompress_hdr_iphc(buffer, frag_size);
} else
#endif /* SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_HC06 */
switch(PACKETBUF_HC1_PTR[PACKETBUF_HC1_DISPATCH]) {
case SICSLOWPAN_DISPATCH_IPV6:
PRINTFI("sicslowpan input: IPV6\n");
LOG_INFO("input: IPV6\n");
packetbuf_hdr_len += SICSLOWPAN_IPV6_HDR_LEN;
/* Put uncompressed IP header in sicslowpan_buf. */
@ -1615,7 +1597,7 @@ input(void)
break;
default:
/* unknown header */
PRINTFI("sicslowpan input: unknown dispatch: %u\n",
LOG_ERR("input: unknown dispatch: %u\n",
PACKETBUF_HC1_PTR[PACKETBUF_HC1_DISPATCH]);
return;
}
@ -1632,7 +1614,7 @@ input(void)
* If this is a subsequent fragment, this is the contrary.
*/
if(packetbuf_datalen() < packetbuf_hdr_len) {
PRINTF("SICSLOWPAN: packet dropped due to header > total packet\n");
LOG_ERR("packet dropped due to header > total packet\n");
return;
}
packetbuf_payload_len = packetbuf_datalen() - packetbuf_hdr_len;
@ -1642,8 +1624,8 @@ input(void)
int req_size = UIP_LLH_LEN + uncomp_hdr_len + (uint16_t)(frag_offset << 3)
+ packetbuf_payload_len;
if(req_size > sizeof(uip_buf)) {
PRINTF(
"SICSLOWPAN: packet dropped, minimum required IP_BUF size: %d+%d+%d+%d=%d (current size: %u)\n",
LOG_ERR(
"packet dropped, minimum required IP_BUF size: %d+%d+%d+%d=%d (current size: %u)\n",
UIP_LLH_LEN, uncomp_hdr_len, (uint16_t)(frag_offset << 3),
packetbuf_payload_len, req_size, (unsigned)sizeof(uip_buf));
return;
@ -1688,20 +1670,20 @@ input(void)
#else
uip_len = packetbuf_payload_len + uncomp_hdr_len;
#endif /* SICSLOWPAN_CONF_FRAG */
PRINTFI("sicslowpan input: IP packet ready (length %d)\n",
LOG_INFO("input: IP packet ready (length %d)\n",
uip_len);
#if DEBUG
#if LOG_DBG_ENABLED
{
uint16_t ndx;
PRINTF("after decompression %u:", UIP_IP_BUF->len[1]);
LOG_DBG("after decompression %u:", UIP_IP_BUF->len[1]);
for (ndx = 0; ndx < UIP_IP_BUF->len[1] + 40; ndx++) {
uint8_t data = ((uint8_t *) (UIP_IP_BUF))[ndx];
PRINTF("%02x", data);
LOG_DBG("%02x", data);
}
PRINTF("\n");
LOG_DBG("\n");
}
#endif
#endif /* LOG_DBG_ENABLED */
/* if callback is set then set attributes and call */
if(callback) {

View File

@ -52,8 +52,10 @@
#include "net/packetbuf.h"
#include "net/ipv6/uip-ds6-nbr.h"
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "IPv6 Neighbor"
#define LOG_LEVEL IPV6_LOG_LEVEL
#ifdef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED
#define NEIGHBOR_STATE_CHANGED(n) UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED(n)
@ -105,19 +107,19 @@ uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr,
stimer_set(&nbr->sendns, 0);
nbr->nscount = 0;
#endif /* UIP_ND6_SEND_NS */
PRINTF("Adding neighbor with ip addr ");
PRINT6ADDR(ipaddr);
PRINTF(" link addr ");
PRINTLLADDR(lladdr);
PRINTF(" state %u\n", state);
LOG_INFO("Adding neighbor with ip addr ");
LOG_INFO_6ADDR(ipaddr);
LOG_INFO(" link addr ");
LOG_INFO_LLADDR((linkaddr_t*)lladdr);
LOG_INFO(" state %u\n", state);
NEIGHBOR_STATE_CHANGED(nbr);
return nbr;
} else {
PRINTF("uip_ds6_nbr_add drop ip addr ");
PRINT6ADDR(ipaddr);
PRINTF(" link addr (%p) ", lladdr);
PRINTLLADDR(lladdr);
PRINTF(" state %u\n", state);
LOG_INFO("Add drop ip addr ");
LOG_INFO_6ADDR(ipaddr);
LOG_INFO(" link addr (%p) ", lladdr);
LOG_INFO_LLADDR((linkaddr_t*)lladdr);
LOG_INFO(" state %u\n", state);
return NULL;
}
}
@ -237,9 +239,9 @@ uip_ds6_link_neighbor_callback(int status, int numtx)
if(nbr != NULL && nbr->state != NBR_INCOMPLETE) {
nbr->state = NBR_REACHABLE;
stimer_set(&nbr->reachable, UIP_ND6_REACHABLE_TIME / 1000);
PRINTF("uip-ds6-neighbor : received a link layer ACK : ");
PRINTLLADDR((uip_lladdr_t *)dest);
PRINTF(" is reachable.\n");
LOG_INFO("received a link layer ACK : ");
LOG_INFO_LLADDR((uip_lladdr_t *)dest);
LOG_INFO(" is reachable.\n");
}
}
#endif /* UIP_DS6_LL_NUD */
@ -264,22 +266,22 @@ uip_ds6_neighbor_periodic(void)
mimics the 6LoWPAN-ND behavior.
*/
if(uip_ds6_defrt_lookup(&nbr->ipaddr) != NULL) {
PRINTF("REACHABLE: defrt moving to DELAY (");
PRINT6ADDR(&nbr->ipaddr);
PRINTF(")\n");
LOG_INFO("REACHABLE: defrt moving to DELAY (");
LOG_INFO_6ADDR(&nbr->ipaddr);
LOG_INFO(")\n");
nbr->state = NBR_DELAY;
stimer_set(&nbr->reachable, UIP_ND6_DELAY_FIRST_PROBE_TIME);
nbr->nscount = 0;
} else {
PRINTF("REACHABLE: moving to STALE (");
PRINT6ADDR(&nbr->ipaddr);
PRINTF(")\n");
LOG_INFO("REACHABLE: moving to STALE (");
LOG_INFO_6ADDR(&nbr->ipaddr);
LOG_INFO(")\n");
nbr->state = NBR_STALE;
}
#else /* UIP_CONF_IPV6_RPL */
PRINTF("REACHABLE: moving to STALE (");
PRINT6ADDR(&nbr->ipaddr);
PRINTF(")\n");
LOG_INFO("REACHABLE: moving to STALE (");
LOG_INFO_6ADDR(&nbr->ipaddr);
LOG_INFO(")\n");
nbr->state = NBR_STALE;
#endif /* UIP_CONF_IPV6_RPL */
}
@ -289,7 +291,7 @@ uip_ds6_neighbor_periodic(void)
uip_ds6_nbr_rm(nbr);
} else if(stimer_expired(&nbr->sendns) && (uip_len == 0)) {
nbr->nscount++;
PRINTF("NBR_INCOMPLETE: NS %u\n", nbr->nscount);
LOG_INFO("NBR_INCOMPLETE: NS %u\n", nbr->nscount);
uip_nd6_ns_output(NULL, NULL, &nbr->ipaddr);
stimer_set(&nbr->sendns, uip_ds6_if.retrans_timer / 1000);
}
@ -298,14 +300,14 @@ uip_ds6_neighbor_periodic(void)
if(stimer_expired(&nbr->reachable)) {
nbr->state = NBR_PROBE;
nbr->nscount = 0;
PRINTF("DELAY: moving to PROBE\n");
LOG_INFO("DELAY: moving to PROBE\n");
stimer_set(&nbr->sendns, 0);
}
break;
case NBR_PROBE:
if(nbr->nscount >= UIP_ND6_MAX_UNICAST_SOLICIT) {
uip_ds6_defrt_t *locdefrt;
PRINTF("PROBE END\n");
LOG_INFO("PROBE END\n");
if((locdefrt = uip_ds6_defrt_lookup(&nbr->ipaddr)) != NULL) {
if (!locdefrt->isinfinite) {
uip_ds6_defrt_rm(locdefrt);
@ -314,7 +316,7 @@ uip_ds6_neighbor_periodic(void)
uip_ds6_nbr_rm(nbr);
} else if(stimer_expired(&nbr->sendns) && (uip_len == 0)) {
nbr->nscount++;
PRINTF("PROBE: NS %u\n", nbr->nscount);
LOG_INFO("PROBE: NS %u\n", nbr->nscount);
uip_nd6_ns_output(NULL, &nbr->ipaddr, &nbr->ipaddr);
stimer_set(&nbr->sendns, uip_ds6_if.retrans_timer / 1000);
}

View File

@ -45,7 +45,10 @@
#include "lib/memb.h"
#include "net/nbr-table.h"
#include <string.h>
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "IPv6 Route"
#define LOG_LEVEL IPV6_LOG_LEVEL
/* A configurable function called after adding a new neighbor as next hop */
#ifdef NETSTACK_CONF_ROUTING_NEIGHBOR_ADDED_CALLBACK
@ -86,12 +89,8 @@ MEMB(defaultroutermemb, uip_ds6_defrt_t, UIP_DS6_DEFRT_NB);
LIST(notificationlist);
#endif
#undef DEBUG
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
/*---------------------------------------------------------------------------*/
#if DEBUG != DEBUG_NONE
#if LOG_DBG_ENABLED
static void
assert_nbr_routes_list_sane(void)
{
@ -117,7 +116,7 @@ assert_nbr_routes_list_sane(void)
num_routes, count, UIP_CONF_MAX_ROUTES);
}
}
#endif /* DEBUG != DEBUG_NONE */
#endif /* LOG_DBG_ENABLED */
/*---------------------------------------------------------------------------*/
#if UIP_DS6_NOTIFICATIONS
static void
@ -258,9 +257,9 @@ uip_ds6_route_lookup(uip_ipaddr_t *addr)
uip_ds6_route_t *found_route;
uint8_t longestmatch;
PRINTF("uip-ds6-route: Looking up route for ");
PRINT6ADDR(addr);
PRINTF("\n");
LOG_INFO("Looking up route for ");
LOG_INFO_6ADDR(addr);
LOG_INFO("\n");
found_route = NULL;
@ -280,13 +279,13 @@ uip_ds6_route_lookup(uip_ipaddr_t *addr)
}
if(found_route != NULL) {
PRINTF("uip-ds6-route: Found route: ");
PRINT6ADDR(addr);
PRINTF(" via ");
PRINT6ADDR(uip_ds6_route_nexthop(found_route));
PRINTF("\n");
LOG_INFO("Found route: ");
LOG_INFO_6ADDR(addr);
LOG_INFO(" via ");
LOG_INFO_6ADDR(uip_ds6_route_nexthop(found_route));
LOG_INFO("\n");
} else {
PRINTF("uip-ds6-route: No route found\n");
LOG_WARN("No route found\n");
}
if(found_route != NULL && found_route != list_head(routelist)) {
@ -313,16 +312,16 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
uip_ds6_route_t *r;
struct uip_ds6_route_neighbor_route *nbrr;
#if DEBUG != DEBUG_NONE
#if LOG_DBG_ENABLED
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
#endif /* LOG_DBG_ENABLED */
/* Get link-layer address of next hop, make sure it is in neighbor table */
const uip_lladdr_t *nexthop_lladdr = uip_ds6_nbr_lladdr_from_ipaddr(nexthop);
if(nexthop_lladdr == NULL) {
PRINTF("uip_ds6_route_add: neighbor link-local address unknown for ");
PRINT6ADDR(nexthop);
PRINTF("\n");
LOG_WARN("Add: neighbor link-local address unknown for ");
LOG_WARN_6ADDR(nexthop);
LOG_WARN("\n");
return NULL;
}
@ -337,9 +336,9 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
/* no need to update route - already correct! */
return r;
}
PRINTF("uip_ds6_route_add: old route for ");
PRINT6ADDR(ipaddr);
PRINTF(" found, deleting it\n");
LOG_INFO("Add: old route for ");
LOG_INFO_6ADDR(ipaddr);
LOG_INFO(" found, deleting it\n");
uip_ds6_route_rm(r);
}
@ -360,9 +359,9 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
if(oldest == NULL) {
return NULL;
}
PRINTF("uip_ds6_route_add: dropping route to ");
PRINT6ADDR(&oldest->ipaddr);
PRINTF("\n");
LOG_INFO("Add: dropping route to ");
LOG_INFO_6ADDR(&oldest->ipaddr);
LOG_INFO("\n");
uip_ds6_route_rm(oldest);
}
@ -390,7 +389,7 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
if(routes == NULL) {
/* This should not happen, as we explicitly deallocated one
route table entry above. */
PRINTF("uip_ds6_route_add: could not allocate neighbor table entry\n");
LOG_ERR("Add: could not allocate neighbor table entry\n");
return NULL;
}
LIST_STRUCT_INIT(routes, route_list);
@ -405,7 +404,7 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
if(r == NULL) {
/* This should not happen, as we explicitly deallocated one
route table entry above. */
PRINTF("uip_ds6_route_add: could not allocate route\n");
LOG_ERR("Add: could not allocate route\n");
return NULL;
}
@ -417,7 +416,7 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
if(nbrr == NULL) {
/* This should not happen, as we explicitly deallocated one
route table entry above. */
PRINTF("uip_ds6_route_add: could not allocate neighbor route list entry\n");
LOG_ERR("Add: could not allocate neighbor route list entry\n");
memb_free(&routememb, r);
return NULL;
}
@ -428,7 +427,7 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
r->neighbor_routes = routes;
num_routes++;
PRINTF("uip_ds6_route_add num %d\n", num_routes);
LOG_INFO("Add: num %d\n", num_routes);
/* lock this entry so that nexthop is not removed */
nbr_table_lock(nbr_routes, routes);
@ -441,20 +440,20 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
memset(&r->state, 0, sizeof(UIP_DS6_ROUTE_STATE_TYPE));
#endif
PRINTF("uip_ds6_route_add: adding route: ");
PRINT6ADDR(ipaddr);
PRINTF(" via ");
PRINT6ADDR(nexthop);
PRINTF("\n");
ANNOTATE("#L %u 1;blue\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
LOG_INFO("Add: adding route: ");
LOG_INFO_6ADDR(ipaddr);
LOG_INFO(" via ");
LOG_INFO_6ADDR(nexthop);
LOG_INFO("\n");
LOG_ANNOTATE("#L %u 1;blue\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
#if UIP_DS6_NOTIFICATIONS
call_route_callback(UIP_DS6_NOTIFICATION_ROUTE_ADD, ipaddr, nexthop);
#endif
#if DEBUG != DEBUG_NONE
#if LOG_DBG_ENABLED
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
#endif /* LOG_DBG_ENABLED */
return r;
#else /* (UIP_CONF_MAX_ROUTES != 0) */
@ -468,14 +467,14 @@ uip_ds6_route_rm(uip_ds6_route_t *route)
{
#if (UIP_CONF_MAX_ROUTES != 0)
struct uip_ds6_route_neighbor_route *neighbor_route;
#if DEBUG != DEBUG_NONE
#if LOG_DBG_ENABLED
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
#endif /* LOG_DBG_ENABLED */
if(route != NULL && route->neighbor_routes != NULL) {
PRINTF("uip_ds6_route_rm: removing route: ");
PRINT6ADDR(&route->ipaddr);
PRINTF("\n");
LOG_INFO("Rm: removing route: ");
LOG_INFO_6ADDR(&route->ipaddr);
LOG_INFO("\n");
/* Remove the route from the route list */
list_remove(routelist, route);
@ -486,21 +485,21 @@ uip_ds6_route_rm(uip_ds6_route_t *route)
neighbor_route = list_item_next(neighbor_route));
if(neighbor_route == NULL) {
PRINTF("uip_ds6_route_rm: neighbor_route was NULL for ");
uip_debug_ipaddr_print(&route->ipaddr);
PRINTF("\n");
LOG_INFO("Rm: neighbor_route was NULL for ");
LOG_INFO_6ADDR(&route->ipaddr);
LOG_INFO("\n");
}
list_remove(route->neighbor_routes->route_list, neighbor_route);
if(list_head(route->neighbor_routes->route_list) == NULL) {
/* If this was the only route using this neighbor, remove the
neighbor from the table - this implicitly unlocks nexthop */
#if (DEBUG) & DEBUG_ANNOTATE
#if LOG_WITH_ANNOTATE
uip_ipaddr_t *nexthop = uip_ds6_route_nexthop(route);
if(nexthop != NULL) {
ANNOTATE("#L %u 0\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
LOG_ANNOTATE("#L %u 0\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
}
#endif /* (DEBUG) & DEBUG_ANNOTATE */
PRINTF("uip_ds6_route_rm: removing neighbor too\n");
#endif /* LOG_WITH_ANNOTATE */
LOG_INFO("Rm: removing neighbor too\n");
nbr_table_remove(nbr_routes, route->neighbor_routes->route_list);
#ifdef NETSTACK_CONF_ROUTING_NEIGHBOR_REMOVED_CALLBACK
NETSTACK_CONF_ROUTING_NEIGHBOR_REMOVED_CALLBACK(
@ -512,7 +511,7 @@ uip_ds6_route_rm(uip_ds6_route_t *route)
num_routes--;
PRINTF("uip_ds6_route_rm num %d\n", num_routes);
LOG_INFO("Rm: num %d\n", num_routes);
#if UIP_DS6_NOTIFICATIONS
call_route_callback(UIP_DS6_NOTIFICATION_ROUTE_RM,
@ -520,9 +519,9 @@ uip_ds6_route_rm(uip_ds6_route_t *route)
#endif
}
#if DEBUG != DEBUG_NONE
#if LOG_DBG_ENABLED
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
#endif /* LOG_DBG_ENABLED */
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
return;
@ -532,10 +531,9 @@ uip_ds6_route_rm(uip_ds6_route_t *route)
static void
rm_routelist(struct uip_ds6_route_neighbor_routes *routes)
{
#if DEBUG != DEBUG_NONE
#if LOG_DBG_ENABLED
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
PRINTF("uip_ds6_route_rm_routelist\n");
#endif /* LOG_DBG_ENABLED */
if(routes != NULL && routes->route_list != NULL) {
struct uip_ds6_route_neighbor_route *r;
r = list_head(routes->route_list);
@ -545,9 +543,9 @@ rm_routelist(struct uip_ds6_route_neighbor_routes *routes)
}
nbr_table_remove(nbr_routes, routes);
}
#if DEBUG != DEBUG_NONE
#if LOG_DBG_ENABLED
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
#endif /* LOG_DBG_ENABLED */
}
/*---------------------------------------------------------------------------*/
static void
@ -583,23 +581,23 @@ uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval)
{
uip_ds6_defrt_t *d;
#if DEBUG != DEBUG_NONE
#if LOG_DBG_ENABLED
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
#endif /* LOG_DBG_ENABLED */
PRINTF("uip_ds6_defrt_add\n");
LOG_INFO("Add default\n");
d = uip_ds6_defrt_lookup(ipaddr);
if(d == NULL) {
d = memb_alloc(&defaultroutermemb);
if(d == NULL) {
PRINTF("uip_ds6_defrt_add: could not add default route to ");
PRINT6ADDR(ipaddr);
PRINTF(", out of memory\n");
LOG_ERR("Add default: could not add default route to ");
LOG_ERR_6ADDR(ipaddr);
LOG_ERR(", out of memory\n");
return NULL;
} else {
PRINTF("uip_ds6_defrt_add: adding default route to ");
PRINT6ADDR(ipaddr);
PRINTF("\n");
LOG_INFO("Add default: adding default route to ");
LOG_INFO_6ADDR(ipaddr);
LOG_INFO("\n");
}
list_push(defaultrouterlist, d);
@ -613,15 +611,15 @@ uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval)
d->isinfinite = 1;
}
ANNOTATE("#L %u 1\n", ipaddr->u8[sizeof(uip_ipaddr_t) - 1]);
LOG_ANNOTATE("#L %u 1\n", ipaddr->u8[sizeof(uip_ipaddr_t) - 1]);
#if UIP_DS6_NOTIFICATIONS
call_route_callback(UIP_DS6_NOTIFICATION_DEFRT_ADD, ipaddr, ipaddr);
#endif
#if DEBUG != DEBUG_NONE
#if LOG_DBG_ENABLED
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
#endif /* LOG_DBG_ENABLED */
return d;
}
@ -631,19 +629,19 @@ uip_ds6_defrt_rm(uip_ds6_defrt_t *defrt)
{
uip_ds6_defrt_t *d;
#if DEBUG != DEBUG_NONE
#if LOG_DBG_ENABLED
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
#endif /* LOG_DBG_ENABLED */
/* Make sure that the defrt is in the list before we remove it. */
for(d = list_head(defaultrouterlist);
d != NULL;
d = list_item_next(d)) {
if(d == defrt) {
PRINTF("Removing default route\n");
LOG_INFO("Removing default\n");
list_remove(defaultrouterlist, defrt);
memb_free(&defaultroutermemb, defrt);
ANNOTATE("#L %u 0\n", defrt->ipaddr.u8[sizeof(uip_ipaddr_t) - 1]);
LOG_ANNOTATE("#L %u 0\n", defrt->ipaddr.u8[sizeof(uip_ipaddr_t) - 1]);
#if UIP_DS6_NOTIFICATIONS
call_route_callback(UIP_DS6_NOTIFICATION_DEFRT_RM,
&defrt->ipaddr, &defrt->ipaddr);
@ -651,9 +649,9 @@ uip_ds6_defrt_rm(uip_ds6_defrt_t *defrt)
return;
}
}
#if DEBUG != DEBUG_NONE
#if LOG_DBG_ENABLED
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
#endif /* LOG_DBG_ENABLED */
}
/*---------------------------------------------------------------------------*/
@ -682,20 +680,20 @@ uip_ds6_defrt_choose(void)
for(d = list_head(defaultrouterlist);
d != NULL;
d = list_item_next(d)) {
PRINTF("Defrt, IP address ");
PRINT6ADDR(&d->ipaddr);
PRINTF("\n");
LOG_INFO("Default route, IP address ");
LOG_INFO_6ADDR(&d->ipaddr);
LOG_INFO("\n");
bestnbr = uip_ds6_nbr_lookup(&d->ipaddr);
if(bestnbr != NULL && bestnbr->state != NBR_INCOMPLETE) {
PRINTF("Defrt found, IP address ");
PRINT6ADDR(&d->ipaddr);
PRINTF("\n");
LOG_INFO("Default route found, IP address ");
LOG_INFO_6ADDR(&d->ipaddr);
LOG_INFO("\n");
return &d->ipaddr;
} else {
addr = &d->ipaddr;
PRINTF("Defrt INCOMPLETE found, IP address ");
PRINT6ADDR(&d->ipaddr);
PRINTF("\n");
LOG_INFO("Default route Incomplete found, IP address ");
LOG_INFO_6ADDR(&d->ipaddr);
LOG_INFO("\n");
}
}
return addr;
@ -709,7 +707,7 @@ uip_ds6_defrt_periodic(void)
while(d != NULL) {
if(!d->isinfinite &&
stimer_expired(&d->lifetime)) {
PRINTF("uip_ds6_defrt_periodic: defrt lifetime expired\n");
LOG_INFO("Default route periodic: defrt lifetime expired\n");
uip_ds6_defrt_rm(d);
d = list_head(defaultrouterlist);
} else {

View File

@ -51,8 +51,10 @@
#include "net/ipv6/multicast/uip-mcast6.h"
#include "net/ip/uip-packetqueue.h"
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "IPv6 Data Structures"
#define LOG_LEVEL IPV6_LOG_LEVEL
struct etimer uip_ds6_timer_periodic; /**< Timer for maintenance of data structures */
@ -97,8 +99,7 @@ uip_ds6_init(void)
uip_ds6_neighbors_init();
uip_ds6_route_init();
PRINTF("Init of IPv6 data structures\n");
PRINTF("%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%u default routers\n%u prefixes\n%u routes\n%u unicast addresses\n%u multicast addresses\n%u anycast addresses\n",
NBR_TABLE_MAX_NEIGHBORS, UIP_DS6_DEFRT_NB, UIP_DS6_PREFIX_NB, UIP_DS6_ROUTE_NB,
UIP_DS6_ADDR_NB, UIP_DS6_MADDR_NB, UIP_DS6_AADDR_NB);
memset(uip_ds6_prefix_list, 0, sizeof(uip_ds6_prefix_list));
@ -247,13 +248,13 @@ uip_ds6_prefix_add(uip_ipaddr_t *ipaddr, uint8_t ipaddrlen,
locprefix->l_a_reserved = flags;
locprefix->vlifetime = vtime;
locprefix->plifetime = ptime;
PRINTF("Adding prefix ");
PRINT6ADDR(&locprefix->ipaddr);
PRINTF("length %u, flags %x, Valid lifetime %lx, Preffered lifetime %lx\n",
LOG_INFO("Adding prefix ");
LOG_INFO_6ADDR(&locprefix->ipaddr);
LOG_INFO("length %u, flags %x, Valid lifetime %lx, Preffered lifetime %lx\n",
ipaddrlen, flags, vtime, ptime);
return locprefix;
} else {
PRINTF("No more space in Prefix list\n");
LOG_INFO("No more space in Prefix list\n");
}
return NULL;
}
@ -277,9 +278,9 @@ uip_ds6_prefix_add(uip_ipaddr_t *ipaddr, uint8_t ipaddrlen,
} else {
locprefix->isinfinite = 1;
}
PRINTF("Adding prefix ");
PRINT6ADDR(&locprefix->ipaddr);
PRINTF("length %u, vlifetime %lu\n", ipaddrlen, interval);
LOG_INFO("Adding prefix ");
LOG_INFO_6ADDR(&locprefix->ipaddr);
LOG_INFO("length %u, vlifetime %lu\n", ipaddrlen, interval);
return locprefix;
}
return NULL;
@ -613,9 +614,9 @@ uip_ds6_dad(uip_ds6_addr_t *addr)
* If we arrive here it means DAD succeeded, otherwise the dad process
* would have been interrupted in ds6_dad_ns/na_input
*/
PRINTF("DAD succeeded, ipaddr: ");
PRINT6ADDR(&addr->ipaddr);
PRINTF("\n");
LOG_INFO("DAD succeeded, ipaddr: ");
LOG_INFO_6ADDR(&addr->ipaddr);
LOG_INFO("\n");
addr->state = ADDR_PREFERRED;
return;
@ -630,7 +631,7 @@ int
uip_ds6_dad_failed(uip_ds6_addr_t *addr)
{
if(uip_is_addr_linklocal(&addr->ipaddr)) {
PRINTF("Contiki shutdown, DAD for link local address failed\n");
LOG_ERR("Contiki shutdown, DAD for link local address failed\n");
return 0;
}
uip_ds6_addr_rm(addr);
@ -651,7 +652,7 @@ uip_ds6_send_ra_sollicited(void)
* the RA (setting the timer to 0 below). We keep the code logic for
* the days contiki will support appropriate timers */
rand_time = 0;
PRINTF("Solicited RA, random time %u\n", rand_time);
LOG_INFO("Solicited RA, random time %u\n", rand_time);
if(stimer_remaining(&uip_ds6_timer_ra) > rand_time) {
if(stimer_elapsed(&uip_ds6_timer_ra) < UIP_ND6_MIN_DELAY_BETWEEN_RAS) {
@ -672,21 +673,21 @@ uip_ds6_send_ra_periodic(void)
if(racount > 0) {
/* send previously scheduled RA */
uip_nd6_ra_output(NULL);
PRINTF("Sending periodic RA\n");
LOG_INFO("Sending periodic RA\n");
}
rand_time = UIP_ND6_MIN_RA_INTERVAL + random_rand() %
(uint16_t) (UIP_ND6_MAX_RA_INTERVAL - UIP_ND6_MIN_RA_INTERVAL);
PRINTF("Random time 1 = %u\n", rand_time);
LOG_DBG("Random time 1 = %u\n", rand_time);
if(racount < UIP_ND6_MAX_INITIAL_RAS) {
if(rand_time > UIP_ND6_MAX_INITIAL_RA_INTERVAL) {
rand_time = UIP_ND6_MAX_INITIAL_RA_INTERVAL;
PRINTF("Random time 2 = %u\n", rand_time);
LOG_DBG("Random time 2 = %u\n", rand_time);
}
racount++;
}
PRINTF("Random time 3 = %u\n", rand_time);
LOG_DBG("Random time 3 = %u\n", rand_time);
stimer_set(&uip_ds6_timer_ra, rand_time);
}
@ -698,13 +699,13 @@ uip_ds6_send_rs(void)
{
if((uip_ds6_defrt_choose() == NULL)
&& (rscount < UIP_ND6_MAX_RTR_SOLICITATIONS)) {
PRINTF("Sending RS %u\n", rscount);
LOG_INFO("Sending RS %u\n", rscount);
uip_nd6_rs_output();
rscount++;
etimer_set(&uip_ds6_timer_rs,
UIP_ND6_RTR_SOLICITATION_INTERVAL * CLOCK_SECOND);
} else {
PRINTF("Router found ? (boolean): %u\n",
LOG_INFO("Router found ? (boolean): %u\n",
(uip_ds6_defrt_choose() != NULL));
etimer_stop(&uip_ds6_timer_rs);
}

View File

@ -47,16 +47,10 @@
#include "net/ipv6/uip-icmp6.h"
#include "contiki-default-conf.h"
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#define PRINT6ADDR(addr) PRINTF(" %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x ", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15])
#define PRINTLLADDR(lladdr) PRINTF(" %02x:%02x:%02x:%02x:%02x:%02x ",lladdr->addr[0], lladdr->addr[1], lladdr->addr[2], lladdr->addr[3],lladdr->addr[4], lladdr->addr[5])
#else
#define PRINTF(...)
#define PRINT6ADDR(addr)
#endif
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "IPv6 ICMPv6"
#define LOG_LEVEL IPV6_LOG_LEVEL
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
@ -125,11 +119,11 @@ echo_request_input(void)
* headers in the request otherwise we need to remove the extension
* headers and change a few fields
*/
PRINTF("Received Echo Request from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(" to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF("\n");
LOG_INFO("Received Echo Request from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO(" to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO("\n");
/* IP header */
UIP_IP_BUF->ttl = uip_ds6_if.cur_hop_limit;
@ -170,11 +164,11 @@ echo_request_input(void)
UIP_ICMP_BUF->icmpchksum = 0;
UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();
PRINTF("Sending Echo Reply to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF(" from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF("\n");
LOG_INFO("Sending Echo Reply to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO(" from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO("\n");
UIP_STAT(++uip_stat.icmp.sent);
return;
}
@ -257,11 +251,11 @@ uip_icmp6_error_output(uint8_t type, uint8_t code, uint32_t param) {
UIP_STAT(++uip_stat.icmp.sent);
PRINTF("Sending ICMPv6 ERROR message type %d code %d to ", type, code);
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF(" from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF("\n");
LOG_WARN("Sending ICMPv6 ERROR message type %d code %d to ", type, code);
LOG_WARN_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_WARN(" from ");
LOG_WARN_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_WARN("\n");
return;
}
@ -301,11 +295,11 @@ echo_reply_input(void)
int ttl;
uip_ipaddr_t sender;
PRINTF("Received Echo Reply from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(" to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF("\n");
LOG_INFO("Received Echo Reply from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO(" to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO("\n");
uip_ipaddr_copy(&sender, &UIP_IP_BUF->srcipaddr);
ttl = UIP_IP_BUF->ttl;

View File

@ -75,18 +75,10 @@
#include "net/ip/uip-nameserver.h"
#include "lib/random.h"
/*------------------------------------------------------------------*/
#define DEBUG 0
#include "net/ip/uip-debug.h"
#if UIP_LOGGING
#include <stdio.h>
void uip_log(char *msg);
#define UIP_LOG(m) uip_log(m)
#else
#define UIP_LOG(m)
#endif /* UIP_LOGGING == 1 */
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "IPv6 NDP"
#define LOG_LEVEL IPV6_LOG_LEVEL
/*------------------------------------------------------------------*/
/** @{ */
@ -186,20 +178,20 @@ static void
ns_input(void)
{
uint8_t flags;
PRINTF("Received NS from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(" to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF(" with target address ");
PRINT6ADDR((uip_ipaddr_t *) (&UIP_ND6_NS_BUF->tgtipaddr));
PRINTF("\n");
LOG_INFO("Received NS from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO(" to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO(" with target address ");
LOG_INFO_6ADDR((uip_ipaddr_t *) (&UIP_ND6_NS_BUF->tgtipaddr));
LOG_INFO("\n");
UIP_STAT(++uip_stat.nd6.recv);
#if UIP_CONF_IPV6_CHECKS
if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||
(uip_is_addr_mcast(&UIP_ND6_NS_BUF->tgtipaddr)) ||
(UIP_ICMP_BUF->icode != 0)) {
PRINTF("NS received is bad\n");
LOG_ERR("NS received is bad\n");
goto discard;
}
#endif /* UIP_CONF_IPV6_CHECKS */
@ -210,7 +202,7 @@ ns_input(void)
while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {
#if UIP_CONF_IPV6_CHECKS
if(UIP_ND6_OPT_HDR_BUF->len == 0) {
PRINTF("NS received is bad\n");
LOG_ERR("NS received is bad\n");
goto discard;
}
#endif /* UIP_CONF_IPV6_CHECKS */
@ -220,7 +212,7 @@ ns_input(void)
#if UIP_CONF_IPV6_CHECKS
/* There must be NO option in a DAD NS */
if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {
PRINTF("NS received is bad\n");
LOG_ERR("NS received is bad\n");
goto discard;
} else {
#endif /*UIP_CONF_IPV6_CHECKS */
@ -253,7 +245,7 @@ ns_input(void)
#endif /*UIP_CONF_IPV6_CHECKS */
break;
default:
PRINTF("ND option not supported in NS");
LOG_WARN("ND option not supported in NS");
break;
}
nd6_opt_offset += (UIP_ND6_OPT_HDR_BUF->len << 3);
@ -266,7 +258,7 @@ ns_input(void)
#if UIP_ND6_DEF_MAXDADNS > 0
#if UIP_CONF_IPV6_CHECKS
if(!uip_is_addr_solicited_node(&UIP_IP_BUF->destipaddr)) {
PRINTF("NS received is bad\n");
LOG_ERR("NS received is bad\n");
goto discard;
}
#endif /* UIP_CONF_IPV6_CHECKS */
@ -292,7 +284,7 @@ ns_input(void)
* NA in response of DAD NS we sent, hence DAD will fail anyway. If we
* were not doing DAD, it means there is a duplicate in the network!
*/
PRINTF("NS received is bad\n");
LOG_ERR("NS received is bad\n");
goto discard;
}
#endif /*UIP_CONF_IPV6_CHECKS */
@ -313,7 +305,7 @@ ns_input(void)
goto create_na;
} else {
#if UIP_CONF_IPV6_CHECKS
PRINTF("NS received is bad\n");
LOG_ERR("NS received is bad\n");
goto discard;
#endif /* UIP_CONF_IPV6_CHECKS */
}
@ -352,13 +344,13 @@ create_na:
UIP_IPH_LEN + UIP_ICMPH_LEN + UIP_ND6_NA_LEN + UIP_ND6_OPT_LLAO_LEN;
UIP_STAT(++uip_stat.nd6.sent);
PRINTF("Sending NA to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF(" from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(" with target address ");
PRINT6ADDR(&UIP_ND6_NA_BUF->tgtipaddr);
PRINTF("\n");
LOG_INFO("Sending NA to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO(" from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO(" with target address ");
LOG_INFO_6ADDR(&UIP_ND6_NA_BUF->tgtipaddr);
LOG_INFO("\n");
return;
discard:
@ -401,7 +393,7 @@ uip_nd6_ns_output(uip_ipaddr_t * src, uip_ipaddr_t * dest, uip_ipaddr_t * tgt)
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
}
if (uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {
PRINTF("Dropping NS due to no suitable source address\n");
LOG_ERR("Dropping NS due to no suitable source address\n");
uip_clear_buf();
return;
}
@ -423,13 +415,13 @@ uip_nd6_ns_output(uip_ipaddr_t * src, uip_ipaddr_t * dest, uip_ipaddr_t * tgt)
UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();
UIP_STAT(++uip_stat.nd6.sent);
PRINTF("Sending NS to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF(" from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(" with target address ");
PRINT6ADDR(tgt);
PRINTF("\n");
LOG_INFO("Sending NS to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO(" from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO(" with target address ");
LOG_INFO_6ADDR(tgt);
LOG_INFO("\n");
return;
}
#endif /* UIP_ND6_SEND_NS */
@ -462,13 +454,13 @@ na_input(void)
uint8_t is_override;
uip_lladdr_t lladdr_aligned;
PRINTF("Received NA from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(" to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF(" with target address ");
PRINT6ADDR((uip_ipaddr_t *) (&UIP_ND6_NA_BUF->tgtipaddr));
PRINTF("\n");
LOG_INFO("Received NA from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO(" to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO(" with target address ");
LOG_INFO_6ADDR((uip_ipaddr_t *) (&UIP_ND6_NA_BUF->tgtipaddr));
LOG_INFO("\n");
UIP_STAT(++uip_stat.nd6.recv);
/*
@ -487,7 +479,7 @@ na_input(void)
(UIP_ICMP_BUF->icode != 0) ||
(uip_is_addr_mcast(&UIP_ND6_NA_BUF->tgtipaddr)) ||
(is_solicited && uip_is_addr_mcast(&UIP_IP_BUF->destipaddr))) {
PRINTF("NA received is bad\n");
LOG_ERR("NA received is bad\n");
goto discard;
}
#endif /*UIP_CONF_IPV6_CHECKS */
@ -498,7 +490,7 @@ na_input(void)
while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {
#if UIP_CONF_IPV6_CHECKS
if(UIP_ND6_OPT_HDR_BUF->len == 0) {
PRINTF("NA received is bad\n");
LOG_ERR("NA received is bad\n");
goto discard;
}
#endif /*UIP_CONF_IPV6_CHECKS */
@ -507,7 +499,7 @@ na_input(void)
nd6_opt_llao = (uint8_t *)UIP_ND6_OPT_HDR_BUF;
break;
default:
PRINTF("ND option not supported in NA\n");
LOG_WARN("ND option not supported in NA\n");
break;
}
nd6_opt_offset += (UIP_ND6_OPT_HDR_BUF->len << 3);
@ -520,7 +512,7 @@ na_input(void)
uip_ds6_dad_failed(addr);
}
#endif /*UIP_ND6_DEF_MAXDADNS > 0 */
PRINTF("NA received is bad\n");
LOG_ERR("NA received is bad\n");
goto discard;
} else {
const uip_lladdr_t *lladdr;
@ -618,11 +610,11 @@ static void
rs_input(void)
{
PRINTF("Received RS from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(" to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF("\n");
LOG_INFO("Received RS from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO(" to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO("\n");
UIP_STAT(++uip_stat.nd6.recv);
@ -633,7 +625,7 @@ rs_input(void)
* if the NA is solicited, dest must not be multicast
*/
if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) || (UIP_ICMP_BUF->icode != 0)) {
PRINTF("RS received is bad\n");
LOG_ERR("RS received is bad\n");
goto discard;
}
#endif /*UIP_CONF_IPV6_CHECKS */
@ -646,7 +638,7 @@ rs_input(void)
while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {
#if UIP_CONF_IPV6_CHECKS
if(UIP_ND6_OPT_HDR_BUF->len == 0) {
PRINTF("RS received is bad\n");
LOG_ERR("RS received is bad\n");
goto discard;
}
#endif /*UIP_CONF_IPV6_CHECKS */
@ -655,7 +647,7 @@ rs_input(void)
nd6_opt_llao = (uint8_t *)UIP_ND6_OPT_HDR_BUF;
break;
default:
PRINTF("ND option not supported in RS\n");
LOG_WARN("ND option not supported in RS\n");
break;
}
nd6_opt_offset += (UIP_ND6_OPT_HDR_BUF->len << 3);
@ -664,7 +656,7 @@ rs_input(void)
if(nd6_opt_llao != NULL) {
#if UIP_CONF_IPV6_CHECKS
if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {
PRINTF("RS received is bad\n");
LOG_ERR("RS received is bad\n");
goto discard;
} else {
#endif /*UIP_CONF_IPV6_CHECKS */
@ -792,7 +784,7 @@ uip_nd6_ra_output(uip_ipaddr_t * dest)
i++;
}
UIP_ND6_OPT_RDNSS_BUF->len = UIP_ND6_OPT_RDNSS_LEN + (i << 1);
PRINTF("%d nameservers reported\n", i);
LOG_INFO("%d nameservers reported\n", i);
uip_len += UIP_ND6_OPT_RDNSS_BUF->len << 3;
nd6_opt_offset += UIP_ND6_OPT_RDNSS_BUF->len << 3;
}
@ -806,11 +798,11 @@ uip_nd6_ra_output(uip_ipaddr_t * dest)
UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();
UIP_STAT(++uip_stat.nd6.sent);
PRINTF("Sending RA to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF(" from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF("\n");
LOG_INFO("Sending RA to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO(" from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO("\n");
return;
}
#endif /* UIP_ND6_SEND_RA */
@ -848,11 +840,11 @@ uip_nd6_rs_output(void)
UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();
UIP_STAT(++uip_stat.nd6.sent);
PRINTF("Sendin RS to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF(" from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF("\n");
LOG_INFO("Sending RS to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO(" from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO("\n");
return;
}
/*---------------------------------------------------------------------------*/
@ -870,25 +862,25 @@ ra_input(void)
{
uip_lladdr_t lladdr_aligned;
PRINTF("Received RA from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(" to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF("\n");
LOG_INFO("Received RA from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO(" to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO("\n");
UIP_STAT(++uip_stat.nd6.recv);
#if UIP_CONF_IPV6_CHECKS
if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||
(!uip_is_addr_linklocal(&UIP_IP_BUF->srcipaddr)) ||
(UIP_ICMP_BUF->icode != 0)) {
PRINTF("RA received is bad");
LOG_ERR("RA received is bad");
goto discard;
}
#endif /*UIP_CONF_IPV6_CHECKS */
if(UIP_ND6_RA_BUF->cur_ttl != 0) {
uip_ds6_if.cur_hop_limit = UIP_ND6_RA_BUF->cur_ttl;
PRINTF("uip_ds6_if.cur_hop_limit %u\n", uip_ds6_if.cur_hop_limit);
LOG_INFO("uip_ds6_if.cur_hop_limit %u\n", uip_ds6_if.cur_hop_limit);
}
if(UIP_ND6_RA_BUF->reachable_time != 0) {
@ -906,12 +898,12 @@ ra_input(void)
nd6_opt_offset = UIP_ND6_RA_LEN;
while(uip_l3_icmp_hdr_len + nd6_opt_offset < uip_len) {
if(UIP_ND6_OPT_HDR_BUF->len == 0) {
PRINTF("RA received is bad");
LOG_ERR("RA received is bad");
goto discard;
}
switch (UIP_ND6_OPT_HDR_BUF->type) {
case UIP_ND6_OPT_SLLAO:
PRINTF("Processing SLLAO option in RA\n");
LOG_DBG("Processing SLLAO option in RA\n");
nd6_opt_llao = (uint8_t *) UIP_ND6_OPT_HDR_BUF;
nbr = uip_ds6_nbr_lookup(&UIP_IP_BUF->srcipaddr);
if(!extract_lladdr_from_llao_aligned(&lladdr_aligned)) {
@ -942,12 +934,12 @@ ra_input(void)
}
break;
case UIP_ND6_OPT_MTU:
PRINTF("Processing MTU option in RA\n");
LOG_DBG("Processing MTU option in RA\n");
uip_ds6_if.link_mtu =
uip_ntohl(((uip_nd6_opt_mtu *) UIP_ND6_OPT_HDR_BUF)->mtu);
break;
case UIP_ND6_OPT_PREFIX_INFO:
PRINTF("Processing PREFIX option in RA\n");
LOG_DBG("Processing PREFIX option in RA\n");
nd6_opt_prefix_info = (uip_nd6_opt_prefix_info *) UIP_ND6_OPT_HDR_BUF;
if((uip_ntohl(nd6_opt_prefix_info->validlt) >=
uip_ntohl(nd6_opt_prefix_info->preferredlt))
@ -978,9 +970,9 @@ ra_input(void)
prefix->isinfinite = 1;
break;
default:
PRINTF("Updating timer of prefix ");
PRINT6ADDR(&prefix->ipaddr);
PRINTF(" new value %lu\n", uip_ntohl(nd6_opt_prefix_info->validlt));
LOG_DBG("Updating timer of prefix ");
LOG_DBG_6ADDR(&prefix->ipaddr);
LOG_DBG(" new value %lu\n", uip_ntohl(nd6_opt_prefix_info->validlt));
stimer_set(&prefix->vlifetime,
uip_ntohl(nd6_opt_prefix_info->validlt));
prefix->isinfinite = 0;
@ -1003,17 +995,17 @@ ra_input(void)
if((uip_ntohl(nd6_opt_prefix_info->validlt) > 2 * 60 * 60) ||
(uip_ntohl(nd6_opt_prefix_info->validlt) >
stimer_remaining(&addr->vlifetime))) {
PRINTF("Updating timer of address ");
PRINT6ADDR(&addr->ipaddr);
PRINTF(" new value %lu\n",
LOG_DBG("Updating timer of address ");
LOG_DBG_6ADDR(&addr->ipaddr);
LOG_DBG(" new value %lu\n",
uip_ntohl(nd6_opt_prefix_info->validlt));
stimer_set(&addr->vlifetime,
uip_ntohl(nd6_opt_prefix_info->validlt));
} else {
stimer_set(&addr->vlifetime, 2 * 60 * 60);
PRINTF("Updating timer of address ");
PRINT6ADDR(&addr->ipaddr);
PRINTF(" new value %lu\n", (unsigned long)(2 * 60 * 60));
LOG_DBG("Updating timer of address ");
LOG_DBG_6ADDR(&addr->ipaddr);
LOG_DBG(" new value %lu\n", (unsigned long)(2 * 60 * 60));
}
addr->isinfinite = 0;
} else {
@ -1035,14 +1027,14 @@ ra_input(void)
#if UIP_ND6_RA_RDNSS
case UIP_ND6_OPT_RDNSS:
if(UIP_ND6_RA_BUF->flags_reserved & (UIP_ND6_O_FLAG << 6)) {
PRINTF("Processing RDNSS option\n");
LOG_DBG("Processing RDNSS option\n");
uint8_t naddr = (UIP_ND6_OPT_RDNSS_BUF->len - 1) / 2;
uip_ipaddr_t *ip = (uip_ipaddr_t *)(&UIP_ND6_OPT_RDNSS_BUF->ip);
PRINTF("got %d nameservers\n", naddr);
LOG_DBG("got %d nameservers\n", naddr);
while(naddr-- > 0) {
PRINTF(" nameserver: ");
PRINT6ADDR(ip);
PRINTF(" lifetime: %lx\n", uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime));
LOG_DBG(" nameserver: ");
LOG_DBG_6ADDR(ip);
LOG_DBG(" lifetime: %lx\n", uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime));
uip_nameserver_update(ip, uip_ntohl(UIP_ND6_OPT_RDNSS_BUF->lifetime));
ip++;
}
@ -1050,7 +1042,7 @@ ra_input(void)
break;
#endif /* UIP_ND6_RA_RDNSS */
default:
PRINTF("ND option not supported in RA");
LOG_ERR("ND option not supported in RA");
break;
}
nd6_opt_offset += (UIP_ND6_OPT_HDR_BUF->len << 3);

View File

@ -89,27 +89,10 @@
#include "net/ipv6/uip-ds6-nbr.h"
#endif /* UIP_ND6_SEND_NS */
#include <string.h>
/*---------------------------------------------------------------------------*/
/* For Debug, logging, statistics */
/*---------------------------------------------------------------------------*/
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
#if UIP_LOGGING == 1
#include <stdio.h>
void uip_log(char *msg);
#define UIP_LOG(m) uip_log(m)
#else
#define UIP_LOG(m)
#endif /* UIP_LOGGING == 1 */
#if UIP_STATISTICS == 1
struct uip_stats uip_stat;
#endif /* UIP_STATISTICS == 1 */
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "IPv6"
#define LOG_LEVEL IPV6_LOG_LEVEL
/*---------------------------------------------------------------------------*/
/**
@ -366,7 +349,7 @@ uip_ipchksum(void)
uint16_t sum;
sum = chksum(0, &uip_buf[UIP_LLH_LEN], UIP_IPH_LEN);
PRINTF("uip_ipchksum: sum 0x%04x\n", sum);
LOG_DBG("uip_ipchksum: sum 0x%04x\n", sum);
return (sum == 0) ? 0xffff : uip_htons(sum);
}
#endif
@ -388,7 +371,7 @@ upper_layer_chksum(uint8_t proto)
upper_layer_len = (((uint16_t)(UIP_IP_BUF->len[0]) << 8) + UIP_IP_BUF->len[1] - uip_ext_len);
PRINTF("Upper layer checksum len: %d from: %d\n", upper_layer_len,
LOG_DBG("Upper layer checksum len: %d from: %d\n", upper_layer_len,
UIP_IPH_LEN + UIP_LLH_LEN + uip_ext_len);
/* First sum pseudoheader. */
@ -538,10 +521,10 @@ remove_ext_hdr(void)
{
/* Remove ext header before TCP/UDP processing. */
if(uip_ext_len > 0) {
PRINTF("Cutting ext-header before processing (extlen: %d, uiplen: %d)\n",
LOG_DBG("Cutting ext-header before processing (extlen: %d, uiplen: %d)\n",
uip_ext_len, uip_len);
if(uip_len < UIP_IPH_LEN + uip_ext_len) {
PRINTF("ERROR: uip_len too short compared to ext len\n");
LOG_ERR("ERROR: uip_len too short compared to ext len\n");
uip_clear_buf();
return;
}
@ -677,7 +660,7 @@ uip_reass(void)
/* We first write the unfragmentable part of IP header into the reassembly
buffer. The reset the other reassembly variables. */
if(uip_reass_on == 0) {
PRINTF("Starting reassembly\n");
LOG_INFO("Starting reassembly\n");
memcpy(FBUF, UIP_IP_BUF, uip_ext_len + UIP_IPH_LEN);
/* temporary in case we do not receive the fragment with offset 0 first */
etimer_set(&uip_reass_timer, UIP_REASS_MAXAGE*CLOCK_SECOND);
@ -698,8 +681,8 @@ uip_reass(void)
len = uip_len - uip_ext_len - UIP_IPH_LEN - UIP_FRAGH_LEN;
offset = (uip_ntohs(UIP_FRAG_BUF->offsetresmore) & 0xfff8);
/* in byte, originaly in multiple of 8 bytes*/
PRINTF("len %d\n", len);
PRINTF("offset %d\n", offset);
LOG_INFO("len %d\n", len);
LOG_INFO("offset %d\n", offset);
if(offset == 0){
uip_reassflags |= UIP_REASS_FLAG_FIRSTFRAG;
/*
@ -709,11 +692,11 @@ uip_reass(void)
*/
*uip_next_hdr = UIP_FRAG_BUF->next;
memcpy(FBUF, UIP_IP_BUF, uip_ext_len + UIP_IPH_LEN);
PRINTF("src ");
PRINT6ADDR(&FBUF->srcipaddr);
PRINTF("dest ");
PRINT6ADDR(&FBUF->destipaddr);
PRINTF("next %d\n", UIP_IP_BUF->proto);
LOG_INFO("src ");
LOG_INFO_6ADDR(&FBUF->srcipaddr);
LOG_INFO("dest ");
LOG_INFO_6ADDR(&FBUF->destipaddr);
LOG_INFO("next %d\n", UIP_IP_BUF->proto);
}
@ -732,7 +715,7 @@ uip_reass(void)
uip_reassflags |= UIP_REASS_FLAG_LASTFRAG;
/*calculate the size of the entire packet*/
uip_reasslen = offset + len;
PRINTF("LAST FRAGMENT reasslen %d\n", uip_reasslen);
LOG_INFO("last fragment reasslen %d\n", uip_reasslen);
} else {
/* If len is not a multiple of 8 octets and the M flag of that fragment
is 1, then that fragment must be discarded and an ICMP Parameter
@ -800,14 +783,14 @@ uip_reass(void)
memcpy(UIP_IP_BUF, FBUF, uip_reasslen);
UIP_IP_BUF->len[0] = ((uip_reasslen - UIP_IPH_LEN) >> 8);
UIP_IP_BUF->len[1] = ((uip_reasslen - UIP_IPH_LEN) & 0xff);
PRINTF("REASSEMBLED PAQUET %d (%d)\n", uip_reasslen,
LOG_INFO("reassembled packet %d (%d)\n", uip_reasslen,
(UIP_IP_BUF->len[0] << 8) | UIP_IP_BUF->len[1]);
return uip_reasslen;
}
} else {
PRINTF("Already reassembling another paquet\n");
LOG_WARN("Already reassembling another paquet\n");
}
return 0;
}
@ -821,7 +804,7 @@ uip_reass_over(void)
etimer_stop(&uip_reass_timer);
if(uip_reassflags & UIP_REASS_FLAG_FIRSTFRAG){
PRINTF("FRAG INTERRUPTED TOO LATE\n");
LOG_ERR("fragmentation timeout\n");
/* If the first fragment has been received, an ICMP Time Exceeded
-- Fragment Reassembly Time Exceeded message should be sent to the
source of that fragment. */
@ -877,11 +860,11 @@ ext_hdr_options_process(void)
* hence we can only have
*/
case UIP_EXT_HDR_OPT_PAD1:
PRINTF("Processing PAD1 option\n");
LOG_DBG("Processing PAD1 option\n");
uip_ext_opt_offset += 1;
break;
case UIP_EXT_HDR_OPT_PADN:
PRINTF("Processing PADN option\n");
LOG_DBG("Processing PADN option\n");
uip_ext_opt_offset += UIP_EXT_HDR_OPT_PADN_BUF->opt_len + 2;
break;
case UIP_EXT_HDR_OPT_RPL:
@ -894,9 +877,9 @@ ext_hdr_options_process(void)
* present) is processed.
*/
#if UIP_CONF_IPV6_RPL
PRINTF("Processing RPL option\n");
LOG_DBG("Processing RPL option\n");
if(!rpl_verify_hbh_header(uip_ext_opt_offset)) {
PRINTF("RPL Option Error: Dropping Packet\n");
LOG_ERR("RPL Option Error: Dropping Packet\n");
return 1;
}
#endif /* UIP_CONF_IPV6_RPL */
@ -916,7 +899,7 @@ ext_hdr_options_process(void)
* Problem, Code 2, message to the packet's Source Address,
* pointing to the unrecognized Option Type.
*/
PRINTF("MSB %x\n", UIP_EXT_HDR_OPT_BUF->type);
LOG_DBG("MSB %x\n", UIP_EXT_HDR_OPT_BUF->type);
switch(UIP_EXT_HDR_OPT_BUF->type & 0xC0) {
case 0:
break;
@ -1113,7 +1096,7 @@ uip_process(uint8_t flag)
if((UIP_IP_BUF->vtc & 0xf0) != 0x60) { /* IP version and header length. */
UIP_STAT(++uip_stat.ip.drop);
UIP_STAT(++uip_stat.ip.vhlerr);
UIP_LOG("ipv6: invalid version.");
LOG_ERR("invalid version.");
goto drop;
}
/*
@ -1139,19 +1122,19 @@ uip_process(uint8_t flag)
* header (40 bytes).
*/
} else {
UIP_LOG("ip: packet shorter than reported in IP header.");
LOG_ERR("packet shorter than reported in IP header.");
goto drop;
}
PRINTF("IPv6 packet received from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(" to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF("\n");
LOG_INFO("packet received from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO(" to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO("\n");
if(uip_is_addr_mcast(&UIP_IP_BUF->srcipaddr)){
UIP_STAT(++uip_stat.ip.drop);
PRINTF("Dropping packet, src is mcast\n");
LOG_ERR("Dropping packet, src is mcast\n");
goto drop;
}
@ -1182,11 +1165,11 @@ uip_process(uint8_t flag)
uip_ext_len += (UIP_EXT_BUF->len << 3) + 8;
break;
case 1:
PRINTF("Dropping packet after extension header processing\n");
LOG_ERR("Dropping packet after extension header processing\n");
/* silently discard */
goto drop;
case 2:
PRINTF("Sending error message after extension header processing\n");
LOG_ERR("Sending error message after extension header processing\n");
/* send icmp error message (created in ext_hdr_options_process)
* and discard*/
goto send;
@ -1241,9 +1224,9 @@ uip_process(uint8_t flag)
}
UIP_IP_BUF->ttl = UIP_IP_BUF->ttl - 1;
PRINTF("Forwarding packet to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF("\n");
LOG_INFO("Forwarding packet to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO("\n");
UIP_STAT(++uip_stat.ip.forwarded);
goto send;
} else {
@ -1252,12 +1235,12 @@ uip_process(uint8_t flag)
(!uip_is_addr_loopback(&UIP_IP_BUF->destipaddr)) &&
(!uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) &&
(!uip_ds6_is_addr_onlink((&UIP_IP_BUF->destipaddr)))) {
PRINTF("LL source address with off link destination, dropping\n");
LOG_ERR("LL source address with off link destination, dropping\n");
uip_icmp6_error_output(ICMP6_DST_UNREACH,
ICMP6_DST_UNREACH_NOTNEIGHBOR, 0);
goto send;
}
PRINTF("Dropping packet, not for me and link local or multicast\n");
LOG_ERR("Dropping packet, not for me and link local or multicast\n");
UIP_STAT(++uip_stat.ip.drop);
goto drop;
}
@ -1266,7 +1249,7 @@ uip_process(uint8_t flag)
if(!uip_ds6_is_my_addr(&UIP_IP_BUF->destipaddr) &&
!uip_ds6_is_my_maddr(&UIP_IP_BUF->destipaddr) &&
!uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) {
PRINTF("Dropping packet, not for me\n");
LOG_ERR("Dropping packet, not for me\n");
UIP_STAT(++uip_stat.ip.drop);
goto drop;
}
@ -1300,7 +1283,7 @@ uip_process(uint8_t flag)
/* ICMPv6 */
goto icmp6_input;
case UIP_PROTO_HBHO:
PRINTF("Processing hbh header\n");
LOG_DBG("Processing hbh header\n");
/* Hop by hop option header */
#if UIP_CONF_IPV6_CHECKS
/* Hop by hop option header. If we saw one HBH already, drop */
@ -1328,7 +1311,7 @@ uip_process(uint8_t flag)
case UIP_PROTO_DESTO:
#if UIP_CONF_IPV6_CHECKS
/* Destination option header. if we saw two already, drop */
PRINTF("Processing desto header\n");
LOG_DBG("Processing desto header\n");
if(uip_ext_bitmap & UIP_EXT_HDR_BITMAP_DESTO1) {
if(uip_ext_bitmap & UIP_EXT_HDR_BITMAP_DESTO2) {
goto bad_hdr;
@ -1371,7 +1354,7 @@ uip_process(uint8_t flag)
* to the routing type
*/
PRINTF("Processing Routing header\n");
LOG_DBG("Processing Routing header\n");
if(UIP_ROUTING_BUF->seg_left > 0) {
#if UIP_CONF_IPV6_RPL && RPL_WITH_NON_STORING
if(rpl_process_srh_header()) {
@ -1380,7 +1363,7 @@ uip_process(uint8_t flag)
#endif /* UIP_CONF_IPV6_RPL && RPL_WITH_NON_STORING */
uip_icmp6_error_output(ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, UIP_IPH_LEN + uip_ext_len + 2);
UIP_STAT(++uip_stat.ip.drop);
UIP_LOG("ip6: unrecognized routing type");
LOG_ERR("unrecognized routing type");
goto send;
}
uip_next_hdr = &UIP_EXT_BUF->next;
@ -1389,7 +1372,7 @@ uip_process(uint8_t flag)
case UIP_PROTO_FRAG:
/* Fragmentation header:call the reassembly function, then leave */
#if UIP_CONF_IPV6_REASSEMBLY
PRINTF("Processing frag header\n");
LOG_INFO("Processing fragmentation header\n");
uip_len = uip_reass();
if(uip_len == 0) {
goto drop;
@ -1400,7 +1383,7 @@ uip_process(uint8_t flag)
}
/*packet is reassembled, reset the next hdr to the beginning
of the IP header and restart the parsing of the reassembled pkt*/
PRINTF("Processing reassembled packet\n");
LOG_INFO("Processing reassembled packet\n");
uip_ext_len = 0;
uip_ext_bitmap = 0;
uip_next_hdr = &UIP_IP_BUF->proto;
@ -1408,7 +1391,7 @@ uip_process(uint8_t flag)
#else /* UIP_CONF_IPV6_REASSEMBLY */
UIP_STAT(++uip_stat.ip.drop);
UIP_STAT(++uip_stat.ip.fragerr);
UIP_LOG("ip: fragment dropped.");
LOG_ERR("fragment dropped.");
goto drop;
#endif /* UIP_CONF_IPV6_REASSEMBLY */
case UIP_PROTO_NONE:
@ -1425,21 +1408,20 @@ uip_process(uint8_t flag)
uip_icmp6_error_output(ICMP6_PARAM_PROB, ICMP6_PARAMPROB_NEXTHEADER, (uint32_t)(uip_next_hdr - (uint8_t *)UIP_IP_BUF));
UIP_STAT(++uip_stat.ip.drop);
UIP_STAT(++uip_stat.ip.protoerr);
UIP_LOG("ip6: unrecognized header");
LOG_ERR("unrecognized header");
goto send;
/* End of headers processing */
icmp6_input:
/* This is IPv6 ICMPv6 processing code. */
PRINTF("icmp6_input: length %d type: %d \n", uip_len, UIP_ICMP_BUF->type);
LOG_INFO("icmp6: input length %d type: %d \n", uip_len, UIP_ICMP_BUF->type);
#if UIP_CONF_IPV6_CHECKS
/* Compute and check the ICMP header checksum */
if(uip_icmp6chksum() != 0xffff) {
UIP_STAT(++uip_stat.icmp.drop);
UIP_STAT(++uip_stat.icmp.chkerr);
UIP_LOG("icmpv6: bad checksum.");
PRINTF("icmpv6: bad checksum.\n");
LOG_ERR("icmpv6: bad checksum.");
goto drop;
}
#endif /*UIP_CONF_IPV6_CHECKS*/
@ -1464,10 +1446,10 @@ uip_process(uint8_t flag)
*/
if(uip_icmp6_input(UIP_ICMP_BUF->type,
UIP_ICMP_BUF->icode) == UIP_ICMP6_INPUT_ERROR) {
PRINTF("Unknown ICMPv6 message type/code %d\n", UIP_ICMP_BUF->type);
LOG_ERR("Unknown ICMPv6 message type/code %d\n", UIP_ICMP_BUF->type);
UIP_STAT(++uip_stat.icmp.drop);
UIP_STAT(++uip_stat.icmp.typeerr);
UIP_LOG("icmp6: unknown ICMPv6 message.");
LOG_ERR("icmp6: unknown ICMPv6 message.");
uip_clear_buf();
}
@ -1486,7 +1468,7 @@ uip_process(uint8_t flag)
remove_ext_hdr();
UIP_IP_BUF->proto = UIP_PROTO_UDP;
PRINTF("Receiving UDP packet\n");
LOG_INFO("Receiving UDP packet\n");
/* UDP processing is really just a hack. We don't do anything to the
UDP/IP headers, but let the UDP application do all the hard
@ -1501,7 +1483,7 @@ uip_process(uint8_t flag)
if(UIP_UDP_BUF->udpchksum != 0 && uip_udpchksum() != 0xffff) {
UIP_STAT(++uip_stat.udp.drop);
UIP_STAT(++uip_stat.udp.chkerr);
PRINTF("udp: bad checksum 0x%04x 0x%04x\n", UIP_UDP_BUF->udpchksum,
LOG_ERR("udp: bad checksum 0x%04x 0x%04x\n", UIP_UDP_BUF->udpchksum,
uip_udpchksum());
goto drop;
}
@ -1509,7 +1491,7 @@ uip_process(uint8_t flag)
/* Make sure that the UDP destination port number is not zero. */
if(UIP_UDP_BUF->destport == 0) {
PRINTF("udp: zero port.\n");
LOG_ERR("udp: zero port.\n");
goto drop;
}
@ -1533,14 +1515,14 @@ uip_process(uint8_t flag)
goto udp_found;
}
}
PRINTF("udp: no matching connection found\n");
LOG_ERR("udp: no matching connection found\n");
UIP_STAT(++uip_stat.udp.drop);
uip_icmp6_error_output(ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
goto send;
udp_found:
PRINTF("In udp_found\n");
LOG_DBG("In udp_found\n");
UIP_STAT(++uip_stat.udp.recv);
uip_len = uip_len - UIP_IPUDPH_LEN;
@ -1552,7 +1534,7 @@ uip_process(uint8_t flag)
UIP_UDP_APPCALL();
udp_send:
PRINTF("In udp_send\n");
LOG_DBG("In udp_send\n");
if(uip_slen == 0) {
goto drop;
@ -1598,21 +1580,21 @@ uip_process(uint8_t flag)
UIP_IP_BUF->proto = UIP_PROTO_TCP;
UIP_STAT(++uip_stat.tcp.recv);
PRINTF("Receiving TCP packet\n");
LOG_INFO("Receiving TCP packet\n");
/* Start of TCP input header processing code. */
if(uip_tcpchksum() != 0xffff) { /* Compute and check the TCP
checksum. */
UIP_STAT(++uip_stat.tcp.drop);
UIP_STAT(++uip_stat.tcp.chkerr);
PRINTF("tcp: bad checksum 0x%04x 0x%04x\n", UIP_TCP_BUF->tcpchksum,
LOG_ERR("tcp: bad checksum 0x%04x 0x%04x\n", UIP_TCP_BUF->tcpchksum,
uip_tcpchksum());
goto drop;
}
/* Make sure that the TCP port number is not zero. */
if(UIP_TCP_BUF->destport == 0 || UIP_TCP_BUF->srcport == 0) {
PRINTF("tcp: zero port.");
LOG_ERR("tcp: zero port.");
goto drop;
}
@ -1648,7 +1630,7 @@ uip_process(uint8_t flag)
UIP_STAT(++uip_stat.tcp.synrst);
reset:
PRINTF("In reset\n");
LOG_WARN("In reset\n");
/* We do not send resets in response to resets. */
if(UIP_TCP_BUF->flags & TCP_RST) {
goto drop;
@ -1703,7 +1685,7 @@ uip_process(uint8_t flag)
with a connection in LISTEN. In that case, we should create a new
connection and send a SYNACK in return. */
found_listen:
PRINTF("In found listen\n");
LOG_DBG("In found listen\n");
/* First we check if there are any connections avaliable. Unused
connections are kept in the same table as used connections, but
unused ones have the tcpstate set to CLOSED. Also, connections in
@ -1729,7 +1711,7 @@ uip_process(uint8_t flag)
the remote end will retransmit the packet at a time when we
have more spare connections. */
UIP_STAT(++uip_stat.tcp.syndrop);
UIP_LOG("tcp: found no unused connections.");
LOG_ERR("tcp: found no unused connections.");
goto drop;
}
uip_conn = uip_connr;
@ -1814,7 +1796,7 @@ uip_process(uint8_t flag)
/* This label will be jumped to if we found an active connection. */
found:
PRINTF("In found\n");
LOG_DBG("In found\n");
uip_conn = uip_connr;
uip_flags = 0;
/* We do a very naive form of TCP reset processing; we just accept
@ -1823,7 +1805,7 @@ uip_process(uint8_t flag)
before we accept the reset. */
if(UIP_TCP_BUF->flags & TCP_RST) {
uip_connr->tcpstateflags = UIP_CLOSED;
UIP_LOG("tcp: got reset, aborting connection.");
LOG_WARN("tcp: got reset, aborting connection.");
uip_flags = UIP_ABORT;
UIP_APPCALL();
goto drop;
@ -2253,7 +2235,7 @@ uip_process(uint8_t flag)
headers before calculating the checksum and finally send the
packet. */
tcp_send:
PRINTF("In tcp_send\n");
LOG_DBG("In tcp_send\n");
UIP_TCP_BUF->ackno[0] = uip_connr->rcv_nxt[0];
UIP_TCP_BUF->ackno[1] = uip_connr->rcv_nxt[1];
@ -2270,11 +2252,11 @@ uip_process(uint8_t flag)
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &uip_connr->ripaddr);
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
PRINTF("Sending TCP packet to ");
PRINT6ADDR(&UIP_IP_BUF->destipaddr);
PRINTF(" from ");
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF("\n");
LOG_INFO("Sending TCP packet to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO(" from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO("\n");
if(uip_connr->tcpstateflags & UIP_STOPPED) {
/* If the connection has issued uip_stop(), we advertise a zero
@ -2307,7 +2289,7 @@ uip_process(uint8_t flag)
UIP_IP_BUF->tcflow = 0x00;
UIP_IP_BUF->flow = 0x00;
send:
PRINTF("Sending packet with length %d (%d)\n", uip_len,
LOG_INFO("Sending packet with length %d (%d)\n", uip_len,
(UIP_IP_BUF->len[0] << 8) | UIP_IP_BUF->len[1]);
UIP_STAT(++uip_stat.ip.sent);

View File

@ -38,8 +38,10 @@
#include <stdio.h>
#include <string.h>
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "IPv6 Websocket"
#define LOG_LEVEL IPV6_LOG_LEVEL
enum {
STATE_WAITING_FOR_HEADER,
@ -78,7 +80,7 @@ send_get(struct websocket_http_client_state *s)
tcp_socket_send_str(tcps, s->subprotocol);
tcp_socket_send_str(tcps, "\r\n");
tcp_socket_send_str(tcps, "\r\n");
PRINTF("websocket-http-client: send_get(): output buffer left %d\n", tcp_socket_max_sendlen(tcps));
LOG_INFO("send_get(): output buffer left %d\n", tcp_socket_max_sendlen(tcps));
}
/*---------------------------------------------------------------------------*/
static void
@ -153,7 +155,7 @@ parse_header_byte(struct websocket_http_client_state *s,
(s->proxy_port == 0 && s->http_status != 101)) {
/* This is a websocket request, so the server should have answered
with a 101 Switching protocols response. */
PRINTF("Websocket HTTP client didn't get the 101 status code (got %d), closing connection\n",
LOG_WARN("didn't get the 101 status code (got %d), closing connection\n",
s->http_status);
websocket_http_client_close(s);
while(1) {
@ -261,7 +263,7 @@ websocket_http_client_get(struct websocket_http_client_state *s)
uip_ip6addr_t *addr;
uint16_t port;
PRINTF("websocket_http_client_get: connecting to %s with file %s subprotocol %s header %s\n",
LOG_INFO("Get: connecting to %s with file %s subprotocol %s header %s\n",
s->host, s->file, s->subprotocol, s->header);

View File

@ -37,6 +37,11 @@
#include "websocket.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "IPv6 Websocket"
#define LOG_LEVEL IPV6_LOG_LEVEL
PROCESS(websocket_process, "Websockets process");
#define MAX_HOSTLEN 64
@ -66,9 +71,6 @@ struct websocket_frame_mask {
uint8_t mask[4];
};
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
/*---------------------------------------------------------------------------*/
static int
parse_url(const char *url, char *host, uint16_t *portptr, char *path)
@ -148,11 +150,11 @@ static int
start_get(struct websocket *s)
{
if(websocket_http_client_get(&(s->s)) == 0) {
PRINTF("Out of memory error\n");
LOG_ERR("Out of memory error\n");
s->state = WEBSOCKET_STATE_CLOSED;
return WEBSOCKET_ERR;
} else {
PRINTF("Connecting...\n");
LOG_INFO("Connecting...\n");
s->state = WEBSOCKET_STATE_HTTP_REQUEST_SENT;
return WEBSOCKET_OK;
}
@ -192,13 +194,13 @@ PROCESS_THREAD(websocket_process, ev, data)
if(ret == RESOLV_STATUS_CACHED) {
/* Hostname found, restart get. */
if(s->state == WEBSOCKET_STATE_DNS_REQUEST_SENT) {
PRINTF("Restarting get\n");
LOG_INFO("Restarting get\n");
start_get(s);
}
} else {
if(s->state == WEBSOCKET_STATE_DNS_REQUEST_SENT) {
/* Hostname not found, kill connection. */
/* PRINTF("XXX killing connection\n");*/
LOG_ERR("killing connection\n");
call(s, WEBSOCKET_HOSTNAME_NOT_FOUND, NULL, 0);
}
}
@ -219,7 +221,7 @@ websocket_http_client_aborted(struct websocket_http_client_state *client_state)
if(client_state != NULL) {
struct websocket *s = (struct websocket *)
((char *)client_state - offsetof(struct websocket, s));
PRINTF("Websocket reset\n");
LOG_WARN("Websocket reset\n");
s->state = WEBSOCKET_STATE_CLOSED;
call(s, WEBSOCKET_RESET, NULL, 0);
}
@ -234,7 +236,7 @@ websocket_http_client_timedout(struct websocket_http_client_state *client_state)
if(client_state != NULL) {
struct websocket *s = (struct websocket *)
((char *)client_state - offsetof(struct websocket, s));
PRINTF("Websocket timed out\n");
LOG_WARN("Websocket timed out\n");
s->state = WEBSOCKET_STATE_CLOSED;
call(s, WEBSOCKET_TIMEDOUT, NULL, 0);
}
@ -250,7 +252,7 @@ websocket_http_client_closed(struct websocket_http_client_state *client_state)
if(client_state != NULL) {
struct websocket *s = (struct websocket *)
((char *)client_state - offsetof(struct websocket, s));
PRINTF("Websocket closed.\n");
LOG_INFO("Websocket closed.\n");
s->state = WEBSOCKET_STATE_CLOSED;
call(s, WEBSOCKET_CLOSED, NULL, 0);
}
@ -265,7 +267,7 @@ websocket_http_client_connected(struct websocket_http_client_state *client_state
struct websocket *s = (struct websocket *)
((char *)client_state - offsetof(struct websocket, s));
PRINTF("Websocket connected\n");
LOG_INFO("Websocket connected\n");
s->state = WEBSOCKET_STATE_WAITING_FOR_HEADER;
call(s, WEBSOCKET_CONNECTED, NULL, 0);
}
@ -409,10 +411,10 @@ websocket_http_client_datahandler(struct websocket_http_client_state *client_sta
See if the application data chunk is masked or not. If it is,
we copy the bitmask into the s->mask field. */
if((hdr->len & WEBSOCKET_MASK_BIT) == 0) {
/* PRINTF("No mask\n");*/
/* LOG_INFO("No mask\n");*/
} else {
memcpy(s->mask, &maskptr->mask, sizeof(s->mask));
/* PRINTF("There was a mask, %02x %02x %02x %02x\n",
/* LOG_INFO("There was a mask, %02x %02x %02x %02x\n",
s->mask[0], s->mask[1], s->mask[2], s->mask[3]);*/
}
@ -429,13 +431,13 @@ websocket_http_client_datahandler(struct websocket_http_client_state *client_sta
if(s->left > 0) {
websocket_http_client_send(&s->s, (const uint8_t*)data, s->left);
}
PRINTF("Got ping\n");
LOG_INFO("Got ping\n");
call(s, WEBSOCKET_PINGED, NULL, 0);
s->state = WEBSOCKET_STATE_WAITING_FOR_HEADER;
} else if(s->opcode == WEBSOCKET_OPCODE_PONG) {
/* If the opcode is pong, we call the application to let it
know we got a pong. */
PRINTF("Got pong\n");
LOG_INFO("Got pong\n");
call(s, WEBSOCKET_PONG_RECEIVED, NULL, 0);
s->state = WEBSOCKET_STATE_WAITING_FOR_HEADER;
} else if(s->opcode == WEBSOCKET_OPCODE_CLOSE) {
@ -446,7 +448,7 @@ websocket_http_client_datahandler(struct websocket_http_client_state *client_sta
if(s->left > 0) {
websocket_http_client_send(&s->s, (const uint8_t*)data, s->left);
}
PRINTF("websocket: got close, sending close\n");
LOG_INFO("Got close, sending close\n");
s->state = WEBSOCKET_STATE_WAITING_FOR_HEADER;
websocket_http_client_close(&s->s);
} else if(s->opcode == WEBSOCKET_OPCODE_BIN ||
@ -477,15 +479,12 @@ websocket_http_client_datahandler(struct websocket_http_client_state *client_sta
/* Need to keep parsing the incoming data to check for more
frames, if the incoming datalen is > than s->left. */
if(datalen > 0) {
PRINTF("XXX 1 again\n");
websocket_http_client_datahandler(client_state,
data, datalen);
}
}
} else if(s->state == WEBSOCKET_STATE_RECEIVING_DATA) {
/* XXX todo: mask if needed. */
/* PRINTF("Calling with s->left %d datalen %d\n",
s->left, datalen);*/
if(datalen > 0) {
if(datalen < s->left) {
call(s, WEBSOCKET_DATA, data, datalen);
@ -505,7 +504,6 @@ websocket_http_client_datahandler(struct websocket_http_client_state *client_sta
/* Need to keep parsing the incoming data to check for more
frames, if the incoming datalen is > than len. */
if(datalen > 0) {
PRINTF("XXX 2 again (datalen %d s->left %d)\n", datalen, (int)s->left);
websocket_http_client_datahandler(client_state,
data, datalen);
@ -558,7 +556,7 @@ websocket_open(struct websocket *s, const char *url,
}
if(s->state != WEBSOCKET_STATE_CLOSED) {
PRINTF("websocket_open: closing websocket before opening it again.\n");
LOG_INFO("Open: closing websocket before opening it again.\n");
websocket_close(s);
}
s->callback = c;
@ -577,7 +575,7 @@ websocket_open(struct websocket *s, const char *url,
if(ret != RESOLV_STATUS_CACHED) {
resolv_query(host);
s->state = WEBSOCKET_STATE_DNS_REQUEST_SENT;
PRINTF("Resolving host...\n");
LOG_INFO("Resolving host...\n");
return WEBSOCKET_OK;
}
}
@ -608,27 +606,27 @@ send_data(struct websocket *s, const void *data,
struct websocket_frame_hdr *hdr;
struct websocket_frame_mask *mask;
PRINTF("websocket send data len %d %.*s\n", datalen, datalen, (char *)data);
LOG_INFO("send data len %d %.*s\n", datalen, datalen, (char *)data);
if(s->state == WEBSOCKET_STATE_CLOSED ||
s->state == WEBSOCKET_STATE_DNS_REQUEST_SENT ||
s->state == WEBSOCKET_STATE_HTTP_REQUEST_SENT) {
/* Trying to send data on a non-connected websocket. */
PRINTF("websocket send fail: not connected\n");
LOG_ERR("send fail: not connected\n");
return -1;
}
/* We need to have 4 + 4 additional bytes for the websocket framing
header. */
if(4 + 4 + datalen > websocket_http_client_sendbuflen(&s->s)) {
PRINTF("websocket: too few bytes left (%d left, %d needed)\n",
LOG_ERR("too few bytes left (%d left, %d needed)\n",
websocket_http_client_sendbuflen(&s->s),
4 + 4 + datalen);
return -1;
}
if(datalen > sizeof(buf) - 4 - 4) {
PRINTF("websocket: trying to send too large data chunk %d > %d\n",
datalen, sizeof(buf) - 4 - 4);
LOG_ERR("trying to send too large data chunk %d > %d\n",
datalen, (int)sizeof(buf) - 4 - 4);
return -1;
}

View File

@ -50,22 +50,15 @@
#include "lib/list.h"
#include "lib/memb.h"
#include <string.h>
#include <stdio.h>
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64
#include "lib/simEnvChange.h"
#include "sys/cooja_mt.h"
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#else /* DEBUG */
#define PRINTF(...)
#endif /* DEBUG */
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "CSMA"
#define LOG_LEVEL MAC_LOG_LEVEL
/* Constants of the IEEE 802.15.4 standard */
@ -179,7 +172,7 @@ send_one_packet(mac_callback_t sent, void *ptr)
if(NETSTACK_FRAMER.create() < 0) {
/* Failed to allocate space for headers */
PRINTF("csma: send failed, too large header\n");
LOG_ERR("send failed, too large header\n");
ret = MAC_TX_ERR_FATAL;
} else {
#if CSMA_802154_AUTOACK
@ -251,7 +244,7 @@ send_one_packet(mac_callback_t sent, void *ptr)
}
}
} else {
PRINTF("csma tx noack\n");
LOG_WARN("tx noack\n");
}
}
break;
@ -297,7 +290,7 @@ transmit_from_queue(void *ptr)
if(n) {
struct packet_queue *q = list_head(n->packet_queue);
if(q != NULL) {
PRINTF("csma: preparing number %d %p, queue len %d\n", n->transmissions, q,
LOG_INFO("preparing number %d %p, queue len %d\n", n->transmissions, q,
list_length(n->packet_queue));
/* Send first packet in the neighbor queue */
queuebuf_to_packetbuf(q->buf);
@ -321,7 +314,7 @@ schedule_transmission(struct neighbor_queue *n)
delay = random_rand() % delay;
}
PRINTF("csma: scheduling transmission in %u ticks, NB=%u, BE=%u\n",
LOG_INFO("scheduling transmission in %u ticks, NB=%u, BE=%u\n",
(unsigned)delay, n->collisions, backoff_exponent);
ctimer_set(&n->transmit_timer, delay, transmit_from_queue, n);
}
@ -336,7 +329,7 @@ free_packet(struct neighbor_queue *n, struct packet_queue *p, int status)
queuebuf_free(p->buf);
memb_free(&metadata_memb, p->ptr);
memb_free(&packet_memb, p);
PRINTF("csma: free_queued_packet, queue length %d, free packets %d\n",
LOG_INFO("free_queued_packet, queue length %d, free packets %d\n",
list_length(n->packet_queue), memb_numfree(&packet_memb));
if(list_head(n->packet_queue) != NULL) {
/* There is a next packet. We reset current tx information */
@ -368,15 +361,15 @@ tx_done(int status, struct packet_queue *q, struct neighbor_queue *n)
switch(status) {
case MAC_TX_OK:
PRINTF("csma: rexmit ok %d\n", n->transmissions);
LOG_INFO("tx ok %d\n", n->transmissions);
break;
case MAC_TX_COLLISION:
case MAC_TX_NOACK:
PRINTF("csma: drop with status %d after %d transmissions, %d collisions\n",
LOG_WARN("drop with status %d after %d transmissions, %d collisions\n",
status, n->transmissions, n->collisions);
break;
default:
PRINTF("csma: rexmit failed %d: %d\n", n->transmissions, status);
LOG_ERR("tx failed %d: %d\n", n->transmissions, status);
break;
}
@ -412,7 +405,7 @@ collision(struct packet_queue *q, struct neighbor_queue *n,
if(n->transmissions >= metadata->max_transmissions) {
tx_done(MAC_TX_COLLISION, q, n);
} else {
PRINTF("csma: rexmit collision %d\n", n->transmissions);
LOG_INFO("tx collision %d\n", n->transmissions);
rexmit(q, n);
}
}
@ -430,7 +423,7 @@ noack(struct packet_queue *q, struct neighbor_queue *n, int num_transmissions)
if(n->transmissions >= metadata->max_transmissions) {
tx_done(MAC_TX_NOACK, q, n);
} else {
PRINTF("csma: rexmit noack %d\n", n->transmissions);
LOG_INFO("tx noack %d\n", n->transmissions);
rexmit(q, n);
}
}
@ -464,11 +457,11 @@ packet_sent(void *ptr, int status, int num_transmissions)
}
if(q == NULL) {
PRINTF("csma: seqno %d not found\n",
LOG_WARN("seqno %d not found\n",
packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO));
return;
} else if(q->ptr == NULL) {
PRINTF("csma: no metadata\n");
LOG_WARN("no metadata\n");
return;
}
@ -546,7 +539,7 @@ csma_output_packet(mac_callback_t sent, void *ptr)
metadata->cptr = ptr;
list_add(n->packet_queue, q);
PRINTF("csma: send_packet, queue length %d, free packets %d\n",
LOG_INFO("send_packet, queue length %d, free packets %d\n",
list_length(n->packet_queue), memb_numfree(&packet_memb));
/* If q is the first packet in the neighbor's queue, send asap */
if(list_head(n->packet_queue) == q) {
@ -555,10 +548,10 @@ csma_output_packet(mac_callback_t sent, void *ptr)
return;
}
memb_free(&metadata_memb, q->ptr);
PRINTF("csma: could not allocate queuebuf, dropping packet\n");
LOG_WARN("could not allocate queuebuf, dropping packet\n");
}
memb_free(&packet_memb, q);
PRINTF("csma: could not allocate queuebuf, dropping packet\n");
LOG_WARN("could not allocate queuebuf, dropping packet\n");
}
/* The packet allocation failed. Remove and free neighbor entry if empty. */
if(list_length(n->packet_queue) == 0) {
@ -566,11 +559,11 @@ csma_output_packet(mac_callback_t sent, void *ptr)
memb_free(&neighbor_memb, n);
}
} else {
PRINTF("csma: Neighbor queue full\n");
LOG_WARN("Neighbor queue full\n");
}
PRINTF("csma: could not allocate packet, dropping packet\n");
LOG_WARN("could not allocate packet, dropping packet\n");
} else {
PRINTF("csma: could not allocate neighbor, dropping packet\n");
LOG_WARN("could not allocate neighbor, dropping packet\n");
}
mac_call_sent_callback(sent, ptr, MAC_TX_ERR, 1);
}

View File

@ -44,16 +44,10 @@
#include "net/packetbuf.h"
#include "net/netstack.h"
#include <string.h>
#include <stdio.h>
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#else /* DEBUG */
#define PRINTF(...)
#endif /* DEBUG */
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "CSMA"
#define LOG_LEVEL MAC_LOG_LEVEL
/*---------------------------------------------------------------------------*/
static void
@ -76,15 +70,15 @@ input_packet(void)
#if CSMA_802154_AUTOACK
if(packetbuf_datalen() == CSMA_ACK_LEN) {
/* Ignore ack packets */
PRINTF("csma: ignored ack\n");
LOG_INFO("ignored ack\n");
} else
#endif /* CSMA_802154_AUTOACK */
if(NETSTACK_FRAMER.parse() < 0) {
PRINTF("csma: failed to parse %u\n", packetbuf_datalen());
LOG_ERR("failed to parse %u\n", packetbuf_datalen());
} else if(!linkaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
&linkaddr_node_addr) &&
!packetbuf_holds_broadcast()) {
PRINTF("csma: not for us\n");
LOG_WARN("not for us\n");
} else {
int duplicate = 0;
@ -93,7 +87,7 @@ input_packet(void)
duplicate = mac_sequence_is_duplicate();
if(duplicate) {
/* Drop the packet. */
PRINTF("csma: drop duplicate link layer packet %u\n",
LOG_WARN("drop duplicate link layer packet %u\n",
packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO));
} else {
mac_sequence_register_seqno();

View File

@ -40,8 +40,10 @@
#include <string.h>
#include "net/mac/framer/frame802154e-ie.h"
#define DEBUG DEBUG_NONE
#include "net/net-debug.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Frame 802.15.4e"
#define LOG_LEVEL FRAMER_LOG_LEVEL
/* c.f. IEEE 802.15.4e Table 4b */
enum ieee802154e_header_ie_id {
@ -470,27 +472,27 @@ frame802154e_parse_information_elements(const uint8_t *buf, uint8_t buf_size,
buf_size -= 2;
buf += 2;
type = ie_desc & 0x8000 ? 1 : 0; /* b15 */
PRINTF("frame802154e: ie type %u, current state %u\n", type, parsing_state);
LOG_DBG("ie type %u, current state %u\n", type, parsing_state);
switch(parsing_state) {
case PARSING_HEADER_IE:
if(type != 0) {
PRINTF("frame802154e: wrong type %04x\n", ie_desc);
LOG_ERR("wrong type %04x\n", ie_desc);
return -1;
}
/* Header IE: 2 bytes descriptor, c.f. fig 48n in IEEE 802.15.4e */
len = ie_desc & 0x007f; /* b0-b6 */
id = (ie_desc & 0x7f80) >> 7; /* b7-b14 */
PRINTF("frame802154e: header ie len %u id %x\n", len, id);
LOG_DBG("header ie len %u id %x\n", len, id);
switch(id) {
case HEADER_IE_LIST_TERMINATION_1:
if(len == 0) {
/* End of payload IE list, now expect payload IEs */
parsing_state = PARSING_PAYLOAD_IE;
ies->ie_payload_ie_offset = buf - start; /* Save IE header len */
PRINTF("frame802154e: list termination 1, look for payload IEs\n");
LOG_DBG("list termination 1, look for payload IEs\n");
} else {
PRINTF("frame802154e: list termination 1, wrong len %u\n", len);
LOG_ERR("list termination 1, wrong len %u\n", len);
return -1;
}
break;
@ -498,15 +500,15 @@ frame802154e_parse_information_elements(const uint8_t *buf, uint8_t buf_size,
/* End of IE parsing */
if(len == 0) {
ies->ie_payload_ie_offset = buf - start; /* Save IE header len */
PRINTF("frame802154e: list termination 2\n");
LOG_DBG("list termination 2\n");
return buf + len - start;
} else {
PRINTF("frame802154e: list termination 2, wrong len %u\n", len);
LOG_ERR("list termination 2, wrong len %u\n", len);
return -1;
}
default:
if(len > buf_size || frame802154e_parse_header_ie(buf, len, id, ies) == -1) {
PRINTF("frame802154e: failed to parse\n");
LOG_ERR("failed to parse\n");
return -1;
}
break;
@ -514,26 +516,26 @@ frame802154e_parse_information_elements(const uint8_t *buf, uint8_t buf_size,
break;
case PARSING_PAYLOAD_IE:
if(type != 1) {
PRINTF("frame802154e: wrong type %04x\n", ie_desc);
LOG_ERR("wrong type %04x\n", ie_desc);
return -1;
}
/* Payload IE: 2 bytes descriptor, c.f. fig 48o in IEEE 802.15.4e */
len = ie_desc & 0x7ff; /* b0-b10 */
id = (ie_desc & 0x7800) >> 11; /* b11-b14 */
PRINTF("frame802154e: payload ie len %u id %x\n", len, id);
LOG_DBG("payload ie len %u id %x\n", len, id);
switch(id) {
case PAYLOAD_IE_MLME:
/* Now expect 'len' bytes of MLME sub-IEs */
parsing_state = PARSING_MLME_SUBIE;
nested_mlme_len = len;
len = 0; /* Reset len as we want to read subIEs and not jump over them */
PRINTF("frame802154e: entering MLME ie with len %u\n", nested_mlme_len);
LOG_DBG("entering MLME ie with len %u\n", nested_mlme_len);
break;
case PAYLOAD_IE_LIST_TERMINATION:
PRINTF("frame802154e: payload ie list termination %u\n", len);
LOG_DBG("payload ie list termination %u\n", len);
return (len == 0) ? buf + len - start : -1;
default:
PRINTF("frame802154e: non-supported payload ie\n");
LOG_ERR("non-supported payload ie\n");
return -1;
}
break;
@ -544,30 +546,30 @@ frame802154e_parse_information_elements(const uint8_t *buf, uint8_t buf_size,
/* Short sub-IE, c.f. fig 48r in IEEE 802.15.4e */
len = ie_desc & 0x00ff; /* b0-b7 */
id = (ie_desc & 0x7f00) >> 8; /* b8-b14 */
PRINTF("frame802154e: short mlme ie len %u id %x\n", len, id);
LOG_DBG("short mlme ie len %u id %x\n", len, id);
if(len > buf_size || frame802154e_parse_mlme_short_ie(buf, len, id, ies) == -1) {
PRINTF("frame802154e: failed to parse ie\n");
LOG_ERR("failed to parse ie\n");
return -1;
}
} else {
/* Long sub-IE, c.f. fig 48s in IEEE 802.15.4e */
len = ie_desc & 0x7ff; /* b0-b10 */
id = (ie_desc & 0x7800) >> 11; /* b11-b14 */
PRINTF("frame802154e: long mlme ie len %u id %x\n", len, id);
LOG_DBG("long mlme ie len %u id %x\n", len, id);
if(len > buf_size || frame802154e_parse_mlme_long_ie(buf, len, id, ies) == -1) {
PRINTF("frame802154e: failed to parse ie\n");
LOG_ERR("failed to parse ie\n");
return -1;
}
}
/* Update remaining nested MLME len */
nested_mlme_len -= 2 + len;
if(nested_mlme_len < 0) {
PRINTF("frame802154e: found more sub-IEs than initially advertised\n");
LOG_ERR("found more sub-IEs than initially advertised\n");
/* We found more sub-IEs than initially advertised */
return -1;
}
if(nested_mlme_len == 0) {
PRINTF("frame802154e: end of MLME IE parsing\n");
LOG_DBG("end of MLME IE parsing\n");
/* End of IE parsing, look for another payload IE */
parsing_state = PARSING_PAYLOAD_IE;
}

View File

@ -43,16 +43,10 @@
#include "lib/random.h"
#include <string.h>
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#define PRINTADDR(addr) PRINTF(" %02x%02x:%02x%02x:%02x%02x:%02x%02x ", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7])
#else
#define PRINTF(...)
#define PRINTADDR(addr)
#endif
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "Frame 802.15.4e"
#define LOG_LEVEL FRAMER_LOG_LEVEL
/** \brief The sequence number (0x00 - 0xff) added to the transmitted
* data or MAC command frame. The default is a random value within
@ -180,13 +174,13 @@ create_frame(int type, int do_create)
} else if(packetbuf_hdralloc(hdr_len)) {
frame802154_create(&params, packetbuf_hdrptr());
PRINTF("15.4-OUT: %2X", params.fcf.frame_type);
PRINTADDR(params.dest_addr);
PRINTF("%d %u (%u)\n", hdr_len, packetbuf_datalen(), packetbuf_totlen());
LOG_INFO("Out: %2X", params.fcf.frame_type);
LOG_INFO_LLADDR((const linkaddr_t *)params.dest_addr);
LOG_INFO("%d %u (%u)\n", hdr_len, packetbuf_datalen(), packetbuf_totlen());
return hdr_len;
} else {
PRINTF("15.4-OUT: too large header: %u\n", hdr_len);
LOG_ERR("Out: too large header: %u\n", hdr_len);
return FRAMER_FAILED;
}
}
@ -218,7 +212,7 @@ parse(void)
if(frame.dest_pid != frame802154_get_pan_id() &&
frame.dest_pid != FRAME802154_BROADCASTPANDID) {
/* Packet to another PAN */
PRINTF("15.4: for another pan %u\n", frame.dest_pid);
LOG_WARN("In: for another pan %u\n", frame.dest_pid);
return FRAMER_FAILED;
}
if(!frame802154_is_broadcast_addr(frame.fcf.dest_addr_mode, frame.dest_addr)) {
@ -243,10 +237,10 @@ parse(void)
}
#endif /* LLSEC802154_USES_AUX_HEADER */
PRINTF("15.4-IN: %2X", frame.fcf.frame_type);
PRINTADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
PRINTADDR(packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
PRINTF("%d %u (%u)\n", hdr_len, packetbuf_datalen(), packetbuf_totlen());
LOG_INFO("In: %2X", frame.fcf.frame_type);
LOG_INFO_LLADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
LOG_INFO_LLADDR(packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
LOG_INFO("%d %u (%u)\n", hdr_len, packetbuf_datalen(), packetbuf_totlen());
return hdr_len;
}

View File

@ -32,32 +32,29 @@
#include "net/mac/mac.h"
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#define PRINTF(...) printf(__VA_ARGS__)
#else /* DEBUG */
#define PRINTF(...)
#endif /* DEBUG */
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "MAC"
#define LOG_LEVEL MAC_LOG_LEVEL
/*---------------------------------------------------------------------------*/
void
mac_call_sent_callback(mac_callback_t sent, void *ptr, int status, int num_tx)
{
PRINTF("mac_callback_t %p ptr %p status %d num_tx %d\n",
LOG_INFO("mac_callback_t %p ptr %p status %d num_tx %d\n",
(void *)sent, ptr, status, num_tx);
switch(status) {
case MAC_TX_COLLISION:
PRINTF("mac: collision after %d tx\n", num_tx);
break;
LOG_INFO("collision after %d tx\n", num_tx);
break;
case MAC_TX_NOACK:
PRINTF("mac: noack after %d tx\n", num_tx);
LOG_INFO("noack after %d tx\n", num_tx);
break;
case MAC_TX_OK:
PRINTF("mac: sent after %d tx\n", num_tx);
LOG_INFO("sent after %d tx\n", num_tx);
break;
default:
PRINTF("mac: error %d after %d tx\n", status, num_tx);
LOG_INFO("error %d after %d tx\n", status, num_tx);
}
if(sent) {

View File

@ -51,14 +51,7 @@
#include "net/mac/tsch/tsch-slot-operation.h"
#include "lib/ringbufindex.h"
#if TSCH_LOG_LEVEL >= 1
#define DEBUG DEBUG_PRINT
#else /* TSCH_LOG_LEVEL */
#define DEBUG DEBUG_NONE
#endif /* TSCH_LOG_LEVEL */
#include "net/net-debug.h"
#if TSCH_LOG_LEVEL >= 2 /* Skip this file for log levels 0 or 1 */
#if TSCH_LOG_PER_SLOT
PROCESS_NAME(tsch_pending_events_process);
@ -156,4 +149,4 @@ tsch_log_init(void)
ringbufindex_init(&log_ringbuf, TSCH_LOG_QUEUE_LEN);
}
#endif /* TSCH_LOG_LEVEL */
#endif /* TSCH_LOG_PER_SLOT */

View File

@ -41,6 +41,14 @@
/******** Configuration *******/
/* TSCH per-slot logging. Enabled by default if DBG is enabled */
#ifdef TSCH_LOG_CONF_PER_SLOT
#define TSCH_LOG_PER_SLOT TSCH_LOG_CONF_PER_SLOT
#else /* TSCH_LOG_CONF_PER_SLOT */
#include "sys/log.h"
#define TSCH_LOG_PER_SLOT (MAC_LOG_LEVEL >= LOG_LEVEL_DBG)
#endif /* TSCH_LOG_CONF_PER_SLOT */
/* The length of the log queue, i.e. maximum number postponed log messages */
#ifdef TSCH_LOG_CONF_QUEUE_LEN
#define TSCH_LOG_QUEUE_LEN TSCH_LOG_CONF_QUEUE_LEN
@ -55,23 +63,13 @@
#define TSCH_LOG_ID_FROM_LINKADDR(addr) ((addr) ? (addr)->u8[LINKADDR_SIZE - 1] : 0)
#endif /* TSCH_LOG_ID_FROM_LINKADDR */
/* TSCH log levels:
* 0: no log
* 1: basic PRINTF enabled
* 2: basic PRINTF enabled and tsch-log module enabled */
#ifdef TSCH_LOG_CONF_LEVEL
#define TSCH_LOG_LEVEL TSCH_LOG_CONF_LEVEL
#else /* TSCH_LOG_CONF_LEVEL */
#define TSCH_LOG_LEVEL 2
#endif /* TSCH_LOG_CONF_LEVEL */
#if TSCH_LOG_LEVEL < 2 /* For log level 0 or 1, the logging functions do nothing */
#if (TSCH_LOG_PER_SLOT == 0)
#define tsch_log_init()
#define tsch_log_process_pending()
#define TSCH_LOG_ADD(log_type, init_code)
#else /* TSCH_LOG_LEVEL */
#else /* (TSCH_LOG_PER_SLOT == 0) */
/************ Types ***********/
@ -133,6 +131,6 @@ void tsch_log_process_pending(void);
} \
} while(0);
#endif /* TSCH_LOG_LEVEL */
#endif /* (TSCH_LOG_PER_SLOT == 0) */
#endif /* __TSCH_LOG_H__ */

View File

@ -45,21 +45,16 @@
#include "net/mac/tsch/tsch-private.h"
#include "net/mac/tsch/tsch-schedule.h"
#include "net/mac/tsch/tsch-security.h"
#include "net/mac/tsch/tsch-log.h"
#include "net/mac/framer/frame802154.h"
#include "net/mac/framer/framer-802154.h"
#include "net/netstack.h"
#include "lib/ccm-star.h"
#include "lib/aes-128.h"
#include <stdio.h>
#include <string.h>
#if TSCH_LOG_LEVEL >= 1
#define DEBUG DEBUG_PRINT
#else /* TSCH_LOG_LEVEL */
#define DEBUG DEBUG_NONE
#endif /* TSCH_LOG_LEVEL */
#include "net/net-debug.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "TSCH Packet"
#define LOG_LEVEL MAC_LOG_LEVEL
/*---------------------------------------------------------------------------*/
/* Construct enhanced ACK packet and return ACK length */
@ -357,19 +352,19 @@ tsch_packet_parse_eb(const uint8_t *buf, int buf_size,
/* Parse 802.15.4-2006 frame, i.e. all fields before Information Elements */
if((ret = frame802154_parse((uint8_t *)buf, buf_size, frame)) == 0) {
PRINTF("TSCH:! parse_eb: failed to parse frame\n");
LOG_ERR("! parse_eb: failed to parse frame\n");
return 0;
}
if(frame->fcf.frame_version < FRAME802154_IEEE802154E_2012
|| frame->fcf.frame_type != FRAME802154_BEACONFRAME) {
PRINTF("TSCH:! parse_eb: frame is not a valid TSCH beacon. Frame version %u, type %u, FCF %02x %02x\n",
LOG_ERR("! parse_eb: frame is not a valid TSCH beacon. Frame version %u, type %u, FCF %02x %02x\n",
frame->fcf.frame_version, frame->fcf.frame_type, buf[0], buf[1]);
PRINTF("TSCH:! parse_eb: frame was from 0x%x/", frame->src_pid);
PRINTLLADDR((const uip_lladdr_t *)&frame->src_addr);
PRINTF(" to 0x%x/", frame->dest_pid);
PRINTLLADDR((const uip_lladdr_t *)&frame->dest_addr);
PRINTF("\n");
LOG_ERR("! parse_eb: frame was from 0x%x/", frame->src_pid);
LOG_ERR_LLADDR((const linkaddr_t *)&frame->src_addr);
LOG_ERR(" to 0x%x/", frame->dest_pid);
LOG_ERR_LLADDR((const linkaddr_t *)&frame->dest_addr);
LOG_ERR("\n");
return 0;
}
@ -396,7 +391,7 @@ tsch_packet_parse_eb(const uint8_t *buf, int buf_size,
/* Parse information elements. We need to substract the MIC length, as the exact payload len is needed while parsing */
if((ret = frame802154e_parse_information_elements(buf + curr_len, buf_size - curr_len - mic_len, ies)) == -1) {
PRINTF("TSCH:! parse_eb: failed to parse IEs\n");
LOG_ERR("! parse_eb: failed to parse IEs\n");
return 0;
}
curr_len += ret;

View File

@ -55,12 +55,10 @@
#include "net/mac/tsch/tsch-log.h"
#include <string.h>
#if TSCH_LOG_LEVEL >= 1
#define DEBUG DEBUG_PRINT
#else /* TSCH_LOG_LEVEL */
#define DEBUG DEBUG_NONE
#endif /* TSCH_LOG_LEVEL */
#include "net/net-debug.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "TSCH Queue"
#define LOG_LEVEL MAC_LOG_LEVEL
/* Check if TSCH_QUEUE_NUM_PER_NEIGHBOR is power of two */
#if (TSCH_QUEUE_NUM_PER_NEIGHBOR & (TSCH_QUEUE_NUM_PER_NEIGHBOR - 1)) != 0
@ -155,7 +153,7 @@ tsch_queue_update_time_source(const linkaddr_t *new_addr)
}
if(new_time_src != old_time_src) {
PRINTF("TSCH: update time source: %u -> %u\n",
LOG_INFO("update time source: %u -> %u\n",
TSCH_LOG_ID_FROM_LINKADDR(old_time_src ? &old_time_src->addr : NULL),
TSCH_LOG_ID_FROM_LINKADDR(new_time_src ? &new_time_src->addr : NULL));
@ -195,13 +193,13 @@ tsch_queue_flush_nbr_queue(struct tsch_neighbor *n)
if(p != NULL) {
/* Set return status for packet_sent callback */
p->ret = MAC_TX_ERR;
PRINTF("TSCH-queue:! flushing packet\n");
LOG_WARN("! flushing packet\n");
/* Call packet_sent callback */
mac_call_sent_callback(p->sent, p->ptr, p->ret, p->transmissions);
/* Free packet queuebuf */
tsch_queue_free_packet(p);
}
PRINTF("TSCH-queue: packet is deleted packet=%p\n", p);
LOG_INFO("packet deleted %p\n", p);
}
}
/*---------------------------------------------------------------------------*/
@ -253,7 +251,7 @@ tsch_queue_add_packet(const linkaddr_t *addr, mac_callback_t sent, void *ptr)
/* Add to ringbuf (actual add committed through atomic operation) */
n->tx_array[put_index] = p;
ringbufindex_put(&n->tx_ringbuf);
PRINTF("TSCH-queue: packet is added put_index=%u, packet=%p\n",
LOG_INFO("packet is added put_index %u, packet %p\n",
put_index, p);
return p;
} else {
@ -263,7 +261,7 @@ tsch_queue_add_packet(const linkaddr_t *addr, mac_callback_t sent, void *ptr)
}
}
}
PRINTF("TSCH-queue:! add packet failed: %u %p %d %p %p\n", tsch_is_locked(), n, put_index, p, p ? p->qb : NULL);
LOG_ERR("! add packet failed: %u %p %d %p %p\n", tsch_is_locked(), n, put_index, p, p ? p->qb : NULL);
return 0;
}
/*---------------------------------------------------------------------------*/
@ -290,7 +288,7 @@ tsch_queue_remove_packet_from_queue(struct tsch_neighbor *n)
/* Get and remove packet from ringbuf (remove committed through an atomic operation */
int16_t get_index = ringbufindex_get(&n->tx_ringbuf);
if(get_index != -1) {
PRINTF("TSCH-queue: packet is removed, get_index=%u\n", get_index);
LOG_INFO("packet is removed, get_index %u\n", get_index);
return n->tx_array[get_index];
} else {
return NULL;

View File

@ -46,12 +46,10 @@
#include "net/mac/tsch/tsch-log.h"
#include "tsch-rpl.h"
#if TSCH_LOG_LEVEL >= 1
#define DEBUG DEBUG_PRINT
#else /* TSCH_LOG_LEVEL */
#define DEBUG DEBUG_NONE
#endif /* TSCH_LOG_LEVEL */
#include "net/net-debug.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "TSCH RPL"
#define LOG_LEVEL MAC_LOG_LEVEL
/*---------------------------------------------------------------------------*/
/* To use, set #define TSCH_CALLBACK_JOINING_NETWORK tsch_rpl_callback_joining_network */

View File

@ -55,12 +55,10 @@
#include "sys/rtimer.h"
#include <string.h>
#if TSCH_LOG_LEVEL >= 1
#define DEBUG DEBUG_PRINT
#else /* TSCH_LOG_LEVEL */
#define DEBUG DEBUG_NONE
#endif /* TSCH_LOG_LEVEL */
#include "net/net-debug.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "TSCH Schedule"
#define LOG_LEVEL MAC_LOG_LEVEL
/* Pre-allocated space for links */
MEMB(link_memb, struct tsch_link, TSCH_SCHEDULE_MAX_LINKS);
@ -92,7 +90,7 @@ tsch_schedule_add_slotframe(uint16_t handle, uint16_t size)
/* Add the slotframe to the global list */
list_add(slotframe_list, sf);
}
PRINTF("TSCH-schedule: add_slotframe %u %u\n",
LOG_INFO("add_slotframe %u %u\n",
handle, size);
tsch_release_lock();
return sf;
@ -126,7 +124,7 @@ tsch_schedule_remove_slotframe(struct tsch_slotframe *slotframe)
/* Now that the slotframe has no links, remove it. */
if(tsch_get_lock()) {
PRINTF("TSCH-schedule: remove slotframe %u %u\n", slotframe->handle, slotframe->size.val);
LOG_INFO("remove slotframe %u %u\n", slotframe->handle, slotframe->size.val);
memb_free(&slotframe_memb, slotframe);
list_remove(slotframe_list, slotframe);
tsch_release_lock();
@ -186,11 +184,11 @@ tsch_schedule_add_link(struct tsch_slotframe *slotframe,
* to keep neighbor state in sync with link options etc.) */
tsch_schedule_remove_link_by_timeslot(slotframe, timeslot);
if(!tsch_get_lock()) {
PRINTF("TSCH-schedule:! add_link memb_alloc couldn't take lock\n");
LOG_ERR("! add_link memb_alloc couldn't take lock\n");
} else {
l = memb_alloc(&link_memb);
if(l == NULL) {
PRINTF("TSCH-schedule:! add_link memb_alloc failed\n");
LOG_ERR("! add_link memb_alloc failed\n");
tsch_release_lock();
} else {
static int current_link_handle = 0;
@ -210,7 +208,7 @@ tsch_schedule_add_link(struct tsch_slotframe *slotframe,
}
linkaddr_copy(&l->addr, address);
PRINTF("TSCH-schedule: add_link %u %u %u %u %u %u\n",
LOG_INFO("add_link %u %u %u %u %u %u\n",
slotframe->handle, link_options, link_type, timeslot, channel_offset, TSCH_LOG_ID_FROM_LINKADDR(address));
/* Release the lock before we update the neighbor (will take the lock) */
@ -251,7 +249,7 @@ tsch_schedule_remove_link(struct tsch_slotframe *slotframe, struct tsch_link *l)
if(l == current_link) {
current_link = NULL;
}
PRINTF("TSCH-schedule: remove_link %u %u %u %u %u\n",
LOG_INFO("remove_link %u %u %u %u %u\n",
slotframe->handle, l->link_options, l->timeslot, l->channel_offset,
TSCH_LOG_ID_FROM_LINKADDR(&l->addr));
@ -274,7 +272,7 @@ tsch_schedule_remove_link(struct tsch_slotframe *slotframe, struct tsch_link *l)
return 1;
} else {
PRINTF("TSCH-schedule:! remove_link memb_alloc couldn't take lock\n");
LOG_ERR("! remove_link memb_alloc couldn't take lock\n");
}
}
return 0;

View File

@ -53,13 +53,6 @@
#include <stdio.h>
#include <string.h>
#if TSCH_LOG_LEVEL >= 1
#define DEBUG DEBUG_PRINT
#else /* TSCH_LOG_LEVEL */
#define DEBUG DEBUG_NONE
#endif /* TSCH_LOG_LEVEL */
#include "net/net-debug.h"
/* The two keys K1 and K2 from 6TiSCH minimal configuration
* K1: well-known, used for EBs
* K2: secret, used for data and ACK

View File

@ -40,8 +40,8 @@
*
*/
#include "contiki.h"
#include "dev/radio.h"
#include "contiki.h"
#include "net/netstack.h"
#include "net/packetbuf.h"
#include "net/queuebuf.h"
@ -59,12 +59,7 @@
#include "sys/cooja_mt.h"
#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */
#if TSCH_LOG_LEVEL >= 1
#define DEBUG DEBUG_PRINT
#else /* TSCH_LOG_LEVEL */
#define DEBUG DEBUG_NONE
#endif /* TSCH_LOG_LEVEL */
#include "net/net-debug.h"
#include <stdio.h>
/* TSCH debug macros, i.e. to set LEDs or GPIOs on various TSCH
* timeslot events */

View File

@ -61,12 +61,10 @@
#error TSCH: FRAME802154_VERSION must be at least FRAME802154_IEEE802154E_2012
#endif
#if TSCH_LOG_LEVEL >= 1
#define DEBUG DEBUG_PRINT
#else /* TSCH_LOG_LEVEL */
#define DEBUG DEBUG_NONE
#endif /* TSCH_LOG_LEVEL */
#include "net/net-debug.h"
/* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "TSCH"
#define LOG_LEVEL MAC_LOG_LEVEL
/* Use to collect link statistics even on Keep-Alive, even though they were
* not sent from an upper layer and don't have a valid packet_sent callback */
@ -147,9 +145,9 @@ static struct ctimer keepalive_timer;
/* TSCH processes and protothreads */
PT_THREAD(tsch_scan(struct pt *pt));
PROCESS(tsch_process, "TSCH: main process");
PROCESS(tsch_send_eb_process, "TSCH: send EB process");
PROCESS(tsch_pending_events_process, "TSCH: pending events process");
PROCESS(tsch_process, "main process");
PROCESS(tsch_send_eb_process, "send EB process");
PROCESS(tsch_pending_events_process, "pending events process");
/* Other function prototypes */
static void packet_input(void);
@ -228,7 +226,7 @@ keepalive_packet_sent(void *ptr, int status, int transmissions)
#ifdef TSCH_LINK_NEIGHBOR_CALLBACK
TSCH_LINK_NEIGHBOR_CALLBACK(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), status, transmissions);
#endif
PRINTF("TSCH: KA sent to %u, st %d-%d\n",
LOG_INFO("KA sent to %u, st %d-%d\n",
TSCH_LOG_ID_FROM_LINKADDR(packetbuf_addr(PACKETBUF_ADDR_RECEIVER)), status, transmissions);
tsch_schedule_keepalive();
}
@ -243,7 +241,7 @@ keepalive_send()
packetbuf_clear();
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &n->addr);
NETSTACK_MAC.send(keepalive_packet_sent, NULL);
PRINTF("TSCH: sending KA to %u\n",
LOG_INFO("sending KA to %u\n",
TSCH_LOG_ID_FROM_LINKADDR(&n->addr));
}
}
@ -263,7 +261,7 @@ tsch_schedule_keepalive()
static void
eb_input(struct input_packet *current_input)
{
/* PRINTF("TSCH: EB received\n"); */
/* LOG_INFO("EB received\n"); */
frame802154_t frame;
/* Verify incoming EB (does its ASN match our Rx time?),
* and update our join priority. */
@ -313,20 +311,20 @@ eb_input(struct input_packet *current_input)
int32_t asn_diff = TSCH_ASN_DIFF(current_input->rx_asn, eb_ies.ie_asn);
if(asn_diff != 0) {
/* We disagree with our time source's ASN -- leave the network */
PRINTF("TSCH:! ASN drifted by %ld, leaving the network\n", asn_diff);
LOG_WARN("! ASN drifted by %ld, leaving the network\n", asn_diff);
tsch_disassociate();
}
if(eb_ies.ie_join_priority >= TSCH_MAX_JOIN_PRIORITY) {
/* Join priority unacceptable. Leave network. */
PRINTF("TSCH:! EB JP too high %u, leaving the network\n",
LOG_WARN("! EB JP too high %u, leaving the network\n",
eb_ies.ie_join_priority);
tsch_disassociate();
} else {
#if TSCH_AUTOSELECT_TIME_SOURCE
/* Update join priority */
if(tsch_join_priority != eb_ies.ie_join_priority + 1) {
PRINTF("TSCH: update JP from EB %u -> %u\n",
LOG_INFO("update JP from EB %u -> %u\n",
tsch_join_priority, eb_ies.ie_join_priority + 1);
tsch_join_priority = eb_ies.ie_join_priority + 1;
}
@ -409,7 +407,7 @@ tsch_start_coordinator(void)
tsch_is_associated = 1;
tsch_join_priority = 0;
PRINTF("TSCH: starting as coordinator, PAN ID %x, asn-%x.%lx\n",
LOG_INFO("starting as coordinator, PAN ID %x, asn-%x.%lx\n",
frame802154_get_pan_id(), tsch_current_asn.ms1b, tsch_current_asn.ls4b);
/* Start slot operation */
@ -423,7 +421,7 @@ tsch_disassociate(void)
if(tsch_is_associated == 1) {
tsch_is_associated = 0;
process_post(&tsch_process, PROCESS_EVENT_POLL, NULL);
PRINTF("TSCH: leaving the network\n");
LOG_WARN("leaving the network\n");
}
}
/*---------------------------------------------------------------------------*/
@ -438,7 +436,7 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
if(input_eb == NULL || tsch_packet_parse_eb(input_eb->payload, input_eb->len,
&frame, &ies, &hdrlen, 0) == 0) {
PRINTF("TSCH:! failed to parse EB (len %u)\n", input_eb->len);
LOG_ERR("! failed to parse EB (len %u)\n", input_eb->len);
return 0;
}
@ -447,7 +445,7 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
#if TSCH_JOIN_SECURED_ONLY
if(frame.fcf.security_enabled == 0) {
PRINTF("TSCH:! parse_eb: EB is not secured\n");
LOG_ERR("! parse_eb: EB is not secured\n");
return 0;
}
#endif /* TSCH_JOIN_SECURED_ONLY */
@ -456,14 +454,14 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
if(!tsch_security_parse_frame(input_eb->payload, hdrlen,
input_eb->len - hdrlen - tsch_security_mic_len(&frame),
&frame, (linkaddr_t*)&frame.src_addr, &tsch_current_asn)) {
PRINTF("TSCH:! parse_eb: failed to authenticate\n");
LOG_ERR("! parse_eb: failed to authenticate\n");
return 0;
}
#endif /* LLSEC802154_ENABLED */
#if !LLSEC802154_ENABLED
if(frame.fcf.security_enabled == 1) {
PRINTF("TSCH:! parse_eb: we do not support security, but EB is secured\n");
LOG_ERR("! parse_eb: we do not support security, but EB is secured\n");
return 0;
}
#endif /* !LLSEC802154_ENABLED */
@ -471,14 +469,14 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
#if TSCH_JOIN_MY_PANID_ONLY
/* Check if the EB comes from the PAN ID we expect */
if(frame.src_pid != IEEE802154_PANID) {
PRINTF("TSCH:! parse_eb: PAN ID %x != %x\n", frame.src_pid, IEEE802154_PANID);
LOG_ERR("! parse_eb: PAN ID %x != %x\n", frame.src_pid, IEEE802154_PANID);
return 0;
}
#endif /* TSCH_JOIN_MY_PANID_ONLY */
/* There was no join priority (or 0xff) in the EB, do not join */
if(ies.ie_join_priority == 0xff) {
PRINTF("TSCH:! parse_eb: no join priority\n");
LOG_ERR("! parse_eb: no join priority\n");
return 0;
}
@ -500,7 +498,7 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
memcpy(tsch_hopping_sequence, ies.ie_hopping_sequence_list, ies.ie_hopping_sequence_len);
TSCH_ASN_DIVISOR_INIT(tsch_hopping_sequence_length, ies.ie_hopping_sequence_len);
} else {
PRINTF("TSCH:! parse_eb: hopping sequence too long (%u)\n", ies.ie_hopping_sequence_len);
LOG_ERR("! parse_eb: hopping sequence too long (%u)\n", ies.ie_hopping_sequence_len);
return 0;
}
}
@ -511,7 +509,7 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
int32_t asn_threshold = TSCH_CHECK_TIME_AT_ASSOCIATION * 60ul * TSCH_CLOCK_TO_SLOTS(CLOCK_SECOND, tsch_timing_timeslot_length);
int32_t asn_diff = (int32_t)tsch_current_asn.ls4b - expected_asn;
if(asn_diff > asn_threshold) {
PRINTF("TSCH:! EB ASN rejected %lx %lx %ld\n",
LOG_ERR("! EB ASN rejected %lx %lx %ld\n",
tsch_current_asn.ls4b, expected_asn, asn_diff);
return 0;
}
@ -521,10 +519,10 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
/* Create schedule */
if(ies.ie_tsch_slotframe_and_link.num_slotframes == 0) {
#if TSCH_SCHEDULE_WITH_6TISCH_MINIMAL
PRINTF("TSCH: parse_eb: no schedule, setting up minimal schedule\n");
LOG_INFO("parse_eb: no schedule, setting up minimal schedule\n");
tsch_schedule_create_minimal();
#else
PRINTF("TSCH: parse_eb: no schedule\n");
LOG_INFO("parse_eb: no schedule\n");
#endif
} else {
/* First, empty current schedule */
@ -543,7 +541,7 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
ies.ie_tsch_slotframe_and_link.links[i].timeslot, ies.ie_tsch_slotframe_and_link.links[i].channel_offset);
}
} else {
PRINTF("TSCH:! parse_eb: too many links in schedule (%u)\n", num_links);
LOG_ERR("! parse_eb: too many links in schedule (%u)\n", num_links);
return 0;
}
}
@ -575,7 +573,7 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
TSCH_CALLBACK_JOINING_NETWORK();
#endif
PRINTF("TSCH: association done, sec %u, PAN ID %x, asn-%x.%lx, jp %u, timeslot id %u, hopping id %u, slotframe len %u with %u links, from ",
LOG_INFO("association done, sec %u, PAN ID %x, asn-%x.%lx, jp %u, timeslot id %u, hopping id %u, slotframe len %u with %u links, from ",
tsch_is_pan_secured,
frame.src_pid,
tsch_current_asn.ms1b, tsch_current_asn.ls4b, tsch_join_priority,
@ -583,13 +581,13 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
ies.ie_channel_hopping_sequence_id,
ies.ie_tsch_slotframe_and_link.slotframe_size,
ies.ie_tsch_slotframe_and_link.num_links);
PRINTLLADDR((const uip_lladdr_t *)&frame.src_addr);
PRINTF("\n");
LOG_INFO_LLADDR((const linkaddr_t *)&frame.src_addr);
LOG_INFO("\n");
return 1;
}
}
PRINTF("TSCH:! did not associate.\n");
LOG_ERR("! did not associate.\n");
return 0;
}
@ -631,7 +629,7 @@ PT_THREAD(tsch_scan(struct pt *pt))
if(current_channel != scan_channel) {
NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, scan_channel);
current_channel = scan_channel;
PRINTF("TSCH: scanning on channel %u\n", scan_channel);
LOG_INFO("scanning on channel %u\n", scan_channel);
}
current_channel_since = now_time;
}
@ -654,7 +652,7 @@ PT_THREAD(tsch_scan(struct pt *pt))
NETSTACK_RADIO.get_object(RADIO_PARAM_LAST_PACKET_TIMESTAMP, &t0, sizeof(rtimer_clock_t));
/* Parse EB and attempt to associate */
PRINTF("TSCH: association: received packet (%u bytes) on channel %u\n", input_eb.len, current_channel);
LOG_INFO("association: received packet (%u bytes) on channel %u\n", input_eb.len, current_channel);
tsch_associate(&input_eb, t0);
}
@ -754,9 +752,9 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data)
packetbuf_set_datalen(eb_len);
/* Enqueue EB packet */
if(!(p = tsch_queue_add_packet(&tsch_eb_address, NULL, NULL))) {
PRINTF("TSCH:! could not enqueue EB packet\n");
LOG_ERR("! could not enqueue EB packet\n");
} else {
PRINTF("TSCH: enqueue EB packet %u %u\n", eb_len, hdr_len);
LOG_INFO("enqueue EB packet %u %u\n", eb_len, hdr_len);
p->tsch_sync_ie_offset = tsch_sync_ie_offset;
p->header_len = hdr_len;
}
@ -804,7 +802,7 @@ tsch_init(void)
/* Radio Rx mode */
if(NETSTACK_RADIO.get_value(RADIO_PARAM_RX_MODE, &radio_rx_mode) != RADIO_RESULT_OK) {
printf("TSCH:! radio does not support getting RADIO_PARAM_RX_MODE. Abort init.\n");
LOG_ERR("! radio does not support getting RADIO_PARAM_RX_MODE. Abort init.\n");
return;
}
/* Disable radio in frame filtering */
@ -814,34 +812,34 @@ tsch_init(void)
/* Set radio in poll mode */
radio_rx_mode |= RADIO_RX_MODE_POLL_MODE;
if(NETSTACK_RADIO.set_value(RADIO_PARAM_RX_MODE, radio_rx_mode) != RADIO_RESULT_OK) {
printf("TSCH:! radio does not support setting required RADIO_PARAM_RX_MODE. Abort init.\n");
LOG_ERR("! radio does not support setting required RADIO_PARAM_RX_MODE. Abort init.\n");
return;
}
/* Radio Tx mode */
if(NETSTACK_RADIO.get_value(RADIO_PARAM_TX_MODE, &radio_tx_mode) != RADIO_RESULT_OK) {
printf("TSCH:! radio does not support getting RADIO_PARAM_TX_MODE. Abort init.\n");
LOG_ERR("! radio does not support getting RADIO_PARAM_TX_MODE. Abort init.\n");
return;
}
/* Unset CCA */
radio_tx_mode &= ~RADIO_TX_MODE_SEND_ON_CCA;
if(NETSTACK_RADIO.set_value(RADIO_PARAM_TX_MODE, radio_tx_mode) != RADIO_RESULT_OK) {
printf("TSCH:! radio does not support setting required RADIO_PARAM_TX_MODE. Abort init.\n");
LOG_ERR("! radio does not support setting required RADIO_PARAM_TX_MODE. Abort init.\n");
return;
}
/* Test setting channel */
if(NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, TSCH_DEFAULT_HOPPING_SEQUENCE[0]) != RADIO_RESULT_OK) {
printf("TSCH:! radio does not support setting channel. Abort init.\n");
LOG_ERR("! radio does not support setting channel. Abort init.\n");
return;
}
/* Test getting timestamp */
if(NETSTACK_RADIO.get_object(RADIO_PARAM_LAST_PACKET_TIMESTAMP, &t, sizeof(rtimer_clock_t)) != RADIO_RESULT_OK) {
printf("TSCH:! radio does not support getting last packet timestamp. Abort init.\n");
LOG_ERR("! radio does not support getting last packet timestamp. Abort init.\n");
return;
}
/* Check max hopping sequence length vs default sequence length */
if(TSCH_HOPPING_SEQUENCE_MAX_LEN < sizeof(TSCH_DEFAULT_HOPPING_SEQUENCE)) {
printf("TSCH:! TSCH_HOPPING_SEQUENCE_MAX_LEN < sizeof(TSCH_DEFAULT_HOPPING_SEQUENCE). Abort init.\n");
LOG_ERR("! TSCH_HOPPING_SEQUENCE_MAX_LEN < sizeof(TSCH_DEFAULT_HOPPING_SEQUENCE). Abort init.\n");
}
/* Init TSCH sub-modules */
@ -872,9 +870,9 @@ send_packet(mac_callback_t sent, void *ptr)
if(!tsch_is_associated) {
if(!tsch_is_initialized) {
PRINTF("TSCH:! not initialized (see earlier logs), drop outgoing packet\n");
LOG_WARN("! not initialized (see earlier logs), drop outgoing packet\n");
} else {
PRINTF("TSCH:! not associated, drop outgoing packet\n");
LOG_WARN("! not associated, drop outgoing packet\n");
}
ret = MAC_TX_ERR;
mac_call_sent_callback(sent, ptr, ret, 1);
@ -920,27 +918,27 @@ send_packet(mac_callback_t sent, void *ptr)
#endif
if((hdr_len = NETSTACK_FRAMER.create()) < 0) {
PRINTF("TSCH:! can't send packet due to framer error\n");
LOG_ERR("! can't send packet due to framer error\n");
ret = MAC_TX_ERR;
} else {
struct tsch_packet *p;
/* Enqueue packet */
p = tsch_queue_add_packet(addr, sent, ptr);
if(p == NULL) {
PRINTF("TSCH:! can't send packet to %u with seqno %u, queue %u %u\n",
LOG_ERR("! can't send packet to %u with seqno %u, queue %u %u\n",
TSCH_LOG_ID_FROM_LINKADDR(addr), tsch_packet_seqno,
packet_count_before,
tsch_queue_packet_count(addr));
ret = MAC_TX_ERR;
} else {
p->header_len = hdr_len;
PRINTF("TSCH: send packet to %u with seqno %u, queue %u %u, len %u %u\n",
LOG_INFO("send packet to %u with seqno %u, queue %u %u, len %u %u\n",
TSCH_LOG_ID_FROM_LINKADDR(addr), tsch_packet_seqno,
packet_count_before,
tsch_queue_packet_count(addr),
p->header_len,
queuebuf_datalen(p->qb));
(void)packet_count_before; /* Discard "variable set but unused" warning in case of TSCH_LOG_LEVEL of 0 */
(void)packet_count_before; /* Discard "variable set but unused" warning in case of TSCH_LOG_PER_SLOT */
}
}
if(ret != MAC_TX_DEFERRED) {
@ -956,7 +954,7 @@ packet_input(void)
frame_parsed = NETSTACK_FRAMER.parse();
if(frame_parsed < 0) {
PRINTF("TSCH:! failed to parse %u\n", packetbuf_datalen());
LOG_ERR("! failed to parse %u\n", packetbuf_datalen());
} else {
int duplicate = 0;
@ -966,7 +964,7 @@ packet_input(void)
duplicate = mac_sequence_is_duplicate();
if(duplicate) {
/* Drop the packet. */
PRINTF("TSCH:! drop dup ll from %u seqno %u\n",
LOG_WARN("! drop dup ll from %u seqno %u\n",
TSCH_LOG_ID_FROM_LINKADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER)),
packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO));
} else {
@ -975,7 +973,7 @@ packet_input(void)
}
if(!duplicate) {
PRINTF("TSCH: received from %u with seqno %u\n",
LOG_INFO("received from %u with seqno %u\n",
TSCH_LOG_ID_FROM_LINKADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER)),
packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO));
NETSTACK_NETWORK.input();
@ -994,7 +992,7 @@ turn_on(void)
process_start(&tsch_send_eb_process, NULL);
/* try to associate to a network or start one if setup as coordinator */
process_start(&tsch_process, NULL);
PRINTF("TSCH: starting as %s\n", tsch_is_coordinator ? "coordinator" : "node");
LOG_INFO("starting as %s\n", tsch_is_coordinator ? "coordinator": "node");
return 1;
}
return 0;

74
core/sys/log-conf.h Normal file
View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 2017, RISE SICS.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/**
* \file
* Default log levels for a number of modules
* \author
* Simon Duquennoy <simon.duquennoy@ri.se>
*/
/** \addtogroup sys
* @{ */
/** \addtogroup log
* @{ */
#ifndef __LOG_CONF_H__
#define __LOG_CONF_H__
/* A list of currently supported modules */
#ifndef IPV6_LOG_LEVEL
#define IPV6_LOG_LEVEL LOG_LEVEL_NONE
#endif /* IPV6_LOG_LEVEL */
#ifndef SICSLOWPAN_LOG_LEVEL
#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 */
#ifndef FRAMER_LOG_LEVEL
#define FRAMER_LOG_LEVEL LOG_LEVEL_NONE
#endif /* FRAMER_LOG_LEVEL */
#endif /* __LOG_CONF_H__ */
/** @} */
/** @} */

View File

@ -1,45 +1,150 @@
/*
* Copyright (c) 2004, Swedish Institute of Computer Science.
* All rights reserved.
* Copyright (c) 2017, RISE SICS.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
#ifndef LOG_H_
#define LOG_H_
#include "contiki-conf.h"
/**
* \file
* Header file for the logging system
* \author
* Simon Duquennoy <simon.duquennoy@ri.se>
*/
#if LOG_CONF_ENABLED
void log_message(const char *part1, const char *part2);
#else /* LOG_CONF_ENABLED */
#define log_message(p1, p2)
#endif /* LOG_CONF_ENABLED */
/** \addtogroup sys
* @{ */
#endif /* LOG_H_ */
/**
* \defgroup log Per-module, per-level logging
* @{
*
* The log module performs per-module, per-level logging
*
*/
#ifndef __LOG_H__
#define __LOG_H__
#include <stdio.h>
#include "net/linkaddr.h"
#include "sys/log-conf.h"
#if NETSTACK_CONF_WITH_IPV6
#include "net/ip/uip.h"
#endif /* NETSTACK_CONF_WITH_IPV6 */
void net_debug_lladdr_print(const linkaddr_t *addr);
void uip_debug_ipaddr_print(const uip_ipaddr_t *addr);
#define LOG_LEVEL_NONE 0 /* No log */
#define LOG_LEVEL_ERR 1 /* Errors */
#define LOG_LEVEL_WARN 2 /* Warnings */
#define LOG_LEVEL_INFO 3 /* Basic info */
#define LOG_LEVEL_DBG 4 /* Detailled debug */
/* Prefix all logs with file name and line-of-code */
#ifdef LOG_CONF_WITH_LOC
#define LOG_WITH_LOC LOG_CONF_WITH_LOC
#else /* LOG_CONF_WITH_LOC */
#define LOG_WITH_LOC 0
#endif /* LOG_CONF_WITH_LOC */
/* Custom output function -- default is printf */
#ifdef LOG_CONF_OUTPUT
#define LOG_OUTPUT(...) LOG_CONF_OUTPUT(__VA_ARGS__)
#else /* LOG_CONF_OUTPUT */
#define LOG_OUTPUT(...) printf(__VA_ARGS__)
#endif /* LOG_CONF_OUTPUT */
/* Cooja annotations */
#ifdef LOG_CONF_WITH_ANNOTATE
#define LOG_WITH_ANNOTATE LOG_CONF_WITH_ANNOTATE
#else /* LOG_CONF_WITH_ANNOTATE */
#define LOG_WITH_ANNOTATE 0
#endif /* LOG_CONF_WITH_ANNOTATE */
/* Main log function */
#define LOG(level, ...) do { \
if(level <= LOG_LEVEL) { \
if(LOG_WITH_LOC) { \
LOG_OUTPUT("%s:%d: ", __FILE__, __LINE__); \
} \
LOG_OUTPUT("%s: ", LOG_MODULE); \
LOG_OUTPUT(__VA_ARGS__); \
} \
} while (0)
/* For Cooja annotations */
#define LOG_ANNOTATE(...) do { \
if(LOG_WITH_ANNOTATE) { \
LOG_OUTPUT(__VA_ARGS__); \
} \
} while (0)
/* Link-layer address */
#define LOG_LLADDR(level, lladdr) do { \
if(level <= LOG_LEVEL) { \
net_debug_lladdr_print(lladdr); \
} \
} while (0)
/* IPv6 address */
#define LOG_6ADDR(level, lladdr) do { \
if(level <= LOG_LEVEL) { \
uip_debug_ipaddr_print(lladdr); \
} \
} while (0)
/* More compact versions of LOG macros */
#define LOG_ERR(...) LOG(LOG_LEVEL_ERR, __VA_ARGS__)
#define LOG_WARN(...) LOG(LOG_LEVEL_WARN, __VA_ARGS__)
#define LOG_INFO(...) LOG(LOG_LEVEL_INFO, __VA_ARGS__)
#define LOG_DBG(...) LOG(LOG_LEVEL_DBG, __VA_ARGS__)
#define LOG_ERR_LLADDR(...) LOG_LLADDR(LOG_LEVEL_ERR, __VA_ARGS__)
#define LOG_WARN_LLADDR(...) LOG_LLADDR(LOG_LEVEL_WARN, __VA_ARGS__)
#define LOG_INFO_LLADDR(...) LOG_LLADDR(LOG_LEVEL_INFO, __VA_ARGS__)
#define LOG_DBG_LLADDR(...) LOG_LLADDR(LOG_LEVEL_DBG, __VA_ARGS__)
#define LOG_ERR_6ADDR(...) LOG_6ADDR(LOG_LEVEL_ERR, __VA_ARGS__)
#define LOG_WARN_6ADDR(...) LOG_6ADDR(LOG_LEVEL_WARN, __VA_ARGS__)
#define LOG_INFO_6ADDR(...) LOG_6ADDR(LOG_LEVEL_INFO, __VA_ARGS__)
#define LOG_DBG_6ADDR(...) LOG_6ADDR(LOG_LEVEL_DBG, __VA_ARGS__)
/* For testing log level */
#define LOG_ERR_ENABLED (LOG_LEVEL >= LOG_LEVEL_ERR)
#define LOG_WARN_ENABLED (LOG_LEVEL >= LOG_LEVEL_WARN)
#define LOG_INFO_ENABLED (LOG_LEVEL >= LOG_LEVEL_INFO)
#define LOG_DBG_ENABLED (LOG_LEVEL >= LOG_LEVEL_DBG)
#define LOG_ANNOTATE_ENABLED (LOG_LEVEL >= LOG_LEVEL_ANNOTATE)
#endif /* __LOG_H__ */
/** @} */
/** @} */

View File

@ -55,7 +55,12 @@
#endif
#include "contiki-net.h"
#include "sys/log.h"
#if LOG_CONF_ENABLED
void log_message(const char *part1, const char *part2);
#else /* LOG_CONF_ENABLED */
#define log_message(p1, p2)
#endif /* LOG_CONF_ENABLED */
#include "net/wpcap.h"
@ -155,7 +160,7 @@ HMODULE wpcap;
static struct pcap *pcap;
/* uip_lladdr is defined in uip.c. It is not used in uip6.c.
/* uip_lladdr is defined in uip.c. It is not used in uip6.c.
* If needed for some purpose it can be defined here
*/
#if NETSTACK_CONF_WITH_IPV6
@ -350,7 +355,7 @@ init_pcap(struct in_addr addr)
struct pcap_if *interfaces;
struct pcap_addr *paddr;
char error[256];
if(pcap_findalldevs(&interfaces, error) == -1) {
error_exit(error);
}
@ -624,7 +629,7 @@ wpcap_poll(void)
PRINTF("SIN: Discarding echoed packet\n");
return 0;
}
/* To implement multihop, ignore packets to us from specified source macs
*/
// printf("ethtype=%x %x",*(packet+2*UIP_LLADDR_LEN),*(packet+2*UIP_LLADDR_LEN+1));

View File

@ -31,7 +31,6 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "sys/log.h"
#include "lib/simEnvChange.h"
#define IMPLEMENT_PRINTF 1

View File

@ -82,7 +82,7 @@ OBJDUMP:=$(CROSS_COMPILE)-objdump
ARCH = jn516x-ccm-star.c exceptions.c rtimer-arch.c rtimer-arch-slow.c \
slip_uart0.c clock.c micromac-radio.c \
mtarch.c node-id.c watchdog.c log.c slip.c sprintf.c
mtarch.c node-id.c watchdog.c slip.c sprintf.c
# Default uart0 for printf and slip
TARGET_WITH_UART0 ?= 1
TARGET_WITH_UART1 ?= 0

View File

@ -1,56 +0,0 @@
/*
* Copyright (c) 2015, SICS Swedish ICT.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the Contiki OS
*
*/
#include <unistd.h>
#include <string.h>
#include "net/ip/uip.h"
#include "sys/log.h"
/*---------------------------------------------------------------------------*/
#if LOG_CONF_ENABLED
void
log_message(char *m1, char *m2)
{
printf("%s%s\n", m1, m2);
}
#endif /* LOG_CONF_ENABLED */
/*---------------------------------------------------------------------------*/
#if UIP_LOGGING
void
uip_log(char *m)
{
printf("uip_log: %s\n", m);
}
#endif /* UIP_LOGGING */
/*---------------------------------------------------------------------------*/

View File

@ -392,11 +392,3 @@ main(int argc, char **argv)
return 0;
}
/*---------------------------------------------------------------------------*/
#if LOG_CONF_ENABLED
void
log_message(char *m1, char *m2)
{
printf("%s%s\n", m1, m2);
}
#endif /* LOG_CONF_ENABLED */

View File

@ -92,10 +92,9 @@
/******************* Configure TSCH ********************/
/*******************************************************/
/* TSCH logging. 0: disabled. 1: basic log. 2: with delayed
* log messages from interrupt */
#undef TSCH_LOG_CONF_LEVEL
#define TSCH_LOG_CONF_LEVEL 2
/* TSCH per-slot logging */
#undef TSCH_LOG_CONF_PER_SLOT
#define TSCH_LOG_CONF_PER_SLOT 1
/* IEEE802.15.4 PANID */
#undef IEEE802154_CONF_PANID

View File

@ -0,0 +1,6 @@
CONTIKI_PROJECT = logging
all: $(CONTIKI_PROJECT)
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
CONTIKI = ../..
include $(CONTIKI)/Makefile.include

View File

@ -0,0 +1,6 @@
Logging
===========
This example shows how to configure the logging system. See core/net/sys/log.h
and core/net/sys/log-conf.h more information on logging. Edit project-conf.h
for configure debug levels for the different modules.

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 2006, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/**
* \file
* A very simple Contiki application showing how Contiki programs look
* \author
* Adam Dunkels <adam@sics.se>
*/
#include "contiki.h"
#include <stdio.h> /* For printf() */
/*---------------------------------------------------------------------------*/
PROCESS(logging_example_process, "Logging example process");
AUTOSTART_PROCESSES(&logging_example_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(logging_example_process, ev, data)
{
PROCESS_BEGIN();
printf("Hello, world, from logging example process\n");
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2015, Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
/* Set maximum debug level on all modules. See core/sys/log-conf.h for
* a list of supported modules. The different log levels are defined in
* core/sys/log.h:
* LOG_LEVEL_NONE No log
* LOG_LEVEL_ERR Errors
* LOG_LEVEL_WARN Warnings
* LOG_LEVEL_INFO Basic info
* LOG_LEVEL_DBG Detailled debug
*/
#define IPV6_LOG_LEVEL LOG_LEVEL_DBG
#define SICSLOWPAN_LOG_LEVEL LOG_LEVEL_DBG
#define TCPIP_LOG_LEVEL LOG_LEVEL_DBG
#define MAC_LOG_LEVEL LOG_LEVEL_DBG
#define FRAMER_LOG_LEVEL LOG_LEVEL_DBG
/* Enable cooja annotations */
#define LOG_CONF_WITH_ANNOTATE 1
#endif

View File

@ -68,10 +68,9 @@
#define TSCH_CALLBACK_JOINING_NETWORK tsch_rpl_callback_joining_network
#define TSCH_CALLBACK_LEAVING_NETWORK tsch_rpl_callback_leaving_network
/* TSCH logging. 0: disabled. 1: basic log. 2: with delayed
* log messages from interrupt */
#undef TSCH_LOG_CONF_LEVEL
#define TSCH_LOG_CONF_LEVEL 2
/* TSCH per-slot logging */
#undef TSCH_LOG_CONF_PER_SLOT
#define TSCH_LOG_CONF_PER_SLOT 1
/* Do not start TSCH at init, wait for NETSTACK_MAC.on() */
#undef TSCH_CONF_AUTOSTART

View File

@ -38,7 +38,7 @@
#define WITH_TSCH 1
#define WITH_TSCH_SECURITY 0
#define TSCH_LOG_CONF_LEVEL 2
#define TSCH_LOG_CONF_PER_SLOT 1
#define WITH_COAP_RESOURCES 0
#undef ENABLE_COOJA_DEBUG

View File

@ -6,6 +6,7 @@ hello-world/native \
hello-world/sky \
eeprom-test/native \
ipv6/multicast/sky \
logging/native \
TOOLS=

View File

@ -41,7 +41,8 @@ cfs-coffee/openmote-cc2538 \
cfs-coffee/zoul \
ipv6/rpl-tsch/zoul \
ipv6/rpl-tsch/zoul:MAKE_WITH_ORCHESTRA=1 \
ipv6/rpl-tsch/zoul:MAKE_WITH_SECURITY=1
ipv6/rpl-tsch/zoul:MAKE_WITH_SECURITY=1 \
logging/zoul \
TOOLS=

View File

@ -18,7 +18,8 @@ platform-specific/jn516x/tsch/uart1-test-node/jn516x \
sensniff/jn516x \
ipv6/rpl-tsch/jn516x \
ipv6/rpl-tsch/jn516x:MAKE_WITH_ORCHESTRA=1 \
ipv6/rpl-tsch/jn516x:MAKE_WITH_SECURITY=1
ipv6/rpl-tsch/jn516x:MAKE_WITH_SECURITY=1 \
logging/jn516x
TOOLS=

View File

@ -5,14 +5,15 @@ TOOLSDIR=../../tools
# even though it's not a valid IPV6 address. This is due to limitation
# of the testing framework which splits compliation arguments using
# a colon.
EXAMPLES = \
hello-world/nrf52dk \
platform-specific/nrf52dk/coap-demo/nrf52dk:coap-server \
platform-specific/nrf52dk/coap-demo/nrf52dk:coap-client:SERVER_IPV6_ADDR=ffff \
platform-specific/nrf52dk/mqtt-demo/nrf52dk \
platform-specific/nrf52dk/blink-hello/nrf52dk \
platform-specific/nrf52dk/timer-test/nrf52dk
platform-specific/nrf52dk/timer-test/nrf52dk \
logging/nrf52dk
TOOLS=

View File

@ -38,8 +38,9 @@
#undef QUEUEBUF_CONF_NUM
#define QUEUEBUF_CONF_NUM 1
#undef TSCH_LOG_CONF_LEVEL
#define TSCH_LOG_CONF_LEVEL 2
/* TSCH per-slot logging */
#undef TSCH_LOG_CONF_PER_SLOT
#define TSCH_LOG_CONF_PER_SLOT 1
#undef TSCH_CONF_AUTOSTART
#define TSCH_CONF_AUTOSTART 1