Lines Matching +full:attribute +full:- +full:set
1 /* SPDX-License-Identifier: GPL-2.0 */
12 * ------------------------------------------------------------------------
14 * ------------------------------------------------------------------------
17 * <--- nlmsg_total_size(payload) --->
18 * <-- nlmsg_msg_size(payload) ->
19 * +----------+- - -+-------------+- - -+-------- - -
21 * +----------+- - -+-------------+- - -+-------- - -
22 * nlmsg_data(nlh)---^ ^
23 * nlmsg_next(nlh)-----------------------+
26 * <---------------------- nlmsg_len(nlh) --------------------->
27 * <------ hdrlen ------> <- nlmsg_attrlen(nlh, hdrlen) ->
28 * +----------------------+- - -+--------------------------------+
30 * +----------------------+- - -+--------------------------------+
31 * nlmsg_attrdata(nlh, hdrlen)---^
66 * nlmsg_find_attr() find an attribute in a message
74 * ------------------------------------------------------------------------
76 * ------------------------------------------------------------------------
78 * Attribute Format:
79 * <------- nla_total_size(payload) ------->
80 * <---- nla_attr_size(payload) ----->
81 * +----------+- - -+- - - - - - - - - +- - -+-------- - -
83 * +----------+- - -+- - - - - - - - - +- - -+-------- - -
84 * <- nla_len(nla) -> ^
85 * nla_data(nla)----^ |
86 * nla_next(nla)-----------------------------'
89 * struct nlattr netlink attribute header
91 * Attribute Construction:
92 * nla_reserve(skb, type, len) reserve room for an attribute
93 * nla_reserve_nohdr(skb, len) reserve room for an attribute w/o hdr
94 * nla_put(skb, type, len, data) add attribute to skb
95 * nla_put_nohdr(skb, len, data) add attribute w/o hdr
98 * Attribute Construction for Basic Types:
99 * nla_put_u8(skb, type, value) add u8 attribute to skb
100 * nla_put_u16(skb, type, value) add u16 attribute to skb
101 * nla_put_u32(skb, type, value) add u32 attribute to skb
103 * value, padattr) add u64 attribute to skb
104 * nla_put_s8(skb, type, value) add s8 attribute to skb
105 * nla_put_s16(skb, type, value) add s16 attribute to skb
106 * nla_put_s32(skb, type, value) add s32 attribute to skb
108 * padattr) add s64 attribute to skb
109 * nla_put_string(skb, type, str) add string attribute to skb
110 * nla_put_flag(skb, type) add flag attribute to skb
112 * padattr) add msecs attribute to skb
113 * nla_put_in_addr(skb, type, addr) add IPv4 address attribute to skb
114 * nla_put_in6_addr(skb, type, addr) add IPv6 address attribute to skb
117 * nla_nest_start(skb, type) start a nested attribute
118 * nla_nest_end(skb, nla) finalize a nested attribute
119 * nla_nest_cancel(skb, nla) cancel nested attribute construction
121 * Attribute Length Calculations:
122 * nla_attr_size(payload) length of attribute w/o padding
123 * nla_total_size(payload) length of attribute w/ padding
126 * Attribute Payload Access:
127 * nla_data(nla) head of attribute payload
128 * nla_len(nla) length of attribute payload
130 * Attribute Payload Access for Basic Types:
131 * nla_get_u8(nla) get payload for a u8 attribute
132 * nla_get_u16(nla) get payload for a u16 attribute
133 * nla_get_u32(nla) get payload for a u32 attribute
134 * nla_get_u64(nla) get payload for a u64 attribute
135 * nla_get_s8(nla) get payload for a s8 attribute
136 * nla_get_s16(nla) get payload for a s16 attribute
137 * nla_get_s32(nla) get payload for a s32 attribute
138 * nla_get_s64(nla) get payload for a s64 attribute
140 * nla_get_msecs(nla) get payload for a msecs attribute
142 * Attribute Misc:
143 * nla_memcpy(dest, nla, count) copy attribute into memory
144 * nla_memcmp(nla, data, size) compare attribute with memory area
145 * nla_strlcpy(dst, nla, size) copy attribute to a sized string
146 * nla_strcmp(nla, str) compare attribute with string
148 * Attribute Parsing:
150 * nla_next(nla, remaining) get next netlink attribute
153 * nla_find() find attribute in stream of attributes
154 * nla_find_nested() find attribute in nested attributes
163 * Standard attribute types to specify validation policy
187 #define NLA_TYPE_MAX (__NLA_TYPE_MAX - 1)
209 * struct nla_policy - attribute validation policy
210 * @type: Type of attribute or NLA_UNSPEC
211 * @validation_type: type of attribute validation done in addition to
212 * type-specific validation (e.g. range, function call), see
217 * accessible by attribute type up to the highest identifier to be expected.
223 * NLA_BINARY Maximum length of attribute payload
239 * All other Minimum length of attribute payload
242 * NLA_BITFIELD32 This is a 32-bit bitmap/bitselector attribute and
244 * NLA_REJECT This attribute is always rejected and `reject_message'
248 * also set `len' to the max attribute number. Use the
251 * parse, the nested sub-policies.
253 * must also set `len' to the max attribute number. Use
258 * level down and the attribute types directly in the
270 * the value of the integer attribute.
274 * of s16 - do that as usual in the code instead.
280 * NLA_U64 If the validation_type field instead is set to
288 * NLA_S64 If the validation_type field instead is set to
296 * integers) of the attribute is enforced.
298 * All other Unused - but note that it's a union
301 * NLA_BINARY Validation function called for the attribute.
302 * All other Unused - but note that it's a union
331 /* This entry is special, and used for the attribute at index 0
334 * starts for any attribute types >= this value, also, strict
343 * For completely new families it should be set to 1 so that the
345 * it should be set at least when new attributes are added to
346 * the enum used by the policy, and be set to the new value that
361 _NLA_POLICY_NESTED(ARRAY_SIZE(policy) - 1, policy)
363 _NLA_POLICY_NESTED_ARRAY(ARRAY_SIZE(policy) - 1, policy)
446 * struct nl_info - netlink source information
451 * @skip_notify_kernel: Skip selected in-kernel notifications
462 * enum netlink_validation - netlink message/attribute validation levels
463 * @NL_VALIDATE_LIBERAL: Old-style "be liberal" validation, not caring about
466 * @NL_VALIDATE_TRAILING: Reject junk data encountered after attribute parsing.
470 * This can safely be set by the kernel when the given policy has no
473 * @NL_VALIDATE_STRICT_ATTRS: strict attribute policy parsing (e.g.
475 * @NL_VALIDATE_NESTED: Check that NLA_F_NESTED is set for NLA_NESTED(_ARRAY)
538 * nlmsg_msg_size - length of netlink message not including padding
547 * nlmsg_total_size - length of netlink message including padding
556 * nlmsg_padlen - length of padding at the message's tail
561 return nlmsg_total_size(payload) - nlmsg_msg_size(payload); in nlmsg_padlen()
565 * nlmsg_data - head of message payload
574 * nlmsg_len - length of message payload
579 return nlh->nlmsg_len - NLMSG_HDRLEN; in nlmsg_len()
583 * nlmsg_attrdata - head of attributes data
595 * nlmsg_attrlen - length of attributes data
601 return nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen); in nlmsg_attrlen()
605 * nlmsg_ok - check if the netlink message fits into the remaining bytes
612 nlh->nlmsg_len >= sizeof(struct nlmsghdr) && in nlmsg_ok()
613 nlh->nlmsg_len <= remaining); in nlmsg_ok()
617 * nlmsg_next - next netlink message in message stream
627 int totlen = NLMSG_ALIGN(nlh->nlmsg_len); in nlmsg_next()
629 *remaining -= totlen; in nlmsg_next()
635 * nla_parse - Parse a stream of attributes into a tb buffer
637 * @maxtype: maximum attribute type to be expected
638 * @head: head of attribute stream
639 * @len: length of attribute stream
643 * Parses a stream of attributes and stores a pointer to each attribute in
644 * the tb array accessible via the attribute type. Attributes with a type
660 * nla_parse_deprecated - Parse a stream of attributes into a tb buffer
662 * @maxtype: maximum attribute type to be expected
663 * @head: head of attribute stream
664 * @len: length of attribute stream
668 * Parses a stream of attributes and stores a pointer to each attribute in
669 * the tb array accessible via the attribute type. Attributes with a type
685 * nla_parse_deprecated_strict - Parse a stream of attributes into a tb buffer
687 * @maxtype: maximum attribute type to be expected
688 * @head: head of attribute stream
689 * @len: length of attribute stream
693 * Parses a stream of attributes and stores a pointer to each attribute in
694 * the tb array accessible via the attribute type. Attributes with a type
711 * __nlmsg_parse - parse attributes of a netlink message
715 * @maxtype: maximum attribute type to be expected
728 if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) { in __nlmsg_parse()
730 return -EINVAL; in __nlmsg_parse()
739 * nlmsg_parse - parse attributes of a netlink message
743 * @maxtype: maximum attribute type to be expected
758 * nlmsg_parse_deprecated - parse attributes of a netlink message
762 * @maxtype: maximum attribute type to be expected
777 * nlmsg_parse_deprecated_strict - parse attributes of a netlink message
781 * @maxtype: maximum attribute type to be expected
797 * nlmsg_find_attr - find a specific attribute in a netlink message
800 * @attrtype: type of attribute to look for
802 * Returns the first attribute which matches the specified type.
812 * nla_validate_deprecated - Validate a stream of attributes
813 * @head: head of attribute stream
814 * @len: length of attribute stream
815 * @maxtype: maximum attribute type to be expected
820 * Validates all attributes in the specified attribute stream against the
836 * nla_validate - Validate a stream of attributes
837 * @head: head of attribute stream
838 * @len: length of attribute stream
839 * @maxtype: maximum attribute type to be expected
843 * Validates all attributes in the specified attribute stream against the
858 * nlmsg_validate_deprecated - validate a netlink message including attributes
861 * @maxtype: maximum attribute type to be expected
870 if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) in nlmsg_validate_deprecated()
871 return -EINVAL; in nlmsg_validate_deprecated()
881 * nlmsg_report - need to report back to application?
888 return !!(nlh->nlmsg_flags & NLM_F_ECHO); in nlmsg_report()
892 * nlmsg_for_each_attr - iterate over a stream of attributes
893 * @pos: loop counter, set to current attribute
903 * nlmsg_put - Add a new netlink message to an skb
924 * nlmsg_put_answer - Add a new callback based netlink message to an skb
939 return nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, in nlmsg_put_answer()
944 * nlmsg_new - Allocate a new netlink message
957 * nlmsg_end - Finalize a netlink message
967 nlh->nlmsg_len = skb_tail_pointer(skb) - (unsigned char *)nlh; in nlmsg_end()
971 * nlmsg_get_pos - return current position in netlink message
982 * nlmsg_trim - Trim message to a mark
991 WARN_ON((unsigned char *) mark < skb->data); in nlmsg_trim()
992 skb_trim(skb, (unsigned char *) mark - skb->data); in nlmsg_trim()
997 * nlmsg_cancel - Cancel construction of a netlink message
1010 * nlmsg_free - free a netlink message
1019 * nlmsg_multicast - multicast a netlink message
1041 * nlmsg_unicast - unicast a netlink message
1058 * nlmsg_for_each_msg - iterate over a stream of messages
1059 * @pos: loop counter, set to current message
1070 * nl_dump_check_consistent - check if sequence is consistent and advertise if not
1077 * The correct way to use it is to set cb->seq to the generation counter when
1088 if (cb->prev_seq && cb->seq != cb->prev_seq) in nl_dump_check_consistent()
1089 nlh->nlmsg_flags |= NLM_F_DUMP_INTR; in nl_dump_check_consistent()
1090 cb->prev_seq = cb->seq; in nl_dump_check_consistent()
1098 * nla_attr_size - length of attribute not including padding
1107 * nla_total_size - total length of attribute including padding
1116 * nla_padlen - length of padding at the tail of attribute
1121 return nla_total_size(payload) - nla_attr_size(payload); in nla_padlen()
1125 * nla_type - attribute type
1126 * @nla: netlink attribute
1130 return nla->nla_type & NLA_TYPE_MASK; in nla_type()
1134 * nla_data - head of payload
1135 * @nla: netlink attribute
1143 * nla_len - length of payload
1144 * @nla: netlink attribute
1148 return nla->nla_len - NLA_HDRLEN; in nla_len()
1152 * nla_ok - check if the netlink attribute fits into the remaining bytes
1153 * @nla: netlink attribute
1154 * @remaining: number of bytes remaining in attribute stream
1159 nla->nla_len >= sizeof(*nla) && in nla_ok()
1160 nla->nla_len <= remaining; in nla_ok()
1164 * nla_next - next netlink attribute in attribute stream
1165 * @nla: netlink attribute
1166 * @remaining: number of bytes remaining in attribute stream
1168 * Returns the next netlink attribute in the attribute stream and
1169 * decrements remaining by the size of the current attribute.
1173 unsigned int totlen = NLA_ALIGN(nla->nla_len); in nla_next()
1175 *remaining -= totlen; in nla_next()
1180 * nla_find_nested - find attribute in a set of nested attributes
1181 * @nla: attribute containing the nested attributes
1182 * @attrtype: type of attribute to look for
1184 * Returns the first attribute which matches the specified type.
1193 * nla_parse_nested - parse nested attributes
1195 * @maxtype: maximum attribute type to be expected
1196 * @nla: attribute containing the nested attributes
1207 if (!(nla->nla_type & NLA_F_NESTED)) { in nla_parse_nested()
1209 return -EINVAL; in nla_parse_nested()
1217 * nla_parse_nested_deprecated - parse nested attributes
1219 * @maxtype: maximum attribute type to be expected
1220 * @nla: attribute containing the nested attributes
1236 * nla_put_u8 - Add a u8 netlink attribute to a socket buffer
1237 * @skb: socket buffer to add attribute to
1238 * @attrtype: attribute type
1243 /* temporary variables to work around GCC PR81715 with asan-stack=1 */ in nla_put_u8()
1250 * nla_put_u16 - Add a u16 netlink attribute to a socket buffer
1251 * @skb: socket buffer to add attribute to
1252 * @attrtype: attribute type
1263 * nla_put_be16 - Add a __be16 netlink attribute to a socket buffer
1264 * @skb: socket buffer to add attribute to
1265 * @attrtype: attribute type
1276 * nla_put_net16 - Add 16-bit network byte order netlink attribute to a socket buffer
1277 * @skb: socket buffer to add attribute to
1278 * @attrtype: attribute type
1289 * nla_put_le16 - Add a __le16 netlink attribute to a socket buffer
1290 * @skb: socket buffer to add attribute to
1291 * @attrtype: attribute type
1302 * nla_put_u32 - Add a u32 netlink attribute to a socket buffer
1303 * @skb: socket buffer to add attribute to
1304 * @attrtype: attribute type
1315 * nla_put_be32 - Add a __be32 netlink attribute to a socket buffer
1316 * @skb: socket buffer to add attribute to
1317 * @attrtype: attribute type
1328 * nla_put_net32 - Add 32-bit network byte order netlink attribute to a socket buffer
1329 * @skb: socket buffer to add attribute to
1330 * @attrtype: attribute type
1341 * nla_put_le32 - Add a __le32 netlink attribute to a socket buffer
1342 * @skb: socket buffer to add attribute to
1343 * @attrtype: attribute type
1354 * nla_put_u64_64bit - Add a u64 netlink attribute to a skb and align it
1355 * @skb: socket buffer to add attribute to
1356 * @attrtype: attribute type
1358 * @padattr: attribute type for the padding
1369 * nla_put_be64 - Add a __be64 netlink attribute to a socket buffer and align it
1370 * @skb: socket buffer to add attribute to
1371 * @attrtype: attribute type
1373 * @padattr: attribute type for the padding
1384 * nla_put_net64 - Add 64-bit network byte order nlattr to a skb and align it
1385 * @skb: socket buffer to add attribute to
1386 * @attrtype: attribute type
1388 * @padattr: attribute type for the padding
1400 * nla_put_le64 - Add a __le64 netlink attribute to a socket buffer and align it
1401 * @skb: socket buffer to add attribute to
1402 * @attrtype: attribute type
1404 * @padattr: attribute type for the padding
1415 * nla_put_s8 - Add a s8 netlink attribute to a socket buffer
1416 * @skb: socket buffer to add attribute to
1417 * @attrtype: attribute type
1428 * nla_put_s16 - Add a s16 netlink attribute to a socket buffer
1429 * @skb: socket buffer to add attribute to
1430 * @attrtype: attribute type
1441 * nla_put_s32 - Add a s32 netlink attribute to a socket buffer
1442 * @skb: socket buffer to add attribute to
1443 * @attrtype: attribute type
1454 * nla_put_s64 - Add a s64 netlink attribute to a socket buffer and align it
1455 * @skb: socket buffer to add attribute to
1456 * @attrtype: attribute type
1458 * @padattr: attribute type for the padding
1469 * nla_put_string - Add a string netlink attribute to a socket buffer
1470 * @skb: socket buffer to add attribute to
1471 * @attrtype: attribute type
1481 * nla_put_flag - Add a flag netlink attribute to a socket buffer
1482 * @skb: socket buffer to add attribute to
1483 * @attrtype: attribute type
1491 * nla_put_msecs - Add a msecs netlink attribute to a skb and align it
1492 * @skb: socket buffer to add attribute to
1493 * @attrtype: attribute type
1495 * @padattr: attribute type for the padding
1506 * nla_put_in_addr - Add an IPv4 address netlink attribute to a socket
1508 * @skb: socket buffer to add attribute to
1509 * @attrtype: attribute type
1521 * nla_put_in6_addr - Add an IPv6 address netlink attribute to a socket
1523 * @skb: socket buffer to add attribute to
1524 * @attrtype: attribute type
1534 * nla_put_bitfield32 - Add a bitfield32 netlink attribute to a socket buffer
1535 * @skb: socket buffer to add attribute to
1536 * @attrtype: attribute type
1549 * nla_get_u32 - return payload of u32 attribute
1550 * @nla: u32 netlink attribute
1558 * nla_get_be32 - return payload of __be32 attribute
1559 * @nla: __be32 netlink attribute
1567 * nla_get_le32 - return payload of __le32 attribute
1568 * @nla: __le32 netlink attribute
1576 * nla_get_u16 - return payload of u16 attribute
1577 * @nla: u16 netlink attribute
1585 * nla_get_be16 - return payload of __be16 attribute
1586 * @nla: __be16 netlink attribute
1594 * nla_get_le16 - return payload of __le16 attribute
1595 * @nla: __le16 netlink attribute
1603 * nla_get_u8 - return payload of u8 attribute
1604 * @nla: u8 netlink attribute
1612 * nla_get_u64 - return payload of u64 attribute
1613 * @nla: u64 netlink attribute
1625 * nla_get_be64 - return payload of __be64 attribute
1626 * @nla: __be64 netlink attribute
1638 * nla_get_le64 - return payload of __le64 attribute
1639 * @nla: __le64 netlink attribute
1647 * nla_get_s32 - return payload of s32 attribute
1648 * @nla: s32 netlink attribute
1656 * nla_get_s16 - return payload of s16 attribute
1657 * @nla: s16 netlink attribute
1665 * nla_get_s8 - return payload of s8 attribute
1666 * @nla: s8 netlink attribute
1674 * nla_get_s64 - return payload of s64 attribute
1675 * @nla: s64 netlink attribute
1687 * nla_get_flag - return payload of flag attribute
1688 * @nla: flag netlink attribute
1696 * nla_get_msecs - return payload of msecs attribute
1697 * @nla: msecs netlink attribute
1709 * nla_get_in_addr - return payload of IPv4 address attribute
1710 * @nla: IPv4 address netlink attribute
1718 * nla_get_in6_addr - return payload of IPv6 address attribute
1719 * @nla: IPv6 address netlink attribute
1730 * nla_get_bitfield32 - return payload of 32 bitfield attribute
1731 * @nla: nla_bitfield32 attribute
1742 * nla_memdup - duplicate attribute memory (kmemdup)
1743 * @src: netlink attribute to duplicate from
1752 * nla_nest_start_noflag - Start a new level of nested attributes
1754 * @attrtype: attribute type of container
1760 * Returns the container attribute or NULL on error
1774 * nla_nest_start - Start a new level of nested attributes, with NLA_F_NESTED
1776 * @attrtype: attribute type of container
1778 * Unlike nla_nest_start_noflag(), mark the nest attribute with NLA_F_NESTED
1781 * Returns the container attribute or NULL on error
1789 * nla_nest_end - Finalize nesting of attributes
1791 * @start: container attribute
1793 * Corrects the container attribute header to include the all
1800 start->nla_len = skb_tail_pointer(skb) - (unsigned char *)start; in nla_nest_end()
1801 return skb->len; in nla_nest_end()
1805 * nla_nest_cancel - Cancel nesting of attributes
1807 * @start: container attribute
1809 * Removes the container attribute and including all nested
1810 * attributes. Returns -EMSGSIZE
1818 * __nla_validate_nested - Validate a stream of nested attributes
1819 * @start: container attribute
1820 * @maxtype: maximum attribute type to be expected
1825 * Validates all attributes in the nested attribute stream against the
1859 * nla_need_padding_for_64bit - test 64-bit alignment of the next attribute
1862 * Return true if padding is needed to align the next attribute (nla_data()) to
1863 * a 64-bit aligned area.
1869 * if the skb->data _is_ aligned. A NOP attribute, plus in nla_need_padding_for_64bit()
1870 * nlattr header for next attribute, will make nla_data() in nla_need_padding_for_64bit()
1871 * 8-byte aligned. in nla_need_padding_for_64bit()
1880 * nla_align_64bit - 64-bit align the nla_data() of next attribute
1882 * @padattr: attribute type for the padding
1884 * Conditionally emit a padding netlink attribute in order to make
1885 * the next attribute we emit have a 64-bit aligned nla_data() area.
1895 return -EMSGSIZE; in nla_align_64bit()
1901 * nla_total_size_64bit - total length of attribute including padding
1914 * nla_for_each_attr - iterate over a stream of attributes
1915 * @pos: loop counter, set to current attribute
1916 * @head: head of attribute stream
1917 * @len: length of attribute stream
1926 * nla_for_each_nested - iterate over nested attributes
1927 * @pos: loop counter, set to current attribute
1928 * @nla: attribute containing the nested attributes
1935 * nla_is_last - Test if attribute is last in stream
1936 * @nla: attribute to test
1941 return nla->nla_len == rem; in nla_is_last()