diff options
author | eric <> | 2013-11-12 20:37:16 +0000 |
---|---|---|
committer | eric <> | 2013-11-12 20:37:16 +0000 |
commit | eb56a6b4b449d7d65f54812c03a2562929966616 (patch) | |
tree | 24970078f56a3204649b6aa7d8775779cafb68db /src/lib/libc/net/res_mkquery.c | |
parent | 8ef84bdff61bb5b6cd20dcdccc675cee0f3a17bc (diff) | |
download | openbsd-eb56a6b4b449d7d65f54812c03a2562929966616.tar.gz openbsd-eb56a6b4b449d7d65f54812c03a2562929966616.tar.bz2 openbsd-eb56a6b4b449d7d65f54812c03a2562929966616.zip |
remove dead files
ok deraadt@
Diffstat (limited to 'src/lib/libc/net/res_mkquery.c')
-rw-r--r-- | src/lib/libc/net/res_mkquery.c | 232 |
1 files changed, 0 insertions, 232 deletions
diff --git a/src/lib/libc/net/res_mkquery.c b/src/lib/libc/net/res_mkquery.c deleted file mode 100644 index 5c6b273abe..0000000000 --- a/src/lib/libc/net/res_mkquery.c +++ /dev/null | |||
@@ -1,232 +0,0 @@ | |||
1 | /* $OpenBSD: res_mkquery.c,v 1.17 2005/08/06 20:30:04 espie Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * ++Copyright++ 1985, 1993 | ||
5 | * - | ||
6 | * Copyright (c) 1985, 1993 | ||
7 | * The Regents of the University of California. All rights reserved. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. Neither the name of the University nor the names of its contributors | ||
18 | * may be used to endorse or promote products derived from this software | ||
19 | * without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | * SUCH DAMAGE. | ||
32 | * - | ||
33 | * Portions Copyright (c) 1993 by Digital Equipment Corporation. | ||
34 | * | ||
35 | * Permission to use, copy, modify, and distribute this software for any | ||
36 | * purpose with or without fee is hereby granted, provided that the above | ||
37 | * copyright notice and this permission notice appear in all copies, and that | ||
38 | * the name of Digital Equipment Corporation not be used in advertising or | ||
39 | * publicity pertaining to distribution of the document or software without | ||
40 | * specific, written prior permission. | ||
41 | * | ||
42 | * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL | ||
43 | * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES | ||
44 | * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT | ||
45 | * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | ||
46 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR | ||
47 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS | ||
48 | * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | ||
49 | * SOFTWARE. | ||
50 | * - | ||
51 | * --Copyright-- | ||
52 | */ | ||
53 | |||
54 | #include <sys/types.h> | ||
55 | #include <sys/param.h> | ||
56 | #include <netinet/in.h> | ||
57 | #include <arpa/nameser.h> | ||
58 | |||
59 | #include <stdio.h> | ||
60 | #include <netdb.h> | ||
61 | #include <resolv.h> | ||
62 | #include <string.h> | ||
63 | |||
64 | #include "thread_private.h" | ||
65 | |||
66 | /* | ||
67 | * Form all types of queries. | ||
68 | * Returns the size of the result or -1. | ||
69 | */ | ||
70 | /* ARGSUSED */ | ||
71 | int | ||
72 | res_mkquery(int op, | ||
73 | const char *dname, /* opcode of query */ | ||
74 | int class, /* domain name */ | ||
75 | int type, /* class and type of query */ | ||
76 | const u_char *data, /* resource record data */ | ||
77 | int datalen, /* length of data */ | ||
78 | const u_char *newrr_in, /* new rr for modify or append */ | ||
79 | u_char *buf, /* buffer to put query */ | ||
80 | int buflen) /* size of buffer */ | ||
81 | { | ||
82 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); | ||
83 | HEADER *hp; | ||
84 | u_char *cp, *ep; | ||
85 | int n; | ||
86 | u_char *dnptrs[20], **dpp, **lastdnptr; | ||
87 | |||
88 | if (_res_init(0) == -1) { | ||
89 | h_errno = NETDB_INTERNAL; | ||
90 | return (-1); | ||
91 | } | ||
92 | #ifdef DEBUG | ||
93 | if (_resp->options & RES_DEBUG) | ||
94 | printf(";; res_mkquery(%d, %s, %d, %d)\n", | ||
95 | op, dname, class, type); | ||
96 | #endif | ||
97 | /* | ||
98 | * Initialize header fields. | ||
99 | * | ||
100 | * A special random number generator is used to create non predictable | ||
101 | * and non repeating ids over a long period. It also avoids reuse | ||
102 | * by switching between two distinct number cycles. | ||
103 | */ | ||
104 | |||
105 | if ((buf == NULL) || (buflen < HFIXEDSZ)) | ||
106 | return (-1); | ||
107 | bzero(buf, HFIXEDSZ); | ||
108 | hp = (HEADER *) buf; | ||
109 | _resp->id = res_randomid(); | ||
110 | hp->id = htons(_resp->id); | ||
111 | hp->opcode = op; | ||
112 | hp->rd = (_resp->options & RES_RECURSE) != 0; | ||
113 | hp->rcode = NOERROR; | ||
114 | cp = buf + HFIXEDSZ; | ||
115 | ep = buf + buflen; | ||
116 | dpp = dnptrs; | ||
117 | *dpp++ = buf; | ||
118 | *dpp++ = NULL; | ||
119 | lastdnptr = dnptrs + sizeof dnptrs / sizeof dnptrs[0]; | ||
120 | /* | ||
121 | * perform opcode specific processing | ||
122 | */ | ||
123 | switch (op) { | ||
124 | case QUERY: /*FALLTHROUGH*/ | ||
125 | case NS_NOTIFY_OP: | ||
126 | if (ep - cp < QFIXEDSZ) | ||
127 | return (-1); | ||
128 | if ((n = dn_comp(dname, cp, ep - cp - QFIXEDSZ, dnptrs, | ||
129 | lastdnptr)) < 0) | ||
130 | return (-1); | ||
131 | cp += n; | ||
132 | __putshort(type, cp); | ||
133 | cp += INT16SZ; | ||
134 | __putshort(class, cp); | ||
135 | cp += INT16SZ; | ||
136 | hp->qdcount = htons(1); | ||
137 | if (op == QUERY || data == NULL) | ||
138 | break; | ||
139 | /* | ||
140 | * Make an additional record for completion domain. | ||
141 | */ | ||
142 | if (ep - cp < RRFIXEDSZ) | ||
143 | return (-1); | ||
144 | n = dn_comp((char *)data, cp, ep - cp - RRFIXEDSZ, dnptrs, | ||
145 | lastdnptr); | ||
146 | if (n < 0) | ||
147 | return (-1); | ||
148 | cp += n; | ||
149 | __putshort(T_NULL, cp); | ||
150 | cp += INT16SZ; | ||
151 | __putshort(class, cp); | ||
152 | cp += INT16SZ; | ||
153 | __putlong(0, cp); | ||
154 | cp += INT32SZ; | ||
155 | __putshort(0, cp); | ||
156 | cp += INT16SZ; | ||
157 | hp->arcount = htons(1); | ||
158 | break; | ||
159 | |||
160 | case IQUERY: | ||
161 | /* | ||
162 | * Initialize answer section | ||
163 | */ | ||
164 | if (ep - cp < 1 + RRFIXEDSZ + datalen) | ||
165 | return (-1); | ||
166 | *cp++ = '\0'; /* no domain name */ | ||
167 | __putshort(type, cp); | ||
168 | cp += INT16SZ; | ||
169 | __putshort(class, cp); | ||
170 | cp += INT16SZ; | ||
171 | __putlong(0, cp); | ||
172 | cp += INT32SZ; | ||
173 | __putshort(datalen, cp); | ||
174 | cp += INT16SZ; | ||
175 | if (datalen) { | ||
176 | bcopy(data, cp, datalen); | ||
177 | cp += datalen; | ||
178 | } | ||
179 | hp->ancount = htons(1); | ||
180 | break; | ||
181 | |||
182 | default: | ||
183 | return (-1); | ||
184 | } | ||
185 | return (cp - buf); | ||
186 | } | ||
187 | |||
188 | /* attach OPT pseudo-RR, as documented in RFC2671 (EDNS0). */ | ||
189 | int | ||
190 | res_opt(int n0, | ||
191 | u_char *buf, /* buffer to put query */ | ||
192 | int buflen, /* size of buffer */ | ||
193 | int anslen) /* answer buffer length */ | ||
194 | { | ||
195 | struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); | ||
196 | HEADER *hp; | ||
197 | u_char *cp, *ep; | ||
198 | |||
199 | hp = (HEADER *) buf; | ||
200 | cp = buf + n0; | ||
201 | ep = buf + buflen; | ||
202 | |||
203 | if (ep - cp < 1 + RRFIXEDSZ) | ||
204 | return -1; | ||
205 | |||
206 | *cp++ = 0; /* "." */ | ||
207 | |||
208 | __putshort(T_OPT, cp); /* TYPE */ | ||
209 | cp += INT16SZ; | ||
210 | if (anslen > 0xffff) | ||
211 | anslen = 0xffff; /* limit to 16bit value */ | ||
212 | __putshort(anslen & 0xffff, cp); /* CLASS = UDP payload size */ | ||
213 | cp += INT16SZ; | ||
214 | *cp++ = NOERROR; /* extended RCODE */ | ||
215 | *cp++ = 0; /* EDNS version */ | ||
216 | if (_resp->options & RES_USE_DNSSEC) { | ||
217 | #ifdef DEBUG | ||
218 | if (_resp->options & RES_DEBUG) | ||
219 | printf(";; res_opt()... ENDS0 DNSSEC OK\n"); | ||
220 | #endif /* DEBUG */ | ||
221 | __putshort(DNS_MESSAGEEXTFLAG_DO, cp); /* EDNS Z field */ | ||
222 | cp += INT16SZ; | ||
223 | } else { | ||
224 | __putshort(0, cp); /* EDNS Z field */ | ||
225 | cp += INT16SZ; | ||
226 | } | ||
227 | __putshort(0, cp); /* RDLEN */ | ||
228 | cp += INT16SZ; | ||
229 | hp->arcount = htons(ntohs(hp->arcount) + 1); | ||
230 | |||
231 | return cp - buf; | ||
232 | } | ||