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 * lcp.h - Network Link Control 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-11-05 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 * lcp.h - Link Control 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 * $Id: lcp.h,v 1.4 2010/01/18 20:49:43 goldsimon Exp $
iva2k 0:e614f7875b60 52 */
iva2k 0:e614f7875b60 53
iva2k 0:e614f7875b60 54 #ifndef LCP_H
iva2k 0:e614f7875b60 55 #define LCP_H
iva2k 0:e614f7875b60 56 /*
iva2k 0:e614f7875b60 57 * Options.
iva2k 0:e614f7875b60 58 */
iva2k 0:e614f7875b60 59 #define CI_MRU 1 /* Maximum Receive Unit */
iva2k 0:e614f7875b60 60 #define CI_ASYNCMAP 2 /* Async Control Character Map */
iva2k 0:e614f7875b60 61 #define CI_AUTHTYPE 3 /* Authentication Type */
iva2k 0:e614f7875b60 62 #define CI_QUALITY 4 /* Quality Protocol */
iva2k 0:e614f7875b60 63 #define CI_MAGICNUMBER 5 /* Magic Number */
iva2k 0:e614f7875b60 64 #define CI_PCOMPRESSION 7 /* Protocol Field Compression */
iva2k 0:e614f7875b60 65 #define CI_ACCOMPRESSION 8 /* Address/Control Field Compression */
iva2k 0:e614f7875b60 66 #define CI_CALLBACK 13 /* callback */
iva2k 0:e614f7875b60 67 #define CI_MRRU 17 /* max reconstructed receive unit; multilink */
iva2k 0:e614f7875b60 68 #define CI_SSNHF 18 /* short sequence numbers for multilink */
iva2k 0:e614f7875b60 69 #define CI_EPDISC 19 /* endpoint discriminator */
iva2k 0:e614f7875b60 70
iva2k 0:e614f7875b60 71 /*
iva2k 0:e614f7875b60 72 * LCP-specific packet types (code numbers).
iva2k 0:e614f7875b60 73 */
iva2k 0:e614f7875b60 74 #define PROTREJ 8 /* Protocol Reject */
iva2k 0:e614f7875b60 75 #define ECHOREQ 9 /* Echo Request */
iva2k 0:e614f7875b60 76 #define ECHOREP 10 /* Echo Reply */
iva2k 0:e614f7875b60 77 #define DISCREQ 11 /* Discard Request */
iva2k 0:e614f7875b60 78 #define CBCP_OPT 6 /* Use callback control protocol */
iva2k 0:e614f7875b60 79
iva2k 0:e614f7875b60 80 /*
iva2k 0:e614f7875b60 81 * The state of options is described by an lcp_options structure.
iva2k 0:e614f7875b60 82 */
iva2k 0:e614f7875b60 83 typedef struct lcp_options {
iva2k 0:e614f7875b60 84 u_int passive : 1; /* Don't die if we don't get a response */
iva2k 0:e614f7875b60 85 u_int silent : 1; /* Wait for the other end to start first */
iva2k 0:e614f7875b60 86 u_int restart : 1; /* Restart vs. exit after close */
iva2k 0:e614f7875b60 87 u_int neg_mru : 1; /* Negotiate the MRU? */
iva2k 0:e614f7875b60 88 u_int neg_asyncmap : 1; /* Negotiate the async map? */
iva2k 0:e614f7875b60 89 u_int neg_upap : 1; /* Ask for UPAP authentication? */
iva2k 0:e614f7875b60 90 u_int neg_chap : 1; /* Ask for CHAP authentication? */
iva2k 0:e614f7875b60 91 u_int neg_magicnumber : 1; /* Ask for magic number? */
iva2k 0:e614f7875b60 92 u_int neg_pcompression : 1; /* HDLC Protocol Field Compression? */
iva2k 0:e614f7875b60 93 u_int neg_accompression : 1; /* HDLC Address/Control Field Compression? */
iva2k 0:e614f7875b60 94 u_int neg_lqr : 1; /* Negotiate use of Link Quality Reports */
iva2k 0:e614f7875b60 95 u_int neg_cbcp : 1; /* Negotiate use of CBCP */
iva2k 0:e614f7875b60 96 #ifdef PPP_MULTILINK
iva2k 0:e614f7875b60 97 u_int neg_mrru : 1; /* Negotiate multilink MRRU */
iva2k 0:e614f7875b60 98 u_int neg_ssnhf : 1; /* Negotiate short sequence numbers */
iva2k 0:e614f7875b60 99 u_int neg_endpoint : 1; /* Negotiate endpoint discriminator */
iva2k 0:e614f7875b60 100 #endif
iva2k 0:e614f7875b60 101 u_short mru; /* Value of MRU */
iva2k 0:e614f7875b60 102 #ifdef PPP_MULTILINK
iva2k 0:e614f7875b60 103 u_short mrru; /* Value of MRRU, and multilink enable */
iva2k 0:e614f7875b60 104 #endif
iva2k 0:e614f7875b60 105 u_char chap_mdtype; /* which MD type (hashing algorithm) */
iva2k 0:e614f7875b60 106 u32_t asyncmap; /* Value of async map */
iva2k 0:e614f7875b60 107 u32_t magicnumber;
iva2k 0:e614f7875b60 108 int numloops; /* Number of loops during magic number neg. */
iva2k 0:e614f7875b60 109 u32_t lqr_period; /* Reporting period for LQR 1/100ths second */
iva2k 0:e614f7875b60 110 #ifdef PPP_MULTILINK
iva2k 0:e614f7875b60 111 struct epdisc endpoint; /* endpoint discriminator */
iva2k 0:e614f7875b60 112 #endif
iva2k 0:e614f7875b60 113 } lcp_options;
iva2k 0:e614f7875b60 114
iva2k 0:e614f7875b60 115 /*
iva2k 0:e614f7875b60 116 * Values for phase from BSD pppd.h based on RFC 1661.
iva2k 0:e614f7875b60 117 */
iva2k 0:e614f7875b60 118 typedef enum {
iva2k 0:e614f7875b60 119 PHASE_DEAD = 0,
iva2k 0:e614f7875b60 120 PHASE_INITIALIZE,
iva2k 0:e614f7875b60 121 PHASE_ESTABLISH,
iva2k 0:e614f7875b60 122 PHASE_AUTHENTICATE,
iva2k 0:e614f7875b60 123 PHASE_CALLBACK,
iva2k 0:e614f7875b60 124 PHASE_NETWORK,
iva2k 0:e614f7875b60 125 PHASE_TERMINATE
iva2k 0:e614f7875b60 126 } LinkPhase;
iva2k 0:e614f7875b60 127
iva2k 0:e614f7875b60 128
iva2k 0:e614f7875b60 129
iva2k 0:e614f7875b60 130 extern LinkPhase lcp_phase[NUM_PPP]; /* Phase of link session (RFC 1661) */
iva2k 0:e614f7875b60 131 extern lcp_options lcp_wantoptions[];
iva2k 0:e614f7875b60 132 extern lcp_options lcp_gotoptions[];
iva2k 0:e614f7875b60 133 extern lcp_options lcp_allowoptions[];
iva2k 0:e614f7875b60 134 extern lcp_options lcp_hisoptions[];
iva2k 0:e614f7875b60 135 extern ext_accm xmit_accm[];
iva2k 0:e614f7875b60 136
iva2k 0:e614f7875b60 137
iva2k 0:e614f7875b60 138 void lcp_init (int);
iva2k 0:e614f7875b60 139 void lcp_open (int);
iva2k 0:e614f7875b60 140 void lcp_close (int, char *);
iva2k 0:e614f7875b60 141 void lcp_lowerup (int);
iva2k 0:e614f7875b60 142 void lcp_lowerdown(int);
iva2k 0:e614f7875b60 143 void lcp_sprotrej (int, u_char *, int); /* send protocol reject */
iva2k 0:e614f7875b60 144
iva2k 0:e614f7875b60 145 extern struct protent lcp_protent;
iva2k 0:e614f7875b60 146
iva2k 0:e614f7875b60 147 /* Default number of times we receive our magic number from the peer
iva2k 0:e614f7875b60 148 before deciding the link is looped-back. */
iva2k 0:e614f7875b60 149 #define DEFLOOPBACKFAIL 10
iva2k 0:e614f7875b60 150
iva2k 0:e614f7875b60 151 #endif /* LCP_H */