netlink-raw.yaml 18 KB

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