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