netlabel_mgmt.h 6.2 KB

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