netlink: add u8/u64 attribute fetcher accessors to snl(3).
MFC after: 2 weeks
This commit is contained in:
parent
4530e0c3e7
commit
61507ae30b
@ -75,10 +75,14 @@
|
||||
.Ft "bool"
|
||||
.Fn snl_attr_get_flag "struct snl_state *ss" "struct nlattr *nla" "void *target"
|
||||
.Ft "bool"
|
||||
.Fn snl_attr_get_uint8 "struct snl_state *ss" "struct nlattr *nla" "void *target"
|
||||
.Ft "bool"
|
||||
.Fn snl_attr_get_uint16 "struct snl_state *ss" "struct nlattr *nla" "void *target"
|
||||
.Ft "bool"
|
||||
.Fn snl_attr_get_uint32 "struct snl_state *ss" "struct nlattr *nla" "void *target"
|
||||
.Ft "bool"
|
||||
.Fn snl_attr_get_uint64 "struct snl_state *ss" "struct nlattr *nla" "void *target"
|
||||
.Ft "bool"
|
||||
.Fn snl_attr_get_string "struct snl_state *ss" "struct nlattr *nla" "void *target"
|
||||
.Ft "bool"
|
||||
.Fn snl_attr_get_stringn "struct snl_state *ss" "struct nlattr *nla" "void *target"
|
||||
@ -181,10 +185,14 @@ A number of predefined getters for the common data types exist.
|
||||
.Fn snl_attr_get_flag
|
||||
converts a flag-type attribute to an uint8_t value of 1 or 0, depending on the
|
||||
attribute presence.
|
||||
.Fn snl_attr_get_uint8
|
||||
stores a uint8_t type attribute into the uint8_t target field.
|
||||
.Fn snl_attr_get_uint16
|
||||
stores a uint16_t type attribute into the uint16_t target field.
|
||||
.Fn snl_attr_get_uint32
|
||||
stores a uint32_t type attribute into the uint32_t target field.
|
||||
.Fn snl_attr_get_uint64
|
||||
stores a uint64_t type attribute into the uint64_t target field.
|
||||
.Fn snl_attr_get_ip
|
||||
and
|
||||
.Fn snl_attr_get_ipvia
|
||||
|
@ -355,6 +355,17 @@ snl_attr_get_flag(struct snl_state *ss __unused, struct nlattr *nla, void *targe
|
||||
return (false);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
snl_attr_get_uint8(struct snl_state *ss __unused, struct nlattr *nla,
|
||||
const void *arg __unused, void *target)
|
||||
{
|
||||
if (NLA_DATA_LEN(nla) == sizeof(uint8_t)) {
|
||||
*((uint8_t *)target) = *((const uint8_t *)NLA_DATA_CONST(nla));
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
snl_attr_get_uint16(struct snl_state *ss __unused, struct nlattr *nla,
|
||||
const void *arg __unused, void *target)
|
||||
@ -377,6 +388,17 @@ snl_attr_get_uint32(struct snl_state *ss __unused, struct nlattr *nla,
|
||||
return (false);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
snl_attr_get_uint64(struct snl_state *ss __unused, struct nlattr *nla,
|
||||
const void *arg __unused, void *target)
|
||||
{
|
||||
if (NLA_DATA_LEN(nla) == sizeof(uint64_t)) {
|
||||
memcpy(target, NLA_DATA_CONST(nla), sizeof(uint64_t));
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
snl_attr_get_string(struct snl_state *ss __unused, struct nlattr *nla,
|
||||
const void *arg __unused, void *target)
|
||||
@ -416,7 +438,8 @@ snl_attr_get_nested(struct snl_state *ss, struct nlattr *nla, const void *arg, v
|
||||
}
|
||||
|
||||
static inline bool
|
||||
snl_attr_get_nla(struct snl_state *ss __unused, struct nlattr *nla, void *target)
|
||||
snl_attr_get_nla(struct snl_state *ss __unused, struct nlattr *nla,
|
||||
const void *arg __unused, void *target)
|
||||
{
|
||||
*((struct nlattr **)target) = nla;
|
||||
return (true);
|
||||
|
Loading…
Reference in New Issue
Block a user