| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include <linux/sock_diag.h> |
| 4 |
#include <linux/unix_diag.h> |
| 5 |
|
| 6 |
#include "netlink-internal.h" |
| 7 |
#include "netlink-sock-diag.h" |
| 8 |
|
| 9 |
int sd_sock_diag_socket_open(sd_netlink **ret) { |
| 10 |
return netlink_open_family(ret, NETLINK_SOCK_DIAG); |
| 11 |
} |
| 12 |
|
| 13 |
int sd_sock_diag_message_new_unix( |
| 14 |
sd_netlink *sdnl, |
| 15 |
sd_netlink_message **ret, |
| 16 |
ino_t inode, |
| 17 |
uint64_t cookie, |
| 18 |
uint32_t show) { |
| 19 |
|
| 20 |
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL; |
| 21 |
int r; |
| 22 |
|
| 23 |
assert_return(sdnl, -EINVAL); |
| 24 |
assert_return(ret, -EINVAL); |
| 25 |
|
| 26 |
r = message_new(sdnl, &m, SOCK_DIAG_BY_FAMILY, NLM_F_REQUEST | NLM_F_ACK); |
| 27 |
if (r < 0) |
| 28 |
return r; |
| 29 |
|
| 30 |
*(struct unix_diag_req*) NLMSG_DATA(m->hdr) = (struct unix_diag_req) { |
| 31 |
.sdiag_family = AF_UNIX, |
| 32 |
.udiag_ino = inode, |
| 33 |
.udiag_show = show, |
| 34 |
.udiag_cookie = { |
| 35 |
cookie & UINT32_MAX, |
| 36 |
(cookie >> 32) & UINT32_MAX, |
| 37 |
}, |
| 38 |
}; |
| 39 |
|
| 40 |
*ret = TAKE_PTR(m); |
| 41 |
return 0; |
| 42 |
} |