[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #36403] ip4_input() and ip6_input() always pass inp to
From: |
Ivan Delamer |
Subject: |
[lwip-devel] [bug #36403] ip4_input() and ip6_input() always pass inp to higher layers |
Date: |
Tue, 17 Feb 2015 21:33:22 +0000 |
User-agent: |
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0 |
Follow-up Comment #6, bug #36403 (project lwip):
This is what I did with ip_route():
diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c
index a2551d6..8223721 100644
--- a/src/core/ipv4/ip4.c
+++ b/src/core/ipv4/ip4.c
@@ -108,7 +108,7 @@
* @return the netif on which to send to reach dest
*/
struct netif *
-ip_route(ip_addr_t *dest)
+ip_route(ip_addr_t *src, ip_addr_t *dest)
{
struct netif *netif;
@@ -133,6 +133,19 @@
return netif;
}
}
+ }
+ if (!ip_addr_isany(src)) {
+ for (netif = netif_list; netif != NULL; netif = netif->next) {
+ /* network mask matches? */
+ if (netif_is_up(netif)) {
+ if (ip_addr_cmp(src, &(netif->ip_addr))) {
+ if (!ip_addr_isany(&(netif->gw))) {
+ /* return netif on which to forward IP packet */
+ return netif;
+ }
+ }
+ }
+ }
}
if ((netif_default == NULL) || (!netif_is_up(netif_default))) {
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_route: No route to
%"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
@@ -868,7 +881,7 @@
LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p);
- if ((netif = ip_route(dest)) == NULL) {
+ if ((netif = ip_route(src, dest)) == NULL) {
LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to
%"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest),
ip4_addr4_16(dest)));
IP_STATS_INC(ip.rterr);
diff --git a/src/include/lwip/ip.h b/src/include/lwip/ip.h
index 350d51b..296de24 100644
--- a/src/include/lwip/ip.h
+++ b/src/include/lwip/ip.h
@@ -230,7 +230,7 @@
#define ipX_route(isipv6, src, dest) \
((isipv6) ? \
ip6_route(ipX_2_ip6(src), ipX_2_ip6(dest)) : \
- ip_route(ipX_2_ip(dest)))
+ ip_route(ipX_2_ip(src), ipX_2_ip(dest)))
#define ipX_netif_get_local_ipX(isipv6, netif, dest) \
((isipv6) ? \
ip6_netif_get_local_ipX(netif, ipX_2_ip6(dest)) : \
@@ -246,7 +246,7 @@
#define ipX_output_hinted(isipv6, p, src, dest, ttl, tos, proto, addr_hint)
\
ip_output_hinted(p, src, dest, ttl, tos, proto, addr_hint)
#define ipX_route(isipv6, src, dest) \
- ip_route(ipX_2_ip(dest))
+ ip_route(&ip_addr_any, ipX_2_ip(dest))
#define ipX_netif_get_local_ipX(isipv6, netif, dest) \
ip_netif_get_local_ipX(netif)
#define ipX_debug_print(is_ipv6, p) ip_debug_print(p)
diff --git a/src/include/lwip/ip4.h b/src/include/lwip/ip4.h
index c49a771..d3dedc7 100644
--- a/src/include/lwip/ip4.h
+++ b/src/include/lwip/ip4.h
@@ -112,7 +112,7 @@
#define ip_init() /* Compatibility define, no init needed. */
-struct netif *ip_route(ip_addr_t *dest);
+struct netif *ip_route(ip_addr_t *src, ip_addr_t *dest);
err_t ip_input(struct pbuf *p, struct netif *inp);
err_t ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
u8_t ttl, u8_t tos, u8_t proto);
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?36403>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/