Skip to content

Commit

Permalink
Fix IpV6 link local address connections
Browse files Browse the repository at this point in the history
Paho currently successfully resolves IPv6 link-local addresses (of the
form `tcp://[xxxx::xxxx:xxxx:xxxx%eth0]:1883`). But it does not copy
the resolved link information over when attempting to make the
connection.

This is a 3-line fix.

See: eclipse#1464
  • Loading branch information
jumoog committed Apr 10, 2024
1 parent bcbe0f1 commit ab2f737
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,10 @@ int Socket_new(const char* addr, size_t addr_len, int port, SOCKET* sock)
{
address6.sin6_port = htons(port);
address6.sin6_family = family = AF_INET6;
memcpy(&address6.sin6_addr, &((struct sockaddr_in6*)(res->ai_addr))->sin6_addr, sizeof(address6.sin6_addr));
struct sockaddr_in6* res6 = (struct sockaddr_in6*)(res->ai_addr);
memcpy(&address6.sin6_addr, &res6->sin6_addr, sizeof(address6.sin6_addr));
memcpy(&address6.sin6_scope_id, &res6->sin6_scope_id, sizeof(address6.sin6_scope_id));
memcpy(&address6.sin6_flowinfo, &res6->sin6_flowinfo, sizeof(address6.sin6_flowinfo));
}
else
#endif
Expand Down

0 comments on commit ab2f737

Please sign in to comment.