📄 name.h
字号:
isc_boolean_tdns_name_equal(const dns_name_t *name1, const dns_name_t *name2);/* * Are 'name1' and 'name2' equal? * * Notes: * Because it only needs to test for equality, dns_name_equal() can be * significantly faster than dns_name_fullcompare() or dns_name_compare(). * * Offsets tables are not used in the comparision. * * 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. * * Requires: * 'name1' is a valid name * * 'name2' is a valid name * * Either name1 is absolute and name2 is absolute, or neither is. * * Returns: * ISC_TRUE 'name1' and 'name2' are equal * ISC_FALSE 'name1' and 'name2' are not equal */intdns_name_rdatacompare(const dns_name_t *name1, const dns_name_t *name2);/* * Compare two names as if they are part of rdata in DNSSEC canonical * form. * * Requires: * 'name1' is a valid absolute name * * dns_name_countlabels(name1) > 0 * * 'name2' is a valid absolute name * * dns_name_countlabels(name2) > 0 * * Returns: * < 0 'name1' is less than 'name2' * 0 'name1' is equal to 'name2' * > 0 'name1' is greater than 'name2' */isc_boolean_tdns_name_issubdomain(const dns_name_t *name1, const dns_name_t *name2);/* * Is 'name1' a subdomain of 'name2'? * * Notes: * name1 is a subdomain of name2 if name1 is contained in name2, or * name1 equals name2. * * 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. * * Requires: * 'name1' is a valid name * * 'name2' is a valid name * * Either name1 is absolute and name2 is absolute, or neither is. * * Returns: * TRUE 'name1' is a subdomain of 'name2' * FALSE 'name1' is not a subdomain of 'name2' */isc_boolean_tdns_name_matcheswildcard(const dns_name_t *name, const dns_name_t *wname);/* * Does 'name' match the wildcard specified in 'wname'? * * Notes: * name matches the wildcard specified in wname if all labels * following the wildcard in wname are identical to the same number * of labels at the end of name. * * 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. * * Requires: * 'name' is a valid name * * dns_name_countlabels(name) > 0 * * 'wname' is a valid name * * dns_name_countlabels(wname) > 0 * * dns_name_iswildcard(wname) is true * * Either name is absolute and wname is absolute, or neither is. * * Returns: * TRUE 'name' matches the wildcard specified in 'wname' * FALSE 'name' does not match the wildcard specified in 'wname' *//*** *** Labels ***/unsigned intdns_name_countlabels(const dns_name_t *name);/* * How many labels does 'name' have? * * Notes: * In this case, as in other places, a 'label' is an ordinary label. * * Requires: * 'name' is a valid name * * Ensures: * The result is <= 128. * * Returns: * The number of labels in 'name'. */voiddns_name_getlabel(const dns_name_t *name, unsigned int n, dns_label_t *label);/* * Make 'label' refer to the 'n'th least significant label of 'name'. * * Notes: * Numbering starts at 0. * * Given "rc.vix.com.", the label 0 is "rc", and label 3 is the * root label. * * 'label' refers to the same memory as 'name', so 'name' must not * be changed while 'label' is still in use. * * Requires: * n < dns_name_countlabels(name) */voiddns_name_getlabelsequence(const dns_name_t *source, unsigned int first, unsigned int n, dns_name_t *target);/* * Make 'target' refer to the 'n' labels including and following 'first' * in 'source'. * * Notes: * Numbering starts at 0. * * Given "rc.vix.com.", the label 0 is "rc", and label 3 is the * root label. * * 'target' refers to the same memory as 'source', so 'source' * must not be changed while 'target' is still in use. * * Requires: * 'source' and 'target' are valid names. * * first < dns_name_countlabels(name) * * first + n <= dns_name_countlabels(name) */voiddns_name_clone(dns_name_t *source, dns_name_t *target);/* * Make 'target' refer to the same name as 'source'. * * Notes: * * 'target' refers to the same memory as 'source', so 'source' * must not be changed while 'target' is still in use. * * This call is functionally equivalent to: * * dns_name_getlabelsequence(source, 0, * dns_name_countlabels(source), * target); * * but is more efficient. Also, dns_name_clone() works even if 'source' * is empty. * * Requires: * * 'source' is a valid name. * * 'target' is a valid name that is not read-only. *//*** *** Conversions ***/voiddns_name_fromregion(dns_name_t *name, const isc_region_t *r);/* * Make 'name' refer to region 'r'. * * Note: * If the conversion encounters a root label before the end of the * region the conversion stops and the length is set to the length * so far converted. A maximum of 255 bytes is converted. * * Requires: * The data in 'r' is a sequence of one or more type 00 or type 01000001 * labels. */voiddns_name_toregion(dns_name_t *name, isc_region_t *r);/* * Make 'r' refer to 'name'. * * Requires: * * 'name' is a valid name. * * 'r' is a valid region. */isc_result_tdns_name_fromwire(dns_name_t *name, isc_buffer_t *source, dns_decompress_t *dctx, unsigned int options, isc_buffer_t *target);/* * Copy the possibly-compressed name at source (active region) into target, * decompressing it. * * Notes: * Decompression policy is controlled by 'dctx'. * * If DNS_NAME_DOWNCASE is set, any uppercase letters in 'source' will be * downcased when they are copied into 'target'. * * Security: * * *** WARNING *** * * This routine will often be used when 'source' contains raw network * data. A programming error in this routine could result in a denial * of service, or in the hijacking of the server. * * Requires: * * 'name' is a valid name. * * 'source' is a valid buffer and the first byte of the active * region should be the first byte of a DNS wire format domain name. * * 'target' is a valid buffer or 'target' is NULL and 'name' has * a dedicated buffer. * * 'dctx' is a valid decompression context. * * Ensures: * * If result is success: * If 'target' is not NULL, 'name' is attached to it. * * Uppercase letters are downcased in the copy iff * DNS_NAME_DOWNCASE is set in options. * * The current location in source is advanced, and the used space * in target is updated. * * Result: * Success * Bad Form: Label Length * Bad Form: Unknown Label Type * Bad Form: Name Length * Bad Form: Compression type not allowed * Bad Form: Bad compression pointer * Bad Form: Input too short * Resource Limit: Too many compression pointers * Resource Limit: Not enough space in buffer */isc_result_tdns_name_towire(dns_name_t *name, dns_compress_t *cctx, isc_buffer_t *target);/* * Convert 'name' into wire format, compressing it as specified by the * compression context 'cctx', and storing the result in 'target'. * * Notes: * If the compression context allows global compression, then the * global compression table may be updated. * * Requires: * 'name' is a valid name * * dns_name_countlabels(name) > 0 * * dns_name_isabsolute(name) == TRUE * * target is a valid buffer. * * Any offsets specified in a global compression table are valid * for buffer. * * Ensures: * * If the result is success: * * The used space in target is updated. * * Returns: * Success * Resource Limit: Not enough space in buffer */isc_result_tdns_name_fromtext(dns_name_t *name, isc_buffer_t *source, dns_name_t *origin, unsigned int options, isc_buffer_t *target);/* * 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. * * If DNS_NAME_DOWNCASE is set in 'options', any uppercase letters * in 'source' will be downcased when they are copied into 'target'. * * Requires: * * 'name' is a valid name. * * 'source' is a valid buffer. * * 'target' is a valid buffer or 'target' is NULL and 'name' has * a dedicated buffer. * * Ensures: * * If result is success: * If 'target' is not NULL, 'name' is attached to it. * * Uppercase letters are downcased in the copy iff * DNS_NAME_DOWNCASE is set in 'options'. * * The current location in source is advanced, and the used space * in target is updated. * * Result: * ISC_R_SUCCESS * DNS_R_EMPTYLABEL * DNS_R_LABELTOOLONG * DNS_R_BADESCAPE * (DNS_R_BADBITSTRING: should not be returned) * (DNS_R_BITSTRINGTOOLONG: should not be returned) * DNS_R_BADDOTTEDQUAD * ISC_R_NOSPACE * ISC_R_UNEXPECTEDEND */isc_result_tdns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot, isc_buffer_t *target);/* * Convert 'name' into text format, storing the result in 'target'. * * Notes: * If 'omit_final_dot' is true, then the final '.' in absolute * names other than the root name will be omitted. * * If dns_name_countlabels == 0, the name will be "@", representing the * current origin as described by RFC 1035. * * The name is not NUL terminated. * * Requires: * * 'name' is a valid name * * 'target' is a valid buffer. * * if dns_name_isabsolute == FALSE, then omit_final_dot == FALSE * * Ensures: * * If the result is success: * * The used space in target is updated. * * Returns: * ISC_R_SUCCESS * ISC_R_NOSPACE */#define DNS_NAME_MAXTEXT 1023/* * The maximum length of the text representation of a domain * name as generated by dns_name_totext(). This does not * include space for a terminating NULL. * * This definition is conservative - the actual maximum * is 1004, derived as follows: * * A backslash-decimal escaped character takes 4 bytes. * A wire-encoded name can be up to 255 bytes and each * label is one length byte + at most 63 bytes of data. * Maximizing the label lengths gives us a name of
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -