netlabel_mgmt.h 6.2 KB

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