Committer:
donatien
Date:
Fri Aug 06 10:42:05 2010 +0000
Revision:
3:e02ec42cf9c8
Parent:
0:0f5a52711275

        

Who changed what in which revision?

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