Merge pull request #251 from agalliazzo/udp6_multicast_hop_bugfix

Fix issue #250
This commit is contained in:
Tomoaki Yamaguchi
2021-12-26 16:20:44 +09:00
committed by GitHub
2 changed files with 16 additions and 4 deletions

View File

@@ -17,6 +17,6 @@
#ifndef MQTTSNGWVERSION_H_IN_
#define MQTTSNGWVERSION_H_IN_
#define PAHO_GATEWAY_VERSION "1.6.0"
#define PAHO_GATEWAY_VERSION "1.5.1"
#endif /* MQTTSNGWVERSION_H_IN_ */

View File

@@ -416,12 +416,24 @@ int UDPPort6::unicast(const uint8_t* buf, uint32_t length, SensorNetAddress* add
int UDPPort6::broadcast(const uint8_t* buf, uint32_t length)
{
int err = unicast(buf, length, &_grpAddr);
sockaddr_in6 dest;
memset(&dest, 0, sizeof(dest));
dest.sin6_family = AF_INET6;
dest.sin6_port = _grpAddr.getPortNo();
memcpy(dest.sin6_addr.s6_addr, (const void*) &_grpAddr.getIpAddress()->sin6_addr, sizeof(in6_addr));
if (err < 0)
#ifdef DEBUG_NW
char addrBuf[INET6_ADDRSTRLEN];
addr->sprint(addrBuf);
D_NWSTACK("sendto %s\n", addrBuf);
#endif
int status = ::sendto(_pollfds[1].fd, buf, length, 0, (const sockaddr*) &dest, sizeof(dest));
if (status < 0)
{
D_NWSTACK("UDP6::broadcast - sendto: %s", strerror(errno));
return err;
return status;
}
return 0;