1LWRES_RESUTIL(3)                     BIND9                    LWRES_RESUTIL(3)
2
3
4

NAME

6       lwres_string_parse, lwres_addr_parse, lwres_getaddrsbyname,
7       lwres_getnamebyaddr - lightweight resolver utility functions
8

SYNOPSIS

10       #include <lwres/lwres.h>
11
12       lwres_result_t lwres_string_parse(lwres_buffer_t *b, char **c,
13                                         uint16_t *len);
14
15       lwres_result_t lwres_addr_parse(lwres_buffer_t *b, lwres_addr_t *addr);
16
17       lwres_result_t lwres_getaddrsbyname(lwres_context_t *ctx,
18                                           const char *name,
19                                           uint32_t addrtypes,
20                                           lwres_gabnresponse_t **structp);
21
22       lwres_result_t lwres_getnamebyaddr(lwres_context_t *ctx,
23                                          uint32_t addrtype, uint16_t addrlen,
24                                          const unsigned char *addr,
25                                          lwres_gnbaresponse_t **structp);
26

DESCRIPTION

28       lwres_string_parse() retrieves a DNS-encoded string starting the
29       current pointer of lightweight resolver buffer b: i.e.  b->current.
30       When the function returns, the address of the first byte of the encoded
31       string is returned via *c and the length of that string is given by
32       *len. The buffer's current pointer is advanced to point at the
33       character following the string length, the encoded string, and the
34       trailing NULL character.
35
36       lwres_addr_parse() extracts an address from the buffer b. The buffer's
37       current pointer b->current is presumed to point at an encoded address:
38       the address preceded by a 32-bit protocol family identifier and a
39       16-bit length field. The encoded address is copied to addr->address and
40       addr->length indicates the size in bytes of the address that was
41       copied.  b->current is advanced to point at the next byte of available
42       data in the buffer following the encoded address.
43
44       lwres_getaddrsbyname() and lwres_getnamebyaddr() use the
45       lwres_gnbaresponse_t structure defined below:
46
47           typedef struct {
48                   uint32_t          flags;
49                   uint16_t          naliases;
50                   uint16_t          naddrs;
51                   char                   *realname;
52                   char                  **aliases;
53                   uint16_t          realnamelen;
54                   uint16_t         *aliaslen;
55                   lwres_addrlist_t        addrs;
56                   void                   *base;
57                   size_t                  baselen;
58           } lwres_gabnresponse_t;
59
60       The contents of this structure are not manipulated directly but they
61       are controlled through the lwres_gabn(3) functions.
62
63       The lightweight resolver uses lwres_getaddrsbyname() to perform forward
64       lookups. Hostname name is looked up using the resolver context ctx for
65       memory allocation.  addrtypes is a bitmask indicating which type of
66       addresses are to be looked up. Current values for this bitmask are
67       LWRES_ADDRTYPE_V4 for IPv4 addresses and LWRES_ADDRTYPE_V6 for IPv6
68       addresses. Results of the lookup are returned in *structp.
69
70       lwres_getnamebyaddr() performs reverse lookups. Resolver context ctx is
71       used for memory allocation. The address type is indicated by addrtype:
72       LWRES_ADDRTYPE_V4 or LWRES_ADDRTYPE_V6. The address to be looked up is
73       given by addr and its length is addrlen bytes. The result of the
74       function call is made available through *structp.
75

RETURN VALUES

77       Successful calls to lwres_string_parse() and lwres_addr_parse() return
78       LWRES_R_SUCCESS.  Both functions return LWRES_R_FAILURE if the buffer
79       is corrupt or LWRES_R_UNEXPECTEDEND if the buffer has less space than
80       expected for the components of the encoded string or address.
81
82       lwres_getaddrsbyname() returns LWRES_R_SUCCESS on success and it
83       returns LWRES_R_NOTFOUND if the hostname name could not be found.
84
85       LWRES_R_SUCCESS is returned by a successful call to
86       lwres_getnamebyaddr().
87
88       Both lwres_getaddrsbyname() and lwres_getnamebyaddr() return
89       LWRES_R_NOMEMORY when memory allocation requests fail and
90       LWRES_R_UNEXPECTEDEND if the buffers used for sending queries and
91       receiving replies are too small.
92

SEE ALSO

94       lwres_buffer(3), lwres_gabn(3).
95

AUTHOR

97       Internet Systems Consortium, Inc.
98
100       Copyright © 2000, 2001, 2004, 2005, 2007, 2014-2016, 2018-2020 Internet
101       Systems Consortium, Inc. ("ISC")
102
103
104
105ISC                               2007-06-18                  LWRES_RESUTIL(3)
Impressum