aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/netlink.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/netlink.h')
-rw-r--r--include/net/netlink.h34
1 files changed, 24 insertions, 10 deletions
diff --git a/include/net/netlink.h b/include/net/netlink.h
index f3b201d335b3..02740a94f108 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -225,13 +225,15 @@ extern int nlmsg_notify(struct sock *sk, struct sk_buff *skb,
225 u32 pid, unsigned int group, int report, 225 u32 pid, unsigned int group, int report,
226 gfp_t flags); 226 gfp_t flags);
227 227
228extern int nla_validate(struct nlattr *head, int len, int maxtype, 228extern int nla_validate(const struct nlattr *head,
229 int len, int maxtype,
229 const struct nla_policy *policy); 230 const struct nla_policy *policy);
230extern int nla_parse(struct nlattr *tb[], int maxtype, 231extern int nla_parse(struct nlattr **tb, int maxtype,
231 struct nlattr *head, int len, 232 const struct nlattr *head, int len,
232 const struct nla_policy *policy); 233 const struct nla_policy *policy);
233extern int nla_policy_len(const struct nla_policy *, int); 234extern int nla_policy_len(const struct nla_policy *, int);
234extern struct nlattr * nla_find(struct nlattr *head, int len, int attrtype); 235extern struct nlattr * nla_find(const struct nlattr *head,
236 int len, int attrtype);
235extern size_t nla_strlcpy(char *dst, const struct nlattr *nla, 237extern size_t nla_strlcpy(char *dst, const struct nlattr *nla,
236 size_t dstsize); 238 size_t dstsize);
237extern int nla_memcpy(void *dest, const struct nlattr *src, int count); 239extern int nla_memcpy(void *dest, const struct nlattr *src, int count);
@@ -288,7 +290,7 @@ static inline int nlmsg_padlen(int payload)
288 290
289/** 291/**
290 * nlmsg_data - head of message payload 292 * nlmsg_data - head of message payload
291 * @nlh: netlink messsage header 293 * @nlh: netlink message header
292 */ 294 */
293static inline void *nlmsg_data(const struct nlmsghdr *nlh) 295static inline void *nlmsg_data(const struct nlmsghdr *nlh)
294{ 296{
@@ -346,7 +348,8 @@ static inline int nlmsg_ok(const struct nlmsghdr *nlh, int remaining)
346 * Returns the next netlink message in the message stream and 348 * Returns the next netlink message in the message stream and
347 * decrements remaining by the size of the current message. 349 * decrements remaining by the size of the current message.
348 */ 350 */
349static inline struct nlmsghdr *nlmsg_next(struct nlmsghdr *nlh, int *remaining) 351static inline struct nlmsghdr *
352nlmsg_next(const struct nlmsghdr *nlh, int *remaining)
350{ 353{
351 int totlen = NLMSG_ALIGN(nlh->nlmsg_len); 354 int totlen = NLMSG_ALIGN(nlh->nlmsg_len);
352 355
@@ -384,7 +387,7 @@ static inline int nlmsg_parse(const struct nlmsghdr *nlh, int hdrlen,
384 * 387 *
385 * Returns the first attribute which matches the specified type. 388 * Returns the first attribute which matches the specified type.
386 */ 389 */
387static inline struct nlattr *nlmsg_find_attr(struct nlmsghdr *nlh, 390static inline struct nlattr *nlmsg_find_attr(const struct nlmsghdr *nlh,
388 int hdrlen, int attrtype) 391 int hdrlen, int attrtype)
389{ 392{
390 return nla_find(nlmsg_attrdata(nlh, hdrlen), 393 return nla_find(nlmsg_attrdata(nlh, hdrlen),
@@ -398,7 +401,8 @@ static inline struct nlattr *nlmsg_find_attr(struct nlmsghdr *nlh,
398 * @maxtype: maximum attribute type to be expected 401 * @maxtype: maximum attribute type to be expected
399 * @policy: validation policy 402 * @policy: validation policy
400 */ 403 */
401static inline int nlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype, 404static inline int nlmsg_validate(const struct nlmsghdr *nlh,
405 int hdrlen, int maxtype,
402 const struct nla_policy *policy) 406 const struct nla_policy *policy)
403{ 407{
404 if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) 408 if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen))
@@ -727,7 +731,8 @@ static inline struct nlattr *nla_next(const struct nlattr *nla, int *remaining)
727 * 731 *
728 * Returns the first attribute which matches the specified type. 732 * Returns the first attribute which matches the specified type.
729 */ 733 */
730static inline struct nlattr *nla_find_nested(struct nlattr *nla, int attrtype) 734static inline struct nlattr *
735nla_find_nested(const struct nlattr *nla, int attrtype)
731{ 736{
732 return nla_find(nla_data(nla), nla_len(nla), attrtype); 737 return nla_find(nla_data(nla), nla_len(nla), attrtype);
733} 738}
@@ -851,18 +856,27 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,
851#define NLA_PUT_BE16(skb, attrtype, value) \ 856#define NLA_PUT_BE16(skb, attrtype, value) \
852 NLA_PUT_TYPE(skb, __be16, attrtype, value) 857 NLA_PUT_TYPE(skb, __be16, attrtype, value)
853 858
859#define NLA_PUT_NET16(skb, attrtype, value) \
860 NLA_PUT_BE16(skb, attrtype | NLA_F_NET_BYTEORDER, value)
861
854#define NLA_PUT_U32(skb, attrtype, value) \ 862#define NLA_PUT_U32(skb, attrtype, value) \
855 NLA_PUT_TYPE(skb, u32, attrtype, value) 863 NLA_PUT_TYPE(skb, u32, attrtype, value)
856 864
857#define NLA_PUT_BE32(skb, attrtype, value) \ 865#define NLA_PUT_BE32(skb, attrtype, value) \
858 NLA_PUT_TYPE(skb, __be32, attrtype, value) 866 NLA_PUT_TYPE(skb, __be32, attrtype, value)
859 867
868#define NLA_PUT_NET32(skb, attrtype, value) \
869 NLA_PUT_BE32(skb, attrtype | NLA_F_NET_BYTEORDER, value)
870
860#define NLA_PUT_U64(skb, attrtype, value) \ 871#define NLA_PUT_U64(skb, attrtype, value) \
861 NLA_PUT_TYPE(skb, u64, attrtype, value) 872 NLA_PUT_TYPE(skb, u64, attrtype, value)
862 873
863#define NLA_PUT_BE64(skb, attrtype, value) \ 874#define NLA_PUT_BE64(skb, attrtype, value) \
864 NLA_PUT_TYPE(skb, __be64, attrtype, value) 875 NLA_PUT_TYPE(skb, __be64, attrtype, value)
865 876
877#define NLA_PUT_NET64(skb, attrtype, value) \
878 NLA_PUT_BE64(skb, attrtype | NLA_F_NET_BYTEORDER, value)
879
866#define NLA_PUT_STRING(skb, attrtype, value) \ 880#define NLA_PUT_STRING(skb, attrtype, value) \
867 NLA_PUT(skb, attrtype, strlen(value) + 1, value) 881 NLA_PUT(skb, attrtype, strlen(value) + 1, value)
868 882
@@ -1032,7 +1046,7 @@ static inline void nla_nest_cancel(struct sk_buff *skb, struct nlattr *start)
1032 * 1046 *
1033 * Returns 0 on success or a negative error code. 1047 * Returns 0 on success or a negative error code.
1034 */ 1048 */
1035static inline int nla_validate_nested(struct nlattr *start, int maxtype, 1049static inline int nla_validate_nested(const struct nlattr *start, int maxtype,
1036 const struct nla_policy *policy) 1050 const struct nla_policy *policy)
1037{ 1051{
1038 return nla_validate(nla_data(start), nla_len(start), maxtype, policy); 1052 return nla_validate(nla_data(start), nla_len(start), maxtype, policy);