res_mkquery.c (156953) | res_mkquery.c (156956) |
---|---|
1/* 2 * Copyright (c) 1985, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 58 unchanged lines hidden (view full) --- 67 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 68 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 69 */ 70 71#if defined(LIBC_SCCS) && !defined(lint) 72static const char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93"; 73static const char rcsid[] = "$Id: res_mkquery.c,v 1.1.2.2.4.2 2004/03/16 12:34:18 marka Exp $"; 74#endif /* LIBC_SCCS and not lint */ | 1/* 2 * Copyright (c) 1985, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 58 unchanged lines hidden (view full) --- 67 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 68 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 69 */ 70 71#if defined(LIBC_SCCS) && !defined(lint) 72static const char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93"; 73static const char rcsid[] = "$Id: res_mkquery.c,v 1.1.2.2.4.2 2004/03/16 12:34:18 marka Exp $"; 74#endif /* LIBC_SCCS and not lint */ |
75#include <sys/cdefs.h> 76__FBSDID("$FreeBSD: head/lib/libc/resolv/res_mkquery.c 156956 2006-03-21 15:37:16Z ume $"); |
|
75 76#include "port_before.h" 77#include <sys/types.h> 78#include <sys/param.h> 79#include <netinet/in.h> 80#include <arpa/nameser.h> 81#include <netdb.h> 82#include <resolv.h> --- 16 unchanged lines hidden (view full) --- 99 const char *dname, /* domain name */ 100 int class, int type, /* class and type of query */ 101 const u_char *data, /* resource record data */ 102 int datalen, /* length of data */ 103 const u_char *newrr_in, /* new rr for modify or append */ 104 u_char *buf, /* buffer to put query */ 105 int buflen) /* size of buffer */ 106{ | 77 78#include "port_before.h" 79#include <sys/types.h> 80#include <sys/param.h> 81#include <netinet/in.h> 82#include <arpa/nameser.h> 83#include <netdb.h> 84#include <resolv.h> --- 16 unchanged lines hidden (view full) --- 101 const char *dname, /* domain name */ 102 int class, int type, /* class and type of query */ 103 const u_char *data, /* resource record data */ 104 int datalen, /* length of data */ 105 const u_char *newrr_in, /* new rr for modify or append */ 106 u_char *buf, /* buffer to put query */ 107 int buflen) /* size of buffer */ 108{ |
107 register HEADER *hp; 108 register u_char *cp, *ep; 109 register int n; | 109 HEADER *hp; 110 u_char *cp, *ep; 111 int n; |
110 u_char *dnptrs[20], **dpp, **lastdnptr; 111 112 UNUSED(newrr_in); 113 114#ifdef DEBUG 115 if (statp->options & RES_DEBUG) 116 printf(";; res_nmkquery(%s, %s, %s, %s)\n", 117 _res_opcodes[op], dname, p_class(class), p_type(type)); --- 91 unchanged lines hidden (view full) --- 209 210int 211res_nopt(res_state statp, 212 int n0, /* current offset in buffer */ 213 u_char *buf, /* buffer to put query */ 214 int buflen, /* size of buffer */ 215 int anslen) /* UDP answer buffer size */ 216{ | 112 u_char *dnptrs[20], **dpp, **lastdnptr; 113 114 UNUSED(newrr_in); 115 116#ifdef DEBUG 117 if (statp->options & RES_DEBUG) 118 printf(";; res_nmkquery(%s, %s, %s, %s)\n", 119 _res_opcodes[op], dname, p_class(class), p_type(type)); --- 91 unchanged lines hidden (view full) --- 211 212int 213res_nopt(res_state statp, 214 int n0, /* current offset in buffer */ 215 u_char *buf, /* buffer to put query */ 216 int buflen, /* size of buffer */ 217 int anslen) /* UDP answer buffer size */ 218{ |
217 register HEADER *hp; 218 register u_char *cp, *ep; | 219 HEADER *hp; 220 u_char *cp, *ep; |
219 u_int16_t flags = 0; 220 221#ifdef DEBUG 222 if ((statp->options & RES_DEBUG) != 0U) 223 printf(";; res_nopt()\n"); 224#endif 225 226 hp = (HEADER *) buf; 227 cp = buf + n0; 228 ep = buf + buflen; 229 230 if ((ep - cp) < 1 + RRFIXEDSZ) 231 return (-1); 232 233 *cp++ = 0; /* "." */ 234 235 ns_put16(T_OPT, cp); /* TYPE */ 236 cp += INT16SZ; | 221 u_int16_t flags = 0; 222 223#ifdef DEBUG 224 if ((statp->options & RES_DEBUG) != 0U) 225 printf(";; res_nopt()\n"); 226#endif 227 228 hp = (HEADER *) buf; 229 cp = buf + n0; 230 ep = buf + buflen; 231 232 if ((ep - cp) < 1 + RRFIXEDSZ) 233 return (-1); 234 235 *cp++ = 0; /* "." */ 236 237 ns_put16(T_OPT, cp); /* TYPE */ 238 cp += INT16SZ; |
239 if (anslen > 0xffff) 240 anslen = 0xffff; /* limit to 16bit value */ |
|
237 ns_put16(anslen & 0xffff, cp); /* CLASS = UDP payload size */ 238 cp += INT16SZ; 239 *cp++ = NOERROR; /* extended RCODE */ 240 *cp++ = 0; /* EDNS version */ 241 if (statp->options & RES_USE_DNSSEC) { 242#ifdef DEBUG 243 if (statp->options & RES_DEBUG) 244 printf(";; res_opt()... ENDS0 DNSSEC\n"); --- 12 unchanged lines hidden --- | 241 ns_put16(anslen & 0xffff, cp); /* CLASS = UDP payload size */ 242 cp += INT16SZ; 243 *cp++ = NOERROR; /* extended RCODE */ 244 *cp++ = 0; /* EDNS version */ 245 if (statp->options & RES_USE_DNSSEC) { 246#ifdef DEBUG 247 if (statp->options & RES_DEBUG) 248 printf(";; res_opt()... ENDS0 DNSSEC\n"); --- 12 unchanged lines hidden --- |