dns: remove some magic numbers
Let's use enum values for the EDNS codes now that we have them, for readability.
This commit is contained in:
@@ -775,7 +775,7 @@ int dns_packet_append_opt(
|
||||
|
||||
static const uint8_t rfc6975[] = {
|
||||
|
||||
0, 5, /* OPTION_CODE: DAU */
|
||||
0, DNS_EDNS_OPT_DAU, /* OPTION_CODE */
|
||||
#if PREFER_OPENSSL || (HAVE_GCRYPT && GCRYPT_VERSION_NUMBER >= 0x010600)
|
||||
0, 7, /* LIST_LENGTH */
|
||||
#else
|
||||
@@ -791,13 +791,13 @@ int dns_packet_append_opt(
|
||||
DNSSEC_ALGORITHM_ED25519,
|
||||
#endif
|
||||
|
||||
0, 6, /* OPTION_CODE: DHU */
|
||||
0, DNS_EDNS_OPT_DHU, /* OPTION_CODE */
|
||||
0, 3, /* LIST_LENGTH */
|
||||
DNSSEC_DIGEST_SHA1,
|
||||
DNSSEC_DIGEST_SHA256,
|
||||
DNSSEC_DIGEST_SHA384,
|
||||
|
||||
0, 7, /* OPTION_CODE: N3U */
|
||||
0, DNS_EDNS_OPT_N3U, /* OPTION_CODE */
|
||||
0, 1, /* LIST_LENGTH */
|
||||
NSEC3_ALGORITHM_SHA1,
|
||||
};
|
||||
@@ -2180,7 +2180,7 @@ static bool opt_is_good(DnsResourceRecord *rr, bool *rfc6975) {
|
||||
return false;
|
||||
|
||||
/* RFC 6975 DAU, DHU or N3U fields found. */
|
||||
if (IN_SET(option_code, 5, 6, 7))
|
||||
if (IN_SET(option_code, DNS_EDNS_OPT_DAU, DNS_EDNS_OPT_DHU, DNS_EDNS_OPT_N3U))
|
||||
found_dau_dhu_n3u = true;
|
||||
|
||||
p += option_length + 4U;
|
||||
@@ -2597,7 +2597,7 @@ int dns_packet_has_nsid_request(DnsPacket *p) {
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Truncated option in EDNS0 variable part.");
|
||||
|
||||
if (code == 3) {
|
||||
if (code == DNS_EDNS_OPT_NSID) {
|
||||
if (has_nsid)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
|
||||
"Duplicate NSID option in EDNS0 variable part.");
|
||||
|
||||
Reference in New Issue
Block a user