mirror of
https://github.com/systemd/systemd.git
synced 2025-01-20 18:04:03 +03:00
networkd: add multicast membership to lldp socket (#5282)
This commit is contained in:
parent
28c78e07aa
commit
6f844e3a3f
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user