summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/getrrsetbyname.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/net/getrrsetbyname.3')
-rw-r--r--src/lib/libc/net/getrrsetbyname.3165
1 files changed, 165 insertions, 0 deletions
diff --git a/src/lib/libc/net/getrrsetbyname.3 b/src/lib/libc/net/getrrsetbyname.3
new file mode 100644
index 0000000000..a786ff8747
--- /dev/null
+++ b/src/lib/libc/net/getrrsetbyname.3
@@ -0,0 +1,165 @@
1.\" $OpenBSD: getrrsetbyname.3,v 1.11 2003/05/30 21:37:59 jmc Exp $
2.\"
3.\" Copyright (C) 2000, 2001 Internet Software Consortium.
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
10.\" DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
11.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
12.\" INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
13.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
14.\" FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15.\" NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
16.\" WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd October 18, 2000
19.Dt GETRRSETBYNAME 3
20.Os
21.Sh NAME
22.Nm getrrsetbyname
23.Nd retrieve DNS records
24.Sh SYNOPSIS
25.Fd #include <netdb.h>
26.Ft int
27.Fn getrrsetbyname "const char *hostname" "unsigned int rdclass" \
28"unsigned int rdtype" "unsigned int flags" "struct rrsetinfo **res"
29.Ft int
30.Fn freerrset "struct rrsetinfo **rrset"
31.Sh DESCRIPTION
32.Fn getrrsetbyname
33gets a set of resource records associated with a
34.Fa hostname ,
35.Fa class
36and
37.Fa type .
38.Fa hostname
39is a pointer a to null-terminated string.
40The
41.Fa flags
42field is currently unused and must be zero.
43.Pp
44After a successful call to
45.Fn getrrsetbyname ,
46.Fa *res
47is a pointer to an
48.Li rrsetinfo
49structure, containing a list of one or more
50.Li rdatainfo
51structures containing resource records and potentially another list of
52.Li rdatainfo
53structures containing SIG resource records associated with those records.
54The members
55.Li rri_rdclass
56and
57.Li rri_rdtype
58are copied from the parameters.
59.Li rri_ttl
60and
61.Li rri_name
62are properties of the obtained rrset.
63The resource records contained in
64.Li rri_rdatas
65and
66.Li rri_sigs
67are in uncompressed DNS wire format.
68Properties of the rdataset are represented in the
69.Li rri_flags
70bitfield.
71If the
72.Dv RRSET_VALIDATED
73bit is set, the data has been DNSSEC
74validated and the signatures verified.
75.Pp
76The following structures are used:
77.Bd -literal -offset
78struct rdatainfo {
79 unsigned int rdi_length; /* length of data */
80 unsigned char *rdi_data; /* record data */
81};
82
83struct rrsetinfo {
84 unsigned int rri_flags; /* RRSET_VALIDATED ... */
85 unsigned int rri_rdclass; /* class number */
86 unsigned int rri_rdtype; /* RR type number */
87 unsigned int rri_ttl; /* time to live */
88 unsigned int rri_nrdatas; /* size of rdatas array */
89 unsigned int rri_nsigs; /* size of sigs array */
90 char *rri_name; /* canonical name */
91 struct rdatainfo *rri_rdatas; /* individual records */
92 struct rdatainfo *rri_sigs; /* individual signatures */
93};
94.Ed
95.Pp
96All of the information returned by
97.Fn getrrsetbyname
98is dynamically allocated: the
99.Li rrsetinfo
100and
101.Li rdatainfo
102structures,
103and the canonical host name strings pointed to by the
104.Li rrsetinfo
105structure.
106Memory allocated for the dynamically allocated structures created by
107a successful call to
108.Fn getrrsetbyname
109is released by
110.Fn freerrset .
111.Li rrset
112is a pointer to a
113.Li struct rrset
114created by a call to
115.Fn getrrsetbyname .
116.Pp
117If the EDNS0 option is activated in
118.Xr resolv.conf 5 ,
119.Fn getrrsetbyname
120will request DNSSEC authentication using the EDNS0 DNSSEC OK (DO) bit.
121.Sh RETURN VALUES
122.Fn getrrsetbyname
123returns zero on success, and one of the following error
124codes if an error occurred:
125.Pp
126.Bl -tag -width ERRSET_NOMEMORY -compact
127.It Dv ERRSET_NONAME
128the name does not exist
129.It Dv ERRSET_NODATA
130the name exists, but does not have data of the desired type
131.It Dv ERRSET_NOMEMORY
132memory could not be allocated
133.It Dv ERRSET_INVAL
134a parameter is invalid
135.It Dv ERRSET_FAIL
136other failure
137.El
138.Sh SEE ALSO
139.Xr resolver 3 ,
140.Xr resolv.conf 5 ,
141.Xr named 8
142.Sh HISTORY
143.Fn getrrsetbyname
144first appeared in
145.Ox 3.0 .
146The API first appeared in ISC BIND version 9.
147.Sh AUTHORS
148.An Jakob Schlyter Aq jakob@openbsd.org
149.Sh CAVEATS
150The
151.Dv RRSET_VALIDATED
152flag in
153.Li rri_flags
154is set if the AD (authenticated data) bit in the DNS answer is
155set.
156This flag
157.Em should not
158be trusted unless the transport between the nameserver and the resolver
159is secure (e.g. IPsec, trusted network, loopback communication).
160.Sh BUGS
161The data in
162.Li *rdi_data
163should be returned in uncompressed wire format.
164Currently, the data is in compressed format and the caller can't
165uncompress since it doesn't have the full message.