Skip to Content.
Sympa Menu

ndt-users - IPv6 problems in web100.c

Subject: ndt-users list created

List archive

IPv6 problems in web100.c


Chronological Thread 
  • From: Josh Bailey <>
  • To:
  • Subject: IPv6 problems in web100.c
  • Date: Tue, 3 Apr 2012 21:42:13 -0700 (PDT)


(bcc
)

Hi all;

Wanted to hopefully save some others some time, by posting some patches for some IPv6 problems I've found while working with NDT/web100.

I'm told that the web100 code is frozen now so here is the first patch against web110.c.

The problem is that the code inserts an extraenous ":" when trying to shorten an IPv6 address with consecutive zeros, resulting in an invalid address.

There are some other problems (always writing an IPv4 connection_spec struct even when IPv6 is being used for example, and giving junk addresses). I'll post those patches seperately.

HTH,

--
Josh Bailey@@ -1185,47 +1185,8 @@
case WEB100_TYPE_INET_PORT_NUMBER:
return snprintf(dest, size, "%u", *(u_int16_t *) buf);
case WEB100_TYPE_INET_ADDRESS_IPV6:
- {
- short *addr = (short *)buf;
- int start = -1, end = -1;
- int i, j;
- int pos;
-
- /* Find longest subsequence of 0's in addr */
- for (i = 0; i < 8; i++) {
- if (addr[i] == 0) {
- for (j = i + 1; addr[j] == 0 && j < 8; j++)
- ;
- if (j - i > end - start) {
- end = j;
- start = i;
- }
- i = j;
- }
- }
- if (end - start == 1)
- start = -1;
-
- pos = 0;
- for (i = 0; i < 8; i++) {
- if (i > 0)
- pos += snprintf(dest + pos, size - pos, ":");
- if (pos >= size)
- break;
- if (i == start) {
- pos += snprintf(dest + pos, size - pos, ":");
- i += end - start - 1;
- } else {
- pos += snprintf(dest + pos, size - pos, "%hx",
ntohs(addr[i]));
- }
- if (pos >= size)
- break;
- }
-
- if (pos > size)
- pos = size;
- return pos;
- }
+ inet_ntop(AF_INET6, buf, dest, size);
+ return 1;
case WEB100_TYPE_STR32:
return snprintf(dest, size, "%s", (char *)buf);
case WEB100_TYPE_OCTET:



Archive powered by MHonArc 2.6.16.

Top of Page