swig.i 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. %module ipsec_lib
  2. %module(directors="1") ipsec_lib
  3. %include "enums.swg"
  4. %include <stdint.i>
  5. %define %cs_marshal_array(TYPE, CSTYPE)
  6. %typemap(ctype) TYPE[] "void*"
  7. %typemap(imtype,
  8. inattributes="[MarshalAs(UnmanagedType.LPArray)]") TYPE[] "CSTYPE[]"
  9. %typemap(cstype) TYPE[] "CSTYPE[]"
  10. %typemap(in) TYPE[] %{ $1 = (TYPE*)$input; %}
  11. %typemap(csin) TYPE[] "$csinput"
  12. %enddef
  13. // Mapping void* as IntPtr
  14. %typemap(ctype) void * "void *"
  15. %typemap(imtype) void * "IntPtr"
  16. %typemap(cstype) void * "IntPtr"
  17. %typemap(csin) void * "$csinput"
  18. %typemap(in) void * %{ $1 = $input; %}
  19. %typemap(out) void * %{ $result = $1; %}
  20. %typemap(csout) void * { return $imcall; }
  21. %typemap(csdirectorin) void * "$iminput"
  22. %{
  23. #include "IPSecCtx.h"
  24. %}
  25. %nodefaultctor;
  26. %include "IPSecCtx.h"
  27. %clearnodefaultctor;
  28. /**@def tipsec_lifetime_t
  29. */
  30. /**@def tipsec_spi_t
  31. */
  32. /**@def tipsec_port_t
  33. */
  34. /**@def tipsec_key_t
  35. */
  36. typedef uint64_t tipsec_lifetime_t;
  37. typedef uint32_t tipsec_spi_t;
  38. typedef uint16_t tipsec_port_t;
  39. typedef void tipsec_key_t;
  40. /**@ingroup tipsec_common_group
  41. * List of IPSec modes.
  42. **/
  43. typedef enum tipsec_mode_e {
  44. //! IPSec transport mode.
  45. tipsec_mode_trans,
  46. //! IPSec tunneling mode.
  47. tipsec_mode_tun
  48. }
  49. tipsec_mode_t;
  50. /** List of supported IPSec protocols.
  51. **/
  52. typedef enum tipsec_proto_e {
  53. //! AH protocol ("ah").
  54. tipsec_proto_ah = (0x01 << 0),
  55. //! ESP protocol ("esp").
  56. tipsec_proto_esp = (0x01 << 1),
  57. //! Both AH and ESP protocols ("ah/esp").
  58. tipsec_proto_both = (tipsec_proto_ah | tipsec_proto_esp)
  59. }
  60. tipsec_proto_t;
  61. /**List of supported Internet protocols for IPSec.
  62. **/
  63. typedef enum tipsec_ipproto_e {
  64. //! UDP.
  65. tipsec_ipproto_udp,
  66. //! TCP.
  67. tipsec_ipproto_tcp,
  68. //! ICMP.
  69. tipsec_ipproto_icmp,
  70. //! ALL.
  71. tipsec_ipproto_all
  72. }
  73. tipsec_ipproto_t;
  74. /**List of IPSec IPSec algorithms.
  75. **/
  76. typedef enum tipsec_alg_e {
  77. //! "hmac-md5-96" algorithm.
  78. tipsec_alg_hmac_md5_96,
  79. //! "hmac-sha-1-96" algorithm.
  80. tipsec_alg_hmac_sha_1_96
  81. }
  82. tipsec_alg_t;
  83. /**List of supported IPSec encryption algorithms.
  84. **/
  85. typedef enum tipsec_ealg_e {
  86. //! "des-ede3-cbc" encryption algorithm.
  87. tipsec_ealg_des_ede3_cbc,
  88. //! "aes" encryption algorithm.
  89. tipsec_ealg_aes,
  90. //! "null" encryption algorithm.
  91. tipsec_ealg_null
  92. }
  93. tipsec_ealg_t;
  94. /** List of IPSec states.
  95. **/
  96. typedef enum tipsec_state_e {
  97. //! The default state. At this state no SA is created. It's the first and default state.
  98. tipsec_state_initial,
  99. //! Partial state. At this state only inbound SAs (with their SPIs) have been created.
  100. tipsec_state_inbound,
  101. //! Full state. At this state both inbound and outbound SAs have been create. It's the final state.
  102. tipsec_state_full,
  103. //! All SAs are in active mode.
  104. tipsec_state_active
  105. }
  106. tipsec_state_t;
  107. /** List of supported IPSec errors
  108. */
  109. typedef enum tipsec_error_e {
  110. tipsec_error_success = 0, /**< Success */
  111. tipsec_error_invalid_param, /**< Invalid parameter */
  112. tipsec_error_invalid_state, /**< Invalid state */
  113. tipsec_error_access_violation, /**< Access violation */
  114. tipsec_error_permission_denied, /**< Permission denied */
  115. tipsec_error_outofmemory, /**< Out of memory */
  116. tipsec_error_outofbound, /**< Out of bound */
  117. tipsec_error_notfound, /**< Not found */
  118. tipsec_error_notimplemented, /**< Not implemented */
  119. tipsec_error_sys, /**< System error */
  120. }
  121. tipsec_error_t;