This library is stripped down version of NetServices library. HTTP server and client function is NOT supported.

Dependents:   imu-daq-eth

Committer:
idinor
Date:
Wed Jul 20 11:45:39 2011 +0000
Revision:
0:dcf3c92487ca

        

Who changed what in which revision?

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