WebSocketServer test

Dependencies:   mbed

Committer:
gtk2k
Date:
Sun Apr 29 03:58:08 2012 +0000
Revision:
0:74be48b504a5
WebSocketServer

Who changed what in which revision?

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