mirror of https://gerrit.osmocom.org/libosmocore
socket: Add new OSMO_SOCK_F_NO_MCAST_ALL option
Using this option at socket creation, the caller can request disabling the IP_MULTICAST_ALL socket option. Change-Id: I5ab5de45c0b64ceb3636ea98245a23defa24ffd4
This commit is contained in:
parent
bc43a62f41
commit
37d204a120
|
@ -22,6 +22,8 @@ struct osmo_fd;
|
|||
#define OSMO_SOCK_F_NONBLOCK (1 << 2)
|
||||
/*! disable multiast loop (IP_MULTICAST_LOOP) */
|
||||
#define OSMO_SOCK_F_NO_MCAST_LOOP (1 << 3)
|
||||
/*! disable receiving all multiast even for non-subscribed groups */
|
||||
#define OSMO_SOCK_F_NO_MCAST_ALL (1 << 4)
|
||||
|
||||
int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto,
|
||||
const char *host, uint16_t port, unsigned int flags);
|
||||
|
|
10
src/socket.c
10
src/socket.c
|
@ -132,6 +132,16 @@ static int osmo_sock_init_tail(int fd, uint16_t type, unsigned int flags)
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & OSMO_SOCK_F_NO_MCAST_ALL) {
|
||||
rc = osmo_sock_mcast_all_set(fd, false);
|
||||
if (rc < 0) {
|
||||
LOGP(DLGLOBAL, LOGL_ERROR, "unable to disable receive of all multicast: %s\n",
|
||||
strerror(errno));
|
||||
/* do not abort here, as this is just an
|
||||
* optional additional optimization that only
|
||||
* exists on Linux only */
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue