Version of http://mbed.org/cookbook/NetServicesTribute with setting set the same for LPC2368

Dependents:   UDPSocketExample 24LCxx_I2CApp WeatherPlatform_pachube HvZServerLib ... more

Committer:
simon
Date:
Tue Nov 23 14:15:36 2010 +0000
Revision:
0:350011bf8be7
Experimental version for testing UDP

Who changed what in which revision?

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