Xbee test 2

Dependencies:   XBee mbed

Committer:
takashiyamanoue
Date:
Sat Jul 21 04:08:27 2012 +0000
Revision:
0:ffac63d6a7f0
xbee test 2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
takashiyamanoue 0:ffac63d6a7f0 1 /*****************************************************************************
takashiyamanoue 0:ffac63d6a7f0 2 * pap.h - PPP Password Authentication Protocol header file.
takashiyamanoue 0:ffac63d6a7f0 3 *
takashiyamanoue 0:ffac63d6a7f0 4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
takashiyamanoue 0:ffac63d6a7f0 5 * portions Copyright (c) 1997 Global Election Systems Inc.
takashiyamanoue 0:ffac63d6a7f0 6 *
takashiyamanoue 0:ffac63d6a7f0 7 * The authors hereby grant permission to use, copy, modify, distribute,
takashiyamanoue 0:ffac63d6a7f0 8 * and license this software and its documentation for any purpose, provided
takashiyamanoue 0:ffac63d6a7f0 9 * that existing copyright notices are retained in all copies and that this
takashiyamanoue 0:ffac63d6a7f0 10 * notice and the following disclaimer are included verbatim in any
takashiyamanoue 0:ffac63d6a7f0 11 * distributions. No written agreement, license, or royalty fee is required
takashiyamanoue 0:ffac63d6a7f0 12 * for any of the authorized uses.
takashiyamanoue 0:ffac63d6a7f0 13 *
takashiyamanoue 0:ffac63d6a7f0 14 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
takashiyamanoue 0:ffac63d6a7f0 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
takashiyamanoue 0:ffac63d6a7f0 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
takashiyamanoue 0:ffac63d6a7f0 17 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
takashiyamanoue 0:ffac63d6a7f0 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
takashiyamanoue 0:ffac63d6a7f0 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
takashiyamanoue 0:ffac63d6a7f0 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
takashiyamanoue 0:ffac63d6a7f0 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
takashiyamanoue 0:ffac63d6a7f0 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
takashiyamanoue 0:ffac63d6a7f0 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
takashiyamanoue 0:ffac63d6a7f0 24 *
takashiyamanoue 0:ffac63d6a7f0 25 ******************************************************************************
takashiyamanoue 0:ffac63d6a7f0 26 * REVISION HISTORY
takashiyamanoue 0:ffac63d6a7f0 27 *
takashiyamanoue 0:ffac63d6a7f0 28 * 03-01-01 Marc Boucher <marc@mbsi.ca>
takashiyamanoue 0:ffac63d6a7f0 29 * Ported to lwIP.
takashiyamanoue 0:ffac63d6a7f0 30 * 97-12-04 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
takashiyamanoue 0:ffac63d6a7f0 31 * Original derived from BSD codes.
takashiyamanoue 0:ffac63d6a7f0 32 *****************************************************************************/
takashiyamanoue 0:ffac63d6a7f0 33 /*
takashiyamanoue 0:ffac63d6a7f0 34 * upap.h - User/Password Authentication Protocol definitions.
takashiyamanoue 0:ffac63d6a7f0 35 *
takashiyamanoue 0:ffac63d6a7f0 36 * Copyright (c) 1989 Carnegie Mellon University.
takashiyamanoue 0:ffac63d6a7f0 37 * All rights reserved.
takashiyamanoue 0:ffac63d6a7f0 38 *
takashiyamanoue 0:ffac63d6a7f0 39 * Redistribution and use in source and binary forms are permitted
takashiyamanoue 0:ffac63d6a7f0 40 * provided that the above copyright notice and this paragraph are
takashiyamanoue 0:ffac63d6a7f0 41 * duplicated in all such forms and that any documentation,
takashiyamanoue 0:ffac63d6a7f0 42 * advertising materials, and other materials related to such
takashiyamanoue 0:ffac63d6a7f0 43 * distribution and use acknowledge that the software was developed
takashiyamanoue 0:ffac63d6a7f0 44 * by Carnegie Mellon University. The name of the
takashiyamanoue 0:ffac63d6a7f0 45 * University may not be used to endorse or promote products derived
takashiyamanoue 0:ffac63d6a7f0 46 * from this software without specific prior written permission.
takashiyamanoue 0:ffac63d6a7f0 47 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
takashiyamanoue 0:ffac63d6a7f0 48 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
takashiyamanoue 0:ffac63d6a7f0 49 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
takashiyamanoue 0:ffac63d6a7f0 50 */
takashiyamanoue 0:ffac63d6a7f0 51
takashiyamanoue 0:ffac63d6a7f0 52 #ifndef PAP_H
takashiyamanoue 0:ffac63d6a7f0 53 #define PAP_H
takashiyamanoue 0:ffac63d6a7f0 54
takashiyamanoue 0:ffac63d6a7f0 55 #if PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
takashiyamanoue 0:ffac63d6a7f0 56
takashiyamanoue 0:ffac63d6a7f0 57 /*
takashiyamanoue 0:ffac63d6a7f0 58 * Packet header = Code, id, length.
takashiyamanoue 0:ffac63d6a7f0 59 */
takashiyamanoue 0:ffac63d6a7f0 60 #define UPAP_HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short))
takashiyamanoue 0:ffac63d6a7f0 61
takashiyamanoue 0:ffac63d6a7f0 62
takashiyamanoue 0:ffac63d6a7f0 63 /*
takashiyamanoue 0:ffac63d6a7f0 64 * UPAP codes.
takashiyamanoue 0:ffac63d6a7f0 65 */
takashiyamanoue 0:ffac63d6a7f0 66 #define UPAP_AUTHREQ 1 /* Authenticate-Request */
takashiyamanoue 0:ffac63d6a7f0 67 #define UPAP_AUTHACK 2 /* Authenticate-Ack */
takashiyamanoue 0:ffac63d6a7f0 68 #define UPAP_AUTHNAK 3 /* Authenticate-Nak */
takashiyamanoue 0:ffac63d6a7f0 69
takashiyamanoue 0:ffac63d6a7f0 70 /*
takashiyamanoue 0:ffac63d6a7f0 71 * Each interface is described by upap structure.
takashiyamanoue 0:ffac63d6a7f0 72 */
takashiyamanoue 0:ffac63d6a7f0 73 typedef struct upap_state {
takashiyamanoue 0:ffac63d6a7f0 74 int us_unit; /* Interface unit number */
takashiyamanoue 0:ffac63d6a7f0 75 const char *us_user; /* User */
takashiyamanoue 0:ffac63d6a7f0 76 int us_userlen; /* User length */
takashiyamanoue 0:ffac63d6a7f0 77 const char *us_passwd; /* Password */
takashiyamanoue 0:ffac63d6a7f0 78 int us_passwdlen; /* Password length */
takashiyamanoue 0:ffac63d6a7f0 79 int us_clientstate; /* Client state */
takashiyamanoue 0:ffac63d6a7f0 80 int us_serverstate; /* Server state */
takashiyamanoue 0:ffac63d6a7f0 81 u_char us_id; /* Current id */
takashiyamanoue 0:ffac63d6a7f0 82 int us_timeouttime; /* Timeout (seconds) for auth-req retrans. */
takashiyamanoue 0:ffac63d6a7f0 83 int us_transmits; /* Number of auth-reqs sent */
takashiyamanoue 0:ffac63d6a7f0 84 int us_maxtransmits; /* Maximum number of auth-reqs to send */
takashiyamanoue 0:ffac63d6a7f0 85 int us_reqtimeout; /* Time to wait for auth-req from peer */
takashiyamanoue 0:ffac63d6a7f0 86 } upap_state;
takashiyamanoue 0:ffac63d6a7f0 87
takashiyamanoue 0:ffac63d6a7f0 88 /*
takashiyamanoue 0:ffac63d6a7f0 89 * Client states.
takashiyamanoue 0:ffac63d6a7f0 90 */
takashiyamanoue 0:ffac63d6a7f0 91 #define UPAPCS_INITIAL 0 /* Connection down */
takashiyamanoue 0:ffac63d6a7f0 92 #define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */
takashiyamanoue 0:ffac63d6a7f0 93 #define UPAPCS_PENDING 2 /* Connection down, have requested auth */
takashiyamanoue 0:ffac63d6a7f0 94 #define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */
takashiyamanoue 0:ffac63d6a7f0 95 #define UPAPCS_OPEN 4 /* We've received an Ack */
takashiyamanoue 0:ffac63d6a7f0 96 #define UPAPCS_BADAUTH 5 /* We've received a Nak */
takashiyamanoue 0:ffac63d6a7f0 97
takashiyamanoue 0:ffac63d6a7f0 98 /*
takashiyamanoue 0:ffac63d6a7f0 99 * Server states.
takashiyamanoue 0:ffac63d6a7f0 100 */
takashiyamanoue 0:ffac63d6a7f0 101 #define UPAPSS_INITIAL 0 /* Connection down */
takashiyamanoue 0:ffac63d6a7f0 102 #define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */
takashiyamanoue 0:ffac63d6a7f0 103 #define UPAPSS_PENDING 2 /* Connection down, have requested auth */
takashiyamanoue 0:ffac63d6a7f0 104 #define UPAPSS_LISTEN 3 /* Listening for an Authenticate */
takashiyamanoue 0:ffac63d6a7f0 105 #define UPAPSS_OPEN 4 /* We've sent an Ack */
takashiyamanoue 0:ffac63d6a7f0 106 #define UPAPSS_BADAUTH 5 /* We've sent a Nak */
takashiyamanoue 0:ffac63d6a7f0 107
takashiyamanoue 0:ffac63d6a7f0 108
takashiyamanoue 0:ffac63d6a7f0 109 extern upap_state upap[];
takashiyamanoue 0:ffac63d6a7f0 110
takashiyamanoue 0:ffac63d6a7f0 111 void upap_authwithpeer (int, char *, char *);
takashiyamanoue 0:ffac63d6a7f0 112 void upap_authpeer (int);
takashiyamanoue 0:ffac63d6a7f0 113
takashiyamanoue 0:ffac63d6a7f0 114 extern struct protent pap_protent;
takashiyamanoue 0:ffac63d6a7f0 115
takashiyamanoue 0:ffac63d6a7f0 116 #endif /* PAP_SUPPORT */
takashiyamanoue 0:ffac63d6a7f0 117
takashiyamanoue 0:ffac63d6a7f0 118 #endif /* PAP_H */