Skip to content

Commit 7bf5131

Browse files
stackiaclaude
andcommitted
fix(multicast): remove platform-specific IP_MULTICAST_IF branching
XNU kernel supports ip_mreqn with IP_MULTICAST_IF (checks optlen), so the macOS-specific fallback using in_addr is unnecessary. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 269e2c0 commit 7bf5131

1 file changed

Lines changed: 0 additions & 14 deletions

File tree

src/multicast.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,13 @@ static int create_igmp_raw_socket(service_t *service) {
114114
}
115115

116116
if (upstream_if && upstream_if[0] != '\0') {
117-
#if defined(__LINUX__) || defined(__FreeBSD__)
118117
struct ip_mreqn mreq;
119118
memset(&mreq, 0, sizeof(mreq));
120119
mreq.imr_ifindex = if_nametoindex(upstream_if);
121120
if (setsockopt(raw_sock, IPPROTO_IP, IP_MULTICAST_IF, &mreq,
122121
sizeof(mreq)) < 0) {
123122
logger(LOG_WARN, "Failed to set IP_MULTICAST_IF: %s", strerror(errno));
124123
}
125-
#else
126-
/* macOS: Use in_addr for IP_MULTICAST_IF */
127-
unsigned int ifidx = if_nametoindex(upstream_if);
128-
if (ifidx > 0) {
129-
/* Set by interface index using IP_BOUND_IF as fallback */
130-
struct in_addr ifaddr;
131-
ifaddr.s_addr = htonl(ifidx);
132-
if (setsockopt(raw_sock, IPPROTO_IP, IP_MULTICAST_IF, &ifaddr,
133-
sizeof(ifaddr)) < 0) {
134-
logger(LOG_WARN, "Failed to set IP_MULTICAST_IF: %s", strerror(errno));
135-
}
136-
}
137-
#endif
138124
}
139125

140126
return raw_sock;

0 commit comments

Comments
 (0)