Read NTP time from Ethernet and drive six 7-segment LEDs using a MAX7221 to show time, date, month, week, year etc....
Dependencies: NTPClient_NetServices mbed
LPC1768/lwip/netif/ppp/chap.h@0:e083abcfe7a8, 2011-06-22 (annotated)
- Committer:
- cheungderek
- Date:
- Wed Jun 22 01:31:47 2011 +0000
- Revision:
- 0:e083abcfe7a8
First release.
Just some testing but working code to read NTP time and drive 6 LEDs to display time, date, month, year etc...
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cheungderek | 0:e083abcfe7a8 | 1 | /***************************************************************************** |
cheungderek | 0:e083abcfe7a8 | 2 | * chap.h - Network Challenge Handshake Authentication Protocol header file. |
cheungderek | 0:e083abcfe7a8 | 3 | * |
cheungderek | 0:e083abcfe7a8 | 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. |
cheungderek | 0:e083abcfe7a8 | 5 | * portions Copyright (c) 1998 Global Election Systems Inc. |
cheungderek | 0:e083abcfe7a8 | 6 | * |
cheungderek | 0:e083abcfe7a8 | 7 | * The authors hereby grant permission to use, copy, modify, distribute, |
cheungderek | 0:e083abcfe7a8 | 8 | * and license this software and its documentation for any purpose, provided |
cheungderek | 0:e083abcfe7a8 | 9 | * that existing copyright notices are retained in all copies and that this |
cheungderek | 0:e083abcfe7a8 | 10 | * notice and the following disclaimer are included verbatim in any |
cheungderek | 0:e083abcfe7a8 | 11 | * distributions. No written agreement, license, or royalty fee is required |
cheungderek | 0:e083abcfe7a8 | 12 | * for any of the authorized uses. |
cheungderek | 0:e083abcfe7a8 | 13 | * |
cheungderek | 0:e083abcfe7a8 | 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR |
cheungderek | 0:e083abcfe7a8 | 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
cheungderek | 0:e083abcfe7a8 | 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
cheungderek | 0:e083abcfe7a8 | 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
cheungderek | 0:e083abcfe7a8 | 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
cheungderek | 0:e083abcfe7a8 | 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
cheungderek | 0:e083abcfe7a8 | 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
cheungderek | 0:e083abcfe7a8 | 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
cheungderek | 0:e083abcfe7a8 | 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
cheungderek | 0:e083abcfe7a8 | 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
cheungderek | 0:e083abcfe7a8 | 24 | * |
cheungderek | 0:e083abcfe7a8 | 25 | ****************************************************************************** |
cheungderek | 0:e083abcfe7a8 | 26 | * REVISION HISTORY |
cheungderek | 0:e083abcfe7a8 | 27 | * |
cheungderek | 0:e083abcfe7a8 | 28 | * 03-01-01 Marc Boucher <marc@mbsi.ca> |
cheungderek | 0:e083abcfe7a8 | 29 | * Ported to lwIP. |
cheungderek | 0:e083abcfe7a8 | 30 | * 97-12-03 Guy Lancaster <lancasterg@acm.org>, Global Election Systems Inc. |
cheungderek | 0:e083abcfe7a8 | 31 | * Original built from BSD network code. |
cheungderek | 0:e083abcfe7a8 | 32 | ******************************************************************************/ |
cheungderek | 0:e083abcfe7a8 | 33 | /* |
cheungderek | 0:e083abcfe7a8 | 34 | * chap.h - Challenge Handshake Authentication Protocol definitions. |
cheungderek | 0:e083abcfe7a8 | 35 | * |
cheungderek | 0:e083abcfe7a8 | 36 | * Copyright (c) 1993 The Australian National University. |
cheungderek | 0:e083abcfe7a8 | 37 | * All rights reserved. |
cheungderek | 0:e083abcfe7a8 | 38 | * |
cheungderek | 0:e083abcfe7a8 | 39 | * Redistribution and use in source and binary forms are permitted |
cheungderek | 0:e083abcfe7a8 | 40 | * provided that the above copyright notice and this paragraph are |
cheungderek | 0:e083abcfe7a8 | 41 | * duplicated in all such forms and that any documentation, |
cheungderek | 0:e083abcfe7a8 | 42 | * advertising materials, and other materials related to such |
cheungderek | 0:e083abcfe7a8 | 43 | * distribution and use acknowledge that the software was developed |
cheungderek | 0:e083abcfe7a8 | 44 | * by the Australian National University. The name of the University |
cheungderek | 0:e083abcfe7a8 | 45 | * may not be used to endorse or promote products derived from this |
cheungderek | 0:e083abcfe7a8 | 46 | * software without specific prior written permission. |
cheungderek | 0:e083abcfe7a8 | 47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
cheungderek | 0:e083abcfe7a8 | 48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
cheungderek | 0:e083abcfe7a8 | 49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
cheungderek | 0:e083abcfe7a8 | 50 | * |
cheungderek | 0:e083abcfe7a8 | 51 | * Copyright (c) 1991 Gregory M. Christy |
cheungderek | 0:e083abcfe7a8 | 52 | * All rights reserved. |
cheungderek | 0:e083abcfe7a8 | 53 | * |
cheungderek | 0:e083abcfe7a8 | 54 | * Redistribution and use in source and binary forms are permitted |
cheungderek | 0:e083abcfe7a8 | 55 | * provided that the above copyright notice and this paragraph are |
cheungderek | 0:e083abcfe7a8 | 56 | * duplicated in all such forms and that any documentation, |
cheungderek | 0:e083abcfe7a8 | 57 | * advertising materials, and other materials related to such |
cheungderek | 0:e083abcfe7a8 | 58 | * distribution and use acknowledge that the software was developed |
cheungderek | 0:e083abcfe7a8 | 59 | * by the author. |
cheungderek | 0:e083abcfe7a8 | 60 | * |
cheungderek | 0:e083abcfe7a8 | 61 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
cheungderek | 0:e083abcfe7a8 | 62 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
cheungderek | 0:e083abcfe7a8 | 63 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
cheungderek | 0:e083abcfe7a8 | 64 | * |
cheungderek | 0:e083abcfe7a8 | 65 | * $Id: chap.h,v 1.6 2010/01/24 13:19:34 goldsimon Exp $ |
cheungderek | 0:e083abcfe7a8 | 66 | */ |
cheungderek | 0:e083abcfe7a8 | 67 | |
cheungderek | 0:e083abcfe7a8 | 68 | #ifndef CHAP_H |
cheungderek | 0:e083abcfe7a8 | 69 | #define CHAP_H |
cheungderek | 0:e083abcfe7a8 | 70 | |
cheungderek | 0:e083abcfe7a8 | 71 | /* Code + ID + length */ |
cheungderek | 0:e083abcfe7a8 | 72 | #define CHAP_HEADERLEN 4 |
cheungderek | 0:e083abcfe7a8 | 73 | |
cheungderek | 0:e083abcfe7a8 | 74 | /* |
cheungderek | 0:e083abcfe7a8 | 75 | * CHAP codes. |
cheungderek | 0:e083abcfe7a8 | 76 | */ |
cheungderek | 0:e083abcfe7a8 | 77 | |
cheungderek | 0:e083abcfe7a8 | 78 | #define CHAP_DIGEST_MD5 5 /* use MD5 algorithm */ |
cheungderek | 0:e083abcfe7a8 | 79 | #define MD5_SIGNATURE_SIZE 16 /* 16 bytes in a MD5 message digest */ |
cheungderek | 0:e083abcfe7a8 | 80 | #define CHAP_MICROSOFT 0x80 /* use Microsoft-compatible alg. */ |
cheungderek | 0:e083abcfe7a8 | 81 | #define MS_CHAP_RESPONSE_LEN 49 /* Response length for MS-CHAP */ |
cheungderek | 0:e083abcfe7a8 | 82 | |
cheungderek | 0:e083abcfe7a8 | 83 | #define CHAP_CHALLENGE 1 |
cheungderek | 0:e083abcfe7a8 | 84 | #define CHAP_RESPONSE 2 |
cheungderek | 0:e083abcfe7a8 | 85 | #define CHAP_SUCCESS 3 |
cheungderek | 0:e083abcfe7a8 | 86 | #define CHAP_FAILURE 4 |
cheungderek | 0:e083abcfe7a8 | 87 | |
cheungderek | 0:e083abcfe7a8 | 88 | /* |
cheungderek | 0:e083abcfe7a8 | 89 | * Challenge lengths (for challenges we send) and other limits. |
cheungderek | 0:e083abcfe7a8 | 90 | */ |
cheungderek | 0:e083abcfe7a8 | 91 | #define MIN_CHALLENGE_LENGTH 32 |
cheungderek | 0:e083abcfe7a8 | 92 | #define MAX_CHALLENGE_LENGTH 64 |
cheungderek | 0:e083abcfe7a8 | 93 | #define MAX_RESPONSE_LENGTH 64 /* sufficient for MD5 or MS-CHAP */ |
cheungderek | 0:e083abcfe7a8 | 94 | |
cheungderek | 0:e083abcfe7a8 | 95 | /* |
cheungderek | 0:e083abcfe7a8 | 96 | * Each interface is described by a chap structure. |
cheungderek | 0:e083abcfe7a8 | 97 | */ |
cheungderek | 0:e083abcfe7a8 | 98 | |
cheungderek | 0:e083abcfe7a8 | 99 | typedef struct chap_state { |
cheungderek | 0:e083abcfe7a8 | 100 | int unit; /* Interface unit number */ |
cheungderek | 0:e083abcfe7a8 | 101 | int clientstate; /* Client state */ |
cheungderek | 0:e083abcfe7a8 | 102 | int serverstate; /* Server state */ |
cheungderek | 0:e083abcfe7a8 | 103 | u_char challenge[MAX_CHALLENGE_LENGTH]; /* last challenge string sent */ |
cheungderek | 0:e083abcfe7a8 | 104 | u_char chal_len; /* challenge length */ |
cheungderek | 0:e083abcfe7a8 | 105 | u_char chal_id; /* ID of last challenge */ |
cheungderek | 0:e083abcfe7a8 | 106 | u_char chal_type; /* hash algorithm for challenges */ |
cheungderek | 0:e083abcfe7a8 | 107 | u_char id; /* Current id */ |
cheungderek | 0:e083abcfe7a8 | 108 | char *chal_name; /* Our name to use with challenge */ |
cheungderek | 0:e083abcfe7a8 | 109 | int chal_interval; /* Time until we challenge peer again */ |
cheungderek | 0:e083abcfe7a8 | 110 | int timeouttime; /* Timeout time in seconds */ |
cheungderek | 0:e083abcfe7a8 | 111 | int max_transmits; /* Maximum # of challenge transmissions */ |
cheungderek | 0:e083abcfe7a8 | 112 | int chal_transmits; /* Number of transmissions of challenge */ |
cheungderek | 0:e083abcfe7a8 | 113 | int resp_transmits; /* Number of transmissions of response */ |
cheungderek | 0:e083abcfe7a8 | 114 | u_char response[MAX_RESPONSE_LENGTH]; /* Response to send */ |
cheungderek | 0:e083abcfe7a8 | 115 | u_char resp_length; /* length of response */ |
cheungderek | 0:e083abcfe7a8 | 116 | u_char resp_id; /* ID for response messages */ |
cheungderek | 0:e083abcfe7a8 | 117 | u_char resp_type; /* hash algorithm for responses */ |
cheungderek | 0:e083abcfe7a8 | 118 | char *resp_name; /* Our name to send with response */ |
cheungderek | 0:e083abcfe7a8 | 119 | } chap_state; |
cheungderek | 0:e083abcfe7a8 | 120 | |
cheungderek | 0:e083abcfe7a8 | 121 | |
cheungderek | 0:e083abcfe7a8 | 122 | /* |
cheungderek | 0:e083abcfe7a8 | 123 | * Client (peer) states. |
cheungderek | 0:e083abcfe7a8 | 124 | */ |
cheungderek | 0:e083abcfe7a8 | 125 | #define CHAPCS_INITIAL 0 /* Lower layer down, not opened */ |
cheungderek | 0:e083abcfe7a8 | 126 | #define CHAPCS_CLOSED 1 /* Lower layer up, not opened */ |
cheungderek | 0:e083abcfe7a8 | 127 | #define CHAPCS_PENDING 2 /* Auth us to peer when lower up */ |
cheungderek | 0:e083abcfe7a8 | 128 | #define CHAPCS_LISTEN 3 /* Listening for a challenge */ |
cheungderek | 0:e083abcfe7a8 | 129 | #define CHAPCS_RESPONSE 4 /* Sent response, waiting for status */ |
cheungderek | 0:e083abcfe7a8 | 130 | #define CHAPCS_OPEN 5 /* We've received Success */ |
cheungderek | 0:e083abcfe7a8 | 131 | |
cheungderek | 0:e083abcfe7a8 | 132 | /* |
cheungderek | 0:e083abcfe7a8 | 133 | * Server (authenticator) states. |
cheungderek | 0:e083abcfe7a8 | 134 | */ |
cheungderek | 0:e083abcfe7a8 | 135 | #define CHAPSS_INITIAL 0 /* Lower layer down, not opened */ |
cheungderek | 0:e083abcfe7a8 | 136 | #define CHAPSS_CLOSED 1 /* Lower layer up, not opened */ |
cheungderek | 0:e083abcfe7a8 | 137 | #define CHAPSS_PENDING 2 /* Auth peer when lower up */ |
cheungderek | 0:e083abcfe7a8 | 138 | #define CHAPSS_INITIAL_CHAL 3 /* We've sent the first challenge */ |
cheungderek | 0:e083abcfe7a8 | 139 | #define CHAPSS_OPEN 4 /* We've sent a Success msg */ |
cheungderek | 0:e083abcfe7a8 | 140 | #define CHAPSS_RECHALLENGE 5 /* We've sent another challenge */ |
cheungderek | 0:e083abcfe7a8 | 141 | #define CHAPSS_BADAUTH 6 /* We've sent a Failure msg */ |
cheungderek | 0:e083abcfe7a8 | 142 | |
cheungderek | 0:e083abcfe7a8 | 143 | extern chap_state chap[]; |
cheungderek | 0:e083abcfe7a8 | 144 | |
cheungderek | 0:e083abcfe7a8 | 145 | void ChapAuthWithPeer (int, char *, u_char); |
cheungderek | 0:e083abcfe7a8 | 146 | void ChapAuthPeer (int, char *, u_char); |
cheungderek | 0:e083abcfe7a8 | 147 | |
cheungderek | 0:e083abcfe7a8 | 148 | extern struct protent chap_protent; |
cheungderek | 0:e083abcfe7a8 | 149 | |
cheungderek | 0:e083abcfe7a8 | 150 | #endif /* CHAP_H */ |