summaryrefslogtreecommitdiffstats
path: root/Samples/C#/IPSec/ipsec_lib
diff options
context:
space:
mode:
Diffstat (limited to 'Samples/C#/IPSec/ipsec_lib')
-rw-r--r--Samples/C#/IPSec/ipsec_lib/IPSecCtx.cs94
-rw-r--r--Samples/C#/IPSec/ipsec_lib/IPSecCtx.cxx95
-rw-r--r--Samples/C#/IPSec/ipsec_lib/IPSecCtx.h50
-rw-r--r--Samples/C#/IPSec/ipsec_lib/ipsecWRAP.cxx512
-rw-r--r--Samples/C#/IPSec/ipsec_lib/ipsecWRAP.h15
-rw-r--r--Samples/C#/IPSec/ipsec_lib/ipsec_lib.cs17
-rw-r--r--Samples/C#/IPSec/ipsec_lib/ipsec_lib.vcproj241
-rw-r--r--Samples/C#/IPSec/ipsec_lib/ipsec_libPINVOKE.cs226
-rw-r--r--Samples/C#/IPSec/ipsec_lib/swig.i135
-rw-r--r--Samples/C#/IPSec/ipsec_lib/swig.sh1
-rw-r--r--Samples/C#/IPSec/ipsec_lib/tipsec_alg_t.cs16
-rw-r--r--Samples/C#/IPSec/ipsec_lib/tipsec_ealg_t.cs17
-rw-r--r--Samples/C#/IPSec/ipsec_lib/tipsec_error_t.cs24
-rw-r--r--Samples/C#/IPSec/ipsec_lib/tipsec_ipproto_t.cs18
-rw-r--r--Samples/C#/IPSec/ipsec_lib/tipsec_mode_t.cs16
-rw-r--r--Samples/C#/IPSec/ipsec_lib/tipsec_proto_t.cs17
-rw-r--r--Samples/C#/IPSec/ipsec_lib/tipsec_state_t.cs18
17 files changed, 1512 insertions, 0 deletions
diff --git a/Samples/C#/IPSec/ipsec_lib/IPSecCtx.cs b/Samples/C#/IPSec/ipsec_lib/IPSecCtx.cs
new file mode 100644
index 0000000..ccf94e2
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/IPSecCtx.cs
@@ -0,0 +1,94 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.9
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace org.doubango.ipsecWRAP {
+
+using System;
+using System.Runtime.InteropServices;
+
+public class IPSecCtx : IDisposable {
+ private HandleRef swigCPtr;
+ protected bool swigCMemOwn;
+
+ internal IPSecCtx(IntPtr cPtr, bool cMemoryOwn) {
+ swigCMemOwn = cMemoryOwn;
+ swigCPtr = new HandleRef(this, cPtr);
+ }
+
+ internal static HandleRef getCPtr(IPSecCtx obj) {
+ return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
+ }
+
+ ~IPSecCtx() {
+ Dispose();
+ }
+
+ public virtual void Dispose() {
+ lock(this) {
+ if (swigCPtr.Handle != IntPtr.Zero) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ ipsec_libPINVOKE.delete_IPSecCtx(swigCPtr);
+ }
+ swigCPtr = new HandleRef(null, IntPtr.Zero);
+ }
+ GC.SuppressFinalize(this);
+ }
+ }
+
+ public IPSecCtx(tipsec_ipproto_t ipproto, bool use_ipv6, tipsec_mode_t mode, tipsec_ealg_t ealg, tipsec_alg_t alg, tipsec_proto_t protocol) : this(ipsec_libPINVOKE.new_IPSecCtx((int)ipproto, use_ipv6, (int)mode, (int)ealg, (int)alg, (int)protocol), true) {
+ }
+
+ public tipsec_error_t start() {
+ tipsec_error_t ret = (tipsec_error_t)ipsec_libPINVOKE.IPSecCtx_start(swigCPtr);
+ return ret;
+ }
+
+ public tipsec_error_t setLocal(string addr_local, string addr_remote, ushort port_uc, ushort port_us) {
+ tipsec_error_t ret = (tipsec_error_t)ipsec_libPINVOKE.IPSecCtx_setLocal(swigCPtr, addr_local, addr_remote, port_uc, port_us);
+ return ret;
+ }
+
+ public tipsec_error_t setKeys(IntPtr ik, IntPtr ck) {
+ tipsec_error_t ret = (tipsec_error_t)ipsec_libPINVOKE.IPSecCtx_setKeys(swigCPtr, ik, ck);
+ return ret;
+ }
+
+ public tipsec_error_t setRemote(uint spi_pc, uint spi_ps, ushort port_pc, ushort port_ps, ulong lifetime) {
+ tipsec_error_t ret = (tipsec_error_t)ipsec_libPINVOKE.IPSecCtx_setRemote(swigCPtr, spi_pc, spi_ps, port_pc, port_ps, lifetime);
+ return ret;
+ }
+
+ public tipsec_error_t stop() {
+ tipsec_error_t ret = (tipsec_error_t)ipsec_libPINVOKE.IPSecCtx_stop(swigCPtr);
+ return ret;
+ }
+
+ public uint getSpiUC() {
+ uint ret = ipsec_libPINVOKE.IPSecCtx_getSpiUC(swigCPtr);
+ return ret;
+ }
+
+ public uint getSpiUS() {
+ uint ret = ipsec_libPINVOKE.IPSecCtx_getSpiUS(swigCPtr);
+ return ret;
+ }
+
+ public uint getSpiPC() {
+ uint ret = ipsec_libPINVOKE.IPSecCtx_getSpiPC(swigCPtr);
+ return ret;
+ }
+
+ public uint getSpiPS() {
+ uint ret = ipsec_libPINVOKE.IPSecCtx_getSpiPS(swigCPtr);
+ return ret;
+ }
+
+}
+
+}
diff --git a/Samples/C#/IPSec/ipsec_lib/IPSecCtx.cxx b/Samples/C#/IPSec/ipsec_lib/IPSecCtx.cxx
new file mode 100644
index 0000000..db6bf63
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/IPSecCtx.cxx
@@ -0,0 +1,95 @@
+/* Copyright (C) 2010-2014 Mamadou DIOP
+* Copyright (C) 2011-2014 Doubango Telecom <http://www.doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*/
+#include "IPSecCtx.h"
+#include "tsk_debug.h"
+
+#include <assert.h>
+
+bool IPSecCtx::sInitialized = false;
+extern "C" const tipsec_plugin_def_t *plugin_win_ipsec_vista_plugin_def_t;
+
+IPSecCtx::IPSecCtx(tipsec_ipproto_t ipproto,
+ bool use_ipv6,
+ tipsec_mode_t mode,
+ tipsec_ealg_t ealg,
+ tipsec_alg_t alg,
+ tipsec_proto_t protocol)
+: m_pCtx(NULL)
+{
+ tipsec_ctx_t* pCtx = NULL;
+ if (!IPSecCtx::sInitialized)
+ {
+ assert (tipsec_plugin_register_static(plugin_win_ipsec_vista_plugin_def_t) == 0);
+ IPSecCtx::sInitialized = true;
+ }
+ assert (tipsec_ctx_create(ipproto, use_ipv6, mode, ealg, alg, protocol, &m_pCtx) == 0 && m_pCtx != NULL);
+}
+
+IPSecCtx::~IPSecCtx()
+{
+ TSK_OBJECT_SAFE_FREE(m_pCtx);
+}
+
+tipsec_error_t IPSecCtx::start()
+{
+ return tipsec_ctx_start(m_pCtx);
+}
+
+tipsec_error_t IPSecCtx::setLocal(const char* addr_local, const char* addr_remote, tipsec_port_t port_uc, tipsec_port_t port_us)
+{
+ return tipsec_ctx_set_local(m_pCtx, addr_local, addr_remote, port_uc, port_us);
+}
+
+tipsec_error_t IPSecCtx::setKeys(const tipsec_key_t* ik, const tipsec_key_t* ck)
+{
+ return tipsec_ctx_set_keys(m_pCtx, ik, ck);
+}
+
+tipsec_error_t IPSecCtx::setRemote(tipsec_spi_t spi_pc, tipsec_spi_t spi_ps, tipsec_port_t port_pc, tipsec_port_t port_ps, tipsec_lifetime_t lifetime)
+{
+ return tipsec_ctx_set_remote(m_pCtx, spi_pc, spi_ps, port_pc, port_ps, lifetime);
+}
+
+tipsec_error_t IPSecCtx::stop()
+{
+ return tipsec_ctx_stop(m_pCtx);
+}
+
+tipsec_spi_t IPSecCtx::getSpiUC()
+{
+ return m_pCtx->spi_uc;
+}
+
+tipsec_spi_t IPSecCtx::getSpiUS()
+{
+ return m_pCtx->spi_us;
+}
+
+tipsec_spi_t IPSecCtx::getSpiPC()
+{
+ return m_pCtx->spi_pc;
+}
+
+tipsec_spi_t IPSecCtx::getSpiPS()
+{
+ return m_pCtx->spi_ps;
+}
+
+
+
diff --git a/Samples/C#/IPSec/ipsec_lib/IPSecCtx.h b/Samples/C#/IPSec/ipsec_lib/IPSecCtx.h
new file mode 100644
index 0000000..0e7d0ef
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/IPSecCtx.h
@@ -0,0 +1,50 @@
+/* Copyright (C) 2010-2014 Mamadou DIOP
+* Copyright (C) 2011-2014 Doubango Telecom <http://www.doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* DOUBANGO is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with DOUBANGO.
+*/
+#ifndef IPSEC_CTX_H
+#define IPSEC_CTX_H
+
+#include "tipsec.h"
+
+class IPSecCtx
+{
+public:
+ IPSecCtx(tipsec_ipproto_t ipproto,
+ bool use_ipv6,
+ tipsec_mode_t mode,
+ tipsec_ealg_t ealg,
+ tipsec_alg_t alg,
+ tipsec_proto_t protocol);
+ virtual ~IPSecCtx();
+ tipsec_error_t start();
+ tipsec_error_t setLocal(const char* addr_local, const char* addr_remote, tipsec_port_t port_uc, tipsec_port_t port_us);
+ tipsec_error_t setKeys(const tipsec_key_t* ik, const tipsec_key_t* ck);
+ tipsec_error_t setRemote(tipsec_spi_t spi_pc, tipsec_spi_t spi_ps, tipsec_port_t port_pc, tipsec_port_t port_ps, tipsec_lifetime_t lifetime);
+ tipsec_error_t stop();
+
+ tipsec_spi_t getSpiUC();
+ tipsec_spi_t getSpiUS();
+ tipsec_spi_t getSpiPC();
+ tipsec_spi_t getSpiPS();
+
+private:
+ static bool sInitialized;
+ tipsec_ctx_t* m_pCtx;
+};
+
+#endif /* IPSEC_CTX_H */
diff --git a/Samples/C#/IPSec/ipsec_lib/ipsecWRAP.cxx b/Samples/C#/IPSec/ipsec_lib/ipsecWRAP.cxx
new file mode 100644
index 0000000..336643d
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/ipsecWRAP.cxx
@@ -0,0 +1,512 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.9
+ *
+ * This file is not intended to be easily readable and contains a number of
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+#define SWIGCSHARP
+#define SWIG_DIRECTORS
+
+
+#ifdef __cplusplus
+/* SwigValueWrapper is described in swig.swg */
+template<typename T> class SwigValueWrapper {
+ struct SwigMovePointer {
+ T *ptr;
+ SwigMovePointer(T *p) : ptr(p) { }
+ ~SwigMovePointer() { delete ptr; }
+ SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
+ } pointer;
+ SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
+ SwigValueWrapper(const SwigValueWrapper<T>& rhs);
+public:
+ SwigValueWrapper() : pointer(0) { }
+ SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
+ operator T&() const { return *pointer.ptr; }
+ T *operator&() { return pointer.ptr; }
+};
+
+template <typename T> T SwigValueInit() {
+ return T();
+}
+#endif
+
+/* -----------------------------------------------------------------------------
+ * This section contains generic SWIG labels for method/variable
+ * declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# elif defined(__HP_aCC)
+/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
+/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+# define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+# define SWIGINLINE inline
+# else
+# define SWIGINLINE
+# endif
+#endif
+
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+# elif defined(__ICC)
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+#endif
+
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+# pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif
+#endif
+
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+# define SWIGUNUSEDPARM(p)
+# else
+# define SWIGUNUSEDPARM(p) p SWIGUNUSED
+# endif
+#endif
+
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
+
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
+
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+# ifndef GCC_HASCLASSVISIBILITY
+# define GCC_HASCLASSVISIBILITY
+# endif
+#endif
+
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# if defined(STATIC_LINKED)
+# define SWIGEXPORT
+# else
+# define SWIGEXPORT __declspec(dllexport)
+# endif
+# else
+# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+# define SWIGEXPORT __attribute__ ((visibility("default")))
+# else
+# define SWIGEXPORT
+# endif
+# endif
+#endif
+
+/* calling conventions for Windows */
+#ifndef SWIGSTDCALL
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# define SWIGSTDCALL __stdcall
+# else
+# define SWIGSTDCALL
+# endif
+#endif
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+
+/* Support for throwing C# exceptions from C/C++. There are two types:
+ * Exceptions that take a message and ArgumentExceptions that take a message and a parameter name. */
+typedef enum {
+ SWIG_CSharpApplicationException,
+ SWIG_CSharpArithmeticException,
+ SWIG_CSharpDivideByZeroException,
+ SWIG_CSharpIndexOutOfRangeException,
+ SWIG_CSharpInvalidCastException,
+ SWIG_CSharpInvalidOperationException,
+ SWIG_CSharpIOException,
+ SWIG_CSharpNullReferenceException,
+ SWIG_CSharpOutOfMemoryException,
+ SWIG_CSharpOverflowException,
+ SWIG_CSharpSystemException
+} SWIG_CSharpExceptionCodes;
+
+typedef enum {
+ SWIG_CSharpArgumentException,
+ SWIG_CSharpArgumentNullException,
+ SWIG_CSharpArgumentOutOfRangeException
+} SWIG_CSharpExceptionArgumentCodes;
+
+typedef void (SWIGSTDCALL* SWIG_CSharpExceptionCallback_t)(const char *);
+typedef void (SWIGSTDCALL* SWIG_CSharpExceptionArgumentCallback_t)(const char *, const char *);
+
+typedef struct {
+ SWIG_CSharpExceptionCodes code;
+ SWIG_CSharpExceptionCallback_t callback;
+} SWIG_CSharpException_t;
+
+typedef struct {
+ SWIG_CSharpExceptionArgumentCodes code;
+ SWIG_CSharpExceptionArgumentCallback_t callback;
+} SWIG_CSharpExceptionArgument_t;
+
+static SWIG_CSharpException_t SWIG_csharp_exceptions[] = {
+ { SWIG_CSharpApplicationException, NULL },
+ { SWIG_CSharpArithmeticException, NULL },
+ { SWIG_CSharpDivideByZeroException, NULL },
+ { SWIG_CSharpIndexOutOfRangeException, NULL },
+ { SWIG_CSharpInvalidCastException, NULL },
+ { SWIG_CSharpInvalidOperationException, NULL },
+ { SWIG_CSharpIOException, NULL },
+ { SWIG_CSharpNullReferenceException, NULL },
+ { SWIG_CSharpOutOfMemoryException, NULL },
+ { SWIG_CSharpOverflowException, NULL },
+ { SWIG_CSharpSystemException, NULL }
+};
+
+static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = {
+ { SWIG_CSharpArgumentException, NULL },
+ { SWIG_CSharpArgumentNullException, NULL },
+ { SWIG_CSharpArgumentOutOfRangeException, NULL }
+};
+
+static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) {
+ SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback;
+ if ((size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) {
+ callback = SWIG_csharp_exceptions[code].callback;
+ }
+ callback(msg);
+}
+
+static void SWIGUNUSED SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code, const char *msg, const char *param_name) {
+ SWIG_CSharpExceptionArgumentCallback_t callback = SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback;
+ if ((size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) {
+ callback = SWIG_csharp_exceptions_argument[code].callback;
+ }
+ callback(msg, param_name);
+}
+
+
+#ifdef __cplusplus
+extern "C"
+#endif
+SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionCallbacks_ipsec_lib(
+ SWIG_CSharpExceptionCallback_t applicationCallback,
+ SWIG_CSharpExceptionCallback_t arithmeticCallback,
+ SWIG_CSharpExceptionCallback_t divideByZeroCallback,
+ SWIG_CSharpExceptionCallback_t indexOutOfRangeCallback,
+ SWIG_CSharpExceptionCallback_t invalidCastCallback,
+ SWIG_CSharpExceptionCallback_t invalidOperationCallback,
+ SWIG_CSharpExceptionCallback_t ioCallback,
+ SWIG_CSharpExceptionCallback_t nullReferenceCallback,
+ SWIG_CSharpExceptionCallback_t outOfMemoryCallback,
+ SWIG_CSharpExceptionCallback_t overflowCallback,
+ SWIG_CSharpExceptionCallback_t systemCallback) {
+ SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback = applicationCallback;
+ SWIG_csharp_exceptions[SWIG_CSharpArithmeticException].callback = arithmeticCallback;
+ SWIG_csharp_exceptions[SWIG_CSharpDivideByZeroException].callback = divideByZeroCallback;
+ SWIG_csharp_exceptions[SWIG_CSharpIndexOutOfRangeException].callback = indexOutOfRangeCallback;
+ SWIG_csharp_exceptions[SWIG_CSharpInvalidCastException].callback = invalidCastCallback;
+ SWIG_csharp_exceptions[SWIG_CSharpInvalidOperationException].callback = invalidOperationCallback;
+ SWIG_csharp_exceptions[SWIG_CSharpIOException].callback = ioCallback;
+ SWIG_csharp_exceptions[SWIG_CSharpNullReferenceException].callback = nullReferenceCallback;
+ SWIG_csharp_exceptions[SWIG_CSharpOutOfMemoryException].callback = outOfMemoryCallback;
+ SWIG_csharp_exceptions[SWIG_CSharpOverflowException].callback = overflowCallback;
+ SWIG_csharp_exceptions[SWIG_CSharpSystemException].callback = systemCallback;
+}
+
+#ifdef __cplusplus
+extern "C"
+#endif
+SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_ipsec_lib(
+ SWIG_CSharpExceptionArgumentCallback_t argumentCallback,
+ SWIG_CSharpExceptionArgumentCallback_t argumentNullCallback,
+ SWIG_CSharpExceptionArgumentCallback_t argumentOutOfRangeCallback) {
+ SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback = argumentCallback;
+ SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentNullException].callback = argumentNullCallback;
+ SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentOutOfRangeException].callback = argumentOutOfRangeCallback;
+}
+
+
+/* Callback for returning strings to C# without leaking memory */
+typedef char * (SWIGSTDCALL* SWIG_CSharpStringHelperCallback)(const char *);
+static SWIG_CSharpStringHelperCallback SWIG_csharp_string_callback = NULL;
+
+
+#ifdef __cplusplus
+extern "C"
+#endif
+SWIGEXPORT void SWIGSTDCALL SWIGRegisterStringCallback_ipsec_lib(SWIG_CSharpStringHelperCallback callback) {
+ SWIG_csharp_string_callback = callback;
+}
+
+
+/* Contract support */
+
+#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentOutOfRangeException, msg, ""); return nullreturn; } else
+
+/* -----------------------------------------------------------------------------
+ * director.swg
+ *
+ * This file contains support for director classes so that C# proxy
+ * methods can be called from C++.
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+
+#if defined(DEBUG_DIRECTOR_OWNED)
+#include <iostream>
+#endif
+#include <string>
+
+namespace Swig {
+ /* Director base class - not currently used in C# directors */
+ class Director {
+ };
+
+ /* Base class for director exceptions */
+ class DirectorException {
+ protected:
+ std::string swig_msg;
+
+ public:
+ DirectorException(const char* msg) : swig_msg(msg) {
+ }
+ DirectorException(const std::string &msg) : swig_msg(msg) {
+ }
+ const std::string& what() const {
+ return swig_msg;
+ }
+ virtual ~DirectorException() {
+ }
+ };
+
+ /* Pure virtual method exception */
+ class DirectorPureVirtualException : public Swig::DirectorException {
+ public:
+ DirectorPureVirtualException(const char* msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) {
+ }
+ };
+}
+
+#endif /* __cplusplus */
+
+
+
+#include <stdint.h> // Use the C99 official header
+
+
+#include "IPSecCtx.h"
+
+
+
+/* ---------------------------------------------------
+ * C++ director class methods
+ * --------------------------------------------------- */
+
+#include "ipsecWRAP.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_new_IPSecCtx(int jarg1, unsigned int jarg2, int jarg3, int jarg4, int jarg5, int jarg6) {
+ void * jresult ;
+ tipsec_ipproto_t arg1 ;
+ bool arg2 ;
+ tipsec_mode_t arg3 ;
+ tipsec_ealg_t arg4 ;
+ tipsec_alg_t arg5 ;
+ tipsec_proto_t arg6 ;
+ IPSecCtx *result = 0 ;
+
+ arg1 = (tipsec_ipproto_t)jarg1;
+ arg2 = jarg2 ? true : false;
+ arg3 = (tipsec_mode_t)jarg3;
+ arg4 = (tipsec_ealg_t)jarg4;
+ arg5 = (tipsec_alg_t)jarg5;
+ arg6 = (tipsec_proto_t)jarg6;
+ result = (IPSecCtx *)new IPSecCtx(arg1,arg2,arg3,arg4,arg5,arg6);
+ jresult = (void *)result;
+ return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_delete_IPSecCtx(void * jarg1) {
+ IPSecCtx *arg1 = (IPSecCtx *) 0 ;
+
+ arg1 = (IPSecCtx *)jarg1;
+ delete arg1;
+}
+
+
+SWIGEXPORT int SWIGSTDCALL CSharp_IPSecCtx_start(void * jarg1) {
+ int jresult ;
+ IPSecCtx *arg1 = (IPSecCtx *) 0 ;
+ tipsec_error_t result;
+
+ arg1 = (IPSecCtx *)jarg1;
+ result = (tipsec_error_t)(arg1)->start();
+ jresult = result;
+ return jresult;
+}
+
+
+SWIGEXPORT int SWIGSTDCALL CSharp_IPSecCtx_setLocal(void * jarg1, char * jarg2, char * jarg3, unsigned short jarg4, unsigned short jarg5) {
+ int jresult ;
+ IPSecCtx *arg1 = (IPSecCtx *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ tipsec_port_t arg4 ;
+ tipsec_port_t arg5 ;
+ tipsec_error_t result;
+
+ arg1 = (IPSecCtx *)jarg1;
+ arg2 = (char *)jarg2;
+ arg3 = (char *)jarg3;
+ arg4 = (tipsec_port_t)jarg4;
+ arg5 = (tipsec_port_t)jarg5;
+ result = (tipsec_error_t)(arg1)->setLocal((char const *)arg2,(char const *)arg3,arg4,arg5);
+ jresult = result;
+ return jresult;
+}
+
+
+SWIGEXPORT int SWIGSTDCALL CSharp_IPSecCtx_setKeys(void * jarg1, void * jarg2, void * jarg3) {
+ int jresult ;
+ IPSecCtx *arg1 = (IPSecCtx *) 0 ;
+ tipsec_key_t *arg2 = (tipsec_key_t *) 0 ;
+ tipsec_key_t *arg3 = (tipsec_key_t *) 0 ;
+ tipsec_error_t result;
+
+ arg1 = (IPSecCtx *)jarg1;
+ arg2 = jarg2;
+ arg3 = jarg3;
+ result = (tipsec_error_t)(arg1)->setKeys((tipsec_key_t const *)arg2,(tipsec_key_t const *)arg3);
+ jresult = result;
+ return jresult;
+}
+
+
+SWIGEXPORT int SWIGSTDCALL CSharp_IPSecCtx_setRemote(void * jarg1, unsigned int jarg2, unsigned int jarg3, unsigned short jarg4, unsigned short jarg5, unsigned long long jarg6) {
+ int jresult ;
+ IPSecCtx *arg1 = (IPSecCtx *) 0 ;
+ tipsec_spi_t arg2 ;
+ tipsec_spi_t arg3 ;
+ tipsec_port_t arg4 ;
+ tipsec_port_t arg5 ;
+ tipsec_lifetime_t arg6 ;
+ tipsec_error_t result;
+
+ arg1 = (IPSecCtx *)jarg1;
+ arg2 = (tipsec_spi_t)jarg2;
+ arg3 = (tipsec_spi_t)jarg3;
+ arg4 = (tipsec_port_t)jarg4;
+ arg5 = (tipsec_port_t)jarg5;
+ arg6 = (tipsec_lifetime_t)jarg6;
+ result = (tipsec_error_t)(arg1)->setRemote(arg2,arg3,arg4,arg5,arg6);
+ jresult = result;
+ return jresult;
+}
+
+
+SWIGEXPORT int SWIGSTDCALL CSharp_IPSecCtx_stop(void * jarg1) {
+ int jresult ;
+ IPSecCtx *arg1 = (IPSecCtx *) 0 ;
+ tipsec_error_t result;
+
+ arg1 = (IPSecCtx *)jarg1;
+ result = (tipsec_error_t)(arg1)->stop();
+ jresult = result;
+ return jresult;
+}
+
+
+SWIGEXPORT unsigned int SWIGSTDCALL CSharp_IPSecCtx_getSpiUC(void * jarg1) {
+ unsigned int jresult ;
+ IPSecCtx *arg1 = (IPSecCtx *) 0 ;
+ tipsec_spi_t result;
+
+ arg1 = (IPSecCtx *)jarg1;
+ result = (tipsec_spi_t)(arg1)->getSpiUC();
+ jresult = result;
+ return jresult;
+}
+
+
+SWIGEXPORT unsigned int SWIGSTDCALL CSharp_IPSecCtx_getSpiUS(void * jarg1) {
+ unsigned int jresult ;
+ IPSecCtx *arg1 = (IPSecCtx *) 0 ;
+ tipsec_spi_t result;
+
+ arg1 = (IPSecCtx *)jarg1;
+ result = (tipsec_spi_t)(arg1)->getSpiUS();
+ jresult = result;
+ return jresult;
+}
+
+
+SWIGEXPORT unsigned int SWIGSTDCALL CSharp_IPSecCtx_getSpiPC(void * jarg1) {
+ unsigned int jresult ;
+ IPSecCtx *arg1 = (IPSecCtx *) 0 ;
+ tipsec_spi_t result;
+
+ arg1 = (IPSecCtx *)jarg1;
+ result = (tipsec_spi_t)(arg1)->getSpiPC();
+ jresult = result;
+ return jresult;
+}
+
+
+SWIGEXPORT unsigned int SWIGSTDCALL CSharp_IPSecCtx_getSpiPS(void * jarg1) {
+ unsigned int jresult ;
+ IPSecCtx *arg1 = (IPSecCtx *) 0 ;
+ tipsec_spi_t result;
+
+ arg1 = (IPSecCtx *)jarg1;
+ result = (tipsec_spi_t)(arg1)->getSpiPS();
+ jresult = result;
+ return jresult;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/Samples/C#/IPSec/ipsec_lib/ipsecWRAP.h b/Samples/C#/IPSec/ipsec_lib/ipsecWRAP.h
new file mode 100644
index 0000000..49aa0fe
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/ipsecWRAP.h
@@ -0,0 +1,15 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.9
+ *
+ * This file is not intended to be easily readable and contains a number of
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+#ifndef SWIG_ipsec_lib_WRAP_H_
+#define SWIG_ipsec_lib_WRAP_H_
+
+
+#endif
diff --git a/Samples/C#/IPSec/ipsec_lib/ipsec_lib.cs b/Samples/C#/IPSec/ipsec_lib/ipsec_lib.cs
new file mode 100644
index 0000000..702aea0
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/ipsec_lib.cs
@@ -0,0 +1,17 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.9
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace org.doubango.ipsecWRAP {
+
+using System;
+using System.Runtime.InteropServices;
+
+public class ipsec_lib {
+}
+
+}
diff --git a/Samples/C#/IPSec/ipsec_lib/ipsec_lib.vcproj b/Samples/C#/IPSec/ipsec_lib/ipsec_lib.vcproj
new file mode 100644
index 0000000..814aabf
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/ipsec_lib.vcproj
@@ -0,0 +1,241 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="ipsec_lib"
+ ProjectGUID="{F9B529B2-2AC2-4318-AD31-E7A9B195E204}"
+ RootNamespace="ipsec_lib"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\..\..\thirdparties\win32\include;..\..\..\..\tinySAK\src;..\..\..\..\tinyIPSec\src"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;IPSEC_LIB_EXPORTS;TINYIPSEC_IMPORTS_IGNORE;PLUGIN_WIN_IPSEC_VISTA_IMPORTS_IGNORE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Ws2_32.lib $(OutDir)\tinySAK.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="..\..\..\..\thirdparties\win32\include;..\..\..\..\tinySAK\src;..\..\..\..\tinyIPSec\src"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IPSEC_LIB_EXPORTS;TINYIPSEC_IMPORTS_IGNORE;PLUGIN_WIN_IPSEC_VISTA_IMPORTS_IGNORE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Ws2_32.lib $(OutDir)\tinySAK.lib"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\IPSecCtx.cxx"
+ >
+ </File>
+ <File
+ RelativePath=".\ipsecWRAP.cxx"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\plugins\pluginWinIPSecVista\plugin_win_ipsec_vista.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\tinyIPSec\src\tipsec.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\IPSecCtx.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ipsecWRAP.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\plugins\pluginWinIPSecVista\plugin_win_ipsec_vista_config.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\tinyIPSec\src\tinyipsec_config.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\tinyIPSec\src\tipsec.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <Filter
+ Name="swig"
+ >
+ <File
+ RelativePath=".\swig.i"
+ >
+ </File>
+ <File
+ RelativePath=".\swig.sh"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Samples/C#/IPSec/ipsec_lib/ipsec_libPINVOKE.cs b/Samples/C#/IPSec/ipsec_lib/ipsec_libPINVOKE.cs
new file mode 100644
index 0000000..075d822
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/ipsec_libPINVOKE.cs
@@ -0,0 +1,226 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.9
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace org.doubango.ipsecWRAP {
+
+using System;
+using System.Runtime.InteropServices;
+
+class ipsec_libPINVOKE {
+
+ protected class SWIGExceptionHelper {
+
+ public delegate void ExceptionDelegate(string message);
+ public delegate void ExceptionArgumentDelegate(string message, string paramName);
+
+ static ExceptionDelegate applicationDelegate = new ExceptionDelegate(SetPendingApplicationException);
+ static ExceptionDelegate arithmeticDelegate = new ExceptionDelegate(SetPendingArithmeticException);
+ static ExceptionDelegate divideByZeroDelegate = new ExceptionDelegate(SetPendingDivideByZeroException);
+ static ExceptionDelegate indexOutOfRangeDelegate = new ExceptionDelegate(SetPendingIndexOutOfRangeException);
+ static ExceptionDelegate invalidCastDelegate = new ExceptionDelegate(SetPendingInvalidCastException);
+ static ExceptionDelegate invalidOperationDelegate = new ExceptionDelegate(SetPendingInvalidOperationException);
+ static ExceptionDelegate ioDelegate = new ExceptionDelegate(SetPendingIOException);
+ static ExceptionDelegate nullReferenceDelegate = new ExceptionDelegate(SetPendingNullReferenceException);
+ static ExceptionDelegate outOfMemoryDelegate = new ExceptionDelegate(SetPendingOutOfMemoryException);
+ static ExceptionDelegate overflowDelegate = new ExceptionDelegate(SetPendingOverflowException);
+ static ExceptionDelegate systemDelegate = new ExceptionDelegate(SetPendingSystemException);
+
+ static ExceptionArgumentDelegate argumentDelegate = new ExceptionArgumentDelegate(SetPendingArgumentException);
+ static ExceptionArgumentDelegate argumentNullDelegate = new ExceptionArgumentDelegate(SetPendingArgumentNullException);
+ static ExceptionArgumentDelegate argumentOutOfRangeDelegate = new ExceptionArgumentDelegate(SetPendingArgumentOutOfRangeException);
+
+ [DllImport("ipsec_lib", EntryPoint="SWIGRegisterExceptionCallbacks_ipsec_lib")]
+ public static extern void SWIGRegisterExceptionCallbacks_ipsec_lib(
+ ExceptionDelegate applicationDelegate,
+ ExceptionDelegate arithmeticDelegate,
+ ExceptionDelegate divideByZeroDelegate,
+ ExceptionDelegate indexOutOfRangeDelegate,
+ ExceptionDelegate invalidCastDelegate,
+ ExceptionDelegate invalidOperationDelegate,
+ ExceptionDelegate ioDelegate,
+ ExceptionDelegate nullReferenceDelegate,
+ ExceptionDelegate outOfMemoryDelegate,
+ ExceptionDelegate overflowDelegate,
+ ExceptionDelegate systemExceptionDelegate);
+
+ [DllImport("ipsec_lib", EntryPoint="SWIGRegisterExceptionArgumentCallbacks_ipsec_lib")]
+ public static extern void SWIGRegisterExceptionCallbacksArgument_ipsec_lib(
+ ExceptionArgumentDelegate argumentDelegate,
+ ExceptionArgumentDelegate argumentNullDelegate,
+ ExceptionArgumentDelegate argumentOutOfRangeDelegate);
+
+ static void SetPendingApplicationException(string message) {
+ SWIGPendingException.Set(new System.ApplicationException(message, SWIGPendingException.Retrieve()));
+ }
+ static void SetPendingArithmeticException(string message) {
+ SWIGPendingException.Set(new System.ArithmeticException(message, SWIGPendingException.Retrieve()));
+ }
+ static void SetPendingDivideByZeroException(string message) {
+ SWIGPendingException.Set(new System.DivideByZeroException(message, SWIGPendingException.Retrieve()));
+ }
+ static void SetPendingIndexOutOfRangeException(string message) {
+ SWIGPendingException.Set(new System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve()));
+ }
+ static void SetPendingInvalidCastException(string message) {
+ SWIGPendingException.Set(new System.InvalidCastException(message, SWIGPendingException.Retrieve()));
+ }
+ static void SetPendingInvalidOperationException(string message) {
+ SWIGPendingException.Set(new System.InvalidOperationException(message, SWIGPendingException.Retrieve()));
+ }
+ static void SetPendingIOException(string message) {
+ SWIGPendingException.Set(new System.IO.IOException(message, SWIGPendingException.Retrieve()));
+ }
+ static void SetPendingNullReferenceException(string message) {
+ SWIGPendingException.Set(new System.NullReferenceException(message, SWIGPendingException.Retrieve()));
+ }
+ static void SetPendingOutOfMemoryException(string message) {
+ SWIGPendingException.Set(new System.OutOfMemoryException(message, SWIGPendingException.Retrieve()));
+ }
+ static void SetPendingOverflowException(string message) {
+ SWIGPendingException.Set(new System.OverflowException(message, SWIGPendingException.Retrieve()));
+ }
+ static void SetPendingSystemException(string message) {
+ SWIGPendingException.Set(new System.SystemException(message, SWIGPendingException.Retrieve()));
+ }
+
+ static void SetPendingArgumentException(string message, string paramName) {
+ SWIGPendingException.Set(new System.ArgumentException(message, paramName, SWIGPendingException.Retrieve()));
+ }
+ static void SetPendingArgumentNullException(string message, string paramName) {
+ Exception e = SWIGPendingException.Retrieve();
+ if (e != null) message = message + " Inner Exception: " + e.Message;
+ SWIGPendingException.Set(new System.ArgumentNullException(paramName, message));
+ }
+ static void SetPendingArgumentOutOfRangeException(string message, string paramName) {
+ Exception e = SWIGPendingException.Retrieve();
+ if (e != null) message = message + " Inner Exception: " + e.Message;
+ SWIGPendingException.Set(new System.ArgumentOutOfRangeException(paramName, message));
+ }
+
+ static SWIGExceptionHelper() {
+ SWIGRegisterExceptionCallbacks_ipsec_lib(
+ applicationDelegate,
+ arithmeticDelegate,
+ divideByZeroDelegate,
+ indexOutOfRangeDelegate,
+ invalidCastDelegate,
+ invalidOperationDelegate,
+ ioDelegate,
+ nullReferenceDelegate,
+ outOfMemoryDelegate,
+ overflowDelegate,
+ systemDelegate);
+
+ SWIGRegisterExceptionCallbacksArgument_ipsec_lib(
+ argumentDelegate,
+ argumentNullDelegate,
+ argumentOutOfRangeDelegate);
+ }
+ }
+
+ protected static SWIGExceptionHelper swigExceptionHelper = new SWIGExceptionHelper();
+
+ public class SWIGPendingException {
+ [ThreadStatic]
+ private static Exception pendingException = null;
+ private static int numExceptionsPending = 0;
+
+ public static bool Pending {
+ get {
+ bool pending = false;
+ if (numExceptionsPending > 0)
+ if (pendingException != null)
+ pending = true;
+ return pending;
+ }
+ }
+
+ public static void Set(Exception e) {
+ if (pendingException != null)
+ throw new ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e);
+ pendingException = e;
+ lock(typeof(ipsec_libPINVOKE)) {
+ numExceptionsPending++;
+ }
+ }
+
+ public static Exception Retrieve() {
+ Exception e = null;
+ if (numExceptionsPending > 0) {
+ if (pendingException != null) {
+ e = pendingException;
+ pendingException = null;
+ lock(typeof(ipsec_libPINVOKE)) {
+ numExceptionsPending--;
+ }
+ }
+ }
+ return e;
+ }
+ }
+
+
+ protected class SWIGStringHelper {
+
+ public delegate string SWIGStringDelegate(string message);
+ static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString);
+
+ [DllImport("ipsec_lib", EntryPoint="SWIGRegisterStringCallback_ipsec_lib")]
+ public static extern void SWIGRegisterStringCallback_ipsec_lib(SWIGStringDelegate stringDelegate);
+
+ static string CreateString(string cString) {
+ return cString;
+ }
+
+ static SWIGStringHelper() {
+ SWIGRegisterStringCallback_ipsec_lib(stringDelegate);
+ }
+ }
+
+ static protected SWIGStringHelper swigStringHelper = new SWIGStringHelper();
+
+
+ static ipsec_libPINVOKE() {
+ }
+
+
+ [DllImport("ipsec_lib", EntryPoint="CSharp_new_IPSecCtx")]
+ public static extern IntPtr new_IPSecCtx(int jarg1, bool jarg2, int jarg3, int jarg4, int jarg5, int jarg6);
+
+ [DllImport("ipsec_lib", EntryPoint="CSharp_delete_IPSecCtx")]
+ public static extern void delete_IPSecCtx(HandleRef jarg1);
+
+ [DllImport("ipsec_lib", EntryPoint="CSharp_IPSecCtx_start")]
+ public static extern int IPSecCtx_start(HandleRef jarg1);
+
+ [DllImport("ipsec_lib", EntryPoint="CSharp_IPSecCtx_setLocal")]
+ public static extern int IPSecCtx_setLocal(HandleRef jarg1, string jarg2, string jarg3, ushort jarg4, ushort jarg5);
+
+ [DllImport("ipsec_lib", EntryPoint="CSharp_IPSecCtx_setKeys")]
+ public static extern int IPSecCtx_setKeys(HandleRef jarg1, IntPtr jarg2, IntPtr jarg3);
+
+ [DllImport("ipsec_lib", EntryPoint="CSharp_IPSecCtx_setRemote")]
+ public static extern int IPSecCtx_setRemote(HandleRef jarg1, uint jarg2, uint jarg3, ushort jarg4, ushort jarg5, ulong jarg6);
+
+ [DllImport("ipsec_lib", EntryPoint="CSharp_IPSecCtx_stop")]
+ public static extern int IPSecCtx_stop(HandleRef jarg1);
+
+ [DllImport("ipsec_lib", EntryPoint="CSharp_IPSecCtx_getSpiUC")]
+ public static extern uint IPSecCtx_getSpiUC(HandleRef jarg1);
+
+ [DllImport("ipsec_lib", EntryPoint="CSharp_IPSecCtx_getSpiUS")]
+ public static extern uint IPSecCtx_getSpiUS(HandleRef jarg1);
+
+ [DllImport("ipsec_lib", EntryPoint="CSharp_IPSecCtx_getSpiPC")]
+ public static extern uint IPSecCtx_getSpiPC(HandleRef jarg1);
+
+ [DllImport("ipsec_lib", EntryPoint="CSharp_IPSecCtx_getSpiPS")]
+ public static extern uint IPSecCtx_getSpiPS(HandleRef jarg1);
+}
+
+}
diff --git a/Samples/C#/IPSec/ipsec_lib/swig.i b/Samples/C#/IPSec/ipsec_lib/swig.i
new file mode 100644
index 0000000..e9bd224
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/swig.i
@@ -0,0 +1,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;
diff --git a/Samples/C#/IPSec/ipsec_lib/swig.sh b/Samples/C#/IPSec/ipsec_lib/swig.sh
new file mode 100644
index 0000000..1cf6fa5
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/swig.sh
@@ -0,0 +1 @@
+swig -c++ -csharp -namespace org.doubango.ipsecWRAP -outdir . -o ./ipsecWRAP.cxx ./swig.i \ No newline at end of file
diff --git a/Samples/C#/IPSec/ipsec_lib/tipsec_alg_t.cs b/Samples/C#/IPSec/ipsec_lib/tipsec_alg_t.cs
new file mode 100644
index 0000000..4baf76b
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/tipsec_alg_t.cs
@@ -0,0 +1,16 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.9
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace org.doubango.ipsecWRAP {
+
+public enum tipsec_alg_t {
+ tipsec_alg_hmac_md5_96,
+ tipsec_alg_hmac_sha_1_96
+}
+
+}
diff --git a/Samples/C#/IPSec/ipsec_lib/tipsec_ealg_t.cs b/Samples/C#/IPSec/ipsec_lib/tipsec_ealg_t.cs
new file mode 100644
index 0000000..7dcb7cf
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/tipsec_ealg_t.cs
@@ -0,0 +1,17 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.9
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace org.doubango.ipsecWRAP {
+
+public enum tipsec_ealg_t {
+ tipsec_ealg_des_ede3_cbc,
+ tipsec_ealg_aes,
+ tipsec_ealg_null
+}
+
+}
diff --git a/Samples/C#/IPSec/ipsec_lib/tipsec_error_t.cs b/Samples/C#/IPSec/ipsec_lib/tipsec_error_t.cs
new file mode 100644
index 0000000..b5f5a5e
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/tipsec_error_t.cs
@@ -0,0 +1,24 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.9
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace org.doubango.ipsecWRAP {
+
+public enum tipsec_error_t {
+ tipsec_error_success = 0,
+ tipsec_error_invalid_param,
+ tipsec_error_invalid_state,
+ tipsec_error_access_violation,
+ tipsec_error_permission_denied,
+ tipsec_error_outofmemory,
+ tipsec_error_outofbound,
+ tipsec_error_notfound,
+ tipsec_error_notimplemented,
+ tipsec_error_sys
+}
+
+}
diff --git a/Samples/C#/IPSec/ipsec_lib/tipsec_ipproto_t.cs b/Samples/C#/IPSec/ipsec_lib/tipsec_ipproto_t.cs
new file mode 100644
index 0000000..7f3ea19
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/tipsec_ipproto_t.cs
@@ -0,0 +1,18 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.9
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace org.doubango.ipsecWRAP {
+
+public enum tipsec_ipproto_t {
+ tipsec_ipproto_udp,
+ tipsec_ipproto_tcp,
+ tipsec_ipproto_icmp,
+ tipsec_ipproto_all
+}
+
+}
diff --git a/Samples/C#/IPSec/ipsec_lib/tipsec_mode_t.cs b/Samples/C#/IPSec/ipsec_lib/tipsec_mode_t.cs
new file mode 100644
index 0000000..86af5ff
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/tipsec_mode_t.cs
@@ -0,0 +1,16 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.9
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace org.doubango.ipsecWRAP {
+
+public enum tipsec_mode_t {
+ tipsec_mode_trans,
+ tipsec_mode_tun
+}
+
+}
diff --git a/Samples/C#/IPSec/ipsec_lib/tipsec_proto_t.cs b/Samples/C#/IPSec/ipsec_lib/tipsec_proto_t.cs
new file mode 100644
index 0000000..05ce628
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/tipsec_proto_t.cs
@@ -0,0 +1,17 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.9
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace org.doubango.ipsecWRAP {
+
+public enum tipsec_proto_t {
+ tipsec_proto_ah = (0x01 << 0),
+ tipsec_proto_esp = (0x01 << 1),
+ tipsec_proto_both = (tipsec_proto_ah|tipsec_proto_esp)
+}
+
+}
diff --git a/Samples/C#/IPSec/ipsec_lib/tipsec_state_t.cs b/Samples/C#/IPSec/ipsec_lib/tipsec_state_t.cs
new file mode 100644
index 0000000..fcdf598
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_lib/tipsec_state_t.cs
@@ -0,0 +1,18 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.9
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace org.doubango.ipsecWRAP {
+
+public enum tipsec_state_t {
+ tipsec_state_initial,
+ tipsec_state_inbound,
+ tipsec_state_full,
+ tipsec_state_active
+}
+
+}
OpenPOWER on IntegriCloud