xref: /linux/Documentation/netlink/genetlink.yaml (revision 04317b129e4eb5c6f4a58bb899b2019c1545320b)
1# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2%YAML 1.2
3---
4$id: http://kernel.org/schemas/netlink/genetlink-legacy.yaml#
5$schema: https://json-schema.org/draft-07/schema
6
7# Common defines
8$defs:
9  uint:
10    type: integer
11    minimum: 0
12  len-or-define:
13    type: [ string, integer ]
14    pattern: ^[0-9A-Za-z_]+( - 1)?$
15    minimum: 0
16
17# Schema for specs
18title: Protocol
19description: Specification of a genetlink protocol
20type: object
21required: [ name, doc, attribute-sets, operations ]
22additionalProperties: False
23properties:
24  name:
25    description: Name of the genetlink family.
26    type: string
27  doc:
28    type: string
29  protocol:
30    description: Schema compatibility level. Default is "genetlink".
31    enum: [ genetlink ]
32  uapi-header:
33    description: Path to the uAPI header, default is linux/${family-name}.h
34    type: string
35
36  definitions:
37    description: List of type and constant definitions (enums, flags, defines).
38    type: array
39    items:
40      type: object
41      required: [ type, name ]
42      additionalProperties: False
43      properties:
44        name:
45          type: string
46        header:
47          description: For C-compatible languages, header which already defines this value.
48          type: string
49        type:
50          enum: [ const, enum, flags ]
51        doc:
52          type: string
53        # For const
54        value:
55          description: For const - the value.
56          type: [ string, integer ]
57        # For enum and flags
58        value-start:
59          description: For enum or flags the literal initializer for the first value.
60          type: [ string, integer ]
61        entries:
62          description: For enum or flags array of values.
63          type: array
64          items:
65            oneOf:
66              - type: string
67              - type: object
68                required: [ name ]
69                additionalProperties: False
70                properties:
71                  name:
72                    type: string
73                  value:
74                    type: integer
75                  doc:
76                    type: string
77        render-max:
78          description: Render the max members for this enum.
79          type: boolean
80
81  attribute-sets:
82    description: Definition of attribute spaces for this family.
83    type: array
84    items:
85      description: Definition of a single attribute space.
86      type: object
87      required: [ name, attributes ]
88      additionalProperties: False
89      properties:
90        name:
91          description: |
92            Name used when referring to this space in other definitions, not used outside of the spec.
93          type: string
94        name-prefix:
95          description: |
96            Prefix for the C enum name of the attributes. Default family[name]-set[name]-a-
97          type: string
98        enum-name:
99          description: Name for the enum type of the attribute.
100          type: string
101        doc:
102          description: Documentation of the space.
103          type: string
104        subset-of:
105          description: |
106            Name of another space which this is a logical part of. Sub-spaces can be used to define
107            a limited group of attributes which are used in a nest.
108          type: string
109        attributes:
110          description: List of attributes in the space.
111          type: array
112          items:
113            type: object
114            required: [ name ]
115            additionalProperties: False
116            properties:
117              name:
118                type: string
119              type: &attr-type
120                enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
121                        string, nest, array-nest, nest-type-value ]
122              doc:
123                description: Documentation of the attribute.
124                type: string
125              value:
126                description: Value for the enum item representing this attribute in the uAPI.
127                $ref: '#/$defs/uint'
128              type-value:
129                description: Name of the value extracted from the type of a nest-type-value attribute.
130                type: array
131                items:
132                  type: string
133              byte-order:
134                enum: [ little-endian, big-endian ]
135              multi-attr:
136                type: boolean
137              nested-attributes:
138                description: Name of the space (sub-space) used inside the attribute.
139                type: string
140              enum:
141                description: Name of the enum type used for the attribute.
142                type: string
143              enum-as-flags:
144                description: |
145                  Treat the enum as flags. In most cases enum is either used as flags or as values.
146                  Sometimes, however, both forms are necessary, in which case header contains the enum
147                  form while specific attributes may request to convert the values into a bitfield.
148                type: boolean
149              checks:
150                description: Kernel input validation.
151                type: object
152                additionalProperties: False
153                properties:
154                  flags-mask:
155                    description: Name of the flags constant on which to base mask (unsigned scalar types only).
156                    type: string
157                  min:
158                    description: Min value for an integer attribute.
159                    type: integer
160                  min-len:
161                    description: Min length for a binary attribute.
162                    $ref: '#/$defs/len-or-define'
163                  max-len:
164                    description: Max length for a string or a binary attribute.
165                    $ref: '#/$defs/len-or-define'
166              sub-type: *attr-type
167              display-hint: &display-hint
168                description: |
169                  Optional format indicator that is intended only for choosing
170                  the right formatting mechanism when displaying values of this
171                  type.
172                enum: [ hex, mac, fddi, ipv4, ipv6, uuid ]
173
174      # Make sure name-prefix does not appear in subsets (subsets inherit naming)
175      dependencies:
176        name-prefix:
177          not:
178            required: [ subset-of ]
179        subset-of:
180          not:
181            required: [ name-prefix ]
182
183      # type property is only required if not in subset definition
184      if:
185        properties:
186          subset-of:
187            not:
188              type: string
189      then:
190        properties:
191          attributes:
192            items:
193              required: [ type ]
194
195  operations:
196    description: Operations supported by the protocol.
197    type: object
198    required: [ list ]
199    additionalProperties: False
200    properties:
201      enum-model:
202        description: |
203          The model of assigning values to the operations.
204          "unified" is the recommended model where all message types belong
205          to a single enum.
206          "directional" has the messages sent to the kernel and from the kernel
207          enumerated separately.
208        enum: [ unified ]
209      name-prefix:
210        description: |
211          Prefix for the C enum name of the command. The name is formed by concatenating
212          the prefix with the upper case name of the command, with dashes replaced by underscores.
213        type: string
214      enum-name:
215        description: Name for the enum type with commands.
216        type: string
217      async-prefix:
218        description: Same as name-prefix but used to render notifications and events to separate enum.
219        type: string
220      async-enum:
221        description: Name for the enum type with notifications/events.
222        type: string
223      list:
224        description: List of commands
225        type: array
226        items:
227          type: object
228          additionalProperties: False
229          required: [ name, doc ]
230          properties:
231            name:
232              description: Name of the operation, also defining its C enum value in uAPI.
233              type: string
234            doc:
235              description: Documentation for the command.
236              type: string
237            value:
238              description: Value for the enum in the uAPI.
239              $ref: '#/$defs/uint'
240            attribute-set:
241              description: |
242                Attribute space from which attributes directly in the requests and replies
243                to this command are defined.
244              type: string
245            flags: &cmd_flags
246              description: Command flags.
247              type: array
248              items:
249                enum: [ admin-perm ]
250            dont-validate:
251              description: Kernel attribute validation flags.
252              type: array
253              items:
254                enum: [ strict, dump, dump-strict ]
255            do: &subop-type
256              description: Main command handler.
257              type: object
258              additionalProperties: False
259              properties:
260                request: &subop-attr-list
261                  description: Definition of the request message for a given command.
262                  type: object
263                  additionalProperties: False
264                  properties:
265                    attributes:
266                      description: |
267                        Names of attributes from the attribute-set (not full attribute
268                        definitions, just names).
269                      type: array
270                      items:
271                        type: string
272                reply: *subop-attr-list
273                pre:
274                  description: Hook for a function to run before the main callback (pre_doit or start).
275                  type: string
276                post:
277                  description: Hook for a function to run after the main callback (post_doit or done).
278                  type: string
279            dump: *subop-type
280            notify:
281              description: Name of the command sharing the reply type with this notification.
282              type: string
283            event:
284              type: object
285              additionalProperties: False
286              properties:
287                attributes:
288                  description: Explicit list of the attributes for the notification.
289                  type: array
290                  items:
291                    type: string
292            mcgrp:
293              description: Name of the multicast group generating given notification.
294              type: string
295  mcast-groups:
296    description: List of multicast groups.
297    type: object
298    required: [ list ]
299    additionalProperties: False
300    properties:
301      list:
302        description: List of groups.
303        type: array
304        items:
305          type: object
306          required: [ name ]
307          additionalProperties: False
308          properties:
309            name:
310              description: |
311                The name for the group, used to form the define and the value of the define.
312              type: string
313            flags: *cmd_flags
314