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