Skip to content

Commit

Permalink
Merge pull request #251 from agalliazzo/udp6_multicast_hop_bugfix
Browse files Browse the repository at this point in the history
Fix issue #250
  • Loading branch information
ty4tw authored Dec 26, 2021
2 parents 27b5c76 + debc217 commit 5979712
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion MQTTSNGateway/src/MQTTSNGWVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
18 changes: 15 additions & 3 deletions MQTTSNGateway/src/linux/udp6/SensorNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5979712

Please sign in to comment.