8Xsphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget4/translations/zh_CN/userspace-api/netlink/c-code-genmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/zh_TW/userspace-api/netlink/c-code-genmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/it_IT/userspace-api/netlink/c-code-genmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/ja_JP/userspace-api/netlink/c-code-genmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/ko_KR/userspace-api/netlink/c-code-genmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/sp_SP/userspace-api/netlink/c-code-genmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h%SPDX-License-Identifier: BSD-3-Clauseh]h%SPDX-License-Identifier: BSD-3-Clause}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhN/var/lib/git/docbuild/linux/Documentation/userspace-api/netlink/c-code-gen.rsthKubhsection)}(hhh](htitle)}(hNetlink spec C code generationh]hNetlink spec C code generation}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hThis document describes how Netlink specifications are used to render C code (uAPI, policies etc.). It also defines the additional properties allowed in older families by the ``genetlink-c`` protocol level, to control the naming.h](hThis document describes how Netlink specifications are used to render C code (uAPI, policies etc.). It also defines the additional properties allowed in older families by the }(hhhhhNhNubhliteral)}(h``genetlink-c``h]h genetlink-c}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh' protocol level, to control the naming.}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hFor brevity this document refers to ``name`` properties of various objects by the object type. For example ``$attr`` is the value of ``name`` in an attribute, and ``$family`` is the name of the family (the global ``name`` property).h](h$For brevity this document refers to }(hhhhhNhNubh)}(h``name``h]hname}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh? properties of various objects by the object type. For example }(hhhhhNhNubh)}(h ``$attr``h]h$attr}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh is the value of }(hhhhhNhNubh)}(h``name``h]hname}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh in an attribute, and }(hhhhhNhNubh)}(h ``$family``h]h$family}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh' is the name of the family (the global }(hhhhhNhNubh)}(h``name``h]hname}(hj=hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh property).}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hThe upper case is used to denote literal values, e.g. ``$family-CMD`` means the concatenation of ``$family``, a dash character, and the literal ``CMD``.h](h6The upper case is used to denote literal values, e.g. }(hjUhhhNhNubh)}(h``$family-CMD``h]h $family-CMD}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjUubh means the concatenation of }(hjUhhhNhNubh)}(h ``$family``h]h$family}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhjUubh$, a dash character, and the literal }(hjUhhhNhNubh)}(h``CMD``h]hCMD}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjUubh.}(hjUhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hThe names of ``#defines`` and enum values are always converted to upper case, and with dashes (``-``) replaced by underscores (``_``).h](h The names of }(hjhhhNhNubh)}(h ``#defines``h]h#defines}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubhF and enum values are always converted to upper case, and with dashes (}(hjhhhNhNubh)}(h``-``h]h-}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh) replaced by underscores (}(hjhhhNhNubh)}(h``_``h]h_}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h\If the constructed name is a C keyword, an extra underscore is appended (``do`` -> ``do_``).h](hIIf the constructed name is a C keyword, an extra underscore is appended (}(hjhhhNhNubh)}(h``do``h]hdo}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh -> }(hjhhhNhNubh)}(h``do_``h]hdo_}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hGlobalsh]hGlobals}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(ho``c-family-name`` controls the name of the ``#define`` for the family name, default is ``$family-FAMILY-NAME``.h](h)}(h``c-family-name``h]h c-family-name}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj ubh controls the name of the }(hj hhhNhNubh)}(h ``#define``h]h#define}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj ubh! for the family name, default is }(hj hhhNhNubh)}(h``$family-FAMILY-NAME``h]h$family-FAMILY-NAME}(hjHhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj ubh.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h}``c-version-name`` controls the name of the ``#define`` for the version of the family, default is ``$family-FAMILY-VERSION``.h](h)}(h``c-version-name``h]hc-version-name}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj`ubh controls the name of the }(hj`hhhNhNubh)}(h ``#define``h]h#define}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj`ubh+ for the version of the family, default is }(hj`hhhNhNubh)}(h``$family-FAMILY-VERSION``h]h$family-FAMILY-VERSION}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj`ubh.}(hj`hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK!hjhhubh)}(hk``max-by-define`` selects if max values for enums are defined as a ``#define`` rather than inside the enum.h](h)}(h``max-by-define``h]h max-by-define}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh2 selects if max values for enums are defined as a }(hjhhhNhNubh)}(h ``#define``h]h#define}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh rather than inside the enum.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK$hjhhubeh}(h]globalsah ]h"]globalsah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h Definitionsh]h Definitions}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK(ubh)}(hhh](h)}(h Constantsh]h Constants}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK+ubh)}(hEvery constant is rendered as a ``#define``. The name of the constant is ``$family-$constant`` and the value is rendered as a string or integer according to its type in the spec.h](h Every constant is rendered as a }(hjhhhNhNubh)}(h ``#define``h]h#define}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh. The name of the constant is }(hjhhhNhNubh)}(h``$family-$constant``h]h$family-$constant}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubhT and the value is rendered as a string or integer according to its type in the spec.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK-hjhhubeh}(h] constantsah ]h"] constantsah$]h&]uh1hhjhhhhhK+ubh)}(hhh](h)}(hEnums and flagsh]hEnums and flags}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj2hhhhhK2ubh)}(hX Enums are named ``$family-$enum``. The full name can be set directly or suppressed by specifying the ``enum-name`` property. Default entry name is ``$family-$enum-$entry``. If ``name-prefix`` is specified it replaces the ``$family-$enum`` portion of the entry name.h](hEnums are named }(hjChhhNhNubh)}(h``$family-$enum``h]h $family-$enum}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjCubhD. The full name can be set directly or suppressed by specifying the }(hjChhhNhNubh)}(h ``enum-name``h]h enum-name}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjCubh! property. Default entry name is }(hjChhhNhNubh)}(h``$family-$enum-$entry``h]h$family-$enum-$entry}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhjCubh. If }(hjChhhNhNubh)}(h``name-prefix``h]h name-prefix}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjCubh is specified it replaces the }(hjChhhNhNubh)}(h``$family-$enum``h]h $family-$enum}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjCubh portion of the entry name.}(hjChhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK4hj2hhubh)}(hBoolean ``render-max`` controls creation of the max values (which are enabled by default for attribute enums). These max values are named ``__$pfx-MAX`` and ``$pfx-MAX``. The name of the first value can be overridden via ``enum-cnt-name`` property.h](hBoolean }(hjhhhNhNubh)}(h``render-max``h]h render-max}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubht controls creation of the max values (which are enabled by default for attribute enums). These max values are named }(hjhhhNhNubh)}(h``__$pfx-MAX``h]h __$pfx-MAX}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh and }(hjhhhNhNubh)}(h ``$pfx-MAX``h]h$pfx-MAX}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh4. The name of the first value can be overridden via }(hjhhhNhNubh)}(h``enum-cnt-name``h]h enum-cnt-name}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh property.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK:hj2hhubeh}(h]enums-and-flagsah ]h"]enums and flagsah$]h&]uh1hhjhhhhhK2ubeh}(h] definitionsah ]h"] definitionsah$]h&]uh1hhhhhhhhK(ubh)}(hhh](h)}(h Attributesh]h Attributes}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK@ubh)}(hFEach attribute set (excluding fractional sets) is rendered as an enum.h]hFEach attribute set (excluding fractional sets) is rendered as an enum.}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKBhjhhubh)}(hAttribute enums are traditionally unnamed in netlink headers. If naming is desired ``enum-name`` can be used to specify the name.h](hSAttribute enums are traditionally unnamed in netlink headers. If naming is desired }(hj0hhhNhNubh)}(h ``enum-name``h]h enum-name}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj0ubh! can be used to specify the name.}(hj0hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKDhjhhubh)}(hX The default attribute name prefix is ``$family-A`` if the name of the set is the same as the name of the family and ``$family-A-$set`` if the names differ. The prefix can be overridden by the ``name-prefix`` property of a set. The rest of the section will refer to the prefix as ``$pfx``.h](h%The default attribute name prefix is }(hjPhhhNhNubh)}(h ``$family-A``h]h $family-A}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjPubhB if the name of the set is the same as the name of the family and }(hjPhhhNhNubh)}(h``$family-A-$set``h]h$family-A-$set}(hjjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjPubh: if the names differ. The prefix can be overridden by the }(hjPhhhNhNubh)}(h``name-prefix``h]h name-prefix}(hj|hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjPubhH property of a set. The rest of the section will refer to the prefix as }(hjPhhhNhNubh)}(h``$pfx``h]h$pfx}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjPubh.}(hjPhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKGhjhhubh)}(h)Attributes are named ``$pfx-$attribute``.h](hAttributes are named }(hjhhhNhNubh)}(h``$pfx-$attribute``h]h$pfx-$attribute}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKLhjhhubh)}(hAttribute enums end with two special values ``__$pfx-MAX`` and ``$pfx-MAX`` which are used for sizing attribute tables. These two names can be specified directly with the ``attr-cnt-name`` and ``attr-max-name`` properties respectively.h](h,Attribute enums end with two special values }(hjhhhNhNubh)}(h``__$pfx-MAX``h]h __$pfx-MAX}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh and }(hjhhhNhNubh)}(h ``$pfx-MAX``h]h$pfx-MAX}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh` which are used for sizing attribute tables. These two names can be specified directly with the }(hjhhhNhNubh)}(h``attr-cnt-name``h]h attr-cnt-name}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh and }(hjhhhNhNubh)}(h``attr-max-name``h]h attr-max-name}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh properties respectively.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKNhjhhubh)}(hIf ``max-by-define`` is set to ``true`` at the global level ``attr-max-name`` will be specified as a ``#define`` rather than an enum value.h](hIf }(hjhhhNhNubh)}(h``max-by-define``h]h max-by-define}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh is set to }(hjhhhNhNubh)}(h``true``h]htrue}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh at the global level }(hjhhhNhNubh)}(h``attr-max-name``h]h attr-max-name}(hjHhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh will be specified as a }(hjhhhNhNubh)}(h ``#define``h]h#define}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh rather than an enum value.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKShjhhubeh}(h] attributesah ]h"] attributesah$]h&]uh1hhhhhhhhK@ubh)}(hhh](h)}(h Operationsh]h Operations}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjzhhhhhKWubh)}(hOperations are named ``$family-CMD-$operation``. If ``name-prefix`` is specified it replaces the ``$family-CMD`` portion of the name.h](hOperations are named }(hjhhhNhNubh)}(h``$family-CMD-$operation``h]h$family-CMD-$operation}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh. If }(hjhhhNhNubh)}(h``name-prefix``h]h name-prefix}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh is specified it replaces the }(hjhhhNhNubh)}(h``$family-CMD``h]h $family-CMD}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh portion of the name.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKYhjzhhubh)}(hSimilarly to attribute enums operation enums end with special count and max attributes. For operations those attributes can be renamed with ``cmd-cnt-name`` and ``cmd-max-name``. Max will be a define if ``max-by-define`` is ``true``.h](hSimilarly to attribute enums operation enums end with special count and max attributes. For operations those attributes can be renamed with }(hjhhhNhNubh)}(h``cmd-cnt-name``h]h cmd-cnt-name}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh and }(hjhhhNhNubh)}(h``cmd-max-name``h]h cmd-max-name}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh. Max will be a define if }(hjhhhNhNubh)}(h``max-by-define``h]h max-by-define}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh is }(hjhhhNhNubh)}(h``true``h]htrue}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK]hjzhhubeh}(h] operationsah ]h"] operationsah$]h&]uh1hhhhhhhhKWubh)}(hhh](h)}(hMulticast groupsh]hMulticast groups}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj-hhhhhKcubh)}(hEach multicast group gets a define rendered into the kernel uAPI header. The name of the define is ``$family-MCGRP-$group``, and can be overwritten with the ``c-define-name`` property.h](hcEach multicast group gets a define rendered into the kernel uAPI header. The name of the define is }(hj>hhhNhNubh)}(h``$family-MCGRP-$group``h]h$family-MCGRP-$group}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj>ubh", and can be overwritten with the }(hj>hhhNhNubh)}(h``c-define-name``h]h c-define-name}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj>ubh property.}(hj>hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKehj-hhubeh}(h]multicast-groupsah ]h"]multicast groupsah$]h&]uh1hhhhhhhhKcubh)}(hhh](h)}(hCode generationh]hCode generation}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjxhhhhhKjubh)}(huAPI header is assumed to come from ```` in the default header search path. It can be changed using the ``uapi-header`` global property.h](h$uAPI header is assumed to come from }(hjhhhNhNubh)}(h````h]h}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh@ in the default header search path. It can be changed using the }(hjhhhNhNubh)}(h``uapi-header``h]h uapi-header}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh global property.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKlhjxhhubeh}(h]code-generationah ]h"]code generationah$]h&]uh1hhhhhhhhKjubeh}(h]netlink-spec-c-code-generationah ]h"]netlink spec c code generationah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jjjjjj j/j,jjjwjtj*j'jujrjju nametypes}(jjjj/jjwj*jujuh}(jhjjj jj,jjj2jtjj'jzjrj-jjxu footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.