Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * NETLINK      Netlink attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #ifndef __LIBBPF_NLATTR_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #define __LIBBPF_NLATTR_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <stdint.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/netlink.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) /* avoid multiple definition of netlink features */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define __LINUX_NETLINK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * Standard attribute types to specify validation policy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	LIBBPF_NLA_UNSPEC,	/**< Unspecified type, binary data chunk */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	LIBBPF_NLA_U8,		/**< 8 bit integer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	LIBBPF_NLA_U16,		/**< 16 bit integer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	LIBBPF_NLA_U32,		/**< 32 bit integer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	LIBBPF_NLA_U64,		/**< 64 bit integer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	LIBBPF_NLA_STRING,	/**< NUL terminated character string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	LIBBPF_NLA_FLAG,	/**< Flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	LIBBPF_NLA_MSECS,	/**< Micro seconds (64bit) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	LIBBPF_NLA_NESTED,	/**< Nested attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	__LIBBPF_NLA_TYPE_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define LIBBPF_NLA_TYPE_MAX (__LIBBPF_NLA_TYPE_MAX - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * @ingroup attr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * Attribute validation policy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * See section @core_doc{core_attr_parse,Attribute Parsing} for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) struct libbpf_nla_policy {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	/** Type of attribute or LIBBPF_NLA_UNSPEC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	uint16_t	type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	/** Minimal length of payload required */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	uint16_t	minlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	/** Maximal length of payload allowed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	uint16_t	maxlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * @ingroup attr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * Iterate over a stream of attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * @arg pos	loop counter, set to current attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * @arg head	head of attribute stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * @arg len	length of attribute stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  * @arg rem	initialized to len, holds bytes currently remaining in stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define libbpf_nla_for_each_attr(pos, head, len, rem) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	for (pos = head, rem = len; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	     nla_ok(pos, rem); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	     pos = nla_next(pos, &(rem)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  * libbpf_nla_data - head of payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * @nla: netlink attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) static inline void *libbpf_nla_data(const struct nlattr *nla)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	return (char *) nla + NLA_HDRLEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static inline uint8_t libbpf_nla_getattr_u8(const struct nlattr *nla)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	return *(uint8_t *)libbpf_nla_data(nla);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) static inline uint32_t libbpf_nla_getattr_u32(const struct nlattr *nla)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	return *(uint32_t *)libbpf_nla_data(nla);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) static inline const char *libbpf_nla_getattr_str(const struct nlattr *nla)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	return (const char *)libbpf_nla_data(nla);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  * libbpf_nla_len - length of payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  * @nla: netlink attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) static inline int libbpf_nla_len(const struct nlattr *nla)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	return nla->nla_len - NLA_HDRLEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) int libbpf_nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		     int len, struct libbpf_nla_policy *policy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) int libbpf_nla_parse_nested(struct nlattr *tb[], int maxtype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			    struct nlattr *nla,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			    struct libbpf_nla_policy *policy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int libbpf_nla_dump_errormsg(struct nlmsghdr *nlh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #endif /* __LIBBPF_NLATTR_H */