1# SPDX-License-Identifier: GPL-2.0 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 # Start genetlink-c 37 uapi-header: 38 description: Path to the uAPI header, default is linux/${family-name}.h 39 type: string 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 # End genetlink-legacy 126 127 attribute-sets: 128 description: Definition of attribute spaces for this family. 129 type: array 130 items: 131 description: Definition of a single attribute space. 132 type: object 133 required: [ name, attributes ] 134 additionalProperties: False 135 properties: 136 name: 137 description: | 138 Name used when referring to this space in other definitions, not used outside of the spec. 139 type: string 140 name-prefix: 141 description: | 142 Prefix for the C enum name of the attributes. Default family[name]-set[name]-a- 143 type: string 144 enum-name: 145 description: Name for the enum type of the attribute. 146 type: string 147 doc: 148 description: Documentation of the space. 149 type: string 150 subset-of: 151 description: | 152 Name of another space which this is a logical part of. Sub-spaces can be used to define 153 a limited group of attributes which are used in a nest. 154 type: string 155 # Start genetlink-c 156 attr-cnt-name: 157 description: The explicit name for constant holding the count of attributes (last attr + 1). 158 type: string 159 attr-max-name: 160 description: The explicit name for last member of attribute enum. 161 type: string 162 # End genetlink-c 163 attributes: 164 description: List of attributes in the space. 165 type: array 166 items: 167 type: object 168 required: [ name, type ] 169 additionalProperties: False 170 properties: 171 name: 172 type: string 173 type: &attr-type 174 enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64, 175 string, nest, array-nest, nest-type-value ] 176 doc: 177 description: Documentation of the attribute. 178 type: string 179 value: 180 description: Value for the enum item representing this attribute in the uAPI. 181 $ref: '#/$defs/uint' 182 type-value: 183 description: Name of the value extracted from the type of a nest-type-value attribute. 184 type: array 185 items: 186 type: string 187 byte-order: 188 enum: [ little-endian, big-endian ] 189 multi-attr: 190 type: boolean 191 nested-attributes: 192 description: Name of the space (sub-space) used inside the attribute. 193 type: string 194 enum: 195 description: Name of the enum type used for the attribute. 196 type: string 197 enum-as-flags: 198 description: | 199 Treat the enum as flags. In most cases enum is either used as flags or as values. 200 Sometimes, however, both forms are necessary, in which case header contains the enum 201 form while specific attributes may request to convert the values into a bitfield. 202 type: boolean 203 checks: 204 description: Kernel input validation. 205 type: object 206 additionalProperties: False 207 properties: 208 flags-mask: 209 description: Name of the flags constant on which to base mask (unsigned scalar types only). 210 type: string 211 min: 212 description: Min value for an integer attribute. 213 type: integer 214 min-len: 215 description: Min length for a binary attribute. 216 $ref: '#/$defs/len-or-define' 217 max-len: 218 description: Max length for a string or a binary attribute. 219 $ref: '#/$defs/len-or-define' 220 sub-type: *attr-type 221 222 # Make sure name-prefix does not appear in subsets (subsets inherit naming) 223 dependencies: 224 name-prefix: 225 not: 226 required: [ subset-of ] 227 subset-of: 228 not: 229 required: [ name-prefix ] 230 231 operations: 232 description: Operations supported by the protocol. 233 type: object 234 required: [ list ] 235 additionalProperties: False 236 properties: 237 enum-model: 238 description: | 239 The model of assigning values to the operations. 240 "unified" is the recommended model where all message types belong 241 to a single enum. 242 "directional" has the messages sent to the kernel and from the kernel 243 enumerated separately. 244 enum: [ unified, directional ] # Trim 245 name-prefix: 246 description: | 247 Prefix for the C enum name of the command. The name is formed by concatenating 248 the prefix with the upper case name of the command, with dashes replaced by underscores. 249 type: string 250 enum-name: 251 description: Name for the enum type with commands. 252 type: string 253 async-prefix: 254 description: Same as name-prefix but used to render notifications and events to separate enum. 255 type: string 256 async-enum: 257 description: Name for the enum type with notifications/events. 258 type: string 259 list: 260 description: List of commands 261 type: array 262 items: 263 type: object 264 additionalProperties: False 265 required: [ name, doc ] 266 properties: 267 name: 268 description: Name of the operation, also defining its C enum value in uAPI. 269 type: string 270 doc: 271 description: Documentation for the command. 272 type: string 273 value: 274 description: Value for the enum in the uAPI. 275 $ref: '#/$defs/uint' 276 attribute-set: 277 description: | 278 Attribute space from which attributes directly in the requests and replies 279 to this command are defined. 280 type: string 281 flags: &cmd_flags 282 description: Command flags. 283 type: array 284 items: 285 enum: [ admin-perm ] 286 dont-validate: 287 description: Kernel attribute validation flags. 288 type: array 289 items: 290 enum: [ strict, dump ] 291 do: &subop-type 292 description: Main command handler. 293 type: object 294 additionalProperties: False 295 properties: 296 request: &subop-attr-list 297 description: Definition of the request message for a given command. 298 type: object 299 additionalProperties: False 300 properties: 301 attributes: 302 description: | 303 Names of attributes from the attribute-set (not full attribute 304 definitions, just names). 305 type: array 306 items: 307 type: string 308 # Start genetlink-legacy 309 value: 310 description: | 311 ID of this message if value for request and response differ, 312 i.e. requests and responses have different message enums. 313 $ref: '#/$defs/uint' 314 # End genetlink-legacy 315 reply: *subop-attr-list 316 pre: 317 description: Hook for a function to run before the main callback (pre_doit or start). 318 type: string 319 post: 320 description: Hook for a function to run after the main callback (post_doit or done). 321 type: string 322 dump: *subop-type 323 notify: 324 description: Name of the command sharing the reply type with this notification. 325 type: string 326 event: 327 type: object 328 additionalProperties: False 329 properties: 330 attributes: 331 description: Explicit list of the attributes for the notification. 332 type: array 333 items: 334 type: string 335 mcgrp: 336 description: Name of the multicast group generating given notification. 337 type: string 338 mcast-groups: 339 description: List of multicast groups. 340 type: object 341 required: [ list ] 342 additionalProperties: False 343 properties: 344 list: 345 description: List of groups. 346 type: array 347 items: 348 type: object 349 required: [ name ] 350 additionalProperties: False 351 properties: 352 name: 353 description: | 354 The name for the group, used to form the define and the value of the define. 355 type: string 356 # Start genetlink-c 357 c-define-name: 358 description: Override for the name of the define in C uAPI. 359 type: string 360 # End genetlink-c 361 flags: *cmd_flags 362