mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-04-16 08:43:17 +00:00
DECLINE message was unicast instead of broadcast
This commit is contained in:
parent
bb87d19e84
commit
fab107a9df
@ -679,8 +679,10 @@ static err_t dhcp_decline(struct netif *netif)
|
|||||||
pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len);
|
pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len);
|
||||||
|
|
||||||
udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT);
|
udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT);
|
||||||
udp_connect(dhcp->pcb, &dhcp->server_ip_addr, DHCP_SERVER_PORT);
|
/* @todo: should we really connect here? we are performing sendto() */
|
||||||
udp_send(dhcp->pcb, dhcp->p_out);
|
udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
|
||||||
|
/* per section 4.4.4, broadcast DECLINE messages */
|
||||||
|
udp_sendto(dhcp->pcb, dhcp->p_out, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
|
||||||
dhcp_delete_request(netif);
|
dhcp_delete_request(netif);
|
||||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_decline: BACKING OFF\n"));
|
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_decline: BACKING OFF\n"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -356,9 +356,10 @@ udp_sendto(struct udp_pcb *pcb, struct pbuf *p,
|
|||||||
struct ip_addr *dst_ip, u16_t dst_port)
|
struct ip_addr *dst_ip, u16_t dst_port)
|
||||||
{
|
{
|
||||||
err_t err;
|
err_t err;
|
||||||
|
/* temporary space for current PCB remote address */
|
||||||
struct ip_addr pcb_remote_ip;
|
struct ip_addr pcb_remote_ip;
|
||||||
u16_t pcb_remote_port;
|
u16_t pcb_remote_port;
|
||||||
/* remember remote peer address of PCB */
|
/* remember current remote peer address of PCB */
|
||||||
pcb_remote_ip.addr = pcb->remote_ip.addr;
|
pcb_remote_ip.addr = pcb->remote_ip.addr;
|
||||||
pcb_remote_port = pcb->remote_port;
|
pcb_remote_port = pcb->remote_port;
|
||||||
/* copy packet destination address to PCB remote peer address */
|
/* copy packet destination address to PCB remote peer address */
|
||||||
@ -366,7 +367,7 @@ udp_sendto(struct udp_pcb *pcb, struct pbuf *p,
|
|||||||
pcb->remote_port = dst_port;
|
pcb->remote_port = dst_port;
|
||||||
/* send to the packet destination address */
|
/* send to the packet destination address */
|
||||||
err = udp_send(pcb, p);
|
err = udp_send(pcb, p);
|
||||||
/* reset PCB remote peer address */
|
/* restore PCB remote peer address */
|
||||||
pcb->remote_ip.addr = pcb_remote_ip.addr;
|
pcb->remote_ip.addr = pcb_remote_ip.addr;
|
||||||
pcb->remote_port = pcb_remote_port;
|
pcb->remote_port = pcb_remote_port;
|
||||||
return err;
|
return err;
|
||||||
@ -433,7 +434,9 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
udphdr->chksum = 0x0000;
|
udphdr->chksum = 0x0000;
|
||||||
|
|
||||||
/* find the outgoing network interface for this packet */
|
/* find the outgoing network interface for this packet */
|
||||||
if ((netif = ip_route(&(pcb->remote_ip))) == NULL) {
|
netif = ip_route(&(pcb->remote_ip));
|
||||||
|
/* no outgoing network interface could be found? */
|
||||||
|
if (netif == NULL) {
|
||||||
LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr));
|
LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr));
|
||||||
UDP_STATS_INC(udp.rterr);
|
UDP_STATS_INC(udp.rterr);
|
||||||
return ERR_RTE;
|
return ERR_RTE;
|
||||||
|
@ -117,6 +117,14 @@ extern const struct ip_addr ip_addr_broadcast;
|
|||||||
#define ip_addr_set(dest, src) (dest)->addr = \
|
#define ip_addr_set(dest, src) (dest)->addr = \
|
||||||
((src) == NULL? 0:\
|
((src) == NULL? 0:\
|
||||||
(src)->addr)
|
(src)->addr)
|
||||||
|
/**
|
||||||
|
* Determine if two address are on the same network.
|
||||||
|
*
|
||||||
|
* @arg addr1 IP address 1
|
||||||
|
* @arg addr2 IP address 2
|
||||||
|
* @arg mask network identifier mask
|
||||||
|
* @return !0 if the network identifiers of both address match
|
||||||
|
*/
|
||||||
#define ip_addr_maskcmp(addr1, addr2, mask) (((addr1)->addr & \
|
#define ip_addr_maskcmp(addr1, addr2, mask) (((addr1)->addr & \
|
||||||
(mask)->addr) == \
|
(mask)->addr) == \
|
||||||
((addr2)->addr & \
|
((addr2)->addr & \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user