summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/getrrsetbyname.3
diff options
context:
space:
mode:
authorjakob <>2001-08-06 14:40:47 +0000
committerjakob <>2001-08-06 14:40:47 +0000
commite11d1495c580da2f8d0b3bc4e7e1461b7dbb40cd (patch)
treea1d2a87b40319fe613b8e157eaf5928f30334d8e /src/lib/libc/net/getrrsetbyname.3
parent1161496b1fe96bd200abb99eecc93d8594aa8306 (diff)
downloadopenbsd-e11d1495c580da2f8d0b3bc4e7e1461b7dbb40cd.tar.gz
openbsd-e11d1495c580da2f8d0b3bc4e7e1461b7dbb40cd.tar.bz2
openbsd-e11d1495c580da2f8d0b3bc4e7e1461b7dbb40cd.zip
add getrrsetbyname(3) - API to retrieve arbitrary DNS records
Diffstat (limited to 'src/lib/libc/net/getrrsetbyname.3')
-rw-r--r--src/lib/libc/net/getrrsetbyname.3149
1 files changed, 149 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..3b8c06999e
--- /dev/null
+++ b/src/lib/libc/net/getrrsetbyname.3
@@ -0,0 +1,149 @@
1.\" $Id: getrrsetbyname.3,v 1.1 2001/08/06 14:40:47 jakob 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 Oct 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. If the
71.Dv RRSET_VALIDATED
72bit is set, the data has been DNSSEC
73validated and the signatures verified.
74.Pp
75The following structures are used:
76.Bd -literal -offset
77struct rdatainfo {
78 unsigned int rdi_length; /* length of data */
79 unsigned char *rdi_data; /* record data */
80};
81
82struct rrsetinfo {
83 unsigned int rri_flags; /* RRSET_VALIDATED ... */
84 unsigned int rri_rdclass; /* class number */
85 unsigned int rri_rdtype; /* RR type number */
86 unsigned int rri_ttl; /* time to live */
87 unsigned int rri_nrdatas; /* size of rdatas array */
88 unsigned int rri_nsigs; /* size of sigs array */
89 char *rri_name; /* canonical name */
90 struct rdatainfo *rri_rdatas; /* individual records */
91 struct rdatainfo *rri_sigs; /* individual signatures */
92};
93.Ed
94.Pp
95All of the information returned by
96.Fn getrrsetbyname
97is dynamically allocated: the
98.Li rrsetinfo
99and
100.Li rdatainfo
101structures,
102and the canonical host name strings pointed to by the
103.Li rrsetinfostructure.
104Memory allocated for the dynamically allocated structures created by
105a successful call to
106.Fn getrrsetbyname
107is released by
108.Fn freerrset .
109.Li rrset
110is a pointer to a
111.Li struct rrset
112created by a call to
113.Fn getrrsetbyname .
114.Pp
115If the EDNS0 option is activated in
116.Xr resolv.conf 3 ,
117.Fn getrrsetbyname
118will request DNSSEC authentication using the EDNS0 DNSSEC OK (DO) bit.
119.Sh "RETURN VALUES"
120.Fn getrrsetbyname
121returns zero on success, and one of the following error
122codes if an error occurred:
123.Pp
124.Bl -tag -width ERRSET_NOMEMORY -compact
125.It Dv ERRSET_NONAME
126the name does not exist
127.It Dv ERRSET_NODATA
128the name exists, but does not have data of the desired type
129.It Dv ERRSET_NOMEMORY
130memory could not be allocated
131.It Dv ERRSET_INVAL
132a parameter is invalid
133.It Dv ERRSET_FAIL
134other failure
135.El
136.Sh SEE ALSO
137.Xr resolver 3 ,
138.Xr resolv.conf 5 ,
139.Xr named 8
140.Sh HISTORY
141.Nm
142first appeared in
143.Ox 3.0 .
144.Sh BUGS
145The data in
146.Li *rdi_data
147should be returned in uncompressed wire format.
148Currently, the data is in compressed format and the caller can't
149uncompress since it doesn't have the full message.