aboutsummaryrefslogtreecommitdiff
path: root/okclient.c
diff options
context:
space:
mode:
authorHenryk Plötz <henryk@ploetzli.ch>2014-10-03 20:04:14 +0200
committerHenryk Plötz <henryk@ploetzli.ch>2014-10-03 20:04:14 +0200
commitc44d8b51ffb5a413f8bbdbd9991bbc573853e397 (patch)
treee7f2e644de620879f610c909c405cbc4e44d6062 /okclient.c
parent0e5b2871ca6456b01d4bf037a6e68badf1ff1a41 (diff)
downloadtinydnssec-c44d8b51ffb5a413f8bbdbd9991bbc573853e397.tar.gz
tinydnssec-c44d8b51ffb5a413f8bbdbd9991bbc573853e397.tar.bz2
Apply patch djbdns-1.05-test27.diff.bz2
Source was http://www.fefe.de/dns/djbdns-1.05-test27.diff.bz2, SHA1 f0380ec1866f49c0bcf6369a923ac0a4a5095da8
Diffstat (limited to 'okclient.c')
-rw-r--r--okclient.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/okclient.c b/okclient.c
index a648c02..9a0d3c6 100644
--- a/okclient.c
+++ b/okclient.c
@@ -2,24 +2,34 @@
#include <sys/stat.h>
#include "str.h"
#include "ip4.h"
+#include "ip6.h"
+#include "byte.h"
#include "okclient.h"
-static char fn[3 + IP4_FMT];
+static char fn[3 + IP6_FMT];
-int okclient(char ip[4])
+int okclient(char ip[16])
{
struct stat st;
int i;
+ char sep;
fn[0] = 'i';
fn[1] = 'p';
fn[2] = '/';
- fn[3 + ip4_fmt(fn + 3,ip)] = 0;
+ if (byte_equal(ip,12,V4mappedprefix)) {
+ fn[3 + ip4_fmt(fn + 3,ip+12)] = 0;
+ sep='.';
+ } else {
+ fn[3 + ip6_fmt(fn + 3,ip)] = 0;
+ sep=':';
+ }
for (;;) {
+ if (!fn[3]) return 0;
if (stat(fn,&st) == 0) return 1;
/* treat temporary error as rejection */
- i = str_rchr(fn,'.');
+ i = str_rchr(fn,sep);
if (!fn[i]) return 0;
fn[i] = 0;
}