From 6f844e3a3f97d2b3fce9d37714575177b9ff3f4c Mon Sep 17 00:00:00 2001 From: 27o <27o@users.noreply.github.com> Date: Thu, 9 Feb 2017 10:36:13 +0100 Subject: networkd: add multicast membership to lldp socket (#5282) --- src/libsystemd-network/lldp-network.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/libsystemd-network') diff --git a/src/libsystemd-network/lldp-network.c b/src/libsystemd-network/lldp-network.c index 59c25598e9..ae2f6744d5 100644 --- a/src/libsystemd-network/lldp-network.c +++ b/src/libsystemd-network/lldp-network.c @@ -47,6 +47,13 @@ int lldp_network_bind_raw_socket(int ifindex) { .filter = (struct sock_filter*) filter, }; + struct packet_mreq mreq = { + .mr_ifindex = ifindex, + .mr_type = PACKET_MR_MULTICAST, + .mr_alen = ETH_ALEN, + .mr_address = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x00 } + }; + union sockaddr_union saddrll = { .ll.sll_family = AF_PACKET, .ll.sll_ifindex = ifindex, @@ -66,6 +73,20 @@ int lldp_network_bind_raw_socket(int ifindex) { if (r < 0) return -errno; + r = setsockopt(fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq, sizeof(mreq)); + if (r < 0) + return -errno; + + mreq.mr_address[ETH_ALEN - 1] = 0x03; + r = setsockopt(fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq, sizeof(mreq)); + if (r < 0) + return -errno; + + mreq.mr_address[ETH_ALEN - 1] = 0x0E; + r = setsockopt(fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq, sizeof(mreq)); + if (r < 0) + return -errno; + r = bind(fd, &saddrll.sa, sizeof(saddrll.ll)); if (r < 0) return -errno; -- cgit v1.2.3-54-g00ecf