netlabel_cipso_v4.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. * NetLabel CIPSO/IPv4 Support
  3. *
  4. * This file defines the CIPSO/IPv4 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_CIPSO_V4
  30. #define _NETLABEL_CIPSO_V4
  31. #include <net/netlabel.h>
  32. /*
  33. * The following NetLabel payloads are supported by the CIPSO subsystem, all
  34. * of which are preceeded by the nlmsghdr struct.
  35. *
  36. * o ACK:
  37. * Sent by the kernel in response to an applications message, applications
  38. * should never send this message.
  39. *
  40. * +----------------------+-----------------------+
  41. * | seq number (32 bits) | return code (32 bits) |
  42. * +----------------------+-----------------------+
  43. *
  44. * seq number: the sequence number of the original message, taken from the
  45. * nlmsghdr structure
  46. * return code: return value, based on errno values
  47. *
  48. * o ADD:
  49. * Sent by an application to add a new DOI mapping table, after completion
  50. * of the task the kernel should ACK this message.
  51. *
  52. * +---------------+--------------------+---------------------+
  53. * | DOI (32 bits) | map type (32 bits) | tag count (32 bits) | ...
  54. * +---------------+--------------------+---------------------+
  55. *
  56. * +-----------------+
  57. * | tag #X (8 bits) | ... repeated
  58. * +-----------------+
  59. *
  60. * +-------------- ---- --- -- -
  61. * | mapping data
  62. * +-------------- ---- --- -- -
  63. *
  64. * DOI: the DOI value
  65. * map type: the mapping table type (defined in the cipso_ipv4.h header
  66. * as CIPSO_V4_MAP_*)
  67. * tag count: the number of tags, must be greater than zero
  68. * tag: the CIPSO tag for the DOI, tags listed first are given
  69. * higher priorirty when sending packets
  70. * mapping data: specific to the map type (see below)
  71. *
  72. * CIPSO_V4_MAP_STD
  73. *
  74. * +------------------+-----------------------+----------------------+
  75. * | levels (32 bits) | max l level (32 bits) | max r level (8 bits) | ...
  76. * +------------------+-----------------------+----------------------+
  77. *
  78. * +----------------------+---------------------+---------------------+
  79. * | categories (32 bits) | max l cat (32 bits) | max r cat (16 bits) | ...
  80. * +----------------------+---------------------+---------------------+
  81. *
  82. * +--------------------------+-------------------------+
  83. * | local level #X (32 bits) | CIPSO level #X (8 bits) | ... repeated
  84. * +--------------------------+-------------------------+
  85. *
  86. * +-----------------------------+-----------------------------+
  87. * | local category #X (32 bits) | CIPSO category #X (16 bits) | ... repeated
  88. * +-----------------------------+-----------------------------+
  89. *
  90. * levels: the number of level mappings
  91. * max l level: the highest local level
  92. * max r level: the highest remote/CIPSO level
  93. * categories: the number of category mappings
  94. * max l cat: the highest local category
  95. * max r cat: the highest remote/CIPSO category
  96. * local level: the local part of a level mapping
  97. * CIPSO level: the remote/CIPSO part of a level mapping
  98. * local category: the local part of a category mapping
  99. * CIPSO category: the remote/CIPSO part of a category mapping
  100. *
  101. * CIPSO_V4_MAP_PASS
  102. *
  103. * No mapping data is needed for this map type.
  104. *
  105. * o REMOVE:
  106. * Sent by an application to remove a specific DOI mapping table from the
  107. * CIPSO V4 system. The kernel should ACK this message.
  108. *
  109. * +---------------+
  110. * | DOI (32 bits) |
  111. * +---------------+
  112. *
  113. * DOI: the DOI value
  114. *
  115. * o LIST:
  116. * Sent by an application to list the details of a DOI definition. The
  117. * kernel should send an ACK on error or a response as indicated below. The
  118. * application generated message format is shown below.
  119. *
  120. * +---------------+
  121. * | DOI (32 bits) |
  122. * +---------------+
  123. *
  124. * DOI: the DOI value
  125. *
  126. * The valid response message format depends on the type of the DOI mapping,
  127. * the known formats are shown below.
  128. *
  129. * +--------------------+
  130. * | map type (32 bits) | ...
  131. * +--------------------+
  132. *
  133. * map type: the DOI mapping table type (defined in the cipso_ipv4.h
  134. * header as CIPSO_V4_MAP_*)
  135. *
  136. * (map type == CIPSO_V4_MAP_STD)
  137. *
  138. * +----------------+------------------+----------------------+
  139. * | tags (32 bits) | levels (32 bits) | categories (32 bits) | ...
  140. * +----------------+------------------+----------------------+
  141. *
  142. * +-----------------+
  143. * | tag #X (8 bits) | ... repeated
  144. * +-----------------+
  145. *
  146. * +--------------------------+-------------------------+
  147. * | local level #X (32 bits) | CIPSO level #X (8 bits) | ... repeated
  148. * +--------------------------+-------------------------+
  149. *
  150. * +-----------------------------+-----------------------------+
  151. * | local category #X (32 bits) | CIPSO category #X (16 bits) | ... repeated
  152. * +-----------------------------+-----------------------------+
  153. *
  154. * tags: the number of CIPSO tag types
  155. * levels: the number of level mappings
  156. * categories: the number of category mappings
  157. * tag: the tag number, tags listed first are given higher
  158. * priority when sending packets
  159. * local level: the local part of a level mapping
  160. * CIPSO level: the remote/CIPSO part of a level mapping
  161. * local category: the local part of a category mapping
  162. * CIPSO category: the remote/CIPSO part of a category mapping
  163. *
  164. * (map type == CIPSO_V4_MAP_PASS)
  165. *
  166. * +----------------+
  167. * | tags (32 bits) | ...
  168. * +----------------+
  169. *
  170. * +-----------------+
  171. * | tag #X (8 bits) | ... repeated
  172. * +-----------------+
  173. *
  174. * tags: the number of CIPSO tag types
  175. * tag: the tag number, tags listed first are given higher
  176. * priority when sending packets
  177. *
  178. * o LISTALL:
  179. * This message is sent by an application to list the valid DOIs on the
  180. * system. There is no payload and the kernel should respond with an ACK
  181. * or the following message.
  182. *
  183. * +---------------------+------------------+-----------------------+
  184. * | DOI count (32 bits) | DOI #X (32 bits) | map type #X (32 bits) |
  185. * +---------------------+------------------+-----------------------+
  186. *
  187. * +-----------------------+
  188. * | map type #X (32 bits) | ...
  189. * +-----------------------+
  190. *
  191. * DOI count: the number of DOIs
  192. * DOI: the DOI value
  193. * map type: the DOI mapping table type (defined in the cipso_ipv4.h
  194. * header as CIPSO_V4_MAP_*)
  195. *
  196. */
  197. /* NetLabel CIPSOv4 commands */
  198. enum {
  199. NLBL_CIPSOV4_C_UNSPEC,
  200. NLBL_CIPSOV4_C_ACK,
  201. NLBL_CIPSOV4_C_ADD,
  202. NLBL_CIPSOV4_C_REMOVE,
  203. NLBL_CIPSOV4_C_LIST,
  204. NLBL_CIPSOV4_C_LISTALL,
  205. __NLBL_CIPSOV4_C_MAX,
  206. };
  207. #define NLBL_CIPSOV4_C_MAX (__NLBL_CIPSOV4_C_MAX - 1)
  208. /* NetLabel protocol functions */
  209. int netlbl_cipsov4_genl_init(void);
  210. #endif