Fixed bug in IPv6 address print function.

This commit is contained in:
Matthias Kovatsch 2012-03-21 21:27:52 +01:00
parent 063bb12bd0
commit d57904b289

View file

@ -140,6 +140,7 @@ sprint_ip6(uip_ip6addr_t addr)
unsigned char i = 0; unsigned char i = 0;
unsigned char zerocnt = 0; unsigned char zerocnt = 0;
unsigned char numprinted = 0; unsigned char numprinted = 0;
unsigned char notskipped = 0;
char thestring[40]; char thestring[40];
char *result = thestring; char *result = thestring;
@ -149,10 +150,11 @@ sprint_ip6(uip_ip6addr_t addr)
while(addr.u16[zerocnt + i] == 0) { while(addr.u16[zerocnt + i] == 0) {
zerocnt++; zerocnt++;
} }
if(zerocnt == 1) { if(zerocnt == 1 && notskipped) {
*result++ = '0'; *result++ = '0';
numprinted++; numprinted++;
break; notskipped = 1;
continue;
} }
i += zerocnt; i += zerocnt;
numprinted += zerocnt; numprinted += zerocnt;