From 14a547339602302949f38250e26ef24ded93f640 Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Fri, 6 Sep 2013 14:35:16 +0200 Subject: [PATCH] Fixed output of IPv6 addresses with Contiki in coap_print_addr() Addresses have been truncated and possibly had the wrong byte order. Thanks to Andreas Bender for pointing this out. --- debug.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/debug.c b/debug.c index 30d421bb..5a6b56b4 100644 --- a/debug.c +++ b/debug.c @@ -192,12 +192,14 @@ coap_print_addr(const struct __coap_address_t *addr, unsigned char *buf, size_t *p++ = '['; - for (i=0; i < 8; i += 4) { - *p++ = hex[(addr->addr.u16[i] & 0xf000) >> 24]; - *p++ = hex[(addr->addr.u16[i] & 0x0f00) >> 16]; - *p++ = hex[(addr->addr.u16[i] & 0x00f0) >> 8]; - *p++ = hex[(addr->addr.u16[i] & 0x000f)]; - *p++ = ':'; + for (i=0; i < 16; i += 2) { + if (i) { + *p++ = ':'; + } + *p++ = hex[(addr->addr.u8[i] & 0xf0) >> 4]; + *p++ = hex[(addr->addr.u8[i] & 0x0f)]; + *p++ = hex[(addr->addr.u8[i+1] & 0xf0) >> 4]; + *p++ = hex[(addr->addr.u8[i+1] & 0x0f)]; } *(p-1) = ']'; # else /* WITH_UIP6 */