⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 name.c

📁 bind 9.3结合mysql数据库
💻 C
📖 第 1 页 / 共 4 页
字号:
		INSIST(count1 <= 63 && count2 <= 63);		cdiff = (int)count1 - (int)count2;		if (cdiff < 0)			count = count1;		else			count = count2;		while (count > 0) {			chdiff = (int)maptolower[*label1] -			    (int)maptolower[*label2];			if (chdiff != 0) {				*orderp = chdiff;				goto done;			}			count--;			label1++;			label2++;		}		if (cdiff != 0) {			*orderp = cdiff;			goto done;		}		nlabels++;	}	*orderp = ldiff;	if (ldiff < 0)		namereln = dns_namereln_contains;	else if (ldiff > 0)		namereln = dns_namereln_subdomain;	else		namereln = dns_namereln_equal; done:	*nlabelsp = nlabels;	if (nlabels > 0 && namereln == dns_namereln_none)		namereln = dns_namereln_commonancestor;	return (namereln);}intdns_name_compare(const dns_name_t *name1, const dns_name_t *name2) {	int order;	unsigned int nlabels;	/*	 * Determine the relative ordering under the DNSSEC order relation of	 * 'name1' and 'name2'.	 *	 * Note: It makes no sense for one of the names to be relative and the	 * other absolute.  If both names are relative, then to be meaningfully	 * compared the caller must ensure that they are both relative to the	 * same domain.	 */	(void)dns_name_fullcompare(name1, name2, &order, &nlabels);	return (order);}isc_boolean_tdns_name_equal(const dns_name_t *name1, const dns_name_t *name2) {	unsigned int l, count;	unsigned char c;	unsigned char *label1, *label2;	/*	 * Are 'name1' and 'name2' equal?	 *	 * Note: It makes no sense for one of the names to be relative and the	 * other absolute.  If both names are relative, then to be meaningfully	 * compared the caller must ensure that they are both relative to the	 * same domain.	 */	REQUIRE(VALID_NAME(name1));	REQUIRE(VALID_NAME(name2));	/*	 * Either name1 is absolute and name2 is absolute, or neither is.	 */	REQUIRE((name1->attributes & DNS_NAMEATTR_ABSOLUTE) ==		(name2->attributes & DNS_NAMEATTR_ABSOLUTE));	if (name1->length != name2->length)		return (ISC_FALSE);	l = name1->labels;	if (l != name2->labels)		return (ISC_FALSE);	label1 = name1->ndata;	label2 = name2->ndata;	while (l > 0) {		l--;		count = *label1++;		if (count != *label2++)			return (ISC_FALSE);		INSIST(count <= 63); /* no bitstring support */		while (count > 0) {			count--;			c = maptolower[*label1++];			if (c != maptolower[*label2++])				return (ISC_FALSE);		}	}	return (ISC_TRUE);}intdns_name_rdatacompare(const dns_name_t *name1, const dns_name_t *name2) {	unsigned int l1, l2, l, count1, count2, count;	unsigned char c1, c2;	unsigned char *label1, *label2;	/*	 * Compare two absolute names as rdata.	 */	REQUIRE(VALID_NAME(name1));	REQUIRE(name1->labels > 0);	REQUIRE((name1->attributes & DNS_NAMEATTR_ABSOLUTE) != 0);	REQUIRE(VALID_NAME(name2));	REQUIRE(name2->labels > 0);	REQUIRE((name2->attributes & DNS_NAMEATTR_ABSOLUTE) != 0);	l1 = name1->labels;	l2 = name2->labels;	l = (l1 < l2) ? l1 : l2;	label1 = name1->ndata;	label2 = name2->ndata;	while (l > 0) {		l--;		count1 = *label1++;		count2 = *label2++;		/* no bitstring support */		INSIST(count1 <= 63 && count2 <= 63);		if (count1 != count2)			return ((count1 < count2) ? -1 : 1);		count = count1;		while (count > 0) {			count--;			c1 = maptolower[*label1++];			c2 = maptolower[*label2++];			if (c1 < c2)				return (-1);			else if (c1 > c2)				return (1);		}	}	/*	 * If one name had more labels than the other, their common	 * prefix must have been different because the shorter name	 * ended with the root label and the longer one can't have	 * a root label in the middle of it.  Therefore, if we get	 * to this point, the lengths must be equal.	 */	INSIST(l1 == l2);	return (0);}isc_boolean_tdns_name_issubdomain(const dns_name_t *name1, const dns_name_t *name2) {	int order;	unsigned int nlabels;	dns_namereln_t namereln;	/*	 * Is 'name1' a subdomain of 'name2'?	 *	 * Note: It makes no sense for one of the names to be relative and the	 * other absolute.  If both names are relative, then to be meaningfully	 * compared the caller must ensure that they are both relative to the	 * same domain.	 */	namereln = dns_name_fullcompare(name1, name2, &order, &nlabels);	if (namereln == dns_namereln_subdomain ||	    namereln == dns_namereln_equal)		return (ISC_TRUE);	return (ISC_FALSE);}isc_boolean_tdns_name_matcheswildcard(const dns_name_t *name, const dns_name_t *wname) {	int order;	unsigned int nlabels, labels;	dns_name_t tname;	REQUIRE(VALID_NAME(name));	REQUIRE(name->labels > 0);	REQUIRE(VALID_NAME(wname));	labels = wname->labels;	REQUIRE(labels > 0);	REQUIRE(dns_name_iswildcard(wname));	DNS_NAME_INIT(&tname, NULL);	dns_name_getlabelsequence(wname, 1, labels - 1, &tname);	if (dns_name_fullcompare(name, &tname, &order, &nlabels) ==	    dns_namereln_subdomain)		return (ISC_TRUE);	return (ISC_FALSE);}unsigned intdns_name_countlabels(const dns_name_t *name) {	/*	 * How many labels does 'name' have?	 */	REQUIRE(VALID_NAME(name));	ENSURE(name->labels <= 128);	return (name->labels);}voiddns_name_getlabel(const dns_name_t *name, unsigned int n, dns_label_t *label) {	unsigned char *offsets;	dns_offsets_t odata;	/*	 * Make 'label' refer to the 'n'th least significant label of 'name'.	 */	REQUIRE(VALID_NAME(name));	REQUIRE(name->labels > 0);	REQUIRE(n < name->labels);	REQUIRE(label != NULL);	SETUP_OFFSETS(name, offsets, odata);	label->base = &name->ndata[offsets[n]];	if (n == name->labels - 1)		label->length = name->length - offsets[n];	else		label->length = offsets[n + 1] - offsets[n];}voiddns_name_getlabelsequence(const dns_name_t *source,			  unsigned int first, unsigned int n,			  dns_name_t *target){	unsigned char *offsets;	dns_offsets_t odata;	unsigned int firstoffset, endoffset;	/*	 * Make 'target' refer to the 'n' labels including and following	 * 'first' in 'source'.	 */	REQUIRE(VALID_NAME(source));	REQUIRE(VALID_NAME(target));	REQUIRE(first <= source->labels);	REQUIRE(first + n <= source->labels);	REQUIRE(BINDABLE(target));	SETUP_OFFSETS(source, offsets, odata);	if (first == source->labels)		firstoffset = source->length;	else		firstoffset = offsets[first];	if (first + n == source->labels)		endoffset = source->length;	else		endoffset = offsets[first + n];	target->ndata = &source->ndata[firstoffset];	target->length = endoffset - firstoffset;		if (first + n == source->labels && n > 0 &&	    (source->attributes & DNS_NAMEATTR_ABSOLUTE) != 0)		target->attributes |= DNS_NAMEATTR_ABSOLUTE;	else		target->attributes &= ~DNS_NAMEATTR_ABSOLUTE;	target->labels = n;	/*	 * If source and target are the same, and we're making target	 * a prefix of source, the offsets table is correct already	 * so we don't need to call set_offsets().	 */	if (target->offsets != NULL &&	    (target != source || first != 0))		set_offsets(target, target->offsets, NULL);}voiddns_name_clone(dns_name_t *source, dns_name_t *target) {	/*	 * Make 'target' refer to the same name as 'source'.	 */	REQUIRE(VALID_NAME(source));	REQUIRE(VALID_NAME(target));	REQUIRE(BINDABLE(target));	target->ndata = source->ndata;	target->length = source->length;	target->labels = source->labels;	target->attributes = source->attributes &		(unsigned int)~(DNS_NAMEATTR_READONLY | DNS_NAMEATTR_DYNAMIC |				DNS_NAMEATTR_DYNOFFSETS);	if (target->offsets != NULL && source->labels > 0) {		if (source->offsets != NULL)			memcpy(target->offsets, source->offsets,			       source->labels);		else			set_offsets(target, target->offsets, NULL);	}}voiddns_name_fromregion(dns_name_t *name, const isc_region_t *r) {	unsigned char *offsets;	dns_offsets_t odata;	unsigned int len;	isc_region_t r2;	/*	 * Make 'name' refer to region 'r'.	 */	REQUIRE(VALID_NAME(name));	REQUIRE(r != NULL);	REQUIRE(BINDABLE(name));	INIT_OFFSETS(name, offsets, odata);	if (name->buffer != NULL) {		isc_buffer_clear(name->buffer);		isc_buffer_availableregion(name->buffer, &r2);		len = (r->length < r2.length) ? r->length : r2.length;		if (len > DNS_NAME_MAXWIRE)			len = DNS_NAME_MAXWIRE;		memcpy(r2.base, r->base, len);		name->ndata = r2.base;		name->length = len;	} else {		name->ndata = r->base;		name->length = (r->length <= DNS_NAME_MAXWIRE) ? 			r->length : DNS_NAME_MAXWIRE;	}	if (r->length > 0)		set_offsets(name, offsets, name);	else {		name->labels = 0;		name->attributes &= ~DNS_NAMEATTR_ABSOLUTE;	}	if (name->buffer != NULL)		isc_buffer_add(name->buffer, name->length);}voiddns_name_toregion(dns_name_t *name, isc_region_t *r) {	/*	 * Make 'r' refer to 'name'.	 */	REQUIRE(VALID_NAME(name));	REQUIRE(r != NULL);	DNS_NAME_TOREGION(name, r);}isc_result_tdns_name_fromtext(dns_name_t *name, isc_buffer_t *source,		  dns_name_t *origin, unsigned int options,		  isc_buffer_t *target){	unsigned char *ndata, *label;	char *tdata;	char c;	ft_state state, kind;	unsigned int value, count, tbcount, bitlength, maxlength;	unsigned int n1, n2, vlen, tlen, nrem, nused, digits, labels, tused;	isc_boolean_t done;	unsigned char *offsets;	dns_offsets_t odata;	isc_boolean_t downcase;	/*	 * Convert the textual representation of a DNS name at source	 * into uncompressed wire form stored in target.	 *	 * Notes:	 *	Relative domain names will have 'origin' appended to them	 *	unless 'origin' is NULL, in which case relative domain names	 *	will remain relative.	 */	REQUIRE(VALID_NAME(name));	REQUIRE(ISC_BUFFER_VALID(source));	REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) ||		(target == NULL && ISC_BUFFER_VALID(name->buffer)));		downcase = ISC_TF((options & DNS_NAME_DOWNCASE) != 0);	if (target == NULL && name->buffer != NULL) {		target = name->buffer;		isc_buffer_clear(target);	}	REQUIRE(BINDABLE(name));	INIT_OFFSETS(name, offsets, odata);	offsets[0] = 0;	/*	 * Initialize things to make the compiler happy; they're not required.	 */	n1 = 0;	n2 = 0;	vlen = 0;	label = NULL;	digits = 0;	value = 0;	count = 0;	tbcount = 0;	bitlength = 0;	maxlength = 0;	kind = ft_init;	/*	 * Make 'name' empty in case of failure.	 */	MAKE_EMPTY(name);	/*	 * Set up the state machine.	 */	tdata = (char *)source->base + source->current;	tlen = isc_buffer_remaininglength(source);	tused = 0;	ndata = isc_buffer_used(target);	nrem = isc_buffer_availablelength(target);	if (nrem > 255)		nrem = 255;	nused = 0;	labels = 0;	done = ISC_FALSE;	state = ft_init;	while (nrem > 0 && tlen > 0 && !done) {		c = *tdata++;		tlen--;		tused++;		switch (state) {		case ft_init:			/*			 * Is this the root name?			 */			if (c == '.') {				if (tlen != 0)					return (DNS_R_EMPTYLABEL);				labels++;				*ndata++ = 0;				nrem--;				nused++;				done = ISC_TRUE;				break;			}			if (c == '@' && tlen == 0) {				state = ft_at;				break;			}			/* FALLTHROUGH */		case ft_start:			label = ndata;			ndata++;			nrem--;			nused++;			count = 0;			if (c == '\\') {				state = ft_initialescape;				break;			}			kind = ft_ordinary;			state = ft_ordinary;			if (nrem == 0)				return (ISC_R_NOSPACE);			/* FALLTHROUGH */		case ft_ordinary:			if (c == '.') {				if (count == 0)					return (DNS_R_EMPTYLABEL);				*label = count;				labels++;				INSIST(labels <= 127);				offsets[labels] = nused;				if (tlen == 0) {					labels++;					*ndata++ = 0;					nrem--;					nused++;					done = ISC_TRUE;				}				state = ft_start;			} else if (c == '\\') {				state = ft_escape;			} else {				if (count >= 63)					return (DNS_R_LABELTOOLONG);				count++;				CONVERTTOASCII(c);				if (downcase)					c = maptolower[(int)c];				*ndata++ = c;				nrem--;				nused++;			}			break;		case ft_initialescape:			if (c == '[') {				/*				 * This looks like a bitstring label, which				 * was deprecated.  Intentionally drop it.				 */				return (DNS_R_BADLABELTYPE);			}			kind = ft_ordinary;			state = ft_escape;			/* FALLTHROUGH */		case ft_escape:			if (!isdigit(c & 0xff)) {				if (count >= 63)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -