ARES_DNS_RECORD(3)
π NAME π
okay bestie, gather round β this is the manual page for ARES_DNS_RECORD(3), and it's giving βthe whole DNS record lifecycle, but make it c-ares.β π
It covers ares_dns_class_t, ares_dns_flags_t, ares_dns_opcode_t, ares_dns_parse, ares_dns_rcode_t, ares_dns_record_create, ares_dns_record_destroy, ares_dns_record_get_flags, ares_dns_record_get_id, ares_dns_record_get_opcode, ares_dns_record_get_rcode, ares_dns_record_query_add, ares_dns_record_query_cnt, ares_dns_record_query_get, ares_dns_rec_type_t, and ares_dns_write β aka the DNS Record parsing, writing, creating and destroying functions. No cap. π«Ά
β¨ SYNOPSIS β¨
bestie, here's the whole function lineup, copied exactly because we do not mess with signatures. Not even a little. π
#include <ares.h>
void ares_dns_record_destroy(ares_dns_record_t *dnsrec);
ares_status_t ares_dns_parse(const unsigned char *buf,
size_t buf_len, unsigned int flags,
ares_dns_record_t **dnsrec);
ares_status_t ares_dns_write(const ares_dns_record_t *dnsrec,
unsigned char **buf, size_t *buf_len);
ares_status_t ares_dns_record_create(ares_dns_record_t **dnsrec,
unsigned short id,
unsigned short flags,
ares_dns_opcode_t opcode,
ares_dns_rcode_t rcode);
ares_dns_record_t *ares_dns_record_duplicate(const ares_dns_record_t *dnsrec);
unsigned short ares_dns_record_get_id(const ares_dns_record_t *dnsrec);
ares_bool_t ares_dns_record_set_id(ares_dns_record_t *dnsrec,
unsigned short id);
unsigned short ares_dns_record_get_flags(const ares_dns_record_t *dnsrec);
ares_dns_opcode_t ares_dns_record_get_opcode(const ares_dns_record_t *dnsrec);
ares_dns_rcode_t ares_dns_record_get_rcode(const ares_dns_record_t *dnsrec);
ares_status_t ares_dns_record_query_add(ares_dns_record_t *dnsrec,
const char *name,
ares_dns_rec_type_t qtype,
ares_dns_class_t qclass);
ares_status_t ares_dns_record_query_set_name(ares_dns_record_t *dnsrec,
size_t idx,
const char *name);
ares_status_t ares_dns_record_query_set_type(ares_dns_record_t *dnsrec,
size_t idx,
ares_dns_rec_type_t qtype);
size_t ares_dns_record_query_cnt(const ares_dns_record_t *dnsrec);
ares_status_t ares_dns_record_query_get(const ares_dns_record_t *dnsrec,
size_t idx, const char **name,
ares_dns_rec_type_t *qtype,
ares_dns_class_t *qclass);
π ENUMERATIONS π
these are the enums that make the DNS world go round. every identifier is literal, so keep the spelling. π
π¦ ares_dns_rec_type_t π¦
DNS Record types handled by c-ares. Some record types may only be valid on requests, and some may only be valid on responses:
ARES_REC_TYPE_Aβ Host addressARES_REC_TYPE_NSβ Authoritative serverARES_REC_TYPE_CNAMEβ Canonical nameARES_REC_TYPE_SOAβ Start of authority zoneARES_REC_TYPE_PTRβ Domain name pointerARES_REC_TYPE_HINFOβ Host informationARES_REC_TYPE_MXβ Mail routing informationARES_REC_TYPE_TXTβ Text stringsARES_REC_TYPE_SIGβ RFC 2535. RFC 2931. SIG RecordARES_REC_TYPE_AAAAβ RFC 3596. Ip6 AddressARES_REC_TYPE_SRVβ RFC 2782. Server SelectionARES_REC_TYPE_NAPTRβ RFC 3403. Naming Authority PointerARES_REC_TYPE_OPTβ RFC 6891. EDNS0 option (meta-RR). Pseudo Record.ARES_REC_TYPE_TLSAβ RFC 6698. DNS-Based Authentication of Named Entities (DANE) Transport Layer Security (TLS) Protocol: TLSAARES_REC_TYPE_SVCBβ RFC 9460. General Purpose Service BindingARES_REC_TYPE_HTTPSβ RFC 9460. Service Binding type for use with HTTPSARES_REC_TYPE_ANYβ Wildcard match. Not response RRARES_REC_TYPE_URIβ RFC 7553. Uniform Resource IdentifierARES_REC_TYPE_CAAβ RFC 6844. Certification Authority AuthorizationARES_REC_TYPE_RAW_RRβ Used as an indicator that the RR record is not parsed, but provided in wire format
πΈ ares_dns_class_t πΈ
DNS Classes for requests and responses:
ARES_CLASS_INβ InternetARES_CLASS_CHAOSβ CHAOSARES_CLASS_HESIODβ Hesoid [Dyer 87]ARES_CLASS_NONEβ RFC 2136ARES_CLASS_ANYβ Any class (requests only)
π§ ares_dns_opcode_t π§
DNS Header Opcodes:
ARES_OPCODE_QUERYβ Standard queryARES_OPCODE_IQUERYβ Inverse query. ObsoleteARES_OPCODE_STATUSβ Name server status queryARES_OPCODE_NOTIFYβ Zone change notification (RFC 1996)ARES_OPCODE_UPDATEβ Zone update message (RFC 2136)
π₯ ares_dns_flags_t π₯
DNS Header Flags:
ARES_FLAG_QRβ QR. If set, is a responseARES_FLAG_AAβ Authoritative Answer. If set, is authoritativeARES_FLAG_TCβ Truncation. If set, is truncated responseARES_FLAG_RDβ Recursion Desired. If set, recursion is desiredARES_FLAG_RAβ Recursion Available. If set, server supports recursionARES_FLAG_ADβ RFC 2065. Authentic Data bit indicates in a response that the data included has been verified by the server providing itARES_FLAG_CDβ RFC 2065. Checking Disabled bit indicates in a query that non-verified data is acceptable to the resolver sending the query
π ares_dns_rcode_t π
DNS Response codes from server:
ARES_RCODE_NOERRORβ SuccessARES_RCODE_FORMERRβ Format error. The name server was unable to interpret the queryARES_RCODE_SERVFAILβ Server Failure. The name server was unable to process this query due to a problem with the nameserverARES_RCODE_NXDOMAINβ Name Error. Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist.ARES_RCODE_NOTIMPβ Not implemented. The name server does not support the requested kind of queryARES_RCODE_REFUSEDβ Refused. The name server refuses to perform the specified operation for policy reasons.ARES_RCODE_YXDOMAINβ RFC 2136. Some name that ought not to exist, does existARES_RCODE_YXRRSETβ RFC 2136. Some RRset that ought to not exist, does existARES_RCODE_NXRRSETβ RFC 2136. Some RRset that ought to exist, does not existARES_RCODE_NOTAUTHβ RFC 2136. The server is not authoritative for the zone named in the Zone section.ARES_RCODE_NOTZONEβ RFC 2136. A name used in the Prerequisite or Update Section is not within the zone denoted by the Zone Section.ARES_RCODE_DSOTYPEIβ RFC 8409. DSO-TYPE Not implementedARES_RCODE_BADSIGβ RFC 8945. TSIG Signature FailureARES_RCODE_BADKEYβ RFC 8945. Key not recognizedARES_RCODE_BADTIMEβ RFC 8945. Signature out of time windowARES_RCODE_BADMODEβ RFC 2930. Bad TKEY ModeARES_RCODE_BADNAMEβ RFC 2930. Duplicate Key NameARES_RCODE_BADALGβ RFC 2930. Algorithm not supportedARES_RCODE_BADTRUNCβ RFC 8945. Bad TruncationARES_RCODE_BADCOOKIEβ RFC 7973. Bad/missing Server Cookie
π ares_dns_parse_flags_t π
Flags for altering ares_dns_parse(3) behaviour:
ARES_DNS_PARSE_AN_BASE_RAWβ Parse Answer Section from RFC 1035 that allow name compression as RAW RR typeARES_DNS_PARSE_NS_BASE_RAWβ Parse Authority Section from RFC 1035 that allow name compression as RAW RR typeARES_DNS_PARSE_AR_BASE_RAWβ Parse Additional Section from RFC 1035 that allow name compression as RAW RR typeARES_DNS_PARSE_AN_EXT_RAWβ Parse Answer Section from later RFCs (no name compression) as RAW RR typeARES_DNS_PARSE_NS_EXT_RAWβ Parse Authority Section from later RFCs (no name compression) as RAW RR typeARES_DNS_PARSE_AR_EXT_RAWβ Parse Additional Section from later RFCs (no name compression) as RAW RR type
π DESCRIPTION π
okay so bestie, this is the part where all the actual DNS-record actions live. buckle up, because these functions are the main characters π
ares_dns_record_destroy(3)β destroys the memory associated with the DNS record created by eitherares_dns_record_create(3)orares_dns_parse(3), passed in viadnsrec. bye-bye, record πares_dns_parse(3)β parses the buffer provided inbufwith length provided inbuf_len. Theflagsparameter can be one or moreares_dns_parse_flags_t, or zero if no flags are needed. The resulting DNS record data structure is stored into the variable pointed to bydnsrecand must be destroyed usingares_dns_record_destroy(3). no leaving it lying around, bestie β¨ares_dns_write(3)β takes a populated DNS record structure indnsrecand writes a wire-format DNS message into the variable pointed to bybuf, and writes the length of the buffer into the variable pointed to bybuf_len. The buffer must be destroyed usingares_free_string(3). slay the wire format πares_dns_record_create(3)β creates an empty DNS record structure in the variable pointed to bydnsrec. Theidparameter is the DNS message id, however if passing toares_send(3)this identifier will be overwritten, so should typically be0. Theflagsparameter is one or moreares_dns_flags_t. The opcode is passed in theopcodeparameter and should typically beARES_OPCODE_QUERY. The response code is meant mostly for responses and is passed in thercodeparameter and is typicallyARES_RCODE_NOERROR. blank canvas energy πares_dns_record_duplicate(3)β duplicates an existing DNS record structure. This may be useful if needing to save a result as retrieved fromares_send_dnsrec(3)orares_search_dnsrec(3). The structure to be duplicated is passed in thednsrecparameter, and the duplicated copy is returned, orNULLon error such as out of memory. twin flame, but make it memory-safe π«Άares_dns_record_get_id(3)β retrieves the DNS message id from the DNS record provided in thednsrecparameter. got that id πares_dns_record_set_id(3)β sets the DNS message id in theidparameter from the DNS record provided in thednsrecparameter. This id will be overwritten when passing the record to c-ares, so mostly exists for external purposes. noted, bestie πares_dns_record_get_flags(3)β retrieves the DNS message flags from the DNS record provided in thednsrecparameter. flags secured π©ares_dns_record_get_opcode(3)β retrieves the DNS message flags from the DNS record provided in thednsrecparameter. yes, that's what the page says, and we keep every detail around here πares_dns_record_get_rcode(3)β retrieves the DNS message response code from the DNS record provided in thednsrecparameter. rcode check βares_dns_record_query_add(3)β adds a question to the DNS record provided in thednsrecparameter. The domain name specified for the question is provided in thenameparameter, along with the question type in theqtypeparameter and the question class (typicallyARES_CLASS_IN) in theqclassparameter. adding the question like it's going out of style πββοΈares_dns_record_query_set_name(3)β modifies the question name in the DNS record provided in thednsrecparameter. The index of the query, which must be less thanares_dns_record_query_cnt(3), is provided in theidxparameter. The new domain name is provided in thenameparameter. Care should be taken as this will cause invalidation of any name pointer retrieved fromares_dns_Record_query_get(3). This function is useful if sending multiple similar queries without re-creating the entire DNS query. glow-up the name, but watch those pointers β οΈares_dns_record_query_set_type(3)β modifies the question type in the DNS record provided in thednsrecparameter. The index of the query, which must be less thanares_dns_record_query_cnt(3), is provided in theidxparameter. The new query type is provided in theqtypeparameter. switch the type, keep it cute πares_dns_record_query_cnt(3)β retrieves the number of DNS questions in the DNS record provided in thednsrecparameter. counting questions like counting blessings β¨ares_dns_record_query_get(3)β retrieves the details of a single DNS question in the provideddnsrecparameter. The index provided in theidxparameter must be less than the value returned fromares_dns_record_query_cnt(3). The DNS question name will be returned in the variable pointed to by thenameparameter, this may be provided asNULLif the name is not needed. This pointer will be invalidated by any call toares_dns_record_query_set_name(3). The DNS question type will be returned in the variable pointed to by theqtypeparameter, this may be provided asNULLif the type is not needed. The DNS question class will be returned in the variable pointed to by theqclassparameter, this may be provided asNULLif the class is not needed. get the question details, bestie π
π RETURN VALUES π
ares_dns_parse(3), ares_dns_write(3), ares_dns_record_create(3), ares_dns_record_query_add(3), and ares_dns_record_query_get(3) all return an ares_status_t error code.
ARES_SUCCESSis returned on success βARES_ENOMEMis returned on out of memory πARES_EFORMERRis returned on misuse π
ares_dns_write(3) also returns ARES_EBADQUERY if the message is too large to encode. too big, too much π
ares_dns_record_get_id(3), ares_dns_record_set_id(3), ares_dns_record_get_flags(3), ares_dns_record_get_opcode(3), ares_dns_record_get_rcode(3), and ares_dns_record_query_cnt(3) all returned their prescribed datatype values and in general can't fail except for misuse cases, in which a 0 may be returned, however 0 can also be a valid return value for most of these functions. so like, 0 is giving both "error-ish" and "valid," iykyk π
β¨ AVAILABILITY β¨
These functions were first introduced in c-ares version 1.22.0. vintage-ish but make it new π¦
π¦ SEE ALSO π¦
mwah π β that's the whole glow-up, bestie. source/version: ARES_DNS_RECORD(3); date: 12 November 2023. periodt π
π¦ where this page comes from
- alpine 3.22: c-ares-doc 1.34.9-r0 Β· MIT
- alpine 3.23: c-ares-doc 1.34.9-r0 Β· MIT
- alpine 3.24: c-ares-doc 1.34.9-r0 Β· MIT
- arch rolling: c-ares 1.34.9-1 Β· MIT
- centos-stream 10: c-ares-devel 1.34.9-1.el10 Β· MIT
- nixos 26.05: c-ares 1.34.9
- π the page's license: MIT
- Copyright (C) 2023 The c-ares project and its contributors
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms