mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-26 03:16:18 +00:00
zepif: fix destination IP (default should be broadcast, not 0.0.0.0)
This commit is contained in:
parent
fcccc47be4
commit
cb746a1aea
@ -56,10 +56,14 @@ extern "C" {
|
|||||||
/** Pass this struct as 'state' to netif_add to control the behaviour
|
/** Pass this struct as 'state' to netif_add to control the behaviour
|
||||||
* of this netif. If NULL is passed, default behaviour is chosen */
|
* of this netif. If NULL is passed, default behaviour is chosen */
|
||||||
struct zepif_init {
|
struct zepif_init {
|
||||||
/** The UDP port used for ZEP frames (0 = default) */
|
/** The UDP port used to ZEP frames from (0 = default) */
|
||||||
u16_t zep_udp_port;
|
u16_t zep_src_udp_port;
|
||||||
/** The IP address to sed ZEP frames to */
|
/** The UDP port used to ZEP frames to (0 = default) */
|
||||||
const ip_addr_t *zep_ip_addr;
|
u16_t zep_dst_udp_port;
|
||||||
|
/** The IP address to sed ZEP frames from (NULL = ANY) */
|
||||||
|
const ip_addr_t *zep_src_ip_addr;
|
||||||
|
/** The IP address to sed ZEP frames to (NULL = BROADCAST) */
|
||||||
|
const ip_addr_t *zep_dst_ip_addr;
|
||||||
/** If != NULL, the udp pcb is bound to this netif */
|
/** If != NULL, the udp pcb is bound to this netif */
|
||||||
const struct netif *zep_netif;
|
const struct netif *zep_netif;
|
||||||
/** MAC address of the 6LowPAN device */
|
/** MAC address of the 6LowPAN device */
|
||||||
|
@ -192,7 +192,7 @@ zepif_linkoutput(struct netif *netif, struct pbuf *p)
|
|||||||
#if ZEPIF_LOOPBACK
|
#if ZEPIF_LOOPBACK
|
||||||
zepif_udp_recv(netif, state->pcb, pbuf_clone(PBUF_RAW, PBUF_RAM, q), NULL, 0);
|
zepif_udp_recv(netif, state->pcb, pbuf_clone(PBUF_RAW, PBUF_RAM, q), NULL, 0);
|
||||||
#endif
|
#endif
|
||||||
err = udp_sendto(state->pcb, q, state->init.zep_ip_addr, state->init.zep_udp_port);
|
err = udp_sendto(state->pcb, q, state->init.zep_dst_ip_addr, state->init.zep_dst_udp_port);
|
||||||
}
|
}
|
||||||
pbuf_free(q);
|
pbuf_free(q);
|
||||||
|
|
||||||
@ -214,13 +214,16 @@ zepif_init(struct netif *netif)
|
|||||||
}
|
}
|
||||||
memset(state, 0, sizeof(struct zepif_state));
|
memset(state, 0, sizeof(struct zepif_state));
|
||||||
if (init_state != NULL) {
|
if (init_state != NULL) {
|
||||||
state->init = *init_state;
|
memcpy(&state->init, init_state, sizeof(struct zepif_init));
|
||||||
}
|
}
|
||||||
if (state->init.zep_udp_port == 0) {
|
if (state->init.zep_src_udp_port == 0) {
|
||||||
state->init.zep_udp_port = ZEPIF_DEFAULT_UDP_PORT;
|
state->init.zep_src_udp_port = ZEPIF_DEFAULT_UDP_PORT;
|
||||||
}
|
}
|
||||||
if (state->init.zep_ip_addr == NULL) {
|
if (state->init.zep_dst_udp_port == 0) {
|
||||||
state->init.zep_ip_addr = IP_ADDR_ANY;
|
state->init.zep_dst_udp_port = ZEPIF_DEFAULT_UDP_PORT;
|
||||||
|
}
|
||||||
|
if (state->init.zep_dst_ip_addr == NULL) {
|
||||||
|
state->init.zep_dst_ip_addr = IP_ADDR_BROADCAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
netif->state = NULL;
|
netif->state = NULL;
|
||||||
@ -230,7 +233,7 @@ zepif_init(struct netif *netif)
|
|||||||
err = ERR_MEM;
|
err = ERR_MEM;
|
||||||
goto err_ret;
|
goto err_ret;
|
||||||
}
|
}
|
||||||
err = udp_bind(state->pcb, state->init.zep_ip_addr, state->init.zep_udp_port);
|
err = udp_bind(state->pcb, state->init.zep_src_ip_addr, state->init.zep_src_udp_port);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
goto err_ret;
|
goto err_ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user