STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
icmp.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25  * OF SUCH DAMAGE.
26  *
27  * This file is part of the lwIP TCP/IP stack.
28  *
29  * Author: Adam Dunkels <adam@sics.se>
30  *
31  */
32 #ifndef LWIP_HDR_ICMP_H
33 #define LWIP_HDR_ICMP_H
34 
35 #include "lwip/opt.h"
36 #include "lwip/pbuf.h"
37 #include "lwip/ip_addr.h"
38 #include "lwip/netif.h"
39 
40 #if LWIP_IPV6 && LWIP_ICMP6
41 #include "lwip/icmp6.h"
42 #endif
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 #define ICMP_ER 0 /* echo reply */
49 #define ICMP_DUR 3 /* destination unreachable */
50 #define ICMP_SQ 4 /* source quench */
51 #define ICMP_RD 5 /* redirect */
52 #define ICMP_ECHO 8 /* echo */
53 #define ICMP_TE 11 /* time exceeded */
54 #define ICMP_PP 12 /* parameter problem */
55 #define ICMP_TS 13 /* timestamp */
56 #define ICMP_TSR 14 /* timestamp reply */
57 #define ICMP_IRQ 15 /* information request */
58 #define ICMP_IR 16 /* information reply */
59 #define ICMP_AM 17 /* address mask request */
60 #define ICMP_AMR 18 /* address mask reply */
61 
63  ICMP_DUR_NET = 0, /* net unreachable */
64  ICMP_DUR_HOST = 1, /* host unreachable */
65  ICMP_DUR_PROTO = 2, /* protocol unreachable */
66  ICMP_DUR_PORT = 3, /* port unreachable */
67  ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */
68  ICMP_DUR_SR = 5 /* source route failed */
69 };
70 
72  ICMP_TE_TTL = 0, /* time to live exceeded in transit */
73  ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */
74 };
75 
76 #ifdef PACK_STRUCT_USE_INCLUDES
77 # include "arch/bpstruct.h"
78 #endif
79 
85 struct icmp_echo_hdr {
86  PACK_STRUCT_FLD_8(u8_t type);
87  PACK_STRUCT_FLD_8(u8_t code);
88  PACK_STRUCT_FIELD(u16_t chksum);
90  PACK_STRUCT_FIELD(u16_t seqno);
93 #ifdef PACK_STRUCT_USE_INCLUDES
94 # include "arch/epstruct.h"
95 #endif
96 
97 #define ICMPH_TYPE(hdr) ((hdr)->type)
98 #define ICMPH_CODE(hdr) ((hdr)->code)
99 
101 #define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t))
102 #define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c))
103 
104 
105 #if LWIP_IPV4 && LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
106 
107 void icmp_input(struct pbuf *p, struct netif *inp);
108 void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
109 void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);
110 
111 #endif /* LWIP_IPV4 && LWIP_ICMP */
112 
113 #if LWIP_IPV4 && LWIP_IPV6
114 #if LWIP_ICMP && LWIP_ICMP6
115 #define icmp_port_unreach(isipv6, pbuf) ((isipv6) ? \
116  icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT) : \
117  icmp_dest_unreach(pbuf, ICMP_DUR_PORT))
118 #elif LWIP_ICMP
119 #define icmp_port_unreach(isipv6, pbuf) do{ if(!(isipv6)) { icmp_dest_unreach(pbuf, ICMP_DUR_PORT);}}while(0)
120 #elif LWIP_ICMP6
121 #define icmp_port_unreach(isipv6, pbuf) do{ if(isipv6) { icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT);}}while(0)
122 #else
123 #define icmp_port_unreach(isipv6, pbuf)
124 #endif
125 #elif LWIP_IPV6 && LWIP_ICMP6
126 #define icmp_port_unreach(isipv6, pbuf) icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT)
127 #elif LWIP_IPV4 && LWIP_ICMP
128 #define icmp_port_unreach(isipv6, pbuf) icmp_dest_unreach(pbuf, ICMP_DUR_PORT)
129 #else /* (LWIP_IPV6 && LWIP_ICMP6) || (LWIP_IPV4 && LWIP_ICMP) */
130 #define icmp_port_unreach(isipv6, pbuf)
131 #endif /* (LWIP_IPV6 && LWIP_ICMP6) || (LWIP_IPV4 && LWIP_ICMP) LWIP_IPV4*/
132 
133 #ifdef __cplusplus
134 }
135 #endif
136 
137 #endif /* LWIP_HDR_ICMP_H */
138 
PACK_STRUCT_FIELD(u16_t chksum)
Definition: pbuf.h:108
icmp_te_type
Definition: icmp.h:71
Definition: netif.h:182
PACK_STRUCT_FLD_8(u8_t type)
icmp_dur_type
Definition: icmp.h:62
#define PACK_STRUCT_BEGIN
Definition: arch.h:60
unsigned char u8_t
Definition: cc.h:38
#define PACK_STRUCT_END
Definition: arch.h:64
PACK_STRUCT_BEGIN struct icmp_echo_hdr PACK_STRUCT_STRUCT
unsigned short u16_t
Definition: cc.h:40