diff options
author | John Denker <jsd@av8n.com> | 2012-07-26 10:57:13 -0700 |
---|---|---|
committer | John Denker <jsd@av8n.com> | 2012-07-29 15:32:37 -0700 |
commit | 9aa998757a8736cef02fd92050eacbb2a6fb5180 (patch) | |
tree | 18ae3d172893279aecaf12df94cb468bf887aa72 /ucspi-tcp-0.88/dns_rcip.c | |
parent | 6e8083ff4ffe3fd2b6d337386637a2b5c1378cf7 (diff) |
patch to support IPv6 in tcpserver
Diffstat (limited to 'ucspi-tcp-0.88/dns_rcip.c')
-rw-r--r-- | ucspi-tcp-0.88/dns_rcip.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/ucspi-tcp-0.88/dns_rcip.c b/ucspi-tcp-0.88/dns_rcip.c index 2356c8b..794f6be 100644 --- a/ucspi-tcp-0.88/dns_rcip.c +++ b/ucspi-tcp-0.88/dns_rcip.c @@ -2,12 +2,13 @@ #include "openreadclose.h" #include "byte.h" #include "ip4.h" -#include "env.h" +#include "ip6.h" #include "dns.h" +#include "env.h" static stralloc data = {0}; -static int init(char ip[64]) +static int init(char ip[256]) { int i; int j; @@ -16,15 +17,16 @@ static int init(char ip[64]) x = env_get("DNSCACHEIP"); if (x) - while (iplen <= 60) + while (iplen <= 60) { if (*x == '.') ++x; else { - i = ip4_scan(x,ip + iplen); + i = scan_ip6(x,ip + iplen); if (!i) break; x += i; - iplen += 4; + iplen += 16; } + } if (!iplen) { i = openreadclose("/etc/resolv.conf",&data,64); @@ -39,8 +41,9 @@ static int init(char ip[64]) while ((data.s[i] == ' ') || (data.s[i] == '\t')) ++i; if (iplen <= 60) - if (ip4_scan(data.s + i,ip + iplen)) - iplen += 4; + if (scan_ip6(data.s + i,ip + iplen)) { + iplen += 16; + } } i = j + 1; } @@ -48,19 +51,19 @@ static int init(char ip[64]) } if (!iplen) { - byte_copy(ip,4,"\177\0\0\1"); - iplen = 4; + byte_copy(ip,16,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1"); + iplen = 16; } - byte_zero(ip + iplen,64 - iplen); + byte_zero(ip + iplen,256 - iplen); return 0; } static int ok = 0; static unsigned int uses; static struct taia deadline; -static char ip[64]; /* defined if ok */ +static char ip[256]; /* defined if ok */ -int dns_resolvconfip(char s[64]) +int dns_resolvconfip(char s[256]) { struct taia now; @@ -77,6 +80,6 @@ int dns_resolvconfip(char s[64]) } --uses; - byte_copy(s,64,ip); + byte_copy(s,256,ip); return 0; } |