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.
lwip/include/ipv4/lwip/icmp.h@0:e614f7875b60, 2010-06-12 (annotated)
- Committer:
- iva2k
- Date:
- Sat Jun 12 06:01:50 2010 +0000
- Revision:
- 0:e614f7875b60
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
iva2k | 0:e614f7875b60 | 1 | /* |
iva2k | 0:e614f7875b60 | 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. |
iva2k | 0:e614f7875b60 | 3 | * All rights reserved. |
iva2k | 0:e614f7875b60 | 4 | * |
iva2k | 0:e614f7875b60 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
iva2k | 0:e614f7875b60 | 6 | * are permitted provided that the following conditions are met: |
iva2k | 0:e614f7875b60 | 7 | * |
iva2k | 0:e614f7875b60 | 8 | * 1. Redistributions of source code must retain the above copyright notice, |
iva2k | 0:e614f7875b60 | 9 | * this list of conditions and the following disclaimer. |
iva2k | 0:e614f7875b60 | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
iva2k | 0:e614f7875b60 | 11 | * this list of conditions and the following disclaimer in the documentation |
iva2k | 0:e614f7875b60 | 12 | * and/or other materials provided with the distribution. |
iva2k | 0:e614f7875b60 | 13 | * 3. The name of the author may not be used to endorse or promote products |
iva2k | 0:e614f7875b60 | 14 | * derived from this software without specific prior written permission. |
iva2k | 0:e614f7875b60 | 15 | * |
iva2k | 0:e614f7875b60 | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
iva2k | 0:e614f7875b60 | 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
iva2k | 0:e614f7875b60 | 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
iva2k | 0:e614f7875b60 | 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
iva2k | 0:e614f7875b60 | 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
iva2k | 0:e614f7875b60 | 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
iva2k | 0:e614f7875b60 | 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
iva2k | 0:e614f7875b60 | 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
iva2k | 0:e614f7875b60 | 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
iva2k | 0:e614f7875b60 | 25 | * OF SUCH DAMAGE. |
iva2k | 0:e614f7875b60 | 26 | * |
iva2k | 0:e614f7875b60 | 27 | * This file is part of the lwIP TCP/IP stack. |
iva2k | 0:e614f7875b60 | 28 | * |
iva2k | 0:e614f7875b60 | 29 | * Author: Adam Dunkels <adam@sics.se> |
iva2k | 0:e614f7875b60 | 30 | * |
iva2k | 0:e614f7875b60 | 31 | */ |
iva2k | 0:e614f7875b60 | 32 | #ifndef __LWIP_ICMP_H__ |
iva2k | 0:e614f7875b60 | 33 | #define __LWIP_ICMP_H__ |
iva2k | 0:e614f7875b60 | 34 | |
iva2k | 0:e614f7875b60 | 35 | #include "lwip/opt.h" |
iva2k | 0:e614f7875b60 | 36 | #include "lwip/pbuf.h" |
iva2k | 0:e614f7875b60 | 37 | #include "lwip/ip_addr.h" |
iva2k | 0:e614f7875b60 | 38 | #include "lwip/netif.h" |
iva2k | 0:e614f7875b60 | 39 | |
iva2k | 0:e614f7875b60 | 40 | #ifdef __cplusplus |
iva2k | 0:e614f7875b60 | 41 | extern "C" { |
iva2k | 0:e614f7875b60 | 42 | #endif |
iva2k | 0:e614f7875b60 | 43 | |
iva2k | 0:e614f7875b60 | 44 | #define ICMP_ER 0 /* echo reply */ |
iva2k | 0:e614f7875b60 | 45 | #define ICMP_DUR 3 /* destination unreachable */ |
iva2k | 0:e614f7875b60 | 46 | #define ICMP_SQ 4 /* source quench */ |
iva2k | 0:e614f7875b60 | 47 | #define ICMP_RD 5 /* redirect */ |
iva2k | 0:e614f7875b60 | 48 | #define ICMP_ECHO 8 /* echo */ |
iva2k | 0:e614f7875b60 | 49 | #define ICMP_TE 11 /* time exceeded */ |
iva2k | 0:e614f7875b60 | 50 | #define ICMP_PP 12 /* parameter problem */ |
iva2k | 0:e614f7875b60 | 51 | #define ICMP_TS 13 /* timestamp */ |
iva2k | 0:e614f7875b60 | 52 | #define ICMP_TSR 14 /* timestamp reply */ |
iva2k | 0:e614f7875b60 | 53 | #define ICMP_IRQ 15 /* information request */ |
iva2k | 0:e614f7875b60 | 54 | #define ICMP_IR 16 /* information reply */ |
iva2k | 0:e614f7875b60 | 55 | |
iva2k | 0:e614f7875b60 | 56 | enum icmp_dur_type { |
iva2k | 0:e614f7875b60 | 57 | ICMP_DUR_NET = 0, /* net unreachable */ |
iva2k | 0:e614f7875b60 | 58 | ICMP_DUR_HOST = 1, /* host unreachable */ |
iva2k | 0:e614f7875b60 | 59 | ICMP_DUR_PROTO = 2, /* protocol unreachable */ |
iva2k | 0:e614f7875b60 | 60 | ICMP_DUR_PORT = 3, /* port unreachable */ |
iva2k | 0:e614f7875b60 | 61 | ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ |
iva2k | 0:e614f7875b60 | 62 | ICMP_DUR_SR = 5 /* source route failed */ |
iva2k | 0:e614f7875b60 | 63 | }; |
iva2k | 0:e614f7875b60 | 64 | |
iva2k | 0:e614f7875b60 | 65 | enum icmp_te_type { |
iva2k | 0:e614f7875b60 | 66 | ICMP_TE_TTL = 0, /* time to live exceeded in transit */ |
iva2k | 0:e614f7875b60 | 67 | ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */ |
iva2k | 0:e614f7875b60 | 68 | }; |
iva2k | 0:e614f7875b60 | 69 | |
iva2k | 0:e614f7875b60 | 70 | #ifdef PACK_STRUCT_USE_INCLUDES |
iva2k | 0:e614f7875b60 | 71 | # include "arch/bpstruct.h" |
iva2k | 0:e614f7875b60 | 72 | #endif |
iva2k | 0:e614f7875b60 | 73 | /** This is the standard ICMP header only that the u32_t data |
iva2k | 0:e614f7875b60 | 74 | * is splitted to two u16_t like ICMP echo needs it. |
iva2k | 0:e614f7875b60 | 75 | * This header is also used for other ICMP types that do not |
iva2k | 0:e614f7875b60 | 76 | * use the data part. |
iva2k | 0:e614f7875b60 | 77 | */ |
iva2k | 0:e614f7875b60 | 78 | PACK_STRUCT_BEGIN |
iva2k | 0:e614f7875b60 | 79 | struct icmp_echo_hdr { |
iva2k | 0:e614f7875b60 | 80 | PACK_STRUCT_FIELD(u8_t type); |
iva2k | 0:e614f7875b60 | 81 | PACK_STRUCT_FIELD(u8_t code); |
iva2k | 0:e614f7875b60 | 82 | PACK_STRUCT_FIELD(u16_t chksum); |
iva2k | 0:e614f7875b60 | 83 | PACK_STRUCT_FIELD(u16_t id); |
iva2k | 0:e614f7875b60 | 84 | PACK_STRUCT_FIELD(u16_t seqno); |
iva2k | 0:e614f7875b60 | 85 | } PACK_STRUCT_STRUCT; |
iva2k | 0:e614f7875b60 | 86 | PACK_STRUCT_END |
iva2k | 0:e614f7875b60 | 87 | #ifdef PACK_STRUCT_USE_INCLUDES |
iva2k | 0:e614f7875b60 | 88 | # include "arch/epstruct.h" |
iva2k | 0:e614f7875b60 | 89 | #endif |
iva2k | 0:e614f7875b60 | 90 | |
iva2k | 0:e614f7875b60 | 91 | #define ICMPH_TYPE(hdr) ((hdr)->type) |
iva2k | 0:e614f7875b60 | 92 | #define ICMPH_CODE(hdr) ((hdr)->code) |
iva2k | 0:e614f7875b60 | 93 | |
iva2k | 0:e614f7875b60 | 94 | /** Combines type and code to an u16_t */ |
iva2k | 0:e614f7875b60 | 95 | #define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t)) |
iva2k | 0:e614f7875b60 | 96 | #define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c)) |
iva2k | 0:e614f7875b60 | 97 | |
iva2k | 0:e614f7875b60 | 98 | |
iva2k | 0:e614f7875b60 | 99 | #if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ |
iva2k | 0:e614f7875b60 | 100 | |
iva2k | 0:e614f7875b60 | 101 | void icmp_input(struct pbuf *p, struct netif *inp); |
iva2k | 0:e614f7875b60 | 102 | void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); |
iva2k | 0:e614f7875b60 | 103 | void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); |
iva2k | 0:e614f7875b60 | 104 | |
iva2k | 0:e614f7875b60 | 105 | #endif /* LWIP_ICMP */ |
iva2k | 0:e614f7875b60 | 106 | |
iva2k | 0:e614f7875b60 | 107 | #ifdef __cplusplus |
iva2k | 0:e614f7875b60 | 108 | } |
iva2k | 0:e614f7875b60 | 109 | #endif |
iva2k | 0:e614f7875b60 | 110 | |
iva2k | 0:e614f7875b60 | 111 | #endif /* __LWIP_ICMP_H__ */ |