mirror of
https://github.com/obgm/libcoap.git
synced 2026-12-05 20:02:19 +03:00
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.
This commit is contained in:
1 parent
968939c2db
commit
14a5473396
1 file changed
+8
-6
@@ -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 */
|
||||
|
||||
Reference in new issue
Block a user