MeterLogger
icmp.c
Go to the documentation of this file.
1 /**
2  * @file
3  * ICMP - Internet Control Message Protocol
4  *
5  */
6 
7 /*
8  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without modification,
12  * are permitted provided that the following conditions are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  * 3. The name of the author may not be used to endorse or promote products
20  * derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31  * OF SUCH DAMAGE.
32  *
33  * This file is part of the lwIP TCP/IP stack.
34  *
35  * Author: Adam Dunkels <adam@sics.se>
36  *
37  */
38 
39 /* Some ICMP messages should be passed to the transport protocols. This
40  is not implemented. */
41 
42 #include "lwip/opt.h"
43 
44 #if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
45 
46 #include "lwip/icmp.h"
47 #include "lwip/inet_chksum.h"
48 #include "lwip/ip.h"
49 #include "lwip/def.h"
50 #include "lwipopts.h"
51 #include "lwip/stats.h"
52 #include "lwip/snmp.h"
53 
54 #include <string.h>
55 
56 /** Small optimization: set to 0 if incoming PBUF_POOL pbuf always can be
57  * used to modify and send a response packet (and to 1 if this is not the case,
58  * e.g. when link header is stripped of when receiving) */
59 #ifndef LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN
60 #define LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN 1
61 #endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */
62 
63 /* The amount of data from the original packet to return in a dest-unreachable */
64 #define ICMP_DEST_UNREACH_DATASIZE 8
65 
66 static void icmp_send_response(struct pbuf *p, u8_t type, u8_t code);
67 
68 /**
69  * Processes ICMP input packets, called from ip_input().
70  *
71  * Currently only processes icmp echo requests and sends
72  * out the echo response.
73  *
74  * @param p the icmp echo request packet, p->payload pointing to the ip header
75  * @param inp the netif on which this packet was received
76  */
77 void
78 icmp_input(struct pbuf *p, struct netif *inp)
79 {
80  u8_t type;
81 #ifdef LWIP_DEBUG
82  u8_t code;
83 #endif /* LWIP_DEBUG */
84  struct icmp_echo_hdr *iecho;
85  struct ip_hdr *iphdr;
86  s16_t hlen;
87 
88  ICMP_STATS_INC(icmp.recv);
90 
91 
92  iphdr = (struct ip_hdr *)p->payload;
93  hlen = IPH_HL(iphdr) * 4;
94  if (pbuf_header(p, -hlen) || (p->tot_len < sizeof(u16_t)*2)) {
95  LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%"U16_F" bytes) received\n", p->tot_len));
96  goto lenerr;
97  }
98 
99  type = *((u8_t *)p->payload);
100 #ifdef LWIP_DEBUG
101  code = *(((u8_t *)p->payload)+1);
102 #endif /* LWIP_DEBUG */
103  switch (type) {
104  case ICMP_ER:
105  /* This is OK, echo reply might have been parsed by a raw PCB
106  (as obviously, an echo request has been sent, too). */
107  break;
108  case ICMP_ECHO:
109 #if !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING
110  {
111  int accepted = 1;
112 #if !LWIP_MULTICAST_PING
113  /* multicast destination address? */
115  accepted = 0;
116  }
117 #endif /* LWIP_MULTICAST_PING */
118 #if !LWIP_BROADCAST_PING
119  /* broadcast destination address? */
121  accepted = 0;
122  }
123 #endif /* LWIP_BROADCAST_PING */
124  /* broadcast or multicast destination address not acceptd? */
125  if (!accepted) {
126  LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: Not echoing to multicast or broadcast pings\n"));
127  ICMP_STATS_INC(icmp.err);
128  pbuf_free(p);
129  return;
130  }
131  }
132 #endif /* !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING */
133  LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n"));
134  if (p->tot_len < sizeof(struct icmp_echo_hdr)) {
135  LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
136  goto lenerr;
137  }
138  if (inet_chksum_pbuf(p) != 0) {
139  LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));
140  pbuf_free(p);
141  ICMP_STATS_INC(icmp.chkerr);
143  return;
144  }
145 #if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN
147  /* p is not big enough to contain link headers
148  * allocate a new one and copy p into it
149  */
150  struct pbuf *r;
151  /* switch p->payload to ip header */
152  if (pbuf_header(p, hlen)) {
153  LWIP_ASSERT("icmp_input: moving p->payload to ip header failed\n", 0);
154  goto memerr;
155  }
156  /* allocate new packet buffer with space for link headers */
158  if (r == NULL) {
159  LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: allocating new pbuf failed\n"));
160  goto memerr;
161  }
162  LWIP_ASSERT("check that first pbuf can hold struct the ICMP header",
163  (r->len >= hlen + sizeof(struct icmp_echo_hdr)));
164  /* copy the whole packet including ip header */
165  if (pbuf_copy(r, p) != ERR_OK) {
166  LWIP_ASSERT("icmp_input: copying to new pbuf failed\n", 0);
167  goto memerr;
168  }
169  iphdr = (struct ip_hdr *)r->payload;
170  /* switch r->payload back to icmp header */
171  if (pbuf_header(r, -hlen)) {
172  LWIP_ASSERT("icmp_input: restoring original p->payload failed\n", 0);
173  goto memerr;
174  }
175  /* free the original p */
176  pbuf_free(p);
177  /* we now have an identical copy of p that has room for link headers */
178  p = r;
179  } else {
180  /* restore p->payload to point to icmp header */
182  LWIP_ASSERT("icmp_input: restoring original p->payload failed\n", 0);
183  goto memerr;
184  }
185  }
186 #endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */
187  /* At this point, all checks are OK. */
188  /* We generate an answer by switching the dest and src ip addresses,
189  * setting the icmp type to ECHO_RESPONSE and updating the checksum. */
190  iecho = (struct icmp_echo_hdr *)p->payload;
191  ip_addr_copy(iphdr->src, *ip_current_dest_addr());
192  ip_addr_copy(iphdr->dest, *ip_current_src_addr());
193  ICMPH_TYPE_SET(iecho, ICMP_ER);
194  /* adjust the checksum */
195  if (iecho->chksum >= PP_HTONS(0xffff - (ICMP_ECHO << 8))) {
196  iecho->chksum += PP_HTONS(ICMP_ECHO << 8) + 1;
197  } else {
198  iecho->chksum += PP_HTONS(ICMP_ECHO << 8);
199  }
200 
201  /* Set the correct TTL and recalculate the header checksum. */
202  IPH_TTL_SET(iphdr, ICMP_TTL);
203  IPH_CHKSUM_SET(iphdr, 0);
204 #if CHECKSUM_GEN_IP
205  IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN));
206 #endif /* CHECKSUM_GEN_IP */
207 
208  ICMP_STATS_INC(icmp.xmit);
209  /* increase number of messages attempted to send */
211  /* increase number of echo replies attempted to send */
213 
214  if(pbuf_header(p, hlen)) {
215  LWIP_ASSERT("Can't move over header in packet", 0);
216  } else {
217  err_t ret;
218  /* send an ICMP packet, src addr is the dest addr of the curren packet */
220  ICMP_TTL, 0, IP_PROTO_ICMP, inp);
221  if (ret != ERR_OK) {
222  LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ip_output_if returned an error: %c.\n", ret));
223  }
224  }
225  break;
226  default:
227  LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" code %"S16_F" not supported.\n",
228  (s16_t)type, (s16_t)code));
229  ICMP_STATS_INC(icmp.proterr);
230  ICMP_STATS_INC(icmp.drop);
231  }
232  pbuf_free(p);
233  return;
234 lenerr:
235  pbuf_free(p);
236  ICMP_STATS_INC(icmp.lenerr);
238  return;
239 #if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN
240 memerr:
241  pbuf_free(p);
242  ICMP_STATS_INC(icmp.err);
244  return;
245 #endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */
246 }
247 
248 /**
249  * Send an icmp 'destination unreachable' packet, called from ip_input() if
250  * the transport layer protocol is unknown and from udp_input() if the local
251  * port is not bound.
252  *
253  * @param p the input packet for which the 'unreachable' should be sent,
254  * p->payload pointing to the IP header
255  * @param t type of the 'unreachable' packet
256  */
257 void
258 icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
259 {
260  icmp_send_response(p, ICMP_DUR, t);
261 }
262 
263 #if IP_FORWARD || IP_REASSEMBLY
264 /**
265  * Send a 'time exceeded' packet, called from ip_forward() if TTL is 0.
266  *
267  * @param p the input packet for which the 'time exceeded' should be sent,
268  * p->payload pointing to the IP header
269  * @param t type of the 'time exceeded' packet
270  */
271 void
272 icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
273 {
274  icmp_send_response(p, ICMP_TE, t);
275 }
276 
277 #endif /* IP_FORWARD || IP_REASSEMBLY */
278 
279 /**
280  * Send an icmp packet in response to an incoming packet.
281  *
282  * @param p the input packet for which the 'unreachable' should be sent,
283  * p->payload pointing to the IP header
284  * @param type Type of the ICMP header
285  * @param code Code of the ICMP header
286  */
287 static void ICACHE_FLASH_ATTR
288 icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
289 {
290  struct pbuf *q;
291  struct ip_hdr *iphdr;
292  /* we can use the echo header here */
293  struct icmp_echo_hdr *icmphdr;
294  ip_addr_t iphdr_src;
295 
296  /* ICMP header + IP header + 8 bytes of data */
297  //为差错报文申请pbuf空间,pbuf中预留IP首部和以太网首部空间,pbuf数据区 //长度=差错报文首部+差错报文数据长度(IP首部长度+8) q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE, PBUF_RAM); if (q == NULL) {//失败,返回 LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded: failed to allocate pbuf for ICMP packet.\n")); return; } LWIP_ASSERT("check that first pbuf can hold icmp message", (q->len >= (sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE))); iphdr = (struct ip_hdr *)p->payload;//指向引起差错的IP数据包首部 LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from ")); ip_addr_debug_print(ICMP_DEBUG, &(iphdr->src)); LWIP_DEBUGF(ICMP_DEBUG, (" to ")); ip_addr_debug_print(ICMP_DEBUG, &(iphdr->dest)); LWIP_DEBUGF(ICMP_DEBUG, ("\n")); icmphdr = (struct icmp_echo_hdr *)q->payload;//指向差错报文首部 icmphdr->type = type;//填写类型字段 icmphdr->code = code;//填写代码字段 icmphdr->id = 0;//对于目的不可达和数据报超时 icmphdr->seqno = 0;//报文,首部剩余的4个字节都为0 /* copy fields from original packet 将引起差错的IP数据报的IP首部+8字节数据拷贝到差错报文数据区*/ SMEMCPY((u8_t *)q->payload + sizeof(struct icmp_echo_hdr), (u8_t *)p->payload, IP_HLEN + ICMP_DEST_UNREACH_DATASIZE); /* calculate checksum */ icmphdr->chksum = 0;//报文校验和字段清0 icmphdr->chksum = inet_chksum(icmphdr, q->len);//计算填写校验和 ICMP_STATS_INC(icmp.xmit); /* increase number of messages attempted to send */ snmp_inc_icmpoutmsgs(); /* increase number of destination unreachable messages attempted to send */ snmp_inc_icmpouttimeexcds(); ip_addr_copy(iphdr_src, iphdr->src); ip_output(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP);//调用IP层函数输出ICMP报文 pbuf_free(q); } #endif /* LWIP_ICMP */
298  //长度=差错报文首部+差错报文数据长度(IP首部长度+8)
299  q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE,
300  PBUF_RAM);
301  if (q == NULL) {//失败,返回 LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded: failed to allocate pbuf for ICMP packet.\n")); return; } LWIP_ASSERT("check that first pbuf can hold icmp message", (q->len >= (sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE))); iphdr = (struct ip_hdr *)p->payload;//指向引起差错的IP数据包首部 LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from ")); ip_addr_debug_print(ICMP_DEBUG, &(iphdr->src)); LWIP_DEBUGF(ICMP_DEBUG, (" to ")); ip_addr_debug_print(ICMP_DEBUG, &(iphdr->dest)); LWIP_DEBUGF(ICMP_DEBUG, ("\n")); icmphdr = (struct icmp_echo_hdr *)q->payload;//指向差错报文首部 icmphdr->type = type;//填写类型字段 icmphdr->code = code;//填写代码字段 icmphdr->id = 0;//对于目的不可达和数据报超时 icmphdr->seqno = 0;//报文,首部剩余的4个字节都为0 /* copy fields from original packet 将引起差错的IP数据报的IP首部+8字节数据拷贝到差错报文数据区*/ SMEMCPY((u8_t *)q->payload + sizeof(struct icmp_echo_hdr), (u8_t *)p->payload, IP_HLEN + ICMP_DEST_UNREACH_DATASIZE); /* calculate checksum */ icmphdr->chksum = 0;//报文校验和字段清0 icmphdr->chksum = inet_chksum(icmphdr, q->len);//计算填写校验和 ICMP_STATS_INC(icmp.xmit); /* increase number of messages attempted to send */ snmp_inc_icmpoutmsgs(); /* increase number of destination unreachable messages attempted to send */ snmp_inc_icmpouttimeexcds(); ip_addr_copy(iphdr_src, iphdr->src); ip_output(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP);//调用IP层函数输出ICMP报文 pbuf_free(q); } #endif /* LWIP_ICMP */
302  LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded: failed to allocate pbuf for ICMP packet.\n"));
303  return;
304  }
305  LWIP_ASSERT("check that first pbuf can hold icmp message",
306  (q->len >= (sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE)));
307 
308  iphdr = (struct ip_hdr *)p->payload;//指向引起差错的IP数据包首部
309  LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from "));
310  ip_addr_debug_print(ICMP_DEBUG, &(iphdr->src));
311  LWIP_DEBUGF(ICMP_DEBUG, (" to "));
312  ip_addr_debug_print(ICMP_DEBUG, &(iphdr->dest));
313  LWIP_DEBUGF(ICMP_DEBUG, ("\n"));
314 
315  icmphdr = (struct icmp_echo_hdr *)q->payload;//指向差错报文首部
316  icmphdr->type = type;//填写类型字段 icmphdr->code = code;//填写代码字段 icmphdr->id = 0;//对于目的不可达和数据报超时 icmphdr->seqno = 0;//报文,首部剩余的4个字节都为0 /* copy fields from original packet 将引起差错的IP数据报的IP首部+8字节数据拷贝到差错报文数据区*/ SMEMCPY((u8_t *)q->payload + sizeof(struct icmp_echo_hdr), (u8_t *)p->payload, IP_HLEN + ICMP_DEST_UNREACH_DATASIZE); /* calculate checksum */ icmphdr->chksum = 0;//报文校验和字段清0 icmphdr->chksum = inet_chksum(icmphdr, q->len);//计算填写校验和 ICMP_STATS_INC(icmp.xmit); /* increase number of messages attempted to send */ snmp_inc_icmpoutmsgs(); /* increase number of destination unreachable messages attempted to send */ snmp_inc_icmpouttimeexcds(); ip_addr_copy(iphdr_src, iphdr->src); ip_output(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP);//调用IP层函数输出ICMP报文 pbuf_free(q); } #endif /* LWIP_ICMP */
317  icmphdr->code = code;//填写代码字段 icmphdr->id = 0;//对于目的不可达和数据报超时 icmphdr->seqno = 0;//报文,首部剩余的4个字节都为0 /* copy fields from original packet 将引起差错的IP数据报的IP首部+8字节数据拷贝到差错报文数据区*/ SMEMCPY((u8_t *)q->payload + sizeof(struct icmp_echo_hdr), (u8_t *)p->payload, IP_HLEN + ICMP_DEST_UNREACH_DATASIZE); /* calculate checksum */ icmphdr->chksum = 0;//报文校验和字段清0 icmphdr->chksum = inet_chksum(icmphdr, q->len);//计算填写校验和 ICMP_STATS_INC(icmp.xmit); /* increase number of messages attempted to send */ snmp_inc_icmpoutmsgs(); /* increase number of destination unreachable messages attempted to send */ snmp_inc_icmpouttimeexcds(); ip_addr_copy(iphdr_src, iphdr->src); ip_output(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP);//调用IP层函数输出ICMP报文 pbuf_free(q); } #endif /* LWIP_ICMP */
318  icmphdr->id = 0;//对于目的不可达和数据报超时
319  icmphdr->seqno = 0;//报文,首部剩余的4个字节都为0
320 
321  /* copy fields from original packet 将引起差错的IP数据报的IP首部+8字节数据拷贝到差错报文数据区/ SMEMCPY((u8_t *)q->payload + sizeof(struct icmp_echo_hdr), (u8_t *)p->payload, IP_HLEN + ICMP_DEST_UNREACH_DATASIZE); /* calculate checksum */ icmphdr->chksum = 0;//报文校验和字段清0 icmphdr->chksum = inet_chksum(icmphdr, q->len);//计算填写校验和 ICMP_STATS_INC(icmp.xmit); /* increase number of messages attempted to send */ snmp_inc_icmpoutmsgs(); /* increase number of destination unreachable messages attempted to send */ snmp_inc_icmpouttimeexcds(); ip_addr_copy(iphdr_src, iphdr->src); ip_output(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP);//调用IP层函数输出ICMP报文 pbuf_free(q); } #endif /* LWIP_ICMP */ */
322  SMEMCPY((u8_t *)q->payload + sizeof(struct icmp_echo_hdr), (u8_t *)p->payload,
323  IP_HLEN + ICMP_DEST_UNREACH_DATASIZE);
324 
325  /* calculate checksum */
326  icmphdr->chksum = 0;//报文校验和字段清0
327  icmphdr->chksum = inet_chksum(icmphdr, q->len);//计算填写校验和 ICMP_STATS_INC(icmp.xmit); /* increase number of messages attempted to send */ snmp_inc_icmpoutmsgs(); /* increase number of destination unreachable messages attempted to send */ snmp_inc_icmpouttimeexcds(); ip_addr_copy(iphdr_src, iphdr->src); ip_output(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP);//调用IP层函数输出ICMP报文 pbuf_free(q); } #endif /* LWIP_ICMP */
328  ICMP_STATS_INC(icmp.xmit);
329  /* increase number of messages attempted to send */
331  /* increase number of destination unreachable messages attempted to send */
333  ip_addr_copy(iphdr_src, iphdr->src);
334  ip_output(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP);//调用IP层函数输出ICMP报文
335  pbuf_free(q);
336 }
337 
338 #endif /* LWIP_ICMP */
#define IP_PROTO_ICMP
Definition: ip.h:52
u16_t tot_len
Definition: pbuf.h:90
#define ICMP_ECHO
Definition: icmp.h:48
#define SMEMCPY(dst, src, len)
Definition: opt.h:92
u16_t len
Definition: pbuf.h:93
err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from) ICACHE_FLASH_ATTR
Definition: pbuf.c:930
u16_t inet_chksum(void *dataptr, u16_t len) ICACHE_FLASH_ATTR
Definition: inet_chksum.c:396
#define ip_current_src_addr()
Definition: ip.h:199
#define U16_F
Definition: cc.h:61
signed short s16_t
Definition: cc.h:55
ip_addr_t current_iphdr_dest
Definition: ip.c:110
#define ICMP_ER
Definition: icmp.h:44
#define ICMP_TTL
Definition: opt.h:617
#define NULL
Definition: def.h:47
#define ip_addr_debug_print(debug, ipaddr)
Definition: ip_addr.h:212
#define PBUF_IP_HLEN
Definition: pbuf.h:48
#define ICACHE_FLASH_ATTR
Definition: c_types.h:99
#define ICMP_STATS_INC(x)
Definition: stats.h:187
#define ip_current_dest_addr()
Definition: ip.h:201
#define IPH_HL(hdr)
Definition: ip.h:145
#define IP_HDRINCL
Definition: ip.h:64
Definition: pbuf.h:58
Definition: pbuf.h:53
#define snmp_inc_icmpoutmsgs()
Definition: snmp.h:297
#define ICMP_TE
Definition: icmp.h:49
#define PP_HTONS(x)
Definition: def.h:92
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:94
#define ip_addr_copy(dest, src)
Definition: ip_addr.h:162
u16_t inet_chksum_pbuf(struct pbuf *p) ICACHE_FLASH_ATTR
Definition: inet_chksum.c:409
#define ERR_OK
Definition: err.h:52
err_t ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto, struct netif *netif) ICACHE_FLASH_ATTR
Definition: ip.c:1259
#define snmp_inc_icmpouttimeexcds()
Definition: snmp.h:300
Definition: pbuf.h:76
s8_t err_t
Definition: err.h:47
#define snmp_inc_icmpinerrors()
Definition: snmp.h:285
icmp_te_type
Definition: icmp.h:65
typedefPACK_STRUCT_END struct ip_addr ip_addr_t
Definition: ip_addr.h:64
Definition: netif.h:139
#define ICMP_DUR
Definition: icmp.h:45
icmp_dur_type
Definition: icmp.h:56
#define IPH_CHKSUM_SET(hdr, chksum)
Definition: ip.h:160
#define S16_F
Definition: cc.h:60
u8_t pbuf_free(struct pbuf *p) ICACHE_FLASH_ATTR
Definition: pbuf.c:685
#define IPH_TTL_SET(hdr, ttl)
Definition: ip.h:158
#define ip_addr_isbroadcast(ipaddr, netif)
Definition: ip_addr.h:202
Definition: ip.h:116
#define IP_HLEN
Definition: ip.h:50
u8_t pbuf_header(struct pbuf *p, s16_t header_size) ICACHE_FLASH_ATTR
Definition: pbuf.c:573
unsigned char u8_t
Definition: cc.h:52
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:65
void * payload
Definition: pbuf.h:81
Definition: pbuf.h:52
#define ICMP_DEBUG
Definition: opt.h:1854
err_t ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto) ICACHE_FLASH_ATTR
Definition: ip.c:1435
#define PBUF_LINK_HLEN
Definition: opt.h:1061
#define ip_addr_ismulticast(addr1)
Definition: ip_addr.h:208
#define snmp_inc_icmpoutechoreps()
Definition: snmp.h:305
struct pbuf * pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type) ICACHE_FLASH_ATTR
Definition: pbuf.c:234
unsigned short u16_t
Definition: cc.h:54
#define snmp_inc_icmpinmsgs()
Definition: snmp.h:284
#define ICMPH_TYPE_SET(hdr, t)
Definition: icmp.h:99