mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-06 22:44:38 +08:00
Minor coding style changes
This commit is contained in:
parent
1b07fecbf3
commit
788892ee7c
@ -173,7 +173,8 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
|||||||
* processed, but currently always returns ERR_OK)
|
* processed, but currently always returns ERR_OK)
|
||||||
*/
|
*/
|
||||||
err_t
|
err_t
|
||||||
ip_input(struct pbuf *p, struct netif *inp) {
|
ip_input(struct pbuf *p, struct netif *inp)
|
||||||
|
{
|
||||||
struct ip_hdr *iphdr;
|
struct ip_hdr *iphdr;
|
||||||
struct netif *netif;
|
struct netif *netif;
|
||||||
u16_t iphdrlen;
|
u16_t iphdrlen;
|
||||||
@ -229,43 +230,37 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
|||||||
|
|
||||||
/* match packet against an interface, i.e. is this packet for us? */
|
/* match packet against an interface, i.e. is this packet for us? */
|
||||||
#if LWIP_IGMP
|
#if LWIP_IGMP
|
||||||
if (ip_addr_ismulticast(&(iphdr->dest)))
|
if (ip_addr_ismulticast(&(iphdr->dest))) {
|
||||||
{ if ((inp->flags & NETIF_FLAG_IGMP) && (igmp_lookfor_group( inp, &(iphdr->dest))))
|
if ((inp->flags & NETIF_FLAG_IGMP) && (igmp_lookfor_group(inp, &(iphdr->dest)))) {
|
||||||
{ netif = inp;
|
netif = inp;
|
||||||
}
|
} else {
|
||||||
else
|
netif = NULL;
|
||||||
{ netif = NULL;
|
}
|
||||||
}
|
} else
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#endif /* LWIP_IGMP */
|
#endif /* LWIP_IGMP */
|
||||||
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
{
|
||||||
|
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
||||||
|
LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%"X32_F" netif->ip_addr 0x%"X32_F" (0x%"X32_F", 0x%"X32_F", 0x%"X32_F")\n",
|
||||||
|
iphdr->dest.addr, netif->ip_addr.addr,
|
||||||
|
iphdr->dest.addr & netif->netmask.addr,
|
||||||
|
netif->ip_addr.addr & netif->netmask.addr,
|
||||||
|
iphdr->dest.addr & ~(netif->netmask.addr)));
|
||||||
|
|
||||||
LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%"X32_F" netif->ip_addr 0x%"X32_F" (0x%"X32_F", 0x%"X32_F", 0x%"X32_F")\n",
|
/* interface is up and configured? */
|
||||||
iphdr->dest.addr, netif->ip_addr.addr,
|
if ((netif_is_up(netif)) && (!ip_addr_isany(&(netif->ip_addr)))) {
|
||||||
iphdr->dest.addr & netif->netmask.addr,
|
/* unicast to this interface address? */
|
||||||
netif->ip_addr.addr & netif->netmask.addr,
|
if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr)) ||
|
||||||
iphdr->dest.addr & ~(netif->netmask.addr)));
|
/* or broadcast on this interface network address? */
|
||||||
|
ip_addr_isbroadcast(&(iphdr->dest), netif)) {
|
||||||
|
LWIP_DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n",
|
||||||
|
netif->name[0], netif->name[1]));
|
||||||
|
/* break out of for loop */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* interface is up and configured? */
|
|
||||||
if ((netif_is_up(netif)) && (!ip_addr_isany(&(netif->ip_addr))))
|
|
||||||
{
|
|
||||||
/* unicast to this interface address? */
|
|
||||||
if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr)) ||
|
|
||||||
/* or broadcast on this interface network address? */
|
|
||||||
ip_addr_isbroadcast(&(iphdr->dest), netif)) {
|
|
||||||
LWIP_DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n",
|
|
||||||
netif->name[0], netif->name[1]));
|
|
||||||
/* break out of for loop */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if LWIP_IGMP
|
|
||||||
}
|
|
||||||
#endif /* LWIP_IGMP */
|
|
||||||
|
|
||||||
#if LWIP_DHCP
|
#if LWIP_DHCP
|
||||||
/* Pass DHCP messages regardless of destination address. DHCP traffic is addressed
|
/* Pass DHCP messages regardless of destination address. DHCP traffic is addressed
|
||||||
* using link layer addressing (such as Ethernet MAC) so we must not filter on IP.
|
* using link layer addressing (such as Ethernet MAC) so we must not filter on IP.
|
||||||
@ -292,8 +287,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
|||||||
if (!ip_addr_isbroadcast(&(iphdr->dest), inp)) {
|
if (!ip_addr_isbroadcast(&(iphdr->dest), inp)) {
|
||||||
/* try to forward IP packet on (other) interfaces */
|
/* try to forward IP packet on (other) interfaces */
|
||||||
ip_forward(p, iphdr, inp);
|
ip_forward(p, iphdr, inp);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
#endif /* IP_FORWARD */
|
#endif /* IP_FORWARD */
|
||||||
{
|
{
|
||||||
snmp_inc_ipinaddrerrors();
|
snmp_inc_ipinaddrerrors();
|
||||||
@ -351,56 +345,56 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
|||||||
|
|
||||||
#if LWIP_RAW
|
#if LWIP_RAW
|
||||||
/* raw input did not eat the packet? */
|
/* raw input did not eat the packet? */
|
||||||
if (raw_input(p, inp) == 0) {
|
if (raw_input(p, inp) == 0)
|
||||||
#endif /* LWIP_RAW */
|
#endif /* LWIP_RAW */
|
||||||
|
{
|
||||||
|
|
||||||
switch (IPH_PROTO(iphdr)) {
|
switch (IPH_PROTO(iphdr)) {
|
||||||
#if LWIP_UDP
|
#if LWIP_UDP
|
||||||
case IP_PROTO_UDP:
|
case IP_PROTO_UDP:
|
||||||
#if LWIP_UDPLITE
|
#if LWIP_UDPLITE
|
||||||
case IP_PROTO_UDPLITE:
|
case IP_PROTO_UDPLITE:
|
||||||
#endif /* LWIP_UDPLITE */
|
#endif /* LWIP_UDPLITE */
|
||||||
snmp_inc_ipindelivers();
|
snmp_inc_ipindelivers();
|
||||||
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();
|
||||||
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();
|
||||||
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:
|
||||||
igmp_input(p,inp,&(iphdr->dest));
|
igmp_input(p,inp,&(iphdr->dest));
|
||||||
break;
|
break;
|
||||||
#endif /* LWIP_IGMP */
|
#endif /* LWIP_IGMP */
|
||||||
default:
|
default:
|
||||||
#if LWIP_ICMP
|
#if LWIP_ICMP
|
||||||
/* send ICMP destination protocol unreachable unless is was a broadcast */
|
/* send ICMP destination protocol unreachable unless is was a broadcast */
|
||||||
if (!ip_addr_isbroadcast(&(iphdr->dest), inp) &&
|
if (!ip_addr_isbroadcast(&(iphdr->dest), inp) &&
|
||||||
!ip_addr_ismulticast(&(iphdr->dest))) {
|
!ip_addr_ismulticast(&(iphdr->dest))) {
|
||||||
p->payload = iphdr;
|
p->payload = iphdr;
|
||||||
icmp_dest_unreach(p, ICMP_DUR_PROTO);
|
icmp_dest_unreach(p, ICMP_DUR_PROTO);
|
||||||
}
|
}
|
||||||
#endif /* LWIP_ICMP */
|
#endif /* LWIP_ICMP */
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
|
|
||||||
LWIP_DEBUGF(IP_DEBUG | 2, ("Unsupported transport protocol %"U16_F"\n", IPH_PROTO(iphdr)));
|
LWIP_DEBUGF(IP_DEBUG | 2, ("Unsupported transport protocol %"U16_F"\n", IPH_PROTO(iphdr)));
|
||||||
|
|
||||||
IP_STATS_INC(ip.proterr);
|
IP_STATS_INC(ip.proterr);
|
||||||
IP_STATS_INC(ip.drop);
|
IP_STATS_INC(ip.drop);
|
||||||
snmp_inc_ipinunknownprotos();
|
snmp_inc_ipinunknownprotos();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if LWIP_RAW
|
|
||||||
} /* LWIP_RAW */
|
|
||||||
#endif
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user