Skip to content

Commit

Permalink
fixup! sys/net/ipv6: Simplify type ipv6_addr_t
Browse files Browse the repository at this point in the history
  • Loading branch information
maribu committed Aug 14, 2020
1 parent aedb122 commit 9c77370
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sys/net/network_layer/ipv6/addr/ipv6_addr_to_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ char *ipv6_addr_to_str(char *result, const ipv6_addr_t *addr, uint8_t result_len
* Preprocess:
* Find the longest run of 0x0000's in address for :: shorthanding.
*/
for (uint8_t i = 0; i < sizeof(*addr); i += 2) {
if ((addr->u8[i] == 0) && (addr->u8[i+1] == 0)) {
for (uint8_t i = 0; i < IPV6_ADDR_WORD_LEN; i++) {
if ((addr->u8[2 * i] == 0) && (addr->u8[2 * i+1] == 0)) {
if (cur.base == -1) {
cur.base = i;
cur.len = 1;
Expand Down Expand Up @@ -106,8 +106,9 @@ char *ipv6_addr_to_str(char *result, const ipv6_addr_t *addr, uint8_t result_len
#ifdef MODULE_IPV4_ADDR
/* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && addr->u16[5].u16 == 0xffff))) {
if (!ipv4_addr_to_str(tp, (const ipv4_addr_t *)&addr->u32[3],
(best.len == 6 || (best.len == 5 && addr->u8[10] == 0xff &&
addr->u8[11] == 0xff))) {
if (!ipv4_addr_to_str(tp, (const ipv4_addr_t *)&addr->u8[12],
sizeof(tmp) - (tp - tmp))) {
return (NULL);
}
Expand Down

0 comments on commit 9c77370

Please sign in to comment.