mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/*: replace #if ENABLE_DEBUG with IS_ACTIVE
This commit is contained in:
parent
9dd3b7a3ec
commit
922e2ac1c9
@ -312,13 +312,13 @@ static int _isotp_rcv_ff(struct isotp *isotp, struct can_frame *frame, int ae)
|
||||
((uint8_t *)isotp->rx.snip->data)[isotp->rx.idx++] = frame->data[i];
|
||||
}
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
DEBUG("_isotp_rcv_ff: rx.buf=");
|
||||
for (unsigned i = 0; i < isotp->rx.idx; i++) {
|
||||
DEBUG("%02hhx", ((uint8_t *)isotp->rx.snip->data)[i]);
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
DEBUG("_isotp_rcv_ff: rx.buf=");
|
||||
for (unsigned i = 0; i < isotp->rx.idx; i++) {
|
||||
DEBUG("%02hhx", ((uint8_t *)isotp->rx.snip->data)[i]);
|
||||
}
|
||||
DEBUG("\n");
|
||||
}
|
||||
DEBUG("\n");
|
||||
#endif
|
||||
|
||||
isotp->rx.sn = 1;
|
||||
|
||||
@ -360,13 +360,13 @@ static int _isotp_rcv_cf(struct isotp *isotp, struct can_frame *frame, int ae)
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
DEBUG("_isotp_rcv_cf: rx.buf=");
|
||||
for (unsigned i = 0; i < isotp->rx.idx; i++) {
|
||||
DEBUG("%02hhx", ((uint8_t *)isotp->rx.snip->data)[i]);
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
DEBUG("_isotp_rcv_cf: rx.buf=");
|
||||
for (unsigned i = 0; i < isotp->rx.idx; i++) {
|
||||
DEBUG("%02hhx", ((uint8_t *)isotp->rx.snip->data)[i]);
|
||||
}
|
||||
DEBUG("\n");
|
||||
}
|
||||
DEBUG("\n");
|
||||
#endif
|
||||
|
||||
if (isotp->rx.idx >= isotp->rx.snip->size) {
|
||||
isotp->rx.state = ISOTP_IDLE;
|
||||
@ -392,13 +392,13 @@ static int _isotp_rcv(struct isotp *isotp, struct can_frame *frame)
|
||||
int ae = (isotp->opt.flags & CAN_ISOTP_EXTEND_ADDR) ? 1 : 0;
|
||||
uint8_t n_pci_type;
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
DEBUG("_isotp_rcv: id=%" PRIx32 " data=", frame->can_id);
|
||||
for (int i = 0; i < frame->can_dlc; i++) {
|
||||
DEBUG("%02hhx", frame->data[i]);
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
DEBUG("_isotp_rcv: id=%" PRIx32 " data=", frame->can_id);
|
||||
for (int i = 0; i < frame->can_dlc; i++) {
|
||||
DEBUG("%02hhx", frame->data[i]);
|
||||
}
|
||||
DEBUG("\n");
|
||||
}
|
||||
DEBUG("\n");
|
||||
#endif
|
||||
|
||||
if (ae && frame->data[0] != isotp->opt.rx_ext_address) {
|
||||
return 1;
|
||||
@ -448,13 +448,13 @@ static int _isotp_send_fc(struct isotp *isotp, int ae, uint8_t status)
|
||||
|
||||
isotp->rx.bs = 0;
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
DEBUG("_isotp_send_fc: id=%" PRIx32 " data=", fc.can_id);
|
||||
for (int i = 0; i < fc.can_dlc; i++) {
|
||||
DEBUG("%02hhx", fc.data[i]);
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
DEBUG("_isotp_send_fc: id=%" PRIx32 " data=", fc.can_id);
|
||||
for (int i = 0; i < fc.can_dlc; i++) {
|
||||
DEBUG("%02hhx", fc.data[i]);
|
||||
}
|
||||
DEBUG("\n");
|
||||
}
|
||||
DEBUG("\n");
|
||||
#endif
|
||||
|
||||
xtimer_set(&isotp->rx_timer, CAN_ISOTP_TIMEOUT_N_Ar);
|
||||
isotp->rx.tx_handle = raw_can_send(isotp->entry.ifnum, &fc, isotp_pid);
|
||||
|
@ -30,9 +30,7 @@
|
||||
#include "assert.h"
|
||||
#include "memarray.h"
|
||||
|
||||
#ifdef MODULE_CAN_MBOX
|
||||
#include "mbox.h"
|
||||
#endif
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
@ -71,7 +69,7 @@ static void _insert_to_list(can_reg_entry_t **list, filter_el_t *el);
|
||||
static filter_el_t *_find_filter_el(can_reg_entry_t *list, can_reg_entry_t *entry, canid_t can_id, canid_t mask, void *data);
|
||||
static int _filter_is_used(unsigned int ifnum, canid_t can_id, canid_t mask);
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
#if IS_ACTIVE(ENABLE_DEBUG)
|
||||
static void _print_filters(void)
|
||||
{
|
||||
for (int i = 0; i < (int)CAN_DLL_NUMOF; i++) {
|
||||
@ -84,7 +82,6 @@ static void _print_filters(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define PRINT_FILTERS() _print_filters()
|
||||
#else
|
||||
#define PRINT_FILTERS()
|
||||
@ -214,13 +211,15 @@ int can_router_register(can_reg_entry_t *entry, canid_t can_id, canid_t mask, vo
|
||||
filter_el_t *filter;
|
||||
int ret;
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
if (entry->type == CAN_TYPE_DEFAULT) {
|
||||
DEBUG("can_router_register: ifnum=%d, pid=%" PRIkernel_pid ", can_id=0x%" PRIx32
|
||||
", mask=0x%" PRIx32 ", data=%p\n", entry->ifnum, entry->target.pid, can_id, mask, param);
|
||||
} else if (entry->type == CAN_TYPE_MBOX) {
|
||||
DEBUG("can_router_register: ifnum=%d, mbox=%p, can_id=0x%" PRIx32
|
||||
", mask=0x%" PRIx32 ", data=%p\n", entry->ifnum, (void *)entry->target.mbox, can_id, mask, param);
|
||||
#ifdef MODULE_CAN_MBOX
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
if (entry->type == CAN_TYPE_DEFAULT) {
|
||||
DEBUG("can_router_register: ifnum=%d, pid=%" PRIkernel_pid ", can_id=0x%" PRIx32
|
||||
", mask=0x%" PRIx32 ", data=%p\n", entry->ifnum, entry->target.pid, can_id, mask, param);
|
||||
} else if (entry->type == CAN_TYPE_MBOX) {
|
||||
DEBUG("can_router_register: ifnum=%d, mbox=%p, can_id=0x%" PRIx32
|
||||
", mask=0x%" PRIx32 ", data=%p\n", entry->ifnum, (void *)entry->target.mbox, can_id, mask, param);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -263,13 +262,15 @@ int can_router_unregister(can_reg_entry_t *entry, canid_t can_id,
|
||||
filter_el_t *el;
|
||||
int ret;
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
if (entry->type == CAN_TYPE_DEFAULT) {
|
||||
DEBUG("can_router_unregister: ifnum=%d, pid=%" PRIkernel_pid ", can_id=0x%" PRIx32
|
||||
", mask=0x%" PRIx32 ", data=%p", entry->ifnum, entry->target.pid, can_id, mask, param);
|
||||
} else if (entry->type == CAN_TYPE_MBOX) {
|
||||
DEBUG("can_router_unregister: ifnum=%d, mbox=%p, can_id=0x%" PRIx32
|
||||
", mask=0x%" PRIx32 ", data=%p\n", entry->ifnum, (void *)entry->target.mbox, can_id, mask, param);
|
||||
#ifdef MODULE_CAN_MBOX
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
if (entry->type == CAN_TYPE_DEFAULT) {
|
||||
DEBUG("can_router_unregister: ifnum=%d, pid=%" PRIkernel_pid ", can_id=0x%" PRIx32
|
||||
", mask=0x%" PRIx32 ", data=%p", entry->ifnum, entry->target.pid, can_id, mask, param);
|
||||
} else if (entry->type == CAN_TYPE_MBOX) {
|
||||
DEBUG("can_router_unregister: ifnum=%d, mbox=%p, can_id=0x%" PRIx32
|
||||
", mask=0x%" PRIx32 ", data=%p\n", entry->ifnum, (void *)entry->target.mbox, can_id, mask, param);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -317,9 +318,8 @@ int can_router_dispatch_rx_indic(can_pkt_t *pkt)
|
||||
int res = 0;
|
||||
msg_t msg;
|
||||
msg.type = CAN_MSG_RX_INDICATION;
|
||||
#if ENABLE_DEBUG
|
||||
int msg_cnt = 0;
|
||||
#endif
|
||||
|
||||
DEBUG("can_router_dispatch_rx_indic: pkt=%p, ifnum=%d, can_id=%" PRIx32 "\n",
|
||||
(void *)pkt, pkt->entry.ifnum, pkt->frame.can_id);
|
||||
|
||||
@ -335,9 +335,11 @@ int can_router_dispatch_rx_indic(can_pkt_t *pkt)
|
||||
PRIkernel_pid "\n", entry->target.pid);
|
||||
atomic_fetch_add(&pkt->ref_count, 1);
|
||||
msg.content.ptr = can_pkt_alloc_rx_data(&pkt->frame, sizeof(pkt->frame), el->data);
|
||||
#if ENABLE_DEBUG
|
||||
msg_cnt++;
|
||||
#endif
|
||||
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
msg_cnt++;
|
||||
}
|
||||
|
||||
if (!msg.content.ptr || (_send_msg(&msg, entry) <= 0)) {
|
||||
can_pkt_free_rx_data(msg.content.ptr);
|
||||
atomic_fetch_sub(&pkt->ref_count, 1);
|
||||
@ -349,9 +351,9 @@ int can_router_dispatch_rx_indic(can_pkt_t *pkt)
|
||||
}
|
||||
}
|
||||
mutex_unlock(&lock);
|
||||
#if ENABLE_DEBUG
|
||||
|
||||
DEBUG("can_router_dispatch_rx: msg send to %d threads\n", msg_cnt);
|
||||
#endif
|
||||
|
||||
if (atomic_load(&pkt->ref_count) == 0) {
|
||||
can_pkt_free(pkt);
|
||||
}
|
||||
|
@ -45,15 +45,9 @@
|
||||
#include "bitarithm.h"
|
||||
#include "ecc/golay2412.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
#define DEBUG_FEC_GOLAY2412 (1)
|
||||
#else
|
||||
#define DEBUG_FEC_GOLAY2412 (0)
|
||||
#endif
|
||||
|
||||
/* generator matrix transposed [24 x 12] */
|
||||
static const uint32_t golay2412_Gt[24] = {
|
||||
0x08ed, 0x01db, 0x03b5, 0x0769, 0x0ed1, 0x0da3, 0x0b47, 0x068f,
|
||||
@ -75,7 +69,6 @@ static const uint32_t golay2412_H[12] = {
|
||||
0x00008d1d, 0x00004a3b, 0x00002477, 0x00001ffe
|
||||
};
|
||||
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
/* print string of bits to standard output */
|
||||
static inline void liquid_print_bitstring(uint32_t _x,
|
||||
uint32_t _n)
|
||||
@ -86,7 +79,6 @@ static inline void liquid_print_bitstring(uint32_t _x,
|
||||
printf("%" PRIu32, (_x >> (_n - i - 1)) & 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
static uint32_t block_get_enc_msg_len(uint32_t _dec_msg_len,
|
||||
@ -107,16 +99,15 @@ static uint32_t block_get_enc_msg_len(uint32_t _dec_msg_len,
|
||||
/* compute total number of bytes out: ceil(num_bits_out/8) */
|
||||
uint32_t num_bytes_out = num_bits_out / 8 + ((num_bits_out % 8) ? 1 : 0);
|
||||
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
printf("block_get_enc_msg_len(%" PRIu32 ",%" PRIu32 ",%" PRIu32 ")\n", _dec_msg_len, _m, _k);
|
||||
printf(" dec msg len : %" PRIu32 " bytes\n", _dec_msg_len);
|
||||
printf(" m : %" PRIu32 " bits\n", _m);
|
||||
printf(" k : %" PRIu32 " bits\n", _k);
|
||||
printf(" num bits in : %" PRIu32 " bits\n", num_bits_in);
|
||||
printf(" num blocks : %" PRIu32 "\n", num_blocks);
|
||||
printf(" num bits out: %" PRIu32 " bits\n", num_bits_out);
|
||||
printf(" enc msg len : %" PRIu32 " bytes\n", num_bytes_out);
|
||||
#endif
|
||||
DEBUG("block_get_enc_msg_len(%" PRIu32 ",%" PRIu32 ",%" PRIu32 ")\n",
|
||||
_dec_msg_len, _m, _k);
|
||||
DEBUG(" dec msg len : %" PRIu32 " bytes\n", _dec_msg_len);
|
||||
DEBUG(" m : %" PRIu32 " bits\n", _m);
|
||||
DEBUG(" k : %" PRIu32 " bits\n", _k);
|
||||
DEBUG(" num bits in : %" PRIu32 " bits\n", num_bits_in);
|
||||
DEBUG(" num blocks : %" PRIu32 "\n", num_blocks);
|
||||
DEBUG(" num bits out: %" PRIu32 " bits\n", num_bits_out);
|
||||
DEBUG(" enc msg len : %" PRIu32 " bytes\n", num_bytes_out);
|
||||
|
||||
return num_bytes_out;
|
||||
}
|
||||
@ -187,84 +178,75 @@ static uint32_t golay2412_decode_symbol(uint32_t _sym_enc,
|
||||
|
||||
/* compute syndrome vector, s = r*H^T = ( H*r^T )^T */
|
||||
s = golay2412_matrix_mul(_sym_enc, _B, 12);
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
printf("s (syndrome vector): "); liquid_print_bitstring(s, 12); printf("\n");
|
||||
#endif
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
printf("s (syndrome vector): ");
|
||||
liquid_print_bitstring(s, 12);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/* compute weight of s (12 bits) */
|
||||
uint8_t ws = bitarithm_bits_set_u32(s & 0x00000fff);
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
printf("w(s) = %u\n", ws);
|
||||
#endif
|
||||
DEBUG("w(s) = %u\n", ws);
|
||||
|
||||
/* step 2: */
|
||||
e_hat = 0;
|
||||
if (ws <= 3) {
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
printf(" w(s) <= 3: estimating error vector as [s, 0(12)]\n");
|
||||
#endif
|
||||
DEBUG(" w(s) <= 3: estimating error vector as [s, 0(12)]\n");
|
||||
/* set e_hat = [s 0(12)] */
|
||||
e_hat = (s << 12) & 0xfff000;
|
||||
}
|
||||
else {
|
||||
/* step 3: search for p[i] s.t. w(s+p[i]) <= 2 */
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
printf(" searching for w(s + p_i) <= 2...\n");
|
||||
#endif
|
||||
DEBUG(" searching for w(s + p_i) <= 2...\n");
|
||||
int8_t s_index = golay2412_parity_search(s, _A);
|
||||
|
||||
if (s_index >= 0) {
|
||||
/* vector found! */
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
printf(" w(s + p[%2i]) <= 2: estimating error vector as [s+p[%2i],"
|
||||
"u[%2i]]\n", s_index, s_index, s_index);
|
||||
#endif
|
||||
DEBUG(" w(s + p[%2i]) <= 2: estimating error vector as "
|
||||
"[s+p[%2i],u[%2i]]\n", s_index, s_index, s_index);
|
||||
|
||||
/* NOTE : uj = 1 << (12-j-1) */
|
||||
e_hat = ((s ^ _A[s_index]) << 12) | (1 << (11 - s_index));
|
||||
}
|
||||
else {
|
||||
/* step 4: compute s*P */
|
||||
uint32_t sP = golay2412_matrix_mul(s, _A, 12);
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
printf("s*P: "); liquid_print_bitstring(sP, 12); printf("\n");
|
||||
#endif
|
||||
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
printf("s*P: ");
|
||||
liquid_print_bitstring(sP, 12);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/* compute weight of sP (12 bits) */
|
||||
uint8_t wsP = bitarithm_bits_set_u32(sP & 0x00000fff);
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
printf("w(s*P) = %u\n", wsP);
|
||||
#endif
|
||||
DEBUG("w(s*P) = %u\n", wsP);
|
||||
|
||||
if (wsP == 2 || wsP == 3) {
|
||||
/* step 5: set e = [0, s*P] */
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
printf(" w(s*P) in [2,3]: estimating error vector as [0(12), s*P]\n");
|
||||
#endif
|
||||
DEBUG(" w(s*P) in [2,3]: estimating error vector as "
|
||||
"[0(12), s*P]\n");
|
||||
e_hat = sP;
|
||||
}
|
||||
else {
|
||||
/* step 6: search for p[i] s.t. w(s*P + p[i]) == 2... */
|
||||
DEBUG(" searching for w(s*P + p_i) == 2...\n");
|
||||
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
printf(" searching for w(s*P + p_i) == 2...\n");
|
||||
#endif
|
||||
int8_t sP_index = golay2412_parity_search(sP, _A);
|
||||
|
||||
if (sP_index >= 0) {
|
||||
/* vector found! */
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
printf(" w(s*P + p[%2i]) == 2: estimating error vector as [u[%2i],"
|
||||
"s*P+p[%2i]]\n", sP_index, sP_index, sP_index);
|
||||
#endif
|
||||
DEBUG(" w(s*P + p[%2i]) == 2: estimating error vector "
|
||||
"as [u[%2i],s*P+p[%2i]]\n",
|
||||
sP_index, sP_index, sP_index);
|
||||
|
||||
/* NOTE : uj = 1 << (12-j-1)
|
||||
* [ uj << 1 2 ] [ sP + p[j] ] */
|
||||
e_hat = (1L << (23 - sP_index)) | (sP ^ _A[sP_index]);
|
||||
}
|
||||
else {
|
||||
/* step 7: decoding error */
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
printf(" **** decoding error\n");
|
||||
#endif
|
||||
DEBUG(" **** decoding error\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -272,14 +254,15 @@ static uint32_t golay2412_decode_symbol(uint32_t _sym_enc,
|
||||
|
||||
/* step 8: compute estimated transmitted message: v_hat = r + e_hat */
|
||||
v_hat = _sym_enc ^ e_hat;
|
||||
#if DEBUG_FEC_GOLAY2412
|
||||
printf("r (received vector): ");
|
||||
liquid_print_bitstring(_sym_enc, 24); printf("\n");
|
||||
printf("e-hat (estimated error vector): ");
|
||||
liquid_print_bitstring(e_hat, 24); printf("\n");
|
||||
printf("v-hat (estimated tx vector): ");
|
||||
liquid_print_bitstring(v_hat, 24); printf("\n");
|
||||
#endif
|
||||
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
printf("r (received vector): ");
|
||||
liquid_print_bitstring(_sym_enc, 24); printf("\n");
|
||||
printf("e-hat (estimated error vector): ");
|
||||
liquid_print_bitstring(e_hat, 24); printf("\n");
|
||||
printf("v-hat (estimated tx vector): ");
|
||||
liquid_print_bitstring(v_hat, 24); printf("\n");
|
||||
}
|
||||
|
||||
/* compute estimated original message: (last 12 bits of encoded message) */
|
||||
m_hat = v_hat & 0x0fff;
|
||||
|
@ -332,40 +332,43 @@ static inline dhcpv6_opt_t *_opt_next(dhcpv6_opt_t *opt)
|
||||
|
||||
static bool _check_status_opt(dhcpv6_opt_status_t *status)
|
||||
{
|
||||
/* DHCPV6_STATUS_SUCCESS is 0, so we don't need to fix byte order */
|
||||
#if ENABLE_DEBUG
|
||||
if ((status != NULL) && (status->code.u16 != DHCPV6_STATUS_SUCCESS)) {
|
||||
size_t msg_len = byteorder_ntohs(status->len);
|
||||
char msg[msg_len - 1];
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
if ((status != NULL) && (status->code.u16 != DHCPV6_STATUS_SUCCESS)) {
|
||||
size_t msg_len = byteorder_ntohs(status->len);
|
||||
char msg[msg_len - 1];
|
||||
|
||||
strncpy(msg, status->msg, msg_len - 2);
|
||||
DEBUG("DHCPv6 client: server returned error (%u) \"%s\"\n",
|
||||
byteorder_ntohs(status->code), msg);
|
||||
strncpy(msg, status->msg, msg_len - 2);
|
||||
DEBUG("DHCPv6 client: server returned error (%u) \"%s\"\n",
|
||||
byteorder_ntohs(status->code), msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* DHCPV6_STATUS_SUCCESS is 0, so we don't need to fix byte order */
|
||||
return (status == NULL) || (status->code.u16 == DHCPV6_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
static bool _check_cid_opt(dhcpv6_opt_duid_t *cid)
|
||||
{
|
||||
#if ENABLE_DEBUG
|
||||
if ((byteorder_ntohs(cid->len) != duid_len) ||
|
||||
(memcmp(cid->duid, duid, duid_len) != 0)) {
|
||||
DEBUG("DHCPv6 client: message is not for me\n");
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
if ((byteorder_ntohs(cid->len) != duid_len) ||
|
||||
(memcmp(cid->duid, duid, duid_len) != 0)) {
|
||||
DEBUG("DHCPv6 client: message is not for me\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return ((byteorder_ntohs(cid->len) == duid_len) &&
|
||||
(memcmp(cid->duid, duid, duid_len) == 0));
|
||||
}
|
||||
|
||||
static bool _check_sid_opt(dhcpv6_opt_duid_t *sid)
|
||||
{
|
||||
#if ENABLE_DEBUG
|
||||
if ((byteorder_ntohs(sid->len) != server.duid_len) ||
|
||||
(memcmp(sid->duid, server.duid.u8, server.duid_len) != 0)) {
|
||||
DEBUG("DHCPv6 client: message is not from my server\n");
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
if ((byteorder_ntohs(sid->len) != server.duid_len) ||
|
||||
(memcmp(sid->duid, server.duid.u8, server.duid_len) != 0)) {
|
||||
DEBUG("DHCPv6 client: message is not from my server\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return ((byteorder_ntohs(sid->len) == server.duid_len) &&
|
||||
(memcmp(sid->duid, server.duid.u8, server.duid_len) == 0));
|
||||
}
|
||||
|
@ -25,14 +25,15 @@ uint16_t inet_csum_slice(uint16_t sum, const uint8_t *buf, uint16_t len, size_t
|
||||
uint32_t csum = sum;
|
||||
|
||||
DEBUG("inet_sum: sum = 0x%04" PRIx16 ", len = %" PRIu16, sum, len);
|
||||
#if ENABLE_DEBUG
|
||||
#ifdef MODULE_OD
|
||||
DEBUG(", buf:\n");
|
||||
od_hex_dump(buf, len, OD_WIDTH_DEFAULT);
|
||||
#else
|
||||
DEBUG(", buf output only with od module\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
if (IS_USED(MODULE_OD)) {
|
||||
DEBUG(", buf:\n");
|
||||
od_hex_dump(buf, len, OD_WIDTH_DEFAULT);
|
||||
} else {
|
||||
DEBUG(", buf output only with od module\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (len == 0)
|
||||
return csum;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "od.h"
|
||||
#include "timex.h"
|
||||
#include "random.h"
|
||||
#include "periph/rtt.h"
|
||||
@ -166,9 +167,6 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
|
||||
if (!(state->flags & NETDEV_IEEE802154_RAW)) {
|
||||
gnrc_pktsnip_t *ieee802154_hdr, *netif_hdr;
|
||||
gnrc_netif_hdr_t *hdr;
|
||||
#if ENABLE_DEBUG
|
||||
char src_str[GNRC_NETIF_HDR_L2ADDR_PRINT_LEN];
|
||||
#endif
|
||||
size_t mhr_len = ieee802154_get_frame_hdr_len(pkt->data);
|
||||
|
||||
if (mhr_len == 0) {
|
||||
@ -207,16 +205,19 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
|
||||
hdr->rssi = rx_info.rssi;
|
||||
gnrc_netif_hdr_set_netif(hdr, netif);
|
||||
pkt->type = state->proto;
|
||||
#if ENABLE_DEBUG
|
||||
DEBUG("_recv_ieee802154: received packet from %s of length %u\n",
|
||||
gnrc_netif_addr_to_str(src_str, sizeof(src_str),
|
||||
gnrc_netif_hdr_get_src_addr(hdr),
|
||||
hdr->src_l2addr_len),
|
||||
nread);
|
||||
#if defined(MODULE_OD)
|
||||
od_hex_dump(pkt->data, nread, OD_WIDTH_DEFAULT);
|
||||
#endif
|
||||
#endif
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
char src_str[GNRC_NETIF_HDR_L2ADDR_PRINT_LEN];
|
||||
|
||||
DEBUG("_recv_ieee802154: received packet from %s of length %u\n",
|
||||
gnrc_netif_addr_to_str(gnrc_netif_hdr_get_src_addr(hdr),
|
||||
hdr->src_l2addr_len,
|
||||
src_str),
|
||||
nread);
|
||||
|
||||
if (IS_USED(MODULE_OD)) {
|
||||
od_hex_dump(pkt->data, nread, OD_WIDTH_DEFAULT);
|
||||
}
|
||||
}
|
||||
gnrc_pktbuf_remove_snip(pkt, ieee802154_hdr);
|
||||
pkt = gnrc_pkt_append(pkt, netif_hdr);
|
||||
}
|
||||
@ -923,10 +924,8 @@ static void _lwmac_msg_handler(gnrc_netif_t *netif, msg_t *msg)
|
||||
}
|
||||
#endif
|
||||
default: {
|
||||
#if ENABLE_DEBUG
|
||||
DEBUG("[LWMAC]: unknown message type 0x%04x"
|
||||
DEBUG("[LWMAC]: unknown message type 0x%04x "
|
||||
"(no message handler defined)\n", msg->type);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -24,9 +24,7 @@
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#if defined(MODULE_OD) && ENABLE_DEBUG
|
||||
#include "od.h"
|
||||
#endif
|
||||
|
||||
static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt);
|
||||
static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif);
|
||||
@ -138,9 +136,6 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
|
||||
/* Normal mode, try to parse the frame according to IEEE 802.15.4 */
|
||||
gnrc_pktsnip_t *ieee802154_hdr, *netif_hdr;
|
||||
gnrc_netif_hdr_t *hdr;
|
||||
#if ENABLE_DEBUG
|
||||
char src_str[GNRC_NETIF_HDR_L2ADDR_PRINT_LEN];
|
||||
#endif
|
||||
size_t mhr_len = ieee802154_get_frame_hdr_len(pkt->data);
|
||||
|
||||
/* nread was checked for <= 0 before so we can safely cast it to
|
||||
@ -193,16 +188,18 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
|
||||
hdr->rssi = rx_info.rssi;
|
||||
gnrc_netif_hdr_set_netif(hdr, netif);
|
||||
dev->driver->get(dev, NETOPT_PROTO, &pkt->type, sizeof(pkt->type));
|
||||
#if ENABLE_DEBUG
|
||||
DEBUG("_recv_ieee802154: received packet from %s of length %u\n",
|
||||
gnrc_netif_addr_to_str(gnrc_netif_hdr_get_src_addr(hdr),
|
||||
hdr->src_l2addr_len,
|
||||
src_str),
|
||||
nread);
|
||||
#if defined(MODULE_OD)
|
||||
od_hex_dump(pkt->data, nread, OD_WIDTH_DEFAULT);
|
||||
#endif
|
||||
#endif
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
char src_str[GNRC_NETIF_HDR_L2ADDR_PRINT_LEN];
|
||||
|
||||
DEBUG("_recv_ieee802154: received packet from %s of length %u\n",
|
||||
gnrc_netif_addr_to_str(gnrc_netif_hdr_get_src_addr(hdr),
|
||||
hdr->src_l2addr_len,
|
||||
src_str),
|
||||
nread);
|
||||
if (IS_USED(MODULE_OD)) {
|
||||
od_hex_dump(pkt->data, nread, OD_WIDTH_DEFAULT);
|
||||
}
|
||||
}
|
||||
gnrc_pktbuf_remove_snip(pkt, ieee802154_hdr);
|
||||
pkt = gnrc_pkt_append(pkt, netif_hdr);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
#if IS_ACTIVE(ENABLE_DEBUG)
|
||||
#include "evtimer.h"
|
||||
#endif
|
||||
|
||||
|
@ -57,15 +57,15 @@ gnrc_sixlowpan_ctx_t *gnrc_sixlowpan_ctx_lookup_addr(const ipv6_addr_t *addr)
|
||||
|
||||
mutex_unlock(&_ctx_mutex);
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
if (res != NULL) {
|
||||
DEBUG("6lo ctx: found context (%u, %s/%" PRIu8 ") ",
|
||||
(res->flags_id & GNRC_SIXLOWPAN_CTX_FLAGS_CID_MASK),
|
||||
ipv6_addr_to_str(ipv6str, &res->prefix, sizeof(ipv6str)),
|
||||
res->prefix_len);
|
||||
DEBUG("for address %s\n", ipv6_addr_to_str(ipv6str, addr, sizeof(ipv6str)));
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
if (res != NULL) {
|
||||
DEBUG("6lo ctx: found context (%u, %s/%" PRIu8 ") ",
|
||||
(res->flags_id & GNRC_SIXLOWPAN_CTX_FLAGS_CID_MASK),
|
||||
ipv6_addr_to_str(ipv6str, &res->prefix, sizeof(ipv6str)),
|
||||
res->prefix_len);
|
||||
DEBUG("for address %s\n", ipv6_addr_to_str(ipv6str, addr, sizeof(ipv6str)));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -923,16 +923,16 @@ static int _forward_frag(gnrc_pktsnip_t *pkt, gnrc_pktsnip_t *frag_hdr,
|
||||
DEBUG("to (%s, %u)\n",
|
||||
gnrc_netif_addr_to_str(vrbe->super.dst, vrbe->super.dst_len,
|
||||
addr_str), vrbe->out_tag);
|
||||
#if ENABLE_DEBUG && defined(MODULE_OD)
|
||||
DEBUG("Original fragmentation header:\n");
|
||||
od_hex_dump(frag_hdr->data, frag_hdr->size, OD_WIDTH_DEFAULT);
|
||||
DEBUG("IPHC headers + payload:\n");
|
||||
frag_hdr = pkt;
|
||||
while (frag_hdr) {
|
||||
if (IS_ACTIVE(ENABLE_DEBUG) && IS_USED(MODULE_OD)) {
|
||||
DEBUG("Original fragmentation header:\n");
|
||||
od_hex_dump(frag_hdr->data, frag_hdr->size, OD_WIDTH_DEFAULT);
|
||||
frag_hdr = frag_hdr->next;
|
||||
DEBUG("IPHC headers + payload:\n");
|
||||
frag_hdr = pkt;
|
||||
while (frag_hdr) {
|
||||
od_hex_dump(frag_hdr->data, frag_hdr->size, OD_WIDTH_DEFAULT);
|
||||
frag_hdr = frag_hdr->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
gnrc_pktbuf_release(pkt);
|
||||
(void)frag_hdr;
|
||||
(void)page;
|
||||
|
@ -23,7 +23,7 @@
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
#if IS_ACTIVE(ENABLE_DEBUG)
|
||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
#endif
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
#if IS_ACTIVE(ENABLE_DEBUG)
|
||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
#endif
|
||||
|
||||
|
@ -89,13 +89,13 @@ static int fib_find_entry(fib_table_t *table, uint8_t *dst, size_t dst_size,
|
||||
int ret = -EHOSTUNREACH;
|
||||
bool is_all_zeros_addr = true;
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
DEBUG("[fib_find_entry] dst =");
|
||||
for (size_t i = 0; i < dst_size; i++) {
|
||||
DEBUG(" %02x", dst[i]);
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
DEBUG("[fib_find_entry] dst =");
|
||||
for (size_t i = 0; i < dst_size; i++) {
|
||||
DEBUG(" %02x", dst[i]);
|
||||
}
|
||||
DEBUG("\n");
|
||||
}
|
||||
DEBUG("\n");
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < dst_size; ++i) {
|
||||
if (dst[i] != 0) {
|
||||
@ -175,15 +175,15 @@ static int fib_find_entry(fib_table_t *table, uint8_t *dst, size_t dst_size,
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
if (count > 0) {
|
||||
DEBUG("[fib_find_entry] found prefix on interface %d:", entry_arr[0]->iface_id);
|
||||
for (size_t i = 0; i < entry_arr[0]->global->address_size; i++) {
|
||||
DEBUG(" %02x", entry_arr[0]->global->address[i]);
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
if (count > 0) {
|
||||
DEBUG("[fib_find_entry] found prefix on interface %d:", entry_arr[0]->iface_id);
|
||||
for (size_t i = 0; i < entry_arr[0]->global->address_size; i++) {
|
||||
DEBUG(" %02x", entry_arr[0]->global->address[i]);
|
||||
}
|
||||
DEBUG("\n");
|
||||
}
|
||||
DEBUG("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
*entry_arr_size = count;
|
||||
return ret;
|
||||
|
@ -41,7 +41,7 @@
|
||||
#define CONFIG_PTHREAD_REAPER_BASE_STACKSIZE (THREAD_STACKSIZE_IDLE)
|
||||
#endif
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
#if IS_ACTIVE(ENABLE_DEBUG)
|
||||
# define PTHREAD_REAPER_STACKSIZE ((CONFIG_PTHREAD_REAPER_BASE_STACKSIZE) + THREAD_EXTRA_STACKSIZE_PRINTF)
|
||||
# define PTHREAD_STACKSIZE THREAD_STACKSIZE_MAIN
|
||||
#else
|
||||
|
@ -28,11 +28,11 @@
|
||||
|
||||
timex_t timex_add(const timex_t a, const timex_t b)
|
||||
{
|
||||
#if ENABLE_DEBUG
|
||||
if (!timex_isnormalized(&a) || !timex_isnormalized(&b)) {
|
||||
puts("timex_add on denormalized value");
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
if (!timex_isnormalized(&a) || !timex_isnormalized(&b)) {
|
||||
puts("timex_add on denormalized value");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
timex_t result;
|
||||
result.seconds = a.seconds + b.seconds;
|
||||
@ -52,22 +52,22 @@ timex_t timex_set(uint32_t seconds, uint32_t microseconds)
|
||||
result.seconds = seconds;
|
||||
result.microseconds = microseconds;
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
if (!timex_isnormalized(&result)) {
|
||||
puts("timex_set on denormalized value");
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
if (!timex_isnormalized(&result)) {
|
||||
puts("timex_set on denormalized value");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
timex_t timex_sub(const timex_t a, const timex_t b)
|
||||
{
|
||||
#if ENABLE_DEBUG
|
||||
if (!timex_isnormalized(&a) || !timex_isnormalized(&b)) {
|
||||
puts("timex_sub on denormalized value");
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
if (!timex_isnormalized(&a) || !timex_isnormalized(&b)) {
|
||||
puts("timex_sub on denormalized value");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
timex_t result;
|
||||
|
||||
@ -85,11 +85,11 @@ timex_t timex_sub(const timex_t a, const timex_t b)
|
||||
|
||||
int timex_cmp(const timex_t a, const timex_t b)
|
||||
{
|
||||
#if ENABLE_DEBUG
|
||||
if (!timex_isnormalized(&a) || !timex_isnormalized(&b)) {
|
||||
puts("timex_cmp on denormalized value");
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
if (!timex_isnormalized(&a) || !timex_isnormalized(&b)) {
|
||||
puts("timex_cmp on denormalized value");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (a.seconds < b.seconds) {
|
||||
return -1;
|
||||
|
@ -31,7 +31,8 @@
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
#if ENABLE_DEBUG
|
||||
|
||||
#if IS_ACTIVE(ENABLE_DEBUG)
|
||||
/* Since some of these functions are called by printf, we can't really call
|
||||
* printf from our functions or we end up in an infinite recursion. */
|
||||
#include <unistd.h> /* for STDOUT_FILENO */
|
||||
|
@ -311,7 +311,7 @@ void ztimer_handler(ztimer_clock_t *clock)
|
||||
{
|
||||
DEBUG("ztimer_handler(): %p now=%" PRIu32 "\n", (void *)clock, clock->ops->now(
|
||||
clock));
|
||||
if (ENABLE_DEBUG) {
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
_ztimer_print(clock);
|
||||
}
|
||||
|
||||
@ -364,7 +364,7 @@ void ztimer_handler(ztimer_clock_t *clock)
|
||||
|
||||
_ztimer_update(clock);
|
||||
|
||||
if (ENABLE_DEBUG) {
|
||||
if (IS_ACTIVE(ENABLE_DEBUG)) {
|
||||
_ztimer_print(clock);
|
||||
}
|
||||
DEBUG("ztimer_handler(): %p done.\n", (void *)clock);
|
||||
|
Loading…
Reference in New Issue
Block a user