Web server based weather station using Sparkfun Weather Meters.
Dependencies: FatFileSystem mbed WeatherMeters SDFileSystem
NetStack/lwip/netif/ppp/randm.h@1:c7958aa34fa1, 2012-02-25 (annotated)
- Committer:
- AdamGreen
- Date:
- Sat Feb 25 03:28:05 2012 +0000
- Revision:
- 1:c7958aa34fa1
- Parent:
- 0:616601bde9fb
Use published libraries where possible.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AdamGreen | 0:616601bde9fb | 1 | /***************************************************************************** |
AdamGreen | 0:616601bde9fb | 2 | * randm.h - Random number generator header file. |
AdamGreen | 0:616601bde9fb | 3 | * |
AdamGreen | 0:616601bde9fb | 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. |
AdamGreen | 0:616601bde9fb | 5 | * Copyright (c) 1998 Global Election Systems Inc. |
AdamGreen | 0:616601bde9fb | 6 | * |
AdamGreen | 0:616601bde9fb | 7 | * The authors hereby grant permission to use, copy, modify, distribute, |
AdamGreen | 0:616601bde9fb | 8 | * and license this software and its documentation for any purpose, provided |
AdamGreen | 0:616601bde9fb | 9 | * that existing copyright notices are retained in all copies and that this |
AdamGreen | 0:616601bde9fb | 10 | * notice and the following disclaimer are included verbatim in any |
AdamGreen | 0:616601bde9fb | 11 | * distributions. No written agreement, license, or royalty fee is required |
AdamGreen | 0:616601bde9fb | 12 | * for any of the authorized uses. |
AdamGreen | 0:616601bde9fb | 13 | * |
AdamGreen | 0:616601bde9fb | 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR |
AdamGreen | 0:616601bde9fb | 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
AdamGreen | 0:616601bde9fb | 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
AdamGreen | 0:616601bde9fb | 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
AdamGreen | 0:616601bde9fb | 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
AdamGreen | 0:616601bde9fb | 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
AdamGreen | 0:616601bde9fb | 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
AdamGreen | 0:616601bde9fb | 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AdamGreen | 0:616601bde9fb | 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
AdamGreen | 0:616601bde9fb | 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AdamGreen | 0:616601bde9fb | 24 | * |
AdamGreen | 0:616601bde9fb | 25 | ****************************************************************************** |
AdamGreen | 0:616601bde9fb | 26 | * REVISION HISTORY |
AdamGreen | 0:616601bde9fb | 27 | * |
AdamGreen | 0:616601bde9fb | 28 | * 03-01-01 Marc Boucher <marc@mbsi.ca> |
AdamGreen | 0:616601bde9fb | 29 | * Ported to lwIP. |
AdamGreen | 0:616601bde9fb | 30 | * 98-05-29 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc. |
AdamGreen | 0:616601bde9fb | 31 | * Extracted from avos. |
AdamGreen | 0:616601bde9fb | 32 | *****************************************************************************/ |
AdamGreen | 0:616601bde9fb | 33 | |
AdamGreen | 0:616601bde9fb | 34 | #ifndef RANDM_H |
AdamGreen | 0:616601bde9fb | 35 | #define RANDM_H |
AdamGreen | 0:616601bde9fb | 36 | |
AdamGreen | 0:616601bde9fb | 37 | /*********************** |
AdamGreen | 0:616601bde9fb | 38 | *** PUBLIC FUNCTIONS *** |
AdamGreen | 0:616601bde9fb | 39 | ***********************/ |
AdamGreen | 0:616601bde9fb | 40 | /* |
AdamGreen | 0:616601bde9fb | 41 | * Initialize the random number generator. |
AdamGreen | 0:616601bde9fb | 42 | */ |
AdamGreen | 0:616601bde9fb | 43 | void avRandomInit(void); |
AdamGreen | 0:616601bde9fb | 44 | |
AdamGreen | 0:616601bde9fb | 45 | /* |
AdamGreen | 0:616601bde9fb | 46 | * Churn the randomness pool on a random event. Call this early and often |
AdamGreen | 0:616601bde9fb | 47 | * on random and semi-random system events to build randomness in time for |
AdamGreen | 0:616601bde9fb | 48 | * usage. For randomly timed events, pass a null pointer and a zero length |
AdamGreen | 0:616601bde9fb | 49 | * and this will use the system timer and other sources to add randomness. |
AdamGreen | 0:616601bde9fb | 50 | * If new random data is available, pass a pointer to that and it will be |
AdamGreen | 0:616601bde9fb | 51 | * included. |
AdamGreen | 0:616601bde9fb | 52 | */ |
AdamGreen | 0:616601bde9fb | 53 | void avChurnRand(char *randData, u32_t randLen); |
AdamGreen | 0:616601bde9fb | 54 | |
AdamGreen | 0:616601bde9fb | 55 | /* |
AdamGreen | 0:616601bde9fb | 56 | * Randomize our random seed value. To be called for truely random events |
AdamGreen | 0:616601bde9fb | 57 | * such as user operations and network traffic. |
AdamGreen | 0:616601bde9fb | 58 | */ |
AdamGreen | 0:616601bde9fb | 59 | #if MD5_SUPPORT |
AdamGreen | 0:616601bde9fb | 60 | #define avRandomize() avChurnRand(NULL, 0) |
AdamGreen | 0:616601bde9fb | 61 | #else /* MD5_SUPPORT */ |
AdamGreen | 0:616601bde9fb | 62 | void avRandomize(void); |
AdamGreen | 0:616601bde9fb | 63 | #endif /* MD5_SUPPORT */ |
AdamGreen | 0:616601bde9fb | 64 | |
AdamGreen | 0:616601bde9fb | 65 | /* |
AdamGreen | 0:616601bde9fb | 66 | * Use the random pool to generate random data. This degrades to pseudo |
AdamGreen | 0:616601bde9fb | 67 | * random when used faster than randomness is supplied using churnRand(). |
AdamGreen | 0:616601bde9fb | 68 | * Thus it's important to make sure that the results of this are not |
AdamGreen | 0:616601bde9fb | 69 | * published directly because one could predict the next result to at |
AdamGreen | 0:616601bde9fb | 70 | * least some degree. Also, it's important to get a good seed before |
AdamGreen | 0:616601bde9fb | 71 | * the first use. |
AdamGreen | 0:616601bde9fb | 72 | */ |
AdamGreen | 0:616601bde9fb | 73 | void avGenRand(char *buf, u32_t bufLen); |
AdamGreen | 0:616601bde9fb | 74 | |
AdamGreen | 0:616601bde9fb | 75 | /* |
AdamGreen | 0:616601bde9fb | 76 | * Return a new random number. |
AdamGreen | 0:616601bde9fb | 77 | */ |
AdamGreen | 0:616601bde9fb | 78 | u32_t avRandom(void); |
AdamGreen | 0:616601bde9fb | 79 | |
AdamGreen | 0:616601bde9fb | 80 | |
AdamGreen | 0:616601bde9fb | 81 | #endif /* RANDM_H */ |