---
name: "lwres_getrrsetbyname"
section: "3"
platform: "macos"
package: "bind9"
version: "65"
release: "macOS 26.5"
platforms: ["linux", "macos"]
url: "https://new.carta.tech/lwres_getrrsetbyname"
---

# lwres\_getrrsetbyname(3)

retrieve DNS records

## NAME

lwres\_getrrsetbyname, lwres\_freerrset - retrieve DNS records

## SYNOPSIS

```
#include <lwres/netdb.h>
```

**int lwres\_getrrsetbyname(const char \****hostname***, unsigned int** *rdclass***, unsigned int** *rdtype***, unsigned int** *flags***, struct rrsetinfo \*\****res***);**

**void lwres\_freerrset(struct rrsetinfo \****rrset***);**

The following structures are used:

```
struct  rdatainfo {
        unsigned int            rdi_length;     /* length of data */
        unsigned char           *rdi_data;      /* record data */
};
```

```
struct  rrsetinfo {
        unsigned int            rri_flags;      /* RRSET_VALIDATED... */
        unsigned int            rri_rdclass;    /* class number */
        unsigned int            rri_rdtype;     /* RR type number */
        unsigned int            rri_ttl;        /* time to live */
        unsigned int            rri_nrdatas;    /* size of rdatas array */
        unsigned int            rri_nsigs;      /* size of sigs array */
        char                    *rri_name;      /* canonical name */
        struct rdatainfo        *rri_rdatas;    /* individual records */
        struct rdatainfo        *rri_sigs;      /* individual signatures */
};
```

## DESCRIPTION

**lwres\_getrrsetbyname()** gets a set of resource records associated with a *hostname*, *class*, and *type*. *hostname* is a pointer a to null-terminated string. The *flags* field is currently unused and must be zero.

After a successful call to **lwres\_getrrsetbyname()**, *\*res* is a pointer to an **rrsetinfo** structure, containing a list of one or more **rdatainfo** structures containing resource records and potentially another list of **rdatainfo** structures containing SIG resource records associated with those records. The members **rri\_rdclass** and **rri\_rdtype** are copied from the parameters. **rri\_ttl** and **rri\_name** are properties of the obtained rrset. The resource records contained in **rri\_rdatas** and **rri\_sigs** are in uncompressed DNS wire format. Properties of the rdataset are represented in the **rri\_flags** bitfield. If the RRSET\_VALIDATED bit is set, the data has been DNSSEC validated and the signatures verified.

All of the information returned by **lwres\_getrrsetbyname()** is dynamically allocated: the **rrsetinfo** and **rdatainfo** structures, and the canonical host name strings pointed to by the **rrsetinfo**structure. Memory allocated for the dynamically allocated structures created by a successful call to **lwres\_getrrsetbyname()** is released by **lwres\_freerrset()**. *rrset* is a pointer to a **struct rrset** created by a call to **lwres\_getrrsetbyname()**.

## RETURN VALUES

**lwres\_getrrsetbyname()** returns zero on success, and one of the following error codes if an error occurred:

**ERRSET\_NONAME**

the name does not exist

**ERRSET\_NODATA**

the name exists, but does not have data of the desired type

**ERRSET\_NOMEMORY**

memory could not be allocated

**ERRSET\_INVAL**

a parameter is invalid

**ERRSET\_FAIL**

other failure

## SEE ALSO

[**lwres**(3)](/lwres/3.md).

## AUTHOR

**Internet Systems Consortium, Inc.**

## COPYRIGHT

Copyright © 2004, 2005, 2007, 2014-2016 Internet Systems Consortium, Inc. ("ISC")\
 Copyright © 2000, 2001 Internet Software Consortium.\
