18static int doit(
stralloc *work,
const char *rule)
22 unsigned int prefixlen;
25 if ((ch !=
'?') && (ch !=
'=') && (ch !=
'*') && (ch !=
'-'))
return 1;
26 colon =
str_chr((
char *)rule,
':');
27 if (!rule[colon])
return 1;
29 if (work->
len < colon)
return 1;
30 prefixlen = work->
len - colon;
31 if ((ch ==
'=') && prefixlen)
return 1;
32 if (
case_diffb((
char *)rule,colon,work->
s + prefixlen))
return 1;
34 if (
byte_chr(work->
s,prefixlen,
'.') < prefixlen)
return 1;
35 if (
byte_chr(work->
s,prefixlen,
'[') < prefixlen)
return 1;
36 if (
byte_chr(work->
s,prefixlen,
']') < prefixlen)
return 1;
39 work->
len = prefixlen;
40 if (ch ==
'-') work->
len = 0;
56 for (j = i = 0; j < rules->
len; ++j)
58 if (!doit(fqdn,rules->
s + i))
return DNS_INT;
69 j =
byte_chr(fqdn->
s + i,fqdnlen - i,
'+');
74 if (i >= fqdnlen)
return rc;
104 for (j = i = 0; j < rules->
len; ++j)
106 if (!doit(fqdn,rules->
s + i))
return DNS_INT;
117 j =
byte_chr(fqdn->
s + i,fqdnlen - i,
'+');
119 fqdn->
len = plus + j;
122 if (i >= fqdnlen)
return rc;
148 unsigned int fqdnlen;
155 for (j = i = 0; j < rules->
len; ++j)
157 if (!doit(fqdn,rules->
s + i))
return DNS_INT;
163 if (plus >= fqdnlen) {
166 for (k = 0; k < tmp.
len; k += 4) {
177 j =
byte_chr(fqdn->
s + i,fqdnlen - i,
'+');
179 fqdn->
len = plus + j;
184 for (k = 0; k < tmp.
len; k += 4) {
193 if (i >= fqdnlen)
return rc;
222 return ipout->
len ? ipout->
len % 15 : 0;
const unsigned char V6loopback[16]
const unsigned char V4mappedprefix[12]
int dns_ip4_qualify(stralloc *ipout, stralloc *fqdn, const stralloc *in)
int dns_ip_qualify_localhost(stralloc *ipout, stralloc *fqdn, const stralloc *in)
int dns_ip6_qualify(stralloc *ipout, stralloc *fqdn, const stralloc *in)
int dns_ip4_qualify_rules(stralloc *ipout, stralloc *fqdn, const stralloc *in, const stralloc *rules)
int dns_ip6_qualify_rules(stralloc *ipout, stralloc *fqdn, const stralloc *in, const stralloc *rules)
int dns_ip_qualify(stralloc *ipout, stralloc *fqdn, const stralloc *in)
int dns_ip_qualify_rules(stralloc *ipout, stralloc *fqdn, const stralloc *in, const stralloc *rules)
int case_diffb(char *, unsigned int, char *)
unsigned int byte_chr(char *, unsigned int, int)
void byte_copy(void *, unsigned int, const void *)
#define byte_equal(s, n, t)
int dns_ip4(stralloc *, stralloc *)
int dns_resolvconfrewrite(stralloc *)
int dns_ip6(stralloc *, stralloc *)
unsigned int str_chr(const char *, int)
int stralloc_copy(stralloc *, stralloc *)
int stralloc_catb(stralloc *, const char *, unsigned int)
int stralloc_copyb(stralloc *, const char *, unsigned int)
int stralloc_cat(stralloc *, stralloc *)
int stralloc_cats(stralloc *, const char *)
int stralloc_copys(stralloc *, const char *)