diff options
Diffstat (limited to 'src/libsystemd-network/lldp-network.c')
-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; |