Lines Matching +full:nested +full:- +full:attributes

1 /* SPDX-License-Identifier: GPL-2.0 */
11 * Netlink Messages and Attributes Interface (As Seen On TV)
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 * +----------------------+- - -+--------------------------------+
29 * | Family Header | Pad | Attributes |
30 * +----------------------+- - -+--------------------------------+
31 * nlmsg_attrdata(nlh, hdrlen)---^
59 * nlmsg_attrdata(nlh, hdrlen) head of attributes data
60 * nlmsg_attrlen(nlh, hdrlen) length of attributes data
65 * nlmsg_parse() parse attributes of a message
69 * nlmsg_for_each_attr() loop over all attributes
74 * ------------------------------------------------------------------------
75 * Attributes Interface
76 * ------------------------------------------------------------------------
79 * <------- nla_total_size(payload) ------->
80 * <---- nla_attr_size(payload) ----->
81 * +----------+- - -+- - - - - - - - - +- - -+-------- - -
83 * +----------+- - -+- - - - - - - - - +- - -+-------- - -
84 * <- nla_len(nla) -> ^
85 * nla_data(nla)----^ |
86 * nla_next(nla)-----------------------------'
116 * Nested Attributes Construction:
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
151 * nla_validate() validate a stream of attributes
152 * nla_validate_nested() validate a stream of nested attributes
153 * nla_find() find attribute in stream of attributes
154 * nla_find_nested() find attribute in nested attributes
156 * nla_parse_nested() parse nested attributes
157 * nla_for_each_attr() loop over all attributes
158 * nla_for_each_nested() loop over the nested attributes
189 #define NLA_TYPE_MAX (__NLA_TYPE_MAX - 1)
211 * struct nla_policy - attribute validation policy
214 * type-specific validation (e.g. range, function call), see
229 * nested header (or empty); len field is used if
231 * number in the nested policy.
245 * NLA_BITFIELD32 This is a 32-bit bitmap/bitselector attribute and
250 * NLA_NESTED `nested_policy' to a nested policy to validate, must
254 * parse, the nested sub-policies.
255 * NLA_NESTED_ARRAY `nested_policy' points to a nested policy to validate,
259 * NLA_NESTED has the nested attributes directly inside
260 * while an array has the nested attributes at another
279 * of s16 - do that using the NLA_POLICY_FULL_RANGE()
304 * All other Unused - but note that it's a union
308 * All other Unused - but note that it's a union
342 * validation is enforced for all attributes. For existing ones
343 * it should be set at least when new attributes are added to
372 _NLA_POLICY_NESTED(ARRAY_SIZE(policy) - 1, policy)
374 _NLA_POLICY_NESTED_ARRAY(ARRAY_SIZE(policy) - 1, policy)
458 * struct nl_info - netlink source information
463 * @skip_notify_kernel: Skip selected in-kernel notifications
474 * enum netlink_validation - netlink message/attribute validation levels
475 * @NL_VALIDATE_LIBERAL: Old-style "be liberal" validation, not caring about
476 * extra data at the end of the message, attributes being longer than
477 * they should be, or unknown attributes being present.
479 * @NL_VALIDATE_MAXTYPE: Reject attributes > max type; Together with _TRAILING
481 * @NL_VALIDATE_UNSPEC: Reject attributes with NLA_UNSPEC in the policy.
550 * nlmsg_msg_size - length of netlink message not including padding
559 * nlmsg_total_size - length of netlink message including padding
568 * nlmsg_padlen - length of padding at the message's tail
573 return nlmsg_total_size(payload) - nlmsg_msg_size(payload); in nlmsg_padlen()
577 * nlmsg_data - head of message payload
586 * nlmsg_len - length of message payload
591 return nlh->nlmsg_len - NLMSG_HDRLEN; in nlmsg_len()
595 * nlmsg_attrdata - head of attributes data
607 * nlmsg_attrlen - length of attributes data
613 return nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen); in nlmsg_attrlen()
617 * nlmsg_ok - check if the netlink message fits into the remaining bytes
624 nlh->nlmsg_len >= sizeof(struct nlmsghdr) && in nlmsg_ok()
625 nlh->nlmsg_len <= remaining); in nlmsg_ok()
629 * nlmsg_next - next netlink message in message stream
639 int totlen = NLMSG_ALIGN(nlh->nlmsg_len); in nlmsg_next()
641 *remaining -= totlen; in nlmsg_next()
647 * nla_parse - Parse a stream of attributes into a tb buffer
655 * Parses a stream of attributes and stores a pointer to each attribute in
656 * the tb array accessible via the attribute type. Attributes with a type
657 * exceeding maxtype will be rejected, policy must be specified, attributes
672 * nla_parse_deprecated - Parse a stream of attributes into a tb buffer
680 * Parses a stream of attributes and stores a pointer to each attribute in
681 * the tb array accessible via the attribute type. Attributes with a type
682 * exceeding maxtype will be ignored and attributes from the policy are not
683 * always strictly validated (only for new attributes).
697 * nla_parse_deprecated_strict - Parse a stream of attributes into a tb buffer
705 * Parses a stream of attributes and stores a pointer to each attribute in
706 * the tb array accessible via the attribute type. Attributes with a type
708 * policy is not completely strictly validated (only for new attributes).
723 * __nlmsg_parse - parse attributes of a netlink message
740 if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) { in __nlmsg_parse()
742 return -EINVAL; in __nlmsg_parse()
751 * nlmsg_parse - parse attributes of a netlink message
771 * nlmsg_parse_deprecated - parse attributes of a netlink message
791 * nlmsg_parse_deprecated_strict - parse attributes of a netlink message
812 * nlmsg_find_attr - find a specific attribute in a netlink message
827 * nla_validate_deprecated - Validate a stream of attributes
834 * Validates all attributes in the specified attribute stream against the
850 * nla_validate - Validate a stream of attributes
857 * Validates all attributes in the specified attribute stream against the
872 * nlmsg_validate_deprecated - validate a netlink message including attributes
884 if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) in nlmsg_validate_deprecated()
885 return -EINVAL; in nlmsg_validate_deprecated()
895 * nlmsg_report - need to report back to application?
902 return nlh ? !!(nlh->nlmsg_flags & NLM_F_ECHO) : 0; in nlmsg_report()
906 * nlmsg_seq - return the seq number of netlink message
913 return nlh ? nlh->nlmsg_seq : 0; in nlmsg_seq()
917 * nlmsg_for_each_attr - iterate over a stream of attributes
928 * nlmsg_put - Add a new netlink message to an skb
949 * nlmsg_append - Add more data to a nlmsg in a skb
954 * with multiple fixed-format headers (which is rare).
963 if (NLMSG_ALIGN(size) - size) in nlmsg_append()
965 NLMSG_ALIGN(size) - size); in nlmsg_append()
970 * nlmsg_put_answer - Add a new callback based netlink message to an skb
985 return nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, in nlmsg_put_answer()
990 * nlmsg_new - Allocate a new netlink message
1003 * nlmsg_end - Finalize a netlink message
1008 * attributes. Only necessary if attributes have been added to
1013 nlh->nlmsg_len = skb_tail_pointer(skb) - (unsigned char *)nlh; in nlmsg_end()
1017 * nlmsg_get_pos - return current position in netlink message
1028 * nlmsg_trim - Trim message to a mark
1037 WARN_ON((unsigned char *) mark < skb->data); in nlmsg_trim()
1038 skb_trim(skb, (unsigned char *) mark - skb->data); in nlmsg_trim()
1043 * nlmsg_cancel - Cancel construction of a netlink message
1048 * attributes from the socket buffer again.
1056 * nlmsg_free - free a netlink message
1065 * nlmsg_multicast - multicast a netlink message
1087 * nlmsg_unicast - unicast a netlink message
1104 * nlmsg_for_each_msg - iterate over a stream of messages
1116 * nl_dump_check_consistent - check if sequence is consistent and advertise if not
1123 * The correct way to use it is to set cb->seq to the generation counter when
1134 if (cb->prev_seq && cb->seq != cb->prev_seq) in nl_dump_check_consistent()
1135 nlh->nlmsg_flags |= NLM_F_DUMP_INTR; in nl_dump_check_consistent()
1136 cb->prev_seq = cb->seq; in nl_dump_check_consistent()
1140 * Netlink Attributes
1144 * nla_attr_size - length of attribute not including padding
1153 * nla_total_size - total length of attribute including padding
1162 * nla_padlen - length of padding at the tail of attribute
1167 return nla_total_size(payload) - nla_attr_size(payload); in nla_padlen()
1171 * nla_type - attribute type
1176 return nla->nla_type & NLA_TYPE_MASK; in nla_type()
1180 * nla_data - head of payload
1189 * nla_len - length of payload
1194 return nla->nla_len - NLA_HDRLEN; in nla_len()
1198 * nla_ok - check if the netlink attribute fits into the remaining bytes
1205 nla->nla_len >= sizeof(*nla) && in nla_ok()
1206 nla->nla_len <= remaining; in nla_ok()
1210 * nla_next - next netlink attribute in attribute stream
1219 unsigned int totlen = NLA_ALIGN(nla->nla_len); in nla_next()
1221 *remaining -= totlen; in nla_next()
1226 * nla_find_nested - find attribute in a set of nested attributes
1227 * @nla: attribute containing the nested attributes
1239 * nla_parse_nested - parse nested attributes
1242 * @nla: attribute containing the nested attributes
1253 if (!(nla->nla_type & NLA_F_NESTED)) { in nla_parse_nested()
1255 return -EINVAL; in nla_parse_nested()
1263 * nla_parse_nested_deprecated - parse nested attributes
1266 * @nla: attribute containing the nested attributes
1282 * nla_put_u8 - Add a u8 netlink attribute to a socket buffer
1289 /* temporary variables to work around GCC PR81715 with asan-stack=1 */ in nla_put_u8()
1296 * nla_put_u16 - Add a u16 netlink attribute to a socket buffer
1309 * nla_put_be16 - Add a __be16 netlink attribute to a socket buffer
1322 * nla_put_net16 - Add 16-bit network byte order netlink attribute to a socket buffer
1335 * nla_put_le16 - Add a __le16 netlink attribute to a socket buffer
1348 * nla_put_u32 - Add a u32 netlink attribute to a socket buffer
1361 * nla_put_be32 - Add a __be32 netlink attribute to a socket buffer
1374 * nla_put_net32 - Add 32-bit network byte order netlink attribute to a socket buffer
1387 * nla_put_le32 - Add a __le32 netlink attribute to a socket buffer
1400 * nla_put_u64_64bit - Add a u64 netlink attribute to a skb and align it
1415 * nla_put_be64 - Add a __be64 netlink attribute to a socket buffer and align it
1430 * nla_put_net64 - Add 64-bit network byte order nlattr to a skb and align it
1446 * nla_put_le64 - Add a __le64 netlink attribute to a socket buffer and align it
1461 * nla_put_s8 - Add a s8 netlink attribute to a socket buffer
1474 * nla_put_s16 - Add a s16 netlink attribute to a socket buffer
1487 * nla_put_s32 - Add a s32 netlink attribute to a socket buffer
1500 * nla_put_s64 - Add a s64 netlink attribute to a socket buffer and align it
1515 * nla_put_string - Add a string netlink attribute to a socket buffer
1527 * nla_put_flag - Add a flag netlink attribute to a socket buffer
1537 * nla_put_msecs - Add a msecs netlink attribute to a skb and align it
1552 * nla_put_in_addr - Add an IPv4 address netlink attribute to a socket
1567 * nla_put_in6_addr - Add an IPv6 address netlink attribute to a socket
1580 * nla_put_bitfield32 - Add a bitfield32 netlink attribute to a socket buffer
1595 * nla_get_u32 - return payload of u32 attribute
1604 * nla_get_be32 - return payload of __be32 attribute
1613 * nla_get_le32 - return payload of __le32 attribute
1622 * nla_get_u16 - return payload of u16 attribute
1631 * nla_get_be16 - return payload of __be16 attribute
1640 * nla_get_le16 - return payload of __le16 attribute
1649 * nla_get_u8 - return payload of u8 attribute
1658 * nla_get_u64 - return payload of u64 attribute
1671 * nla_get_be64 - return payload of __be64 attribute
1684 * nla_get_le64 - return payload of __le64 attribute
1693 * nla_get_s32 - return payload of s32 attribute
1702 * nla_get_s16 - return payload of s16 attribute
1711 * nla_get_s8 - return payload of s8 attribute
1720 * nla_get_s64 - return payload of s64 attribute
1733 * nla_get_flag - return payload of flag attribute
1742 * nla_get_msecs - return payload of msecs attribute
1755 * nla_get_in_addr - return payload of IPv4 address attribute
1764 * nla_get_in6_addr - return payload of IPv6 address attribute
1776 * nla_get_bitfield32 - return payload of 32 bitfield attribute
1788 * nla_memdup - duplicate attribute memory (kmemdup)
1798 * nla_nest_start_noflag - Start a new level of nested attributes
1799 * @skb: socket buffer to add attributes to
1803 * marked their nest attributes with NLA_F_NESTED flag. New APIs should use
1820 * nla_nest_start - Start a new level of nested attributes, with NLA_F_NESTED
1821 * @skb: socket buffer to add attributes to
1835 * nla_nest_end - Finalize nesting of attributes
1836 * @skb: socket buffer the attributes are stored in
1840 * appeneded attributes.
1846 start->nla_len = skb_tail_pointer(skb) - (unsigned char *)start; in nla_nest_end()
1847 return skb->len; in nla_nest_end()
1851 * nla_nest_cancel - Cancel nesting of attributes
1855 * Removes the container attribute and including all nested
1856 * attributes. Returns -EMSGSIZE
1864 * __nla_validate_nested - Validate a stream of nested attributes
1871 * Validates all attributes in the nested attribute stream against the
1872 * specified policy. Attributes with a type exceeding maxtype will be
1905 * nla_need_padding_for_64bit - test 64-bit alignment of the next attribute
1909 * a 64-bit aligned area.
1915 * if the skb->data _is_ aligned. A NOP attribute, plus in nla_need_padding_for_64bit()
1917 * 8-byte aligned. in nla_need_padding_for_64bit()
1926 * nla_align_64bit - 64-bit align the nla_data() of next attribute
1931 * the next attribute we emit have a 64-bit aligned nla_data() area.
1941 return -EMSGSIZE; in nla_align_64bit()
1947 * nla_total_size_64bit - total length of attribute including padding
1960 * nla_for_each_attr - iterate over a stream of attributes
1972 * nla_for_each_nested - iterate over nested attributes
1974 * @nla: attribute containing the nested attributes
1981 * nla_is_last - Test if attribute is last in stream
1987 return nla->nla_len == rem; in nla_is_last()