diff options
author | Ulrich Drepper <drepper@redhat.com> | 2007-02-09 23:46:29 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2007-02-09 23:46:29 +0000 |
commit | 2bbb7d5b3c517956e95e5827037a76cbc39a20c8 (patch) | |
tree | e5d2f14edf74a9e9992ebe907e5feffd9dca7c7e /resolv/res_mkquery.c | |
parent | 00458b5bee15b31f90bca83c79f29e168f04ecc8 (diff) | |
download | glibc-2bbb7d5b3c517956e95e5827037a76cbc39a20c8.zip glibc-2bbb7d5b3c517956e95e5827037a76cbc39a20c8.tar.gz glibc-2bbb7d5b3c517956e95e5827037a76cbc39a20c8.tar.bz2 |
* resolv/res_init.c (res_setoptions): Recognize edns0 option.
* resolv/res_mkquery.c: Define __res_nopt.
* resolv/res_query.c (__libc_res_nquery): If RES_USE_EDNS0 is set
try adding EDNS0 record.
* resolv/res_send.c (send_dg): If request failed with FORMERR and
EDNS0 record was send make sure we don't try it again.
* resolv/resolv.h: Define RES_F_EDNS0ERR and RES_USE_EDNS0.
* include/resolv.h: Declare __res_nopt.
Diffstat (limited to 'resolv/res_mkquery.c')
-rw-r--r-- | resolv/res_mkquery.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/resolv/res_mkquery.c b/resolv/res_mkquery.c index fd80569..3fa597f 100644 --- a/resolv/res_mkquery.c +++ b/resolv/res_mkquery.c @@ -208,3 +208,49 @@ res_nmkquery(res_state statp, return (cp - buf); } libresolv_hidden_def (res_nmkquery) + + +/* attach OPT pseudo-RR, as documented in RFC2671 (EDNS0). */ +#ifndef T_OPT +#define T_OPT 41 +#endif + +int +__res_nopt(res_state statp, + int n0, /* current offset in buffer */ + u_char *buf, /* buffer to put query */ + int buflen, /* size of buffer */ + int anslen) /* UDP answer buffer size */ +{ + u_int16_t flags = 0; + +#ifdef DEBUG + if ((statp->options & RES_DEBUG) != 0U) + printf(";; res_nopt()\n"); +#endif + + HEADER *hp = (HEADER *) buf; + u_char *cp = buf + n0; + u_char *ep = buf + buflen; + + if ((ep - cp) < 1 + RRFIXEDSZ) + return -1; + + *cp++ = 0; /* "." */ + + ns_put16(T_OPT, cp); /* TYPE */ + cp += INT16SZ; + ns_put16(anslen & 0xffff, cp); /* CLASS = UDP payload size */ + cp += INT16SZ; + *cp++ = NOERROR; /* extended RCODE */ + *cp++ = 0; /* EDNS version */ + /* XXX Once we support DNSSEC we change the flag value here. */ + ns_put16(flags, cp); + cp += INT16SZ; + ns_put16(0, cp); /* RDLEN */ + cp += INT16SZ; + hp->arcount = htons(ntohs(hp->arcount) + 1); + + return cp - buf; +} +libresolv_hidden_def (__res_nopt) |