Xbee test 2

Dependencies:   XBee mbed

Committer:
takashiyamanoue
Date:
Sat Jul 21 04:08:27 2012 +0000
Revision:
0:ffac63d6a7f0
xbee test 2

Who changed what in which revision?

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