Skip to content

Commit

Permalink
Copy scope id when binding to IPv6 Link-Local address
Browse files Browse the repository at this point in the history
Binding to an IPv6 Link-Local address requires the scope ID to be set.
If this is not set bind will return EINVAL.

Signed-off-by: Thymo van Beers <[email protected]>
  • Loading branch information
ThymoNL authored and ralight committed Nov 1, 2024
1 parent 9d325b2 commit c968f5b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,9 @@ static int net__bind_interface(struct mosquitto__listener *listener, struct addr
memcpy(&((struct sockaddr_in6 *)rp->ai_addr)->sin6_addr,
&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr,
sizeof(struct in6_addr));

((struct sockaddr_in6 *)rp->ai_addr)->sin6_scope_id = ((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_scope_id;

freeifaddrs(ifaddr);
return MOSQ_ERR_SUCCESS;
}
Expand Down

0 comments on commit c968f5b

Please sign in to comment.