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