diff options
Diffstat (limited to 'ldns')
| -rw-r--r-- | ldns/config.h.in | 11 | ||||
| -rw-r--r-- | ldns/dnssec_zone.h | 14 | ||||
| -rw-r--r-- | ldns/edns.h | 6 | ||||
| -rw-r--r-- | ldns/error.h | 3 | ||||
| -rw-r--r-- | ldns/host2str.h | 18 | ||||
| -rw-r--r-- | ldns/packet.h | 13 | ||||
| -rw-r--r-- | ldns/rdata.h | 10 | ||||
| -rw-r--r-- | ldns/rr.h | 20 | ||||
| -rw-r--r-- | ldns/str2host.h | 10 | ||||
| -rw-r--r-- | ldns/util.h.in | 22 |
10 files changed, 116 insertions, 11 deletions
diff --git a/ldns/config.h.in b/ldns/config.h.in index 5449bee63381..a8f061617a84 100644 --- a/ldns/config.h.in +++ b/ldns/config.h.in @@ -394,9 +394,18 @@ /* Define this to enable RR type AVC. */ #undef RRTYPE_AVC +/* Define this to enable RR types CLA and IPN. */ +#undef RRTYPE_CLA_IPN + /* Define this to enable RR type DOA. */ #undef RRTYPE_DOA +/* Define this to enable RR type DSYNC. */ +#undef RRTYPE_DSYNC + +/* Define this to enable RR types HHIT and BRID. */ +#undef RRTYPE_HHIT_BRID + /* Define this to enable RR type NINFO. */ #undef RRTYPE_NINFO @@ -772,7 +781,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz); #define close_socket(_s) do { if (_s != SOCK_INVALID) {closesocket(_s); _s = -1;} } while(0) #else #define SOCK_INVALID -1 -#define close_socket(_s) do { if (_s != SOCK_INVALID) {close(_s); _s = -1;} } while(0) +#define close_socket(_s) do { if (_s != SOCK_INVALID) {close(_s >= -1 ? _s : -1); _s = -1;} } while(0) #endif #ifdef __cplusplus diff --git a/ldns/dnssec_zone.h b/ldns/dnssec_zone.h index 156e39102327..335f57a3c4a6 100644 --- a/ldns/dnssec_zone.h +++ b/ldns/dnssec_zone.h @@ -131,7 +131,8 @@ void ldns_dnssec_rrs_deep_free(ldns_dnssec_rrs *rrs); * * \param[in] rrs the list to add to * \param[in] rr the RR to add - * \return LDNS_STATUS_OK on success + * \return LDNS_STATUS_OK on success and LDNS_STATUS_EQUAL_ERR when and + * RR with equal ownername, class, type and rdata already exists. */ ldns_status ldns_dnssec_rrs_add_rr(ldns_dnssec_rrs *rrs, ldns_rr *rr); @@ -199,7 +200,8 @@ ldns_status ldns_dnssec_rrsets_set_type(ldns_dnssec_rrsets *rrsets, * * \param[in] rrsets the list of rrsets to add the RR to * \param[in] rr the rr to add to the list of rrsets - * \return LDNS_STATUS_OK on success + * \return LDNS_STATUS_OK on success and LDNS_STATUS_EQUAL_ERR when and + * RR with equal ownername, class, type and rdata already exists. */ ldns_status ldns_dnssec_rrsets_add_rr(ldns_dnssec_rrsets *rrsets, ldns_rr *rr); @@ -313,7 +315,9 @@ int ldns_dnssec_name_cmp(const void *a, const void *b); * * \param[in] name The ldns_dnssec_name to add the RR to * \param[in] rr The RR to add - * \return LDNS_STATUS_OK on success, error code otherwise + * \return LDNS_STATUS_OK on success and LDNS_STATUS_EQUAL_ERR when and + * RR with equal ownername, class, type and rdata already exists, + * and an error code otherwise */ ldns_status ldns_dnssec_name_add_rr(ldns_dnssec_name *name, ldns_rr *rr); @@ -415,7 +419,9 @@ void ldns_dnssec_zone_deep_free(ldns_dnssec_zone *zone); * * \param[in] zone the zone to add the RR to * \param[in] rr The RR to add - * \return LDNS_STATUS_OK on success, an error code otherwise + * \return LDNS_STATUS_OK on success and LDNS_STATUS_EQUAL_ERR when and + * RR with equal ownername, class, type and rdata already exists, + * and an error code otherwise */ ldns_status ldns_dnssec_zone_add_rr(ldns_dnssec_zone *zone, ldns_rr *rr); diff --git a/ldns/edns.h b/ldns/edns.h index a33ed0557679..7e51ab322cea 100644 --- a/ldns/edns.h +++ b/ldns/edns.h @@ -76,7 +76,11 @@ enum ldns_edns_enum_ede_code LDNS_EDE_NETWORK_ERROR = 23, LDNS_EDE_INVALID_DATA = 24, LDNS_EDE_SIGNATURE_EXPIRED_BEFORE_VALID = 25, - LDNS_EDE_TOO_EARLY = 26 + LDNS_EDE_TOO_EARLY = 26, /* RFC 9250 */ + LDNS_EDE_UNSUPPORTED_NSEC3_ITERATIONS_VALUE = 27, /* RFC 9276 */ + LDNS_EDE_UNABLE_TO_CONFORM_TO_POLICY = 28, /* draft-homburg-dnsop-codcp-00 */ + LDNS_EDE_SYNTHESIZED = 29, /* https://github.com/PowerDNS/pdns/pull/12334 */ + LDNS_EDE_INVALID_QUERY_TYPE = 30 /* RFC 9824 */ }; typedef enum ldns_edns_enum_ede_code ldns_edns_ede_code; diff --git a/ldns/error.h b/ldns/error.h index 011df284725a..a76eb2ecab5d 100644 --- a/ldns/error.h +++ b/ldns/error.h @@ -143,7 +143,8 @@ enum ldns_enum_status { LDNS_STATUS_SVCPARAM_KEY_MORE_THAN_ONCE, LDNS_STATUS_INVALID_SVCPARAM_VALUE, LDNS_STATUS_NOT_EDE, - LDNS_STATUS_EDE_OPTION_MALFORMED + LDNS_STATUS_EDE_OPTION_MALFORMED, + LDNS_STATUS_EQUAL_RR }; typedef enum ldns_enum_status ldns_status; diff --git a/ldns/host2str.h b/ldns/host2str.h index 79f5561a9451..2f67e2787938 100644 --- a/ldns/host2str.h +++ b/ldns/host2str.h @@ -581,6 +581,14 @@ ldns_status ldns_rdf2buffer_str_int16(ldns_buffer *output, const ldns_rdf *rdf); */ ldns_status ldns_rdf2buffer_str_int32(ldns_buffer *output, const ldns_rdf *rdf); +/** + * Converts an LDNS_RDF_TYPE_INT64 rdata element to presentation format. + * \param[in] *rdf The rdata to convert + * \param[in] *output The buffer to add the data to + * \return LDNS_STATUS_OK on success, and error status on failure + */ +ldns_status ldns_rdf2buffer_str_int64(ldns_buffer *output, const ldns_rdf *rdf); + /** * Converts an LDNS_RDF_TYPE_TIME rdata element to string format and adds it to the output buffer * \param[in] *rdf The rdata to convert @@ -619,6 +627,16 @@ ldns_status ldns_rdf2buffer_str_eui48(ldns_buffer *output, ldns_status ldns_rdf2buffer_str_eui64(ldns_buffer *output, const ldns_rdf *rdf); +/** + * Adds the LDNS_RDF_TYPE_UNQUOTED rdata to the output buffer, + * it escapes nonprinting and special characters. + * \param[in] *rdf The rdata to convert + * \param[in] *output The buffer to add the data to + * \return LDNS_STATUS_OK on success, and error status on failure + */ +ldns_status ldns_rdf2buffer_str_unquoted(ldns_buffer *output, + const ldns_rdf *rdf); + /** * Adds the LDNS_RDF_TYPE_TAG rdata to the output buffer, * provided it contains only alphanumeric characters. diff --git a/ldns/packet.h b/ldns/packet.h index 2c60609fc07a..974944149a27 100644 --- a/ldns/packet.h +++ b/ldns/packet.h @@ -710,6 +710,19 @@ bool ldns_pkt_edns_do(const ldns_pkt *packet); void ldns_pkt_set_edns_do(ldns_pkt *packet, bool value); /** + * return the packet's edns co bit + * \param[in] packet the packet + * \return the bit's value + */ +bool ldns_pkt_edns_co(const ldns_pkt *packet); +/** + * Set the packet's edns co bit + * \param[in] packet the packet + * \param[in] value the bit's new value + */ +void ldns_pkt_set_edns_co(ldns_pkt *packet, bool value); + +/** * return the packet's EDNS header bits that are unassigned. */ uint16_t ldns_pkt_edns_unassigned(const ldns_pkt *packet); diff --git a/ldns/rdata.h b/ldns/rdata.h index 1e2fd397a38a..7623bd17a73b 100644 --- a/ldns/rdata.h +++ b/ldns/rdata.h @@ -54,6 +54,8 @@ enum ldns_enum_rdf_type LDNS_RDF_TYPE_INT16, /** 32 bits */ LDNS_RDF_TYPE_INT32, + /** 64 bits */ + LDNS_RDF_TYPE_INT64, /** A record */ LDNS_RDF_TYPE_A, /** AAAA record */ @@ -70,6 +72,7 @@ enum ldns_enum_rdf_type LDNS_RDF_TYPE_HEX, /** nsec type codes */ LDNS_RDF_TYPE_NSEC, + LDNS_RDF_TYPE_BITMAP = LDNS_RDF_TYPE_NSEC, /** a RR type */ LDNS_RDF_TYPE_TYPE, /** a class */ @@ -120,6 +123,9 @@ enum ldns_enum_rdf_type /** 8 * 8 bit hex numbers separated by dashes. For EUI64. */ LDNS_RDF_TYPE_EUI64, + /** Character string without quotes. */ + LDNS_RDF_TYPE_UNQUOTED, + /** A non-zero sequence of US-ASCII letters and numbers in lower case. * For CAA. */ @@ -145,8 +151,8 @@ enum ldns_enum_rdf_type /** draft-ietf-dnsop-svcb-https **/ LDNS_RDF_TYPE_SVCPARAMS, - /* Aliases */ - LDNS_RDF_TYPE_BITMAP = LDNS_RDF_TYPE_NSEC + /** draft-johnson-dns-ipn-cla-07 **/ + LDNS_RDF_TYPE_IPN }; typedef enum ldns_enum_rdf_type ldns_rdf_type; diff --git a/ldns/rr.h b/ldns/rr.h index 314f159707b3..d2e4ee90aa9c 100644 --- a/ldns/rr.h +++ b/ldns/rr.h @@ -194,6 +194,9 @@ enum ldns_enum_rr_type LDNS_RR_TYPE_ZONEMD = 63, /* RFC 8976 */ LDNS_RR_TYPE_SVCB = 64, /* RFC 9460 */ LDNS_RR_TYPE_HTTPS = 65, /* RFC 9460 */ + LDNS_RR_TYPE_DSYNC = 66, /* RFC 9859 */ + LDNS_RR_TYPE_HHIT = 67, /* draft-ietf-drip-registries-28 */ + LDNS_RR_TYPE_BRID = 68, /* draft-ietf-drip-registries-28 */ LDNS_RR_TYPE_SPF = 99, /* RFC 4408 */ @@ -210,7 +213,7 @@ enum ldns_enum_rr_type LDNS_RR_TYPE_EUI48 = 108, /* RFC 7043 */ LDNS_RR_TYPE_EUI64 = 109, /* RFC 7043 */ - LDNS_RR_TYPE_NXNAME = 128, /* draft-ietf-dnsop-compact-denial-of-existence */ + LDNS_RR_TYPE_NXNAME = 128, /* RFC 9824 */ LDNS_RR_TYPE_TKEY = 249, /* RFC 2930 */ LDNS_RR_TYPE_TSIG = 250, @@ -236,6 +239,12 @@ enum ldns_enum_rr_type /** https://iana.org/assignments/dns-parameters/WALLET/wallet-completed-template */ LDNS_RR_TYPE_WALLET = 262, + /** https://www.iana.org/assignments/dns-parameters/CLA/cla-completed-template */ + LDNS_RR_TYPE_CLA = 263, + + /** https://www.iana.org/assignments/dns-parameters/IPN/ipn-completed-template */ + LDNS_RR_TYPE_IPN = 264, + /** DNSSEC Trust Authorities */ LDNS_RR_TYPE_TA = 32768, /* RFC 4431, 5074, DNSSEC Lookaside Validation */ @@ -251,7 +260,7 @@ enum ldns_enum_rr_type typedef enum ldns_enum_rr_type ldns_rr_type; /* The first fields are contiguous and can be referenced instantly */ -#define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON (LDNS_RR_TYPE_WALLET + 1) +#define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON (LDNS_RR_TYPE_IPN + 1) /** * Resource Record @@ -725,6 +734,13 @@ bool ldns_rr_list_contains_rr(const ldns_rr_list *rr_list, const ldns_rr *rr); bool ldns_is_rrset(const ldns_rr_list *rr_list); /** + * checks if an rr_list is a rrset, including checking for TTL. + * \param[in] rr_list the rr_list to check + * \return true if it is an rrset otherwise false + */ +bool ldns_is_rrset_strict(const ldns_rr_list *rr_list); + +/** * pushes an rr to an rrset (which really are rr_list's). * \param[in] *rr_list the rrset to push the rr to * \param[in] *rr the rr to push diff --git a/ldns/str2host.h b/ldns/str2host.h index 2892db0bfb1c..18bd7f6d7e8a 100644 --- a/ldns/str2host.h +++ b/ldns/str2host.h @@ -331,6 +331,16 @@ ldns_status ldns_str2rdf_amtrelay(ldns_rdf **rd, const char *str); */ ldns_status ldns_str2rdf_svcparams(ldns_rdf **rd, const char *str); +/** + * Convert either two unsigned 32 bit decimal numbers seperated by a '.', + * or a single unsigned 64 bit decimal number, as described in + * [draft-johnson-dns-ipn-cla-07]. + * \param[out] rd the rdf where to put the data + * \param[in] str the string to be converted + * \return ldns_status + */ +ldns_status ldns_str2rdf_ipn(ldns_rdf **rd, const char *str); + #ifdef __cplusplus } diff --git a/ldns/util.h.in b/ldns/util.h.in index 7115a2b7f3bf..6b243ac2b5af 100644 --- a/ldns/util.h.in +++ b/ldns/util.h.in @@ -72,8 +72,10 @@ ldns_read_uint16(const void *src) #ifdef ALLOW_UNALIGNED_ACCESSES return ntohs(*(const uint16_t *) src); #else +# ifndef __clang_analyzer__ const uint8_t *p = (const uint8_t *) src; return ((uint16_t) p[0] << 8) | (uint16_t) p[1]; +# endif #endif } @@ -91,6 +93,26 @@ ldns_read_uint32(const void *src) #endif } +INLINE uint64_t +ldns_read_uint64(const void *src) +{ +#ifdef ALLOW_UNALIGNED_ACCESSES + const uint32_t *p = (const uint32_t *) src; + return ( ((uint64_t) ntohl(src[0]) << 32) + | (uint64_t) ntohl(src[1])); +#else + const uint8_t *p = (const uint8_t *) src; + return ( ((uint64_t) p[0] << 56) + | ((uint64_t) p[1] << 48) + | ((uint64_t) p[2] << 40) + | ((uint64_t) p[3] << 32) + | ((uint64_t) p[4] << 24) + | ((uint64_t) p[5] << 16) + | ((uint64_t) p[6] << 8) + | (uint64_t) p[7]); +#endif +} + /* * Copy data allowing for unaligned accesses in network byte order * (big endian). |
