HTTPClient using static IP

Dependencies:   mbed

Committer:
mr_q
Date:
Mon May 30 11:53:37 2011 +0000
Revision:
0:d8f2f7d5f31b
v0.01 Draft

Who changed what in which revision?

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