This source file includes following definitions.
- libbpf_nla_data
- libbpf_nla_getattr_u8
- libbpf_nla_getattr_u32
- libbpf_nla_getattr_str
- libbpf_nla_len
1
2
3
4
5
6
7
8
9 #ifndef __LIBBPF_NLATTR_H
10 #define __LIBBPF_NLATTR_H
11
12 #include <stdint.h>
13 #include <linux/netlink.h>
14
15 #define __LINUX_NETLINK_H
16
17
18
19
20 enum {
21 LIBBPF_NLA_UNSPEC,
22 LIBBPF_NLA_U8,
23 LIBBPF_NLA_U16,
24 LIBBPF_NLA_U32,
25 LIBBPF_NLA_U64,
26 LIBBPF_NLA_STRING,
27 LIBBPF_NLA_FLAG,
28 LIBBPF_NLA_MSECS,
29 LIBBPF_NLA_NESTED,
30 __LIBBPF_NLA_TYPE_MAX,
31 };
32
33 #define LIBBPF_NLA_TYPE_MAX (__LIBBPF_NLA_TYPE_MAX - 1)
34
35
36
37
38
39
40
41 struct libbpf_nla_policy {
42
43 uint16_t type;
44
45
46 uint16_t minlen;
47
48
49 uint16_t maxlen;
50 };
51
52
53
54
55
56
57
58
59
60 #define libbpf_nla_for_each_attr(pos, head, len, rem) \
61 for (pos = head, rem = len; \
62 nla_ok(pos, rem); \
63 pos = nla_next(pos, &(rem)))
64
65
66
67
68
69 static inline void *libbpf_nla_data(const struct nlattr *nla)
70 {
71 return (char *) nla + NLA_HDRLEN;
72 }
73
74 static inline uint8_t libbpf_nla_getattr_u8(const struct nlattr *nla)
75 {
76 return *(uint8_t *)libbpf_nla_data(nla);
77 }
78
79 static inline uint32_t libbpf_nla_getattr_u32(const struct nlattr *nla)
80 {
81 return *(uint32_t *)libbpf_nla_data(nla);
82 }
83
84 static inline const char *libbpf_nla_getattr_str(const struct nlattr *nla)
85 {
86 return (const char *)libbpf_nla_data(nla);
87 }
88
89
90
91
92
93 static inline int libbpf_nla_len(const struct nlattr *nla)
94 {
95 return nla->nla_len - NLA_HDRLEN;
96 }
97
98 int libbpf_nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head,
99 int len, struct libbpf_nla_policy *policy);
100 int libbpf_nla_parse_nested(struct nlattr *tb[], int maxtype,
101 struct nlattr *nla,
102 struct libbpf_nla_policy *policy);
103
104 int libbpf_nla_dump_errormsg(struct nlmsghdr *nlh);
105
106 #endif