source: rtems/c/src/libnetworking/pppd/magic.c @ 2f1b930

4.104.114.84.95
Last change on this file since 2f1b930 was 2f1b930, checked in by Joel Sherrill <joel.sherrill@…>, on 08/16/01 at 20:42:09

2001-08-16 Mike Siers <mikes@…>

  • Update of PPPD to 2.3.11 from 2.3.5 and addition of an example application. Mike's notes on the modifications:
    • renamed error() function because of namespace problems
    • removed calls to the exit() funciton
    • removed extra files from the pppd source directory
    • defined pppd task constant values in rtemspppd.h
    • modifyied example code to get actual tick per second value
    • placed the pppd 2.3.11 man page file (pppd.8) into the pppd directory
  • pppd/cbcp.c, pppd/cbcp.h, pppd/main.c, pppd/ppp_tty.c, pppd/pppmain.c, pppd/rtems-ppp.c, pppd/rtems-ppp.c: Deleted.
  • pppd/pppd.8, pppd/rtemsmain.c, pppd/rtemspppd.c, pppd/rtemspppd.h, pppd/sys-rtems.c, pppd/utils.c, pppd/example/Makefile, pppd/example/README, pppd/example/init.c, pppd/example/netconfig.h, pppd/example/ppp.conf, pppd/example/pppdapp.c, pppd/example/system.h: New files.
  • modem/ppp_tty.c, net/if_ppp.h, pppd/Makefile.am, pppd/README, pppd/STATUS, pppd/auth.c, pppd/ccp.c, pppd/ccp.h, pppd/chap.c, pppd/chap.h, pppd/chap_ms.c, pppd/chap_ms.h, pppd/chat.c, pppd/demand.c, pppd/fsm.c, pppd/fsm.h, pppd/ipcp.c, pppd/ipcp.h, pppd/ipxcp.c, pppd/ipxcp.h, pppd/lcp.c, pppd/lcp.h, pppd/magic.c, pppd/magic.h, pppd/options.c, pppd/patchlevel.h, pppd/pathnames.h, pppd/pppd.h, pppd/upap.c, pppd/upap.h: Modified.
  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 * magic.c - PPP Magic Number routines.
3 *
4 * Copyright (c) 1989 Carnegie Mellon University.
5 * All rights reserved.
6 *
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.
18 */
19
20#define RCSID   "$Id$"
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <unistd.h>
25#include <sys/types.h>
26#include <sys/time.h>
27
28#include "pppd.h"
29#include "magic.h"
30
31static const char rcsid[] = RCSID;
32
33extern long mrand48 __P((void));
34extern void srand48 __P((long));
35
36/*
37 * magic_init - Initialize the magic number generator.
38 *
39 * Attempts to compute a random number seed which will not repeat.
40 * The current method uses the current hostid, current process ID
41 * and current time, currently.
42 */
43void
44magic_init()
45{
46    long seed;
47    struct timeval t;
48
49    gettimeofday(&t, NULL);
50    seed = get_host_seed() ^ t.tv_sec ^ t.tv_usec ^ getpid();
51    srand48(seed);
52}
53
54/*
55 * magic - Returns the next magic number.
56 */
57u_int32_t
58magic()
59{
60    return (u_int32_t) mrand48();
61}
62
63/*
64 * Substitute procedures for those systems which don't have
65 * drand48 et al.
66 */
67
68double
69drand48()
70{
71    return (double)rand() / (double)0x7fffffffL; /* 2**31-1 */
72}
73
74long
75mrand48()
76{
77    return rand();
78}
79
80void
81srand48(seedval)
82long seedval;
83{
84    srand((int)seedval);
85}
Note: See TracBrowser for help on using the repository browser.