1 #ifndef __NET_NETLINK_WRAPPER_H
2 #define __NET_NETLINK_WRAPPER_H 1
4 #include <linux/version.h>
5 #include_next <net/netlink.h>
7 #ifndef HAVE_NLA_GET_BE16
9 * nla_get_be16 - return payload of __be16 attribute
10 * @nla: __be16 netlink attribute
12 static inline __be16 nla_get_be16(const struct nlattr *nla)
14 return *(__be16 *) nla_data(nla);
16 #endif /* !HAVE_NLA_GET_BE16 */
18 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
19 /* This function was introduced in 2.6.31, but initially it performed an
20 * unaligned access, so we replace it up to 2.6.34 where it was fixed. */
21 #define nla_get_be64 rpl_nla_get_be64
22 static inline __be64 nla_get_be64(const struct nlattr *nla)
26 /* The additional cast is necessary because */
27 nla_memcpy(&tmp, (struct nlattr *) nla, sizeof(tmp));
33 #ifndef HAVE_NLA_PUT_BE16
34 static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value)
36 return nla_put(skb, attrtype, sizeof(__be16), &value);
40 #ifndef HAVE_NLA_PUT_BE32
41 static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value)
43 return nla_put(skb, attrtype, sizeof(__be32), &value);
47 #ifndef HAVE_NLA_PUT_BE64
48 static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value)
50 return nla_put(skb, attrtype, sizeof(__be64), &value);
54 #ifndef nla_for_each_nested
55 #define nla_for_each_nested(pos, nla, rem) \
56 nla_for_each_attr(pos, nla_data(nla), nla_len(nla), rem)
59 #ifndef HAVE_NLA_FIND_NESTED
60 static inline struct nlattr *nla_find_nested(struct nlattr *nla, int attrtype)
62 return nla_find(nla_data(nla), nla_len(nla), attrtype);
66 #endif /* net/netlink.h */