diff options
author | 27o <27o@users.noreply.github.com> | 2017-02-09 10:36:13 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-02-09 10:36:13 +0100 |
commit | 6f844e3a3f97d2b3fce9d37714575177b9ff3f4c (patch) | |
tree | 99df0f8efc9a6472bc06510729f3c9295e4e39bc | |
parent | 28c78e07aaf34ed0ce3a7472b0504e4cefdedc52 (diff) |
networkd: add multicast membership to lldp socket (#5282)
-rw-r--r-- | src/libsystemd-network/lldp-network.c | 21 |
1 files changed, 21 insertions, 0 deletions
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; |