ProjetoBB

Dependencies:   F7_Ethernet WebSocketClient mbed mcp3008

Fork of Nucleo_F746ZG_Ethernet by Dieter Graef

Committer:
DieterGraef
Date:
Sat Jun 18 10:49:12 2016 +0000
Revision:
0:f9b6112278fe
Ethernet for the NUCLEO STM32F746 Board Testprogram uses DHCP and NTP to set the clock

Who changed what in which revision?

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