Contains example code to connect the mbed LPC1768 or FRDM-K64F devices to the IBM Internet of Things Cloud service via ethernet.

Dependencies:   C12832 MQTT LM75B MMA7660

Dependents:   MFT_IoT_demo_USB400 IBM_RFID

Committer:
samdanbury
Date:
Wed Aug 20 12:45:14 2014 +0000
Revision:
6:37b6d0d56190
Code completely changed to improve the structure, flow and memory usage of the application

Who changed what in which revision?

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