mirror of
https://github.com/opnsense/src.git
synced 2026-02-25 11:00:15 -05:00
netlink: add nlattr_get_uint8() function to pack u8 attributes.
MFC after: 2 weeks
This commit is contained in:
parent
34066d0008
commit
70810dc817
2 changed files with 15 additions and 1 deletions
|
|
@ -314,11 +314,23 @@ nlattr_get_ipvia(struct nlattr *nla, struct nl_pstate *npt, const void *arg, voi
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
nlattr_get_uint8(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target)
|
||||
{
|
||||
if (__predict_false(NLA_DATA_LEN(nla) != sizeof(uint8_t))) {
|
||||
NLMSG_REPORT_ERR_MSG(npt, "nla type %d size(%u) is not uint8",
|
||||
nla->nla_type, NLA_DATA_LEN(nla));
|
||||
return (EINVAL);
|
||||
}
|
||||
*((uint16_t *)target) = *((const uint16_t *)NL_RTA_DATA_CONST(nla));
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
nlattr_get_uint16(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target)
|
||||
{
|
||||
if (__predict_false(NLA_DATA_LEN(nla) != sizeof(uint16_t))) {
|
||||
NLMSG_REPORT_ERR_MSG(npt, "nla type %d size(%u) is not uint32",
|
||||
NLMSG_REPORT_ERR_MSG(npt, "nla type %d size(%u) is not uint16",
|
||||
nla->nla_type, NLA_DATA_LEN(nla));
|
||||
return (EINVAL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,6 +169,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_uint8(struct nlattr *nla, struct nl_pstate *npt,
|
||||
const void *arg, void *target);
|
||||
int nlattr_get_uint16(struct nlattr *nla, struct nl_pstate *npt,
|
||||
const void *arg, void *target);
|
||||
int nlattr_get_uint32(struct nlattr *nla, struct nl_pstate *npt,
|
||||
|
|
|
|||
Loading…
Reference in a new issue