Leest de waarde van een sensor binnen een maakt deze beschikbaar via internet

Dependencies:   NTPClient_NetServices mbed

Committer:
hendrikvincent
Date:
Mon Dec 02 09:01:23 2013 +0000
Revision:
0:05ccbd4f84f1
eerste programma;

Who changed what in which revision?

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