2 * magic.c - PPP Magic Number routines.
4 * Copyright (c) 1989 Carnegie Mellon University.
7 * Redistribution and use in source and binary forms are permitted
8 * provided that the above copyright notice and this paragraph are
9 * duplicated in all such forms and that any documentation,
10 * advertising materials, and other materials related to such
11 * distribution and use acknowledge that the software was developed
12 * by Carnegie Mellon University. The name of the
13 * University may not be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 static char rcsid[] = "$Id: magic.c,v 1.3 1994/09/21 06:47:37 paulus Exp $";
25 #include <sys/types.h>
31 static u_int32_t next; /* Next value to return */
33 extern u_int32_t gethostid __P((void));
34 extern long random __P((void));
35 extern void srandom __P((int));
39 * magic_init - Initialize the magic number generator.
41 * Computes first magic number and seed for random number generator.
42 * Attempts to compute a random number seed which will not repeat.
43 * The current method uses the current hostid and current time.
50 if (gettimeofday(&tv, NULL)) {
51 perror("gettimeofday");
54 next ^= (u_int32_t) tv.tv_sec ^ (u_int32_t) tv.tv_usec;
61 * magic - Returns the next magic number.
68 next = (u_int32_t) random();