sa.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
  3. *
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. *
  12. * Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the
  15. * distribution.
  16. *
  17. * Neither the name of Texas Instruments Incorporated nor the names of
  18. * its contributors may be used to endorse or promote products derived
  19. * from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. */
  34. #ifndef NETLINK_XFRM_SA_H_
  35. #define NETLINK_XFRM_SA_H_
  36. #include <netlink/netlink.h>
  37. #include <netlink/cache.h>
  38. #include <netlink/addr.h>
  39. #include <linux/xfrm.h>
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. struct xfrmnl_sa;
  44. extern struct xfrmnl_sa* xfrmnl_sa_alloc(void);
  45. extern void xfrmnl_sa_put(struct xfrmnl_sa *);
  46. extern int xfrmnl_sa_alloc_cache(struct nl_sock *, struct nl_cache **);
  47. extern struct xfrmnl_sa* xfrmnl_sa_get(struct nl_cache*, struct nl_addr*, unsigned int, unsigned int);
  48. extern int xfrmnl_sa_parse(struct nlmsghdr *n, struct xfrmnl_sa **result);
  49. extern int xfrmnl_sa_build_get_request(struct nl_addr*, unsigned int, unsigned int,
  50. unsigned int, unsigned int, struct nl_msg **);
  51. extern int xfrmnl_sa_get_kernel(struct nl_sock*, struct nl_addr*, unsigned int,
  52. unsigned int, unsigned int, unsigned int, struct xfrmnl_sa**);
  53. extern int xfrmnl_sa_build_add_request(struct xfrmnl_sa*, int, struct nl_msg **);
  54. extern int xfrmnl_sa_add(struct nl_sock*, struct xfrmnl_sa*, int);
  55. extern int xfrmnl_sa_build_update_request(struct xfrmnl_sa*, int, struct nl_msg **);
  56. extern int xfrmnl_sa_update(struct nl_sock*, struct xfrmnl_sa*, int);
  57. extern int xfrmnl_sa_build_delete_request(struct xfrmnl_sa*, int, struct nl_msg **);
  58. extern int xfrmnl_sa_delete(struct nl_sock*, struct xfrmnl_sa*, int);
  59. extern struct xfrmnl_sel* xfrmnl_sa_get_sel (struct xfrmnl_sa*);
  60. extern int xfrmnl_sa_set_sel (struct xfrmnl_sa*, struct xfrmnl_sel*);
  61. extern struct nl_addr* xfrmnl_sa_get_daddr (struct xfrmnl_sa*);
  62. extern int xfrmnl_sa_set_daddr (struct xfrmnl_sa*, struct nl_addr*);
  63. extern int xfrmnl_sa_get_spi (struct xfrmnl_sa*);
  64. extern int xfrmnl_sa_set_spi (struct xfrmnl_sa*, unsigned int);
  65. extern int xfrmnl_sa_get_proto (struct xfrmnl_sa*);
  66. extern int xfrmnl_sa_set_proto (struct xfrmnl_sa*, unsigned int);
  67. extern struct nl_addr* xfrmnl_sa_get_saddr (struct xfrmnl_sa*);
  68. extern int xfrmnl_sa_set_saddr (struct xfrmnl_sa*, struct nl_addr*);
  69. extern struct xfrmnl_ltime_cfg* xfrmnl_sa_get_lifetime_cfg (struct xfrmnl_sa*);
  70. extern int xfrmnl_sa_set_lifetime_cfg (struct xfrmnl_sa*, struct xfrmnl_ltime_cfg*);
  71. extern int xfrmnl_sa_get_curlifetime (struct xfrmnl_sa*, unsigned long long int*,
  72. unsigned long long int*, unsigned long long int*,
  73. unsigned long long int*);
  74. extern int xfrmnl_sa_get_stats (struct xfrmnl_sa*, unsigned long long int*,
  75. unsigned long long int*, unsigned long long int*);
  76. extern int xfrmnl_sa_get_seq (struct xfrmnl_sa*);
  77. extern int xfrmnl_sa_get_reqid (struct xfrmnl_sa*);
  78. extern int xfrmnl_sa_set_reqid (struct xfrmnl_sa*, unsigned int);
  79. extern int xfrmnl_sa_get_family (struct xfrmnl_sa*);
  80. extern int xfrmnl_sa_set_family (struct xfrmnl_sa*, unsigned int);
  81. extern int xfrmnl_sa_get_mode (struct xfrmnl_sa*);
  82. extern int xfrmnl_sa_set_mode (struct xfrmnl_sa*, unsigned int);
  83. extern int xfrmnl_sa_get_replay_window (struct xfrmnl_sa*);
  84. extern int xfrmnl_sa_set_replay_window (struct xfrmnl_sa*, unsigned int);
  85. extern int xfrmnl_sa_get_flags (struct xfrmnl_sa*);
  86. extern int xfrmnl_sa_set_flags (struct xfrmnl_sa*, unsigned int);
  87. extern int xfrmnl_sa_get_aead_params (struct xfrmnl_sa*, char*, unsigned int*,
  88. unsigned int*, char*);
  89. extern int xfrmnl_sa_set_aead_params (struct xfrmnl_sa*, const char*, unsigned int,
  90. unsigned int, const char*);
  91. extern int xfrmnl_sa_get_auth_params (struct xfrmnl_sa*, char*, unsigned int*,
  92. unsigned int*, char*);
  93. extern int xfrmnl_sa_set_auth_params (struct xfrmnl_sa*, const char*, unsigned int,
  94. unsigned int, const char*);
  95. extern int xfrmnl_sa_get_crypto_params (struct xfrmnl_sa*, char*, unsigned int*, char*);
  96. extern int xfrmnl_sa_set_crypto_params (struct xfrmnl_sa*, const char*, unsigned int,
  97. const char*);
  98. extern int xfrmnl_sa_get_comp_params (struct xfrmnl_sa*, char*, unsigned int*, char*);
  99. extern int xfrmnl_sa_set_comp_params (struct xfrmnl_sa*, const char*, unsigned int,
  100. const char*);
  101. extern int xfrmnl_sa_get_encap_tmpl (struct xfrmnl_sa*, unsigned int*, unsigned int*,
  102. unsigned int*, struct nl_addr**);
  103. extern int xfrmnl_sa_set_encap_tmpl (struct xfrmnl_sa*, unsigned int, unsigned int,
  104. unsigned int, struct nl_addr*);
  105. extern int xfrmnl_sa_get_tfcpad (struct xfrmnl_sa*);
  106. extern int xfrmnl_sa_set_tfcpad (struct xfrmnl_sa*, unsigned int);
  107. extern struct nl_addr* xfrmnl_sa_get_coaddr (struct xfrmnl_sa*);
  108. extern int xfrmnl_sa_set_coaddr (struct xfrmnl_sa*, struct nl_addr*);
  109. extern int xfrmnl_sa_get_mark (struct xfrmnl_sa*, unsigned int*, unsigned int*);
  110. extern int xfrmnl_sa_set_mark (struct xfrmnl_sa*, unsigned int, unsigned int);
  111. extern int xfrmnl_sa_get_sec_ctx (struct xfrmnl_sa*, unsigned int, unsigned int,
  112. unsigned int, unsigned int, char*);
  113. extern int xfrmnl_sa_set_sec_ctx (struct xfrmnl_sa*, unsigned int, unsigned int,
  114. unsigned int, unsigned int, const char*);
  115. extern int xfrmnl_sa_get_replay_maxage (struct xfrmnl_sa*);
  116. extern int xfrmnl_sa_set_replay_maxage (struct xfrmnl_sa*, unsigned int);
  117. extern int xfrmnl_sa_get_replay_maxdiff (struct xfrmnl_sa*);
  118. extern int xfrmnl_sa_set_replay_maxdiff (struct xfrmnl_sa*, unsigned int);
  119. extern int xfrmnl_sa_get_replay_state (struct xfrmnl_sa*, unsigned int*,
  120. unsigned int*, unsigned int*);
  121. extern int xfrmnl_sa_set_replay_state (struct xfrmnl_sa*, unsigned int,
  122. unsigned int, unsigned int);
  123. extern int xfrmnl_sa_get_replay_state_esn (struct xfrmnl_sa*, unsigned int*, unsigned int*,
  124. unsigned int*, unsigned int*, unsigned int*,
  125. unsigned int*, unsigned int*);
  126. extern int xfrmnl_sa_set_replay_state_esn (struct xfrmnl_sa*, unsigned int, unsigned int,
  127. unsigned int, unsigned int, unsigned int,
  128. unsigned int, unsigned int*);
  129. extern int xfrmnl_sa_is_expiry_reached (struct xfrmnl_sa*);
  130. extern int xfrmnl_sa_is_hardexpiry_reached (struct xfrmnl_sa*);
  131. extern char* xfrmnl_sa_flags2str(int, char *, size_t);
  132. extern int xfrmnl_sa_str2flag(const char *);
  133. extern char* xfrmnl_sa_mode2str(int, char *, size_t);
  134. extern int xfrmnl_sa_str2mode(const char *);
  135. #ifdef __cplusplus
  136. }
  137. #endif
  138. #endif