BugID:18683975:add routing by source address in cellualr network
@@ -130,6 +130,20 @@ ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src)
if (netif != NULL) {
return netif;
}
+#ifdef CELLULAR_SUPPORT
+ /* iterate through netifs */
+ for (netif = netif_list; netif != NULL; netif = netif->next) {
+ /* is the netif up, does it have a link and a valid address? */
+ if (netif_is_up(netif) && netif_is_link_up(netif) && !ip4_addr_isany_val(*netif_ip4_addr(netif))) {
+ /* network mask matches? */
+ /* if src is netif address, use this netif directly. */
+ if (ip4_addr_cmp(src, netif_ip4_addr(netif))) {
+ /* return netif on which to forward IP packet */
+ return netif;
+ }
+ }
+ }
+#endif /* CELLULAR_SUPPORT */
}
return ip4_route(dest);
}
