[NLA_S64] = sizeof(int64_t),
};
-static int validate_nla(struct nlattr *nla, int maxtype,
- struct nla_policy *policy)
+static int validate_nla(const struct nlattr *nla, int maxtype,
+ const struct nla_policy *policy)
{
- struct nla_policy *pt;
+ const struct nla_policy *pt;
int minlen = 0, type = nla_type(nla);
if (type <= 0 || type > maxtype)
* @return 0 on success or a negative error code.
*/
int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len,
- struct nla_policy *policy)
+ const struct nla_policy *policy)
{
struct nlattr *nla;
int rem, err;
*
* @return 0 on success or a negative error code.
*/
-int nla_validate(struct nlattr *head, int len, int maxtype,
- struct nla_policy *policy)
+int nla_validate(const struct nlattr *head, int len, int maxtype,
+ const struct nla_policy *policy)
{
- struct nlattr *nla;
+ const struct nlattr *nla;
int rem, err;
nla_for_each_attr(nla, head, len, rem) {
extern int nla_ok(const struct nlattr *, int);
extern struct nlattr * nla_next(const struct nlattr *, int *);
extern int nla_parse(struct nlattr **, int, struct nlattr *,
- int, struct nla_policy *);
-extern int nla_validate(struct nlattr *, int, int,
- struct nla_policy *);
+ int, const struct nla_policy *);
+extern int nla_validate(const struct nlattr *, int, int,
+ const struct nla_policy *);
extern struct nlattr * nla_find(struct nlattr *, int, int);
/* Unspecific attribute */
*
* @return The number of bytes copied to dest.
*/
-static inline int nla_memcpy(void *dest, struct nlattr *src, int count)
+static inline int nla_memcpy(void *dest, const struct nlattr *src, int count)
{
int minlen;
*
* @return Payload as 8 bit integer.
*/
-static inline int8_t nla_get_s8(struct nlattr *nla)
+static inline int8_t nla_get_s8(const struct nlattr *nla)
{
- return *(int8_t *) nla_data(nla);
+ return *(const int8_t *) nla_data(nla);
}
/**
*
* @return Payload as 8 bit integer.
*/
-static inline uint8_t nla_get_u8(struct nlattr *nla)
+static inline uint8_t nla_get_u8(const struct nlattr *nla)
{
- return *(uint8_t *) nla_data(nla);
+ return *(const uint8_t *) nla_data(nla);
}
/**
*
* @return Payload as 16 bit integer.
*/
-static inline int16_t nla_get_s16(struct nlattr *nla)
+static inline int16_t nla_get_s16(const struct nlattr *nla)
{
- return *(int16_t *) nla_data(nla);
+ return *(const int16_t *) nla_data(nla);
}
/**
*
* @return Payload as 16 bit integer.
*/
-static inline uint16_t nla_get_u16(struct nlattr *nla)
+static inline uint16_t nla_get_u16(const struct nlattr *nla)
{
- return *(uint16_t *) nla_data(nla);
+ return *(const uint16_t *) nla_data(nla);
}
/**
*
* @return Payload as 32 bit integer.
*/
-static inline int32_t nla_get_s32(struct nlattr *nla)
+static inline int32_t nla_get_s32(const struct nlattr *nla)
{
- return *(int32_t *) nla_data(nla);
+ return *(const int32_t *) nla_data(nla);
}
/**
*
* @return Payload as 32 bit integer.
*/
-static inline uint32_t nla_get_u32(struct nlattr *nla)
+static inline uint32_t nla_get_u32(const struct nlattr *nla)
{
- return *(uint32_t *) nla_data(nla);
+ return *(const uint32_t *) nla_data(nla);
}
/**
*
* @return Payload as 64 bit integer.
*/
-static inline int64_t nla_get_s64(struct nlattr *nla)
+static inline int64_t nla_get_s64(const struct nlattr *nla)
{
int64_t tmp;
*
* @return Payload as 64 bit integer.
*/
-static inline uint64_t nla_get_u64(struct nlattr *nla)
+static inline uint64_t nla_get_u64(const struct nlattr *nla)
{
uint64_t tmp;
*
* @return Pointer to attribute payload.
*/
-static inline char *nla_get_string(struct nlattr *nla)
+static inline char *nla_get_string(const struct nlattr *nla)
{
return (char *) nla_data(nla);
}
-static inline char *nla_strdup(struct nlattr *nla)
+static inline char *nla_strdup(const struct nlattr *nla)
{
return strdup(nla_get_string(nla));
}
*
* @return True if flag is set, otherwise false.
*/
-static inline int nla_get_flag(struct nlattr *nla)
+static inline int nla_get_flag(const struct nlattr *nla)
{
return !!nla;
}
*
* @return the number of milliseconds.
*/
-static inline unsigned long nla_get_msecs(struct nlattr *nla)
+static inline unsigned long nla_get_msecs(const struct nlattr *nla)
{
return nla_get_u64(nla);
}
* @see nla_put
* @return 0 on success or a negative error code.
*/
-static inline int nla_put_nested(struct nl_msg *msg, int attrtype, struct nl_msg *nested)
+static inline int nla_put_nested(struct nl_msg *msg, int attrtype, const struct nl_msg *nested)
{
return nla_put(msg, attrtype, nlmsg_len(nested->nm_nlh),
nlmsg_data(nested->nm_nlh));
* @return 0 on success or a negative error code.
*/
static inline int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla,
- struct nla_policy *policy)
+ const struct nla_policy *policy)
{
return nla_parse(tb, maxtype, (struct nlattr *)nla_data(nla), nla_len(nla), policy);
}
* See nla_parse()
*/
int nlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[],
- int maxtype, struct nla_policy *policy)
+ int maxtype, const struct nla_policy *policy)
{
if (!nlmsg_valid_hdr(nlh, hdrlen))
return -NLE_MSG_TOOSHORT;
* @arg maxtype maximum attribute type to be expected
* @arg policy validation policy
*/
-int nlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype,
- struct nla_policy *policy)
+int nlmsg_validate(const struct nlmsghdr *nlh, int hdrlen, int maxtype,
+ const struct nla_policy *policy)
{
if (!nlmsg_valid_hdr(nlh, hdrlen))
return -NLE_MSG_TOOSHORT;