---
name: "ares_dns_rr_get_opt_cnt"
section: "3"
platform: "linux"
package: "c-ares"
version: "1.34.9-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ares_dns_rr"
---

# ares\_dns\_rr\_get\_opt\_cnt(3)

DNS Resource Record creating, reading, and writing functions.

Part of [ares\_dns\_rr(3)](/ares_dns_rr/3.md).

## NAME

ares\_dns\_record\_rr\_add, ares\_dns\_record\_rr\_cnt, ares\_dns\_record\_rr\_del, ares\_dns\_record\_rr\_get, ares\_dns\_record\_rr\_get\_const, ares\_dns\_rr\_get\_addr, ares\_dns\_rr\_get\_addr6, ares\_dns\_rr\_get\_bin, ares\_dns\_rr\_get\_abin\_cnt, ares\_dns\_rr\_get\_abin, ares\_dns\_rr\_get\_class, ares\_dns\_rr\_get\_name, ares\_dns\_rr\_get\_opt, ares\_dns\_rr\_get\_opt\_byid, ares\_dns\_rr\_get\_opt\_cnt, ares\_dns\_rr\_get\_str, ares\_dns\_rr\_get\_ttl, ares\_dns\_rr\_get\_type, ares\_dns\_rr\_get\_u16, ares\_dns\_rr\_get\_u32, ares\_dns\_rr\_get\_u8, ares\_dns\_rr\_key\_t, ares\_dns\_rr\_set\_addr, ares\_dns\_rr\_set\_addr6, ares\_dns\_rr\_set\_bin, ares\_dns\_rr\_add\_abin, ares\_dns\_rr\_del\_abin, ares\_dns\_rr\_set\_opt, ares\_dns\_rr\_set\_str, ares\_dns\_rr\_set\_u16, ares\_dns\_rr\_set\_u32, ares\_dns\_rr\_set\_u8, ares\_dns\_section\_t, ares\_tlsa\_match\_t, ares\_tlsa\_selector\_t, ares\_tlsa\_usage\_t - DNS Resource Record creating, reading, and writing functions.

## SYNOPSIS

```
#include <ares.h>
size_t ares_dns_record_rr_cnt(const ares_dns_record_t *dnsrec,
                              ares_dns_section_t       sect);
ares_status_t ares_dns_record_rr_add(ares_dns_rr_t     **rr_out,
                                     ares_dns_record_t  *dnsrec,
                                     ares_dns_section_t  sect,
                                     const char         *name,
                                     ares_dns_rec_type_t type,
                                     ares_dns_class_t    rclass,
                                     unsigned int        ttl);
ares_dns_rr_t *ares_dns_record_rr_get(ares_dns_record_t *dnsrec,
                                      ares_dns_section_t sect,
                                      size_t             idx);
const ares_dns_rr_t *ares_dns_record_rr_get_const(const ares_dns_record_t *dnsrec,
                                                  ares_dns_section_t sect,
                                                  size_t idx);
ares_status_t ares_dns_record_rr_del(ares_dns_record_t *dnsrec,
                                     ares_dns_section_t sect,
                                     size_t             idx);
const char *ares_dns_rr_get_name(const ares_dns_rr_t *rr);
ares_dns_rec_type_t ares_dns_rr_get_type(const ares_dns_rr_t *rr);
ares_dns_class_t ares_dns_rr_get_class(const ares_dns_rr_t *rr);
unsigned int ares_dns_rr_get_ttl(const ares_dns_rr_t *rr);
ares_status_t ares_dns_rr_set_addr(ares_dns_rr_t        *dns_rr,
                                   ares_dns_rr_key_t     key,
                                   const struct in_addr *addr);
ares_status_t ares_dns_rr_set_addr6(ares_dns_rr_t              *dns_rr,
                                    ares_dns_rr_key_t           key,
                                    const struct ares_in6_addr *addr);
ares_status_t ares_dns_rr_set_str(ares_dns_rr_t    *dns_rr,
                                  ares_dns_rr_key_t key,
                                  const char       *val);
ares_status_t ares_dns_rr_set_u8(ares_dns_rr_t    *dns_rr,
                                 ares_dns_rr_key_t key,
                                 unsigned char     val);
ares_status_t ares_dns_rr_set_u16(ares_dns_rr_t    *dns_rr,
                                  ares_dns_rr_key_t key,
                                  unsigned short    val);
ares_status_t ares_dns_rr_set_u32(ares_dns_rr_t    *dns_rr,
                                  ares_dns_rr_key_t key,
                                  unsigned int      val);
ares_status_t ares_dns_rr_set_bin(ares_dns_rr_t       *dns_rr,
                                  ares_dns_rr_key_t    key,
                                  const unsigned char *val,
                                  size_t               len);
ares_status_t ares_dns_rr_add_abin(ares_dns_rr_t *dns_rr,
                                   ares_dns_rr_key_t key,
                                   const unsigned char *val,
                                   size_t len);
ares_status_t ares_dns_rr_del_abin(ares_dns_rr_t *dns_rr,
                                   ares_dns_rr_key_t key,
                                   size_t idx);
ares_status_t ares_dns_rr_set_opt(ares_dns_rr_t       *dns_rr,
                                  ares_dns_rr_key_t    key,
                                  unsigned short       opt,
                                  const unsigned char *val,
                                  size_t               val_len);
ares_status_t ares_dns_rr_del_opt_byid(ares_dns_rr_t       *dns_rr,
                                       ares_dns_rr_key_t    key,
                                       unsigned short       opt);
const struct in_addr *ares_dns_rr_get_addr(const ares_dns_rr_t *dns_rr,
                                           ares_dns_rr_key_t key);
const struct ares_in6_addr *ares_dns_rr_get_addr6(const ares_dns_rr_t *dns_rr,
                                                  ares_dns_rr_key_t key);
const char *ares_dns_rr_get_str(const ares_dns_rr_t *dns_rr,
                                ares_dns_rr_key_t    key);
unsigned char ares_dns_rr_get_u8(const ares_dns_rr_t *dns_rr,
                                 ares_dns_rr_key_t    key);
unsigned short ares_dns_rr_get_u16(const ares_dns_rr_t *dns_rr,
                                   ares_dns_rr_key_t    key);
unsigned int ares_dns_rr_get_u32(const ares_dns_rr_t *dns_rr,
                                 ares_dns_rr_key_t    key);
const unsigned char *ares_dns_rr_get_bin(const ares_dns_rr_t *dns_rr,
                                         ares_dns_rr_key_t key,
                                         size_t *len);
size_t ares_dns_rr_get_abin_cnt(const ares_dns_rr_t *dns_rr,
                                ares_dns_rr_key_t key);
const unsigned char *ares_dns_rr_get_abin(const ares_dns_rr_t *dns_rr,
                                          ares_dns_rr_key_t key, size_t idx,
                                          size_t *len);
size_t ares_dns_rr_get_opt_cnt(const ares_dns_rr_t *dns_rr,
                               ares_dns_rr_key_t    key);
unsigned short ares_dns_rr_get_opt(const ares_dns_rr_t  *dns_rr,
                                   ares_dns_rr_key_t     key,
                                   size_t                idx,
                                   const unsigned char **val,
                                   size_t               *val_len);
ares_bool_t ares_dns_rr_get_opt_byid(const ares_dns_rr_t  *dns_rr,
                                     ares_dns_rr_key_t     key,
                                     unsigned short        opt,
                                     const unsigned char **val,
                                     size_t *val_len);
```

## ENUMERATIONS

**ares\_dns\_section\_t -** DNS RR section types:

**ARES\_SECTION\_ANSWER** - Answer section\
 **ARES\_SECTION\_AUTHORITY** - Authority section\
 **ARES\_SECTION\_ADDITIONAL** - Additional Information section\

**ares\_dns\_rr\_key\_t -** Keys used for handling RR record parameters:

**ARES\_RR\_A\_ADDR** - A Record. Address. Datatype: *ARES\_DATATYPE\_INADDR*\
 **ARES\_RR\_NS\_NSDNAME** - NS Record. Name. Datatype: *ARES\_DATATYPE\_NAME*\
 **ARES\_RR\_CNAME\_CNAME** - CNAME Record. CName. Datatype: *ARES\_DATATYPE\_NAME*\
 **ARES\_RR\_SOA\_MNAME** - SOA Record. MNAME, Primary Source of Data. Datatype: *ARES\_DATATYPE\_NAME*\
 **ARES\_RR\_SOA\_RNAME** - SOA Record. RNAME, Mailbox of person responsible. Datatype: *ARES\_DATATYPE\_NAME*\
 **ARES\_RR\_SOA\_SERIAL** - SOA Record. Serial, version. Datatype: *ARES\_DATATYPE\_U32*\
 **ARES\_RR\_SOA\_REFRESH** - SOA Record. Refresh, zone refersh interval. Datatype: *ARES\_DATATYPE\_U32*\
 **ARES\_RR\_SOA\_RETRY** - SOA Record. Retry, failed refresh retry interval. Datatype: *ARES\_DATATYPE\_U32*\
 **ARES\_RR\_SOA\_EXPIRE** - SOA Record. Expire, upper limit on authority. Datatype: *ARES\_DATATYPE\_U32*\
 **ARES\_RR\_SOA\_MINIMUM** - SOA Record. Minimum, RR TTL. Datatype: *ARES\_DATATYPE\_U32*\
 **ARES\_RR\_PTR\_DNAME** -  PTR Record. DNAME, pointer domain. Datatype: *ARES\_DATATYPE\_NAME*\
 **ARES\_RR\_HINFO\_CPU** - HINFO Record. CPU. Datatype: *ARES\_DATATYPE\_STR*\
 **ARES\_RR\_HINFO\_OS** - HINFO Record. OS. Datatype: *ARES\_DATATYPE\_STR*\
 **ARES\_RR\_MX\_PREFERENCE** - MX Record. Preference. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_MX\_EXCHANGE** - MX Record. Exchange, domain. Datatype: *ARES\_DATATYPE\_NAME*\
 **ARES\_RR\_TXT\_DATA** - TXT Record. Data. Datatype: *ARES\_DATATYPE\_ABINP*\
 **ARES\_RR\_SIG\_TYPE\_COVERED** - SIG Record. Type Covered. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_SIG\_ALGORITHM** - SIG Record. Algorithm. Datatype: *ARES\_DATATYPE\_U8*\
 **ARES\_RR\_SIG\_LABELS** - SIG Record. Labels. Datatype: *ARES\_DATATYPE\_U8*\
 **ARES\_RR\_SIG\_ORIGINAL\_TTL** - SIG Record. Original TTL. Datatype: *ARES\_DATATYPE\_U32*\
 **ARES\_RR\_SIG\_EXPIRATION** - SIG Record. Signature Expiration. Datatype: *ARES\_DATATYPE\_U32*\
 **ARES\_RR\_SIG\_INCEPTION** - SIG Record. Signature Inception. Datatype: *ARES\_DATATYPE\_U32*\
 **ARES\_RR\_SIG\_KEY\_TAG** - SIG Record. Key Tag. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_SIG\_SIGNERS\_NAME** - SIG Record. Signer's Name. Datatype: *ARES\_DATATYPE\_NAME*\
 **ARES\_RR\_SIG\_SIGNATURE** - SIG Record. Signature. Datatype: *ARES\_DATATYPE\_BIN*\
 **ARES\_RR\_AAAA\_ADDR** - AAAA Record. Address. Datatype: *ARES\_DATATYPE\_INADDR6*\
 **ARES\_RR\_SRV\_PRIORITY** - SRV Record. Priority. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_SRV\_WEIGHT** - SRV Record. Weight. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_SRV\_PORT** - SRV Record. Port. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_SRV\_TARGET** - SRV Record. Target domain. Datatype: *ARES\_DATATYPE\_NAME*\
 **ARES\_RR\_NAPTR\_ORDER** - NAPTR Record. Order. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_NAPTR\_PREFERENCE** - NAPTR Record. Preference. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_NAPTR\_FLAGS** - NAPTR Record. Flags. Datatype: *ARES\_DATATYPE\_STR*\
 **ARES\_RR\_NAPTR\_SERVICES** - NAPTR Record. Services. Datatype: *ARES\_DATATYPE\_STR*\
 **ARES\_RR\_NAPTR\_REGEXP** - NAPTR Record. Regexp. Datatype: *ARES\_DATATYPE\_STR*\
 **ARES\_RR\_NAPTR\_REPLACEMENT** - NAPTR Record. Replacement. Datatype: *ARES\_DATATYPE\_NAME*\
 **ARES\_RR\_OPT\_UDP\_SIZE** - OPT Record. UDP Size. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_OPT\_VERSION** - OPT Record. Version. Datatype: *ARES\_DATATYPE\_U8*\
 **ARES\_RR\_OPT\_FLAGS** - OPT Record. Flags. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_OPT\_OPTIONS** - OPT Record. Options. See *ares\_opt\_param\_t*. Datatype: *ARES\_DATATYPE\_OPT*\
 **ARES\_RR\_TLSA\_CERT\_USAGE** - TLSA Record. Certificate Usage. See *ares\_tlsa\_usage\_t*. Datatype: *ARES\_DATATYPE\_U8*\
 **ARES\_RR\_TLSA\_SELECTOR** - TLSA Record. Selector. See *ares\_tlsa\_selector\_t*. Datatype: *ARES\_DATATYPE\_U8*\
 **ARES\_RR\_TLSA\_MATCH** - TLSA Record. Matching Type. See *ares\_tlsa\_match\_t*. Datatype: *ARES\_DATATYPE\_U8*\
 **ARES\_RR\_TLSA\_DATA** - TLSA Record. Certificate Association Data. Datatype: *ARES\_DATATYPE\_BIN*\
 **ARES\_RR\_SVCB\_PRIORITY** - SVCB Record. SvcPriority. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_SVCB\_TARGET** - SVCB Record. TargetName. Datatype: *ARES\_DATATYPE\_NAME*\
 **ARES\_RR\_SVCB\_PARAMS** - SVCB Record. SvcParams. See *ares\_svcb\_param\_t*. Datatype: *ARES\_DATATYPE\_OPT*\
 **ARES\_RR\_HTTPS\_PRIORITY** - HTTPS Record. SvcPriority. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_HTTPS\_TARGET** - HTTPS Record. TargetName. Datatype: *ARES\_DATATYPE\_NAME*\
 **ARES\_RR\_HTTPS\_PARAMS** - HTTPS Record. SvcParams. See *ares\_svcb\_param\_t*. Datatype: *ARES\_DATATYPE\_OPT*\
 **ARES\_RR\_URI\_PRIORITY** - URI Record. Priority. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_URI\_WEIGHT** - URI Record. Weight. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_URI\_TARGET** - URI Record. Target domain. Datatype: *ARES\_DATATYPE\_NAME*\
 **ARES\_RR\_CAA\_CRITICAL** - CAA Record. Critical flag. Datatype: *ARES\_DATATYPE\_U8*\
 **ARES\_RR\_CAA\_TAG** - CAA Record. Tag/Property. Datatype: *ARES\_DATATYPE\_STR*\
 **ARES\_RR\_CAA\_VALUE** - CAA Record. Value. Datatype: *ARES\_DATATYPE\_BINP*\
 **ARES\_RR\_RAW\_RR\_TYPE** - RAW Record. RR Type. Datatype: *ARES\_DATATYPE\_U16*\
 **ARES\_RR\_RAW\_RR\_DATA** - RAW Record. RR Data. Datatype: *ARES\_DATATYPE\_BIN*\

**ares\_tlsa\_usage\_t -** TLSA Record *ARES\_RR\_TLSA\_CERT\_USAGE* known values

**ARES\_TLSA\_USAGE\_CA** - Certificate Usage 0. CA Constraint\
 **ARES\_TLSA\_USAGE\_SERVICE** - Certificate Usage 1. Service Certificate Constraint\
 **ARES\_TLSA\_USAGE\_TRUSTANCHOR** - Certificate Usage 2. Trust Anchor Assertion\
 **ARES\_TLSA\_USAGE\_DOMAIN** - Certificate Usage 3. Domain-issued certificate\

**ares\_tlsa\_selector\_t -** TLSA Record *ARES\_RR\_TLSA\_SELECTOR* known values:

**ARES\_TLSA\_SELECTOR\_FULL** - Full Certificate\
 **ARES\_TLSA\_SELECTOR\_SUBJPUBKEYINFO** - DER-encoded SubjectPublicKeyInfo\

**ares\_tlsa\_match\_t -** TLSA Record *ARES\_RR\_TLSA\_MATCH* known values:

**ARES\_TLSA\_MATCH\_EXACT** - Exact match\
 **ARES\_TLSA\_MATCH\_SHA256** - Sha256 match\
 **ARES\_TLSA\_MATCH\_SHA512** - Sha512 match\

## DESCRIPTION

The *[ares\_dns\_record\_rr\_cnt(3)](/ares_dns_record_rr_cnt/3.md)* function returns the number of resource records in the DNS record provided by the *dnsrec* parameter for the section provided in the *sect* parameter.

The *[ares\_dns\_record\_rr\_add(3)](/ares_dns_record_rr_add/3.md)* function adds a new resource record entry the the DNS record provided by the *dnsrec* parameter.  The resulting resource record is stored into the variable pointed to by *rr\_out.* The DNS section the resource record belongs to is specified by the *sect* parameter.  The domain name associated with the resource record is specified by the *name* parameter, which can not be NULL but may be an empty string, or ".".  The resource record type is specified in the *type* parameter, along with the DNS record class in the *rclass* parameter, and the Time To Live (TTL) in the *ttl* parameter.

The *[ares\_dns\_record\_rr\_get(3)](/ares_dns_record_rr_get/3.md)* and *[ares\_dns\_record\_rr\_get\_const(3)](/ares_dns_record_rr_get_const/3.md)* functions are used to retrieve the resource record pointer from the DNS record provided in the *dnsrec* parameter, for the resource record section provided in the *sect* parameter, for the specified index in the *idx* parameter.  The index must be less than *[ares\_dns\_record\_rr\_cnt(3)](/ares_dns_record_rr_cnt/3.md)*.  The former returns a writable pointer to the resource record, while the latter returns a read-only pointer to the resource record.

The *[ares\_dns\_record\_rr\_del(3)](/ares_dns_record_rr_del/3.md)* is used to delete a resource record from the DNS record specified in the *dnsrec* parameter.  Its primary use is to remove a *ARES\_REC\_TYPE\_OPT* record when needing to retry a query without EDNS support.  The DNS RR section is specified via the *sect* parameter, and the index to remove is specified in the *idx* parameter.  The index must be less than *[ares\_dns\_record\_rr\_cnt(3)](/ares_dns_record_rr_cnt/3.md)*.

The *[ares\_dns\_rr\_get\_name(3)](/ares_dns_rr_get_name/3.md)* function is used to retrieve the resource record domain name from the Resource Record pointer provided in the *rr* parameter.

The *[ares\_dns\_rr\_get\_type(3)](/ares_dns_rr_get_type/3.md)* function is used to retrieve the resource record type from the Resource Record pointer provided in the *rr* parameter.

The *[ares\_dns\_rr\_get\_class(3)](/ares_dns_rr_get_class/3.md)* function is used to retrieve the resource record class from the Resource Record pointer provided in the *rr* parameter.

The *[ares\_dns\_rr\_get\_ttl(3)](/ares_dns_rr_get_ttl/3.md)* function is used to retrieve the resource record class Time to Live (TTL) from the Resource Record pointer provided in the *rr* parameter.

The *[ares\_dns\_rr\_set\_addr(3)](/ares_dns_rr_set_addr/3.md)* function is used to set an IPv4 address for the associated resource record key/parameter when the datatype is *ARES\_DATATYPE\_INADDR*. The resource record to be modified is provided in the *dns\_rr* parameter, the key/parameter is provided in the *key* parameter, and the value is provided in the *addr* parameter.

The *[ares\_dns\_rr\_set\_addr6(3)](/ares_dns_rr_set_addr6/3.md)* function is used to set an IPv6 address for the associated resource record key/parameter when the datatype is *ARES\_DATATYPE\_INADDR6*. The resource record to be modified is provided in the *dns\_rr* parameter, the key/parameter is provided in the *key* parameter, and the value is provided in the *addr* parameter.

The *[ares\_dns\_rr\_set\_str(3)](/ares_dns_rr_set_str/3.md)* function is used to set a string for the associated resource record key/parameter when the datatype is *ARES\_DATATYPE\_STR* or *ARES\_DATATYPE\_NAME*.  Most strings are limited to 255 bytes, however some records, such as a TXT record may allow longer as they are output as multiple strings. The resource record to be modified is provided in the *dns\_rr* parameter, the key/parameter is provided in the *key* parameter, and the value is provided in the *val* parameter.

The *[ares\_dns\_rr\_set\_u8(3)](/ares_dns_rr_set_u8/3.md)* function is used to set an 8bit unsigned value for the associated resource record key/parameter when the datatype is *ARES\_DATATYPE\_U8*. The resource record to be modified is provided in the *dns\_rr* parameter, the key/parameter is provided in the *key* parameter, and the value is provided in the *val* parameter.

The *[ares\_dns\_rr\_set\_u16(3)](/ares_dns_rr_set_u16/3.md)* function is used to set an 16bit unsigned value for the associated resource record key/parameter when the datatype is *ARES\_DATATYPE\_U16*. The resource record to be modified is provided in the *dns\_rr* parameter, the key/parameter is provided in the *key* parameter, and the value is provided in the *val* parameter.

The *[ares\_dns\_rr\_set\_u32(3)](/ares_dns_rr_set_u32/3.md)* function is used to set an 32bit unsigned value for the associated resource record key/parameter when the datatype is *ARES\_DATATYPE\_U32*. The resource record to be modified is provided in the *dns\_rr* parameter, the key/parameter is provided in the *key* parameter, and the value is provided in the *val* parameter.

The *[ares\_dns\_rr\_set\_bin(3)](/ares_dns_rr_set_bin/3.md)* function is used to set a binary value for the associated resource record key/parameter when the datatype is *ARES\_DATATYPE\_BIN* or *ARES\_DATATYPE\_BINP*. The resource record to be modified is provided in the *dns\_rr* parameter, the key/parameter is provided in the *key* parameter, and the value is provided in the *val* parameter. And the associated value length is provided in the *len* parameter.

The *[ares\_dns\_rr\_add\_abin(3)](/ares_dns_rr_add_abin/3.md)* function is used to append a binary value in the array for the associated resource record key/parameter when the datatype is *ARES\_DATATYPE\_ABINP*. The resource record to be modified is provided in the *dns\_rr* parameter, the key/parameter is provided in the *key* parameter, and the value is provided in the *val* parameter. And the associated value length is provided in the *len* parameter.

The *[ares\_dns\_rr\_del\_abin(3)](/ares_dns_rr_del_abin/3.md)* function is used to delete a binary value in the array for the associated resource record key/parameter when the datatype is *ARES\_DATATYPE\_ABINP*. The resource record to be modified is provided in the *dns\_rr* parameter, the key/parameter is provided in the *key* parameter, and the index to remove is provided in the *idx* parameter.

The *[ares\_dns\_rr\_set\_opt(3)](/ares_dns_rr_set_opt/3.md)* function is used to set option/parameter keys and values for the resource record when the datatype is *ARES\_DATATYPE\_OPT*.  The resource record to be modified is provided in the *dns\_rr* parameter.  They key/parameter is provided in the *key* parameter.  The option/parameter value specific to the resource record is provided in the *opt* parameter, and this is left to the user to determine the appropriate value to use.  Some known values may be provided by *ares\_svcb\_param\_t* and *ares\_opt\_param\_t* enumerations.  The value for the option is always provided in binary form in *val* with length provided in *val\_len.*

The *[ares\_dns\_rr\_del\_opt\_byid(3)](/ares_dns_rr_del_opt_byid/3.md)* function is used to delete option/parameter keys and values for the resource record when the datatype is *ARES\_DATATYPE\_OPT*.  The resource record to be modified is provided in the *dns\_rr* parameter.  They key/parameter is provided in the *key* parameter.  The option/parameter value specific to the resource record is provided in the *opt* parameter.  This function returns *ARES\_SUCCESS* if the record is successfully removed, or *ARES\_ENOTFOUND* if the record could not be found.

The *[ares\_dns\_rr\_get\_addr(3)](/ares_dns_rr_get_addr/3.md)* function is used to retrieve the IPv4 address from the resource record when the datatype is *ARES\_DATATYPE\_INADDR*.  The resource record is provided in the *dns\_rr* parameter and the key/parameter to retrieve is provided in the *key* parameter.

The *[ares\_dns\_rr\_get\_addr6(3)](/ares_dns_rr_get_addr6/3.md)* function is used to retrieve the IPv6 address from the resource record when the datatype is *ARES\_DATATYPE\_INADDR6*.  The resource record is provided in the *dns\_rr* parameter and the key/parameter to retrieve is provided in the *key* parameter.

The *[ares\_dns\_rr\_get\_str(3)](/ares_dns_rr_get_str/3.md)* function is used to retrieve a string from the resource record when the datatype is *ARES\_DATATYPE\_STR* or *ARES\_DATATYPE\_NAME*.  The resource record is provided in the *dns\_rr* parameter and the key/parameter to retrieve is provided in the *key* parameter.

The *[ares\_dns\_rr\_get\_u8(3)](/ares_dns_rr_get_u8/3.md)* function is used to retrieve an 8bit integer from the resource record when the datatype is *ARES\_DATATYPE\_U8*. The resource record is provided in the *dns\_rr* parameter and the key/parameter to retrieve is provided in the *key* parameter.

The *[ares\_dns\_rr\_get\_u16(3)](/ares_dns_rr_get_u16/3.md)* function is used to retrieve a 16bit integer from the resource record when the datatype is *ARES\_DATATYPE\_U16*. The resource record is provided in the *dns\_rr* parameter and the key/parameter to retrieve is provided in the *key* parameter.

The *[ares\_dns\_rr\_get\_u32(3)](/ares_dns_rr_get_u32/3.md)* function is used to retrieve a 32bit integer from the resource record when the datatype is *ARES\_DATATYPE\_U32*. The resource record is provided in the *dns\_rr* parameter and the key/parameter to retrieve is provided in the *key* parameter.

The *[ares\_dns\_rr\_get\_bin(3)](/ares_dns_rr_get_bin/3.md)* function is used to retrieve binary data from the resource record when the datatype is *ARES\_DATATYPE\_BIN* or *ARES\_DATATYPE\_BINP*. The resource record is provided in the *dns\_rr* parameter and the key/parameter to retrieve is provided in the *key* parameter, and length is stored into the variable pointed to by *len.*

The *[ares\_dns\_rr\_get\_abin\_cnt(3)](/ares_dns_rr_get_abin_cnt/3.md)* function is used to retrieve the count of the array of stored binary values from the resource record when the datatype is *ARES\_DATATYPE\_ABINP*. The resource record is provided in the *dns\_rr* parameter and the key/parameter to retrieve is provided in the *key* parameter.

The *[ares\_dns\_rr\_get\_abin(3)](/ares_dns_rr_get_abin/3.md)* function is used to retrieve binary data from the resource record array when the datatype is *ARES\_DATATYPE\_ABINP*. The resource record is provided in the *dns\_rr* parameter and the key/parameter to retrieve is provided in the *key* parameter, and the index to retrieve from the array is provided by the *idx* parameter, and length is stored into the variable pointed to by *len.*

The *[ares\_dns\_rr\_get\_opt\_cnt(3)](/ares_dns_rr_get_opt_cnt/3.md)* function is used to retrieve the count of options/parameters associated with the resource record when the datatype is *ARES\_DATATYPE\_OPT*. The resource record is provided in the *dns\_rr* parameter and the key/parameter to retrieve is provided in the *key.*

The *[ares\_dns\_rr\_get\_opt(3)](/ares_dns_rr_get_opt/3.md)* function is used to retrieve binary option data from the resource record when the datatype is *ARES\_DATATYPE\_OPT* for the specified index. The resource record is provided in the *dns\_rr* parameter and the key/parameter to retrieve is provided in the *key* parameter, the index to retrieve the option data from is provided in the *idx* parameter.  The value is stored into the variable pointed to by *val* and length is stored into the variable pointed to by *val\_len.*

The *[ares\_dns\_rr\_get\_opt\_byid(3)](/ares_dns_rr_get_opt_byid/3.md)* function is used to retrieve binary option data from the resource record when the datatype is *ARES\_DATATYPE\_OPT* for the specified option identifier, if it exists. The resource record is provided in the *dns\_rr* parameter and the key/parameter to retrieve is provided in the *key* parameter, the identifier to retrieve the option data from is provided in the *opt* parameter.  The value is stored into the variable pointed to by *val* and length is stored into the variable pointed to by *val\_len.*

## RETURN VALUES

*[ares\_dns\_record\_rr\_cnt(3)](/ares_dns_record_rr_cnt/3.md)* and *[ares\_dns\_rr\_get\_opt\_cnt(3)](/ares_dns_rr_get_opt_cnt/3.md)* return the respective counts.

*[ares\_dns\_record\_rr\_add(3)](/ares_dns_record_rr_add/3.md)*, *[ares\_dns\_record\_rr\_del(3)](/ares_dns_record_rr_del/3.md)*, *[ares\_dns\_rr\_set\_addr(3)](/ares_dns_rr_set_addr/3.md)*, *[ares\_dns\_rr\_set\_addr6(3)](/ares_dns_rr_set_addr6/3.md)*, *[ares\_dns\_rr\_set\_str(3)](/ares_dns_rr_set_str/3.md)*, *[ares\_dns\_rr\_set\_u8(3)](/ares_dns_rr_set_u8/3.md)*, *[ares\_dns\_rr\_set\_u16(3)](/ares_dns_rr_set_u16/3.md)*, *[ares\_dns\_rr\_set\_u32(3)](/ares_dns_rr_set_u32/3.md)*, *[ares\_dns\_rr\_set\_bin(3)](/ares_dns_rr_set_bin/3.md)*, *[ares\_dns\_rr\_add\_abin(3)](/ares_dns_rr_add_abin/3.md)*, *[ares\_dns\_rr\_del\_abin(3)](/ares_dns_rr_del_abin/3.md)*, and *[ares\_dns\_rr\_set\_opt(3)](/ares_dns_rr_set_opt/3.md)* all return an *ares\_status\_t* error code. **ARES\_SUCCESS** is returned on success, **ARES\_ENOMEM** is returned on out of memory, **ARES\_EFORMERR** is returned on misuse.

*[ares\_dns\_rr\_get\_name(3)](/ares_dns_rr_get_name/3.md)*, *[ares\_dns\_rr\_get\_type(3)](/ares_dns_rr_get_type/3.md)*, *[ares\_dns\_rr\_get\_class(3)](/ares_dns_rr_get_class/3.md)*, *[ares\_dns\_rr\_get\_ttl(3)](/ares_dns_rr_get_ttl/3.md)*, *[ares\_dns\_rr\_get\_addr(3)](/ares_dns_rr_get_addr/3.md)*, *[ares\_dns\_rr\_get\_addr6(3)](/ares_dns_rr_get_addr6/3.md)*, *[ares\_dns\_rr\_get\_str(3)](/ares_dns_rr_get_str/3.md)*, *[ares\_dns\_rr\_get\_u8(3)](/ares_dns_rr_get_u8/3.md)*, *[ares\_dns\_rr\_get\_u16(3)](/ares_dns_rr_get_u16/3.md)*, *[ares\_dns\_rr\_get\_u32(3)](/ares_dns_rr_get_u32/3.md)*, *[ares\_dns\_rr\_get\_bin(3)](/ares_dns_rr_get_bin/3.md)*, *[ares\_dns\_rr\_get\_abin\_cnt(3)](/ares_dns_rr_get_abin_cnt/3.md)*, *[ares\_dns\_rr\_get\_abin(3)](/ares_dns_rr_get_abin/3.md)*, *[ares\_dns\_rr\_get\_opt(3)](/ares_dns_rr_get_opt/3.md)* all return their prescribed datatype values and in general can't fail except for misuse cases, in which a 0 (or NULL) may be returned, however 0 can also be a valid return value for most of these functions.

*[ares\_dns\_record\_rr\_get(3)](/ares_dns_record_rr_get/3.md)* and *[ares\_dns\_record\_rr\_get\_const(3)](/ares_dns_record_rr_get_const/3.md)* will return the requested resource record pointer or NULL on failure (misuse).

*[ares\_dns\_rr\_get\_opt\_byid(3)](/ares_dns_rr_get_opt_byid/3.md)* will return ARES\_TRUE if the option was found, otherwise ARES\_FALSE if not found (or misuse).

## AVAILABILITY

These functions were first introduced in c-ares version 1.22.0.

## SEE ALSO

[**ares\_dns\_mapping**(3)](/ares_dns_mapping/3.md), [**ares\_dns\_record**(3)](/ares_dns_record/3.md), [**ares\_free\_string**(3)](/ares_free_string/3.md)
