fixed bug #38061 (wrong multicast routing in IPv4) by adding an optional default netif for multicast routing

This commit is contained in:
sg
2015-02-25 20:58:11 +01:00
parent 3e8ac30940
commit 612e33c499
4 changed files with 43 additions and 5 deletions

View File

@@ -98,6 +98,18 @@ struct ip_globals ip_data;
/** The IP header ID of the next outgoing IP packet */
static u16_t ip_id;
#if LWIP_IGMP
/** The default netif used for multicast */
static struct netif* ip_default_multicast_netif;
/** Set a default netif for IPv4 multicast. */
void
ip_set_default_multicast_netif(struct netif* default_multicast_netif)
{
ip_default_multicast_netif = default_multicast_netif;
}
#endif /* LWIP_IGMP */
/**
* Finds the appropriate network interface for a given IP address. It
* searches the list of network interfaces linearly. A match is found
@@ -119,6 +131,13 @@ ip_route(const ip_addr_t *dest)
}
#endif
#if LWIP_IGMP
/* Use administratively selected interface for multicast by default */
if (ip_addr_ismulticast(dest) && ip_default_multicast_netif) {
return ip_default_multicast_netif;
}
#endif /* LWIP_IGMP */
/* iterate through netifs */
for (netif = netif_list; netif != NULL; netif = netif->next) {
/* network mask matches? */