Committer:
mbed714
Date:
Sat Sep 18 23:05:49 2010 +0000
Revision:
0:d616ece2d859

        

Who changed what in which revision?

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