code that uses Watchdog to reset Mbed every 30seconds. After 30-60mins, the ethernet interface fails to setup() after WatchDog reset.

Dependencies:   mbed

Committer:
eqon
Date:
Thu Jun 07 05:44:29 2012 +0000
Revision:
0:0ce833f21e63

        

Who changed what in which revision?

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