summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/res_mkquery.c
diff options
context:
space:
mode:
authoritojun <>2001-06-11 10:06:01 +0000
committeritojun <>2001-06-11 10:06:01 +0000
commit3181f54059d8f111597b6e6ebec0e24f7939ada7 (patch)
treebfe7ada7d6c92fea65c972ec4fb3bcfcdbfc2dc5 /src/lib/libc/net/res_mkquery.c
parente48fbbe799cf5b7ff38a184af2aa7f3ce90f7f65 (diff)
downloadopenbsd-3181f54059d8f111597b6e6ebec0e24f7939ada7.tar.gz
openbsd-3181f54059d8f111597b6e6ebec0e24f7939ada7.tar.bz2
openbsd-3181f54059d8f111597b6e6ebec0e24f7939ada7.zip
support EDNS0 (RFC2671) buffer size notification on DNS queries.
"options edns0" in /etc/resolv.conf will enable the behavior. no behavior change if you don't have the line. see resolv.conf(5) for more details. EDNS0 is useful for avoiding TCP DNS queries/replies on larger DNS responses. also, draft-ietf-dnsext-message-size-* plans to mandate EDNS0 support for DNS clients that support IPv6 transport.
Diffstat (limited to 'src/lib/libc/net/res_mkquery.c')
-rw-r--r--src/lib/libc/net/res_mkquery.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/lib/libc/net/res_mkquery.c b/src/lib/libc/net/res_mkquery.c
index 3e7e2ae5d3..61595a6e8c 100644
--- a/src/lib/libc/net/res_mkquery.c
+++ b/src/lib/libc/net/res_mkquery.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: res_mkquery.c,v 1.8 1997/04/13 22:37:21 provos Exp $ */ 1/* $OpenBSD: res_mkquery.c,v 1.9 2001/06/11 10:06:00 itojun Exp $ */
2 2
3/* 3/*
4 * ++Copyright++ 1985, 1993 4 * ++Copyright++ 1985, 1993
@@ -60,7 +60,7 @@
60static char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93"; 60static char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
61static char rcsid[] = "$From: res_mkquery.c,v 8.5 1996/08/27 08:33:28 vixie Exp $"; 61static char rcsid[] = "$From: res_mkquery.c,v 8.5 1996/08/27 08:33:28 vixie Exp $";
62#else 62#else
63static char rcsid[] = "$OpenBSD: res_mkquery.c,v 1.8 1997/04/13 22:37:21 provos Exp $"; 63static char rcsid[] = "$OpenBSD: res_mkquery.c,v 1.9 2001/06/11 10:06:00 itojun Exp $";
64#endif 64#endif
65#endif /* LIBC_SCCS and not lint */ 65#endif /* LIBC_SCCS and not lint */
66 66
@@ -193,3 +193,40 @@ res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
193 } 193 }
194 return (cp - buf); 194 return (cp - buf);
195} 195}
196
197/* attach OPT pseudo-RR, as documented in RFC2671 (EDNS0). */
198int
199res_opt(n0, buf, buflen, anslen)
200 int n0;
201 u_char *buf; /* buffer to put query */
202 int buflen; /* size of buffer */
203 int anslen; /* answer buffer length */
204{
205 register HEADER *hp;
206 register u_char *cp;
207
208 hp = (HEADER *) buf;
209 cp = buf + n0;
210 buflen -= n0;
211
212 if (buflen < 1 + RRFIXEDSZ)
213 return -1;
214
215 *cp++ = 0; /* "." */
216 buflen--;
217
218 __putshort(T_OPT, cp); /* TYPE */
219 cp += INT16SZ;
220 __putshort(anslen & 0xffff, cp); /* CLASS = UDP payload size */
221 cp += INT16SZ;
222 *cp++ = NOERROR; /* extended RCODE */
223 *cp++ = 0; /* EDNS version */
224 __putshort(0, cp); /* MBZ */
225 cp += INT16SZ;
226 __putshort(0, cp); /* RDLEN */
227 cp += INT16SZ;
228 hp->arcount = htons(ntohs(hp->arcount) + 1);
229 buflen -= RRFIXEDSZ;
230
231 return cp - buf;
232}