NetTribute library with debug turned on in FShandler Donatien Garner -> Segundo Equipo -> this version

Committer:
hexley
Date:
Fri Nov 19 01:54:45 2010 +0000
Revision:
0:281d6ff68967

        

Who changed what in which revision?

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