diff --git a/include/libnetlink.h b/include/libnetlink.h index ad7e7127..35a9bb57 100644 --- a/include/libnetlink.h +++ b/include/libnetlink.h @@ -260,6 +260,20 @@ static inline __u64 rta_getattr_u64(const struct rtattr *rta) memcpy(&tmp, RTA_DATA(rta), sizeof(__u64)); return tmp; } +static inline __u64 rta_getattr_uint(const struct rtattr *rta) +{ + switch (RTA_PAYLOAD(rta)) { + case sizeof(__u8): + return rta_getattr_u8(rta); + case sizeof(__u16): + return rta_getattr_u16(rta); + case sizeof(__u32): + return rta_getattr_u32(rta); + case sizeof(__u64): + return rta_getattr_u64(rta); + } + return -1ULL; +} static inline __s32 rta_getattr_s32(const struct rtattr *rta) { return *(__s32 *)RTA_DATA(rta);