PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/packages/net/bsd_tcpip/current/include/netkey/keydb.h

https://gitlab.com/metadevfoundation/ecos-ax-som-bf609
C Header | 178 lines | 82 code | 31 blank | 65 comment | 0 complexity | c32afb7382c3ae30a7f9d03bd2afe9f9 MD5 | raw file
Possible License(s): GPL-2.0, MIT
  1. //==========================================================================
  2. //
  3. // include/netkey/keydb.h
  4. //
  5. //==========================================================================
  6. // ####BSDCOPYRIGHTBEGIN####
  7. // -------------------------------------------
  8. // This file is part of eCos, the Embedded Configurable Operating System.
  9. //
  10. // Portions of this software may have been derived from FreeBSD
  11. // or other sources, and if so are covered by the appropriate copyright
  12. // and license included herein.
  13. //
  14. // Portions created by the Free Software Foundation are
  15. // Copyright (C) 2002 Free Software Foundation, Inc.
  16. // -------------------------------------------
  17. // ####BSDCOPYRIGHTEND####
  18. //==========================================================================
  19. /* $KAME: keydb.h,v 1.14 2000/08/02 17:58:26 sakane Exp $ */
  20. /*
  21. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
  22. * All rights reserved.
  23. *
  24. * Redistribution and use in source and binary forms, with or without
  25. * modification, are permitted provided that the following conditions
  26. * are met:
  27. * 1. Redistributions of source code must retain the above copyright
  28. * notice, this list of conditions and the following disclaimer.
  29. * 2. Redistributions in binary form must reproduce the above copyright
  30. * notice, this list of conditions and the following disclaimer in the
  31. * documentation and/or other materials provided with the distribution.
  32. * 3. Neither the name of the project nor the names of its contributors
  33. * may be used to endorse or promote products derived from this software
  34. * without specific prior written permission.
  35. *
  36. * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  37. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  39. * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  40. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  41. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  42. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  43. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  44. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  45. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46. * SUCH DAMAGE.
  47. */
  48. #ifndef _NETKEY_KEYDB_H_
  49. #define _NETKEY_KEYDB_H_
  50. #ifdef _KERNEL
  51. #include <netkey/key_var.h>
  52. /* Security Assocciation Index */
  53. /* NOTE: Ensure to be same address family */
  54. struct secasindex {
  55. struct sockaddr_storage src; /* srouce address for SA */
  56. struct sockaddr_storage dst; /* destination address for SA */
  57. u_int16_t proto; /* IPPROTO_ESP or IPPROTO_AH */
  58. u_int8_t mode; /* mode of protocol, see ipsec.h */
  59. u_int32_t reqid; /* reqid id who owned this SA */
  60. /* see IPSEC_MANUAL_REQID_MAX. */
  61. };
  62. /* Security Association Data Base */
  63. struct secashead {
  64. LIST_ENTRY(secashead) chain;
  65. struct secasindex saidx;
  66. struct sadb_ident *idents; /* source identity */
  67. struct sadb_ident *identd; /* destination identity */
  68. /* XXX I don't know how to use them. */
  69. u_int8_t state; /* MATURE or DEAD. */
  70. LIST_HEAD(_satree, secasvar) savtree[SADB_SASTATE_MAX+1];
  71. /* SA chain */
  72. /* The first of this list is newer SA */
  73. struct route sa_route; /* route cache */
  74. };
  75. /* Security Association */
  76. struct secasvar {
  77. LIST_ENTRY(secasvar) chain;
  78. int refcnt; /* reference count */
  79. u_int8_t state; /* Status of this Association */
  80. u_int8_t alg_auth; /* Authentication Algorithm Identifier*/
  81. u_int8_t alg_enc; /* Cipher Algorithm Identifier */
  82. u_int32_t spi; /* SPI Value, network byte order */
  83. u_int32_t flags; /* holder for SADB_KEY_FLAGS */
  84. struct sadb_key *key_auth; /* Key for Authentication */
  85. struct sadb_key *key_enc; /* Key for Encryption */
  86. caddr_t iv; /* Initilization Vector */
  87. u_int ivlen; /* length of IV */
  88. void *sched; /* intermediate encryption key */
  89. size_t schedlen;
  90. struct secreplay *replay; /* replay prevention */
  91. long created; /* for lifetime */
  92. struct sadb_lifetime *lft_c; /* CURRENT lifetime, it's constant. */
  93. struct sadb_lifetime *lft_h; /* HARD lifetime */
  94. struct sadb_lifetime *lft_s; /* SOFT lifetime */
  95. u_int32_t seq; /* sequence number */
  96. pid_t pid; /* message's pid */
  97. struct secashead *sah; /* back pointer to the secashead */
  98. };
  99. /* replay prevention */
  100. struct secreplay {
  101. u_int32_t count;
  102. u_int wsize; /* window size, i.g. 4 bytes */
  103. u_int32_t seq; /* used by sender */
  104. u_int32_t lastseq; /* used by receiver */
  105. caddr_t bitmap; /* used by receiver */
  106. int overflow; /* overflow flag */
  107. };
  108. /* socket table due to send PF_KEY messages. */
  109. struct secreg {
  110. LIST_ENTRY(secreg) chain;
  111. struct socket *so;
  112. };
  113. #ifndef IPSEC_NONBLOCK_ACQUIRE
  114. /* acquiring list table. */
  115. struct secacq {
  116. LIST_ENTRY(secacq) chain;
  117. struct secasindex saidx;
  118. u_int32_t seq; /* sequence number */
  119. long created; /* for lifetime */
  120. int count; /* for lifetime */
  121. };
  122. #endif
  123. /* Sensitivity Level Specification */
  124. /* nothing */
  125. #define SADB_KILL_INTERVAL 600 /* six seconds */
  126. struct key_cb {
  127. int key_count;
  128. int any_count;
  129. };
  130. /* secpolicy */
  131. extern struct secpolicy *keydb_newsecpolicy __P((void));
  132. extern void keydb_delsecpolicy __P((struct secpolicy *));
  133. /* secashead */
  134. extern struct secashead *keydb_newsecashead __P((void));
  135. extern void keydb_delsecashead __P((struct secashead *));
  136. /* secasvar */
  137. extern struct secasvar *keydb_newsecasvar __P((void));
  138. extern void keydb_refsecasvar __P((struct secasvar *));
  139. extern void keydb_freesecasvar __P((struct secasvar *));
  140. /* secreplay */
  141. extern struct secreplay *keydb_newsecreplay __P((size_t));
  142. extern void keydb_delsecreplay __P((struct secreplay *));
  143. /* secreg */
  144. extern struct secreg *keydb_newsecreg __P((void));
  145. extern void keydb_delsecreg __P((struct secreg *));
  146. #endif /* _KERNEL */
  147. #endif /* _NETKEY_KEYDB_H_ */