Skip to content

Commit

Permalink
SOL_IP is Linux-specific, replace with portable IPPROTO_IP (fix #481)
Browse files Browse the repository at this point in the history
  • Loading branch information
yrutschle committed Dec 8, 2024
1 parent 9243a6e commit 5f55f7d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ int bind_peer(int fd, int fd_from)
return 0;

#ifndef IP_BINDANY /* use IP_TRANSPARENT */
res = setsockopt(fd, SOL_IP, IP_TRANSPARENT, &enable, sizeof(enable));
res = setsockopt(fd, IPPROTO_IP, IP_TRANSPARENT, &enable, sizeof(enable));
CHECK_RES_DIE(res, "setsockopt IP_TRANSPARENT");
res = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable));
CHECK_RES_DIE(res, "setsockopt SO_REUSEADDR");
Expand All @@ -293,7 +293,7 @@ int bind_peer(int fd, int fd_from)
}
res = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &disable, sizeof(disable));
CHECK_RES_DIE(res, "setsockopt SO_REUSEADDR");
res = setsockopt(fd, SOL_IP, IP_BIND_ADDRESS_NO_PORT, &enable, sizeof(enable));
res = setsockopt(fd, IPPROTO_IP, IP_BIND_ADDRESS_NO_PORT, &enable, sizeof(enable));
CHECK_RES_RETURN(res, "setsockopt IP_BIND_ADDRESS_NO_PORT", res);
((struct sockaddr_in *)from.ai_addr)->sin_port = 0;
res = bind(fd, from.ai_addr, from.ai_addrlen);
Expand Down

0 comments on commit 5f55f7d

Please sign in to comment.