Prusa MINI Firmware overview
magic.h
Go to the documentation of this file.
1 /*
2  * magic.h - PPP Magic Number definitions.
3  *
4  * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The name "Carnegie Mellon University" must not be used to
19  * endorse or promote products derived from this software without
20  * prior written permission. For permission or any legal
21  * details, please contact
22  * Office of Technology Transfer
23  * Carnegie Mellon University
24  * 5000 Forbes Avenue
25  * Pittsburgh, PA 15213-3890
26  * (412) 268-4387, fax: (412) 268-7395
27  * tech-transfer@andrew.cmu.edu
28  *
29  * 4. Redistributions of any form whatsoever must retain the following
30  * acknowledgment:
31  * "This product includes software developed by Computing Services
32  * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
33  *
34  * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
35  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
36  * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
37  * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
38  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
39  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
40  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
41  *
42  * $Id: magic.h,v 1.5 2003/06/11 23:56:26 paulus Exp $
43  */
44 /*****************************************************************************
45 * randm.h - Random number generator header file.
46 *
47 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
48 * Copyright (c) 1998 Global Election Systems Inc.
49 *
50 * The authors hereby grant permission to use, copy, modify, distribute,
51 * and license this software and its documentation for any purpose, provided
52 * that existing copyright notices are retained in all copies and that this
53 * notice and the following disclaimer are included verbatim in any
54 * distributions. No written agreement, license, or royalty fee is required
55 * for any of the authorized uses.
56 *
57 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
58 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
61 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
63 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
64 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
66 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 *
68 ******************************************************************************
69 * REVISION HISTORY
70 *
71 * 03-01-01 Marc Boucher <marc@mbsi.ca>
72 * Ported to lwIP.
73 * 98-05-29 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
74 * Extracted from avos.
75 *****************************************************************************/
76 
77 #include "netif/ppp/ppp_opts.h"
78 #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
79 
80 #ifndef MAGIC_H
81 #define MAGIC_H
82 
83 /***********************
84 *** PUBLIC FUNCTIONS ***
85 ***********************/
86 
87 /*
88  * Initialize the random number generator.
89  */
90 void magic_init(void);
91 
92 /*
93  * Randomize our random seed value. To be called for truely random events
94  * such as user operations and network traffic.
95  */
96 void magic_randomize(void);
97 
98 /*
99  * Return a new random number.
100  */
101 u32_t magic(void); /* Returns the next magic number */
102 
103 /*
104  * Fill buffer with random bytes
105  *
106  * Use the random pool to generate random data. This degrades to pseudo
107  * random when used faster than randomness is supplied using magic_churnrand().
108  * Thus it's important to make sure that the results of this are not
109  * published directly because one could predict the next result to at
110  * least some degree. Also, it's important to get a good seed before
111  * the first use.
112  */
113 void magic_random_bytes(unsigned char *buf, u32_t buf_len);
114 
115 /*
116  * Return a new random number between 0 and (2^pow)-1 included.
117  */
118 u32_t magic_pow(u8_t pow);
119 
120 #endif /* MAGIC_H */
121 
122 #endif /* PPP_SUPPORT */
u32_t
uint32_t u32_t
Definition: arch.h:123
u8_t
uint8_t u8_t
Definition: arch.h:119
ppp_opts.h