summaryrefslogtreecommitdiffstats
path: root/Samples
diff options
context:
space:
mode:
authorMamadou DIOP <bossiel@yahoo.fr>2015-08-17 01:56:35 +0200
committerMamadou DIOP <bossiel@yahoo.fr>2015-08-17 01:56:35 +0200
commit631fffee8a28b1bec5ed1f1d26a20e0135967f99 (patch)
tree74afe3bf3efe15aa82bcd0272b2b0f4d48c2d837 /Samples
parent7908865936604036e6f200f1b5e069f8752f3a3a (diff)
downloaddoubango-631fffee8a28b1bec5ed1f1d26a20e0135967f99.zip
doubango-631fffee8a28b1bec5ed1f1d26a20e0135967f99.tar.gz
-
Diffstat (limited to 'Samples')
-rw-r--r--Samples/C#/IPSec/ipsec.sln106
-rw-r--r--Samples/C#/IPSec/ipsec_app/Program.cs84
-rw-r--r--Samples/C#/IPSec/ipsec_app/Properties/AssemblyInfo.cs36
-rw-r--r--Samples/C#/IPSec/ipsec_app/ipsec_app.csproj136
-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
-rw-r--r--Samples/C++/REGISTER/test/ReadMe.txt33
-rw-r--r--Samples/C++/REGISTER/test/stdafx.cpp8
-rw-r--r--Samples/C++/REGISTER/test/stdafx.h15
-rw-r--r--Samples/C++/REGISTER/test/targetver.h13
-rw-r--r--Samples/C++/REGISTER/test/test.cpp86
-rw-r--r--Samples/C++/REGISTER/test/test.sln20
-rw-r--r--Samples/C++/REGISTER/test/test.vcproj211
28 files changed, 2260 insertions, 0 deletions
diff --git a/Samples/C#/IPSec/ipsec.sln b/Samples/C#/IPSec/ipsec.sln
new file mode 100644
index 0000000..cc63e0c
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec.sln
@@ -0,0 +1,106 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ipsec_app", "ipsec_app\ipsec_app.csproj", "{9765AEFD-D72A-4FB5-B840-D1021B41DD41}"
+ ProjectSection(ProjectDependencies) = postProject
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204} = {F9B529B2-2AC2-4318-AD31-E7A9B195E204}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ipsec_lib", "ipsec_lib\ipsec_lib.vcproj", "{F9B529B2-2AC2-4318-AD31-E7A9B195E204}"
+ ProjectSection(ProjectDependencies) = postProject
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySAK", "..\..\..\tinySAK\tinySAK.vcproj", "{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "csharp", "csharp", "{0325B42D-C2ED-4313-ABB0-B317A2ADBAB9}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cpp", "cpp", "{AB8B1D7B-3776-463A-92F0-6D7236B75B99}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|Mixed Platforms = Debug|Mixed Platforms
+ Debug|Win32 = Debug|Win32
+ Release|Any CPU = Release|Any CPU
+ Release|Mixed Platforms = Release|Mixed Platforms
+ Release|Win32 = Release|Win32
+ Static_Debug|Any CPU = Static_Debug|Any CPU
+ Static_Debug|Mixed Platforms = Static_Debug|Mixed Platforms
+ Static_Debug|Win32 = Static_Debug|Win32
+ Static_Release|Any CPU = Static_Release|Any CPU
+ Static_Release|Mixed Platforms = Static_Release|Mixed Platforms
+ Static_Release|Win32 = Static_Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Release|Win32.ActiveCfg = Release|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Static_Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Static_Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Static_Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Static_Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Static_Debug|Win32.ActiveCfg = Debug|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Static_Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Static_Release|Any CPU.Build.0 = Release|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Static_Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Static_Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41}.Static_Release|Win32.ActiveCfg = Release|Any CPU
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Debug|Win32.Build.0 = Debug|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Release|Any CPU.ActiveCfg = Release|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Release|Win32.ActiveCfg = Release|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Release|Win32.Build.0 = Release|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Static_Debug|Any CPU.ActiveCfg = Debug|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Static_Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Static_Debug|Mixed Platforms.Build.0 = Debug|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Static_Debug|Win32.ActiveCfg = Debug|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Static_Debug|Win32.Build.0 = Debug|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Static_Release|Any CPU.ActiveCfg = Release|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Static_Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Static_Release|Mixed Platforms.Build.0 = Release|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Static_Release|Win32.ActiveCfg = Release|Win32
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204}.Static_Release|Win32.Build.0 = Release|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Debug|Win32.Build.0 = Debug|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Any CPU.ActiveCfg = Release|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Win32.ActiveCfg = Release|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Release|Win32.Build.0 = Release|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Static_Debug|Any CPU.ActiveCfg = Static_Debug|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Static_Debug|Mixed Platforms.ActiveCfg = Static_Debug|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Static_Debug|Mixed Platforms.Build.0 = Static_Debug|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Static_Debug|Win32.ActiveCfg = Static_Debug|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Static_Debug|Win32.Build.0 = Static_Debug|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Static_Release|Any CPU.ActiveCfg = Static_Release|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Static_Release|Mixed Platforms.ActiveCfg = Static_Release|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Static_Release|Mixed Platforms.Build.0 = Static_Release|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Static_Release|Win32.ActiveCfg = Static_Release|Win32
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}.Static_Release|Win32.Build.0 = Static_Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {9765AEFD-D72A-4FB5-B840-D1021B41DD41} = {0325B42D-C2ED-4313-ABB0-B317A2ADBAB9}
+ {F9B529B2-2AC2-4318-AD31-E7A9B195E204} = {AB8B1D7B-3776-463A-92F0-6D7236B75B99}
+ {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {AB8B1D7B-3776-463A-92F0-6D7236B75B99}
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/C#/IPSec/ipsec_app/Program.cs b/Samples/C#/IPSec/ipsec_app/Program.cs
new file mode 100644
index 0000000..0fa9430
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_app/Program.cs
@@ -0,0 +1,84 @@
+/* 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.
+*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using org.doubango.ipsecWRAP;
+using System.Diagnostics;
+using err = org.doubango.ipsecWRAP.tipsec_error_t;
+using System.Runtime.InteropServices;
+namespace ipsec
+{
+ class Program
+ {
+ static tipsec_ipproto_t __ipproto = tipsec_ipproto_t.tipsec_ipproto_udp;
+ static bool __use_ipv6 = false;
+ static tipsec_mode_t __mode = tipsec_mode_t.tipsec_mode_trans;
+ static tipsec_ealg_t __ealg = tipsec_ealg_t.tipsec_ealg_des_ede3_cbc;
+ static tipsec_alg_t __alg = tipsec_alg_t.tipsec_alg_hmac_md5_96;
+ static tipsec_proto_t __proto = tipsec_proto_t.tipsec_proto_esp;
+
+ static String __addr_local = "0.0.0.0";
+ static String __addr_remote = "192.168.0.34";
+ static ushort __port_local_out = 5062; // PORT_UC
+ static ushort __port_local_in = 5064; // PORT_US
+ static ushort __port_remote_out = 5066; // PORT_PC
+ static ushort __port_remote_in = 5068; // PORT_PS
+ static UInt32 __spi_remote_out = 3333; // SPI_PC
+ static UInt32 __spi_remote_in = 4444; // SPI_PS
+ static UInt64 __lifetime = 1800; /* always set it to the maximum value. (Not possible to update the value after REGISTER 200OK. ) */
+
+ static String __key_ik = "1234567890123456";
+ static String __key_ck = "1234567890121234";
+
+ static void Main(string[] args)
+ {
+ /* Create the context */
+ IPSecCtx ipsecCtx = new IPSecCtx(__ipproto, __use_ipv6, __mode, __ealg, __alg, __proto);
+
+ /* Set local */
+ Debug.Assert(ipsecCtx.setLocal(__addr_local, __addr_remote, __port_local_out, __port_local_in) == err.tipsec_error_success);
+
+ /* Dump SPIs created by the OS after calling set_local() */
+ Console.WriteLine("SPI-UC={0}, SPI-US={1}", ipsecCtx.getSpiUC(), ipsecCtx.getSpiUS());
+
+ /* Set remote */
+ Debug.Assert(ipsecCtx.setRemote(__spi_remote_out, __spi_remote_in, __port_remote_out, __port_remote_in, __lifetime) == err.tipsec_error_success);
+
+ /* Set Integrity (IK) and Confidentiality (CK) keys */
+ IntPtr keyIK = Marshal.StringToHGlobalAnsi(__key_ik);
+ IntPtr keyCK = Marshal.StringToHGlobalAnsi(__key_ck);
+ Debug.Assert(ipsecCtx.setKeys(keyIK, keyCK) == err.tipsec_error_success);
+ Marshal.FreeHGlobal(keyIK);
+ Marshal.FreeHGlobal(keyCK);
+
+ /* Start (Setup) the SAs */
+ Debug.Assert(ipsecCtx.start() == err.tipsec_error_success);
+
+ Console.WriteLine("!!! IPSec SAs started (Press any key to stop) !!!");
+
+ Console.ReadLine();
+
+ ipsecCtx.Dispose(); // Not required. GC will collect it when refCount reach zero.
+
+ Console.ReadLine();
+ }
+ }
+}
diff --git a/Samples/C#/IPSec/ipsec_app/Properties/AssemblyInfo.cs b/Samples/C#/IPSec/ipsec_app/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..859c539
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_app/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ipsec")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ipsec")]
+[assembly: AssemblyCopyright("Copyright © 2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("28faf159-2a2b-47ff-9a32-a7acf9c6ec66")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Samples/C#/IPSec/ipsec_app/ipsec_app.csproj b/Samples/C#/IPSec/ipsec_app/ipsec_app.csproj
new file mode 100644
index 0000000..7f33b7f
--- /dev/null
+++ b/Samples/C#/IPSec/ipsec_app/ipsec_app.csproj
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{9765AEFD-D72A-4FB5-B840-D1021B41DD41}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ipsec_app</RootNamespace>
+ <AssemblyName>ipsec_app</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>..\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>..\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="..\ipsec_lib\IPSecCtx.cs">
+ <Link>IPSecCtx.cs</Link>
+ </Compile>
+ <Compile Include="..\ipsec_lib\ipsec_lib.cs">
+ <Link>ipsec_lib.cs</Link>
+ </Compile>
+ <Compile Include="..\ipsec_lib\ipsec_libPINVOKE.cs">
+ <Link>ipsec_libPINVOKE.cs</Link>
+ </Compile>
+ <Compile Include="..\ipsec_lib\tipsec_alg_t.cs">
+ <Link>tipsec_alg_t.cs</Link>
+ </Compile>
+ <Compile Include="..\ipsec_lib\tipsec_ealg_t.cs">
+ <Link>tipsec_ealg_t.cs</Link>
+ </Compile>
+ <Compile Include="..\ipsec_lib\tipsec_error_t.cs">
+ <Link>tipsec_error_t.cs</Link>
+ </Compile>
+ <Compile Include="..\ipsec_lib\tipsec_ipproto_t.cs">
+ <Link>tipsec_ipproto_t.cs</Link>
+ </Compile>
+ <Compile Include="..\ipsec_lib\tipsec_mode_t.cs">
+ <Link>tipsec_mode_t.cs</Link>
+ </Compile>
+ <Compile Include="..\ipsec_lib\tipsec_proto_t.cs">
+ <Link>tipsec_proto_t.cs</Link>
+ </Compile>
+ <Compile Include="..\ipsec_lib\tipsec_state_t.cs">
+ <Link>tipsec_state_t.cs</Link>
+ </Compile>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework Client Profile</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+ <Visible>False</Visible>
+ <ProductName>Windows Installer 3.1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
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
+}
+
+}
diff --git a/Samples/C++/REGISTER/test/ReadMe.txt b/Samples/C++/REGISTER/test/ReadMe.txt
new file mode 100644
index 0000000..ce20636
--- /dev/null
+++ b/Samples/C++/REGISTER/test/ReadMe.txt
@@ -0,0 +1,33 @@
+========================================================================
+ CONSOLE APPLICATION : test Project Overview
+========================================================================
+
+AppWizard has created this test application for you.
+
+This file contains a summary of what you will find in each of the files that
+make up your test application.
+
+
+test.vcproj
+ This is the main project file for VC++ projects generated using an Application Wizard.
+ It contains information about the version of Visual C++ that generated the file, and
+ information about the platforms, configurations, and project features selected with the
+ Application Wizard.
+
+test.cpp
+ This is the main application source file.
+
+/////////////////////////////////////////////////////////////////////////////
+Other standard files:
+
+StdAfx.h, StdAfx.cpp
+ These files are used to build a precompiled header (PCH) file
+ named test.pch and a precompiled types file named StdAfx.obj.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+AppWizard uses "TODO:" comments to indicate parts of the source code you
+should add to or customize.
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/Samples/C++/REGISTER/test/stdafx.cpp b/Samples/C++/REGISTER/test/stdafx.cpp
new file mode 100644
index 0000000..ab6cf71
--- /dev/null
+++ b/Samples/C++/REGISTER/test/stdafx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// test.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/Samples/C++/REGISTER/test/stdafx.h b/Samples/C++/REGISTER/test/stdafx.h
new file mode 100644
index 0000000..b005a83
--- /dev/null
+++ b/Samples/C++/REGISTER/test/stdafx.h
@@ -0,0 +1,15 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#include <stdio.h>
+#include <tchar.h>
+
+
+
+// TODO: reference additional headers your program requires here
diff --git a/Samples/C++/REGISTER/test/targetver.h b/Samples/C++/REGISTER/test/targetver.h
new file mode 100644
index 0000000..6fe8eb7
--- /dev/null
+++ b/Samples/C++/REGISTER/test/targetver.h
@@ -0,0 +1,13 @@
+#pragma once
+
+// The following macros define the minimum required platform. The minimum required platform
+// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
+// your application. The macros work by enabling all features available on platform versions up to and
+// including the version specified.
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
+#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
diff --git a/Samples/C++/REGISTER/test/test.cpp b/Samples/C++/REGISTER/test/test.cpp
new file mode 100644
index 0000000..2668366
--- /dev/null
+++ b/Samples/C++/REGISTER/test/test.cpp
@@ -0,0 +1,86 @@
+// test.cpp : Defines the entry point for the console application.
+//
+
+#include "stdafx.h"
+#include <assert.h>
+#include <api_engine.h>
+#include <api_stack.h>
+
+#define STACK_ID 1234
+
+#ifdef WIN32
+# include <windows.h>
+#endif
+
+/* Event listening using a static method */
+void OnRegistrationStateChanged(int stack_id, dgo::sip_state_registration_t state, int sipcode, const char* sipdesc)
+{
+ /* check if it's our stack */
+ if(stack_id != STACK_ID) return;
+
+ switch(state)
+ {
+ case dgo::srs_none: printf("Test_OnRegistrationStateChanged: %s(%s)\n", "srs_none", sipdesc); break;
+ case dgo::srs_trying: printf("Test_OnRegistrationStateChanged: %s(%s)\n", "srs_trying", sipdesc); break;
+ case dgo::srs_authentifying: printf("Test_OnRegistrationStateChanged: %s(%s)\n", "srs_authentifying", sipdesc); break;
+ case dgo::srs_unregistered: printf("Test_OnRegistrationStateChanged: %s(%s)\n", "srs_unregistered", sipdesc); break;
+ case dgo::srs_registered: printf("Test_OnRegistrationStateChanged: %s(%s)\n", "srs_registered", sipdesc); break;
+ }
+}
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+ /* MUST call this function to initialize the engine befor using the first stack */
+ assert( ERR_SUCCEED(dgo::engine_initialize()) );
+
+ /* create the stack */
+ dgo::stack* stack = new dgo::stack(STACK_ID);
+
+ /* Events registration */
+ stack->registrationStateChanged.connect(&OnRegistrationStateChanged);
+
+ /* check that the stack has been successfuly initialized */
+ assert(stack->get_initialized());
+
+ /* MUST: Initialize mandatory parameters */
+ stack->set_public_id("sip:bob@ims.inexbee.com");
+ stack->set_private_id("bob@ims.inexbee.com");
+
+ stack->set_pcscf("192.168.0.14");
+ stack->set_pcscf_port(4060);
+ stack->set_realm("ims.inexbee.com");
+
+ /* Not mandatory but must be set before starting */
+ stack->set_sigcomp(true);
+
+ /* run stack */
+ assert( ERR_SUCCEED(stack->run()) );
+
+ /* set other optional parameters */
+ stack->set_displayname("Doubango");
+ stack->set_privacy("none");
+ stack->set_password("bob");
+ stack->set_early_ims(false);
+ stack->set_expires(10);
+
+ /* register */
+ stack->sip_register();
+
+ /* wait */
+#ifdef WIN32
+ Sleep(500000);
+#else
+ getchar();
+#endif
+
+ /* Now it's time to unregister */
+ stack->sip_unregister();
+
+ /* wait */
+ getchar();
+
+ /* destroy the engine and unregister all identities*/
+ assert( ERR_SUCCEED(dgo::engine_deinitialize()) );
+
+ return 0;
+} \ No newline at end of file
diff --git a/Samples/C++/REGISTER/test/test.sln b/Samples/C++/REGISTER/test/test.sln
new file mode 100644
index 0000000..a4cebca
--- /dev/null
+++ b/Samples/C++/REGISTER/test/test.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj", "{EB6DC417-98BF-45FD-90D0-F5C72F945316}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {EB6DC417-98BF-45FD-90D0-F5C72F945316}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EB6DC417-98BF-45FD-90D0-F5C72F945316}.Debug|Win32.Build.0 = Debug|Win32
+ {EB6DC417-98BF-45FD-90D0-F5C72F945316}.Release|Win32.ActiveCfg = Release|Win32
+ {EB6DC417-98BF-45FD-90D0-F5C72F945316}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/C++/REGISTER/test/test.vcproj b/Samples/C++/REGISTER/test/test.vcproj
new file mode 100644
index 0000000..b251c82
--- /dev/null
+++ b/Samples/C++/REGISTER/test/test.vcproj
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="test"
+ ProjectGUID="{EB6DC417-98BF-45FD-90D0-F5C72F945316}"
+ RootNamespace="test"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;$(DOUBANGO_HOME)\doubango\src&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\win32&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\su&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\ipt&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\sresolv&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\bnf&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\url&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\msg&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\sip&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\nta&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\nua&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\iptsec&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\http&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\nth&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\nea&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\sdp&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\soa&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\stun&quot;;&quot;$(DOUBANGO_HOME)\sofia-sip-1.12.10\libsofia-sip-ua\tport&quot;"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ 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="$(OutDir)\doubango.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ 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="1"
+ 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"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ 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=".\stdafx.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\test.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\stdafx.h"
+ >
+ </File>
+ <File
+ RelativePath=".\targetver.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>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
OpenPOWER on IntegriCloud