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 version: 30 description: Generic Netlink family version. Default is 1. 31 type: integer 32 minimum: 1 33 protocol: 34 description: Schema compatibility level. Default is "genetlink". 35 enum: [ genetlink, genetlink-c, genetlink-legacy ] # Trim 36 uapi-header: 37 description: Path to the uAPI header, default is linux/${family-name}.h 38 type: string 39 # Start genetlink-c 40 c-family-name: 41 description: Name of the define for the family name. 42 type: string 43 c-version-name: 44 description: Name of the define for the verion of the family. 45 type: string 46 max-by-define: 47 description: Makes the number of attributes and commands be specified by a define, not an enum value. 48 type: boolean 49 # End genetlink-c 50 # Start genetlink-legacy 51 kernel-policy: 52 description: | 53 Defines if the input policy in the kernel is global, per-operation, or split per operation type. 54 Default is split. 55 enum: [ split, per-op, global ] 56 # End genetlink-legacy 57 58 definitions: 59 description: List of type and constant definitions (enums, flags, defines). 60 type: array 61 items: 62 type: object 63 required: [ type, name ] 64 additionalProperties: False 65 properties: 66 name: 67 type: string 68 header: 69 description: For C-compatible languages, header which already defines this value. 70 type: string 71 type: 72 enum: [ const, enum, flags, struct ] # Trim 73 doc: 74 type: string 75 # For const 76 value: 77 description: For const - the value. 78 type: [ string, integer ] 79 # For enum and flags 80 value-start: 81 description: For enum or flags the literal initializer for the first value. 82 type: [ string, integer ] 83 entries: 84 description: For enum or flags array of values. 85 type: array 86 items: 87 oneOf: 88 - type: string 89 - type: object 90 required: [ name ] 91 additionalProperties: False 92 properties: 93 name: 94 type: string 95 value: 96 type: integer 97 doc: 98 type: string 99 render-max: 100 description: Render the max members for this enum. 101 type: boolean 102 # Start genetlink-c 103 enum-name: 104 description: Name for enum, if empty no name will be used. 105 type: [ string, "null" ] 106 name-prefix: 107 description: For enum the prefix of the values, optional. 108 type: string 109 # End genetlink-c 110 # Start genetlink-legacy 111 members: 112 description: List of struct members. Only scalars and strings members allowed. 113 type: array 114 items: 115 type: object 116 required: [ name, type ] 117 additionalProperties: False 118 properties: 119 name: 120 type: string 121 type: 122 enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string ] 123 len: 124 $ref: '#/$defs/len-or-define' 125 byte-order: 126 enum: [ little-endian, big-endian ] 127 doc: 128 description: Documentation for the struct member attribute. 129 type: string 130 enum: 131 description: Name of the enum type used for the attribute. 132 type: string 133 # End genetlink-legacy 134 135 attribute-sets: 136 description: Definition of attribute spaces for this family. 137 type: array 138 items: 139 description: Definition of a single attribute space. 140 type: object 141 required: [ name, attributes ] 142 additionalProperties: False 143 properties: 144 name: 145 description: | 146 Name used when referring to this space in other definitions, not used outside of the spec. 147 type: string 148 name-prefix: 149 description: | 150 Prefix for the C enum name of the attributes. Default family[name]-set[name]-a- 151 type: string 152 enum-name: 153 description: Name for the enum type of the attribute. 154 type: string 155 doc: 156 description: Documentation of the space. 157 type: string 158 subset-of: 159 description: | 160 Name of another space which this is a logical part of. Sub-spaces can be used to define 161 a limited group of attributes which are used in a nest. 162 type: string 163 # Start genetlink-c 164 attr-cnt-name: 165 description: The explicit name for constant holding the count of attributes (last attr + 1). 166 type: string 167 attr-max-name: 168 description: The explicit name for last member of attribute enum. 169 type: string 170 # End genetlink-c 171 attributes: 172 description: List of attributes in the space. 173 type: array 174 items: 175 type: object 176 required: [ name, type ] 177 additionalProperties: False 178 properties: 179 name: 180 type: string 181 type: &attr-type 182 enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64, 183 string, nest, array-nest, nest-type-value ] 184 doc: 185 description: Documentation of the attribute. 186 type: string 187 value: 188 description: Value for the enum item representing this attribute in the uAPI. 189 $ref: '#/$defs/uint' 190 type-value: 191 description: Name of the value extracted from the type of a nest-type-value attribute. 192 type: array 193 items: 194 type: string 195 byte-order: 196 enum: [ little-endian, big-endian ] 197 multi-attr: 198 type: boolean 199 nested-attributes: 200 description: Name of the space (sub-space) used inside the attribute. 201 type: string 202 enum: 203 description: Name of the enum type used for the attribute. 204 type: string 205 enum-as-flags: 206 description: | 207 Treat the enum as flags. In most cases enum is either used as flags or as values. 208 Sometimes, however, both forms are necessary, in which case header contains the enum 209 form while specific attributes may request to convert the values into a bitfield. 210 type: boolean 211 checks: 212 description: Kernel input validation. 213 type: object 214 additionalProperties: False 215 properties: 216 flags-mask: 217 description: Name of the flags constant on which to base mask (unsigned scalar types only). 218 type: string 219 min: 220 description: Min value for an integer attribute. 221 type: integer 222 min-len: 223 description: Min length for a binary attribute. 224 $ref: '#/$defs/len-or-define' 225 max-len: 226 description: Max length for a string or a binary attribute. 227 $ref: '#/$defs/len-or-define' 228 sub-type: *attr-type 229 # Start genetlink-legacy 230 struct: 231 description: Name of the struct type used for the attribute. 232 type: string 233 # End genetlink-legacy 234 235 # Make sure name-prefix does not appear in subsets (subsets inherit naming) 236 dependencies: 237 name-prefix: 238 not: 239 required: [ subset-of ] 240 subset-of: 241 not: 242 required: [ name-prefix ] 243 244 operations: 245 description: Operations supported by the protocol. 246 type: object 247 required: [ list ] 248 additionalProperties: False 249 properties: 250 enum-model: 251 description: | 252 The model of assigning values to the operations. 253 "unified" is the recommended model where all message types belong 254 to a single enum. 255 "directional" has the messages sent to the kernel and from the kernel 256 enumerated separately. 257 enum: [ unified, directional ] # Trim 258 name-prefix: 259 description: | 260 Prefix for the C enum name of the command. The name is formed by concatenating 261 the prefix with the upper case name of the command, with dashes replaced by underscores. 262 type: string 263 enum-name: 264 description: Name for the enum type with commands. 265 type: string 266 async-prefix: 267 description: Same as name-prefix but used to render notifications and events to separate enum. 268 type: string 269 async-enum: 270 description: Name for the enum type with notifications/events. 271 type: string 272 # Start genetlink-legacy 273 fixed-header: &fixed-header 274 description: | 275 Name of the structure defining the optional fixed-length protocol 276 header. This header is placed in a message after the netlink and 277 genetlink headers and before any attributes. 278 type: string 279 # End genetlink-legacy 280 list: 281 description: List of commands 282 type: array 283 items: 284 type: object 285 additionalProperties: False 286 required: [ name, doc ] 287 properties: 288 name: 289 description: Name of the operation, also defining its C enum value in uAPI. 290 type: string 291 doc: 292 description: Documentation for the command. 293 type: string 294 value: 295 description: Value for the enum in the uAPI. 296 $ref: '#/$defs/uint' 297 attribute-set: 298 description: | 299 Attribute space from which attributes directly in the requests and replies 300 to this command are defined. 301 type: string 302 flags: &cmd_flags 303 description: Command flags. 304 type: array 305 items: 306 enum: [ admin-perm ] 307 dont-validate: 308 description: Kernel attribute validation flags. 309 type: array 310 items: 311 enum: [ strict, dump ] 312 # Start genetlink-legacy 313 fixed-header: *fixed-header 314 # End genetlink-legacy 315 do: &subop-type 316 description: Main command handler. 317 type: object 318 additionalProperties: False 319 properties: 320 request: &subop-attr-list 321 description: Definition of the request message for a given command. 322 type: object 323 additionalProperties: False 324 properties: 325 attributes: 326 description: | 327 Names of attributes from the attribute-set (not full attribute 328 definitions, just names). 329 type: array 330 items: 331 type: string 332 # Start genetlink-legacy 333 value: 334 description: | 335 ID of this message if value for request and response differ, 336 i.e. requests and responses have different message enums. 337 $ref: '#/$defs/uint' 338 # End genetlink-legacy 339 reply: *subop-attr-list 340 pre: 341 description: Hook for a function to run before the main callback (pre_doit or start). 342 type: string 343 post: 344 description: Hook for a function to run after the main callback (post_doit or done). 345 type: string 346 dump: *subop-type 347 notify: 348 description: Name of the command sharing the reply type with this notification. 349 type: string 350 event: 351 type: object 352 additionalProperties: False 353 properties: 354 attributes: 355 description: Explicit list of the attributes for the notification. 356 type: array 357 items: 358 type: string 359 mcgrp: 360 description: Name of the multicast group generating given notification. 361 type: string 362 mcast-groups: 363 description: List of multicast groups. 364 type: object 365 required: [ list ] 366 additionalProperties: False 367 properties: 368 list: 369 description: List of groups. 370 type: array 371 items: 372 type: object 373 required: [ name ] 374 additionalProperties: False 375 properties: 376 name: 377 description: | 378 The name for the group, used to form the define and the value of the define. 379 type: string 380 # Start genetlink-c 381 c-define-name: 382 description: Override for the name of the define in C uAPI. 383 type: string 384 # End genetlink-c 385 flags: *cmd_flags 386