summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2015-04-01 17:31:36 +0200
committerHauke Mehrtens <hauke@hauke-m.de>2015-04-05 23:24:06 +0200
commit96915650899b720c2fa21f40654ece84bdc0746e (patch)
treee7c11152132f6282b1d93ef4b371153221fd2825
parentba78c101455b85c58831c808e0f0cf0a12f2c760 (diff)
backports: backport netlink IP/IPv6 address accessors
These were introduced upstream in commits 67b61f6c130a and 930345ea6304. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--backport/backport-include/net/netlink.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/backport/backport-include/net/netlink.h b/backport/backport-include/net/netlink.h
index 9324d02d..35d9260f 100644
--- a/backport/backport-include/net/netlink.h
+++ b/backport/backport-include/net/netlink.h
@@ -2,6 +2,7 @@
#define __BACKPORT_NET_NETLINK_H
#include_next <net/netlink.h>
#include <linux/version.h>
+#include <linux/in6.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
/**
@@ -137,4 +138,33 @@ static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value)
#define NLA_TYPE_MAX (__NLA_TYPE_MAX - 1)
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
+#define nla_put_in_addr LINUX_BACKPORT(nla_put_in_addr)
+static inline int nla_put_in_addr(struct sk_buff *skb, int attrtype,
+ __be32 addr)
+{
+ return nla_put_be32(skb, attrtype, addr);
+}
+
+#define nla_put_in6_addr LINUX_BACKPORT(nla_put_in6_addr)
+static inline int nla_put_in6_addr(struct sk_buff *skb, int attrtype,
+ const struct in6_addr *addr)
+{
+ return nla_put(skb, attrtype, sizeof(*addr), addr);
+}
+
+static inline __be32 nla_get_in_addr(const struct nlattr *nla)
+{
+ return *(__be32 *) nla_data(nla);
+}
+
+static inline struct in6_addr nla_get_in6_addr(const struct nlattr *nla)
+{
+ struct in6_addr tmp;
+
+ nla_memcpy(&tmp, nla, sizeof(tmp));
+ return tmp;
+}
+#endif /* < 4.1 */
+
#endif /* __BACKPORT_NET_NETLINK_H */