fixed bug #35595: Impossible to send broadcast without a gateway (introduced when fixing bug# 33551)

This commit is contained in:
goldsimon 2012-02-23 10:12:38 +01:00
parent 5deeaa652a
commit 6486c4b1d7
2 changed files with 46 additions and 42 deletions

View File

@ -62,6 +62,10 @@ HISTORY
++ Bugfixes: ++ Bugfixes:
2012-02-23: Simon Goldschmidt
* etharp.c: fixed bug #35595: Impossible to send broadcast without a gateway
(introduced when fixing bug# 33551)
2012-02-16: Simon Goldschmidt 2012-02-16: Simon Goldschmidt
* ppp.c: fixed pbuf leak when PPP session is aborted through pppSigHUP() * ppp.c: fixed pbuf leak when PPP session is aborted through pppSigHUP()
(bug #35541: PPP Memory Leak) (bug #35541: PPP Memory Leak)

View File

@ -895,10 +895,31 @@ etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr)
return ERR_BUF; return ERR_BUF;
} }
/* Determine on destination hardware address. Broadcasts and multicasts
* are special, other IP addresses are looked up in the ARP table. */
/* broadcast destination IP address? */
if (ip_addr_isbroadcast(ipaddr, netif)) {
/* broadcast on Ethernet also */
dest = (struct eth_addr *)&ethbroadcast;
/* multicast destination IP address? */
} else if (ip_addr_ismulticast(ipaddr)) {
/* Hash IP multicast address to MAC address.*/
mcastaddr.addr[0] = LL_MULTICAST_ADDR_0;
mcastaddr.addr[1] = LL_MULTICAST_ADDR_1;
mcastaddr.addr[2] = LL_MULTICAST_ADDR_2;
mcastaddr.addr[3] = ip4_addr2(ipaddr) & 0x7f;
mcastaddr.addr[4] = ip4_addr3(ipaddr);
mcastaddr.addr[5] = ip4_addr4(ipaddr);
/* destination Ethernet address is multicast */
dest = &mcastaddr;
/* unicast destination IP address? */
} else {
s8_t i;
/* outside local network? if so, this can neither be a global broadcast nor /* outside local network? if so, this can neither be a global broadcast nor
a subnet broadcast. */ a subnet broadcast. */
if (!ip_addr_netcmp(ipaddr, &(netif->ip_addr), &(netif->netmask)) && if (!ip_addr_netcmp(ipaddr, &(netif->ip_addr), &(netif->netmask)) &&
!ip_addr_islinklocal(ipaddr) && !ip_addr_ismulticast(ipaddr)) { !ip_addr_islinklocal(ipaddr)) {
#if LWIP_AUTOIP #if LWIP_AUTOIP
struct ip_hdr *iphdr = (struct ip_hdr*)((u8_t*)q->payload + struct ip_hdr *iphdr = (struct ip_hdr*)((u8_t*)q->payload +
sizeof(struct eth_hdr)); sizeof(struct eth_hdr));
@ -937,27 +958,6 @@ etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr)
} }
#endif /* LWIP_NETIF_HWADDRHINT */ #endif /* LWIP_NETIF_HWADDRHINT */
/* Determine on destination hardware address. Broadcasts and multicasts
* are special, other IP addresses are looked up in the ARP table. */
/* broadcast destination IP address? */
if (ip_addr_isbroadcast(ipaddr, netif)) {
/* broadcast on Ethernet also */
dest = (struct eth_addr *)&ethbroadcast;
/* multicast destination IP address? */
} else if (ip_addr_ismulticast(ipaddr)) {
/* Hash IP multicast address to MAC address.*/
mcastaddr.addr[0] = LL_MULTICAST_ADDR_0;
mcastaddr.addr[1] = LL_MULTICAST_ADDR_1;
mcastaddr.addr[2] = LL_MULTICAST_ADDR_2;
mcastaddr.addr[3] = ip4_addr2(ipaddr) & 0x7f;
mcastaddr.addr[4] = ip4_addr3(ipaddr);
mcastaddr.addr[5] = ip4_addr4(ipaddr);
/* destination Ethernet address is multicast */
dest = &mcastaddr;
/* unicast destination IP address? */
} else {
s8_t i;
/* find stable entry: do this here since this is a critical path for /* find stable entry: do this here since this is a critical path for
throughput and etharp_find_entry() is kind of slow */ throughput and etharp_find_entry() is kind of slow */
for (i = 0; i < ARP_TABLE_SIZE; i++) { for (i = 0; i < ARP_TABLE_SIZE; i++) {