netlink-raw.yaml 18 KB

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