summaryrefslogtreecommitdiffstats
path: root/Samples/C#/IPSec/ipsec_lib/swig.i
blob: e9bd2241f480a45c7666f9f3a88ab4ad10684ccd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
%module ipsec_lib
%module(directors="1") ipsec_lib

%include "enums.swg"
%include <stdint.i>

%define %cs_marshal_array(TYPE, CSTYPE)
%typemap(ctype) TYPE[] "void*"
%typemap(imtype,
inattributes="[MarshalAs(UnmanagedType.LPArray)]") TYPE[] "CSTYPE[]"
%typemap(cstype) TYPE[] "CSTYPE[]"
%typemap(in) TYPE[] %{ $1 = (TYPE*)$input; %}
%typemap(csin) TYPE[] "$csinput"
%enddef

// Mapping void* as IntPtr
%typemap(ctype)  void * "void *"
%typemap(imtype) void * "IntPtr"
%typemap(cstype) void * "IntPtr"
%typemap(csin)   void * "$csinput"
%typemap(in)     void * %{ $1 = $input; %}
%typemap(out)    void * %{ $result = $1; %}
%typemap(csout)  void * { return $imcall; }
%typemap(csdirectorin) void * "$iminput"

%{
#include "IPSecCtx.h"
%}

%nodefaultctor;
%include "IPSecCtx.h"
%clearnodefaultctor;


/**@def tipsec_lifetime_t
*/
/**@def tipsec_spi_t
*/
/**@def tipsec_port_t
*/
/**@def tipsec_key_t
*/
typedef uint64_t tipsec_lifetime_t;
typedef uint32_t tipsec_spi_t;
typedef uint16_t tipsec_port_t;
typedef void tipsec_key_t;

/**@ingroup tipsec_common_group
 * List of IPSec modes.
**/
typedef enum tipsec_mode_e {
    //! IPSec transport mode.
    tipsec_mode_trans,
    //! IPSec tunneling mode.
    tipsec_mode_tun
}
tipsec_mode_t;

/** List of supported IPSec protocols.
**/
typedef enum tipsec_proto_e {
    //! AH protocol ("ah").
    tipsec_proto_ah = (0x01 << 0),
    //! ESP protocol ("esp").
    tipsec_proto_esp = (0x01 << 1),
    //! Both AH and ESP protocols ("ah/esp").
    tipsec_proto_both = (tipsec_proto_ah | tipsec_proto_esp)
}
tipsec_proto_t;

/**List of supported Internet protocols for IPSec.
**/
typedef enum tipsec_ipproto_e {
    //! UDP.
    tipsec_ipproto_udp,
    //! TCP.
    tipsec_ipproto_tcp,
    //! ICMP.
    tipsec_ipproto_icmp,
    //! ALL.
    tipsec_ipproto_all
}
tipsec_ipproto_t;

/**List of IPSec IPSec algorithms.
**/
typedef enum tipsec_alg_e {
    //! "hmac-md5-96" algorithm.
    tipsec_alg_hmac_md5_96,
    //! "hmac-sha-1-96" algorithm.
    tipsec_alg_hmac_sha_1_96
}
tipsec_alg_t;

/**List of supported IPSec encryption algorithms.
**/
typedef enum tipsec_ealg_e {
    //! "des-ede3-cbc" encryption algorithm.
    tipsec_ealg_des_ede3_cbc,
    //! "aes" encryption algorithm.
    tipsec_ealg_aes,
    //! "null" encryption algorithm.
    tipsec_ealg_null
}
tipsec_ealg_t;

/** List of IPSec states.
**/
typedef enum tipsec_state_e {
    //! The default state. At this state no SA is created. It's the first and default state.
    tipsec_state_initial,
    //! Partial state. At this state only inbound SAs (with their SPIs) have been created.
    tipsec_state_inbound,
    //! Full state. At this state both inbound and outbound SAs have been create. It's the final state.
    tipsec_state_full,
    //! All SAs are in active mode.
    tipsec_state_active
}
tipsec_state_t;

/** List of supported IPSec errors
*/
typedef enum tipsec_error_e {
    tipsec_error_success = 0, /**< Success */
    tipsec_error_invalid_param, /**< Invalid parameter */
	tipsec_error_invalid_state, /**< Invalid state */
    tipsec_error_access_violation, /**< Access violation */
    tipsec_error_permission_denied, /**< Permission denied */
    tipsec_error_outofmemory, /**< Out of memory */
    tipsec_error_outofbound, /**< Out of bound */
    tipsec_error_notfound, /**< Not found */
    tipsec_error_notimplemented, /**< Not implemented */
	tipsec_error_sys, /**< System error */
}
tipsec_error_t;
OpenPOWER on IntegriCloud