Measure system

Dependencies:   EthernetNetIf mbed RF12B

Committer:
benecsj
Date:
Thu Mar 10 19:56:45 2011 +0000
Revision:
1:b26ab2467b1a

        

Who changed what in which revision?

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