summaryrefslogtreecommitdiff
path: root/lib/libc/net/res_mkquery.c
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>1997-04-13 21:30:48 +0000
committerNiels Provos <provos@cvs.openbsd.org>1997-04-13 21:30:48 +0000
commit4f2373a733380e881cb67eb81b13a40a946fb42a (patch)
tree7df37496bce32e7bd9202014f0ddb8e6c64ddb15 /lib/libc/net/res_mkquery.c
parenta836b0197367e41c79e368e58058710e6dc219ae (diff)
the before mentioned random number generator.
Diffstat (limited to 'lib/libc/net/res_mkquery.c')
-rw-r--r--lib/libc/net/res_mkquery.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/libc/net/res_mkquery.c b/lib/libc/net/res_mkquery.c
index 5faba01748d..2c244c24fc8 100644
--- a/lib/libc/net/res_mkquery.c
+++ b/lib/libc/net/res_mkquery.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_mkquery.c,v 1.6 1997/03/13 19:07:39 downsj Exp $ */
+/* $OpenBSD: res_mkquery.c,v 1.7 1997/04/13 21:30:46 provos Exp $ */
/*
* ++Copyright++ 1985, 1993
@@ -60,7 +60,7 @@
static char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "$From: res_mkquery.c,v 8.5 1996/08/27 08:33:28 vixie Exp $";
#else
-static char rcsid[] = "$OpenBSD: res_mkquery.c,v 1.6 1997/03/13 19:07:39 downsj Exp $";
+static char rcsid[] = "$OpenBSD: res_mkquery.c,v 1.7 1997/04/13 21:30:46 provos Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -106,12 +106,17 @@ res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
#endif
/*
* Initialize header fields.
+ *
+ * A special random number generator is used to create non predictable
+ * and non repeating ids over a long period. It also avoids reuse
+ * by switching between two distinct number cycles.
*/
+
if ((buf == NULL) || (buflen < HFIXEDSZ))
return (-1);
bzero(buf, HFIXEDSZ);
hp = (HEADER *) buf;
- hp->id = htons(++_res.id);
+ hp->id = htons(_res.id=res_randomid());
hp->opcode = op;
hp->rd = (_res.options & RES_RECURSE) != 0;
hp->rcode = NOERROR;