netlabel_mgmt.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * NetLabel Management Support
  4. *
  5. * This file defines the management functions for the NetLabel system. The
  6. * NetLabel system manages static and dynamic label mappings for network
  7. * protocols such as CIPSO and RIPSO.
  8. *
  9. * Author: Paul Moore <paul@paul-moore.com>
  10. */
  11. /*
  12. * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
  13. */
  14. #ifndef _NETLABEL_MGMT_H
  15. #define _NETLABEL_MGMT_H
  16. #include <net/netlabel.h>
  17. #include <linux/atomic.h>
  18. /*
  19. * The following NetLabel payloads are supported by the management interface.
  20. *
  21. * o ADD:
  22. * Sent by an application to add a domain mapping to the NetLabel system.
  23. *
  24. * Required attributes:
  25. *
  26. * NLBL_MGMT_A_DOMAIN
  27. * NLBL_MGMT_A_PROTOCOL
  28. *
  29. * If IPv4 is specified the following attributes are required:
  30. *
  31. * NLBL_MGMT_A_IPV4ADDR
  32. * NLBL_MGMT_A_IPV4MASK
  33. *
  34. * If IPv6 is specified the following attributes are required:
  35. *
  36. * NLBL_MGMT_A_IPV6ADDR
  37. * NLBL_MGMT_A_IPV6MASK
  38. *
  39. * If using NETLBL_NLTYPE_CIPSOV4 the following attributes are required:
  40. *
  41. * NLBL_MGMT_A_CV4DOI
  42. *
  43. * If using NETLBL_NLTYPE_UNLABELED no other attributes are required,
  44. * however the following attribute may optionally be sent:
  45. *
  46. * NLBL_MGMT_A_FAMILY
  47. *
  48. * o REMOVE:
  49. * Sent by an application to remove a domain mapping from the NetLabel
  50. * system.
  51. *
  52. * Required attributes:
  53. *
  54. * NLBL_MGMT_A_DOMAIN
  55. *
  56. * o LISTALL:
  57. * This message can be sent either from an application or by the kernel in
  58. * response to an application generated LISTALL message. When sent by an
  59. * application there is no payload and the NLM_F_DUMP flag should be set.
  60. * The kernel should respond with a series of the following messages.
  61. *
  62. * Required attributes:
  63. *
  64. * NLBL_MGMT_A_DOMAIN
  65. * NLBL_MGMT_A_FAMILY
  66. *
  67. * If the IP address selectors are not used the following attribute is
  68. * required:
  69. *
  70. * NLBL_MGMT_A_PROTOCOL
  71. *
  72. * If the IP address selectors are used then the following attritbute is
  73. * required:
  74. *
  75. * NLBL_MGMT_A_SELECTORLIST
  76. *
  77. * If the mapping is using the NETLBL_NLTYPE_CIPSOV4 type then the following
  78. * attributes are required:
  79. *
  80. * NLBL_MGMT_A_CV4DOI
  81. *
  82. * If the mapping is using the NETLBL_NLTYPE_UNLABELED type no other
  83. * attributes are required.
  84. *
  85. * o ADDDEF:
  86. * Sent by an application to set the default domain mapping for the NetLabel
  87. * system.
  88. *
  89. * Required attributes:
  90. *
  91. * NLBL_MGMT_A_PROTOCOL
  92. *
  93. * If using NETLBL_NLTYPE_CIPSOV4 the following attributes are required:
  94. *
  95. * NLBL_MGMT_A_CV4DOI
  96. *
  97. * If using NETLBL_NLTYPE_UNLABELED no other attributes are required,
  98. * however the following attribute may optionally be sent:
  99. *
  100. * NLBL_MGMT_A_FAMILY
  101. *
  102. * o REMOVEDEF:
  103. * Sent by an application to remove the default domain mapping from the
  104. * NetLabel system, there is no payload.
  105. *
  106. * o LISTDEF:
  107. * This message can be sent either from an application or by the kernel in
  108. * response to an application generated LISTDEF message. When sent by an
  109. * application there may be an optional payload.
  110. *
  111. * NLBL_MGMT_A_FAMILY
  112. *
  113. * On success the kernel should send a response using the following format:
  114. *
  115. * If the IP address selectors are not used the following attributes are
  116. * required:
  117. *
  118. * NLBL_MGMT_A_PROTOCOL
  119. * NLBL_MGMT_A_FAMILY
  120. *
  121. * If the IP address selectors are used then the following attritbute is
  122. * required:
  123. *
  124. * NLBL_MGMT_A_SELECTORLIST
  125. *
  126. * If the mapping is using the NETLBL_NLTYPE_CIPSOV4 type then the following
  127. * attributes are required:
  128. *
  129. * NLBL_MGMT_A_CV4DOI
  130. *
  131. * If the mapping is using the NETLBL_NLTYPE_UNLABELED type no other
  132. * attributes are required.
  133. *
  134. * o PROTOCOLS:
  135. * Sent by an application to request a list of configured NetLabel protocols
  136. * in the kernel. When sent by an application there is no payload and the
  137. * NLM_F_DUMP flag should be set. The kernel should respond with a series of
  138. * the following messages.
  139. *
  140. * Required attributes:
  141. *
  142. * NLBL_MGMT_A_PROTOCOL
  143. *
  144. * o VERSION:
  145. * Sent by an application to request the NetLabel version. When sent by an
  146. * application there is no payload. This message type is also used by the
  147. * kernel to respond to an VERSION request.
  148. *
  149. * Required attributes:
  150. *
  151. * NLBL_MGMT_A_VERSION
  152. *
  153. */
  154. /* NetLabel Management commands */
  155. enum {
  156. NLBL_MGMT_C_UNSPEC,
  157. NLBL_MGMT_C_ADD,
  158. NLBL_MGMT_C_REMOVE,
  159. NLBL_MGMT_C_LISTALL,
  160. NLBL_MGMT_C_ADDDEF,
  161. NLBL_MGMT_C_REMOVEDEF,
  162. NLBL_MGMT_C_LISTDEF,
  163. NLBL_MGMT_C_PROTOCOLS,
  164. NLBL_MGMT_C_VERSION,
  165. __NLBL_MGMT_C_MAX,
  166. };
  167. /* NetLabel Management attributes */
  168. enum {
  169. NLBL_MGMT_A_UNSPEC,
  170. NLBL_MGMT_A_DOMAIN,
  171. /* (NLA_NUL_STRING)
  172. * the NULL terminated LSM domain string */
  173. NLBL_MGMT_A_PROTOCOL,
  174. /* (NLA_U32)
  175. * the NetLabel protocol type (defined by NETLBL_NLTYPE_*) */
  176. NLBL_MGMT_A_VERSION,
  177. /* (NLA_U32)
  178. * the NetLabel protocol version number (defined by
  179. * NETLBL_PROTO_VERSION) */
  180. NLBL_MGMT_A_CV4DOI,
  181. /* (NLA_U32)
  182. * the CIPSOv4 DOI value */
  183. NLBL_MGMT_A_IPV6ADDR,
  184. /* (NLA_BINARY, struct in6_addr)
  185. * an IPv6 address */
  186. NLBL_MGMT_A_IPV6MASK,
  187. /* (NLA_BINARY, struct in6_addr)
  188. * an IPv6 address mask */
  189. NLBL_MGMT_A_IPV4ADDR,
  190. /* (NLA_BINARY, struct in_addr)
  191. * an IPv4 address */
  192. NLBL_MGMT_A_IPV4MASK,
  193. /* (NLA_BINARY, struct in_addr)
  194. * and IPv4 address mask */
  195. NLBL_MGMT_A_ADDRSELECTOR,
  196. /* (NLA_NESTED)
  197. * an IP address selector, must contain an address, mask, and protocol
  198. * attribute plus any protocol specific attributes */
  199. NLBL_MGMT_A_SELECTORLIST,
  200. /* (NLA_NESTED)
  201. * the selector list, there must be at least one
  202. * NLBL_MGMT_A_ADDRSELECTOR attribute */
  203. NLBL_MGMT_A_FAMILY,
  204. /* (NLA_U16)
  205. * The address family */
  206. NLBL_MGMT_A_CLPDOI,
  207. /* (NLA_U32)
  208. * the CALIPSO DOI value */
  209. __NLBL_MGMT_A_MAX,
  210. };
  211. #define NLBL_MGMT_A_MAX (__NLBL_MGMT_A_MAX - 1)
  212. /* NetLabel protocol functions */
  213. int netlbl_mgmt_genl_init(void);
  214. /* NetLabel configured protocol reference counter */
  215. extern atomic_t netlabel_mgmt_protocount;
  216. #endif