mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-04 15:40:44 +00:00
netlink: add bool type support
Reviewed by: melifaro Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D44089
This commit is contained in:
parent
48f33b55b0
commit
dfed87b5ce
|
@ -312,6 +312,17 @@ nlattr_get_ipvia(struct nlattr *nla, struct nl_pstate *npt, const void *arg, voi
|
|||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
nlattr_get_bool(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target)
|
||||
{
|
||||
if (__predict_false(NLA_DATA_LEN(nla) != sizeof(bool))) {
|
||||
NLMSG_REPORT_ERR_MSG(npt, "nla type %d size(%u) is not bool",
|
||||
nla->nla_type, NLA_DATA_LEN(nla));
|
||||
return (EINVAL);
|
||||
}
|
||||
*((bool *)target) = *((const bool *)NL_RTA_DATA_CONST(nla));
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
nlattr_get_uint8(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target)
|
||||
|
|
|
@ -173,6 +173,8 @@ int nlattr_get_flag(struct nlattr *nla, struct nl_pstate *npt,
|
|||
const void *arg, void *target);
|
||||
int nlattr_get_ip(struct nlattr *nla, struct nl_pstate *npt,
|
||||
const void *arg, void *target);
|
||||
int nlattr_get_bool(struct nlattr *nla, struct nl_pstate *npt,
|
||||
const void *arg, void *target);
|
||||
int nlattr_get_uint8(struct nlattr *nla, struct nl_pstate *npt,
|
||||
const void *arg, void *target);
|
||||
int nlattr_get_uint16(struct nlattr *nla, struct nl_pstate *npt,
|
||||
|
|
|
@ -1147,6 +1147,12 @@ snl_add_msg_attr_raw(struct snl_writer *nw, const struct nlattr *nla_src)
|
|||
return (snl_add_msg_attr(nw, nla_src->nla_type, attr_len, (const void *)(nla_src + 1)));
|
||||
}
|
||||
|
||||
static inline bool
|
||||
snl_add_msg_attr_bool(struct snl_writer *nw, int attrtype, bool value)
|
||||
{
|
||||
return (snl_add_msg_attr(nw, attrtype, sizeof(bool), &value));
|
||||
}
|
||||
|
||||
static inline bool
|
||||
snl_add_msg_attr_u8(struct snl_writer *nw, int attrtype, uint8_t value)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue