int res_hnok( const char *dn ) { int ppch = '\0', pch = PERIOD, ch = *dn++; while (ch != '\0') { int nch = *dn++; if (periodchar(ch)) { (void)NULL; } else if (periodchar(pch)) { if (!borderchar(ch)) return (0); } else if (periodchar(nch) || nch == '\0') { if (!borderchar(ch)) return (0); } else { if (!middlechar(ch)) return (0); } ppch = pch, pch = ch, ch = nch; } return (1); }
isc_boolean_t dns_name_ismailbox(const dns_name_t *name) { unsigned char *ndata, ch; unsigned int n; isc_boolean_t first; REQUIRE(VALID_NAME(name)); REQUIRE(name->labels > 0); REQUIRE(name->attributes & DNS_NAMEATTR_ABSOLUTE); /* * Root label. */ if (name->length == 1) return (ISC_TRUE); ndata = name->ndata; n = *ndata++; INSIST(n <= 63); while (n--) { ch = *ndata++; if (!domainchar(ch)) return (ISC_FALSE); } if (ndata == name->ndata + name->length) return (ISC_FALSE); /* * RFC292/RFC1123 hostname. */ while (ndata < (name->ndata + name->length)) { n = *ndata++; INSIST(n <= 63); first = ISC_TRUE; while (n--) { ch = *ndata++; if (first || n == 0) { if (!borderchar(ch)) return (ISC_FALSE); } else { if (!middlechar(ch)) return (ISC_FALSE); } first = ISC_FALSE; } } return (ISC_TRUE); }
isc_boolean_t dns_name_ishostname(const dns_name_t *name, isc_boolean_t wildcard) { unsigned char *ndata, ch; unsigned int n; isc_boolean_t first; REQUIRE(VALID_NAME(name)); REQUIRE(name->labels > 0); REQUIRE(name->attributes & DNS_NAMEATTR_ABSOLUTE); /* * Root label. */ if (name->length == 1) return (ISC_TRUE); /* * Skip wildcard if this is a ownername. */ ndata = name->ndata; if (wildcard && ndata[0] == 1 && ndata[1] == '*') ndata += 2; /* * RFC292/RFC1123 hostname. */ while (ndata < (name->ndata + name->length)) { n = *ndata++; INSIST(n <= 63); first = ISC_TRUE; while (n--) { ch = *ndata++; if (first || n == 0) { if (!borderchar(ch)) return (ISC_FALSE); } else { if (!middlechar(ch)) return (ISC_FALSE); } first = ISC_FALSE; } } return (ISC_TRUE); }