Commit 46c5d64d authored by Stephen Hemminger's avatar Stephen Hemminger

libnetlink: add attribute access inline functions

Based on idea in libmnl, add attribute access functions instead
of explicitly exposing casts. Also handle possible alignment issues
of u64.
parent cd70f3f5
......@@ -70,6 +70,25 @@ extern int __parse_rtattr_nested_compat(struct rtattr *tb[], int max, struct rta
({ data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \
__parse_rtattr_nested_compat(tb, max, rta, len); })
static inline __u16 rta_getattr_u16(const struct rtattr *rta)
{
return *(__u16 *)RTA_DATA(rta);
}
static inline __u16 rta_getattr_u32(const struct rtattr *rta)
{
return *(__u32 *)RTA_DATA(rta);
}
static inline __u64 rta_getattr_u64(const struct rtattr *rta)
{
__u64 tmp;
memcpy(&tmp, RTA_DATA(rta), sizeof(__u64));
return tmp;
}
static inline const char *rta_getattr_str(const struct rtattr *rta)
{
return RTA_DATA(rta);
}
extern int rtnl_listen(struct rtnl_handle *, rtnl_filter_t handler,
void *jarg);
extern int rtnl_from_file(FILE *, rtnl_filter_t handler,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment