I have a problem getting this to work. Server only recieves half of the data being sent. Whats wrong

Dependencies:   mbed

Committer:
tax
Date:
Tue Mar 29 13:20:15 2011 +0000
Revision:
0:66300c77c6e9

        

Who changed what in which revision?

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