This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/17418 )
Change subject: socket: Add osmo_sock_mcast_iface_set() to bind multicast to device
......................................................................
socket: Add osmo_sock_mcast_iface_set() to bind multicast to device
Change-Id: Ib52d22710020b56965aefcef09bde8247ace4a9c
Related: OS#2966
---
M src/socket.c
1 file changed, 22 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/18/17418/1
diff --git a/src/socket.c b/src/socket.c
index 9b1d30e..8c267f5 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -41,6 +41,7 @@
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
+#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -1194,6 +1195,27 @@
}
}
+/*! Set the TTL of outbound multicast packets
+ * \param[in] fd file descriptor of related socket
+ * \param[in] ifname name of network interface to user for multicast
+ * \returns 0 on success; negative otherwise */
+int osmo_sock_mcast_iface_set(int fd, const char *ifname)
+{
+ unsigned int ifindex;
+ struct ip_mreqn mr;
+
+ /* first, resolve interface name to ifindex */
+ ifindex = if_nametoindex(ifname);
+ if (ifindex == 0)
+ return -errno;
+
+ /* next, configure kernel to use that ifindex for this sockets multicast traffic */
+ memset(&mr, 0, sizeof(mr));
+ mr.imr_ifindex = ifindex;
+ return setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, &mr, sizeof(mr));
+}
+
+
/*! Enable/disable receiving all multicast packets, even for non-subscribed groups
* \param[in] fd file descriptor of related socket
* \param[in] enable Enable or Disable receiving of all packets
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17418
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ib52d22710020b56965aefcef09bde8247ace4a9c
Gerrit-Change-Number: 17418
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200308/57ceb061/attachment.htm>