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