Example program with HTTPServer and sensor data streaming over TCPSockets, using Donatien Garnier's Net APIs and services code on top of LWIP. Files StreamServer.h and .cpp encapsulate streaming over TCPSockets. Broadcast is done by sendToAll(), and all incoming data is echoed back to the client. Echo code can be replaced with some remote control of the streaming interface. See main() that shows how to periodically send some data to all subscribed clients. To subscribe, a client should open a socket at <mbed_ip> port 123. I used few lines in TCL code to set up a quick sink for the data. HTTP files are served on port 80 concurrently to the streaming.

Dependencies:   mbed

Committer:
iva2k
Date:
Sat Jun 12 06:01:50 2010 +0000
Revision:
0:e614f7875b60

        

Who changed what in which revision?

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