Adds support for 3GPP IMS-IPSec

This commit is contained in:
bossiel 2013-12-26 17:43:05 +00:00
parent e6aab8bce3
commit 921117452f
105 changed files with 5978 additions and 3436 deletions

View File

@ -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

View File

@ -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_ah;
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 no refCount reach zero.
Console.ReadLine();
}
}
}

View File

@ -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")]

View File

@ -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>

View File

@ -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;
}
}
}

View File

@ -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;
}

View File

@ -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 */

View File

@ -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 ;
void *arg2 = (void *) 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((void 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

View File

@ -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

View File

@ -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 {
}
}

View File

@ -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>

View File

@ -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);
}
}

View File

@ -0,0 +1,133 @@
%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 << 0),
//! 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
}
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;

View File

@ -0,0 +1 @@
swig -c++ -csharp -namespace org.doubango.ipsecWRAP -outdir . -o ./ipsecWRAP.cxx ./swig.i

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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_ipproto_t {
tipsec_ipproto_udp,
tipsec_ipproto_tcp,
tipsec_ipproto_icmp
}
}

View File

@ -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
}
}

View File

@ -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 << 0),
tipsec_proto_both = (tipsec_proto_ah|tipsec_proto_esp)
}
}

View File

@ -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
}
}

View File

@ -463,6 +463,11 @@ bool SipStack::isCodecSupported(tdav_codec_id_t codec_id)
return tdav_codec_is_supported(codec_id) ? true : false;
}
bool SipStack::isIPSecSupported()
{
return tdav_ipsec_is_supported() ? true : false;
}
static int stack_callback(const tsip_event_t *sipevent)
{
int ret = 0;

View File

@ -96,6 +96,7 @@ public: /* API functions */
static bool setCodecPriority(tdav_codec_id_t codec_id, int priority);
static bool setCodecPriority_2(int codec, int priority);// For stupid languages
static bool isCodecSupported(tdav_codec_id_t codec_id);
static bool isIPSecSupported();
public: /* Public helper function */
#if !defined(SWIG)

View File

@ -429,6 +429,11 @@ public class MediaSessionMgr : IDisposable {
return ret;
}
public static bool defaultsSetMaxFds(int max_fds) {
bool ret = tinyWRAPPINVOKE.MediaSessionMgr_defaultsSetMaxFds(max_fds);
return ret;
}
}
}

View File

@ -228,6 +228,11 @@ public class SipStack : SafeObject {
return ret;
}
public bool setMaxFDs(uint max_fds) {
bool ret = tinyWRAPPINVOKE.SipStack_setMaxFDs(swigCPtr, max_fds);
return ret;
}
public string getLocalIPnPort(string protocol, out ushort OUTPUT) {
string ret = tinyWRAPPINVOKE.SipStack_getLocalIPnPort(swigCPtr, protocol, out OUTPUT);
return ret;
@ -281,6 +286,11 @@ public class SipStack : SafeObject {
return ret;
}
public static bool isIPSecSupported() {
bool ret = tinyWRAPPINVOKE.SipStack_isIPSecSupported();
return ret;
}
}
}

View File

@ -522,6 +522,9 @@ class tinyWRAPPINVOKE {
[DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsSetOpusMaxPlaybackRate")]
public static extern bool MediaSessionMgr_defaultsSetOpusMaxPlaybackRate(uint jarg1);
[DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsSetMaxFds")]
public static extern bool MediaSessionMgr_defaultsSetMaxFds(int jarg1);
[DllImport("tinyWRAP", EntryPoint="CSharp_delete_MediaContent")]
public static extern void delete_MediaContent(HandleRef jarg1);
@ -1719,6 +1722,9 @@ class tinyWRAPPINVOKE {
[DllImport("tinyWRAP", EntryPoint="CSharp_SipStack_dnsSrv")]
public static extern string SipStack_dnsSrv(HandleRef jarg1, string jarg2, out ushort jarg3);
[DllImport("tinyWRAP", EntryPoint="CSharp_SipStack_setMaxFDs")]
public static extern bool SipStack_setMaxFDs(HandleRef jarg1, uint jarg2);
[DllImport("tinyWRAP", EntryPoint="CSharp_SipStack_getLocalIPnPort")]
public static extern string SipStack_getLocalIPnPort(HandleRef jarg1, string jarg2, out ushort jarg3);
@ -1752,6 +1758,9 @@ class tinyWRAPPINVOKE {
[DllImport("tinyWRAP", EntryPoint="CSharp_SipStack_isCodecSupported")]
public static extern bool SipStack_isCodecSupported(int jarg1);
[DllImport("tinyWRAP", EntryPoint="CSharp_SipStack_isIPSecSupported")]
public static extern bool SipStack_isIPSecSupported();
[DllImport("tinyWRAP", EntryPoint="CSharp_tsip_event_code_dialog_transport_error_get")]
public static extern int tsip_event_code_dialog_transport_error_get();

View File

@ -2538,6 +2538,18 @@ SWIGEXPORT unsigned int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsSetOpusMaxPla
}
SWIGEXPORT unsigned int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsSetMaxFds(int jarg1) {
unsigned int jresult ;
int32_t arg1 ;
bool result;
arg1 = (int32_t)jarg1;
result = (bool)MediaSessionMgr::defaultsSetMaxFds(arg1);
jresult = result;
return jresult;
}
SWIGEXPORT void SWIGSTDCALL CSharp_delete_MediaContent(void * jarg1) {
MediaContent *arg1 = (MediaContent *) 0 ;
@ -7729,6 +7741,20 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SipStack_dnsSrv(void * jarg1, char * jarg2,
}
SWIGEXPORT unsigned int SWIGSTDCALL CSharp_SipStack_setMaxFDs(void * jarg1, unsigned int jarg2) {
unsigned int jresult ;
SipStack *arg1 = (SipStack *) 0 ;
unsigned int arg2 ;
bool result;
arg1 = (SipStack *)jarg1;
arg2 = (unsigned int)jarg2;
result = (bool)(arg1)->setMaxFDs(arg2);
jresult = result;
return jresult;
}
SWIGEXPORT char * SWIGSTDCALL CSharp_SipStack_getLocalIPnPort(void * jarg1, char * jarg2, unsigned short * jarg3) {
char * jresult ;
SipStack *arg1 = (SipStack *) 0 ;
@ -7859,6 +7885,16 @@ SWIGEXPORT unsigned int SWIGSTDCALL CSharp_SipStack_isCodecSupported(int jarg1)
}
SWIGEXPORT unsigned int SWIGSTDCALL CSharp_SipStack_isIPSecSupported() {
unsigned int jresult ;
bool result;
result = (bool)SipStack::isIPSecSupported();
jresult = result;
return jresult;
}
SWIGEXPORT int SWIGSTDCALL CSharp_tsip_event_code_dialog_transport_error_get() {
int jresult ;
int result;

View File

@ -346,4 +346,8 @@ public class MediaSessionMgr {
return tinyWRAPJNI.MediaSessionMgr_defaultsSetOpusMaxPlaybackRate(opus_maxplaybackrate);
}
public static boolean defaultsSetMaxFds(int max_fds) {
return tinyWRAPJNI.MediaSessionMgr_defaultsSetMaxFds(max_fds);
}
}

View File

@ -187,6 +187,10 @@ public class SipStack extends SafeObject {
return tinyWRAPJNI.SipStack_dnsSrv(swigCPtr, this, service, OUTPUT);
}
public boolean setMaxFDs(long max_fds) {
return tinyWRAPJNI.SipStack_setMaxFDs(swigCPtr, this, max_fds);
}
public String getLocalIPnPort(String protocol, int[] OUTPUT) {
return tinyWRAPJNI.SipStack_getLocalIPnPort(swigCPtr, this, protocol, OUTPUT);
}
@ -231,4 +235,8 @@ public class SipStack extends SafeObject {
return tinyWRAPJNI.SipStack_isCodecSupported(codec_id.swigValue());
}
public static boolean isIPSecSupported() {
return tinyWRAPJNI.SipStack_isIPSecSupported();
}
}

View File

@ -346,4 +346,8 @@ public class MediaSessionMgr {
return tinyWRAPJNI.MediaSessionMgr_defaultsSetOpusMaxPlaybackRate(opus_maxplaybackrate);
}
public static boolean defaultsSetMaxFds(int max_fds) {
return tinyWRAPJNI.MediaSessionMgr_defaultsSetMaxFds(max_fds);
}
}

View File

@ -187,6 +187,10 @@ public class SipStack extends SafeObject {
return tinyWRAPJNI.SipStack_dnsSrv(swigCPtr, this, service, OUTPUT);
}
public boolean setMaxFDs(long max_fds) {
return tinyWRAPJNI.SipStack_setMaxFDs(swigCPtr, this, max_fds);
}
public String getLocalIPnPort(String protocol, int[] OUTPUT) {
return tinyWRAPJNI.SipStack_getLocalIPnPort(swigCPtr, this, protocol, OUTPUT);
}
@ -231,4 +235,8 @@ public class SipStack extends SafeObject {
return tinyWRAPJNI.SipStack_isCodecSupported(codec_id.swigValue());
}
public static boolean isIPSecSupported() {
return tinyWRAPJNI.SipStack_isIPSecSupported();
}
}

View File

@ -121,6 +121,7 @@ public class tinyWRAPJNI {
public final static native boolean MediaSessionMgr_defaultsSetAvpfTail(long jarg1, long jarg2);
public final static native boolean MediaSessionMgr_defaultsSetOpusMaxCaptureRate(long jarg1);
public final static native boolean MediaSessionMgr_defaultsSetOpusMaxPlaybackRate(long jarg1);
public final static native boolean MediaSessionMgr_defaultsSetMaxFds(int jarg1);
public final static native void delete_MediaContent(long jarg1);
public final static native String MediaContent_getType(long jarg1, MediaContent jarg1_);
public final static native long MediaContent_getDataLength(long jarg1, MediaContent jarg1_);
@ -527,6 +528,7 @@ public class tinyWRAPJNI {
public final static native String SipStack_dnsENUM(long jarg1, SipStack jarg1_, String jarg2, String jarg3, String jarg4);
public final static native String SipStack_dnsNaptrSrv(long jarg1, SipStack jarg1_, String jarg2, String jarg3, int[] jarg4);
public final static native String SipStack_dnsSrv(long jarg1, SipStack jarg1_, String jarg2, int[] jarg3);
public final static native boolean SipStack_setMaxFDs(long jarg1, SipStack jarg1_, long jarg2);
public final static native String SipStack_getLocalIPnPort(long jarg1, SipStack jarg1_, String jarg2, int[] jarg3);
public final static native String SipStack_getPreferredIdentity(long jarg1, SipStack jarg1_);
public final static native boolean SipStack_isValid(long jarg1, SipStack jarg1_);
@ -538,6 +540,7 @@ public class tinyWRAPJNI {
public final static native boolean SipStack_setCodecPriority(int jarg1, int jarg2);
public final static native boolean SipStack_setCodecPriority_2(int jarg1, int jarg2);
public final static native boolean SipStack_isCodecSupported(int jarg1);
public final static native boolean SipStack_isIPSecSupported();
public final static native long new_XcapSelector(long jarg1, XcapStack jarg1_);
public final static native void delete_XcapSelector(long jarg1);
public final static native long XcapSelector_setAUID(long jarg1, XcapSelector jarg1_, String jarg2);

View File

@ -3732,6 +3732,20 @@ SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionM
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetMaxFds(JNIEnv *jenv, jclass jcls, jint jarg1) {
jboolean jresult = 0 ;
int32_t arg1 ;
bool result;
(void)jenv;
(void)jcls;
arg1 = (int32_t)jarg1;
result = (bool)MediaSessionMgr::defaultsSetMaxFds(arg1);
jresult = (jboolean)result;
return jresult;
}
SWIGEXPORT void JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_delete_1MediaContent(JNIEnv *jenv, jclass jcls, jlong jarg1) {
MediaContent *arg1 = (MediaContent *) 0 ;
@ -11011,6 +11025,23 @@ SWIGEXPORT jstring JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_SipStack_1dnsS
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_SipStack_1setMaxFDs(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) {
jboolean jresult = 0 ;
SipStack *arg1 = (SipStack *) 0 ;
unsigned int arg2 ;
bool result;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(SipStack **)&jarg1;
arg2 = (unsigned int)jarg2;
result = (bool)(arg1)->setMaxFDs(arg2);
jresult = (jboolean)result;
return jresult;
}
SWIGEXPORT jstring JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_SipStack_1getLocalIPnPort(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jintArray jarg3) {
jstring jresult = 0 ;
SipStack *arg1 = (SipStack *) 0 ;
@ -11189,6 +11220,18 @@ SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_SipStack_1isC
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_SipStack_1isIPSecSupported(JNIEnv *jenv, jclass jcls) {
jboolean jresult = 0 ;
bool result;
(void)jenv;
(void)jcls;
result = (bool)SipStack::isIPSecSupported();
jresult = (jboolean)result;
return jresult;
}
SWIGEXPORT jlong JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_new_1XcapSelector(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jlong jresult = 0 ;
XcapStack *arg1 = (XcapStack *) 0 ;

View File

@ -121,6 +121,7 @@ public class tinyWRAPJNI {
public final static native boolean MediaSessionMgr_defaultsSetAvpfTail(long jarg1, long jarg2);
public final static native boolean MediaSessionMgr_defaultsSetOpusMaxCaptureRate(long jarg1);
public final static native boolean MediaSessionMgr_defaultsSetOpusMaxPlaybackRate(long jarg1);
public final static native boolean MediaSessionMgr_defaultsSetMaxFds(int jarg1);
public final static native void delete_MediaContent(long jarg1);
public final static native String MediaContent_getType(long jarg1, MediaContent jarg1_);
public final static native long MediaContent_getDataLength(long jarg1, MediaContent jarg1_);
@ -527,6 +528,7 @@ public class tinyWRAPJNI {
public final static native String SipStack_dnsENUM(long jarg1, SipStack jarg1_, String jarg2, String jarg3, String jarg4);
public final static native String SipStack_dnsNaptrSrv(long jarg1, SipStack jarg1_, String jarg2, String jarg3, int[] jarg4);
public final static native String SipStack_dnsSrv(long jarg1, SipStack jarg1_, String jarg2, int[] jarg3);
public final static native boolean SipStack_setMaxFDs(long jarg1, SipStack jarg1_, long jarg2);
public final static native String SipStack_getLocalIPnPort(long jarg1, SipStack jarg1_, String jarg2, int[] jarg3);
public final static native String SipStack_getPreferredIdentity(long jarg1, SipStack jarg1_);
public final static native boolean SipStack_isValid(long jarg1, SipStack jarg1_);
@ -538,6 +540,7 @@ public class tinyWRAPJNI {
public final static native boolean SipStack_setCodecPriority(int jarg1, int jarg2);
public final static native boolean SipStack_setCodecPriority_2(int jarg1, int jarg2);
public final static native boolean SipStack_isCodecSupported(int jarg1);
public final static native boolean SipStack_isIPSecSupported();
public final static native long new_XcapSelector(long jarg1, XcapStack jarg1_);
public final static native void delete_XcapSelector(long jarg1);
public final static native long XcapSelector_setAUID(long jarg1, XcapSelector jarg1_, String jarg2);

View File

@ -3732,6 +3732,20 @@ SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionM
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetMaxFds(JNIEnv *jenv, jclass jcls, jint jarg1) {
jboolean jresult = 0 ;
int32_t arg1 ;
bool result;
(void)jenv;
(void)jcls;
arg1 = (int32_t)jarg1;
result = (bool)MediaSessionMgr::defaultsSetMaxFds(arg1);
jresult = (jboolean)result;
return jresult;
}
SWIGEXPORT void JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_delete_1MediaContent(JNIEnv *jenv, jclass jcls, jlong jarg1) {
MediaContent *arg1 = (MediaContent *) 0 ;
@ -11011,6 +11025,23 @@ SWIGEXPORT jstring JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_SipStack_1dnsS
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_SipStack_1setMaxFDs(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) {
jboolean jresult = 0 ;
SipStack *arg1 = (SipStack *) 0 ;
unsigned int arg2 ;
bool result;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(SipStack **)&jarg1;
arg2 = (unsigned int)jarg2;
result = (bool)(arg1)->setMaxFDs(arg2);
jresult = (jboolean)result;
return jresult;
}
SWIGEXPORT jstring JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_SipStack_1getLocalIPnPort(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jintArray jarg3) {
jstring jresult = 0 ;
SipStack *arg1 = (SipStack *) 0 ;
@ -11189,6 +11220,18 @@ SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_SipStack_1isC
}
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_SipStack_1isIPSecSupported(JNIEnv *jenv, jclass jcls) {
jboolean jresult = 0 ;
bool result;
(void)jenv;
(void)jcls;
result = (bool)SipStack::isIPSecSupported();
jresult = (jboolean)result;
return jresult;
}
SWIGEXPORT jlong JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_new_1XcapSelector(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jlong jresult = 0 ;
XcapStack *arg1 = (XcapStack *) 0 ;

View File

@ -306,6 +306,7 @@ sub DESTROY {
*defaultsSetAvpfTail = *tinyWRAPc::MediaSessionMgr_defaultsSetAvpfTail;
*defaultsSetOpusMaxCaptureRate = *tinyWRAPc::MediaSessionMgr_defaultsSetOpusMaxCaptureRate;
*defaultsSetOpusMaxPlaybackRate = *tinyWRAPc::MediaSessionMgr_defaultsSetOpusMaxPlaybackRate;
*defaultsSetMaxFds = *tinyWRAPc::MediaSessionMgr_defaultsSetMaxFds;
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);
@ -1976,6 +1977,7 @@ sub DESTROY {
*dnsENUM = *tinyWRAPc::SipStack_dnsENUM;
*dnsNaptrSrv = *tinyWRAPc::SipStack_dnsNaptrSrv;
*dnsSrv = *tinyWRAPc::SipStack_dnsSrv;
*setMaxFDs = *tinyWRAPc::SipStack_setMaxFDs;
*getLocalIPnPort = *tinyWRAPc::SipStack_getLocalIPnPort;
*getPreferredIdentity = *tinyWRAPc::SipStack_getPreferredIdentity;
*isValid = *tinyWRAPc::SipStack_isValid;
@ -1987,6 +1989,7 @@ sub DESTROY {
*setCodecPriority = *tinyWRAPc::SipStack_setCodecPriority;
*setCodecPriority_2 = *tinyWRAPc::SipStack_setCodecPriority_2;
*isCodecSupported = *tinyWRAPc::SipStack_isCodecSupported;
*isIPSecSupported = *tinyWRAPc::SipStack_isIPSecSupported;
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);

View File

@ -5795,6 +5795,34 @@ XS(_wrap_MediaSessionMgr_defaultsSetOpusMaxPlaybackRate) {
}
XS(_wrap_MediaSessionMgr_defaultsSetMaxFds) {
{
int32_t arg1 ;
int val1 ;
int ecode1 = 0 ;
int argvi = 0;
bool result;
dXSARGS;
if ((items < 1) || (items > 1)) {
SWIG_croak("Usage: MediaSessionMgr_defaultsSetMaxFds(max_fds);");
}
ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1);
if (!SWIG_IsOK(ecode1)) {
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetMaxFds" "', argument " "1"" of type '" "int32_t""'");
}
arg1 = static_cast< int32_t >(val1);
result = (bool)MediaSessionMgr::defaultsSetMaxFds(arg1);
ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
XS(_wrap_delete_MediaContent) {
{
MediaContent *arg1 = (MediaContent *) 0 ;
@ -23227,6 +23255,44 @@ XS(_wrap_SipStack_dnsSrv) {
}
XS(_wrap_SipStack_setMaxFDs) {
{
SipStack *arg1 = (SipStack *) 0 ;
unsigned int arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
unsigned int val2 ;
int ecode2 = 0 ;
int argvi = 0;
bool result;
dXSARGS;
if ((items < 2) || (items > 2)) {
SWIG_croak("Usage: SipStack_setMaxFDs(self,max_fds);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_SipStack, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SipStack_setMaxFDs" "', argument " "1"" of type '" "SipStack *""'");
}
arg1 = reinterpret_cast< SipStack * >(argp1);
ecode2 = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SipStack_setMaxFDs" "', argument " "2"" of type '" "unsigned int""'");
}
arg2 = static_cast< unsigned int >(val2);
result = (bool)(arg1)->setMaxFDs(arg2);
ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
XS(_wrap_SipStack_getLocalIPnPort) {
{
SipStack *arg1 = (SipStack *) 0 ;
@ -23558,6 +23624,24 @@ XS(_wrap_SipStack_isCodecSupported) {
}
XS(_wrap_SipStack_isIPSecSupported) {
{
int argvi = 0;
bool result;
dXSARGS;
if ((items < 0) || (items > 0)) {
SWIG_croak("Usage: SipStack_isIPSecSupported();");
}
result = (bool)SipStack::isIPSecSupported();
ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}
}
XS(_wrap_new_XcapSelector) {
{
XcapStack *arg1 = (XcapStack *) 0 ;
@ -27594,6 +27678,7 @@ static swig_command_info swig_commands[] = {
{"tinyWRAPc::MediaSessionMgr_defaultsSetAvpfTail", _wrap_MediaSessionMgr_defaultsSetAvpfTail},
{"tinyWRAPc::MediaSessionMgr_defaultsSetOpusMaxCaptureRate", _wrap_MediaSessionMgr_defaultsSetOpusMaxCaptureRate},
{"tinyWRAPc::MediaSessionMgr_defaultsSetOpusMaxPlaybackRate", _wrap_MediaSessionMgr_defaultsSetOpusMaxPlaybackRate},
{"tinyWRAPc::MediaSessionMgr_defaultsSetMaxFds", _wrap_MediaSessionMgr_defaultsSetMaxFds},
{"tinyWRAPc::delete_MediaContent", _wrap_delete_MediaContent},
{"tinyWRAPc::MediaContent_getType", _wrap_MediaContent_getType},
{"tinyWRAPc::MediaContent_getDataLength", _wrap_MediaContent_getDataLength},
@ -27894,6 +27979,7 @@ static swig_command_info swig_commands[] = {
{"tinyWRAPc::SipStack_dnsENUM", _wrap_SipStack_dnsENUM},
{"tinyWRAPc::SipStack_dnsNaptrSrv", _wrap_SipStack_dnsNaptrSrv},
{"tinyWRAPc::SipStack_dnsSrv", _wrap_SipStack_dnsSrv},
{"tinyWRAPc::SipStack_setMaxFDs", _wrap_SipStack_setMaxFDs},
{"tinyWRAPc::SipStack_getLocalIPnPort", _wrap_SipStack_getLocalIPnPort},
{"tinyWRAPc::SipStack_getPreferredIdentity", _wrap_SipStack_getPreferredIdentity},
{"tinyWRAPc::SipStack_isValid", _wrap_SipStack_isValid},
@ -27905,6 +27991,7 @@ static swig_command_info swig_commands[] = {
{"tinyWRAPc::SipStack_setCodecPriority", _wrap_SipStack_setCodecPriority},
{"tinyWRAPc::SipStack_setCodecPriority_2", _wrap_SipStack_setCodecPriority_2},
{"tinyWRAPc::SipStack_isCodecSupported", _wrap_SipStack_isCodecSupported},
{"tinyWRAPc::SipStack_isIPSecSupported", _wrap_SipStack_isIPSecSupported},
{"tinyWRAPc::new_XcapSelector", _wrap_new_XcapSelector},
{"tinyWRAPc::delete_XcapSelector", _wrap_delete_XcapSelector},
{"tinyWRAPc::XcapSelector_setAUID", _wrap_XcapSelector_setAUID},

View File

@ -319,6 +319,8 @@ class MediaSessionMgr(_object):
if _newclass:defaultsSetOpusMaxCaptureRate = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetOpusMaxCaptureRate)
__swig_getmethods__["defaultsSetOpusMaxPlaybackRate"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsSetOpusMaxPlaybackRate
if _newclass:defaultsSetOpusMaxPlaybackRate = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetOpusMaxPlaybackRate)
__swig_getmethods__["defaultsSetMaxFds"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsSetMaxFds
if _newclass:defaultsSetMaxFds = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetMaxFds)
MediaSessionMgr_swigregister = _tinyWRAP.MediaSessionMgr_swigregister
MediaSessionMgr_swigregister(MediaSessionMgr)
@ -582,6 +584,10 @@ def MediaSessionMgr_defaultsSetOpusMaxPlaybackRate(*args):
return _tinyWRAP.MediaSessionMgr_defaultsSetOpusMaxPlaybackRate(*args)
MediaSessionMgr_defaultsSetOpusMaxPlaybackRate = _tinyWRAP.MediaSessionMgr_defaultsSetOpusMaxPlaybackRate
def MediaSessionMgr_defaultsSetMaxFds(*args):
return _tinyWRAP.MediaSessionMgr_defaultsSetMaxFds(*args)
MediaSessionMgr_defaultsSetMaxFds = _tinyWRAP.MediaSessionMgr_defaultsSetMaxFds
class MediaContent(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, MediaContent, name, value)
@ -1543,6 +1549,7 @@ class SipStack(SafeObject):
def dnsENUM(self, *args): return _tinyWRAP.SipStack_dnsENUM(self, *args)
def dnsNaptrSrv(self, *args): return _tinyWRAP.SipStack_dnsNaptrSrv(self, *args)
def dnsSrv(self, *args): return _tinyWRAP.SipStack_dnsSrv(self, *args)
def setMaxFDs(self, *args): return _tinyWRAP.SipStack_setMaxFDs(self, *args)
def getLocalIPnPort(self, *args): return _tinyWRAP.SipStack_getLocalIPnPort(self, *args)
def getPreferredIdentity(self): return _tinyWRAP.SipStack_getPreferredIdentity(self)
def isValid(self): return _tinyWRAP.SipStack_isValid(self)
@ -1561,6 +1568,8 @@ class SipStack(SafeObject):
if _newclass:setCodecPriority_2 = staticmethod(_tinyWRAP.SipStack_setCodecPriority_2)
__swig_getmethods__["isCodecSupported"] = lambda x: _tinyWRAP.SipStack_isCodecSupported
if _newclass:isCodecSupported = staticmethod(_tinyWRAP.SipStack_isCodecSupported)
__swig_getmethods__["isIPSecSupported"] = lambda x: _tinyWRAP.SipStack_isIPSecSupported
if _newclass:isIPSecSupported = staticmethod(_tinyWRAP.SipStack_isIPSecSupported)
SipStack_swigregister = _tinyWRAP.SipStack_swigregister
SipStack_swigregister(SipStack)
@ -1592,6 +1601,10 @@ def SipStack_isCodecSupported(*args):
return _tinyWRAP.SipStack_isCodecSupported(*args)
SipStack_isCodecSupported = _tinyWRAP.SipStack_isCodecSupported
def SipStack_isIPSecSupported():
return _tinyWRAP.SipStack_isIPSecSupported()
SipStack_isIPSecSupported = _tinyWRAP.SipStack_isIPSecSupported
tsip_stack_mode_ua = _tinyWRAP.tsip_stack_mode_ua
tsip_stack_mode_p2p = _tinyWRAP.tsip_stack_mode_p2p
tsip_stack_mode_mediaproxy = _tinyWRAP.tsip_stack_mode_mediaproxy

View File

@ -8399,6 +8399,28 @@ fail:
}
SWIGINTERN PyObject *_wrap_MediaSessionMgr_defaultsSetMaxFds(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
int32_t arg1 ;
int val1 ;
int ecode1 = 0 ;
PyObject * obj0 = 0 ;
bool result;
if (!PyArg_ParseTuple(args,(char *)"O:MediaSessionMgr_defaultsSetMaxFds",&obj0)) SWIG_fail;
ecode1 = SWIG_AsVal_int(obj0, &val1);
if (!SWIG_IsOK(ecode1)) {
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetMaxFds" "', argument " "1"" of type '" "int32_t""'");
}
arg1 = static_cast< int32_t >(val1);
result = (bool)MediaSessionMgr::defaultsSetMaxFds(arg1);
resultobj = SWIG_From_bool(static_cast< bool >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *MediaSessionMgr_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
@ -22576,6 +22598,37 @@ fail:
}
SWIGINTERN PyObject *_wrap_SipStack_setMaxFDs(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
SipStack *arg1 = (SipStack *) 0 ;
unsigned int arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
unsigned int val2 ;
int ecode2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
bool result;
if (!PyArg_ParseTuple(args,(char *)"OO:SipStack_setMaxFDs",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_SipStack, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SipStack_setMaxFDs" "', argument " "1"" of type '" "SipStack *""'");
}
arg1 = reinterpret_cast< SipStack * >(argp1);
ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SipStack_setMaxFDs" "', argument " "2"" of type '" "unsigned int""'");
}
arg2 = static_cast< unsigned int >(val2);
result = (bool)(arg1)->setMaxFDs(arg2);
resultobj = SWIG_From_bool(static_cast< bool >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_SipStack_getLocalIPnPort(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
SipStack *arg1 = (SipStack *) 0 ;
@ -22840,6 +22893,19 @@ fail:
}
SWIGINTERN PyObject *_wrap_SipStack_isIPSecSupported(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
bool result;
if (!PyArg_ParseTuple(args,(char *)":SipStack_isIPSecSupported")) SWIG_fail;
result = (bool)SipStack::isIPSecSupported();
resultobj = SWIG_From_bool(static_cast< bool >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *SipStack_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
@ -25998,6 +26064,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"MediaSessionMgr_defaultsSetAvpfTail", _wrap_MediaSessionMgr_defaultsSetAvpfTail, METH_VARARGS, NULL},
{ (char *)"MediaSessionMgr_defaultsSetOpusMaxCaptureRate", _wrap_MediaSessionMgr_defaultsSetOpusMaxCaptureRate, METH_VARARGS, NULL},
{ (char *)"MediaSessionMgr_defaultsSetOpusMaxPlaybackRate", _wrap_MediaSessionMgr_defaultsSetOpusMaxPlaybackRate, METH_VARARGS, NULL},
{ (char *)"MediaSessionMgr_defaultsSetMaxFds", _wrap_MediaSessionMgr_defaultsSetMaxFds, METH_VARARGS, NULL},
{ (char *)"MediaSessionMgr_swigregister", MediaSessionMgr_swigregister, METH_VARARGS, NULL},
{ (char *)"delete_MediaContent", _wrap_delete_MediaContent, METH_VARARGS, NULL},
{ (char *)"MediaContent_getType", _wrap_MediaContent_getType, METH_VARARGS, NULL},
@ -26347,6 +26414,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"SipStack_dnsENUM", _wrap_SipStack_dnsENUM, METH_VARARGS, NULL},
{ (char *)"SipStack_dnsNaptrSrv", _wrap_SipStack_dnsNaptrSrv, METH_VARARGS, NULL},
{ (char *)"SipStack_dnsSrv", _wrap_SipStack_dnsSrv, METH_VARARGS, NULL},
{ (char *)"SipStack_setMaxFDs", _wrap_SipStack_setMaxFDs, METH_VARARGS, NULL},
{ (char *)"SipStack_getLocalIPnPort", _wrap_SipStack_getLocalIPnPort, METH_VARARGS, NULL},
{ (char *)"SipStack_getPreferredIdentity", _wrap_SipStack_getPreferredIdentity, METH_VARARGS, NULL},
{ (char *)"SipStack_isValid", _wrap_SipStack_isValid, METH_VARARGS, NULL},
@ -26358,6 +26426,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"SipStack_setCodecPriority", _wrap_SipStack_setCodecPriority, METH_VARARGS, NULL},
{ (char *)"SipStack_setCodecPriority_2", _wrap_SipStack_setCodecPriority_2, METH_VARARGS, NULL},
{ (char *)"SipStack_isCodecSupported", _wrap_SipStack_isCodecSupported, METH_VARARGS, NULL},
{ (char *)"SipStack_isIPSecSupported", _wrap_SipStack_isIPSecSupported, METH_VARARGS, NULL},
{ (char *)"SipStack_swigregister", SipStack_swigregister, METH_VARARGS, NULL},
{ (char *)"new_XcapSelector", _wrap_new_XcapSelector, METH_VARARGS, NULL},
{ (char *)"delete_XcapSelector", _wrap_delete_XcapSelector, METH_VARARGS, NULL},

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango telecom"
VALUE "FileDescription", "Doubango IMS Framework"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "tinywrap.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "tinywrap.dll"
VALUE "ProductName", "Doubango IMS Framework"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango Telecom"
VALUE "FileDescription", "Doubango IMS Framework NVIDIA CUDA Plugin"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "pluginCUDA.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "pluginCUDA.dll"
VALUE "ProductName", "Doubango IMS Framework NVIDIA CUDA Plugin"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango Telecom"
VALUE "FileDescription", "Doubango IMS Framework DirectShow Plugin"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "pluginDirectShow.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "pluginDirectShow.dll"
VALUE "ProductName", "Doubango IMS Framework DirectShow Plugin"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango Telecom"
VALUE "FileDescription", "Doubango IMS Framework WASAPI Plugin"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "pluginWASAPI.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "pluginWASAPI.dll"
VALUE "ProductName", "Doubango IMS Framework WASAPI Plugin"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango Telecom"
VALUE "FileDescription", "Doubango IMS Framework Windows Audio DSP"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "pluginWinAudioDSP.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "pluginWinAudioDSP.dll"
VALUE "ProductName", "Doubango IMS Framework Windows Audio DSP"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -0,0 +1 @@
AStyle.exe --style=k/r --lineend=linux --mode=c --add-brackets --break-closing-brackets --recursive "*.c" "*.h"

View File

@ -0,0 +1,100 @@
/* Copyright (C) 2013-2014 Mamadou DIOP
* Copyright (C) 2013-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 "plugin_win_ipsec_vista_config.h"
#include "tipsec.h"
#include "tsk_plugin.h"
#include "tsk_debug.h"
#include <windows.h>
extern const tipsec_plugin_def_t *plugin_win_ipsec_vista_plugin_def_t;
PLUGIN_WIN_IPSEC_VISTA_BEGIN_DECLS /* BEGIN */
PLUGIN_WIN_IPSEC_VISTA_API int __plugin_get_def_count();
PLUGIN_WIN_IPSEC_VISTA_API tsk_plugin_def_type_t __plugin_get_def_type_at(int index);
PLUGIN_WIN_IPSEC_VISTA_API tsk_plugin_def_media_type_t __plugin_get_def_media_type_at(int index);
PLUGIN_WIN_IPSEC_VISTA_API tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index);
PLUGIN_WIN_IPSEC_VISTA_END_DECLS /* END */
typedef enum PLUGIN_INDEX_E {
PLUGIN_INDEX_WFP, // Windows Filtering platform
PLUGIN_INDEX_COUNT
}
PLUGIN_INDEX_T;
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
int __plugin_get_def_count()
{
return PLUGIN_INDEX_COUNT;
}
tsk_plugin_def_type_t __plugin_get_def_type_at(int index)
{
switch(index) {
case PLUGIN_INDEX_WFP: {
return tsk_plugin_def_type_ipsec;
}
}
TSK_DEBUG_ERROR("No plugin at index %d", index);
return tsk_plugin_def_type_none;
}
tsk_plugin_def_media_type_t __plugin_get_def_media_type_at(int index)
{
switch(index) {
case PLUGIN_INDEX_WFP: {
return tsk_plugin_def_media_type_all;
}
}
TSK_DEBUG_ERROR("No plugin at index %d", index);
return tsk_plugin_def_media_type_none;
}
tsk_plugin_def_ptr_const_t __plugin_get_def_at(int index)
{
switch(index) {
case PLUGIN_INDEX_WFP: {
return plugin_win_ipsec_vista_plugin_def_t;
}
}
TSK_DEBUG_ERROR("No plugin at index %d", index);
return tsk_null;
}

View File

@ -0,0 +1,211 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="pluginWinIPSecVista"
ProjectGUID="{AAD0B2B5-8D8C-4DE0-BB20-1AB6CFAA617D}"
RootNamespace="pluginWinIPSecVista"
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\common\include;..\..\thirdparties\win32\include;..\..\tinySAK\src;..\..\tinyIPSec\src"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_WIN_IPSEC_VISTA_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
WarnAsError="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinyIPSec.lib Ws2_32.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\common\include;..\..\thirdparties\win32\include;..\..\tinySAK\src;..\..\tinyIPSec\src"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_WIN_IPSEC_VISTA_EXPORTS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
WarnAsError="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinyIPSec.lib Ws2_32.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=".\dllmain_ipsec_vista.c"
>
</File>
<File
RelativePath=".\plugin_win_ipsec_vista.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\plugin_win_ipsec_vista_config.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}"
>
<File
RelativePath=".\version.rc"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,636 @@
/* Copyright (C) 2013-2014 Mamadou DIOP
* Copyright (C) 2013-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 "plugin_win_ipsec_vista_config.h"
#include "tipsec.h" /* From tinyIPSec project. Requires linking against "tinyIPSec.lib" */
#include "tsk_memory.h"
#include "tsk_object.h"
#include "tsk_debug.h"
#include <ws2tcpip.h>
#include <Fwpmu.h>
#if defined(_MSC_VER)
# pragma comment(lib, "Fwpuclnt.lib")
#endif
typedef FWP_BYTE_BLOB* PFWP_BYTE_BLOB;
/* as WFP do not provide null encryption I define my own*/
static const IPSEC_CIPHER_TRANSFORM_ID0 IPSEC_CIPHER_TRANSFORM_ID_NULL_NULL= {
(IPSEC_CIPHER_TYPE)NULL,
(IPSEC_CIPHER_TYPE)NULL
};
#define TINYIPSEC_FILTER_NAME TEXT("Doubango Telecom tinyIPSec (Windows Vista)")
#define TINYIPSEC_PROVIDER_KEY NULL
#define TINYIPSEC_SA_NUM_ENTRIES_TO_REQUEST 20
#define TINYIPSEC_SA_MAX_LIFETIME 172799
#define TINYIPSEC_VISTA_GET_ALGO(algo) (algo == tipsec_alg_hmac_md5_96) ? IPSEC_AUTH_TRANSFORM_ID_HMAC_MD5_96 : IPSEC_AUTH_TRANSFORM_ID_HMAC_SHA_1_96
#define TINYIPSEC_VISTA_GET_EALGO(ealg) (ealg == tipsec_ealg_des_ede3_cbc) ? IPSEC_CIPHER_TRANSFORM_ID_CBC_3DES : ( (ealg == tipsec_ealg_aes) ? IPSEC_CIPHER_TRANSFORM_ID_AES_128 : IPSEC_CIPHER_TRANSFORM_ID_NULL_NULL )
#define TINYIPSEC_VISTA_GET_MODE(mode) (mode == tipsec_mode_tun) ? IPSEC_TRAFFIC_TYPE_TUNNEL : IPSEC_TRAFFIC_TYPE_TRANSPORT
#define TINYIPSEC_VISTA_GET_IPPROTO(ipproto) (ipproto == tipsec_ipproto_tcp) ? IPPROTO_TCP : IPPROTO_UDP
#define TINYIPSEC_VISTA_GET_IPVER(ipv6) (ipv6) ? FWP_IP_VERSION_V6 : FWP_IP_VERSION_V4
#define TINYIPSEC_VISTA_GET_PROTO(proto) (proto == tipsec_proto_ah) ? IPSEC_TRANSFORM_AH : ( (proto == tipsec_proto_esp) ? IPSEC_TRANSFORM_ESP_AUTH : IPSEC_TRANSFORM_ESP_AUTH_AND_CIPHER );
typedef struct plugin_win_ipsec_vista_ctx_s {
TIPSEC_DECLARE_CTX;
tipsec_ctx_t* pc_base;
UINT64 saId_us;
UINT64 saId_uc;
HANDLE engine;
}
plugin_win_ipsec_vista_ctx_t;
static int _vista_createLocalSA(__in const plugin_win_ipsec_vista_ctx_t* p_ctx, __in tipsec_port_t local_port, __out tipsec_spi_t *spi, UINT64 *saId);
static int _vista_boundSA(__in const plugin_win_ipsec_vista_ctx_t* p_ctx, __in UINT64 local_saId, __in tipsec_spi_t remote_spi, __in BOOLEAN toInbound);
static int _vista_flushAll(const plugin_win_ipsec_vista_ctx_t* p_ctx);
static void _vista_deleteSaContextAndFilters(__in HANDLE engine, __in UINT64 inFilterId, __in UINT64 outFilterId, __in UINT64 saId);
//
// Plugin implementation
//
static tipsec_error_t _plugin_win_ipsec_vista_ctx_init(tipsec_ctx_t* _p_ctx)
{
plugin_win_ipsec_vista_ctx_t* p_ctx = (plugin_win_ipsec_vista_ctx_t*)_p_ctx;
DWORD code;
if (p_ctx->pc_base->initialized) {
TSK_DEBUG_ERROR("Already initialized");
return tipsec_error_invalid_state;
}
/* Open engine */
if ((code = FwpmEngineOpen0(NULL, RPC_C_AUTHN_WINNT, NULL, NULL, &p_ctx->engine))) {
p_ctx->pc_base->initialized = tsk_false;
TSK_DEBUG_ERROR("FwpmEngineOpen0 failed with error code [%x].", code);
return tipsec_error_sys;
}
else {
p_ctx->pc_base->initialized = tsk_true;
p_ctx->pc_base->state = tipsec_state_initial;
return tipsec_error_success;
}
}
static tipsec_error_t _plugin_win_ipsec_vista_ctx_set_local(tipsec_ctx_t* _p_ctx, const char* addr_local, const char* addr_remote, tipsec_port_t port_uc, tipsec_port_t port_us)
{
plugin_win_ipsec_vista_ctx_t* p_ctx = (plugin_win_ipsec_vista_ctx_t*)_p_ctx;
int ret;
_p_ctx->addr_local = tsk_realloc(_p_ctx->addr_local, _p_ctx->use_ipv6 ? 16 : 4);
if (!_p_ctx->addr_local) {
return tipsec_error_outofmemory;
}
_p_ctx->addr_remote = tsk_realloc(_p_ctx->addr_remote, _p_ctx->use_ipv6 ? 16 : 4);
if (!_p_ctx->addr_remote) {
return tipsec_error_outofmemory;
}
/* Set local IP */
if (_p_ctx->use_ipv6) {
if ((ret = inet_pton(AF_INET6, addr_local, _p_ctx->addr_local)) != 1 ) {
TSK_DEBUG_ERROR("inet_pton(%s) have failed with error code [%x].", addr_local, ret);
return tipsec_error_sys;
}
if ((ret = inet_pton(AF_INET6, addr_remote, _p_ctx->addr_remote)) != 1 ) {
TSK_DEBUG_ERROR("inet_pton(%s) have failed with error code [%x].", addr_remote, ret);
return tipsec_error_sys;
}
}
else {
if ((ret = inet_pton(AF_INET, addr_local, _p_ctx->addr_local)) != 1 ) {
TSK_DEBUG_ERROR("inet_pton(%s) have failed with error code [%x].", addr_local, ret);
return tipsec_error_sys;
}
else {
*((UINT32*)_p_ctx->addr_local) = ntohl(*((UINT32*)_p_ctx->addr_local));
}
if ((ret = inet_pton(AF_INET, addr_remote, _p_ctx->addr_remote)) != 1 ) {
TSK_DEBUG_ERROR("inet_pton(%s) have failed with error code [%x].", addr_remote, ret);
return tipsec_error_sys;
}
else {
*((UINT32*)_p_ctx->addr_remote) = ntohl(*((UINT32*)_p_ctx->addr_remote));
}
}
/* Set ports */
_p_ctx->port_uc = port_uc;
_p_ctx->port_us = port_us;
// Create SA1: (UC -> PS)
if ((ret = _vista_createLocalSA(p_ctx, _p_ctx->port_uc, &_p_ctx->spi_uc, &p_ctx->saId_uc))) {
return tipsec_error_sys;
}
// Create SA2: (US <-PC)
if ((ret = _vista_createLocalSA(p_ctx, _p_ctx->port_us, &_p_ctx->spi_us, &p_ctx->saId_us))) {
return tipsec_error_sys;
}
_p_ctx->state = tipsec_state_inbound;
return tipsec_error_success;
}
static tipsec_error_t _plugin_win_ipsec_vista_ctx_set_remote(tipsec_ctx_t* _p_ctx, tipsec_spi_t spi_pc, tipsec_spi_t spi_ps, tipsec_port_t port_pc, tipsec_port_t port_ps, tipsec_lifetime_t lifetime)
{
plugin_win_ipsec_vista_ctx_t* p_ctx = (plugin_win_ipsec_vista_ctx_t*)_p_ctx;
/* Set Lifetime */
_p_ctx->lifetime = lifetime;
/* Set ports */
_p_ctx->port_ps = port_ps;
_p_ctx->port_pc = port_pc;
/* Set SPIs */
_p_ctx->spi_ps = spi_ps;
_p_ctx->spi_pc = spi_pc;
_p_ctx->state = tipsec_state_full;
return tipsec_error_success;
}
static tipsec_error_t _plugin_win_ipsec_vista_ctx_set_keys(tipsec_ctx_t* _p_ctx, const tipsec_key_t* ik, const tipsec_key_t* ck)
{
plugin_win_ipsec_vista_ctx_t* p_ctx = (plugin_win_ipsec_vista_ctx_t*)_p_ctx;
PFWP_BYTE_BLOB _ik, _ck;
/* Compute ik and ck */
_p_ctx->ik = tsk_realloc(_p_ctx->ik, sizeof(FWP_BYTE_BLOB));
if (!_p_ctx->ik) {
return tipsec_error_outofmemory;
}
_ik = (PFWP_BYTE_BLOB)_p_ctx->ik;
_p_ctx->ck = tsk_realloc(_p_ctx->ck, sizeof(FWP_BYTE_BLOB));
if (!_p_ctx->ck) {
return tipsec_error_outofmemory;
}
_ck = (PFWP_BYTE_BLOB)_p_ctx->ck;
_ik->data = tsk_calloc(1, TIPSEC_IK_LEN);
if (!_ik->data) {
return tipsec_error_outofmemory;
}
memcpy(_ik->data, ik, TIPSEC_KEY_LEN);
_ik->size = TIPSEC_KEY_LEN;
_ck->data = tsk_calloc(1, TIPSEC_CK_LEN);
if (!_ck->data) {
return tipsec_error_outofmemory;
}
memcpy(_ck->data, ck, TIPSEC_KEY_LEN);
_ck->size = TIPSEC_KEY_LEN;
return tipsec_error_success;
}
static tipsec_error_t _plugin_win_ipsec_vista_ctx_start(tipsec_ctx_t* _p_ctx)
{
plugin_win_ipsec_vista_ctx_t* p_ctx = (plugin_win_ipsec_vista_ctx_t*)_p_ctx;
int ret;
/* VERY IMPORTANT: The SA context functions must be called in a specific order:
(http://msdn.microsoft.com/en-us/library/bb540652(VS.85).aspx).
IPsecSaContextCreate0
IPsecSaContextGetSpi0
IPsecSaContextAddInbound0
IPsecSaContextAddOutbound0
*/
/* US <- PC */
if ((ret = _vista_boundSA(p_ctx, p_ctx->saId_us, _p_ctx->spi_us, TRUE))) {
TSK_DEBUG_ERROR("Failed to setup [US <- PC] SA. Error code = %d", ret);
return tipsec_error_sys;
}
/* UC <- PS */
if ((ret = _vista_boundSA(p_ctx, p_ctx->saId_uc, _p_ctx->spi_uc, TRUE))) {
TSK_DEBUG_ERROR("Failed to setup [UC <- PS] SA. Error code = %d", ret);
return tipsec_error_sys;
}
/* UC -> PS */
if ((ret = _vista_boundSA(p_ctx, p_ctx->saId_uc, _p_ctx->spi_ps, FALSE))) {
TSK_DEBUG_ERROR("Failed to setup [UC -> PS] SA. Error code = %d", ret);
return tipsec_error_sys;
}
/* US -> PC */
if ((ret = _vista_boundSA(p_ctx, p_ctx->saId_us, _p_ctx->spi_pc, FALSE))) {
TSK_DEBUG_ERROR("Failed to setup [US -> PC] SA. Error code = %d", ret);
return tipsec_error_sys;
}
_p_ctx->state = tipsec_state_active;
_p_ctx->started = 1;
return tipsec_error_success;
}
static tipsec_error_t _plugin_win_ipsec_vista_ctx_stop(tipsec_ctx_t* _p_ctx)
{
plugin_win_ipsec_vista_ctx_t* p_ctx = (plugin_win_ipsec_vista_ctx_t*)_p_ctx;
tipsec_error_t err = tipsec_error_success;
//if (!_p_ctx->started) {
// return tipsec_error_success;
//}
/* Flush (delete) all SAs associated to tinyIPSEC */
_vista_flushAll(p_ctx);
_p_ctx->started = 0;
_p_ctx->state = tipsec_state_initial;
return tipsec_error_success;
}
//
// Private functions
//
static int _vista_createLocalSA(__in const plugin_win_ipsec_vista_ctx_t* p_ctx, __in tipsec_port_t local_port, __out tipsec_spi_t *spi, UINT64 *saId)
{
DWORD result = NO_ERROR;
UINT64 tmpInFilterId = 0, tmpOutFilterId = 0, tmpSaId = 0;
FWPM_FILTER0 filter;
IPSEC_TRAFFIC0 outTraffic;
IPSEC_GETSPI0 getSpi;
int ret = -1;
FWPM_FILTER_CONDITION0 conds[4];
*spi = 0;
*saId = 0;
conds[0].fieldKey = FWPM_CONDITION_IP_LOCAL_ADDRESS;
conds[0].matchType = FWP_MATCH_EQUAL;
conds[1].fieldKey = FWPM_CONDITION_IP_REMOTE_ADDRESS;
conds[1].matchType = FWP_MATCH_EQUAL;
if (p_ctx->pc_base->use_ipv6) {
conds[0].conditionValue.type = FWP_BYTE_ARRAY16_TYPE;
conds[0].conditionValue.byteArray16 = (FWP_BYTE_ARRAY16*)p_ctx->pc_base->addr_local;
conds[1].conditionValue.type = FWP_BYTE_ARRAY16_TYPE;
conds[1].conditionValue.byteArray16 = (FWP_BYTE_ARRAY16*)p_ctx->pc_base->addr_remote;
}
else {
conds[0].conditionValue.type = FWP_UINT32;
conds[0].conditionValue.uint32 = *((UINT32*)p_ctx->pc_base->addr_local);
conds[1].conditionValue.type = FWP_UINT32;
conds[1].conditionValue.uint32 = *((UINT32*)p_ctx->pc_base->addr_remote);
}
conds[2].fieldKey = FWPM_CONDITION_IP_LOCAL_PORT;
conds[2].matchType = FWP_MATCH_EQUAL;
conds[2].conditionValue.type = FWP_UINT16;
conds[2].conditionValue.uint16 = local_port;
conds[3].fieldKey = FWPM_CONDITION_IP_PROTOCOL;
conds[3].matchType = FWP_MATCH_EQUAL;
conds[3].conditionValue.type = FWP_UINT8;
conds[3].conditionValue.uint16 = TINYIPSEC_VISTA_GET_IPPROTO(p_ctx->pc_base->ipproto);
// Fill in the common fields shared by both filters.
memset(&filter, 0, sizeof(filter));
// For MUI compatibility, object names should be indirect strings. See
// SHLoadIndirectString for details.
filter.displayData.name = (PWSTR)TINYIPSEC_FILTER_NAME;
// Link all objects to our provider. When multiple providers are installed
// on a computer, this makes it easy to determine who added what.
filter.providerKey = (GUID*)TINYIPSEC_PROVIDER_KEY;
filter.numFilterConditions = 4;
filter.filterCondition = conds;
filter.action.type = FWP_ACTION_CALLOUT_TERMINATING;
filter.flags = FWPM_FILTER_FLAG_NONE;
//filter.weight.type = FWP_EMPTY;
// Add the inbound filter.
filter.layerKey = (p_ctx->pc_base->use_ipv6) ? FWPM_LAYER_INBOUND_TRANSPORT_V6 : FWPM_LAYER_INBOUND_TRANSPORT_V4;
if (p_ctx->pc_base->mode == tipsec_mode_tun) {
filter.action.calloutKey = (p_ctx->pc_base->use_ipv6) ? FWPM_CALLOUT_IPSEC_INBOUND_TUNNEL_V6 : FWPM_CALLOUT_IPSEC_INBOUND_TUNNEL_V4;
}
else {
filter.action.calloutKey = (p_ctx->pc_base->use_ipv6) ? FWPM_CALLOUT_IPSEC_INBOUND_TRANSPORT_V6 : FWPM_CALLOUT_IPSEC_INBOUND_TRANSPORT_V4;
}
if ((result = FwpmFilterAdd0(p_ctx->engine, &filter, NULL, &tmpInFilterId)) != ERROR_SUCCESS) {
TSK_DEBUG_ERROR("FwpmFilterAdd0 (inbound) failed with error code [%x]", result);
goto CLEANUP;
}
// Add the outbound filter.
filter.layerKey = (p_ctx->pc_base->use_ipv6) ? FWPM_LAYER_OUTBOUND_TRANSPORT_V6 : FWPM_LAYER_OUTBOUND_TRANSPORT_V4;
if (p_ctx->pc_base->mode == tipsec_mode_tun) {
filter.action.calloutKey = (p_ctx->pc_base->use_ipv6) ? FWPM_CALLOUT_IPSEC_OUTBOUND_TUNNEL_V6 : FWPM_CALLOUT_IPSEC_OUTBOUND_TUNNEL_V4;
}
else {
filter.action.calloutKey = (p_ctx->pc_base->use_ipv6) ? FWPM_CALLOUT_IPSEC_OUTBOUND_TRANSPORT_V6 : FWPM_CALLOUT_IPSEC_OUTBOUND_TRANSPORT_V4;
}
if ((result = FwpmFilterAdd0(p_ctx->engine, &filter, NULL, &tmpOutFilterId)) != ERROR_SUCCESS) {
TSK_DEBUG_ERROR("FwpmFilterAdd0(outbound) failed with error code [%x]", result);
goto CLEANUP;
}
// Create the SA context using the outbound traffic descriptor.
memset(&outTraffic, 0, sizeof(outTraffic));
outTraffic.ipVersion = TINYIPSEC_VISTA_GET_IPVER(p_ctx->pc_base->use_ipv6);
if (p_ctx->pc_base->use_ipv6) {
memcpy(outTraffic.localV6Address, p_ctx->pc_base->addr_local, 16);
memcpy(outTraffic.remoteV6Address, p_ctx->pc_base->addr_remote, 16);
}
else {
outTraffic.localV4Address = *((UINT32*)p_ctx->pc_base->addr_local);
outTraffic.remoteV4Address = *((UINT32*)p_ctx->pc_base->addr_remote);
}
outTraffic.trafficType = TINYIPSEC_VISTA_GET_MODE(p_ctx->pc_base->mode);
outTraffic.ipsecFilterId = tmpOutFilterId;
if ((result = IPsecSaContextCreate0(p_ctx->engine, &outTraffic, NULL, &tmpSaId)) != ERROR_SUCCESS) {
TSK_DEBUG_ERROR("IPsecSaContextCreate0 failed with error code [%x]", result);
goto CLEANUP;
}
// Get the inbound SPI using the inbound traffic descriptor.
memset(&getSpi, 0, sizeof(getSpi));
getSpi.inboundIpsecTraffic.ipVersion = TINYIPSEC_VISTA_GET_IPVER(p_ctx->pc_base->use_ipv6);
if (p_ctx->pc_base->use_ipv6) {
memcpy(getSpi.inboundIpsecTraffic.localV6Address, p_ctx->pc_base->addr_local, 16);
memcpy(getSpi.inboundIpsecTraffic.remoteV6Address, p_ctx->pc_base->addr_remote, 16);
}
else {
getSpi.inboundIpsecTraffic.localV4Address = *((UINT32*)p_ctx->pc_base->addr_local);
getSpi.inboundIpsecTraffic.remoteV4Address = *((UINT32*)p_ctx->pc_base->addr_remote);
}
getSpi.inboundIpsecTraffic.trafficType = TINYIPSEC_VISTA_GET_MODE(p_ctx->pc_base->mode);
getSpi.inboundIpsecTraffic.ipsecFilterId = tmpInFilterId;
getSpi.ipVersion = TINYIPSEC_VISTA_GET_IPVER(p_ctx->pc_base->use_ipv6);
if ((result = IPsecSaContextGetSpi0(p_ctx->engine, tmpSaId, &getSpi, spi))) {
TSK_DEBUG_ERROR("IPsecSaContextGetSpi0 failed with error code [%x]", result);
goto CLEANUP;
}
//// Return the various LUIDs to the caller, so he can clean up.
//*inFilterId = tmpInFilterId;
//*outFilterId = tmpOutFilterId;
*saId = tmpSaId;
CLEANUP:
if (result != NO_ERROR) {
_vista_deleteSaContextAndFilters(p_ctx->engine, tmpInFilterId, tmpOutFilterId, tmpSaId);
}
else {
ret = 0;
}
return ret;
}
static int _vista_boundSA(__in const plugin_win_ipsec_vista_ctx_t* p_ctx, __in UINT64 local_saId, __in tipsec_spi_t remote_spi, __in BOOLEAN toInbound)
{
UINT32 i=0, j=0;
DWORD result = NO_ERROR;
IPSEC_SA0 sa;
IPSEC_SA_BUNDLE0 bundle;
IPSEC_SA_AUTH_INFORMATION0 authInfo;
PFWP_BYTE_BLOB ik = (PFWP_BYTE_BLOB)p_ctx->pc_base->ik;
PFWP_BYTE_BLOB ck = (PFWP_BYTE_BLOB)p_ctx->pc_base->ck;
memset(&sa, 0, sizeof(sa));
sa.spi = remote_spi;
sa.saTransformType = TINYIPSEC_VISTA_GET_PROTO(p_ctx->pc_base->protocol);
//
// Keys padding
//
if (p_ctx->pc_base->alg == tipsec_alg_hmac_sha_1_96) {
if (ik->size < TIPSEC_IK_LEN) {
for(i = ik->size; i < TIPSEC_KEY_LEN; i++) {
ik->data[i] = 0x00; /* Already done by "tsk_calloc" but ... */
}
ik->size = TIPSEC_IK_LEN;
}
}
if (p_ctx->pc_base->ealg == tipsec_ealg_des_ede3_cbc) {
if (ck->size < TIPSEC_CK_LEN) {
for (i = ck->size; i<TIPSEC_CK_LEN; i++) {
ck->data[i] = ck->data[j++];
}
ck->size = TIPSEC_CK_LEN;
}
}
//
// In all case create Authentication info
//
memset(&authInfo, 0, sizeof(authInfo));
authInfo.authTransform.authTransformId = TINYIPSEC_VISTA_GET_ALGO(p_ctx->pc_base->alg);
authInfo.authKey = *ik;
if ( sa.saTransformType == IPSEC_TRANSFORM_AH ) {
sa.ahInformation = &authInfo;
}
else if ( sa.saTransformType == IPSEC_TRANSFORM_ESP_AUTH ) {
sa.espAuthInformation = &authInfo;
}
else if ( sa.saTransformType == IPSEC_TRANSFORM_ESP_AUTH_AND_CIPHER ) {
IPSEC_SA_CIPHER_INFORMATION0 cipherInfo;
IPSEC_SA_AUTH_AND_CIPHER_INFORMATION0 cipherAuthInfo;
memset(&cipherInfo, 0, sizeof(cipherInfo));
cipherInfo.cipherTransform.cipherTransformId = TINYIPSEC_VISTA_GET_EALGO(p_ctx->pc_base->ealg);
cipherInfo.cipherKey = *ck;
memset(&cipherAuthInfo, 0, sizeof(cipherAuthInfo));
cipherAuthInfo.saAuthInformation = authInfo;
cipherAuthInfo.saCipherInformation = cipherInfo;
sa.espAuthAndCipherInformation = &cipherAuthInfo;
}
memset(&bundle, 0, sizeof(bundle));
bundle.numSAs = 1;
bundle.saList = &sa;
bundle.ipVersion = TINYIPSEC_VISTA_GET_IPVER(p_ctx->pc_base->use_ipv6);
bundle.lifetime.lifetimeSeconds = (UINT32)((p_ctx->pc_base->lifetime > TINYIPSEC_SA_MAX_LIFETIME) ? TINYIPSEC_SA_MAX_LIFETIME : p_ctx->pc_base->lifetime);
/* From remote to local (inbound) ? */
if (toInbound) {
if((result = IPsecSaContextAddInbound0(p_ctx->engine, local_saId, &bundle)) != ERROR_SUCCESS) {
TSK_DEBUG_ERROR("IPsecSaContextAddInbound0 failed with error code [%x]", result);
goto CLEANUP;
}
}
else {
if ((result = IPsecSaContextAddOutbound0(p_ctx->engine, local_saId, &bundle)) != ERROR_SUCCESS) {
TSK_DEBUG_ERROR("IPsecSaContextAddOutbound0 failed with error code [%x]", result);
goto CLEANUP;
}
}
CLEANUP:
return (result == ERROR_SUCCESS) ? 0 : -1;
}
static int _vista_flushAll(const plugin_win_ipsec_vista_ctx_t* p_ctx)
{
UINT32 i;
int ret = -1;
if (p_ctx && p_ctx->engine) {
HANDLE enumHandle = NULL;
IPSEC_SA_DETAILS0** entries = NULL;
UINT32 numEntriesReturned = 0;
DWORD result;
if ((result = IPsecSaCreateEnumHandle0(p_ctx->engine, NULL, &enumHandle)) != ERROR_SUCCESS) {
TSK_DEBUG_ERROR("IPsecSaCreateEnumHandle0 failed with error code [%x].", result);
goto CLEANUP;
}
if ((result = IPsecSaEnum0(p_ctx->engine, enumHandle, TINYIPSEC_SA_NUM_ENTRIES_TO_REQUEST, &entries, &numEntriesReturned)) != ERROR_SUCCESS) {
TSK_DEBUG_ERROR("IPsecSaEnum0 failed with error code [%x].", result);
goto CLEANUP;
}
for (i = 0; i<numEntriesReturned; i++) {
IPSEC_SA_DETAILS0* entry = (entries)[i];
if ( !wcscmp(entry->transportFilter->displayData.name, TINYIPSEC_FILTER_NAME)) {
if ((result = FwpmFilterDeleteById0(p_ctx->engine, entry->transportFilter->filterId)) != ERROR_SUCCESS) {
TSK_DEBUG_ERROR("FwpmFilterDeleteById0 failed with error code [%x].", result);
goto CLEANUP;
}
}
}
if ((result = IPsecSaDestroyEnumHandle0(p_ctx->engine, enumHandle)) != ERROR_SUCCESS) {
TSK_DEBUG_ERROR("IPsecSaDestroyEnumHandle0 failed with error code [%x].", result);
goto CLEANUP;
}
TSK_DEBUG_INFO("All SAs have been flushed.");
ret = 0;
CLEANUP:
if (entries) {
FwpmFreeMemory0((void**)entries);
}
}
return ret;
}
static void _vista_deleteSaContextAndFilters(__in HANDLE engine, __in UINT64 inFilterId, __in UINT64 outFilterId, __in UINT64 saId)
{
DWORD result;
// Allow the LUIDs to be zero, so we can use this function to cleanup
// partial results.
if (saId != 0) {
result = IPsecSaContextDeleteById0(engine, saId);
if (result != ERROR_SUCCESS) {
// There's not much we can do if delete fails, so continue trying to
// clean up the remaining objects.
TSK_DEBUG_ERROR("IPsecSaContextDeleteById0 = 0x%08X\n", result);
}
}
if (outFilterId != 0) {
result = FwpmFilterDeleteById0(engine, outFilterId);
if (result != ERROR_SUCCESS) {
TSK_DEBUG_ERROR("FwpmFilterDeleteById0 = 0x%08X\n", result);
}
}
if (inFilterId != 0) {
result = FwpmFilterDeleteById0(engine, inFilterId);
if (result != ERROR_SUCCESS) {
TSK_DEBUG_ERROR("FwpmFilterDeleteById0 = 0x%08X\n", result);
}
}
}
//
// Windows Vista IPSec Plugin definition
//
/* constructor */
static tsk_object_t* _plugin_win_ipsec_vista_ctx_ctor(tsk_object_t * self, va_list * app)
{
plugin_win_ipsec_vista_ctx_t *p_ctx = (plugin_win_ipsec_vista_ctx_t *)self;
if (p_ctx) {
p_ctx->pc_base = TIPSEC_CTX(p_ctx);
}
return self;
}
/* destructor */
static tsk_object_t* _plugin_win_ipsec_vista_ctx_dtor(tsk_object_t * self)
{
plugin_win_ipsec_vista_ctx_t *p_ctx = (plugin_win_ipsec_vista_ctx_t *)self;
if (p_ctx) {
DWORD code;
if (p_ctx->pc_base->started) {
tipsec_ctx_stop(p_ctx->pc_base);
}
/* Close engine */
if (p_ctx->engine) {
if ((code = FwpmEngineClose0(p_ctx->engine))) {
TSK_DEBUG_ERROR("FwpmEngineClose0 failed with error code [%x].", code);
}
}
TSK_FREE(p_ctx->pc_base->addr_local);
TSK_FREE(p_ctx->pc_base->addr_remote);
TSK_FREE(p_ctx->pc_base->ik);
TSK_FREE(p_ctx->pc_base->ck);
TSK_DEBUG_INFO("*** Windows Vista IPSec plugin (Windows Filtering Platform) context destroyed ***");
}
return self;
}
/* object definition */
static const tsk_object_def_t plugin_win_ipsec_vista_ctx_def_s = {
sizeof(plugin_win_ipsec_vista_ctx_t),
_plugin_win_ipsec_vista_ctx_ctor,
_plugin_win_ipsec_vista_ctx_dtor,
tsk_null,
};
/* plugin definition*/
static const tipsec_plugin_def_t plugin_win_ipsec_vista_plugin_def_s = {
&plugin_win_ipsec_vista_ctx_def_s,
tipsec_impl_type_vista,
"Windows Vista IPSec (Windows Filtering Platform)",
_plugin_win_ipsec_vista_ctx_init,
_plugin_win_ipsec_vista_ctx_set_local,
_plugin_win_ipsec_vista_ctx_set_remote,
_plugin_win_ipsec_vista_ctx_set_keys,
_plugin_win_ipsec_vista_ctx_start,
_plugin_win_ipsec_vista_ctx_stop,
};
const tipsec_plugin_def_t *plugin_win_ipsec_vista_plugin_def_t = &plugin_win_ipsec_vista_plugin_def_s;

View File

@ -0,0 +1,75 @@
/* Copyright (C) 2013-2014 Mamadou DIOP
* Copyright (C) 2013-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 PLUGIN_WIN_IPSEC_VISTA_CONFIG_H
#define PLUGIN_WIN_IPSEC_VISTA_CONFIG_H
#ifdef __SYMBIAN32__
#undef _WIN32 /* Because of WINSCW */
#endif
// Windows (XP/Vista/7/CE and Windows Mobile) macro definition
#if defined(WIN32)|| defined(_WIN32) || defined(_WIN32_WCE)
# define PLUGIN_WIN_IPSEC_VISTA_UNDER_WINDOWS 1
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP || WINAPI_FAMILY == WINAPI_FAMILY_APP)
# define PLUGIN_WIN_IPSEC_VISTA_UNDER_WINDOWS_RT 1
# endif
#endif
#if (PLUGIN_WIN_IPSEC_VISTA_UNDER_WINDOWS || defined(__SYMBIAN32__)) && defined(PLUGIN_WIN_IPSEC_VISTA_EXPORTS)
# define PLUGIN_WIN_IPSEC_VISTA_API __declspec(dllexport)
# define PLUGIN_WIN_IPSEC_VISTA_GEXTERN extern __declspec(dllexport)
#elif (PLUGIN_WIN_IPSEC_VISTA_UNDER_WINDOWS || defined(__SYMBIAN32__)) && !defined(PLUGIN_WIN_IPSEC_VISTA_IMPORTS_IGNORE)
# define PLUGIN_WIN_IPSEC_VISTA_API __declspec(dllimport)
# define PLUGIN_WIN_IPSEC_VISTA_GEXTERN __declspec(dllimport)
#else
# define PLUGIN_WIN_IPSEC_VISTA_API
# define PLUGIN_WIN_IPSEC_VISTA_GEXTERN extern
#endif
// x86
#if defined(__x86_64__) || defined(__x86__) || defined(__i386__)
# define PLUGIN_WIN_IPSEC_VISTA_UNDER_X86 1
#endif
// Guards against C++ name mangling
#ifdef __cplusplus
# define PLUGIN_WIN_IPSEC_VISTA_BEGIN_DECLS extern "C" {
# define PLUGIN_WIN_IPSEC_VISTA_END_DECLS }
#else
# define PLUGIN_WIN_IPSEC_VISTA_BEGIN_DECLS
# define PLUGIN_WIN_IPSEC_VISTA_END_DECLS
#endif
#ifdef _MSC_VER
# define inline __inline
# define _CRT_SECURE_NO_WARNINGS
# define _ALLOW_KEYWORD_MACROS
#endif
#include <stdint.h>
#ifdef __SYMBIAN32__
#include <stdlib.h>
#endif
#if HAVE_CONFIG_H
#include <config.h>
#endif
#endif // PLUGIN_WIN_IPSEC_VISTA_CONFIG_H

View File

@ -0,0 +1,102 @@
// Microsoft Visual C++ generated resource script.
//
// #include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Doubango Telecom"
VALUE "FileDescription", "Doubango IMS Framework IPSec implementaion for Windows Vista and later"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "pluginMF.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "pluginWinIPSecVista.dll"
VALUE "ProductName", "Doubango IMS Framework IPSec implementaion"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango Telecom"
VALUE "FileDescription", "Doubango IMS Framework Media Foundation Plugin"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "pluginMF.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "pluginMF.dll"
VALUE "ProductName", "Doubango IMS Framework Foundation Plugin"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -5,10 +5,12 @@ libtinyDAV_la_LIBADD = \
../tinySDP/libtinySDP.la\
../tinyRTP/libtinyRTP.la\
../tinyMEDIA/libtinyMEDIA.la\
../tinyMSRP/libtinyMSRP.la
../tinyMSRP/libtinyMSRP.la\
../tinyIPSec/libtinyIPSec.la
libtinyDAV_la_CPPFLAGS = -I../tinySAK/src\
-I../tinyNET/src\
-I../tinyIPSec/src\
-I../tinySDP/include\
-I../tinyRTP/include\
-I../tinyMEDIA/include\

View File

@ -169,13 +169,13 @@ endif
CFLAGS := $(CFLAGS_LIB) -I$(THIRDPARTIES_INC) -I$(THIRDPARTIES_INC_COMMON) $(ILBC_CFLAGS) $(LIBGSM_CFLAGS) \
$(FFMPEG_CFLAGS) $(LIBYUV_CFLAGS) $(VPX_CFLAGS) $(SPEEX_CFLAGS) $(SPEEX_DSP_CFLAGS) $(WEBRTC_CFLAGS) $(OPUS_CFLAGS) $(OPENCORE_AMR_CFLAGS) $(BV16_CFLAGS) $(G729_CFLAGS) \
$(LIBSRTP_CFLAGS) \
-I../tinySAK/src -I../tinyNET/src -I../tinySDP/include -I../tinyRTP/include -I../tinyMEDIA/include -I../tinyMSRP/include -I./include \
-I../tinySAK/src -I../tinyNET/src -I../tinyIPSec/src -I../tinySDP/include -I../tinyRTP/include -I../tinyMEDIA/include -I../tinyMSRP/include -I./include \
-DJB_HISTORY_SIZE=500
LDFLAGS := $(LDFLAGS_LIB) -L$(THIRDPARTIES_LIB) -L$(THIRDPARTIES_MARCH_LIB) \
$(FFMPEG_LDFLAGS) $(LIBYUV_LDFLAGS) $(VPX_LDFLAGS) $(SPEEX_LDFLAGS) $(SPEEX_DSP_LDFLAGS) $(WEBRTC_LDFLAGS) $(OPUS_LDFLAGS) $(OPENCORE_AMR_LDFLAGS) $(ILBC_LDFLAGS) $(LIBGSM_LDFLAGS) $(BV16_LDFLAGS) $(G729_LDFLAGS) \
$(LIBSRTP_LDFLAGS) \
-ltinySAK_$(MARCH) -ltinyNET_$(MARCH) -ltinySDP_$(MARCH) -ltinyRTP_$(MARCH) -ltinyMEDIA_$(MARCH) -ltinyMSRP_$(MARCH) -lm -lgcc
-ltinySAK_$(MARCH) -ltinyNET_$(MARCH) -ltinyIPSec_$(MARCH) -ltinySDP_$(MARCH) -ltinyRTP_$(MARCH) -ltinyMEDIA_$(MARCH) -ltinyMSRP_$(MARCH) -lm -lgcc
all: $(APP)

View File

@ -88,6 +88,7 @@ TINYDAV_API int tdav_codec_set_priority(tdav_codec_id_t codec_id, int priority);
TINYDAV_API int tdav_set_codecs(tdav_codec_id_t codecs);
TINYDAV_API tsk_bool_t tdav_codec_is_supported(tdav_codec_id_t codec);
TINYDAV_API tsk_bool_t tdav_codec_is_enabled(tdav_codec_id_t codec);
TINYDAV_API tsk_bool_t tdav_ipsec_is_supported();
TINYDAV_API int tdav_deinit();
TDAV_END_DECLS

View File

@ -29,6 +29,7 @@
#include "tinydav/tdav.h"
static tsk_bool_t __b_initialized = tsk_false;
static tsk_bool_t __b_ipsec_supported = tsk_false;
static const struct tmedia_codec_plugin_def_s* __codec_plugins_all[0xFF] = { tsk_null }; // list of all codecs BEFORE filtering
static const tsk_size_t __codec_plugins_all_count = sizeof(__codec_plugins_all)/sizeof(__codec_plugins_all[0]);
@ -48,12 +49,16 @@ static const tsk_size_t __codec_plugins_all_count = sizeof(__codec_plugins_all)/
static struct tsk_plugin_s* __dll_plugin_mf = tsk_null; /* Media Foundation and WASAPI : Windows [7 - 8] */
static struct tsk_plugin_s* __dll_plugin_cuda = tsk_null; /* Media Foundation and WASAPI : Windows [XP - 8] */
static struct tsk_plugin_s* __dll_plugin_audio_dsp = tsk_null; /* Audio DSP, Resampler, AEC, NS, AGC...: Windows [Vista - 8] */
static struct tsk_plugin_s* __dll_plugin_ipsec_wfp = tsk_null; /* IPSec implementation using WFP (Windows Filtering platform): Windows [Vista - 8] */
# endif /* TDAV_UNDER_WINDOWS */
#endif
// Media Contents, ...
// Media Contents, plugins defintion...
#include "tinymedia.h"
// IPSec
#include "tipsec.h"
// Converters
#include "tinymedia/tmedia_converter_video.h"
// Converters
@ -207,6 +212,15 @@ int tdav_init()
plugins_count += tmedia_plugin_register(__dll_plugin_audio_dsp, tsk_plugin_def_type_all, tsk_plugin_def_media_type_all);
}
}
/* IPSec implementation using Windows Filtering Platform (WFP) */
if(tdav_win32_is_winvista_or_later()){
tsk_sprintf(&full_path, "%s/pluginWinIPSecVista.dll", tdav_get_current_directory_const());
if(tsk_plugin_file_exist(full_path) && (tipsec_plugin_register_file(full_path, &__dll_plugin_ipsec_wfp) == 0)){
plugins_count += 1; // at least one
__b_ipsec_supported = tsk_true;
}
}
TSK_FREE(full_path);
TSK_DEBUG_INFO("Windows stand-alone plugins loaded = %u", plugins_count);
}
@ -495,6 +509,15 @@ tsk_bool_t tdav_codec_is_enabled(tdav_codec_id_t codec)
return tmedia_codec_plugin_is_registered_2((tmedia_codec_id_t)codec);
}
/**
* Checks whether a IPSec is supported.
* @return @ref tsk_true if supported and @tsk_false otherwise.
*/
tsk_bool_t tdav_ipsec_is_supported()
{
return __b_ipsec_supported;
}
int tdav_deinit()
{
int ret = 0;
@ -611,6 +634,7 @@ int tdav_deinit()
TSK_OBJECT_SAFE_FREE(__dll_plugin_mf);
TSK_OBJECT_SAFE_FREE(__dll_plugin_dshow);
TSK_OBJECT_SAFE_FREE(__dll_plugin_audio_dsp);
TSK_OBJECT_SAFE_FREE(__dll_plugin_ipsec_wfp);
}
#endif

View File

@ -15,8 +15,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcproj",
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyRTP", "..\tinyRTP\tinyRTP.vcproj", "{99B7D02F-8C70-4B45-AF3C-92313C3CEE15}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyDSHOW", "..\tinyDSHOW\tinyDSHOW.vcproj", "{0CCC02F1-4233-424F-AD5E-A021456E6E8D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyMSRP", "..\tinyMSRP\tinyMSRP.vcproj", "{AA46AF16-9678-4054-8E48-98DC21ECEC82}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyHTTP", "..\tinyHTTP\tinyHTTP.vcproj", "{B3E45009-C7C3-4090-837C-2D30C9058443}"
@ -133,18 +131,6 @@ Global
{99B7D02F-8C70-4B45-AF3C-92313C3CEE15}.Static_Release|Win32.ActiveCfg = Release|Win32
{99B7D02F-8C70-4B45-AF3C-92313C3CEE15}.Static_Release|Win32.Build.0 = Release|Win32
{99B7D02F-8C70-4B45-AF3C-92313C3CEE15}.Static_Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Debug|Win32.ActiveCfg = Debug|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Debug|Win32.Build.0 = Debug|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Release|Win32.ActiveCfg = Release|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Release|Win32.Build.0 = Release|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Static_Debug|Win32.ActiveCfg = Debug|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Static_Debug|Win32.Build.0 = Debug|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Static_Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Static_Release|Win32.ActiveCfg = Release|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Static_Release|Win32.Build.0 = Release|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Static_Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
{AA46AF16-9678-4054-8E48-98DC21ECEC82}.Debug|Win32.ActiveCfg = Debug|Win32
{AA46AF16-9678-4054-8E48-98DC21ECEC82}.Debug|Win32.Build.0 = Debug|Win32
{AA46AF16-9678-4054-8E48-98DC21ECEC82}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32

View File

@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\thirdparties\common\include;..\thirdparties\win32\include;include;..\tinyMSRP\include;..\tinyRTP\include;..\tinyMEDIA\include;..\tinySDP\include;..\tinyNET\src;..\tinySAK\src;..\thirdparties\win32\include\BroadVoice16\bvcommon;..\thirdparties\win32\include\BroadVoice16\bv16"
AdditionalIncludeDirectories="..\thirdparties\common\include;..\thirdparties\win32\include;include;..\tinyMSRP\include;..\tinyRTP\include;..\tinyMEDIA\include;..\tinySDP\include;..\tinyIPSec\src;..\tinyNET\src;..\tinySAK\src;..\thirdparties\win32\include\BroadVoice16\bvcommon;..\thirdparties\win32\include\BroadVoice16\bv16"
PreprocessorDefinitions="HAVE_SRTP=1;HAVE_G729=0;HAVE_BV16=0;HAVE_OPENCORE_AMR=1;HAVE_H264=1;HAVE_ILBC=0;HAVE_LIBGSM=1;HAVE_LIBOPUS=1;HAVE_DSOUND_H=1;HAVE_WAVE_API=1;HAVE_FFMPEG=1;HAVE_SPEEX_DSP=1;HAVE_WEBRTC=1;HAVE_SPEEX_JB=1;HAVE_LIB_SPEEX=1;HAVE_LIBVPX=1;HAVE_LIBYUV=1;G192BITSTREAM=0;DEBUG_LEVEL=DEBUG_LEVEL_INFO;GOTHAM_CITY = 0;WIN32;_DEBUG;_WINDOWS;_USRDLL;_WIN32_WINNT=0x0501;TINYDAV_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -64,7 +64,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Winmm.lib Shlwapi.lib &quot;$(OutDir)\tinySAK.lib&quot; &quot;$(OutDir)\tinyNET.lib&quot; &quot;$(OutDir)\tinyRTP.lib&quot; &quot;$(OutDir)\tinyMSRP.lib&quot; &quot;$(OutDir)\tinySDP.lib&quot; &quot;$(OutDir)\tinyMEDIA.lib&quot; &quot;..\thirdparties\win32\lib\opus\libopus.a&quot; &quot;..\thirdparties\win32\lib\gsm\libgsm.a&quot; &quot;..\thirdparties\win32\lib\ilbc\libiLBC.a&quot; &quot;..\thirdparties\win32\lib\speex\libspeex.a&quot; &quot;..\thirdparties\win32\lib\speex\libspeexdsp.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libavcodec.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libavutil.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libswscale.a&quot; &quot;..\thirdparties\win32\lib\libgcc.a&quot; &quot;..\thirdparties\win32\lib\libmingwex.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libx264.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libtheora.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libogg.a&quot; &quot;..\thirdparties\win32\lib\webrtc\aec.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\aec_sse2.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\apm_util.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\system_wrappers.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\spl.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\ns.lib&quot; &quot;..\thirdparties\win32\lib\libyuv\libyuv.lib&quot; &quot;..\thirdparties\win32\lib\vpx\vpxmt.lib&quot;"
AdditionalDependencies="Winmm.lib Shlwapi.lib &quot;$(OutDir)\tinySAK.lib&quot; &quot;$(OutDir)\tinyIPSec.lib&quot; &quot;$(OutDir)\tinyNET.lib&quot; &quot;$(OutDir)\tinyRTP.lib&quot; &quot;$(OutDir)\tinyMSRP.lib&quot; &quot;$(OutDir)\tinySDP.lib&quot; &quot;$(OutDir)\tinyMEDIA.lib&quot; &quot;..\thirdparties\win32\lib\opus\libopus.a&quot; &quot;..\thirdparties\win32\lib\gsm\libgsm.a&quot; &quot;..\thirdparties\win32\lib\ilbc\libiLBC.a&quot; &quot;..\thirdparties\win32\lib\speex\libspeex.a&quot; &quot;..\thirdparties\win32\lib\speex\libspeexdsp.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libavcodec.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libavutil.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libswscale.a&quot; &quot;..\thirdparties\win32\lib\libgcc.a&quot; &quot;..\thirdparties\win32\lib\libmingwex.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libx264.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libtheora.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libogg.a&quot; &quot;..\thirdparties\win32\lib\webrtc\aec.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\aec_sse2.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\apm_util.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\system_wrappers.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\spl.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\ns.lib&quot; &quot;..\thirdparties\win32\lib\libyuv\libyuv.lib&quot; &quot;..\thirdparties\win32\lib\vpx\vpxmt.lib&quot;"
LinkIncremental="2"
IgnoreDefaultLibraryNames="MSVCRT;LIBCMTD;LIBCMT"
GenerateDebugInformation="true"
@ -122,7 +122,7 @@
Name="VCCLCompilerTool"
Optimization="3"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\thirdparties\common\include;..\thirdparties\win32\include;include;..\tinyMSRP\include;..\tinyRTP\include;..\tinyMEDIA\include;..\tinySDP\include;..\tinyNET\src;..\tinySAK\src;..\thirdparties\win32\include\BroadVoice16\bvcommon;..\thirdparties\win32\include\BroadVoice16\bv16"
AdditionalIncludeDirectories="..\thirdparties\common\include;..\thirdparties\win32\include;include;..\tinyMSRP\include;..\tinyRTP\include;..\tinyMEDIA\include;..\tinySDP\include;..\tinyIPSec\src;..\tinyNET\src;..\tinySAK\src;..\thirdparties\win32\include\BroadVoice16\bvcommon;..\thirdparties\win32\include\BroadVoice16\bv16"
PreprocessorDefinitions="DEBUG_LEVEL=DEBUG_LEVEL_WARN;WIN32;NDEBUG;_WINDOWS;_USRDLL;TINYDAV_EXPORTS;HAVE_SRTP=1;HAVE_G729=0;HAVE_BV16=0;HAVE_H264=1;HAVE_OPENCORE_AMR=1;HAVE_ILBC=0;HAVE_LIBGSM=1;HAVE_LIBOPUS=1;HAVE_DSOUND_H=1;HAVE_WAVE_API=1;HAVE_FFMPEG=1;HAVE_WEBRTC=1;HAVE_SPEEX_DSP=1;HAVE_SPEEX_JB=1;HAVE_LIB_SPEEX=1;HAVE_LIBVPX=1;HAVE_LIBYUV=1;G192BITSTREAM=0;_WIN32_WINNT=0x0501"
RuntimeLibrary="2"
EnableFunctionLevelLinking="false"
@ -144,7 +144,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Winmm.lib Shlwapi.lib $(OutDir)\tinySAK.lib $(OutDir)\tinyNET.lib $(OutDir)\tinyRTP.lib $(OutDir)\tinyMSRP.lib $(OutDir)\tinySDP.lib $(OutDir)\tinyMEDIA.lib &quot;..\thirdparties\win32\lib\opus\libopus.a&quot; &quot;..\thirdparties\win32\lib\gsm\libgsm.a&quot; &quot;..\thirdparties\win32\lib\ilbc\libiLBC.a&quot; &quot;..\thirdparties\win32\lib\speex\libspeex.a&quot; &quot;..\thirdparties\win32\lib\speex\libspeexdsp.a&quot; ..\thirdparties\win32\lib\libgcc.a ..\thirdparties\win32\lib\libmingwex.a &quot;..\thirdparties\win32\lib\ffmpeg\libavcodec.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libavutil.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libswscale.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libx264.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libtheora.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libogg.a&quot; &quot;..\thirdparties\win32\lib\BroadVoice16\libbv16.a&quot; &quot;..\thirdparties\win32\lib\webrtc\aec.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\aec_sse2.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\apm_util.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\system_wrappers.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\spl.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\ns.lib&quot; &quot;..\thirdparties\win32\lib\libyuv\libyuv.lib&quot; &quot;..\thirdparties\win32\lib\vpx\vpxmt.lib&quot;"
AdditionalDependencies="Winmm.lib Shlwapi.lib $(OutDir)\tinySAK.lib $(OutDir)\tinyIPSec.lib $(OutDir)\tinyNET.lib $(OutDir)\tinyRTP.lib $(OutDir)\tinyMSRP.lib $(OutDir)\tinySDP.lib $(OutDir)\tinyMEDIA.lib &quot;..\thirdparties\win32\lib\opus\libopus.a&quot; &quot;..\thirdparties\win32\lib\gsm\libgsm.a&quot; &quot;..\thirdparties\win32\lib\ilbc\libiLBC.a&quot; &quot;..\thirdparties\win32\lib\speex\libspeex.a&quot; &quot;..\thirdparties\win32\lib\speex\libspeexdsp.a&quot; ..\thirdparties\win32\lib\libgcc.a ..\thirdparties\win32\lib\libmingwex.a &quot;..\thirdparties\win32\lib\ffmpeg\libavcodec.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libavutil.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libswscale.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libx264.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libtheora.a&quot; &quot;..\thirdparties\win32\lib\ffmpeg\libogg.a&quot; &quot;..\thirdparties\win32\lib\BroadVoice16\libbv16.a&quot; &quot;..\thirdparties\win32\lib\webrtc\aec.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\aec_sse2.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\apm_util.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\system_wrappers.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\spl.lib&quot; &quot;..\thirdparties\win32\lib\webrtc\ns.lib&quot; &quot;..\thirdparties\win32\lib\libyuv\libyuv.lib&quot; &quot;..\thirdparties\win32\lib\vpx\vpxmt.lib&quot;"
LinkIncremental="1"
IgnoreDefaultLibraryNames="MSVCRTD;LIBCMT"
GenerateDebugInformation="false"

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango telecom"
VALUE "FileDescription", "Doubango IMS Framework"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "tinydav.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "tinydav.dll"
VALUE "ProductName", "Doubango IMS Framework"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -14,7 +14,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyDEMO", "tinyDEMO.vcproj
{002FF064-588F-402E-A096-C8D033F49F40} = {002FF064-588F-402E-A096-C8D033F49F40}
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}
{76261DC8-25B3-43F4-9FB5-112C4AC0880E} = {76261DC8-25B3-43F4-9FB5-112C4AC0880E}
{0CCC02F1-4233-424F-AD5E-A021456E6E8D} = {0CCC02F1-4233-424F-AD5E-A021456E6E8D}
{9A3A5AF3-2333-4477-B880-7F901F9D8972} = {9A3A5AF3-2333-4477-B880-7F901F9D8972}
EndProjectSection
EndProject
@ -72,7 +71,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyDAV", "..\tinyDAV\tinyD
{99B7D02F-8C70-4B45-AF3C-92313C3CEE15} = {99B7D02F-8C70-4B45-AF3C-92313C3CEE15}
{7522A458-92F4-4259-B906-E84C2A65D9F1} = {7522A458-92F4-4259-B906-E84C2A65D9F1}
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}
{0CCC02F1-4233-424F-AD5E-A021456E6E8D} = {0CCC02F1-4233-424F-AD5E-A021456E6E8D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyRTP", "..\tinyRTP\tinyRTP.vcproj", "{99B7D02F-8C70-4B45-AF3C-92313C3CEE15}"
@ -87,12 +85,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySIGCOMP", "..\tinySIGCO
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyDSHOW", "..\tinyDSHOW\tinyDSHOW.vcproj", "{0CCC02F1-4233-424F-AD5E-A021456E6E8D}"
ProjectSection(ProjectDependencies) = postProject
{52814B0D-7DCA-45B8-9A16-8B147040D619} = {52814B0D-7DCA-45B8-9A16-8B147040D619}
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyMSRP", "..\tinyMSRP\tinyMSRP.vcproj", "{AA46AF16-9678-4054-8E48-98DC21ECEC82}"
ProjectSection(ProjectDependencies) = postProject
{E45DB518-6562-4033-80E8-60030F0B169F} = {E45DB518-6562-4033-80E8-60030F0B169F}
@ -200,12 +192,6 @@ Global
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Build.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{76261DC8-25B3-43F4-9FB5-112C4AC0880E}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Debug|Win32.ActiveCfg = Debug|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Debug|Win32.Build.0 = Debug|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Release|Win32.ActiveCfg = Release|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Release|Win32.Build.0 = Release|Win32
{0CCC02F1-4233-424F-AD5E-A021456E6E8D}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
{AA46AF16-9678-4054-8E48-98DC21ECEC82}.Debug|Win32.ActiveCfg = Debug|Win32
{AA46AF16-9678-4054-8E48-98DC21ECEC82}.Debug|Win32.Build.0 = Debug|Win32
{AA46AF16-9678-4054-8E48-98DC21ECEC82}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango telecom"
VALUE "FileDescription", "Doubango IMS Framework"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "tinyhttp.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "tinyhttp.dll"
VALUE "ProductName", "Doubango IMS Framework"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -0,0 +1 @@
AStyle.exe --style=k/r --lineend=linux --mode=c --add-brackets --break-closing-brackets --recursive "*.c" "*.h"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,218 @@
<doxygenlayout version="1.0">
<!-- Generated by doxygen 1.8.4 -->
<!-- Navigation index tabs for HTML output -->
<navindex>
<tab type="usergroup" url="@ref _Page_Main_Overview" title="Overview" />
<tab type="usergroup" url="[none]" title="Building source code">
<tab type="user" url="https://code.google.com/p/doubango/wiki/Building_Source_v2_0" title="Doubango VoIP Framework" />
<tab type="user" url="https://code.google.com/p/boghe/wiki/Building_Boghe_v2" title="Boghe IMS Client" />
</tab>
<tab type="usergroup" url="[none]" title="Samples code">
<tab type="user" url="@ref _Page_Main_Low_Level_Core_API_Overview" title="ANSI-C" />
<tab type="user" url="@ref _Page_Main_Low_Level_Core_API_Overview" title="C#" />
</tab>
<tab type="usergroup" url="https://code.google.com/p/boghe/downloads/list" title="Download Boghe IMS Client">
</tab>
<tab type="usergroup" url="@ref _Page_Main_FAQ" title="FAQ">
</tab>
<tab type="usergroup" url="[none]" title="References">
</tab>
<tab type="usergroup" url="https://groups.google.com/forum/#!forum/doubango" title="Getting help">
</tab>
<tab type="mainpage" visible="no" title=""/>
<tab type="pages" visible="no" title="" intro=""/>
<tab type="modules" visible="no" title="" intro=""/>
<tab type="namespaces" visible="no" title="">
<tab type="namespacelist" visible="no" title="" intro=""/>
<tab type="namespacemembers" visible="no" title="" intro=""/>
</tab>
<tab type="classes" visible="no" title="">
<tab type="classlist" visible="no" title="" intro=""/>
<!--tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/-->
<tab type="classindex" visible="no" title=""/>
<tab type="hierarchy" visible="no" title="" intro=""/>
<tab type="classmembers" visible="no" title="" intro=""/>
</tab>
<tab type="files" visible="no" title="">
<tab type="filelist" visible="no" title="" intro=""/>
<tab type="globals" visible="no" title="" intro=""/>
</tab>
<tab type="examples" visible="yes" title="" intro=""/>
</navindex>
<!-- Layout definition for a class page -->
<class>
<briefdescription visible="yes"/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<inheritancegraph visible="$CLASS_GRAPH"/>
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
<memberdecl>
<nestedclasses visible="yes" title=""/>
<publictypes title=""/>
<services title=""/>
<interfaces title=""/>
<publicslots title=""/>
<signals title=""/>
<publicmethods title=""/>
<publicstaticmethods title=""/>
<publicattributes title=""/>
<publicstaticattributes title=""/>
<protectedtypes title=""/>
<protectedslots title=""/>
<protectedmethods title=""/>
<protectedstaticmethods title=""/>
<protectedattributes title=""/>
<protectedstaticattributes title=""/>
<packagetypes title=""/>
<packagemethods title=""/>
<packagestaticmethods title=""/>
<packageattributes title=""/>
<packagestaticattributes title=""/>
<properties title=""/>
<events title=""/>
<privatetypes title=""/>
<privateslots title=""/>
<privatemethods title=""/>
<privatestaticmethods title=""/>
<privateattributes title=""/>
<privatestaticattributes title=""/>
<friends title=""/>
<related title="" subtitle=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<inlineclasses title=""/>
<typedefs title=""/>
<enums title=""/>
<services title=""/>
<interfaces title=""/>
<constructors title=""/>
<functions title=""/>
<related title=""/>
<variables title=""/>
<properties title=""/>
<events title=""/>
</memberdef>
<allmemberslink visible="yes"/>
<usedfiles visible="$SHOW_USED_FILES"/>
<authorsection visible="yes"/>
</class>
<!-- Layout definition for a namespace page -->
<namespace>
<briefdescription visible="yes"/>
<memberdecl>
<nestednamespaces visible="yes" title=""/>
<constantgroups visible="yes" title=""/>
<classes visible="yes" title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<inlineclasses title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection visible="yes"/>
</namespace>
<!-- Layout definition for a file page -->
<file>
<briefdescription visible="yes"/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<includegraph visible="$INCLUDE_GRAPH"/>
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
<sourcelink visible="yes"/>
<memberdecl>
<classes visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<constantgroups visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<inlineclasses title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection/>
</file>
<!-- Layout definition for a group page -->
<group>
<briefdescription visible="yes"/>
<groupgraph visible="$GROUP_GRAPHS"/>
<memberdecl>
<nestedgroups visible="yes" title=""/>
<dirs visible="yes" title=""/>
<files visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<classes visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<pagedocs/>
<inlineclasses title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
</memberdef>
<authorsection visible="yes"/>
</group>
<!-- Layout definition for a directory page -->
<directory>
<briefdescription visible="yes"/>
<directorygraph visible="yes"/>
<memberdecl>
<dirs visible="yes"/>
<files visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
</directory>
</doxygenlayout>

View File

@ -3,11 +3,7 @@ libtinyIPSec_la_LIBADD = ../tinySAK/libtinySAK.la
libtinyIPSec_la_CPPFLAGS = -I../tinySAK/src -Isrc
libtinyIPSec_la_SOURCES = \
src/tipsec.c\
src/tipsec_common.c\
src/tipsec_racoon.c\
src/tipsec_vista.c\
src/tipsec_xp.c
src/tipsec.c
# LDFLAGS
libtinyIPSec_la_LDFLAGS = $LDFLAGS -no-undefined

View File

@ -6,11 +6,7 @@ LDFLAGS := -ltinySAK_$(MARCH) $(LDFLAGS_LIB)
all: $(APP)
OBJS = \
src/tipsec.o\
src/tipsec_common.o\
src/tipsec_racoon.o\
src/tipsec_vista.o\
src/tipsec_xp.o
src/tipsec.o
$(APP): $(OBJS)

View File

@ -0,0 +1,339 @@
/**@page _Page_Main_Overview Overview
This page is about the <b>open source 3GPP IMS-IPSec implementation</b> in <a target=_blank href="https://code.google.com/p/doubango/">Doubango VoIP framework</a> from <a target=_blank href="http://doubango.org/">Doubango Telecom</a>. <br />
In this page we'll try to explain how security mechanisms are negotiated between an IMS Client and the Proxy-CSCF and how to setup SAs using <a href="http://ipsec-tools.sourceforge.net/"> Linux IPSec-Tools</a> and our demo clients (console app and <a href="https://code.google.com/p/boghe/">Boghe IMS Client</a>). <br />
Our code have been fully tested against <a href="http://www.openimscore.org/">OpenIMSCore</a> and many other comercial IMS Cores. <br />
- @ref _Anchor_TIPSec_Overview_Intro "1/ IPSec implementation in Doubango VoIP framework"
- @ref _Anchor_TIPSec_Overview_SecAgree "2/ Security agreement"
- @ref _Anchor_TIPSec_Overview_SecAgree_CallFlow "2.1/ Call flow"
- @ref _Anchor_TIPSec_Overview_SecAgree_SipMessages "2.3/ SIP messages"
- @ref _Anchor_TIPSec_Overview_IPSecTools "3/ Setting up SAs using Linux Tools"
- @ref _Anchor_TIPSec_Overview_IPSecAPI "4/ Using tinyIPSec API"
- @ref _Anchor_TIPSec_Overview_IPSecAPI_LoadPlugin "4.1/ Loading the Plugin"
- @ref _Anchor_TIPSec_Overview_IPSecAPI_Client "4.2/ Client-side API"
<h2>@anchor _Anchor_TIPSec_Overview_Intro 1/ IPSec implementation in Doubango VoIP framework</h2>
The IPSec implementation in Doubango VoIP framework is distributed as standalone plugins (<b>pluginWinIPSecVista.DLL</b>, <b>pluginWinIPSecXP.DLL</b> and <b>pluginWinIPSecLinux.SO</b>).
This allows having a single installer for all platforms as the right implementation is loaded at runtime (versus at link-time). Right now only <b>pluginWinIPSecVista.DLL</b> is open sourced. <br />
<b>pluginWinIPSecVista.DLL</b> as it's name says, requires Windows Vista or later and uses <a href="http://msdn.microsoft.com/en-us/windows/hardware/gg463267.aspx">Windows Filtering Platform</a> to manually setup the IPSec SAs. <br />
<b>pluginWinIPSecVista.DLL</b> supports:
<ul>
<li>IPProto: "udp", "tcp" and "icmp"</li>
<li>Modes: "tun" (tunnel) and "trans" (transport)</li>
<li>Encryption algorithm: "des-ede3-cbc", "aes-cbc" and "null"</li>
<li>Authentication algorithm: "hmac-sha-1-96" and "hmac-md5-96"</li>
<li>IPsecProto:"esp", "ah" and "ah/esp"</li>
</ul>
The utility functions used to load/unload the plugins and the wrappers for the high level APIs are in <b>tinyIPSec</b> project. <b>tinyIPSec</b> depends on <b>tinySAK </b>. <br />
The framework implements: 3GPP TS 24.229, 3GPP TS 35.205, 3GPP TS 35.206, 3GPP TS 35.207, 3GPP TS 35.208, 3GPP TS 35.909, RFC 3329.
<h2>@anchor _Anchor_TIPSec_Overview_SecAgree 2/ Security agreement</h2>
The main purpose of Security agreement (<a href="http://www.ietf.org/rfc/rfc3329.txt">RFC 3329</a>) is to agree on which mechanisms, algorithms or security parameters to use.
There are five main mechanisms used in VoIP networks: <br />
<ul>
<li>digest</li>
<li>tls</li>
<li>ipsec-ike</li>
<li>ipsec-man</li>
<li><b>ipsec-3gpp</b></li>
</ul>
We will focus on <b>ipsec-3gpp</b> because it's <b>mandatory</b> for IMS. This requires SIP <b>AKAv1/v2</b> authentication. <br />
The security mechanism to use is known after the negotiation between the IMS Client and the Proxy-CSCF succeeds. This negotiation is performed during the IMS registration and authentication procedures.
Three new SIP header fields have been defined, namely <b>Security-Client</b>, <b>Security-Server</b> and <b>Security-Verify</b>.
<h3>@anchor _Anchor_TIPSec_Overview_SecAgree_CallFlow 2.1/ Call flow</h3>
@code
IMS Client P-CSCF S-CSCF
| | |
|----(1)REGISTER---->| |
| | |
| |---(2)REGISTER--->|
| | |
| |<-----(3) 401 ----|
| | |
|<----(4) 494/401----| |
| | |
|<==IPSec in place==>| |
| | |
|----(5)REGISTER---->| |
| |----(6)REGISTER-->|
| | |
| |<---(7) 200 OK----|
|<---(8) 200 OK------| |
| | |
@endcode
- In step <b>(1)</b> the IMS Client sends an unprotected registration request including the security-client header. The Client must indicate that it is able to negotiate security mechanism by adding "Require" and "Proxy-Require" headers. The security-client header includes two ports (client and server ports) that the client wants to negotiate with the proxy CSCF.
- In step <b>(2)</b> the Proxy CSCF forwards the request to the Serving CSCF.
- In step <b>(3)</b> the Serving CSCF (registrar) challenges the Proxy CSCF. The 401 response is sent to the Proxy CSCF (challenge parameters are under WWW-Authenticated header). The Serving CSCF must include the "Security-Server" header.
- In step <b>(4)</b> the Proxy CSCF forwards the 401/494 response to the IMS Client. At this stage the Proxy CSCF opens the IPsec security association (SA) for the IMS Client. The IMS Client also setup a SA (this is a temporary SA).
- The lifetime of the created SA (between the IMS Client and the Proxy CSCF) is equal to the value of reg-await-auth timer.
- In step <b>(5)</b> the IMS Client sends a new registration (to the Proxy CSCF) request including its credentials and copies the content of security-server header to the security-verify header. Before forwarding the request to the Serving CSCF, the Proxy CSCF will check that the previous security-server header and the security-verify headers (added by the IMS Client) are the same. If these values are different, the Proxy CSCF sends an error message to the IMS Client and terminates the created SAs.
- In step <b>(6)</b> the Proxy CSCF forwards the request to the Serving CSCF.
- In step <b>(7)</b> the Serving CSCF authenticates the IMS Client, and responds with 200 OK.
- In step <b>(8)</b> the Proxy CSCF forwards the response to the IMS Client. At this step new SAs will be created. The temporary SAs will be destroyed (or not) by the Proxy CSCF.
<h3>@anchor _Anchor_TIPSec_Overview_SecAgree_SipMessages 2.3/ SIP messages</h3>
<b>(1)</b><br />
@code
REGISTER sip:pcscf.open-ims.test SIP/2.0
Security-Client: ipsec-3gpp; alg=hmac-md5-96; ealg=des-ede3-cbc; prot=ah; mod=trans; spi-c=1111; spi-s=2222; port-c=5062; port-s=5064
Require: sec-agree
Proxy-Require: sec-agree
@endcode
<b>(4)</b>
@code
SIP/2.0 [494 Security Agreement Required / 401 Unauthorized]
Security-Server: ipsec-3gpp; q=0.1; alg=hmac-md5-96; ealg=des-ede3-cbc; prot=ah; mod=trans; spi-c=3333; spi-s=4444; port-c=5066; port-s=5068
@endcode
<b>(5)</b><br />
@code
REGISTER sip:pcscf.open-ims.test SIP/2.0
Security-Client: ipsec-3gpp; alg=hmac-md5-96; ealg=des-ede3-cbc; prot=ah; mod=trans; spi-c=1111; spi-s=2222; port-c=5062; port-s=5064
Security-Verify: ipsec-3gpp; q=0.1; alg=hmac-md5-96; ealg=des-ede3-cbc; prot=ah; mod=trans; spi-c=3333; spi-s=4444; port-c=5066; port-s=5068
Require: sec-agree
Proxy-Require: sec-agree
@endcode
<h2>@anchor _Anchor_TIPSec_Overview_IPSecTools 3/ Setting up SAs using Linux Tools</h2>
Here we suppose that: <br />
- We are using Ubuntu (Linux Kernel 2.6 + KAME-tools)
- the Proxy-CSCF address is '192.168.0.10' and Mercuro IMS Client address is '192.168.0.11'
- for secure ports see above SIP capture
- protocol is esp
- algorithm is 'hmac-md5'
- encrypt-algorithm is 'des-ede3-cbc'
- mode is 'transport'
- confidentiality key is '123456789012123456789012' (see function f2345 in 3GPP milenage algorithms)
- integrity key is '1234567890123456' (see function f2345 in 3GPP milenage algorithms)
<b>1. Install the tools</b>
@code
sudo apt-get install ipsec-tools
@endcode
<b>2. Edit /etc/ipsec-tools file and add the following script</b>
@code
#Incoming Requests [US <- PC]
spdadd 192.168.0.10/32[5066] 192.168.0.11/32[5064] udp -P in ipsec esp/transport//require;
add 192.168.0.10 192.168.0.11 esp 2222 -m transport -E des-ede3-cbc "123456789012123456789012" -A hmac-md5 "1234567890123456";
#Incoming Replies [UC <- PS]
spdadd 192.168.0.10/32[5068] 192.168.0.11/32[5062] udp -P in ipsec esp/transport//require;
add 192.168.0.10 192.168.0.11 esp 1111 -m transport -E des-ede3-cbc "123456789012123456789012" -A hmac-md5 "1234567890123456";
#Outgoing Requests [UC -> PS]
spdadd 192.168.0.11/32[5062] 192.168.0.10/32[5068] udp -P out ipsec esp/transport//unique:1;
add 192.168.0.11 192.168.0.10 esp 4444 -m transport -u 1 -E des-ede3-cbc "123456789012123456789012" -A hmac-md5 "1234567890123456";
#Outgoing Replies [US -> PC]
spdadd 192.168.0.11/32[5064] 192.168.0.10/32[5066] udp -P out ipsec esp/transport//unique:2;
add 192.168.0.11 192.168.0.10 esp 3333 -m transport -u 2 -E des-ede3-cbc "123456789012123456789012" -A hmac-md5 "1234567890123456";
@endcode
<b>3. Run the script</b>
@code
sudo /etc/init.d/setkey start
@endcode
<h2>@anchor _Anchor_TIPSec_Overview_IPSecAPI 4/ Using tinyIPSec API</h2>
This section explain how to setup the IPSec SAs using our API for a client (for the server it's obvisious). The values (SPIs, Ports, IP addresses...) are from previous sections. <br />
In this section:
- <b>UC</b> means UE acting as client (i.e sending a SIP request)
- <b>US</b> means UE acting as server (i.e receiving a SIP request)
- <b>PC</b> means P-CSCF acting as client (i.e sending a SIP request)
- <b>PS</b> means P-CSCF acting as server (i.e receiving a SIP request)
- <b>PORT-C</b> means port used by UC or PC
- <b>PORT-S</b> means port used by US or PS
- <a href="http://en.wikipedia.org/wiki/Security_Parameter_Index">SPI</a> means <b>S</b>ecurity <b>P</b>arameter <b>I</b>ndex (more info: <a href="http://en.wikipedia.org/wiki/Security_Parameter_Index">http://en.wikipedia.org/wiki/Security_Parameter_Index</a>)
- <b>SPI-C</b> means SPI for PORT-C
- <b>SPI-S</b> means SPI for PORT-S
<b>/!\\VERY IMPORTANT:</b> On Windows the application (or Visual Studio if you're debugging the code) must be started as "Administrator" (Right click then <b>Run as administrator</b>) to be autorized to setup IPSec SAs (otherwise <b>error code 5</b>).
<h3>@anchor _Anchor_TIPSec_Overview_IPSecAPI_LoadPlugin 4.1/ Loading the Plugin</h3>
Before calling any API function from <b>tinyIPSec</b> it's required to load the standalone plugin like this:
@code
#include "tipsec.h"
static tsk_bool_t __b_ipsec_supported = tsk_false;
static struct tsk_plugin_s* __dll_plugin_ipsec_wfp = tsk_null;
if(tdav_win32_is_winvista_or_later()){
char* full_path = tsk_null;
tsk_sprintf(&full_path, "%s/pluginWinIPSecVista.dll", tdav_get_current_directory_const());
if (tsk_plugin_file_exist(full_path) && (tipsec_plugin_register_file(full_path, &__dll_plugin_ipsec_wfp) == 0)){
__b_ipsec_supported = tsk_true;
}
TSK_FREE(full_path);
}
@endcode
To unload the plugin:
@code
if (__dll_plugin_ipsec_wfp) {
tipsec_plugin_unregister_file(__dll_plugin_ipsec_wfp);
TSK_OBJECT_SAFE_FREE(__dll_plugin_ipsec_wfp); // free and set the pointer to NULL
}
@endcode
<h3>@anchor _Anchor_TIPSec_Overview_IPSecAPI_Client 4.2/ Client-side API</h3>
<b>1) Create a context</b>
@code
tipsec_error_t err;
tipsec_ctx_t* p_ctx = tsk_null;
err = tipsec_ctx_create(
tipsec_ipproto_udp, // IPProto
tsk_false, // Whether to use IPv6
tipsec_mode_trans, // Mode
tipsec_ealg_des_ede3_cbc, // Encryption algo
tipsec_alg_hmac_md5_96, // Authentication algo
tipsec_proto_ah, // IPSec proto
&p_ctx);
if (err) {
exit(-1);
}
@endcode
Because <a href="http://msdn.microsoft.com/en-us/windows/hardware/gg463267.aspx">Windows Filtering Platform</a> doesn't allow setting arbitrary SPIs we must create temporary SAs in order to have client SPIs for the initial REGISTER request.
Temporary SAs requires information about the local address and ports. Remote port is not required but expected for better filtering to avoid IPSec restrictions for <b>any</b> in/out data towards the local ports. <br />
<b>2) Create temporary SAs and request local SPIs</b>
@code
err = tipsec_ctx_set_local(
p_ctx,
"192.168.0.11", // Local IPv4 address (UE)
"192.168.0.10", // Remote IPv4 address (P-CSCF)
5062, // Port used for outgoing data (UE, PORT-C, SPI-C)
5064 // Port used for incoming data (UE, PORT-S, SPI-S)
);
if (err) {
exit(-1);
}
@endcode
To create the <b>Security-Client</b> header for the initial REGISTER request:
@code
char* str_sec_client = tsk_null;
// Security-Client: ipsec-3gpp; alg=hmac-md5-96; ealg=des-ede3-cbc; prot=ah; mod=trans; spi-c=1111; spi-s=2222; port-c=5062; port-s=5064
tsk_sprintf(&str_sec_client, "Security-Client: ipsec-3gpp; alg=%s; ealg=%s; prot=%s; mod=%s; spi-c=%u; spi-s=%u; port-c=%u; port-s=%u",
TIPSEC_ALG_TO_STR(p_ctx->alg),
TIPSEC_EALG_TO_STR(p_ctx->ealg),
TIPSEC_PROTOCOL_TO_STR(p_ctx->protocol),
TIPSEC_MODE_TO_STR(p_ctx->mode),
p_ctx->spi_uc,
p_ctx->spi_us,
p_ctx->port_uc,
p_ctx->port_us);
@endcode
Now you can send the initial REGISTER (unprotected).
<b>3) Setting remote information</b>
Once the initial REGISTER is sent the server will send back a 494 response with one or several <b>Security-Server</b> headers. Select the best one and extract the information (SPIs, Ports, alogs,...) from it:
@code
err = tipsec_ctx_set_remote(
p_ctx,
3333, // SPI-C for the P-CSCF
4444, // SPI-S for the P-CSCF
5066, // PORT-C for the P-CSCF
5068, // PORT-S for the P-CSCF
1800 // lifetime (in seconds) (at least the registration timeout)
);
if (err) {
exit(-1);
}
@endcode
<b>At this step, any data sent using PORT-C or receieved using PORT-S is (and must be) encrypted.</b>
<b>4) Setting the CK and IK keys</b>
The CK (Confidentiality) and IK (Integrity) keys are computed using the 3GPP milenage functions like this: <a href="https://code.google.com/p/doubango/source/browse/branches/2.0/doubango/tinySIP/src/authentication/tsip_challenge.c?r=765#85">https://code.google.com/p/doubango/source/browse/branches/2.0/doubango/tinySIP/src/authentication/tsip_challenge.c?r=765#85</a>. <br />
To set the keys:
@code
err = tipsec_ctx_set_keys(
p_ctx,
"1234567890123456", // IK
"123456789012123456789012" // CK
);
if (err) {
exit(-1);
}
@endcode
<b>5) Ensure the IPSec SAs</b>
Ensure (promote) the temporary SAs:
@code
err = tipsec_ctx_start(p_ctx);
if (err) {
exit(-1);
}
@endcode
to destroy IPSec SAs:
@code
TSK_OBJECT_SAFE_FREE(p_ctx); // call "stop(p_ctx)" then "free(p_ctx)"
@endcode
Et voilà, you're ready to send (port-c) and receive (port-s) IPSec data. <br />
If you have any issue please check the @ref _Page_Main_FAQ "FAQ".
*/
/**@page _Page_Main_FAQ (FAQ)
- @ref _Anchor_TIPSec_FAQ_Stable "Is IPSec implementation in Doubango stable?"
- @ref _Anchor_TIPSec_FAQ_Systems "Which operating systems are supported?"
- @ref _Anchor_TIPSec_FAQ_Logs "Where are Boghe logs?"
- @ref _Anchor_TIPSec_FAQ_ReportIssues "I'm using Boghe IMS Client to test IPSec but it's not working. How to report issues?"
- @ref _Anchor_TIPSec_FAQ_CheckSAs "How to check SAs are up?"
- @ref _Anchor_TIPSec_FAQ_Error5 "I see \"Error code 5\" when I try to setup a SA. How can I fix this?"
<h2>@anchor _Anchor_TIPSec_FAQ_Stable Is IPSec implementation in Doubango stable?</h2>
Our IPSec implementation is <b>3 years old</b> and have been tested against OpenIMSCore and many other IMS Cores. <br />
By default, IPSec was desabled and it was up to the developer to rebuild the code to enable it. The new code is also clean and use standalone plugins.
<h2>@anchor _Anchor_TIPSec_FAQ_Systems Which operating systems are supported?</h2>
For now only <b>Windows Vista and later</b>. We've code for <b>Windows XP</b> and <b>Linux</b> but it's not published yet. <br />
Ask on our <a href="https://groups.google.com/forum/#!forum/doubango">dev-group</a> to get the complete source code.
<h2>@anchor _Anchor_TIPSec_FAQ_Logs Where are Boghe logs?</h2>
On vista: C:\\Users\\your identity here\\AppData\\Roaming\\Doubango\\Boghe IMS Client\\Boghe.log.
<h2>@anchor _Anchor_TIPSec_FAQ_ReportIssues I'm using Boghe IMS Client to test IPSec but it's not working. How to report issues?</h2>
Make sure that you're:
- using the latest <a href="https://code.google.com/p/boghe/downloads/list">Boghe</a> version (December 2013)
- using Windows Vista or later
- started the app as administrator (right click then, "Run as administrator") or disabled UAC
If you still have problems then, share them on our <a href="https://groups.google.com/forum/#!forum/doubango">dev-group</a>. You <b>must</b> share your @ref _Anchor_TIPSec_FAQ_Logs "logs".
<h2>@anchor _Anchor_TIPSec_FAQ_CheckSAs How to check SAs are up?</h2>
Go to "Control Panel" -> "Administrative Tools" -> "Windows Firewall with Advanced Security" -> "Security Associations" -> "Quick Mode" and check that your SAs are listed there.
<h2>@anchor _Anchor_TIPSec_FAQ_Error5 I see "Error code 5" when I try to setup a SA. How can I fix this?</h2>
On Windows, error code 5 means "Access denied". You must start your app (or Visual Studio) as administrator or disable the UAC.
*/
/**@page _Page_Main_Medium_Level_API_Overview Medium level API (C++)
bla bla bla
*/

View File

@ -1,25 +1,21 @@
/*
* Copyright (C) 2010-2011 Mamadou Diop.
/* Copyright (C) 2010-2014 Mamadou DIOP
* Copyright (C) 2011-2014 Doubango Telecom <http://www.doubango.org>
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]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 TINYIPSEC_CONFIG_H
#define TINYIPSEC_CONFIG_H
@ -48,13 +44,13 @@
# define TINYIPSEC_GEXTERN extern
#endif
/* Guards against C++ name mangling
/* Guards against C++ name mangling
*/
#ifdef __cplusplus
# define TIPSEC_BEGIN_DECLS extern "C" {
# define TIPSEC_END_DECLS }
#else
# define TIPSEC_BEGIN_DECLS
# define TIPSEC_BEGIN_DECLS
# define TIPSEC_END_DECLS
#endif
@ -80,7 +76,7 @@
#if HAVE_CONFIG_H
#include <config.h>
#include <config.h>
#endif
#endif /* TINYIPSEC_CONFIG_H */

View File

@ -1,47 +1,322 @@
/*
* Copyright (C) 2010-2011 Mamadou Diop.
/* Copyright (C) 2010-2014 Mamadou DIOP
* Copyright (C) 2011-2014 Doubango Telecom <http://www.doubango.org>
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]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.
*
*/
/**@file tipsec.c
* @brief IPSec manager.
* @brief IPSec plugin and context managers.
*
* @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
*
*/
#include "tipsec.h"
/** @mainpage TinyIPSec API Overview
*
* This file is an overview of TinyIPSec API.
*
* <b>tinyIPSec</b> is responsible for IPSec SAs managment. It is used in conjunction with security agreement mechanism (RFC 3329)
* to create, manage and terminate SAs. <br>
*
* @par Getting started
*
* - @ref tipsec_common_group
*
* - @ref tipsec_xp_group
* - @ref tipsec_vista_group
* - @ref tipsec_racoon_group
*
#include "tsk_plugin.h"
#include "tsk_debug.h"
/** Max number of plugins (consumer types) we can create */
#if !defined(TIPSEC_MAX_PLUGINS)
# define TIPSEC_MAX_PLUGINS 0x04
#endif /* TIPSEC_MAX_PLUGINS */
/* pointer to all registered consumers */
static const tipsec_plugin_def_t* __tipsec_plugins[TIPSEC_MAX_PLUGINS] = { tsk_null };
/**
* Create an IPSec context to manage the SAs.
* Before calling this function at least one special implementation must be registered using @ref tipsec_plugin_register_static().
* @param ipproto IPSec internet protocol.
* @param use_ipv6 Whether to use IPv6 or not (IPv4).
* @param mode IPSec mode.
* @param ealg IPSec encryption algorithm.
* @param alg IPSec algorithm.
* @param protocol IPSec protocol.
* @param pp_ctx Pointer holding the newly created context. Valid only if the retured code is @ref tipsec_error_success. This object must be destroyed using @a TSK_OBJECT_SAFE_FREE().
* @retval @ref tipsec_error_success if no error; otherwise error code.
*/
tipsec_error_t tipsec_ctx_create(
tipsec_ipproto_t ipproto,
tsk_bool_t use_ipv6,
tipsec_mode_t mode,
tipsec_ealg_t ealg,
tipsec_alg_t alg,
tipsec_proto_t protocol,
tipsec_ctx_t** pp_ctx)
{
tipsec_error_t err = tipsec_error_success;
tsk_size_t i = 0;
const tipsec_plugin_def_t* pc_plugin;
tipsec_ctx_t* p_ctx = tsk_null;
if (!pp_ctx || *pp_ctx) {
TSK_DEBUG_ERROR("Invalid parameter");
return tipsec_error_invalid_param;
}
// Create the context using the plugins registry
while ((i < TIPSEC_MAX_PLUGINS) && (pc_plugin = __tipsec_plugins[i++])) {
if (pc_plugin->objdef) {
if ((p_ctx = tsk_object_new(pc_plugin->objdef))) {
/* initialize the newly IPSec context */
p_ctx->pc_plugin = pc_plugin;
p_ctx->initialized = 0;
p_ctx->started = 0;
p_ctx->state = tipsec_state_initial;
p_ctx->use_ipv6 = use_ipv6;
p_ctx->mode = mode;
p_ctx->ealg = ealg;
p_ctx->alg = alg;
p_ctx->protocol = protocol;
break;
}
}
}
// Initialize the newly created context
err = pc_plugin->init(p_ctx);
if (err) {
goto bail;
}
bail:
if (err) {
TSK_OBJECT_SAFE_FREE(p_ctx);
}
*pp_ctx = p_ctx;
return err;
}
/**
* Ensure the SAs. This function must be called before sending/receiving any data.
* @param p_ctx Pointer to a context created using @ref tipsec_ctx_create().
* @retval @ref tipsec_error_success if no error; otherwise error code.
*/
tipsec_error_t tipsec_ctx_start(tipsec_ctx_t* p_ctx)
{
if (!p_ctx || !p_ctx->pc_plugin) {
TSK_DEBUG_ERROR("Invalid parameter");
return tipsec_error_invalid_param;
}
if (!p_ctx->initialized || p_ctx->state != tipsec_state_full) {
TSK_DEBUG_ERROR("Invalid state (not initialized or not in full state)");
return tipsec_error_invalid_state;
}
return p_ctx->pc_plugin->start(p_ctx);
}
/**
* Set local information. On windows Vista and later this function must be called to request local SPIs.
* @param p_ctx Pointer to a context created using @ref tipsec_ctx_create().
* @param addr_local Local IP address (e.g. "192.168.0.5"). The IP version depends on whether @a use_param (0 or 1) when @ref tipsec_ctx_create() was used to create the context.
* @param addr_remote Remote IP address (e.g. "192.168.0.5"). The IP version depends on whether @a use_param (0 or 1) when @ref tipsec_ctx_create() was used to create the context.
* @param port_uc Local client port used to send data. Must be within [1024-65535].
* @param port_us Local server port used to received data. Must be within [1024-65535].
* @retval @ref tipsec_error_success if no error; otherwise error code.
*/
tipsec_error_t tipsec_ctx_set_local(tipsec_ctx_t* p_ctx, const char* addr_local, const char* addr_remote, tipsec_port_t port_uc, tipsec_port_t port_us)
{
if (!p_ctx || !p_ctx->pc_plugin || !addr_local || !addr_remote || port_uc < 1024 || port_us < 1024) {
TSK_DEBUG_ERROR("Invalid parameter");
return tipsec_error_invalid_param;
}
if (!p_ctx->initialized || p_ctx->state != tipsec_state_initial) {
TSK_DEBUG_ERROR("Invalid state (not initialized or not in initial state)");
return tipsec_error_invalid_state;
}
return p_ctx->pc_plugin->set_local(p_ctx, addr_local, addr_remote, port_uc, port_us);
}
/**
* Set Integrity (IK) and Confidentiality (CK) Keys.
* On the UE, the IK and CK are built using the "nonce" value using the 494 from the P-CSCF which means the function must be called after the REGISTER<->494 round trip.
* @param p_ctx Pointer to a context created using @ref tipsec_ctx_create().
* @param ik The Integrity Key.
* @param ck The Confidentiality Key.
* @retval @ref tipsec_error_success if no error; otherwise error code.
*/
tipsec_error_t tipsec_ctx_set_keys(tipsec_ctx_t* p_ctx, const tipsec_key_t* ik, const tipsec_key_t* ck)
{
if (!p_ctx || !p_ctx->pc_plugin || !ik || !ck) {
TSK_DEBUG_ERROR("Invalid parameter");
return tipsec_error_invalid_param;
}
return p_ctx->pc_plugin->set_keys(p_ctx, ik, ck);
}
/**
* Set the remote information.
* @param p_ctx Pointer to a context created using @ref tipsec_ctx_create().
* @param spi_pc Remote client SPI (Security Parameter Index) used by the remote party to send data.
* @param spi_ps Remote server SPI (Security Parameter Index) used by the remote party to receive data.
* @param port_pc Remote client port used by the remote party to send data. Must be within [1024-65535].
* @param port_ps Remote server port used by the remote party to receive data. Must be within [1024-65535].
* @param lifetime The SA lifetime (in seconds). Must not be null. Should be 2xSipRegistrationTimeout. On Windows vista and later, the maximum allowed value is @a 172799 seconds.
* @retval @ref tipsec_error_success if no error; otherwise error code.
*/
tipsec_error_t tipsec_ctx_set_remote(tipsec_ctx_t* p_ctx, tipsec_spi_t spi_pc, tipsec_spi_t spi_ps, tipsec_port_t port_pc, tipsec_port_t port_ps, tipsec_lifetime_t lifetime)
{
if (!p_ctx || !p_ctx->pc_plugin || port_pc < 1024 || port_ps < 1024 || !lifetime) {
TSK_DEBUG_ERROR("Invalid parameter");
return tipsec_error_invalid_param;
}
if (!p_ctx->initialized || p_ctx->state != tipsec_state_inbound) {
TSK_DEBUG_ERROR("Invalid state (not initialized or not in initial state)");
return tipsec_error_invalid_state;
}
return p_ctx->pc_plugin->set_remote(p_ctx, spi_pc, spi_ps, port_pc, port_ps, lifetime);
}
/**
* Shutdown all SAs associated to this context. It's no longer allowed to send/recv data after calling this function.
* @param p_ctx Pointer to a context created using @ref tipsec_ctx_create().
* @retval @ref tipsec_error_success if no error; otherwise error code.
*/
tipsec_error_t tipsec_ctx_stop(tipsec_ctx_t* p_ctx)
{
if (!p_ctx || !p_ctx->pc_plugin) {
TSK_DEBUG_ERROR("Invalid parameter");
return tipsec_error_invalid_param;
}
return p_ctx->pc_plugin->stop(p_ctx);
}
/**
* Register an IPSec special implementation (e.g. Windows XP, Windows Vista or Linux IPSec-Tools) using a static definition.
* @param pc_plugin pointer to the static definition.
* @retval @ref tipsec_error_success if no error; otherwise error code.
* @sa @ref tipsec_plugin_unregister_static(), @ref tipsec_plugin_unregister_file()
*/
tipsec_error_t tipsec_plugin_register_static(const tipsec_plugin_def_t* pc_plugin)
{
tsk_size_t i;
if (!pc_plugin) {
TSK_DEBUG_ERROR("Invalid parameter");
return tipsec_error_invalid_param;
}
/* add or replace the plugin */
for (i = 0; i < TIPSEC_MAX_PLUGINS; ++i) {
if (!__tipsec_plugins[i] || (__tipsec_plugins[i] == pc_plugin)) {
__tipsec_plugins[i] = pc_plugin;
TSK_DEBUG_INFO("Register IPSec implementation: %s", pc_plugin->desc);
return tipsec_error_success;
}
}
TSK_DEBUG_ERROR("There are already %d plugins.", TIPSEC_MAX_PLUGINS);
return tipsec_error_outofbound;
}
/**
* UnRegister an IPSec special implementation (e.g. Windows XP, Windows Vista or Linux IPSec-Tools) using a static definition.
* @param pc_plugin pointer to the static definition.
* @retval @ref tipsec_error_success if no error; otherwise error code.
* @sa @ref tipsec_plugin_register_static(), @ref tipsec_plugin_register_file()
*/
tipsec_error_t tipsec_plugin_unregister_static(const tipsec_plugin_def_t* pc_plugin)
{
tsk_size_t i;
tsk_bool_t b_found = tsk_false;
if (!pc_plugin) {
TSK_DEBUG_ERROR("Invalid parameter");
return tipsec_error_invalid_param;
}
/* find the plugin to unregister */
for (i = 0; i < TIPSEC_MAX_PLUGINS && __tipsec_plugins[i]; ++i) {
if (__tipsec_plugins[i] == pc_plugin) {
__tipsec_plugins[i] = tsk_null;
b_found = tsk_true;
TSK_DEBUG_INFO("UnRegister IPSec implementation: %s", pc_plugin->desc);
break;
}
}
/* compact */
if (b_found) {
for (; i < (TIPSEC_MAX_PLUGINS - 1); ++i) {
if (__tipsec_plugins[i+1]) {
__tipsec_plugins[i] = __tipsec_plugins[i + 1];
}
else {
break;
}
}
__tipsec_plugins[i] = tsk_null;
}
return (b_found ? tipsec_error_success : tipsec_error_notfound);
}
/**
* Register an IPSec special implementation (e.g. Windows XP, Windows Vista or Linux IPSec-Tools) using a shared library (*.DLL, *.SO).
* @param pc_filepath Path to the plugin.
* @param pp_plugin Pointer to the newly created plugin. You must call @ref tipsec_plugin_unregister_file() when you no longer need to use the plugin.
* @retval @ref tipsec_error_success if no error; otherwise error code.
* @sa @ref tipsec_plugin_unregister_static(), @ref tipsec_plugin_unregister_file()
*/
tipsec_error_t tipsec_plugin_register_file(const char* pc_filepath, struct tsk_plugin_s** pp_plugin)
{
struct tsk_plugin_s* p_plugin = tsk_null;
tsk_plugin_def_ptr_const_t p_def;
tipsec_error_t err;
int i = 0, count = 0;
p_plugin = tsk_plugin_create(pc_filepath);
if (!p_plugin) {
return tipsec_error_notfound;
}
while ((p_def = tsk_plugin_get_def_2(p_plugin, tsk_plugin_def_type_ipsec, tsk_plugin_def_media_type_all, i++))) {
if (p_def) {
err = tipsec_plugin_register_static(p_def);
if (!err) {
++count;
}
}
}
if (count <= 0) {
TSK_DEBUG_ERROR("No plugin in %s", pc_filepath);
TSK_OBJECT_SAFE_FREE(p_plugin);
return tipsec_error_notfound;
}
*pp_plugin = p_plugin;
return err;
}
/**
* UnRegister an IPSec special implementation (e.g. Windows XP, Windows Vista or Linux IPSec-Tools).
* @param p_plugin Pointer to the plugin previously registered using @ref tipsec_plugin_register_file().
* @retval @ref tipsec_error_success if no error; otherwise error code.
* @sa @ref tipsec_plugin_unregister_static(), @ref tipsec_plugin_unregister_file()
*/
tipsec_error_t tipsec_plugin_unregister_file(struct tsk_plugin_s* p_plugin)
{
int i = 0;
tsk_plugin_def_ptr_const_t p_def;
if (!p_plugin) {
TSK_DEBUG_ERROR("Invalid parameter");
return tipsec_error_invalid_param;
}
while ((p_def = tsk_plugin_get_def_2(p_plugin, tsk_plugin_def_type_ipsec, tsk_plugin_def_media_type_all, i++))) {
if (p_def) {
tipsec_plugin_unregister_static(p_def);
}
}
return tipsec_error_success;
}

View File

@ -1,41 +1,345 @@
/*
* Copyright (C) 2010-2011 Mamadou Diop.
/* Copyright (C) 2010-2014 Mamadou DIOP
* Copyright (C) 2011-2014 Doubango Telecom <http://www.doubango.org>
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]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.
*
*/
/**@file tipsec.h
* @brief IPSec manager.
* @brief IPSec plugin and context managers.
*
* @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
*
*/
#ifndef TINYIPSEC_IPSEC_H
#define TINYIPSEC_IPSEC_H
#include "tinyipsec_config.h"
#include "tipsec_common.h"
#include "tsk_string.h"
TIPSEC_BEGIN_DECLS
// Forward declaration
struct tsk_plugin_s;
/** Converts any IPSec context (XP, Vista, Linux IPSec-Tools ...) to the common IPSec context.
* @param self The context to convert. MUST be declared using @ref TIPSEC_DECLARE_CTX.
* @retval A pointer to @ref tipsec_ctx_t.
*/
#define TIPSEC_CTX(self) ((tipsec_ctx_t*)(self))
/**@def TIPSEC_IPPROTO_FROM_STR
* Converts IPSec IP protocol string to enum value.
* @param str_ipproto Must be "tcp", "udp" or "icmp"
* @retval @ref tipsec_ipproto_t value.
*/
/**@def TIPSEC_IPPROTO_TO_STR
* Converts IPSec IP protocol enum to string value.
* @param enum_ipproto @ref tipsec_ipproto_t value.
* @retval "tcp", "udp" or "icmp" string value.
*/
#define TIPSEC_IPPROTO_FROM_STR(str_ipproto) (tsk_strequals(str_ipproto, "tcp") ? tipsec_ipproto_tcp : (tsk_strequals(str_ipproto, "icmp") ? tipsec_ipproto_icmp : tipsec_ipproto_udp))
#define TIPSEC_IPPROTO_TO_STR(enum_ipproto) (enum_ipproto == tipsec_ipproto_tcp ? "tcp" : (enum_ipproto == tipsec_ipproto_icmp ? "icmp" : "udp"))
/**@def TIPSEC_MODE_FROM_STR
* Converts IPSec mode string to enum value.
* @param str_mode Must be "tun" (tunnel) or "trans" (transport).
* @retval @ref tipsec_mode_t value.
*/
/**@def TIPSEC_MODE_TO_STR
* Converts IPSec mode enum to string value.
* @param enum_mode @ref tipsec_mode_t value.
* @retval "tun" (tunnel) or "trans" (transport) string value.
*/
#define TIPSEC_MODE_FROM_STR(str_mode) (tsk_strequals(str_mode, "tun") ? tipsec_mode_tun : tipsec_mode_trans)
#define TIPSEC_MODE_TO_STR(enum_mode) (enum_mode == tipsec_mode_tun ? "tun" : "trans")
/** @def TIPSEC_EALG_FROM_STR
* Converts IPSec encryption algorithm string to enum value.
* @param str_ealg Must be "des-ede3-cbc", "aes" or "null".
* @retval @ref tipsec_ealg_t value.
*/
/**@def TIPSEC_EALG_TO_STR
* Converts IPSec encryption algorithm enum to string value.
* @param enum_ealg @ref tipsec_ealg_t value.
* @retval "des-ede3-cbc", "aes" or "null" string value.
*/
#define TIPSEC_EALG_FROM_STR(str_ealg) (tsk_strequals(str_ealg, "des-ede3-cbc") ? tipsec_ealg_des_ede3_cbc : (tsk_strequals(str_ealg, "aes-cbc") ? tipsec_ealg_aes : tipsec_ealg_null))
#define TIPSEC_EALG_TO_STR(enum_ealg) (enum_ealg == tipsec_ealg_des_ede3_cbc ? "des-ede3-cbc" : (enum_ealg == tipsec_ealg_aes ? "aes-cbc" : "null"))
/** @def TIPSEC_ALG_FROM_STR
* Converts IPSec algorithm string to enum value.
* @param str_alg Must be "hmac-sha-1-96" or "hmac-md5-96".
* @retval @ref tipsec_alg_t value.
*/
/**@def TIPSEC_ALG_TO_STR
* Converts IPSec algorithm enum to string value.
* @param enum_alg @ref tipsec_alg_t value.
* @retval "hmac-sha-1-96" or "hmac-md5-96" string value.
*/
#define TIPSEC_ALG_FROM_STR(str_alg) (tsk_strequals(str_alg, "hmac-sha-1-96") ? tipsec_alg_hmac_sha_1_96 : tipsec_alg_hmac_md5_96)
#define TIPSEC_ALG_TO_STR(enum_alg) (enum_alg == tipsec_alg_hmac_sha_1_96 ? "hmac-sha-1-96" : "hmac-md5-96")
/**@def TIPSEC_PROTOCOL_FROM_STR
* Converts IPSec protocol string to enum value.
* @param str_protocol Must be "ah", "esp" or "ah/esp".
* @retval @ref tipsec_proto_t value.
*/
/**@def TIPSEC_PROTOCOL_TO_STR
* Converts IPSec protocol enum to string value.
* @param enum_protocol @ref tipsec_proto_t value.
* @retval "ah", "esp" or "ah/esp" string value.
*/
#define TIPSEC_PROTOCOL_FROM_STR(str_protocol) (tsk_strequals(str_protocol, "ah") ? tipsec_proto_ah : ((tsk_strequals(str_protocol, "ah/esp")) ? tipsec_proto_both : tipsec_proto_esp))
#define TIPSEC_PROTOCOL_TO_STR(enum_protocol) (enum_protocol == tipsec_proto_ah ? "ah" : (enum_protocol == tipsec_proto_both ? "ah/esp" : "esp"))
/**@def TIPSEC_KEY_LEN
* Default size for IK (Integrity Key) and CK (Confidentiality Key).
**/
/**@def TIPSEC_CK_LEN
* Size of CK (Confidentiality Key).
*/
/**@def TIPSEC_IK_LEN
* Size of IK (Integrity Key).
*/
#define TIPSEC_KEY_LEN 16
#define TIPSEC_IK_LEN 20
#define TIPSEC_CK_LEN 24
/**@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 << 0),
//! 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
}
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;
/** List of supported IPSec implementations
*/
typedef enum tipsec_impl_type_e {
//! Windows XP only. This implementation works with IPv6 only.
tipsec_impl_type_xp,
//! Windows Vista or later. Using Windows Filtering Platform (http://msdn.microsoft.com/en-us/windows/hardware/gg463267.aspx).
tipsec_impl_type_vista,
//! Linux IPSec tools (http://ipsec-tools.sourceforge.net/)
tipsec_impl_type_ltools,
}
tipsec_impl_type_t;
/**
* Base IPSec context wrapping special implementation.
* An instance of this object must be created using @ref tipsec_ctx_create() and destroyed using @ref TSK_OBJECT_SAFE_FREE().
*/
typedef struct tipsec_ctx_s {
TSK_DECLARE_OBJECT;
//! Indicates whether the context have been initialized or not.
unsigned initialized;
//! Indicates whether the context have been started or not.
unsigned started:1;
//! The current state of the IPSec context.
tipsec_state_t state;
//! Indicates whether to use IPv6 addresses or not.
unsigned use_ipv6:1;
//! The network protocol.
tipsec_ipproto_t ipproto;
//! IPSec mode.
tipsec_mode_t mode;
//! Encrypt algorithm ().
tipsec_ealg_t ealg;
//! Algorithm.
tipsec_alg_t alg;
//! IPSec protocol.
tipsec_proto_t protocol;
//! Remote address (Proxy-CSCF).
void* addr_remote;
//! Proxy-CSCF client SPI (Security Parameter Index).
tipsec_spi_t spi_pc;
//! Proxy-CSCF server SPI (Security Parameter Index).
tipsec_spi_t spi_ps;
//! Proxy-CSCF client port.
tipsec_port_t port_pc;
//! Proxy-CSCF server port.
tipsec_port_t port_ps;
//! Local address (UE).
void* addr_local;
//! UE client SPI (Security Parameter Index). On Windows Vista and later it's up to the OS to set this value.
tipsec_spi_t spi_uc;
//! UE server SPI (Security Parameter Index). On Windows Vista and later it's up to the OS to set this value.
tipsec_spi_t spi_us;
//! UE client port.
tipsec_port_t port_uc;
//! UE server port.
tipsec_port_t port_us;
//! The confidentiality key.
tipsec_key_t *ck;
//! The integrity key.
tipsec_key_t *ik;
//! reg-await-auth timer value (in seconds).
tipsec_lifetime_t lifetime;
//! Reference to the plugin used to create this context.
const struct tipsec_plugin_def_s* pc_plugin;
}
tipsec_ctx_t;
/** Declare a struct as a context. Used to simulate inheritence. */
#define TIPSEC_DECLARE_CTX tipsec_ctx_t __ipsec_ctx__
/** Virtual table used to define a special IPSec implentation (XP, Vista or Linux IPSec Tools) plugin */
typedef struct tipsec_plugin_def_s {
//! object definition used to create an instance of the special implementation
const tsk_object_def_t* objdef;
//! the type of the consumer
enum tipsec_impl_type_e type;
//! full description (usefull for debugging)
const char* desc;
tipsec_error_t (* init) (tipsec_ctx_t* );
tipsec_error_t (* set_local) (tipsec_ctx_t* , const char* addr_local, const char* addr_remote, tipsec_port_t port_uc, tipsec_port_t port_us);
tipsec_error_t (* set_remote) (tipsec_ctx_t* , 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 (* set_keys) (tipsec_ctx_t* , const tipsec_key_t* ik, const tipsec_key_t* ck);
tipsec_error_t (* start) (tipsec_ctx_t* );
tipsec_error_t (* stop) (tipsec_ctx_t* );
}
tipsec_plugin_def_t;
TINYIPSEC_API tipsec_error_t tipsec_ctx_create(
tipsec_ipproto_t ipproto,
tsk_bool_t use_ipv6,
tipsec_mode_t mode,
tipsec_ealg_t ealg,
tipsec_alg_t alg,
tipsec_proto_t protocol,
tipsec_ctx_t** pp_ctx);
TINYIPSEC_API tipsec_error_t tipsec_ctx_start(tipsec_ctx_t* p_ctx);
TINYIPSEC_API tipsec_error_t tipsec_ctx_set_local(tipsec_ctx_t* p_ctx, const char* addr_local, const char* addr_remote, tipsec_port_t port_uc, tipsec_port_t port_us);
TINYIPSEC_API tipsec_error_t tipsec_ctx_set_keys(tipsec_ctx_t* p_ctx, const tipsec_key_t* ik, const tipsec_key_t* ck);
TINYIPSEC_API tipsec_error_t tipsec_ctx_set_remote(tipsec_ctx_t* p_ctx, tipsec_spi_t spi_pc, tipsec_spi_t spi_ps, tipsec_port_t port_pc, tipsec_port_t port_ps, tipsec_lifetime_t lifetime);
TINYIPSEC_API tipsec_error_t tipsec_ctx_stop(tipsec_ctx_t* p_ctx);
TINYIPSEC_API tipsec_error_t tipsec_plugin_register_static(const tipsec_plugin_def_t* pc_plugin);
TINYIPSEC_API tipsec_error_t tipsec_plugin_unregister_static(const tipsec_plugin_def_t* pc_plugin);
TINYIPSEC_API tipsec_error_t tipsec_plugin_register_file(const char* pc_filepath, struct tsk_plugin_s** pp_plugin);
TINYIPSEC_API tipsec_error_t tipsec_plugin_unregister_file(struct tsk_plugin_s* pp_plugin);
TIPSEC_END_DECLS
#endif /* TINYIPSEC_IPSEC_H */

View File

@ -1,115 +0,0 @@
/*
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]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.
*
*/
/**@file tipsec_common.c
* @brief IPSec common functions.
*
* @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
*
*/
#include "tipsec_common.h"
#include "tsk_debug.h"
/**@defgroup tipsec_common_group IPSec common.
* Common to all OSes.
*/
tipsec_context_t* tipsec_context_create(tipsec_ipproto_t ipproto, tsk_bool_t use_ipv6, tipsec_mode_t mode, tipsec_ealgorithm_t ealg, tipsec_algorithm_t alg, tipsec_protocol_t protocol)
{
return tsk_object_new(tipsec_context_def_t, ipproto, use_ipv6, (tipsec_mode_t)mode, ealg, alg, protocol);
}
#if !HAVE_IPSEC_VISTA && !HAVE_IPSEC_XP && !HAVE_IPSEC_RACOON
int tipsec_start(tipsec_context_t* ctx)
{
TSK_DEBUG_WARN("No IPSec implementation found.");
return 0;
}
int tipsec_set_local(tipsec_context_t* ctx, const char* addr_local, const char* addr_remote, tipsec_port_t port_uc, tipsec_port_t port_us)
{
TSK_DEBUG_WARN("No IPSec implementation found.");
ctx->port_uc = port_uc;
ctx->port_us = port_us;
return -1;
}
int tipsec_set_keys(tipsec_context_t* ctx, const tipsec_key_t* ik, const tipsec_key_t* ck)
{
TSK_DEBUG_WARN("No IPSec implementation found.");
return 0;
}
int tipsec_set_remote(tipsec_context_t* ctx, tipsec_spi_t spi_pc, tipsec_spi_t spi_ps, tipsec_port_t port_pc, tipsec_port_t port_ps, tipsec_lifetime_t lifetime)
{
TSK_DEBUG_WARN("No IPSec implementation found.");
return 0;
}
int tipsec_stop(tipsec_context_t* ctx)
{
TSK_DEBUG_WARN("No IPSec implementation found.");
return 0;
}
//=================================================================================================
// IPSec context object definition
//
static tsk_object_t* tipsec_context_ctor(tsk_object_t * self, va_list * app)
{
tipsec_context_t *context = self;
if(context){
}
return self;
}
static tsk_object_t* tipsec_context_dtor(tsk_object_t * self)
{
tipsec_context_t *context = self;
if(context){
}
return self;
}
static int tipsec_context_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return-1;
}
static const tsk_object_def_t tipsec_context_def_s =
{
sizeof(tipsec_context_t),
tipsec_context_ctor,
tipsec_context_dtor,
tipsec_context_cmp,
};
const void *tipsec_context_def_t = &tipsec_context_def_s;
#endif

View File

@ -1,280 +0,0 @@
/*
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]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.
*
*/
/**@file tipsec_common.h
* @brief IPSec common functions.
*
* @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
*
*/
#ifndef TINYIPSEC_IPSEC_COMMON_H
#define TINYIPSEC_IPSEC_COMMON_H
#include "tinyipsec_config.h"
#include "tsk_string.h"
TIPSEC_BEGIN_DECLS
/**@ingroup tipsec_common_group
* Converts any IPSec context (XP, Vista, racoon ...) to the common IPSec context.
* @param ctx The context to convert. MUST be declared using @ref TINYIPSEC_DECLARE_CONTEXT.
* @retval A pointer to @ref tipsec_context_t.
*/
#define TIPSEC_CONTEXT(ctx) ((tipsec_context_t*)(ctx))
/**@ingroup tipsec_common_group
* @def TIPSEC_IPPROTO_FROM_STR
*/
/**@ingroup tipsec_common_group
* @def TIPSEC_IPPROTO_TO_STR
*/
#define TIPSEC_IPPROTO_FROM_STR(ipproto) (tsk_strequals(ipproto, "tcp") ? ipproto_tcp : (tsk_strequals(ipproto, "icmp") ? ipproto_icmp : ipproto_udp))
#define TIPSEC_IPPROTO_TO_STR(ipproto) (ipproto == ipproto_tcp ? "tcp" : (ipproto == ipproto_icmp ? "icmp" : "udp"))
/**@ingroup tipsec_common_group
* @def TIPSEC_MODE_FROM_STR
*/
/**@ingroup tipsec_common_group
* @def TIPSEC_MODE_TO_STR
*/
#define TIPSEC_MODE_FROM_STR(mode) (tsk_strequals(mode, "tun") ? mode_tun : mode_trans)
#define TIPSEC_MODE_TO_STR(mode) (mode == mode_tun ? "tun" : "trans")
/**@ingroup tipsec_common_group
* @def TIPSEC_EALG_FROM_STR
*/
/**@ingroup tipsec_common_group
* @def TIPSEC_EALG_TO_STR
*/
#define TIPSEC_EALG_FROM_STR(ealg) (tsk_strequals(ealg, "des-ede3-cbc") ? ealg_des_ede3_cbc : (tsk_strequals(ealg, "aes") ? ealg_aes : ealg_null))
#define TIPSEC_EALG_TO_STR(ealg) (ealg == ealg_des_ede3_cbc ? "des-ede3-cbc" : (ealg == ealg_aes ? "aes" : "null"))
/**@ingroup tipsec_common_group
* @def TIPSEC_ALG_FROM_STR
*/
/**@ingroup tipsec_common_group
* @def TIPSEC_ALG_TO_STR
*/
#define TIPSEC_ALG_FROM_STR(alg) (tsk_strequals(alg, "hmac-sha-1-96") ? algo_hmac_sha_1_96 : algo_hmac_md5_96)
#define TIPSEC_ALG_TO_STR(alg) (alg == algo_hmac_sha_1_96 ? "hmac-sha-1-96" : "hmac-md5-96")
/**@ingroup tipsec_common_group
* @def TIPSEC_PROTOCOL_FROM_STR
*/
/**@ingroup tipsec_common_group
* @def TIPSEC_PROTOCOL_TO_STR
*/
#define TIPSEC_PROTOCOL_FROM_STR(protocol) (tsk_strequals(protocol, "ah") ? proto_ah : ((tsk_strequals(protocol, "ah/esp")) ? proto_both : proto_esp))
#define TIPSEC_PROTOCOL_TO_STR(protocol) (protocol == proto_ah ? "ah" : (protocol == proto_both ? "ah/esp" : "esp"))
/**@ingroup tipsec_common_group
* @def TIPSEC_KEY_LEN
* Size of IK (Integrity Key) and CK (Confidentiality Key).
**/
/**@ingroup tipsec_common_group
* @def TIPSEC_IK_LEN
*/
/**@ingroup tipsec_common_group
* @def TIPSEC_CK_LEN
*/
#define TIPSEC_KEY_LEN 16
#define TIPSEC_IK_LEN 20
#define TIPSEC_CK_LEN 24
/**@ingroup tipsec_common_group
* @def tipsec_lifetime_t
*/
/**@ingroup tipsec_common_group
* @def tipsec_spi_t
*/
/**@ingroup tipsec_common_group
* @def tipsec_port_t
*/
/**@ingroup tipsec_common_group
* @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.
mode_trans,
//! IPSec tunneling mode.
mode_tun
}
tipsec_mode_t;
/**@ingroup tipsec_common_group
* List of IPSec protocols.
**/
typedef enum tipsec_protocol_e
{
//! AH protocol.
proto_ah,
//! ESP protocol.
proto_esp,
//! Both AH and ESP protocols.
proto_both
}
tipsec_protocol_t;
/**@ingroup tipsec_common_group
* List of Internet protocols.
**/
typedef enum tipsec_ipproto_e
{
//! UDP.
ipproto_udp,
//! TCP.
ipproto_tcp,
//! ICMP.
ipproto_icmp
}
tipsec_ipproto_t;
/**@ingroup tipsec_common_group
* List of IPSec algorithms.
**/
typedef enum tipsec_algorithm_e
{
//! hmac-md5-96 algorithm.
algo_hmac_md5_96,
//! hmac-sha-1-96 algorithm.
algo_hmac_sha_1_96
}
tipsec_algorithm_t;
/**@ingroup tipsec_common_group
* List of IPSec encrypt-algorithms.
**/
typedef enum tipsec_ealgorithm_e
{
//! des-ede3-cbc encrypt-algorithm.
ealg_des_ede3_cbc,
//! aes encrypt-algorithm.
ealg_aes,
//! null encrypt-algorithm.
ealg_null
}
tipsec_ealgorithm_t;
/**@ingroup tipsec_common_group
* 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.
state_initial,
//! Partial state. At this state only inbound SAs (with their SPIs) have been created.
state_inbound,
//! Full state. At this state both inbound and outbound SAs have been create. It's the final state.
state_full,
//! All SAs are in active mode.
state_active
}
tipsec_state_t;
/**@ingroup tipsec_common_group
* IPSec context. Common fields.
*/
typedef struct tipsec_context_s
{
TSK_DECLARE_OBJECT;
//! Indicates whether the context have been initialized or not.
unsigned initialized;
//! Indicates whether the context have been started or not.
unsigned started:1;
//! The current state of the IPSec context.
tipsec_state_t state;
//! Indicates whether to use IPv6 addresses or not.
unsigned use_ipv6:1;
//! The network protocol.
tipsec_ipproto_t ipproto;
//! IPSec mode.
tipsec_mode_t mode;
//! Encrypt algorithm ().
tipsec_ealgorithm_t ealg;
//! Algorithm.
tipsec_algorithm_t alg;
//! IPSec protocol.
tipsec_protocol_t protocol;
//! Remote address (Proxy-CSCF).
void* addr_remote;
//! Proxy-CSCF client SPI.
tipsec_spi_t spi_pc;
//! Proxy-CSCF server SPI.
tipsec_spi_t spi_ps;
//! Proxy-CSCF client port.
tipsec_port_t port_pc;
//! Proxy-CSCF server port.
tipsec_port_t port_ps;
//! Local address (UE).
void* addr_local;
//! UE client SPI.
tipsec_spi_t spi_uc;
//! UE server SPI.
tipsec_spi_t spi_us;
//! UE client port.
tipsec_port_t port_uc;
//! UE server port.
tipsec_port_t port_us;
//! The confidentiality key.
tipsec_key_t *ck;
//! The integrity key.
tipsec_key_t *ik;
//! reg-await-auth timer value.
tipsec_lifetime_t lifetime;
}
tipsec_context_t;
/**@ingroup tipsec_common_group
*/
#define TINYIPSEC_DECLARE_CONTEXT tipsec_context_t context
TINYIPSEC_GEXTERN const void *tipsec_context_def_t;
TINYIPSEC_API tipsec_context_t* tipsec_context_create(tipsec_ipproto_t ipproto, tsk_bool_t use_ipv6, tipsec_mode_t mode, tipsec_ealgorithm_t ealg, tipsec_algorithm_t alg, tipsec_protocol_t protocol);
TINYIPSEC_API int tipsec_start(tipsec_context_t* ctx);
TINYIPSEC_API int tipsec_set_local(tipsec_context_t* ctx, const char* addr_local, const char* addr_remote, tipsec_port_t port_uc, tipsec_port_t port_us);
TINYIPSEC_API int tipsec_set_keys(tipsec_context_t* ctx, const tipsec_key_t* ik, const tipsec_key_t* ck);
TINYIPSEC_API int tipsec_set_remote(tipsec_context_t* ctx, tipsec_spi_t spi_pc, tipsec_spi_t spi_ps, tipsec_port_t port_pc, tipsec_port_t port_ps, tipsec_lifetime_t lifetime);
TINYIPSEC_API int tipsec_stop(tipsec_context_t* ctx);
TIPSEC_END_DECLS
#endif /* TINYIPSEC_IPSEC_COMMON_H */

View File

@ -1,116 +0,0 @@
/*
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]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.
*
*/
/**@file tipsec_racoon.c
* @brief IPSec racoon functions.
*
* @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
*
*/
#include "tipsec_racoon.h"
#include "tsk_debug.h"
/**@defgroup tipsec_racoon_group IPSec racoon implementation (IPSec-tools).
* Supported algo: <b>hmac-md5-96</b> and <b>hmac-sha-1-96</b>.<br>
* Supported ealg: <b>des-ede3-cbc</b>, <b>aes-cbc</b> and <b>null</b>.<br>
* Supported mode: <b>tunnel</b> and <b>transport</b>.<br>
* Supported proto: <b>ah</b> and <b>esp</b>.<br>
* Supported IP proto: <b>tcp</b> and <b>udp</b>.<br>
* Supported IP version: <b>IPv4</b> and <b>IPv6</b>.
*/
#if HAVE_IPSEC_RACOON
/**@ingroup tipsec_racoon_group
*/
int tipsec_start(tipsec_context_t* ctx)
{
TSK_DEBUG_ERROR("No IPSec implementation found.");
return -1;
}
/**@ingroup tipsec_racoon_group
*/
int tipsec_set_local(tipsec_context_t* ctx, const char* addr_local, const char* addr_remote, tipsec_port_t port_uc, tipsec_port_t port_us)
{
TSK_DEBUG_ERROR("No IPSec implementation found.");
return -1;
}
/**@ingroup tipsec_racoon_group
*/
int tipsec_set_remote(tipsec_context_t* ctx, tipsec_spi_t spi_pc, tipsec_spi_t spi_ps, tipsec_port_t port_pc, tipsec_port_t port_ps, tipsec_lifetime_t lifetime)
{
TSK_DEBUG_ERROR("No IPSec implementation found.");
return -1;
}
/**@ingroup tipsec_racoon_group
*/
int tipsec_stop(tipsec_context_t* ctx)
{
TSK_DEBUG_ERROR("No IPSec implementation found.");
return -1;
}
//=================================================================================================
// IPSec context object definition
//
static tsk_object_t* tipsec_context_ctor(tsk_object_t * self, va_list * app)
{
tipsec_context_t *context = self;
if(context){
}
bail:
return self;
}
static tsk_object_t* tipsec_context_dtor(tsk_object_t * self)
{
tipsec_context_t *context = self;
if(context){
}
return self;
}
static int tipsec_context_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return-1;
}
static const tsk_object_def_t tipsec_context_def_s =
{
sizeof(tipsec_context_t),
tipsec_context_ctor,
tipsec_context_dtor,
tipsec_context_cmp,
};
const void *tipsec_context_def_t = &tipsec_context_def_s;
#endif /* HAVE_IPSEC_RACOON */

View File

@ -1,49 +0,0 @@
/*
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]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.
*
*/
/**@file tipsec_racoon.h
* @brief IPSec racoon functions.
*
* @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
*
*/
#ifndef TINYIPSEC_IPSEC_RACOON_H
#define TINYIPSEC_IPSEC_RACOON_H
#include "tinyipsec_config.h"
#include "tipsec_common.h"
TIPSEC_BEGIN_DECLS
#if HAVE_IPSEC_RACOON
#endif /* HAVE_IPSEC_RACOON */
TIPSEC_END_DECLS
#endif /* TINYIPSEC_IPSEC_RACOON_H */

View File

@ -1,728 +0,0 @@
/*
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]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.
*
*/
/**@file tipsec_vista.c
* @brief Windows Vista/7 IPsec implementation using WFP.
*
* @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
*
*/
#include "tipsec_vista.h"
/**@defgroup tipsec_vista_group IPSec Vista/7 implementation (WFP).
* Supported algo: <b>hmac-md5-96</b> and <b>hmac-sha-1-96</b>.<br>
* Supported ealg: <b>des-ede3-cbc</b>, <b>aes-cbc</b> and <b>null</b>.<br>
* Supported mode: <b>transport</b> only.<br>
* Supported proto: <b>ah</b> and <b>esp</b>.<br>
* Supported IP proto: <b>tcp</b> and <b>udp</b>.<br>
* Supported IP version: <b>IPv4</b> and <b>IPv6</b>.
*/
#if HAVE_IPSEC_VISTA
#include "tsk_memory.h"
#include "tsk_debug.h"
#if defined(_MSC_VER)
# pragma comment(lib, "Fwpuclnt.lib")
#endif
#include <ws2tcpip.h>
#include <Fwpmu.h>
typedef FWP_BYTE_BLOB* PFWP_BYTE_BLOB;
/**@ingroup tipsec_vista_group
* @def TINYIPSEC_FILTER_NAME
*/
#define TINYIPSEC_FILTER_NAME TEXT("tinyIPSEC")
#define TINYIPSEC_PROVIDER_KEY NULL
/**@ingroup tipsec_vista_group
* @def TINYIPSEC_SA_NUM_ENTRIES_TO_REQUEST
*/
/**@ingroup tipsec_vista_group
* @def TINYIPSEC_SA_MAX_LIFETIME
*/
#define TINYIPSEC_SA_NUM_ENTRIES_TO_REQUEST 20
#define TINYIPSEC_SA_MAX_LIFETIME 172799
#define TINYIPSEC_VISTA_GET_ALGO(algo) (algo == algo_hmac_md5_96) ? IPSEC_AUTH_TRANSFORM_ID_HMAC_MD5_96 : IPSEC_AUTH_TRANSFORM_ID_HMAC_SHA_1_96
#define TINYIPSEC_VISTA_GET_EALGO(ealg) (ealg == ealg_des_ede3_cbc) ? IPSEC_CIPHER_TRANSFORM_ID_CBC_3DES : ( (ealg == ealg_aes) ? IPSEC_CIPHER_TRANSFORM_ID_AES_128 : IPSEC_CIPHER_TRANSFORM_ID_NULL_NULL )
#define TINYIPSEC_VISTA_GET_MODE(mode) (mode == mode_tun) ? IPSEC_TRAFFIC_TYPE_TUNNEL : IPSEC_TRAFFIC_TYPE_TRANSPORT
#define TINYIPSEC_VISTA_GET_IPPROTO(ipproto) (ipproto == ipproto_tcp) ? IPPROTO_TCP : IPPROTO_UDP
#define TINYIPSEC_VISTA_GET_IPVER(ipv6) (ipv6) ? FWP_IP_VERSION_V6 : FWP_IP_VERSION_V4
#define TINYIPSEC_VISTA_GET_PROTO(proto) (proto == proto_ah) ? IPSEC_TRANSFORM_AH : ( (proto == proto_esp) ? IPSEC_TRANSFORM_ESP_AUTH : IPSEC_TRANSFORM_ESP_AUTH_AND_CIPHER );
/* as WFP do not provide null encryption I define my own*/
static const IPSEC_CIPHER_TRANSFORM_ID0 IPSEC_CIPHER_TRANSFORM_ID_NULL_NULL=
{
(IPSEC_CIPHER_TYPE)NULL,
(IPSEC_CIPHER_TYPE)NULL
};
/**@ingroup tipsec_vista_group
* IPSec context.
*/
typedef struct tipsec_context_vista_s
{
TINYIPSEC_DECLARE_CONTEXT;
UINT64 saId_us;
UINT64 saId_uc;
HANDLE engine;
}
tipsec_context_vista_t;
/**@ingroup tipsec_vista_group
*/
#define TIPSEC_CONTEXT_VISTA(ctx) ((tipsec_context_vista_t*)(ctx))
int tipsec_create_localSA(__in const tipsec_context_vista_t* context, __in tipsec_port_t local_port, __out tipsec_spi_t *spi, UINT64 *saId);
int tipsec_boundSA(__in const tipsec_context_vista_t* context, __in UINT64 local_saId, __in tipsec_spi_t remote_spi, __in BOOLEAN toInbound);
int tipsec_flush_all(const tipsec_context_vista_t* context);
void DeleteSaContextAndFilters(__in HANDLE engine, __in UINT64 inFilterId, __in UINT64 outFilterId, __in UINT64 saId);
/**@ingroup tipsec_vista_group
*/
int tipsec_start(tipsec_context_t* ctx)
{
tipsec_context_vista_t* ctx_vista = TIPSEC_CONTEXT_VISTA(ctx);
int ret = -1;
if(!ctx_vista){
ret = -1;
goto bail;
}
if(TIPSEC_CONTEXT(ctx_vista)->started){
TSK_DEBUG_WARN("The IPSec context already started.");
ret = -2;
goto bail;
}
if(TIPSEC_CONTEXT(ctx_vista)->state != state_full){
TSK_DEBUG_ERROR("IPSec context is in the wrong state.");
ret = -3;
goto bail;
}
/* VERY IMPORTANT: The SA context functions must be called in a specific order:
(http://msdn.microsoft.com/en-us/library/bb540652(VS.85).aspx).
IPsecSaContextCreate0
IPsecSaContextGetSpi0
IPsecSaContextAddInbound0
IPsecSaContextAddOutbound0
*/
/* US <- PC */
if((ret = tipsec_boundSA(ctx_vista, ctx_vista->saId_us, TIPSEC_CONTEXT(ctx_vista)->spi_us, TRUE))){
TSK_DEBUG_ERROR("Failed to setup [US <- PC] SA.");
goto bail;
}
/* UC <- PS */
if((ret = tipsec_boundSA(ctx_vista, ctx_vista->saId_uc, TIPSEC_CONTEXT(ctx_vista)->spi_uc, TRUE))){
TSK_DEBUG_ERROR("Failed to setup [UC <- PS] SA.");
goto bail;
}
/* UC -> PS */
if((ret = tipsec_boundSA(ctx_vista, ctx_vista->saId_uc, TIPSEC_CONTEXT(ctx_vista)->spi_ps, FALSE))){
TSK_DEBUG_ERROR("Failed to setup [UC -> PS] SA.");
goto bail;
}
/* US -> PC */
if((ret = tipsec_boundSA(ctx_vista, ctx_vista->saId_us, TIPSEC_CONTEXT(ctx_vista)->spi_pc, FALSE))){
TSK_DEBUG_ERROR("Failed to setup [US -> PC] SA.");
goto bail;
}
// Set the state to active.
TIPSEC_CONTEXT(ctx_vista)->state = state_active;
TIPSEC_CONTEXT(ctx_vista)->started = 1;
bail:
return ret;
}
/**@ingroup tipsec_vista_group
*/
int tipsec_set_local(tipsec_context_t* ctx, const char* addr_local, const char* addr_remote, tipsec_port_t port_uc, tipsec_port_t port_us)
{
tipsec_context_vista_t* ctx_vista = TIPSEC_CONTEXT_VISTA(ctx);
int ret;
if(!ctx_vista){
ret = -1;
goto bail;
}
if(!addr_local || !port_uc || !port_us){
ret = -2;
goto bail;
}
if(!TIPSEC_CONTEXT(ctx_vista)->initialized){
TSK_DEBUG_ERROR("IPSec engine not initialized.");
ret = -3;
goto bail;
}
if(TIPSEC_CONTEXT(ctx_vista)->state != state_initial){
TSK_DEBUG_ERROR("IPSec context is in the wrong state.");
ret = -4;
goto bail;
}
TSK_FREE(TIPSEC_CONTEXT(ctx_vista)->addr_local);
TSK_FREE(TIPSEC_CONTEXT(ctx_vista)->addr_remote);
/* Set local IP */
if(TIPSEC_CONTEXT(ctx_vista)->use_ipv6){
TIPSEC_CONTEXT(ctx_vista)->addr_local = tsk_calloc(16, sizeof(uint8_t));
TIPSEC_CONTEXT(ctx_vista)->addr_remote = tsk_calloc(16, sizeof(uint8_t));
if ((ret = inet_pton(AF_INET6, addr_local, TIPSEC_CONTEXT(ctx_vista)->addr_local)) != 1 ){
TSK_DEBUG_ERROR("inet_pton(%s) have failed with error code [%x].", addr_local, ret);
goto bail;
} else ret = 0;
if ((ret = inet_pton(AF_INET6, addr_remote, TIPSEC_CONTEXT(ctx_vista)->addr_remote)) != 1 ){
TSK_DEBUG_ERROR("inet_pton(%s) have failed with error code [%x].", addr_remote, ret);
goto bail;
} else ret = 0;
}
else{
TIPSEC_CONTEXT(ctx_vista)->addr_local = tsk_calloc(4, sizeof(uint8_t));
TIPSEC_CONTEXT(ctx_vista)->addr_remote = tsk_calloc(4, sizeof(uint8_t));
if ((ret = inet_pton(AF_INET, addr_local, TIPSEC_CONTEXT(ctx_vista)->addr_local)) != 1 ){
TSK_DEBUG_ERROR("inet_pton(%s) have failed with error code [%x].", addr_local, ret);
goto bail;
}
else {
*((UINT32*)TIPSEC_CONTEXT(ctx_vista)->addr_local) = ntohl(*((UINT32*)TIPSEC_CONTEXT(ctx_vista)->addr_local));
ret = 0;
}
if ((ret = inet_pton(AF_INET, addr_remote, TIPSEC_CONTEXT(ctx_vista)->addr_remote)) != 1 ){
TSK_DEBUG_ERROR("inet_pton(%s) have failed with error code [%x].", addr_remote, ret);
goto bail;
}
else{
*((UINT32*)TIPSEC_CONTEXT(ctx_vista)->addr_remote) = ntohl(*((UINT32*)TIPSEC_CONTEXT(ctx_vista)->addr_remote));
ret = 0;
}
}
/* Set ports */
TIPSEC_CONTEXT(ctx_vista)->port_uc = port_uc;
TIPSEC_CONTEXT(ctx_vista)->port_us = port_us;
if((ret = tipsec_create_localSA(ctx_vista, TIPSEC_CONTEXT(ctx_vista)->port_uc, &TIPSEC_CONTEXT(ctx_vista)->spi_uc, &ctx_vista->saId_uc))){
goto bail;
}
if((ret = tipsec_create_localSA(ctx_vista, TIPSEC_CONTEXT(ctx_vista)->port_us, &TIPSEC_CONTEXT(ctx_vista)->spi_us, &ctx_vista->saId_us))){
goto bail;
}
TIPSEC_CONTEXT(ctx_vista)->state = state_inbound;
bail:
return ret;
}
/**@ingroup tipsec_vista_group
*/
int tipsec_set_keys(tipsec_context_t* ctx, const tipsec_key_t* ik, const tipsec_key_t* ck)
{
if(!ctx || !ik || !ck){
return -1;
}
/* Compute ik and ck */
TIPSEC_CONTEXT(ctx)->ik = tsk_calloc(1, sizeof(FWP_BYTE_BLOB));
TIPSEC_CONTEXT(ctx)->ck = tsk_calloc(1, sizeof(FWP_BYTE_BLOB));
((PFWP_BYTE_BLOB)TIPSEC_CONTEXT(ctx)->ik)->data = tsk_calloc(1, TIPSEC_IK_LEN);
memcpy(((PFWP_BYTE_BLOB)TIPSEC_CONTEXT(ctx)->ik)->data, ik, TIPSEC_KEY_LEN);
((PFWP_BYTE_BLOB)TIPSEC_CONTEXT(ctx)->ik)->size = TIPSEC_KEY_LEN;
((PFWP_BYTE_BLOB)TIPSEC_CONTEXT(ctx)->ck)->data = tsk_calloc(1, TIPSEC_CK_LEN);
memcpy(((PFWP_BYTE_BLOB)TIPSEC_CONTEXT(ctx)->ck)->data, ck, TIPSEC_KEY_LEN);
((PFWP_BYTE_BLOB)TIPSEC_CONTEXT(ctx)->ck)->size = TIPSEC_KEY_LEN;
return 0;
}
/**@ingroup tipsec_vista_group
*/
int tipsec_set_remote(tipsec_context_t* ctx, 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_context_vista_t* ctx_vista = TIPSEC_CONTEXT_VISTA(ctx);
int ret = -1;
if(!ctx_vista){
ret = -1;
goto bail;
}
if(!lifetime || !port_pc || !port_ps){
ret = -2;
goto bail;
}
if(TIPSEC_CONTEXT(ctx_vista)->state != state_inbound){
TSK_DEBUG_ERROR("IPSec context is in the wrong state.");
ret = -3;
goto bail;
}
/* Set Lifetime */
TIPSEC_CONTEXT(ctx_vista)->lifetime = lifetime;
/* Set ports */
TIPSEC_CONTEXT(ctx_vista)->port_ps = port_ps;
TIPSEC_CONTEXT(ctx_vista)->port_pc = port_pc;
/* Set spis */
TIPSEC_CONTEXT(ctx_vista)->spi_ps = spi_ps;
TIPSEC_CONTEXT(ctx_vista)->spi_pc = spi_pc;
TIPSEC_CONTEXT(ctx_vista)->state = state_full;
ret = 0;
bail:
return ret;
}
/**@ingroup tipsec_vista_group
*/
int tipsec_stop(tipsec_context_t* ctx)
{
tipsec_context_vista_t* ctx_vista = TIPSEC_CONTEXT_VISTA(ctx);
int ret = -1;
if(!ctx_vista){
ret = -1;
goto bail;
}
if(!TIPSEC_CONTEXT(ctx_vista)->started){
TSK_DEBUG_WARN("The IPSec context not started.");
ret = -2;
goto bail;
}
/* Flush (delete) all SAs associated to tinyIPSEC */
tipsec_flush_all(ctx_vista);
TIPSEC_CONTEXT(ctx_vista)->started = 0;
TIPSEC_CONTEXT(ctx_vista)->state = state_initial;
bail:
return ret;
}
int tipsec_create_localSA(__in const tipsec_context_vista_t* context, __in tipsec_port_t local_port, __out tipsec_spi_t *spi, UINT64 *saId)
{
DWORD result = NO_ERROR;
UINT64 tmpInFilterId = 0, tmpOutFilterId = 0, tmpSaId = 0;
FWPM_FILTER0 filter;
IPSEC_TRAFFIC0 outTraffic;
IPSEC_GETSPI0 getSpi;
int ret = -1;
FWPM_FILTER_CONDITION0 conds[4];
conds[0].fieldKey = FWPM_CONDITION_IP_LOCAL_ADDRESS;
conds[0].matchType = FWP_MATCH_EQUAL;
*spi = 0;
*saId = 0;
if(TIPSEC_CONTEXT(context)->use_ipv6){
conds[0].conditionValue.type = FWP_BYTE_ARRAY16_TYPE;
conds[0].conditionValue.byteArray16 = (FWP_BYTE_ARRAY16*)TIPSEC_CONTEXT(context)->addr_local;
}
else{
conds[0].conditionValue.type = FWP_UINT32;
conds[0].conditionValue.uint32 = *((UINT32*)TIPSEC_CONTEXT(context)->addr_local);
}
conds[1].fieldKey = FWPM_CONDITION_IP_REMOTE_ADDRESS;
conds[1].matchType = FWP_MATCH_EQUAL;
if(TIPSEC_CONTEXT(context)->use_ipv6){
conds[1].conditionValue.type = FWP_BYTE_ARRAY16_TYPE;
conds[1].conditionValue.byteArray16 = (FWP_BYTE_ARRAY16*)TIPSEC_CONTEXT(context)->addr_remote;
}
else{
conds[1].conditionValue.type = FWP_UINT32;
conds[1].conditionValue.uint32 = *((UINT32*)TIPSEC_CONTEXT(context)->addr_remote);
}
conds[2].fieldKey = FWPM_CONDITION_IP_LOCAL_PORT;
conds[2].matchType = FWP_MATCH_EQUAL;
conds[2].conditionValue.type = FWP_UINT16;
conds[2].conditionValue.uint16 = local_port;
conds[3].fieldKey = FWPM_CONDITION_IP_PROTOCOL;
conds[3].matchType = FWP_MATCH_EQUAL;
conds[3].conditionValue.type = FWP_UINT8;
conds[3].conditionValue.uint16 = TINYIPSEC_VISTA_GET_IPPROTO(TIPSEC_CONTEXT(context)->ipproto);
// Fill in the common fields shared by both filters.
memset(&filter, 0, sizeof(filter));
// For MUI compatibility, object names should be indirect strings. See
// SHLoadIndirectString for details.
filter.displayData.name = (PWSTR)TINYIPSEC_FILTER_NAME;
// Link all objects to our provider. When multiple providers are installed
// on a computer, this makes it easy to determine who added what.
filter.providerKey = (GUID*)TINYIPSEC_PROVIDER_KEY;
filter.numFilterConditions = 4;
filter.filterCondition = conds;
filter.action.type = FWP_ACTION_CALLOUT_TERMINATING;
filter.flags = FWPM_FILTER_FLAG_NONE;
//filter.weight.type = FWP_EMPTY;
// Add the inbound filter.
filter.layerKey = (TIPSEC_CONTEXT(context)->use_ipv6) ? FWPM_LAYER_INBOUND_TRANSPORT_V6 : FWPM_LAYER_INBOUND_TRANSPORT_V4;
if(TIPSEC_CONTEXT(context)->mode == mode_tun){
filter.action.calloutKey = (TIPSEC_CONTEXT(context)->use_ipv6) ? FWPM_CALLOUT_IPSEC_INBOUND_TUNNEL_V6 : FWPM_CALLOUT_IPSEC_INBOUND_TUNNEL_V4;
}
else{
filter.action.calloutKey = (TIPSEC_CONTEXT(context)->use_ipv6) ? FWPM_CALLOUT_IPSEC_INBOUND_TRANSPORT_V6 : FWPM_CALLOUT_IPSEC_INBOUND_TRANSPORT_V4;
}
if((result = FwpmFilterAdd0(context->engine, &filter, NULL, &tmpInFilterId)) != ERROR_SUCCESS){
TSK_DEBUG_ERROR("FwpmFilterAdd0 (inbound) failed with error code [%x]", result);
goto CLEANUP;
}
// Add the outbound filter.
filter.layerKey = (TIPSEC_CONTEXT(context)->use_ipv6) ? FWPM_LAYER_OUTBOUND_TRANSPORT_V6 : FWPM_LAYER_OUTBOUND_TRANSPORT_V4;
if(TIPSEC_CONTEXT(context)->mode == mode_tun){
filter.action.calloutKey = (TIPSEC_CONTEXT(context)->use_ipv6) ? FWPM_CALLOUT_IPSEC_OUTBOUND_TUNNEL_V6 : FWPM_CALLOUT_IPSEC_OUTBOUND_TUNNEL_V4;
}
else{
filter.action.calloutKey = (TIPSEC_CONTEXT(context)->use_ipv6) ? FWPM_CALLOUT_IPSEC_OUTBOUND_TRANSPORT_V6 : FWPM_CALLOUT_IPSEC_OUTBOUND_TRANSPORT_V4;
}
if((result = FwpmFilterAdd0(context->engine, &filter, NULL, &tmpOutFilterId)) != ERROR_SUCCESS){
TSK_DEBUG_ERROR("FwpmFilterAdd0(outbound) failed with error code [%x]", result);
goto CLEANUP;
}
// Create the SA context using the outbound traffic descriptor.
memset(&outTraffic, 0, sizeof(outTraffic));
outTraffic.ipVersion = TINYIPSEC_VISTA_GET_IPVER(TIPSEC_CONTEXT(context)->use_ipv6);
if(TIPSEC_CONTEXT(context)->use_ipv6){
memcpy(outTraffic.localV6Address, TIPSEC_CONTEXT(context)->addr_local, 16);
memcpy(outTraffic.remoteV6Address, TIPSEC_CONTEXT(context)->addr_remote, 16);
}
else{
outTraffic.localV4Address = *((ULONG*)TIPSEC_CONTEXT(context)->addr_local);
outTraffic.remoteV4Address = *((ULONG*)TIPSEC_CONTEXT(context)->addr_remote);
}
outTraffic.trafficType = TINYIPSEC_VISTA_GET_MODE(TIPSEC_CONTEXT(context)->mode);
outTraffic.ipsecFilterId = tmpOutFilterId;
if((result = IPsecSaContextCreate0(context->engine, &outTraffic, NULL, &tmpSaId)) != ERROR_SUCCESS){
TSK_DEBUG_ERROR("IPsecSaContextCreate0 failed with error code [%x]", result);
goto CLEANUP;
}
// Get the inbound SPI using the inbound traffic descriptor.
memset(&getSpi, 0, sizeof(getSpi));
getSpi.inboundIpsecTraffic.ipVersion = TINYIPSEC_VISTA_GET_IPVER(TIPSEC_CONTEXT(context)->use_ipv6);
if(TIPSEC_CONTEXT(context)->use_ipv6){
memcpy(getSpi.inboundIpsecTraffic.localV6Address, TIPSEC_CONTEXT(context)->addr_local, 16);
memcpy(getSpi.inboundIpsecTraffic.remoteV6Address, TIPSEC_CONTEXT(context)->addr_remote, 16);
}
else{
getSpi.inboundIpsecTraffic.localV4Address = *((ULONG*)TIPSEC_CONTEXT(context)->addr_local);
getSpi.inboundIpsecTraffic.remoteV4Address = *((ULONG*)TIPSEC_CONTEXT(context)->addr_remote);
}
getSpi.inboundIpsecTraffic.trafficType = TINYIPSEC_VISTA_GET_MODE(TIPSEC_CONTEXT(context)->mode);
getSpi.inboundIpsecTraffic.ipsecFilterId = tmpInFilterId;
getSpi.ipVersion = TINYIPSEC_VISTA_GET_IPVER(TIPSEC_CONTEXT(context)->use_ipv6);
if((result = IPsecSaContextGetSpi0(context->engine, tmpSaId, &getSpi, spi))){
TSK_DEBUG_ERROR("IPsecSaContextGetSpi0 failed with error code [%x]", result);
goto CLEANUP;
}
//// Return the various LUIDs to the caller, so he can clean up.
//*inFilterId = tmpInFilterId;
//*outFilterId = tmpOutFilterId;
*saId = tmpSaId;
CLEANUP:
if (result != NO_ERROR){
DeleteSaContextAndFilters(context->engine, tmpInFilterId, tmpOutFilterId, tmpSaId);
}else ret = 0;
return ret;
}
int tipsec_boundSA(__in const tipsec_context_vista_t* context, __in UINT64 local_saId, __in tipsec_spi_t remote_spi, __in BOOLEAN toInbound)
{
UINT32 i=0, j=0;
DWORD result = NO_ERROR;
IPSEC_SA0 sa;
IPSEC_SA_BUNDLE0 bundle;
IPSEC_SA_AUTH_INFORMATION0 authInfo;
PFWP_BYTE_BLOB ik = (PFWP_BYTE_BLOB)TIPSEC_CONTEXT(context)->ik;
PFWP_BYTE_BLOB ck = (PFWP_BYTE_BLOB)TIPSEC_CONTEXT(context)->ck;
memset(&sa, 0, sizeof(sa));
sa.spi = remote_spi;
sa.saTransformType = TINYIPSEC_VISTA_GET_PROTO(TIPSEC_CONTEXT(context)->protocol);
//
// Keys padding
//
if(TIPSEC_CONTEXT(context)->alg == algo_hmac_sha_1_96){
if(ik->size < TIPSEC_IK_LEN){
for(i = ik->size; i<TIPSEC_KEY_LEN; i++){
ik->data[i] = 0x00; /* Already done by "tsk_calloc" but ... */
}
ik->size = TIPSEC_IK_LEN;
}
}
if(TIPSEC_CONTEXT(context)->ealg == ealg_des_ede3_cbc){
if(ck->size < TIPSEC_CK_LEN){
for(i = ck->size; i<TIPSEC_CK_LEN; i++){
ck->data[i] = ck->data[j++];
}
ck->size = TIPSEC_CK_LEN;
}
}
//
// In all case create Authentication info
//
memset(&authInfo, 0, sizeof(authInfo));
authInfo.authTransform.authTransformId = TINYIPSEC_VISTA_GET_ALGO(TIPSEC_CONTEXT(context)->alg);
authInfo.authKey = *ik;
if( sa.saTransformType == IPSEC_TRANSFORM_AH ){
sa.ahInformation = &authInfo;
}
else if( sa.saTransformType == IPSEC_TRANSFORM_ESP_AUTH ){
sa.espAuthInformation = &authInfo;
}
else if( sa.saTransformType == IPSEC_TRANSFORM_ESP_AUTH_AND_CIPHER ){
IPSEC_SA_CIPHER_INFORMATION0 cipherInfo;
IPSEC_SA_AUTH_AND_CIPHER_INFORMATION0 cipherAuthInfo;
memset(&cipherInfo, 0, sizeof(cipherInfo));
cipherInfo.cipherTransform.cipherTransformId = TINYIPSEC_VISTA_GET_EALGO(TIPSEC_CONTEXT(context)->ealg);
cipherInfo.cipherKey = *ck;
memset(&cipherAuthInfo, 0, sizeof(cipherAuthInfo));
cipherAuthInfo.saAuthInformation = authInfo;
cipherAuthInfo.saCipherInformation = cipherInfo;
sa.espAuthAndCipherInformation = &cipherAuthInfo;
}
memset(&bundle, 0, sizeof(bundle));
bundle.numSAs = 1;
bundle.saList = &sa;
bundle.ipVersion = TINYIPSEC_VISTA_GET_IPVER(TIPSEC_CONTEXT(context)->use_ipv6);
bundle.lifetime.lifetimeSeconds = (UINT32)((TIPSEC_CONTEXT(context)->lifetime > TINYIPSEC_SA_MAX_LIFETIME) ? TINYIPSEC_SA_MAX_LIFETIME : TIPSEC_CONTEXT(context)->lifetime);
/* From remote to local (inbound) ? */
if(toInbound){
if((result = IPsecSaContextAddInbound0(context->engine, local_saId, &bundle)) != ERROR_SUCCESS){
TSK_DEBUG_ERROR("IPsecSaContextAddInbound0 failed with error code [%x]", result);
goto CLEANUP;
}
}
else{
if((result = IPsecSaContextAddOutbound0(context->engine, local_saId, &bundle)) != ERROR_SUCCESS){
TSK_DEBUG_ERROR("IPsecSaContextAddOutbound0 failed with error code [%x]", result);
goto CLEANUP;
}
}
CLEANUP:
return (result == ERROR_SUCCESS) ? 0 : -1;
}
void DeleteSaContextAndFilters(__in HANDLE engine, __in UINT64 inFilterId, __in UINT64 outFilterId, __in UINT64 saId)
{
DWORD result;
// Allow the LUIDs to be zero, so we can use this function to cleanup
// partial results.
if (saId != 0)
{
result = IPsecSaContextDeleteById0(engine, saId);
if (result != ERROR_SUCCESS)
{
// There's not much we can do if delete fails, so continue trying to
// clean up the remaining objects.
TSK_DEBUG_ERROR("IPsecSaContextDeleteById0 = 0x%08X\n", result);
}
}
if (outFilterId != 0)
{
result = FwpmFilterDeleteById0(engine, outFilterId);
if (result != ERROR_SUCCESS)
{
TSK_DEBUG_ERROR("FwpmFilterDeleteById0 = 0x%08X\n", result);
}
}
if (inFilterId != 0)
{
result = FwpmFilterDeleteById0(engine, inFilterId);
if (result != ERROR_SUCCESS)
{
TSK_DEBUG_ERROR("FwpmFilterDeleteById0 = 0x%08X\n", result);
}
}
}
int tipsec_flush_all(const tipsec_context_vista_t* context)
{
UINT32 i;
int ret = -1;
if(context)
{
HANDLE enumHandle = NULL;
IPSEC_SA_DETAILS0** entries = NULL;
UINT32 numEntriesReturned = 0;
DWORD result;
if((result = IPsecSaCreateEnumHandle0(context->engine, NULL, &enumHandle)) != ERROR_SUCCESS){
TSK_DEBUG_ERROR("IPsecSaCreateEnumHandle0 failed with error code [%x].", result);
goto CLEANUP;
}
if((result = IPsecSaEnum0(context->engine, enumHandle, TINYIPSEC_SA_NUM_ENTRIES_TO_REQUEST, &entries, &numEntriesReturned)) != ERROR_SUCCESS){
TSK_DEBUG_ERROR("IPsecSaEnum0 failed with error code [%x].", result);
goto CLEANUP;
}
for(i = 0; i<numEntriesReturned; i++)
{
IPSEC_SA_DETAILS0* entry = (entries)[i];
if( !wcscmp(entry->transportFilter->displayData.name, TINYIPSEC_FILTER_NAME))
{
if((result = FwpmFilterDeleteById0(context->engine, entry->transportFilter->filterId)) != ERROR_SUCCESS){
TSK_DEBUG_ERROR("FwpmFilterDeleteById0 failed with error code [%x].", result);
goto CLEANUP;
}
}
}
if((result = IPsecSaDestroyEnumHandle0(context->engine, enumHandle)) != ERROR_SUCCESS){
TSK_DEBUG_ERROR("IPsecSaDestroyEnumHandle0 failed with error code [%x].", result);
goto CLEANUP;
}
TSK_DEBUG_INFO("All SAs have been flushed.");
ret = 0;
CLEANUP:
FwpmFreeMemory0((void**)entries);
}
return ret;
}
//=================================================================================================
// IPSec context object definition
//
static tsk_object_t* tipsec_context_ctor(tsk_object_t * self, va_list * app)
{
tipsec_context_vista_t *context = self;
if(context){
DWORD code;
TIPSEC_CONTEXT(context)->ipproto = va_arg(*app, tipsec_ipproto_t);
TIPSEC_CONTEXT(context)->use_ipv6 = va_arg(*app, int);
TIPSEC_CONTEXT(context)->mode = va_arg(*app, tipsec_mode_t);
TIPSEC_CONTEXT(context)->ealg = va_arg(*app, tipsec_ealgorithm_t);
TIPSEC_CONTEXT(context)->alg = va_arg(*app, tipsec_algorithm_t);
TIPSEC_CONTEXT(context)->protocol = va_arg(*app, tipsec_protocol_t);
/* Open engine */
if((code = FwpmEngineOpen0(NULL, RPC_C_AUTHN_WINNT, NULL, NULL, &context->engine))){
TIPSEC_CONTEXT(context)->initialized = tsk_false;
TSK_DEBUG_ERROR("FwpmEngineOpen0 failed with error code [%x].", code);
}
else{
TIPSEC_CONTEXT(context)->initialized = tsk_true;
}
TIPSEC_CONTEXT(context)->state = state_initial;
}
return self;
}
static tsk_object_t* tipsec_context_dtor(tsk_object_t * self)
{
tipsec_context_vista_t *context = self;
if(context)
{
DWORD code;
if(TIPSEC_CONTEXT(context)->started){
tipsec_stop(TIPSEC_CONTEXT(context));
}
/* Close engine */
if((code = FwpmEngineClose0(context->engine))){
TSK_DEBUG_ERROR("FwpmEngineClose0 failed with error code [%x].", code);
}
TSK_FREE(TIPSEC_CONTEXT(context)->addr_local);
TSK_FREE(TIPSEC_CONTEXT(context)->addr_remote);
TSK_FREE(TIPSEC_CONTEXT(context)->ik);
TSK_FREE(TIPSEC_CONTEXT(context)->ck);
}
return self;
}
static int tipsec_context_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return-1;
}
static const tsk_object_def_t tipsec_context_def_s =
{
sizeof(tipsec_context_vista_t),
tipsec_context_ctor,
tipsec_context_dtor,
tipsec_context_cmp,
};
const void *tipsec_context_def_t = &tipsec_context_def_s;
#endif /* HAVE_IPSEC_VISTA */

View File

@ -1,49 +0,0 @@
/*
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]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.
*
*/
/**@file tipsec_vista.h
* @brief Windows Vista/7 IPsec implementation using WFP.
*
* @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
*
*/
#ifndef TINYIPSEC_IPSEC_VISTA_H
#define TINYIPSEC_IPSEC_VISTA_H
#include "tinyipsec_config.h"
#include "tipsec_common.h"
TIPSEC_BEGIN_DECLS
#if HAVE_IPSEC_VISTA
#endif /* HAVE_IPSEC_VISTA */
TIPSEC_END_DECLS
#endif /* TINYIPSEC_IPSEC_VISTA_H */

View File

@ -1,652 +0,0 @@
/*
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]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.
*
*/
/**@file tipsec_xp.c
* @brief Windows XP/2003 IPsec implementation using ipsec6 tool.
* @sa http://technet.microsoft.com/en-us/library/cc787900.aspx
*
* @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
*
*/
#include "tipsec_xp.h"
/**@defgroup tipsec_xp_group IPSec XP implementation.
* Supported algo: <b>hmac-md5-96</b> and <b>hmac-sha-1-96</b>.<br>
* Supported ealg: <b>null</b> only.<br>
* Supported mode: <b>tunnel</b> and <b>transport</b>.<br>
* Supported proto: <b>ah</b> and <b>esp</b>.<br>
* Supported IP proto: <b>tcp</b> and <b>udp</b>.<br>
* Supported IP version: <b>IPv6</b> only.
*/
#if HAVE_IPSEC_XP
#include "tsk_debug.h"
#include "tsk_memory.h"
#define TINYIPSEC_XP_GET_ALGO(algo) ((algo == algo_hmac_md5_96) ? "HMAC-MD5-96" : "HMAC-SHA1")
#define TINYIPSEC_XP_GET_MODE(mode) ((mode == mode_tun) ? "TUNNEL" : "TRANSPORT")
#define TINYIPSEC_XP_GET_PROTO(proto) ((proto == proto_ah) ? "AH" : "ESP")
#define TINYIPSEC_XP_GET_IPPROTO(ipproto) ((ipproto == ipproto_tcp) ? "TCP" : ((ipproto == ipproto_icmp) ? "ICMP" : "UDP"))
/**@ingroup tipsec_xp_group
* @def TINYIPSEC_IPSEC6_FILE
*/
/**@ingroup tipsec_xp_group
* @def TINYIPSEC_IPSEC6_FILE_KEY
*/
/**@ingroup tipsec_xp_group
* @def TINYIPSEC_IPSEC6_FILE_SAD
*/
/**@ingroup tipsec_xp_group
* @def TINYIPSEC_IPSEC6_FILE_SPD
*/
#define TINYIPSEC_IPSEC6_FILE "tinyIPSec"
#define TINYIPSEC_IPSEC6_FILE_KEY TINYIPSEC_IPSEC6_FILE".key"
#define TINYIPSEC_IPSEC6_FILE_SAD TINYIPSEC_IPSEC6_FILE".sad"
#define TINYIPSEC_IPSEC6_FILE_SPD TINYIPSEC_IPSEC6_FILE".spd"
#define TINYIPSEC_IPSEC6_TEMPLATE_POLICY "\n"\
"Security Policy List\n"\
"\n"\
"Policy RemoteIPAddr LocalIPAddr Protocol RemotePort LocalPort IPSecProtocol IPSecMode RemoteGWIPAddr SABundleIndex Direction Action InterfaceIndex \n"\
"_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________\n"\
"%s - %s - %s - %s - %u - %u %s %s %s %s %s %s %s ;\n"\
"%s - %s - %s - %s - %u - %u %s %s %s %s %s %s %s ;\n"\
"_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________\n"\
"\n"\
"- = Take selector from policy.\n"\
"+ = Take selector from packet.\n"
#define TINYIPSEC_IPSEC6_TEMPLATE_SA "\n"\
"Security Association List\n"\
"\n"\
"SAEntry SPI SADestIPAddr DestIPAddr SrcIPAddr Protocol DestPort SrcPort AuthAlg KeyFile Direction SecPolicyIndex \n"\
"___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________\n"\
"%s %u %s %s %s %s %s %s %s %s %s %s ;\n"\
"%s %u %s %s %s %s %s %s %s %s %s %s ;\n"\
"%s %u %s %s %s %s %s %s %s %s %s %s ;\n"\
"%s %u %s %s %s %s %s %s %s %s %s %s ;\n"\
"___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________\n"
/**@ingroup tipsec_xp_group
*/
#define TINYIPSEC_IPSEC6_UCPS_POLICY "11111983"
/**@ingroup tipsec_xp_group
*/
#define TINYIPSEC_IPSEC6_USPC_POLICY "22221983"
/**@ingroup tipsec_xp_group
* IPSec context.
*/
typedef struct tipsec_context_xp_s
{
TINYIPSEC_DECLARE_CONTEXT;
}
tipsec_context_xp_t;
/**@ingroup tipsec_xp_group
*/
#define TIPSEC_CONTEXT_XP(ctx) ((tipsec_context_xp_t*)(ctx))
int tipsec_set_IKey(tipsec_context_xp_t* ctx_xp);
int tipsec_set_SPDs(tipsec_context_xp_t* ctx_xp);
int tipsec_set_SAs(tipsec_context_xp_t* ctx_xp);
struct handleInfo{
HANDLE process;
HANDLE pipe;
};
int tipsec_run_command(TCHAR *args);
DWORD WINAPI tipsec_waitForExit(void *arg);
/**@ingroup tipsec_xp_group
*/
int tipsec_start(tipsec_context_t* ctx)
{
tipsec_context_xp_t* ctx_xp = TIPSEC_CONTEXT_XP(ctx);
int ret = -1;
if(!ctx_xp){
ret = -1;
goto bail;
}
if(TIPSEC_CONTEXT(ctx_xp)->started){
TSK_DEBUG_WARN("The IPSec context already started.");
ret = -2;
goto bail;
}
if(TIPSEC_CONTEXT(ctx_xp)->state != state_full){
TSK_DEBUG_ERROR("IPSec context is in the wrong state.");
ret = -3;
goto bail;
}
if((ret = tipsec_set_IKey(ctx_xp))){
TSK_DEBUG_ERROR("Failed to set IKey.");
goto bail;
}
if((ret = tipsec_set_SPDs(ctx_xp))){
TSK_DEBUG_ERROR("Failed to set SPDs.");
goto bail;
}
if((ret = tipsec_set_SAs(ctx_xp))){
TSK_DEBUG_ERROR("Failed to set SAs.");
goto bail;
}
/* delete previous Policies */
tipsec_run_command(TEXT("d sp "TEXT(TINYIPSEC_IPSEC6_UCPS_POLICY)));
tipsec_run_command(TEXT("d sp "TEXT(TINYIPSEC_IPSEC6_USPC_POLICY)));
/* Load new policies */
if(!(ret = tipsec_run_command(TEXT("l "TEXT(TINYIPSEC_IPSEC6_FILE))))){
TIPSEC_CONTEXT(ctx_xp)->started = 1;
}
bail:
/* Remove files */
remove(TINYIPSEC_IPSEC6_FILE_SPD);
remove(TINYIPSEC_IPSEC6_FILE_SAD);
remove(TINYIPSEC_IPSEC6_FILE_KEY);
return ret;
}
/**@ingroup tipsec_xp_group
*/
int tipsec_set_local(tipsec_context_t* ctx, const char* addr_local, const char* addr_remote, tipsec_port_t port_uc, tipsec_port_t port_us)
{
tipsec_context_xp_t* ctx_xp = TIPSEC_CONTEXT_XP(ctx);
int ret = -1;
if(!ctx_xp){
ret = -1;
goto bail;
}
if(!addr_local || !port_uc || !port_us){
ret = -2;
goto bail;
}
if(!TIPSEC_CONTEXT(ctx_xp)->initialized){
TSK_DEBUG_ERROR("IPSec engine not initialized.");
ret = -3;
goto bail;
}
if(TIPSEC_CONTEXT(ctx_xp)->state != state_initial){
TSK_DEBUG_ERROR("IPSec context is in the wrong state.");
ret = -4;
goto bail;
}
/* Set local/remote IPv6 addresses*/
tsk_strupdate((char**)&TIPSEC_CONTEXT(ctx_xp)->addr_local, addr_local);
tsk_strupdate((char**)&TIPSEC_CONTEXT(ctx_xp)->addr_remote, addr_remote);
/* Set ports */
TIPSEC_CONTEXT(ctx_xp)->port_uc = port_uc;
TIPSEC_CONTEXT(ctx_xp)->port_us = port_us;
/* Set SPIs */
TIPSEC_CONTEXT(ctx_xp)->spi_uc = (rand() ^ rand());
TIPSEC_CONTEXT(ctx_xp)->spi_us = (rand() ^ rand());
TIPSEC_CONTEXT(ctx_xp)->state = state_inbound;
ret = 0;
bail:
return ret;
}
/**@ingroup tipsec_xp_group
*/
int tipsec_set_keys(tipsec_context_t* ctx, const tipsec_key_t* ik, const tipsec_key_t* ck)
{
if(!ctx || !ik || !ck){
return -1;
}
TSK_FREE(ctx->ik);
TSK_FREE(ctx->ck);
ctx->ik = tsk_strndup(ik, TIPSEC_KEY_LEN);
ctx->ck = tsk_strndup(ck, TIPSEC_KEY_LEN); /* XP version of IPSec do not support encryption key but we copy ck (Who know?). */
return 0;
}
/**@ingroup tipsec_xp_group
*/
int tipsec_set_remote(tipsec_context_t* ctx, 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_context_xp_t* ctx_xp = TIPSEC_CONTEXT_XP(ctx);
int ret = -1;
if(!ctx_xp){
ret = -1;
goto bail;
}
if(!lifetime || !port_pc || !port_ps){
ret = -2;
goto bail;
}
if(TIPSEC_CONTEXT(ctx_xp)->state != state_inbound){
TSK_DEBUG_ERROR("IPSec context is in the wrong state.");
ret = -3;
goto bail;
}
/* Set Lifetime */
TIPSEC_CONTEXT(ctx_xp)->lifetime = lifetime;
/* Set ports */
TIPSEC_CONTEXT(ctx_xp)->port_ps = port_ps;
TIPSEC_CONTEXT(ctx_xp)->port_pc = port_pc;
/* Set spis */
TIPSEC_CONTEXT(ctx_xp)->spi_ps = spi_ps;
TIPSEC_CONTEXT(ctx_xp)->spi_pc = spi_pc;
TIPSEC_CONTEXT(ctx_xp)->state = state_full;
ret = 0;
bail:
return ret;
}
/**@ingroup tipsec_xp_group
*/
int tipsec_stop(tipsec_context_t* ctx)
{
tipsec_context_xp_t* ctx_xp = TIPSEC_CONTEXT_XP(ctx);
int ret = -1;
/* Load previous Policies */
ret = tipsec_run_command(TEXT("d sp "TEXT(TINYIPSEC_IPSEC6_UCPS_POLICY)));
ret = tipsec_run_command(TEXT("d sp "TEXT(TINYIPSEC_IPSEC6_USPC_POLICY)));
return ret;
}
int tipsec_set_IKey(tipsec_context_xp_t* ctx_xp)
{
int ret = -1;
FILE* file = NULL;
if(!ctx_xp){
goto bail;
}
if(TIPSEC_CONTEXT(ctx_xp)->state != state_full){
TSK_DEBUG_ERROR("IPSec context is in the wrong state.");
ret = -3;
goto bail;
}
if(!(file = fopen(TINYIPSEC_IPSEC6_FILE_KEY, "wb+"))){
TSK_DEBUG_ERROR("Failed to open file [%s].", TINYIPSEC_IPSEC6_FILE_KEY);
ret = -4;
goto bail;
}
fwrite(TIPSEC_CONTEXT(ctx_xp)->ik, TIPSEC_KEY_LEN, sizeof(uint8_t), file);
if(TIPSEC_CONTEXT(ctx_xp)->alg == algo_hmac_md5_96){ /* Pad if HMAC-MD5-96 */
uint8_t zeros[4];
memset(zeros, 0, 4);
fwrite(zeros, 4, sizeof(uint8_t), file);
}
ret = 0;
bail:
if(file){
fclose(file);
}
return ret;
}
int tipsec_set_SPDs(tipsec_context_xp_t* ctx_xp)
{
int ret = -1;
FILE* file = NULL;
char* str = NULL;
if(!ctx_xp){
goto bail;
}
if(TIPSEC_CONTEXT(ctx_xp)->state != state_full){
TSK_DEBUG_ERROR("IPSec context is in the wrong state.");
ret = -3;
goto bail;
}
if(!(file = fopen(TINYIPSEC_IPSEC6_FILE_SPD, "wb+"))){
TSK_DEBUG_ERROR("Failed to open file [%s].", TINYIPSEC_IPSEC6_FILE_SPD);
ret = -4;
goto bail;
}
tsk_sprintf(&str, TINYIPSEC_IPSEC6_TEMPLATE_POLICY,
/* UC -> PS */
TINYIPSEC_IPSEC6_UCPS_POLICY,
TIPSEC_CONTEXT(ctx_xp)->addr_remote,
TIPSEC_CONTEXT(ctx_xp)->addr_local,
TINYIPSEC_XP_GET_IPPROTO(TIPSEC_CONTEXT(ctx_xp)->ipproto),
TIPSEC_CONTEXT(ctx_xp)->port_ps,
TIPSEC_CONTEXT(ctx_xp)->port_uc,
TINYIPSEC_XP_GET_PROTO(TIPSEC_CONTEXT(ctx_xp)->protocol),
TINYIPSEC_XP_GET_MODE(TIPSEC_CONTEXT(ctx_xp)->mode),
"*", /* RemoteGWIPAddr */
"NONE", /* SABundleIndex */
"BIDIRECT", /* Direction */
"APPLY", /* Action */
"0", /* InterfaceIndex */
/* US -> PC */
TINYIPSEC_IPSEC6_USPC_POLICY,
TIPSEC_CONTEXT(ctx_xp)->addr_remote,
TIPSEC_CONTEXT(ctx_xp)->addr_local,
TINYIPSEC_XP_GET_IPPROTO(TIPSEC_CONTEXT(ctx_xp)->ipproto),
TIPSEC_CONTEXT(ctx_xp)->port_pc,
TIPSEC_CONTEXT(ctx_xp)->port_us,
TINYIPSEC_XP_GET_PROTO(TIPSEC_CONTEXT(ctx_xp)->protocol),
TINYIPSEC_XP_GET_MODE(TIPSEC_CONTEXT(ctx_xp)->mode),
"*", /* RemoteGWIPAddr */
"NONE", /* SABundleIndex */
"BIDIRECT", /* Direction */
"APPLY", /* Action */
"0" /* InterfaceIndex */
);
fwrite(str, tsk_strlen(str), sizeof(uint8_t), file);
ret = 0;
bail:
if(file){
fclose(file);
}
if(str){
TSK_FREE(str);
}
return ret;
}
int tipsec_set_SAs(tipsec_context_xp_t* ctx_xp)
{
int ret = -1;
FILE* file = NULL;
char* str = NULL;
if(!ctx_xp){
goto bail;
}
if(TIPSEC_CONTEXT(ctx_xp)->state != state_full){
TSK_DEBUG_ERROR("IPSec context is in the wrong state.");
ret = -3;
goto bail;
}
if(!(file = fopen(TINYIPSEC_IPSEC6_FILE_SAD, "wb+"))){
TSK_DEBUG_ERROR("Failed to open file [%s].", TINYIPSEC_IPSEC6_FILE_SAD);
ret = -4;
goto bail;
}
tsk_sprintf(&str, TINYIPSEC_IPSEC6_TEMPLATE_SA,
/* PC -> US */
"1", // SAEntry
TIPSEC_CONTEXT(ctx_xp)->spi_us, // SPI
TIPSEC_CONTEXT(ctx_xp)->addr_local, // SADestIPAddr
"POLICY", // DestIPAddr
"POLICY", // SrcIPAddr
"POLICY", // Protocol
"POLICY", // DestPort
"POLICY", // SrcPort
TINYIPSEC_XP_GET_ALGO(TIPSEC_CONTEXT(ctx_xp)->alg), // AuthAlg
TINYIPSEC_IPSEC6_FILE_KEY, // KeyFile
"INBOUND", // Direction
"0", /* SecPolicyIndex */
/* US -> PC */
"2", // SAEntry
TIPSEC_CONTEXT(ctx_xp)->spi_pc, // SPI
TIPSEC_CONTEXT(ctx_xp)->addr_remote, // SADestIPAddr
"POLICY", // DestIPAddr
"POLICY", // SrcIPAddr
"POLICY", // Protocol
"POLICY", // DestPort
"POLICY", // SrcPort
TINYIPSEC_XP_GET_ALGO(TIPSEC_CONTEXT(ctx_xp)->alg), // AuthAlg
TINYIPSEC_IPSEC6_FILE_KEY, // KeyFile
"OUTBOUND", // Direction
"0", /* SecPolicyIndex */
/* PS -> UC */
"3", // SAEntry
TIPSEC_CONTEXT(ctx_xp)->spi_uc, // SPI
TIPSEC_CONTEXT(ctx_xp)->addr_local, // SADestIPAddr
"POLICY", // DestIPAddr
"POLICY", // SrcIPAddr
"POLICY", // Protocol
"POLICY", // DestPort
"POLICY", // SrcPort
TINYIPSEC_XP_GET_ALGO(TIPSEC_CONTEXT(ctx_xp)->alg), // AuthAlg
TINYIPSEC_IPSEC6_FILE_KEY, // KeyFile
"INBOUND", // Direction
"0", /* SecPolicyIndex */
/* UC -> PS */
"4", // SAEntry
TIPSEC_CONTEXT(ctx_xp)->spi_ps, // SPI
TIPSEC_CONTEXT(ctx_xp)->addr_remote, // SADestIPAddr
"POLICY", // DestIPAddr
"POLICY", // SrcIPAddr
"POLICY", // Protocol
"POLICY", // DestPort
"POLICY", // SrcPort
TINYIPSEC_XP_GET_ALGO(TIPSEC_CONTEXT(ctx_xp)->alg), // AuthAlg
TINYIPSEC_IPSEC6_FILE_KEY, // KeyFile
"OUTBOUND", // Direction
"0" /* SecPolicyIndex */
);
fwrite(str, tsk_strlen(str), sizeof(uint8_t), file);
ret = 0;
bail:
if(file){
fclose(file);
}
if(str){
TSK_FREE(str);
}
return ret;
}
int tipsec_run_command(TCHAR *args)
{
#define TIPSEC_PIPE_BUFFER 1024
DWORD bread=0,tid=0;
int ret = -1;
struct handleInfo hInfo;
TCHAR _args[MAX_PATH];
HANDLE writePipe, readPipe, hThread;
SECURITY_ATTRIBUTES secAttr = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
char buffer[TIPSEC_PIPE_BUFFER];
/* Create pipes */
if((ret = CreatePipe(&readPipe, &writePipe, &secAttr, 0)) == 0) {
TSK_DEBUG_ERROR("CreatePipe failed with error code [%d].", GetLastError());
ret = -5;
goto bail;
}
wsprintf(_args, TEXT("\"%s\" %s"), TEXT("ipsec6.exe"), args );
memset(buffer, 0, TIPSEC_PIPE_BUFFER);
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = NULL;
si.hStdOutput = writePipe;
si.hStdError = NULL;
/* Create process */
if (CreateProcess(NULL, _args, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi) == 0){
TSK_DEBUG_ERROR("CreateProcess failed with error code [%d].", GetLastError());
ret = -3;
goto bail;
}
hInfo.process = pi.hProcess;
hInfo.pipe = writePipe;
/* Create thread */
if((hThread = CreateThread(NULL, 0, tipsec_waitForExit, &hInfo, 0, &tid)) == NULL) {
TSK_DEBUG_ERROR("CreateThread failed with error code [%d].", GetLastError());
ret = -4;
goto bail;
}
/* For debugging */
#if defined(DEBUG) || defined(_DEBUG)
while (ReadFile(readPipe, buffer, TIPSEC_PIPE_BUFFER-2, &bread, NULL))
{
if(bread > 0){
TSK_DEBUG_INFO("IPSEC6 ==> %s\n-------------\n", buffer);
memset(buffer, 0, TIPSEC_PIPE_BUFFER); /* reset the buffer. */
}
}
#endif
ret = 0;
bail:
return ret;
}
DWORD WINAPI tipsec_waitForExit(void *arg)
{
struct handleInfo *info = (struct handleInfo *)arg;
WaitForSingleObject(&(info->process),INFINITE);
CloseHandle(info->pipe);
return 0;
}
//=================================================================================================
// IPSec context object definition
//
static tsk_object_t* tipsec_context_ctor(tsk_object_t * self, va_list * app)
{
tipsec_context_xp_t *context = self;
if(context){
TIPSEC_CONTEXT(context)->ipproto = va_arg(*app, tipsec_ipproto_t);
TIPSEC_CONTEXT(context)->use_ipv6 = va_arg(*app, int);
TIPSEC_CONTEXT(context)->mode = va_arg(*app, tipsec_mode_t);
TIPSEC_CONTEXT(context)->ealg = va_arg(*app, tipsec_ealgorithm_t);
TIPSEC_CONTEXT(context)->alg = va_arg(*app, tipsec_algorithm_t);
TIPSEC_CONTEXT(context)->protocol = va_arg(*app, tipsec_protocol_t);
/* Open engine */
if(!TIPSEC_CONTEXT(context)->use_ipv6){
TSK_DEBUG_ERROR("IPSec/IPv4 is not supported on Windows XP.");
TIPSEC_CONTEXT(context)->initialized = tsk_false;
goto bail;
}
else{
TIPSEC_CONTEXT(context)->initialized = tsk_true;
}
TIPSEC_CONTEXT(context)->state = state_initial;
}
bail:
return self;
}
static tsk_object_t* tipsec_context_dtor(tsk_object_t * self)
{
tipsec_context_xp_t *context = self;
if(context)
{
if(TIPSEC_CONTEXT(context)->started){
tipsec_stop(TIPSEC_CONTEXT(context));
}
TSK_FREE(TIPSEC_CONTEXT(context)->addr_local);
TSK_FREE(TIPSEC_CONTEXT(context)->addr_remote);
TSK_FREE(TIPSEC_CONTEXT(context)->ik);
TSK_FREE(TIPSEC_CONTEXT(context)->ck);
}
return self;
}
static int tipsec_context_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
{
return-1;
}
static const tsk_object_def_t tipsec_context_def_s =
{
sizeof(tipsec_context_xp_t),
tipsec_context_ctor,
tipsec_context_dtor,
tipsec_context_cmp,
};
const void *tipsec_context_def_t = &tipsec_context_def_s;
#endif /* HAVE_IPSEC_XP */

View File

@ -1,50 +0,0 @@
/*
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]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.
*
*/
/**@file tipsec_xp.h
* @brief Windows XP/2003 IPsec implementation using ipsec6 tool.
* @sa http://technet.microsoft.com/en-us/library/cc787900.aspx
*
* @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
*
*/
#ifndef TINYIPSEC_IPSEC_XP_H
#define TINYIPSEC_IPSEC_XP_H
#include "tinyipsec_config.h"
#include "tipsec_common.h"
TIPSEC_BEGIN_DECLS
#if HAVE_IPSEC_XP
#endif /* HAVE_IPSEC_XP */
TIPSEC_END_DECLS
#endif /* TINYIPSEC_IPSEC_XP_H */

View File

@ -1,26 +1,23 @@
/*
* Copyright (C) 2009 Mamadou Diop.
/* Copyright (C) 2013-2014 Mamadou DIOP
* Copyright (C) 2013-2014 Doubango Telecom <http://www.doubango.org>
*
* Contact: Mamadou Diop <diopmamadou(at)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 "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
*/
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

View File

@ -1,25 +1,21 @@
/*
* Copyright (C) 2009 Mamadou Diop.
/* Copyright (C) 2013-2014 Mamadou DIOP
* Copyright (C) 2013-2014 Doubango Telecom <http://www.doubango.org>
*
* Contact: Mamadou Diop <diopmamadou(at)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 TEST_TINYIPSEC_STDAFX_H
#define TEST_TINYIPSEC_STDAFX_H
@ -30,5 +26,4 @@
#endif
// TODO: reference additional headers your program requires here
#endif /* TEST_TINYIPSEC_STDAFX_H */

View File

@ -1,159 +1,157 @@
/*
* Copyright (C) 2009 Mamadou Diop.
/* Copyright (C) 2013-2014 Mamadou DIOP
* Copyright (C) 2013-2014 Doubango Telecom <http://www.doubango.org>
*
* Contact: Mamadou Diop <diopmamadou(at)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 "stdafx.h"
#include "tipsec.h"
#include "tsk_debug.h"
//#define ADDR_REMOTE "192.168.0.9" //"2a01:e35:8b32:7050:6122:2706:2124:32ca"//"192.168.0.15"
//#define ADDR_LOCAL "192.168.0.12" //"2a01:e35:8b32:7050:6122:2706:2124:32cb"//"192.168.0.14"
#define ADDR_REMOTE "2001:5c0:1502:1800::225"
#define ADDR_LOCAL "2001:5c0:1502:1800:5cc8:4a4e:3ef7:3314"
#define USE_IPV6 1
#define IK "1234567890123456"
#define CK "1234567890121234"
#define PORT_UC 1010
#define PORT_US 2020
#define PORT_PC 3030
#define PORT_PS 4040
#define SPI_PC 2222
#define SPI_PS 3333
*/
#include "stdafx.h"
#include "tipsec.h"
#include "tsk_plugin.h"
#include "tsk_debug.h"
static tipsec_ipproto_t __ipproto = tipsec_ipproto_udp;
static tsk_bool_t __use_ipv6 = tsk_false;
static tipsec_mode_t __mode = tipsec_mode_trans;
static tipsec_ealg_t __ealg = tipsec_ealg_des_ede3_cbc;
static tipsec_alg_t __alg = tipsec_alg_hmac_md5_96;
static tipsec_proto_t __proto = tipsec_proto_ah;
static const char* __addr_local = "0.0.0.0";
static const char* __addr_remote = "192.168.0.34";
static tipsec_port_t __port_local_out = 5062; // PORT_UC
static tipsec_port_t __port_local_in = 5064; // PORT_US
static tipsec_port_t __port_remote_out = 5066; // PORT_PC
static tipsec_port_t __port_remote_in = 5068; // PORT_PS
static tipsec_spi_t __spi_remote_out = 3333; // SPI_PC
static tipsec_spi_t __spi_remote_in = 4444; // SPI_PS
static tipsec_lifetime_t __lifetime = 1800; /* always set it to the maximum value. (Not possible to update the value after REGISTER 200OK. ) */
static const char* __key_ik = "1234567890123456";
static const char* __key_ck = "1234567890121234";
#if TIPSEC_UNDER_WINDOWS
#include <Windows.h>
static tsk_bool_t test_ipsec_is_winvista_or_later()
{
/*
Version Number Description
6.1 Windows 7 / Windows 2008 R2
6.0 Windows Vista / Windows 2008
5.2 Windows 2003
5.1 Windows XP
5.0 Windows 2000
*/
static DWORD dwMajorVersion = -1;
static DWORD dwMinorVersion = -1;
if(dwMajorVersion == -1 || dwMinorVersion == -1){
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
dwMajorVersion = osvi.dwMajorVersion;
dwMinorVersion = osvi.dwMinorVersion;
}
return (dwMajorVersion >= 6);
}
#else
static tsk_bool_t test_ipsec_is_winvista_or_later()
{
return 0;
}
#endif
#ifdef _WIN32_WCE
int _tmain(int argc, _TCHAR* argv[])
#else
int main()
#endif
{
int ret;
tipsec_lifetime_t lifetime = 600000; /* Always set it to the maximum value. (Not possible to update the value after REGISTER 200OK. ) */
tipsec_context_t * ctx = tipsec_context_create(ipproto_icmp, USE_IPV6, mode_trans, ealg_aes, algo_hmac_md5_96, proto_both);
if((ret = tipsec_set_local(ctx, ADDR_LOCAL, ADDR_REMOTE, PORT_UC, PORT_US))){
goto bail;
}
/* Now send your first request with security-client header using
*/
TSK_DEBUG_INFO("Security-Client: ipsec-3gpp; alg=%s; ealg=%s; spi-c=%u; spi-s=%u; port-c=%u; port-s=%u\n\n",
TIPSEC_ALG_TO_STR(ctx->alg), TIPSEC_EALG_TO_STR(ctx->ealg), ctx->spi_uc, ctx->spi_us, ctx->port_uc, ctx->port_us
);
getchar();
/* get and process the 401/407
*/
if((ret = tipsec_set_remote(ctx, SPI_PC, SPI_PS, PORT_PC, PORT_PS, lifetime))){
goto bail;
}
tipsec_set_keys(ctx, IK, CK);
/* Start */
if((ret = tipsec_start(ctx))){
goto bail;
}
TSK_DEBUG_INFO("ALL IS OOOOOOOK");
getchar();
if((ret = tipsec_stop(ctx))){
goto bail;
}
bail:
TSK_OBJECT_SAFE_FREE(ctx);
//ipsec_context_t* context = 0;
//uint32_t spi_local_s = 0, spi_local_c = 0, spi_remote_s = 0, spi_remote_c = 0;
////http://www.arib.or.jp/IMT-2000/V740Dec09/2_T63/ARIB-STD-T63/Rel7/33/A33203-790.pdf
///* create context */
//IPSEC_CONTEXT_CREATE(context);
//// FIXME: check context validity
///* set algorithms, proto and mode */
//context->auth = iaa_hmac_md5_96;
//context->encrypt = iea_null;
//context->proto = ipp_esp;
//context->mode = ipm_transport;
//
///* set ik and ck */
//ipsec_set_ck(context, CK);
//ipsec_set_ik(context, IK);
///* set local and remote IPs */
//context->localIP = ipsec_strdup(LOCAL_IP);
//context->remoteIP = ipsec_strdup(REMOTE_IP);
//context->ipv6 = 0;
///* set local ports */
//context->SAs[ipd_incoming_req].port = PORT_LOCAL_S; /* US <- PC */
//context->SAs[ipd_incoming_rep].port = PORT_LOCAL_C; /* UC <- PS */
///* get local spis */
//spi_local_s = ipsec_get_spi(context, ipd_incoming_req);
//spi_local_c = ipsec_get_spi(context, ipd_incoming_rep);
///*******
// now send your first request with security-client header using
// ...
//*/
//printf("Security-Client: ipsec-3gpp; alg=%s; ealg=%s; spi-c=%u; spi-s=%u; port-c=%u; port-s=%u\n\n",
// IPSEC_AUTH_ALG_STR(context->auth), IPSEC_ENC_ALG_STR(context->encrypt), spi_local_c, spi_local_s, PORT_LOCAL_C, PORT_LOCAL_S
// );
//getchar();
///*
// get and process the 401/407
// ...
//*/
//printf("Security-Server: ipsec-3gpp; q=0.1; alg=%s; ealg=%s; spi-c=%u; spi-s=%u; port-c=%u; port-s=%u\n\n",
// IPSEC_AUTH_ALG_STR(context->auth), IPSEC_ENC_ALG_STR(context->encrypt), SPI_REMOTE_C, SPI_REMOTE_S, PORT_REMOTE_C, PORT_REMOTE_S
// );
///* set values for remote entity */
//context->SAs[ipd_outgoing_rep].port = PORT_REMOTE_C; /* US -> PC */
//context->SAs[ipd_outgoing_rep].spi = SPI_REMOTE_C; /* US -> PC */
//context->SAs[ipd_outgoing_req].port = PORT_REMOTE_S; /* UC -> PS */
//context->SAs[ipd_outgoing_req].spi = SPI_REMOTE_S; /* UC -> PS */
///* bound SAs and begin sending/receiving sip messages */
//ipsec_sa_bound(context, ipd_incoming_rep);
//ipsec_sa_bound(context, ipd_incoming_req);
//ipsec_sa_bound(context, ipd_outgoing_rep);
//ipsec_sa_bound(context, ipd_outgoing_req);
//getchar();
///* free context */
//IPSEC_CONTEXT_SAFE_FREE(context);
return 0;
}
#endif
{
int err = 0;
tsk_size_t i;
struct tsk_plugin_s* p_plugin = tsk_null;
tipsec_ctx_t* p_ctx = tsk_null;
static const char* __plugins_path[] = /* Visual Studio requires "Debugging" -> "Working Directory" = "$(OutDir)" */
{
"pluginWinIPSecVista.DLL",
"pluginWinIPSecXP.DLL",
"pluginLinIPsecTools.so"
};
static const tsk_size_t __plugins_count = sizeof(__plugins_path)/sizeof(__plugins_path[0]);
/* Create the plugin */
for (i = 0; i < __plugins_count; ++i) {
if (tsk_plugin_file_exist(__plugins_path[i])) {
tipsec_plugin_register_file(__plugins_path[i], &p_plugin);
if (p_plugin) {
break;
}
}
}
if (!p_plugin) {
TSK_DEBUG_ERROR("Failed to create IPSec plugin");
err = -1; goto bail;
}
/* Create the context */
err = tipsec_ctx_create(__ipproto, __use_ipv6, __mode, __ealg, __alg, __proto, &p_ctx);
if (err) {
goto bail;
}
/* Set local */
err = tipsec_ctx_set_local(p_ctx, __addr_local, __addr_remote, __port_local_out, __port_local_in);
if (err) {
goto bail;
}
// Dump SPIs created by the OS after calling set_local()
TSK_DEBUG_INFO("SPI-UC=%u, SPI-US=%u", p_ctx->spi_uc, p_ctx->spi_us);
/* Set remote */
err = tipsec_ctx_set_remote(p_ctx, __spi_remote_out, __spi_remote_in, __port_remote_out, __port_remote_in, __lifetime);
if (err) {
goto bail;
}
/* Set Integrity (IK) and Confidentiality (CK) keys */
err = tipsec_ctx_set_keys(p_ctx, __key_ik, __key_ck);
if (err) {
goto bail;
}
/* Start (Setup) the SAs */
err = tipsec_ctx_start(p_ctx);
if (err) {
goto bail;
}
TSK_DEBUG_INFO("!!! IPSec SAs started (Press any key to stop) !!!");
/* Wait */
getchar();
bail:
// Stop the SAs, cleanup and destroy the context
TSK_OBJECT_SAFE_FREE(p_ctx); // must destroy the contect before unloading the plugin (*.DLL or *.SO)
// Unregister the plugin and close the file handle
if (p_plugin) {
tipsec_plugin_unregister_file(p_plugin);
TSK_OBJECT_SAFE_FREE(p_plugin);
}
return err;
}

View File

@ -41,13 +41,14 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(DOUBANGO_HOME)\thirdparties\win32\include&quot;;&quot;$(SolutionDir)\src&quot;;&quot;$(DOUBANGO_HOME)\tinySAK\src&quot;"
AdditionalIncludeDirectories="..\..\thirdparties\win32\include;&quot;$(SolutionDir)\src&quot;;..\..\tinySAK\src"
PreprocessorDefinitions="DEBUG_LEVEL=DEBUG_LEVEL_INFO;WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
WarnAsError="true"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
CompileAs="1"
@ -118,10 +119,12 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\thirdparties\win32\include;&quot;$(SolutionDir)\src&quot;;..\..\tinySAK\src"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
WarnAsError="true"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>

View File

@ -4,8 +4,24 @@ Microsoft Visual Studio Solution File, Format Version 10.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinySAK", "..\tinySAK\tinySAK.vcproj", "{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyIPSec", "tinyIPSec.vcproj", "{002FF064-588F-402E-A096-C8D033F49F40}"
ProjectSection(ProjectDependencies) = postProject
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcproj", "{E40FEB1F-BE85-488D-BCBE-89668F6EBBF7}"
ProjectSection(ProjectDependencies) = postProject
{002FF064-588F-402E-A096-C8D033F49F40} = {002FF064-588F-402E-A096-C8D033F49F40}
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}
{AAD0B2B5-8D8C-4DE0-BB20-1AB6CFAA617D} = {AAD0B2B5-8D8C-4DE0-BB20-1AB6CFAA617D}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "plugins", "plugins", "{C912B38F-CF43-4E66-BC61-A2475663BB31}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pluginWinIPSecVista", "..\plugins\pluginWinIPSecVista\pluginWinIPSecVista.vcproj", "{AAD0B2B5-8D8C-4DE0-BB20-1AB6CFAA617D}"
ProjectSection(ProjectDependencies) = postProject
{002FF064-588F-402E-A096-C8D033F49F40} = {002FF064-588F-402E-A096-C8D033F49F40}
{6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA} = {6BC9B796-10C6-4CF7-A6E4-E2DACCDA84DA}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -37,8 +53,17 @@ Global
{E40FEB1F-BE85-488D-BCBE-89668F6EBBF7}.Release|Win32.ActiveCfg = Release|Win32
{E40FEB1F-BE85-488D-BCBE-89668F6EBBF7}.Release|Win32.Build.0 = Release|Win32
{E40FEB1F-BE85-488D-BCBE-89668F6EBBF7}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
{AAD0B2B5-8D8C-4DE0-BB20-1AB6CFAA617D}.Debug|Win32.ActiveCfg = Debug|Win32
{AAD0B2B5-8D8C-4DE0-BB20-1AB6CFAA617D}.Debug|Win32.Build.0 = Debug|Win32
{AAD0B2B5-8D8C-4DE0-BB20-1AB6CFAA617D}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32
{AAD0B2B5-8D8C-4DE0-BB20-1AB6CFAA617D}.Release|Win32.ActiveCfg = Release|Win32
{AAD0B2B5-8D8C-4DE0-BB20-1AB6CFAA617D}.Release|Win32.Build.0 = Release|Win32
{AAD0B2B5-8D8C-4DE0-BB20-1AB6CFAA617D}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{AAD0B2B5-8D8C-4DE0-BB20-1AB6CFAA617D} = {C912B38F-CF43-4E66-BC61-A2475663BB31}
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Version="9.00"
Name="tinyIPSec"
ProjectGUID="{002FF064-588F-402E-A096-C8D033F49F40}"
RootNamespace="tinyIPSec"
@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;..\thirdparties\win32\include&quot;;&quot;..\tinySAK\src&quot;"
AdditionalIncludeDirectories="..\thirdparties\win32\include;..\tinySAK\src"
PreprocessorDefinitions="HAVE_IPSEC=0;WIN32;_WIN32_WINNT=0x0501;_DEBUG;_WINDOWS;_USRDLL;TINYIPSEC_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -121,7 +121,7 @@
Name="VCCLCompilerTool"
Optimization="3"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="&quot;..\thirdparties\win32\include&quot;;&quot;..\tinySAK\src&quot;"
AdditionalIncludeDirectories="..\thirdparties\win32\include;..\..\tinySAK\src"
PreprocessorDefinitions="HAVE_IPSEC=0;WIN32;_WIN32_WINNT=0x0501;NDEBUG;_WINDOWS;_USRDLL;TINYIPSEC_EXPORTS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="false"
@ -187,22 +187,6 @@
RelativePath=".\src\tipsec.c"
>
</File>
<File
RelativePath=".\src\tipsec_common.c"
>
</File>
<File
RelativePath=".\src\tipsec_racoon.c"
>
</File>
<File
RelativePath=".\src\tipsec_vista.c"
>
</File>
<File
RelativePath=".\src\tipsec_xp.c"
>
</File>
</Filter>
<Filter
Name="include(*.h)"
@ -215,22 +199,6 @@
RelativePath=".\src\tipsec.h"
>
</File>
<File
RelativePath=".\src\tipsec_common.h"
>
</File>
<File
RelativePath=".\src\tipsec_racoon.h"
>
</File>
<File
RelativePath=".\src\tipsec_vista.h"
>
</File>
<File
RelativePath=".\src\tipsec_xp.h"
>
</File>
</Filter>
<Filter
Name="resources(*.rc)"

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango telecom"
VALUE "FileDescription", "Doubango IMS Framework"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "tinyipsec.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "tinyipsec.dll"
VALUE "ProductName", "Doubango IMS Framework"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango telecom"
VALUE "FileDescription", "Doubango IMS Framework"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "tinymedia.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "tinymedia.dll"
VALUE "ProductName", "Doubango IMS Framework"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango telecom"
VALUE "FileDescription", "Doubango IMS Framework"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "tinymsrp.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "tinymsrp.dll"
VALUE "ProductName", "Doubango IMS Framework"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango telecom"
VALUE "FileDescription", "Doubango IMS Framework"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "tinynet.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "tinynet.dll"
VALUE "ProductName", "Doubango IMS Framework"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango telecom"
VALUE "FileDescription", "Doubango IMS Framework"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "tinyrtp.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "tinyrtp.dll"
VALUE "ProductName", "Doubango IMS Framework"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -36,6 +36,7 @@ typedef enum tsk_plugin_def_type_e
tsk_plugin_def_type_jb = (1 << 5),
tsk_plugin_def_type_denoiser = (1 << 6),
tsk_plugin_def_type_converter = (1 << 7),
tsk_plugin_def_type_ipsec = (1 << 8),
tsk_plugin_def_type_all = (~0)
}
tsk_plugin_def_type_t;

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango telecom"
VALUE "FileDescription", "Doubango IMS Framework"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "tinywrap.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "tinywrap.dll"
VALUE "ProductName", "Doubango IMS Framework"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango telecom"
VALUE "FileDescription", "Doubango IMS Framework"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "tinysdp.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "tinysdp.dll"
VALUE "ProductName", "Doubango IMS Framework"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -53,8 +53,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,972
PRODUCTVERSION 2,0,0,972
FILEVERSION 2,0,0,1001
PRODUCTVERSION 2,0,0,1001
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -71,12 +71,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Doubango telecom"
VALUE "FileDescription", "Doubango IMS Framework"
VALUE "FileVersion", "2.0.0.972"
VALUE "FileVersion", "2.0.0.1001"
VALUE "InternalName", "tinysigcomp.dll"
VALUE "LegalCopyright", "(c) 2010-2013 Doubango Telecom. All rights reserved."
VALUE "OriginalFilename", "tinysigcomp.dll"
VALUE "ProductName", "Doubango IMS Framework"
VALUE "ProductVersion", "2.0.0.972"
VALUE "ProductVersion", "2.0.0.1001"
END
END
BLOCK "VarFileInfo"

View File

@ -48,10 +48,14 @@ typedef struct tsip_ipsec_association_s
const tsip_transport_t* transport;
tipsec_context_t* ctx;
tipsec_ctx_t* ctx;
tnet_socket_t *socket_uc;
tnet_socket_t *socket_us;
tnet_ip_t ip_remote;
tnet_ip_t ip_local;
tnet_port_t port_local;
}
tsip_ipsec_association_t;

View File

@ -36,8 +36,6 @@
#include "tinysip/tsip_message.h"
#include "tsip.h"
#include "tipsec.h"
TSIP_BEGIN_DECLS
typedef struct tsip_transport_layer_s

View File

@ -28,7 +28,7 @@
* @sa 3G Security
* <a href="http://www.3gpp.org/ftp/Specs/html-info/35205.htm"> 3GPP TS 35.205 </a>
* <a href="http://www.3gpp.org/ftp/Specs/html-info/35206.htm"> 3GPP TS 35.206 </a>
* <a href="http://www.3gpp.org/ftp/Specs/html-info/35207.htm"> 3GPP TS 35.208 </a>
* <a href="http://www.3gpp.org/ftp/Specs/html-info/35207.htm"> 3GPP TS 35.207 </a>
* <a href="http://www.3gpp.org/ftp/Specs/html-info/35208.htm"> 3GPP TS 35.208 </a>
* <a href="http://www.3gpp.org/ftp/Specs/html-info/35909.htm"> 3GPP TS 35.909 </a>
*-------------------------------------------------------------------

View File

@ -31,6 +31,8 @@
#include "tinysip/transactions/tsip_transac_layer.h"
#include "tipsec.h"
#include "tsk_memory.h"
#include "tsk_debug.h"
#include "tsk_time.h"

View File

@ -65,9 +65,9 @@ int tsip_header_Security_Client_serialize(const tsip_header_t* header, tsk_buffe
const tsip_header_Security_Client_t *Security_Client = (const tsip_header_Security_Client_t *)header;
int ret = 0;
// ipsec-3gpp; alg=hmac-md5-96; ealg=des-ede3-cbc; spi-c=1111; spi-s=2222; port-c=5062; port-s=5064
// ipsec-3gpp; alg=hmac-md5-96; ealg=des-ede3-cbc; mod=trans; spi-c=1111; spi-s=2222; port-c=5062; port-s=5064
if(tsk_striequals(Security_Client->mech, "ipsec-3gpp")){
ret = tsk_buffer_append_2(output, "%s%s%s%s%s%s%s;spi-c=%u;spi-s=%u;port-c=%u;port-s=%u",
ret = tsk_buffer_append_2(output, "%s%s%s%s%s%s%s%s%s;spi-c=%u;spi-s=%u;port-c=%u;port-s=%u",
Security_Client->mech,
Security_Client->alg ? ";alg=" : "",
@ -78,6 +78,9 @@ int tsip_header_Security_Client_serialize(const tsip_header_t* header, tsk_buffe
Security_Client->prot ? ";prot=" : "",
Security_Client->prot ? Security_Client->prot : "",
Security_Client->prot ? ";mod=" : "",
Security_Client->prot ? Security_Client->mod : "",
Security_Client->spi_c,
Security_Client->spi_s,

View File

@ -560,13 +560,10 @@ tsk_size_t tsip_transport_send(const tsip_transport_t* self, const char *branch,
}
else if(TNET_SOCKET_TYPE_IS_IPSEC(self->type)){
tnet_fd_t fd = tsip_transport_ipsec_getFD(TSIP_TRANSPORT_IPSEC(self), TSIP_MESSAGE_IS_REQUEST(msg));
if(fd != TNET_INVALID_FD){
//struct sockaddr_storage to;
//tnet_sockaddr_init("2001:5c0:1502:1800::225", 4060, self->type, &to);
//tnet_sockfd_sendto(fd, (const struct sockaddr *)&to, buffer->data, buffer->size);
ret = tnet_sockfd_send(fd, buffer->data, buffer->size, 0);
}
// "fd == TNET_INVALID_FD" means IPSec SAs not up yet
ret = (fd != TNET_INVALID_FD)
? tnet_sockfd_send(fd, buffer->data, buffer->size, 0)
: tsip_transport_send_raw(self, destIP, destPort, buffer->data, buffer->size, callid);
}
else{
ret = tsip_transport_send_raw(self, destIP, destPort, buffer->data, buffer->size, callid);

Some files were not shown because too many files have changed in this diff Show More