Skip to content

Commit

Permalink
ipv4.hpp: set sockaddr_in::sin_len field on macOS and FreeBSD
Browse files Browse the repository at this point in the history
This field is presented on respective OSes and is required
when interacting with BSD routing socket.

For IPv6 we already have the similar code.

Signed-off-by: Lev Stipakov <[email protected]>
  • Loading branch information
lstipakov committed Oct 9, 2024
1 parent 1c10d8f commit 7459a2a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openvpn/addr/ipv4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ class Addr // NOTE: must be union-legal, so default constructor does not initial
ret.sin_family = AF_INET;
ret.sin_port = htons(port);
ret.sin_addr.s_addr = htonl(u.addr);
#if defined(__APPLE__) || defined(__FreeBSD__)
/* macOS and FreeBSD have the sin_len member */
ret.sin_len = sizeof(struct sockaddr_in);
#endif
return ret;
}

Expand Down

0 comments on commit 7459a2a

Please sign in to comment.