Experimental HTTPClient with proxy support

Committer:
igorsk
Date:
Wed Jun 29 16:01:58 2011 +0000
Revision:
0:b56b6a05cad4

        

Who changed what in which revision?

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