diff options
| author | zy <[email protected]> | 2024-01-12 02:47:43 -0500 |
|---|---|---|
| committer | zy <[email protected]> | 2024-01-12 02:47:43 -0500 |
| commit | f92139eb6685672ebceb34c8d26975772022bedd (patch) | |
| tree | 3979a734648e160b4348e0bb6236b7e6600723a0 /src | |
| parent | 32708c0a8b140efb545cc35101ee5fdeca6d6489 (diff) | |
change ip_forwarddev_zy
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/ipv4/ip4.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c index 26c26a91..7335f4e0 100644 --- a/src/core/ipv4/ip4.c +++ b/src/core/ipv4/ip4.c @@ -315,6 +315,8 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) } #endif /* IP_FORWARD_ALLOW_TX_ON_RX_NETIF */ + LWIP_DEBUGF(IP_DEBUG, ("ip4_forward: packet to interface %c%c\n", netif->name[0], netif->name[1])); + /* decrement TTL */ IPH_TTL_SET(iphdr, IPH_TTL(iphdr) - 1); /* send ICMP if TTL == 0 */ @@ -383,6 +385,7 @@ ip4_input_accept(struct netif *netif) if ((netif_is_up(netif)) && (!ip4_addr_isany_val(*netif_ip4_addr(netif)))) { /* unicast to this interface address? */ if (ip4_addr_cmp(ip4_current_dest_addr(), netif_ip4_addr(netif)) || + // if (1 || /* or broadcast on this interface network address? */ ip4_addr_isbroadcast(ip4_current_dest_addr(), netif) #if LWIP_NETIF_LOOPBACK && !LWIP_HAVE_LOOPIF @@ -405,6 +408,10 @@ ip4_input_accept(struct netif *netif) } #endif /* LWIP_AUTOIP */ } + struct netif* netif_default = ip4_route_src(ip4_current_src_addr(), ip4_current_dest_addr()); + if (netif == netif_default) { + return 1; + } return 0; } @@ -566,7 +573,7 @@ ip4_input(struct pbuf *p, struct netif *inp) } } -#if IP_ACCEPT_LINK_LAYER_ADDRESSING +#if IP_ACCEPT_LINK_LAYER_ADDRESSING // dhcp 消息 /* 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. * According to RFC 1542 section 3.1.1, referred by RFC 2131). @@ -619,7 +626,7 @@ ip4_input(struct pbuf *p, struct netif *inp) /* packet not for us, route or discard */ LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip4_input: packet not for us.\n")); #if IP_FORWARD - /* non-broadcast packet? */ + /* non-broadcast packet? */ // 非广播包 if (!ip4_addr_isbroadcast(ip4_current_dest_addr(), inp)) { /* try to forward IP packet on (other) interfaces */ ip4_forward(p, (struct ip_hdr *)p->payload, inp); |
