1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-12 01:53:07 +03:00

Fixes for IPv6, added in CI (#5557)

This commit is contained in:
david gauchard
2018-12-27 16:13:48 +01:00
committed by GitHub
parent 9def8b0669
commit e3bc3c226b
12 changed files with 85 additions and 76 deletions

View File

@ -154,11 +154,9 @@ bool ESP8266NetBIOS::begin(const char *name)
if(_pcb != NULL) {
return true;
}
ip_addr_t addr;
addr.addr = INADDR_ANY;
_pcb = udp_new();
udp_recv(_pcb, &_s_recv, (void *) this);
err_t err = udp_bind(_pcb, &addr, NBNS_PORT);
err_t err = udp_bind(_pcb, INADDR_ANY, NBNS_PORT);
if(err != ERR_OK) {
end();
return false;
@ -182,9 +180,13 @@ void ESP8266NetBIOS::_recv(udp_pcb *upcb, pbuf *pb, CONST ip_addr_t *addr, uint1
while(pb != NULL) {
uint8_t * data = (uint8_t*)((pb)->payload);
size_t len = pb->len;
ip_hdr* iphdr = reinterpret_cast<ip_hdr*>(data - UDP_HLEN - IP_HLEN);
ip_addr_t saddr;
saddr.addr = iphdr->src.addr;
#if LWIP_VERSION_MAJOR == 1
// check UdpContext.h
const ip_addr_t* saddr = &current_iphdr_src;
#else
// check UdpContext.h
const ip_addr_t* saddr = &ip_data.current_iphdr_src;
#endif
if (len >= sizeof(struct NBNSQUESTION)) {
struct NBNSQUESTION * question = (struct NBNSQUESTION *)data;
@ -221,7 +223,7 @@ void ESP8266NetBIOS::_recv(udp_pcb *upcb, pbuf *pb, CONST ip_addr_t *addr, uint1
if(pbt != NULL) {
uint8_t* dst = reinterpret_cast<uint8_t*>(pbt->payload);
memcpy(dst, (uint8_t *)&nbnsa, sizeof(nbnsa));
udp_sendto(_pcb, pbt, &saddr, NBNS_PORT);
udp_sendto(_pcb, pbt, saddr, NBNS_PORT);
pbuf_free(pbt);
}
} else if (0 == strcmp(name, "*")) {
@ -251,7 +253,7 @@ void ESP8266NetBIOS::_recv(udp_pcb *upcb, pbuf *pb, CONST ip_addr_t *addr, uint1
if(pbt != NULL) {
uint8_t* dst = reinterpret_cast<uint8_t*>(pbt->payload);
memcpy(dst, (uint8_t *)&nbnsan, sizeof(nbnsan));
udp_sendto(_pcb, pbt, &saddr, NBNS_PORT);
udp_sendto(_pcb, pbt, saddr, NBNS_PORT);
pbuf_free(pbt);
}
}