| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include <linux/netlink.h> |
| 4 |
#include <linux/sock_diag.h> |
| 5 |
#include <linux/unix_diag.h> |
| 6 |
|
| 7 |
#include "netlink-types-internal.h" |
| 8 |
#include "netlink-types.h" |
| 9 |
|
| 10 |
static const NLAPolicy unix_diag_req_policies[] = { |
| 11 |
}; |
| 12 |
DEFINE_POLICY_SET(unix_diag_req); |
| 13 |
|
| 14 |
static const NLAPolicy sdnl_req_policies[] = { |
| 15 |
[SOCK_DIAG_BY_FAMILY] = BUILD_POLICY_NESTED_WITH_SIZE(unix_diag_req, sizeof(struct unix_diag_req)), |
| 16 |
}; |
| 17 |
|
| 18 |
DEFINE_POLICY_SET(sdnl_req); |
| 19 |
|
| 20 |
static const NLAPolicy unix_diag_msg_policies[] = { |
| 21 |
[UNIX_DIAG_RQLEN] = BUILD_POLICY_WITH_SIZE(BINARY, sizeof(struct unix_diag_rqlen)), |
| 22 |
}; |
| 23 |
DEFINE_POLICY_SET(unix_diag_msg); |
| 24 |
|
| 25 |
static const NLAPolicy sdnl_msg_policies[] = { |
| 26 |
[SOCK_DIAG_BY_FAMILY] = BUILD_POLICY_NESTED_WITH_SIZE(unix_diag_msg, sizeof(struct unix_diag_msg)), |
| 27 |
}; |
| 28 |
|
| 29 |
DEFINE_POLICY_SET(sdnl_msg); |
| 30 |
|
| 31 |
const NLAPolicy *sdnl_get_policy(uint16_t nlmsg_type, uint16_t flags) { |
| 32 |
/* for sock_diag we need to look at whether a message is a response or request to determine how to decode it. */ |
| 33 |
if (flags & NLM_F_REQUEST) |
| 34 |
return policy_set_get_policy(&sdnl_req_policy_set, nlmsg_type); |
| 35 |
|
| 36 |
return policy_set_get_policy(&sdnl_msg_policy_set, nlmsg_type); |
| 37 |
} |