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