Moved common call to pbuf_header outside the switch()

This commit is contained in:
goldsimon 2011-06-07 19:10:10 +00:00
parent 5a674f419d
commit 5b04860b8b

View File

@ -477,6 +477,7 @@ ip_input(struct pbuf *p, struct netif *inp)
if (raw_input(p, inp) == 0) if (raw_input(p, inp) == 0)
#endif /* LWIP_RAW */ #endif /* LWIP_RAW */
{ {
pbuf_header(p, -iphdr_hlen); /* Move to payload, no check necessary. */
switch (IPH_PROTO(iphdr)) { switch (IPH_PROTO(iphdr)) {
#if LWIP_UDP #if LWIP_UDP
@ -485,27 +486,23 @@ ip_input(struct pbuf *p, struct netif *inp)
case IP_PROTO_UDPLITE: case IP_PROTO_UDPLITE:
#endif /* LWIP_UDPLITE */ #endif /* LWIP_UDPLITE */
snmp_inc_ipindelivers(); snmp_inc_ipindelivers();
pbuf_header(p, -iphdr_hlen); /* Move to payload, no check necessary. */
udp_input(p, inp); udp_input(p, inp);
break; break;
#endif /* LWIP_UDP */ #endif /* LWIP_UDP */
#if LWIP_TCP #if LWIP_TCP
case IP_PROTO_TCP: case IP_PROTO_TCP:
snmp_inc_ipindelivers(); snmp_inc_ipindelivers();
pbuf_header(p, -iphdr_hlen); /* Move to payload, no check necessary. */
tcp_input(p, inp); tcp_input(p, inp);
break; break;
#endif /* LWIP_TCP */ #endif /* LWIP_TCP */
#if LWIP_ICMP #if LWIP_ICMP
case IP_PROTO_ICMP: case IP_PROTO_ICMP:
snmp_inc_ipindelivers(); snmp_inc_ipindelivers();
pbuf_header(p, -iphdr_hlen); /* Move to payload, no check necessary. */
icmp_input(p, inp); icmp_input(p, inp);
break; break;
#endif /* LWIP_ICMP */ #endif /* LWIP_ICMP */
#if LWIP_IGMP #if LWIP_IGMP
case IP_PROTO_IGMP: case IP_PROTO_IGMP:
pbuf_header(p, -iphdr_hlen); /* Move to payload, no check necessary. */
igmp_input(p, inp, ip_current_dest_addr()); igmp_input(p, inp, ip_current_dest_addr());
break; break;
#endif /* LWIP_IGMP */ #endif /* LWIP_IGMP */
@ -514,6 +511,7 @@ ip_input(struct pbuf *p, struct netif *inp)
/* send ICMP destination protocol unreachable unless is was a broadcast */ /* send ICMP destination protocol unreachable unless is was a broadcast */
if (!ip_addr_isbroadcast(ip_current_dest_addr(), inp) && if (!ip_addr_isbroadcast(ip_current_dest_addr(), inp) &&
!ip_addr_ismulticast(ip_current_dest_addr())) { !ip_addr_ismulticast(ip_current_dest_addr())) {
pbuf_header(p, iphdr_hlen); /* Move to ip header, no check necessary. */
p->payload = iphdr; p->payload = iphdr;
icmp_dest_unreach(p, ICMP_DUR_PROTO); icmp_dest_unreach(p, ICMP_DUR_PROTO);
} }