genetlink.yaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. # 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. len-or-limit:
  16. # literal int or limit based on fixed-width type e.g. u8-min, u16-max, etc.
  17. type: [ string, integer ]
  18. pattern: ^[su](8|16|32|64)-(min|max)$
  19. minimum: 0
  20. # Schema for specs
  21. title: Protocol
  22. description: Specification of a genetlink protocol
  23. type: object
  24. required: [ name, doc, attribute-sets, operations ]
  25. additionalProperties: False
  26. properties:
  27. name:
  28. description: Name of the genetlink family.
  29. type: string
  30. doc:
  31. type: string
  32. protocol:
  33. description: Schema compatibility level. Default is "genetlink".
  34. enum: [ genetlink ]
  35. uapi-header:
  36. description: Path to the uAPI header, default is linux/${family-name}.h
  37. type: string
  38. definitions:
  39. description: List of type and constant definitions (enums, flags, defines).
  40. type: array
  41. items:
  42. type: object
  43. required: [ type, name ]
  44. additionalProperties: False
  45. properties:
  46. name:
  47. type: string
  48. header:
  49. description: For C-compatible languages, header which already defines this value.
  50. type: string
  51. type:
  52. enum: [ const, enum, flags ]
  53. doc:
  54. type: string
  55. # For const
  56. value:
  57. description: For const - the value.
  58. type: [ string, integer ]
  59. # For enum and flags
  60. value-start:
  61. description: For enum or flags the literal initializer for the first value.
  62. type: [ string, integer ]
  63. entries:
  64. description: For enum or flags array of values.
  65. type: array
  66. items:
  67. oneOf:
  68. - type: string
  69. - type: object
  70. required: [ name ]
  71. additionalProperties: False
  72. properties:
  73. name:
  74. type: string
  75. value:
  76. type: integer
  77. doc:
  78. type: string
  79. render-max:
  80. description: Render the max members for this enum.
  81. type: boolean
  82. attribute-sets:
  83. description: Definition of attribute spaces for this family.
  84. type: array
  85. items:
  86. description: Definition of a single attribute space.
  87. type: object
  88. required: [ name, attributes ]
  89. additionalProperties: False
  90. properties:
  91. name:
  92. description: |
  93. Name used when referring to this space in other definitions, not used outside of the spec.
  94. type: string
  95. name-prefix:
  96. description: |
  97. Prefix for the C enum name of the attributes. Default family[name]-set[name]-a-
  98. type: string
  99. enum-name:
  100. description: Name for the enum type of the attribute.
  101. type: string
  102. doc:
  103. description: Documentation of the space.
  104. type: string
  105. subset-of:
  106. description: |
  107. Name of another space which this is a logical part of. Sub-spaces can be used to define
  108. a limited group of attributes which are used in a nest.
  109. type: string
  110. attributes:
  111. description: List of attributes in the space.
  112. type: array
  113. items:
  114. type: object
  115. required: [ name ]
  116. additionalProperties: False
  117. properties:
  118. name:
  119. type: string
  120. type: &attr-type
  121. enum: [ unused, pad, flag, binary,
  122. uint, sint, u8, u16, u32, u64, s32, s64,
  123. string, nest, indexed-array, nest-type-value ]
  124. doc:
  125. description: Documentation of the attribute.
  126. type: string
  127. value:
  128. description: Value for the enum item representing this attribute in the uAPI.
  129. $ref: '#/$defs/uint'
  130. type-value:
  131. description: Name of the value extracted from the type of a nest-type-value attribute.
  132. type: array
  133. items:
  134. type: string
  135. byte-order:
  136. enum: [ little-endian, big-endian ]
  137. multi-attr:
  138. type: boolean
  139. nested-attributes:
  140. description: Name of the space (sub-space) used inside the attribute.
  141. type: string
  142. enum:
  143. description: Name of the enum type used for the attribute.
  144. type: string
  145. enum-as-flags:
  146. description: |
  147. Treat the enum as flags. In most cases enum is either used as flags or as values.
  148. Sometimes, however, both forms are necessary, in which case header contains the enum
  149. form while specific attributes may request to convert the values into a bitfield.
  150. type: boolean
  151. checks:
  152. description: Kernel input validation.
  153. type: object
  154. additionalProperties: False
  155. properties:
  156. flags-mask:
  157. description: Name of the flags constant on which to base mask (unsigned scalar types only).
  158. type: string
  159. min:
  160. description: Min value for an integer attribute.
  161. $ref: '#/$defs/len-or-limit'
  162. max:
  163. description: Max value for an integer attribute.
  164. $ref: '#/$defs/len-or-limit'
  165. min-len:
  166. description: Min length for a binary attribute.
  167. $ref: '#/$defs/len-or-define'
  168. max-len:
  169. description: Max length for a string or a binary attribute.
  170. $ref: '#/$defs/len-or-define'
  171. exact-len:
  172. description: Exact length for a string or a binary attribute.
  173. $ref: '#/$defs/len-or-define'
  174. sub-type: *attr-type
  175. display-hint: &display-hint
  176. description: |
  177. Optional format indicator that is intended only for choosing
  178. the right formatting mechanism when displaying values of this
  179. type.
  180. enum: [ hex, mac, fddi, ipv4, ipv6, uuid ]
  181. # Make sure name-prefix does not appear in subsets (subsets inherit naming)
  182. dependencies:
  183. name-prefix:
  184. not:
  185. required: [ subset-of ]
  186. subset-of:
  187. not:
  188. required: [ name-prefix ]
  189. # type property is only required if not in subset definition
  190. if:
  191. properties:
  192. subset-of:
  193. not:
  194. type: string
  195. then:
  196. properties:
  197. attributes:
  198. items:
  199. required: [ type ]
  200. operations:
  201. description: Operations supported by the protocol.
  202. type: object
  203. required: [ list ]
  204. additionalProperties: False
  205. properties:
  206. enum-model:
  207. description: |
  208. The model of assigning values to the operations.
  209. "unified" is the recommended model where all message types belong
  210. to a single enum.
  211. "directional" has the messages sent to the kernel and from the kernel
  212. enumerated separately.
  213. enum: [ unified ]
  214. name-prefix:
  215. description: |
  216. Prefix for the C enum name of the command. The name is formed by concatenating
  217. the prefix with the upper case name of the command, with dashes replaced by underscores.
  218. type: string
  219. enum-name:
  220. description: Name for the enum type with commands.
  221. type: string
  222. async-prefix:
  223. description: Same as name-prefix but used to render notifications and events to separate enum.
  224. type: string
  225. async-enum:
  226. description: Name for the enum type with notifications/events.
  227. type: string
  228. list:
  229. description: List of commands
  230. type: array
  231. items:
  232. type: object
  233. additionalProperties: False
  234. required: [ name, doc ]
  235. properties:
  236. name:
  237. description: Name of the operation, also defining its C enum value in uAPI.
  238. type: string
  239. doc:
  240. description: Documentation for the command.
  241. type: string
  242. value:
  243. description: Value for the enum in the uAPI.
  244. $ref: '#/$defs/uint'
  245. attribute-set:
  246. description: |
  247. Attribute space from which attributes directly in the requests and replies
  248. to this command are defined.
  249. type: string
  250. flags: &cmd_flags
  251. description: Command flags.
  252. type: array
  253. items:
  254. enum: [ admin-perm ]
  255. dont-validate:
  256. description: Kernel attribute validation flags.
  257. type: array
  258. items:
  259. enum: [ strict, dump, dump-strict ]
  260. config-cond:
  261. description: |
  262. Name of the kernel config option gating the presence of
  263. the operation, without the 'CONFIG_' prefix.
  264. type: string
  265. do: &subop-type
  266. description: Main command handler.
  267. type: object
  268. additionalProperties: False
  269. properties:
  270. request: &subop-attr-list
  271. description: Definition of the request message for a given command.
  272. type: object
  273. additionalProperties: False
  274. properties:
  275. attributes:
  276. description: |
  277. Names of attributes from the attribute-set (not full attribute
  278. definitions, just names).
  279. type: array
  280. items:
  281. type: string
  282. reply: *subop-attr-list
  283. pre:
  284. description: Hook for a function to run before the main callback (pre_doit or start).
  285. type: string
  286. post:
  287. description: Hook for a function to run after the main callback (post_doit or done).
  288. type: string
  289. dump: *subop-type
  290. notify:
  291. description: Name of the command sharing the reply type with this notification.
  292. type: string
  293. event:
  294. type: object
  295. additionalProperties: False
  296. properties:
  297. attributes:
  298. description: Explicit list of the attributes for the notification.
  299. type: array
  300. items:
  301. type: string
  302. mcgrp:
  303. description: Name of the multicast group generating given notification.
  304. type: string
  305. mcast-groups:
  306. description: List of multicast groups.
  307. type: object
  308. required: [ list ]
  309. additionalProperties: False
  310. properties:
  311. list:
  312. description: List of groups.
  313. type: array
  314. items:
  315. type: object
  316. required: [ name ]
  317. additionalProperties: False
  318. properties:
  319. name:
  320. description: |
  321. The name for the group, used to form the define and the value of the define.
  322. type: string
  323. flags: *cmd_flags
  324. kernel-family:
  325. description: Additional global attributes used for kernel C code generation.
  326. type: object
  327. additionalProperties: False
  328. properties:
  329. headers:
  330. description: |
  331. List of extra headers which should be included in the source
  332. of the generated code.
  333. type: array
  334. items:
  335. type: string
  336. sock-priv:
  337. description: |
  338. Literal name of the type which is used within the kernel
  339. to store the socket state. The type / structure is internal
  340. to the kernel, and is not defined in the spec.
  341. type: string