Dependents:   SNMPAgent HTTPServer think_speak_a cyassl-client ... more

Committer:
mamezu
Date:
Thu Dec 09 01:33:56 2010 +0000
Revision:
0:0f6c82fcde82

        

Who changed what in which revision?

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