Demo Application for the Celeritous Breakout Board

Dependencies:   mbed

Committer:
celeritous
Date:
Fri May 18 03:55:10 2012 +0000
Revision:
0:1a3da73fe36a
Celeritous_BreakoutBoardDemo

Who changed what in which revision?

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