55 |
|
|
56 |
#include "arch/perf.h" |
#include "arch/perf.h" |
57 |
|
|
58 |
#if LWIP_SNMP > 0 |
#include "snmp.h" |
|
# include "snmp.h" |
|
|
#endif |
|
59 |
#if LWIP_DHCP |
#if LWIP_DHCP |
60 |
#include "lwip/dhcp.h" |
#include "lwip/dhcp.h" |
61 |
#endif /* LWIP_DHCP */ |
#endif /* LWIP_DHCP */ |
167 |
if(netif == NULL) { |
if(netif == NULL) { |
168 |
DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for 0x%lx found\n", |
DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for 0x%lx found\n", |
169 |
iphdr->dest.addr)); |
iphdr->dest.addr)); |
|
#if LWIP_SNMP > 0 |
|
170 |
snmp_inc_ipnoroutes(); |
snmp_inc_ipnoroutes(); |
|
#endif |
|
171 |
return; |
return; |
172 |
} |
} |
173 |
/* Do not forward packets onto the same network interface on which |
/* Do not forward packets onto the same network interface on which |
174 |
they arrived. */ |
they arrived. */ |
175 |
if(netif == inp) { |
if(netif == inp) { |
176 |
DEBUGF(IP_DEBUG, ("ip_forward: not bouncing packets back on incoming interface.\n")); |
DEBUGF(IP_DEBUG, ("ip_forward: not bouncing packets back on incoming interface.\n")); |
|
#if LWIP_SNMP > 0 |
|
177 |
snmp_inc_ipnoroutes(); |
snmp_inc_ipnoroutes(); |
|
#endif |
|
178 |
return; |
return; |
179 |
} |
} |
180 |
|
|
185 |
/* Don't send ICMP messages in response to ICMP messages */ |
/* Don't send ICMP messages in response to ICMP messages */ |
186 |
if(IPH_PROTO(iphdr) != IP_PROTO_ICMP) { |
if(IPH_PROTO(iphdr) != IP_PROTO_ICMP) { |
187 |
icmp_time_exceeded(p, ICMP_TE_TTL); |
icmp_time_exceeded(p, ICMP_TE_TTL); |
|
#if LWIP_SNMP > 0 |
|
188 |
snmp_inc_icmpouttimeexcds(); |
snmp_inc_icmpouttimeexcds(); |
|
#endif |
|
189 |
} |
} |
190 |
return; |
return; |
191 |
} |
} |
204 |
++lwip_stats.ip.fw; |
++lwip_stats.ip.fw; |
205 |
++lwip_stats.ip.xmit; |
++lwip_stats.ip.xmit; |
206 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
|
#if LWIP_SNMP > 0 |
|
207 |
snmp_inc_ipforwdatagrams(); |
snmp_inc_ipforwdatagrams(); |
|
#endif |
|
208 |
|
|
209 |
PERF_STOP("ip_forward"); |
PERF_STOP("ip_forward"); |
210 |
/* transmit pbuf on chosen interface */ |
/* transmit pbuf on chosen interface */ |
232 |
#ifdef IP_STATS |
#ifdef IP_STATS |
233 |
++lwip_stats.ip.recv; |
++lwip_stats.ip.recv; |
234 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
235 |
#if LWIP_SNMP > 0 |
snmp_inc_ipinreceives(); |
|
snmp_inc_ipinreceives(); |
|
|
#endif |
|
236 |
|
|
237 |
/* identify the IP header */ |
/* identify the IP header */ |
238 |
iphdr = p->payload; |
iphdr = p->payload; |
246 |
++lwip_stats.ip.err; |
++lwip_stats.ip.err; |
247 |
++lwip_stats.ip.drop; |
++lwip_stats.ip.drop; |
248 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
|
#if LWIP_SNMP > 0 |
|
249 |
snmp_inc_ipunknownprotos(); |
snmp_inc_ipunknownprotos(); |
|
#endif |
|
250 |
return ERR_OK; |
return ERR_OK; |
251 |
} |
} |
252 |
/* obtain IP header length in number of 32-bit words */ |
/* obtain IP header length in number of 32-bit words */ |
264 |
++lwip_stats.ip.lenerr; |
++lwip_stats.ip.lenerr; |
265 |
++lwip_stats.ip.drop; |
++lwip_stats.ip.drop; |
266 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
|
#if LWIP_SNMP > 0 |
|
267 |
snmp_inc_ipindiscards(); |
snmp_inc_ipindiscards(); |
|
#endif |
|
268 |
return ERR_OK; |
return ERR_OK; |
269 |
} |
} |
270 |
|
|
280 |
++lwip_stats.ip.chkerr; |
++lwip_stats.ip.chkerr; |
281 |
++lwip_stats.ip.drop; |
++lwip_stats.ip.drop; |
282 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
|
#if LWIP_SNMP > 0 |
|
283 |
snmp_inc_ipindiscards(); |
snmp_inc_ipindiscards(); |
|
#endif |
|
284 |
return ERR_OK; |
return ERR_OK; |
285 |
} |
} |
286 |
|
|
343 |
else |
else |
344 |
#endif /* IP_FORWARD */ |
#endif /* IP_FORWARD */ |
345 |
{ |
{ |
|
#if LWIP_SNMP > 0 |
|
346 |
snmp_inc_ipindiscards(); |
snmp_inc_ipindiscards(); |
|
#endif |
|
347 |
} |
} |
348 |
pbuf_free(p); |
pbuf_free(p); |
349 |
return ERR_OK; |
return ERR_OK; |
367 |
++lwip_stats.ip.opterr; |
++lwip_stats.ip.opterr; |
368 |
++lwip_stats.ip.drop; |
++lwip_stats.ip.drop; |
369 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
|
#if LWIP_SNMP > 0 |
|
370 |
snmp_inc_ipunknownprotos(); |
snmp_inc_ipunknownprotos(); |
|
#endif |
|
371 |
return ERR_OK; |
return ERR_OK; |
372 |
} |
} |
373 |
#endif /* IP_REASSEMBLY */ |
#endif /* IP_REASSEMBLY */ |
380 |
++lwip_stats.ip.opterr; |
++lwip_stats.ip.opterr; |
381 |
++lwip_stats.ip.drop; |
++lwip_stats.ip.drop; |
382 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
|
#if LWIP_SNMP > 0 |
|
383 |
snmp_inc_ipunknownprotos(); |
snmp_inc_ipunknownprotos(); |
|
#endif |
|
384 |
return ERR_OK; |
return ERR_OK; |
385 |
} |
} |
386 |
#endif /* IP_OPTIONS == 0 */ |
#endif /* IP_OPTIONS == 0 */ |
395 |
switch(IPH_PROTO(iphdr)) { |
switch(IPH_PROTO(iphdr)) { |
396 |
#if LWIP_UDP > 0 |
#if LWIP_UDP > 0 |
397 |
case IP_PROTO_UDP: |
case IP_PROTO_UDP: |
|
#if LWIP_SNMP > 0 |
|
398 |
snmp_inc_ipindelivers(); |
snmp_inc_ipindelivers(); |
|
#endif |
|
399 |
udp_input(p, inp); |
udp_input(p, inp); |
400 |
break; |
break; |
401 |
#endif /* LWIP_UDP */ |
#endif /* LWIP_UDP */ |
402 |
#if LWIP_TCP > 0 |
#if LWIP_TCP > 0 |
403 |
case IP_PROTO_TCP: |
case IP_PROTO_TCP: |
|
#if LWIP_SNMP > 0 |
|
404 |
snmp_inc_ipindelivers(); |
snmp_inc_ipindelivers(); |
|
#endif |
|
405 |
tcp_input(p, inp); |
tcp_input(p, inp); |
406 |
break; |
break; |
407 |
#endif /* LWIP_TCP */ |
#endif /* LWIP_TCP */ |
408 |
case IP_PROTO_ICMP: |
case IP_PROTO_ICMP: |
|
#if LWIP_SNMP > 0 |
|
409 |
snmp_inc_ipindelivers(); |
snmp_inc_ipindelivers(); |
|
#endif |
|
410 |
icmp_input(p, inp); |
icmp_input(p, inp); |
411 |
break; |
break; |
412 |
default: |
default: |
424 |
++lwip_stats.ip.proterr; |
++lwip_stats.ip.proterr; |
425 |
++lwip_stats.ip.drop; |
++lwip_stats.ip.drop; |
426 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
|
#if LWIP_SNMP > 0 |
|
427 |
snmp_inc_ipunknownprotos(); |
snmp_inc_ipunknownprotos(); |
|
#endif |
|
428 |
|
|
429 |
} |
} |
430 |
return ERR_OK; |
return ERR_OK; |
447 |
static struct ip_hdr *iphdr; |
static struct ip_hdr *iphdr; |
448 |
static u16_t ip_id = 0; |
static u16_t ip_id = 0; |
449 |
|
|
450 |
|
snmp_inc_ipoutrequests(); |
|
#if LWIP_SNMP > 0 |
|
|
snmp_inc_ipoutrequests(); |
|
|
#endif |
|
451 |
|
|
452 |
if(dest != IP_HDRINCL) { |
if(dest != IP_HDRINCL) { |
453 |
if(pbuf_header(p, IP_HLEN)) { |
if(pbuf_header(p, IP_HLEN)) { |
456 |
#ifdef IP_STATS |
#ifdef IP_STATS |
457 |
++lwip_stats.ip.err; |
++lwip_stats.ip.err; |
458 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
459 |
#if LWIP_SNMP > 0 |
snmp_inc_ipoutdiscards(); |
|
snmp_inc_ipoutdiscards(); |
|
|
#endif |
|
460 |
return ERR_BUF; |
return ERR_BUF; |
461 |
} |
} |
462 |
|
|
523 |
#ifdef IP_STATS |
#ifdef IP_STATS |
524 |
++lwip_stats.ip.rterr; |
++lwip_stats.ip.rterr; |
525 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
|
#if LWIP_SNMP > 0 |
|
526 |
snmp_inc_ipoutdiscards(); |
snmp_inc_ipoutdiscards(); |
|
#endif |
|
527 |
return ERR_RTE; |
return ERR_RTE; |
528 |
} |
} |
529 |
|
|