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

# lwres\_packet(3)

lightweight resolver packet handling functions

## NAME

lwres\_lwpacket\_renderheader, lwres\_lwpacket\_parseheader - lightweight resolver packet handling functions

## SYNOPSIS

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

**lwres\_result\_t lwres\_lwpacket\_renderheader(lwres\_buffer\_t \****b***, lwres\_lwpacket\_t \****pkt***);**

**lwres\_result\_t lwres\_lwpacket\_parseheader(lwres\_buffer\_t \****b***, lwres\_lwpacket\_t \****pkt***);**

## DESCRIPTION

These functions rely on a **struct lwres\_lwpacket** which is defined in lwres/lwpacket.h.

```
typedef struct lwres_lwpacket lwres_lwpacket_t;
```

```
struct lwres_lwpacket {
        lwres_uint32_t          length;
        lwres_uint16_t          version;
        lwres_uint16_t          pktflags;
        lwres_uint32_t          serial;
        lwres_uint32_t          opcode;
        lwres_uint32_t          result;
        lwres_uint32_t          recvlength;
        lwres_uint16_t          authtype;
        lwres_uint16_t          authlength;
};
```

The elements of this structure are:

**length**

the overall packet length, including the entire packet header. This field is filled in by the lwres\_gabn\_\*() and lwres\_gnba\_\*() calls.

**version**

the header format. There is currently only one format, **LWRES\_LWPACKETVERSION\_0**. This field is filled in by the lwres\_gabn\_\*() and lwres\_gnba\_\*() calls.

**pktflags**

library-defined flags for this packet: for instance whether the packet is a request or a reply. Flag values can be set, but not defined by the caller. This field is filled in by the application wit the exception of the LWRES\_LWPACKETFLAG\_RESPONSE bit, which is set by the library in the lwres\_gabn\_\*() and lwres\_gnba\_\*() calls.

**serial**

is set by the requestor and is returned in all replies. If two or more packets from the same source have the same serial number and are from the same source, they are assumed to be duplicates and the latter ones may be dropped. This field must be set by the application.

**opcode**

indicates the operation. Opcodes between 0x00000000 and 0x03ffffff are reserved for use by the lightweight resolver library. Opcodes between 0x04000000 and 0xffffffff are application defined. This field is filled in by the lwres\_gabn\_\*() and lwres\_gnba\_\*() calls.

**result**

is only valid for replies. Results between 0x04000000 and 0xffffffff are application defined. Results between 0x00000000 and 0x03ffffff are reserved for library use. This field is filled in by the lwres\_gabn\_\*() and lwres\_gnba\_\*() calls.

**recvlength**

is the maximum buffer size that the receiver can handle on requests and the size of the buffer needed to satisfy a request when the buffer is too large for replies. This field is supplied by the application.

**authtype**

defines the packet level authentication that is used. Authorisation types between 0x1000 and 0xffff are application defined and types between 0x0000 and 0x0fff are reserved for library use. Currently these are not used and must be zero.

**authlen**

gives the length of the authentication data. Since packet authentication is currently not used, this must be zero.

The following opcodes are currently defined:

**NOOP**

Success is always returned and the packet contents are echoed. The lwres\_noop\_\*() functions should be used for this type.

**GETADDRSBYNAME**

returns all known addresses for a given name. The lwres\_gabn\_\*() functions should be used for this type.

**GETNAMEBYADDR**

return the hostname for the given address. The lwres\_gnba\_\*() functions should be used for this type.

**lwres\_lwpacket\_renderheader()** transfers the contents of lightweight resolver packet structure **lwres\_lwpacket\_t***\*pkt* in network byte order to the lightweight resolver buffer, *\*b*.

**lwres\_lwpacket\_parseheader()** performs the converse operation. It transfers data in network byte order from buffer *\*b* to resolver packet *\*pkt*. The contents of the buffer *b* should correspond to a **lwres\_lwpacket\_t**.

## RETURN VALUES

Successful calls to **lwres\_lwpacket\_renderheader()** and **lwres\_lwpacket\_parseheader()** return **LWRES\_R\_SUCCESS**. If there is insufficient space to copy data between the buffer *\*b* and lightweight resolver packet *\*pkt* both functions return **LWRES\_R\_UNEXPECTEDEND**.

## AUTHOR

**Internet Systems Consortium, Inc.**

## COPYRIGHT

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