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