netlabel_mgmt.h 6.5 KB

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