54 |
|
|
55 |
#include "arch/perf.h" |
#include "arch/perf.h" |
56 |
|
|
57 |
|
#if LWIP_SNMP > 0 |
58 |
|
# include "snmp.h" |
59 |
|
#endif |
60 |
#if LWIP_DHCP |
#if LWIP_DHCP |
61 |
#include "lwip/dhcp.h" |
#include "lwip/dhcp.h" |
62 |
#endif /* LWIP_DHCP */ |
#endif /* LWIP_DHCP */ |
166 |
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", |
167 |
iphdr->dest.addr)); |
iphdr->dest.addr)); |
168 |
|
|
169 |
|
#if LWIP_SNMP > 0 |
170 |
|
snmp_inc_ipnoroutes(); |
171 |
|
#endif |
172 |
return; |
return; |
173 |
} |
} |
174 |
|
|
177 |
if(netif == inp) { |
if(netif == inp) { |
178 |
DEBUGF(IP_DEBUG, ("ip_forward: not forward packets back on incoming interface.\n")); |
DEBUGF(IP_DEBUG, ("ip_forward: not forward packets back on incoming interface.\n")); |
179 |
|
|
180 |
|
#if LWIP_SNMP > 0 |
181 |
|
snmp_inc_ipnoroutes(); |
182 |
|
#endif |
183 |
return; |
return; |
184 |
} |
} |
185 |
|
|
189 |
/* Don't send ICMP messages in response to ICMP messages */ |
/* Don't send ICMP messages in response to ICMP messages */ |
190 |
if(IPH_PROTO(iphdr) != IP_PROTO_ICMP) { |
if(IPH_PROTO(iphdr) != IP_PROTO_ICMP) { |
191 |
icmp_time_exceeded(p, ICMP_TE_TTL); |
icmp_time_exceeded(p, ICMP_TE_TTL); |
192 |
|
#if LWIP_SNMP > 0 |
193 |
|
snmp_inc_icmpouttimeexcds(); |
194 |
|
#endif |
195 |
} |
} |
196 |
return; |
return; |
197 |
} |
} |
210 |
++stats.ip.fw; |
++stats.ip.fw; |
211 |
++stats.ip.xmit; |
++stats.ip.xmit; |
212 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
213 |
|
#if LWIP_SNMP > 0 |
214 |
|
snmp_inc_ipforwdatagrams(); |
215 |
|
#endif |
216 |
|
|
217 |
PERF_STOP("ip_forward"); |
PERF_STOP("ip_forward"); |
218 |
|
|
404 |
#ifdef IP_STATS |
#ifdef IP_STATS |
405 |
++stats.ip.recv; |
++stats.ip.recv; |
406 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
407 |
|
#if LWIP_SNMP > 0 |
408 |
|
snmp_inc_ipinreceives(); |
409 |
|
#endif |
410 |
|
|
411 |
/* identify the IP header */ |
/* identify the IP header */ |
412 |
iphdr = p->payload; |
iphdr = p->payload; |
420 |
++stats.ip.err; |
++stats.ip.err; |
421 |
++stats.ip.drop; |
++stats.ip.drop; |
422 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
423 |
|
#if LWIP_SNMP > 0 |
424 |
|
snmp_inc_ipunknownprotos(); |
425 |
|
#endif |
426 |
return ERR_OK; |
return ERR_OK; |
427 |
} |
} |
428 |
|
|
436 |
++stats.ip.lenerr; |
++stats.ip.lenerr; |
437 |
++stats.ip.drop; |
++stats.ip.drop; |
438 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
439 |
|
#if LWIP_SNMP > 0 |
440 |
|
snmp_inc_ipindiscards(); |
441 |
|
#endif |
442 |
return ERR_OK; |
return ERR_OK; |
443 |
} |
} |
444 |
|
|
454 |
++stats.ip.chkerr; |
++stats.ip.chkerr; |
455 |
++stats.ip.drop; |
++stats.ip.drop; |
456 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
457 |
|
#if LWIP_SNMP > 0 |
458 |
|
snmp_inc_ipindiscards(); |
459 |
|
#endif |
460 |
return ERR_OK; |
return ERR_OK; |
461 |
} |
} |
462 |
|
|
502 |
if(!ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask))) { |
if(!ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask))) { |
503 |
ip_forward(p, iphdr, inp); |
ip_forward(p, iphdr, inp); |
504 |
} |
} |
505 |
|
else |
506 |
#endif /* IP_FORWARD */ |
#endif /* IP_FORWARD */ |
507 |
|
{ |
508 |
|
#if LWIP_SNMP > 0 |
509 |
|
snmp_inc_ipindiscards(); |
510 |
|
#endif |
511 |
|
} |
512 |
pbuf_free(p); |
pbuf_free(p); |
513 |
return ERR_OK; |
return ERR_OK; |
514 |
} |
} |
530 |
++stats.ip.opterr; |
++stats.ip.opterr; |
531 |
++stats.ip.drop; |
++stats.ip.drop; |
532 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
533 |
|
#if LWIP_SNMP > 0 |
534 |
|
snmp_inc_ipunknownprotos(); |
535 |
|
#endif |
536 |
return ERR_OK; |
return ERR_OK; |
537 |
} |
} |
538 |
#endif /* IP_REASSEMBLY */ |
#endif /* IP_REASSEMBLY */ |
546 |
++stats.ip.opterr; |
++stats.ip.opterr; |
547 |
++stats.ip.drop; |
++stats.ip.drop; |
548 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
549 |
|
#if LWIP_SNMP > 0 |
550 |
|
snmp_inc_ipunknownprotos(); |
551 |
|
#endif |
552 |
return ERR_OK; |
return ERR_OK; |
553 |
} |
} |
554 |
#endif /* IP_OPTIONS == 0 */ |
#endif /* IP_OPTIONS == 0 */ |
564 |
switch(IPH_PROTO(iphdr)) { |
switch(IPH_PROTO(iphdr)) { |
565 |
#if LWIP_UDP > 0 |
#if LWIP_UDP > 0 |
566 |
case IP_PROTO_UDP: |
case IP_PROTO_UDP: |
567 |
|
#if LWIP_SNMP > 0 |
568 |
|
snmp_inc_ipindelivers(); |
569 |
|
#endif |
570 |
udp_input(p, inp); |
udp_input(p, inp); |
571 |
break; |
break; |
572 |
#endif /* LWIP_UDP */ |
#endif /* LWIP_UDP */ |
573 |
#if LWIP_TCP > 0 |
#if LWIP_TCP > 0 |
574 |
case IP_PROTO_TCP: |
case IP_PROTO_TCP: |
575 |
|
#if LWIP_SNMP > 0 |
576 |
|
snmp_inc_ipindelivers(); |
577 |
|
#endif |
578 |
tcp_input(p, inp); |
tcp_input(p, inp); |
579 |
break; |
break; |
580 |
#endif /* LWIP_TCP */ |
#endif /* LWIP_TCP */ |
581 |
case IP_PROTO_ICMP: |
case IP_PROTO_ICMP: |
582 |
|
#if LWIP_SNMP > 0 |
583 |
|
snmp_inc_ipindelivers(); |
584 |
|
#endif |
585 |
icmp_input(p, inp); |
icmp_input(p, inp); |
586 |
break; |
break; |
587 |
default: |
default: |
599 |
++stats.ip.proterr; |
++stats.ip.proterr; |
600 |
++stats.ip.drop; |
++stats.ip.drop; |
601 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
602 |
|
#if LWIP_SNMP > 0 |
603 |
|
snmp_inc_ipunknownprotos(); |
604 |
|
#endif |
605 |
|
|
606 |
} |
} |
607 |
return ERR_OK; |
return ERR_OK; |
625 |
static u16_t ip_id = 0; |
static u16_t ip_id = 0; |
626 |
|
|
627 |
|
|
628 |
|
#if LWIP_SNMP > 0 |
629 |
|
snmp_inc_ipoutrequests(); |
630 |
|
#endif |
631 |
|
|
632 |
if(dest != IP_HDRINCL) { |
if(dest != IP_HDRINCL) { |
633 |
if(pbuf_header(p, IP_HLEN)) { |
if(pbuf_header(p, IP_HLEN)) { |
636 |
#ifdef IP_STATS |
#ifdef IP_STATS |
637 |
++stats.ip.err; |
++stats.ip.err; |
638 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
639 |
|
#if LWIP_SNMP > 0 |
640 |
|
snmp_inc_ipoutdiscards(); |
641 |
|
#endif |
642 |
return ERR_BUF; |
return ERR_BUF; |
643 |
} |
} |
644 |
|
|
676 |
ip_debug_print(p); |
ip_debug_print(p); |
677 |
#endif /* IP_DEBUG */ |
#endif /* IP_DEBUG */ |
678 |
|
|
679 |
|
DEBUGF(IP_DEBUG, ("netif->output()")); |
680 |
|
|
681 |
return netif->output(netif, p, dest); |
return netif->output(netif, p, dest); |
682 |
} |
} |
700 |
#ifdef IP_STATS |
#ifdef IP_STATS |
701 |
++stats.ip.rterr; |
++stats.ip.rterr; |
702 |
#endif /* IP_STATS */ |
#endif /* IP_STATS */ |
703 |
|
#if LWIP_SNMP > 0 |
704 |
|
snmp_inc_ipoutdiscards(); |
705 |
|
#endif |
706 |
return ERR_RTE; |
return ERR_RTE; |
707 |
} |
} |
708 |
|
|