summaryrefslogtreecommitdiffstats
path: root/tinySIP/test
diff options
context:
space:
mode:
Diffstat (limited to 'tinySIP/test')
-rw-r--r--tinySIP/test/droid-makefile28
-rw-r--r--tinySIP/test/stdafx.c26
-rw-r--r--tinySIP/test/stdafx.h41
-rw-r--r--tinySIP/test/targetver.h14
-rw-r--r--tinySIP/test/test.c85
-rw-r--r--tinySIP/test/test.vcproj404
-rw-r--r--tinySIP/test/test_imsaka.h93
-rw-r--r--tinySIP/test/test_ip6_torture.h1
-rw-r--r--tinySIP/test/test_sipmessages.h265
-rw-r--r--tinySIP/test/test_stack.h521
-rw-r--r--tinySIP/test/test_transac.h34
-rw-r--r--tinySIP/test/test_uri.h177
12 files changed, 1689 insertions, 0 deletions
diff --git a/tinySIP/test/droid-makefile b/tinySIP/test/droid-makefile
new file mode 100644
index 0000000..4c10009
--- /dev/null
+++ b/tinySIP/test/droid-makefile
@@ -0,0 +1,28 @@
+APP := test
+
+CFLAGS := $(CFLAGS_COMMON) -I../include -I../../tinySAK/src -I../../tinyNET/src -I../../tinyHTTP/include
+LDFLAGS := $(LDFLAGS_COMMON) -Wl,-Bsymbolic,--whole-archive -l$(PROJECT) -ltinySAK -ltinyNET -Wl,--entry=main
+
+all: $(APP)
+
+OBJS += $(APP).o
+
+$(APP): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^
+
+%.o: %.c
+ $(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@
+
+install: $(APP)
+ $(ANDROID_SDK_ROOT)/tools/adb push $(APP) $(EXEC_DIR)/$(APP)
+ $(ANDROID_SDK_ROOT)/tools/adb shell chmod 777 $(EXEC_DIR)/$(APP)
+
+run:
+ $(ANDROID_SDK_ROOT)/tools/adb shell $(EXEC_DIR)/$(APP)
+
+#dbg:
+# $(MAKE) $(MAKEFILE) DEBUG="-g -DDEBUG"
+# $(MAKE) $(MAKEFILE) install
+
+clean:
+ @rm -f $(OBJS) $(APP) \ No newline at end of file
diff --git a/tinySIP/test/stdafx.c b/tinySIP/test/stdafx.c
new file mode 100644
index 0000000..2983941
--- /dev/null
+++ b/tinySIP/test/stdafx.c
@@ -0,0 +1,26 @@
+/*
+* Copyright (C) 2009 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.
+*
+*/
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/tinySIP/test/stdafx.h b/tinySIP/test/stdafx.h
new file mode 100644
index 0000000..0632737
--- /dev/null
+++ b/tinySIP/test/stdafx.h
@@ -0,0 +1,41 @@
+/*
+* Copyright (C) 2009 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.
+*
+*/
+
+#ifndef TEST_TSIP_STDAFX_H
+#define TEST_TSIP_STDAFX_H
+
+#ifdef WIN32
+#include "targetver.h"
+#endif
+
+#include <stdio.h>
+
+#if (defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE)) && !defined(__SYMBIAN32__)
+#include <tchar.h>
+#endif
+
+
+
+// TODO: reference additional headers your program requires here
+#include <string.h>
+
+#endif /* TEST_TSIP_STDAFX_H */
diff --git a/tinySIP/test/targetver.h b/tinySIP/test/targetver.h
new file mode 100644
index 0000000..9927d16
--- /dev/null
+++ b/tinySIP/test/targetver.h
@@ -0,0 +1,14 @@
+#ifndef TSIP_TEST_TARGETVER_H
+#define TSIP_TEST_TARGETVER_H
+// The following macros define the minimum required platform. The minimum required platform
+// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
+// your application. The macros work by enabling all features available on platform versions up to and
+// including the version specified.
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
+#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#endif /* TSIP_TEST_TARGETVER_H */
diff --git a/tinySIP/test/test.c b/tinySIP/test/test.c
new file mode 100644
index 0000000..64eef40
--- /dev/null
+++ b/tinySIP/test/test.c
@@ -0,0 +1,85 @@
+/*
+* Copyright (C) 2009 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.
+*
+*/
+
+#include "stdafx.h"
+
+#include "tinysip.h"
+
+#include "test_sipmessages.h"
+#include "test_uri.h" /*SIP/SIPS/TEL*/
+#include "test_transac.h"
+#include "test_stack.h"
+#include "test_imsaka.h"
+
+
+#define RUN_TEST_LOOP 1
+
+#define RUN_TEST_ALL 0
+#define RUN_TEST_MESSAGES 1
+#define RUN_TEST_URI 0
+#define RUN_TEST_TRANSAC 0
+#define RUN_TEST_STACK 0
+#define RUN_TEST_IMS_AKA 0
+
+#ifdef _WIN32_WCE
+int _tmain(int argc, _TCHAR* argv[])
+#else
+int main()
+#endif
+{
+ tnet_startup();
+
+#if RUN_TEST_LOOP
+ for(;;)
+#endif
+ {
+ /* Print copyright information */
+ printf("Doubango Project\nCopyright (C) 2009 - 2010 Mamadou Diop \n\n");
+
+
+
+#if RUN_TEST_ALL || RUN_TEST_MESSAGES
+ test_messages();
+#endif
+
+#if RUN_TEST_ALL || RUN_TEST_URI
+ test_uri();
+#endif
+
+#if RUN_TEST_ALL ||RUN_TEST_TRANSAC
+ test_transac();
+#endif
+
+#if RUN_TEST_ALL || RUN_TEST_STACK
+ test_stack();
+#endif
+
+#if RUN_TEST_ALL || RUN_TEST_IMS_AKA
+ test_imsaka();
+#endif
+ }
+
+ tnet_cleanup();
+
+ return 0;
+}
+
diff --git a/tinySIP/test/test.vcproj b/tinySIP/test/test.vcproj
new file mode 100644
index 0000000..7868008
--- /dev/null
+++ b/tinySIP/test/test.vcproj
@@ -0,0 +1,404 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="test"
+ ProjectGUID="{353640F9-25C2-4850-BCF8-07A07D8E46AE}"
+ RootNamespace="test"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;$(SolutionDir)include&quot;;..\..\thirdparties\win32\include;..\..\tinySAK\src;..\..\tinyNET\src;..\..\tinyHTTP\include;..\..\tinyMEDIA\include;..\..\tinySDP\include"
+ PreprocessorDefinitions="DEBUG_LEVEL=DEBUG_LEVEL_INFO;WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ WarnAsError="true"
+ DebugInformationFormat="4"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinySIP.lib $(OutDir)\tinyNET.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
+ OutputDirectory="&quot;$(SolutionDir)$(ConfigurationName)\wce&quot;"
+ IntermediateDirectory="&quot;$(SolutionDir)$(ConfigurationName)&quot;"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="1"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ ExecutionBucket="7"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;$(DOUBANGO_HOME)\thirdparties\win32\include&quot;;&quot;$(SolutionDir)\include&quot;;&quot;$(DOUBANGO_HOME)\tinySAK\src&quot;;&quot;$(DOUBANGO_HOME)\tinyNET\src&quot;;&quot;$(DOUBANGO_HOME)\tinyHTTP\include&quot;"
+ PreprocessorDefinitions="DEBUG_LEVEL=DEBUG_LEVEL_INFO;_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;$(ARCHFAM);$(_ARCHFAM_);_CONSOLE"
+ MinimalRebuild="true"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ WarnAsError="true"
+ DebugInformationFormat="3"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinySIP.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="8"
+ EntryPointSymbol="mainWCRTStartup"
+ TargetMachine="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCCodeSignTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ <DeploymentTool
+ ForceDirty="-1"
+ RemoteDirectory=""
+ RegisterOutput="0"
+ AdditionalFiles=""
+ />
+ <DebuggerTool
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="&quot;$(SolutionDir)\include&quot;;..\..\thirdparties\win32\include;..\..\tinySAK\src;..\..\tinyNET\src;..\..\tinyHTTP\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ WarnAsError="true"
+ DebugInformationFormat="3"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
+ OutputDirectory="$(SolutionDir)Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\$(ConfigurationName)"
+ IntermediateDirectory="Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="1"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ ExecutionBucket="7"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ WarnAsError="true"
+ DebugInformationFormat="3"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCCodeSignTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ <DeploymentTool
+ ForceDirty="-1"
+ RemoteDirectory=""
+ RegisterOutput="0"
+ AdditionalFiles=""
+ />
+ <DebuggerTool
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\stdafx.c"
+ >
+ </File>
+ <File
+ RelativePath=".\test.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\stdafx.h"
+ >
+ </File>
+ <File
+ RelativePath=".\targetver.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="tests"
+ 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=".\test_imsaka.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_ip6_torture.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_sipmessages.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_stack.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_transac.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_uri.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/tinySIP/test/test_imsaka.h b/tinySIP/test/test_imsaka.h
new file mode 100644
index 0000000..3b5d35d
--- /dev/null
+++ b/tinySIP/test/test_imsaka.h
@@ -0,0 +1,93 @@
+/*
+* Copyright (C) 2009 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.
+*
+*/
+#ifndef _TEST_IMS_AKA_H
+#define _TEST_IMS_AKA_H
+
+#include "tinysip/authentication/tsip_challenge.h" /* Not part of the API */
+
+#define TEST_IMS_AKA_REQUEST "REGISTER sip:ims.inexbee.com SIP/2.0\r\n" \
+"v: SIP/2.0/TCP 192.168.16.82:2851;branch=z9hG4bK1272986926192;rport\r\n" \
+"f: <sip:bob@ims.inexbee.com>;tag=1272986909384\r\n" \
+"t: <sip:bob@ims.inexbee.com>\r\n" \
+"m: <sip:bob@192.168.16.82:2851;transport=tcp>;expires=30;+g.oma.sip-im;+g.3gpp.smsip;language=\"en,fr\"\r\n" \
+"i: ef566354-2051-df74-b888-1d30e1753213\r\n" \
+"CSeq: 30149 REGISTER\r\n" \
+"l: 0\r\n" \
+"Max-Forwards: 70\r\n" \
+"Authorization: Digest username=\"bob@ims.inexbee.com\",realm=\"ims.inexbee.com\",nonce=\"\",uri=\"sip:ims.inexbee.com\",response=\"\"\r\n" \
+"Privacy: header;id\r\n" \
+"Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n" \
+"P-Access-Network-Info: ADSL;utran-cell-id-3gpp=00000000\r\n" \
+"User-Agent: IM-client/OMA1.0 doubango/v1.0.0\r\n" \
+"P-Preferred-Identity: <sip:bob@ims.inexbee.com>\r\n" \
+"k: path\r\n" \
+"Action-Header: Myheader-value\r\n" \
+"\r\n"
+
+
+
+void test_imsaka()
+{
+ tsip_challenge_t* challenge;
+ tsip_stack_handle_t *stack;
+ tsip_request_t *request = tsk_null;
+ tsk_ragel_state_t state;
+ tsip_header_Authorization_t* hdr_Auth;
+
+ /* create the SIP stack */
+ stack = tsip_stack_create(tsk_null, "sip:ims.inexbee.com", "bob@ims.inexbee.com", "sip:bob@ims.inexbee.com",
+ TSIP_STACK_SET_PASSWORD("bob"),
+ TSIP_STACK_SET_NULL());
+
+ /* create the chalenge */
+ challenge = tsip_challenge_create(stack,
+ tsk_false,
+ "Digest", /* scheme */
+ "ims.inexbee.com", /* realm */
+ "RqhHfrN+ciXaM4mt8k/0Lyx7bgshVgAA5TcTpiTtqsY=", /* nonce */
+ tsk_null, /* opaque */
+ "AKAv1-MD5", /* algorithm */
+ "auth" /* qop */
+ );
+
+ /* Parse SIP request */
+ tsk_ragel_state_init(&state, TEST_IMS_AKA_REQUEST, tsk_strlen(TEST_IMS_AKA_REQUEST));
+ if(!tsip_message_parse(&state, &request, tsk_true)){
+ goto bail;
+ }
+
+ /* Gets auth header */
+ if((hdr_Auth = (tsip_header_Authorization_t*)tsip_challenge_create_header_authorization(challenge, request))){
+ TSK_DEBUG_INFO("Response=[%s]", hdr_Auth->response);
+ }
+
+
+bail:
+ TSK_OBJECT_SAFE_FREE(request);
+ TSK_OBJECT_SAFE_FREE(challenge);
+ TSK_OBJECT_SAFE_FREE(stack);
+
+ getchar();
+}
+
+#endif /* _TEST_IMS_AKA_H */
+
diff --git a/tinySIP/test/test_ip6_torture.h b/tinySIP/test/test_ip6_torture.h
new file mode 100644
index 0000000..7e180e2
--- /dev/null
+++ b/tinySIP/test/test_ip6_torture.h
@@ -0,0 +1 @@
+// http://tools.ietf.org/html/rfc5118 \ No newline at end of file
diff --git a/tinySIP/test/test_sipmessages.h b/tinySIP/test/test_sipmessages.h
new file mode 100644
index 0000000..47b5608
--- /dev/null
+++ b/tinySIP/test/test_sipmessages.h
@@ -0,0 +1,265 @@
+/*
+* Copyright (C) 2009 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.
+*
+*/
+#ifndef _TEST_SIPMESSAGES_H
+#define _TEST_SIPMESSAGES_H
+
+#define SIP_REQUEST \
+ "REGISTER sip:open-ims.test SIP/2.0\r\n" \
+ "Test-Header: 0\r\n" \
+ "v: SIP/2.0/UDP [::]:1988;test=1234;comp=sigcomp;rport=254;ttl=457;received=192.0.2.101;branch=z9hG4bK1245420841406\r\n" \
+ "f: \"Mamadou\" <sip:mamadou@open-ims.test>;tag=29358\r\n" \
+ "t: <sip:mamadou@open-ims.test>;tag= 12345\r\n" \
+ "i: M-fa53180346f7f55ceb8d8670f9223dbb\r\n" \
+ "CSeq: 201 REGISTER\r\n" \
+ "Max-Forwards: 70\r\n" \
+ "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK\r\n" \
+ "Allow: REFER, UPDATE\r\n" \
+ "u: talk, hold, conference, LocalModeStatus\r\n" \
+ "m: <sip:mamadou@[::]:1988;comp=sigcomp;transport=udp>;expires=600000;+deviceID=\"3ca50bcb-7a67-44f1-afd0-994a55f930f4\";mobility=\"fixed\";+g.3gpp.cs-voice;+g.3gpp.app%5fref=\"urn%3Aurnxxx%3A3gpp-application.ims.iari.gsmais\";+g.oma.sip-im.large-message;+g.oma.sip-im\r\n" \
+ "User-Agent: IM-client/OMA1.0 doubango/v0.0.0\r\n" \
+ "Require: pref, path\r\n" \
+ "Service-Route: <sip:orig@open-ims.test:6060;lr>,<sip:orig2@open-ims.test:6060;lr>\r\n" \
+ "Path: <sip:term@open-ims.test:4060;lr>\r\n" \
+ "Require: 100rel\r\n" \
+ "P-Preferred-Identity: <sip:mamadou@open-ims.test>\r\n" \
+ "k: path\r\n" \
+ "k: gruu, outbound, timer\r\n" \
+ "P-Access-Network-Info: 3GPP-UTRAN-TDD;utran-cell-id-3gpp=00000000\r\n" \
+ "Privacy: none;user;id\r\n" \
+ "Supported: gruu, outbound, path, timer\r\n" \
+ "Expires12: 1983\r\n" \
+ "l: 180\r\n" \
+ "\r\n"
+
+#define SIP_RESPONSE \
+ "SIP/2.0 200 This is my reason phrase\r\n" \
+ "To: <sip:mamadou@open-ims.test>;tag=bweyal\r\n" \
+ "Via: SIP/2.0/UDP 192.168.0.11:63140;branch=z9hG4bK1261611942868;rport=63140\r\n" \
+ "CSeq: 31516 REGISTER\r\n" \
+ "Content-Length: 0\r\n" \
+ "Call-ID: 1261611941121\r\n" \
+ "Min-Expires: 30\r\n" \
+ "Event: reg\r\n" \
+ "From: <sip:mamadou@open-ims.test>;tag=1261611941121\r\n" \
+ "Contact: <sip:mamadou@192.168.0.12:58827;transport=udp>;mobility=fixed;+deviceid=\"DD1289FA-C3D7-47bd-A40D-F1F1B2CC5FFC\";expires=300,<sip:mamadou@192.168.0.12:58828;transport=udp>;mobility=fixed;+deviceid=\"DD1289FA-C3D7-47bd-A40D-F1F1B2CC5FFC\";expires=300,<sip:mamadou@192.168.0.12:58829;transport=udp>;mobility=fixed;+deviceid=\"DD1289FA-C3D7-47bd-A40D-F1F1B2CC5FFC\";expires=300\r\n"\
+ "Contact: <sip:mamadou@192.168.0.11:63140>;expires=3600;q=1.0,<sip:mamadou@192.168.0.11:56717>;expires=3600;q=1.0\r\n" \
+ "Contact: <sip:mamadou@127.0.0.1:5060>;expires=3600;q=1.0\r\n" \
+ "Contact: <sip:mamadou@127.0.0.1>;expires=3600;q=1.0\r\n" \
+ "P-Preferred-Identity: <sip:mamadou@open-ims.test>\r\n" \
+ "Service-Route: <sip:orig@open-ims.test:6060;lr><sip:orig2@open-ims.test:6060;lr>,<sip:orig3@open-ims.test:6060;lr>\r\n" \
+ "Path: <sip:term@open-ims.test:4060;lr>\r\n" \
+ "P-Access-Network-Info: 3GPP-UTRAN-TDD;utran-cell-id-3gpp=00000000\r\n" \
+ "Authorization: Digest username=\"Alice\", realm=\"atlanta.com\",nonce=\"84a4cc6f3082121f32b42a2187831a9e\",response=\"7587245234b3434cc3412213e5f113a5432,test=123\"\r\n" \
+ "Privacy: none;user;id\r\n" \
+ "Proxy-Authenticate: Digest realm=\"atlanta.com\",domain=\"sip:ss1.carrier.com\",qop=\"auth,auth-int\",nonce=\"f84f1cec41e6cbe5aea9c8e88d359\",opaque=\"\", stale=FALSE, algorithm=MD5,test=124\r\n" \
+ "Authorization: Digest username=\"bob\", realm=\"atlanta.example.com\",nonce=\"ea9c8e88df84f1cec4341ae6cbe5a359\", opaque=\"\",uri=\"sips:ss2.biloxi.example.com\",test=\"7854\",response=\"dfe56131d1958046689d83306477ecc\"\r\n" \
+ "Proxy-Authorization: Digest username=\"Alice\", test=666,realm=\"atlanta.com\",nonce=\"c60f3082ee1212b402a21831ae\",response=\"245f23415f11432b3434341c022\"\r\n" \
+ "WWW-Authenticate: Digest realm=\"atlanta.com\",domain=\"sip:boxesbybob.com\", qop=\"auth\",nonce=\"f84f1cec41e6cbe5aea9c8e88d359\",opaque=\"\",stale=FALSE,algorithm=MD5,test=\"3\"\r\n" \
+ "l: 0\r\n" \
+ "Subscription-State: active;reason=deactivated;expires=507099;retry-after=145;test=jk\r\n"\
+ "\r\n"
+
+ //"Via: SIP/2.0/UDP 192.168.0.11:64163;rport=4;branch=z9hG4bK1262758946486\r\n" \
+ //"Via: SIP/2.0/UDP 192.168.0.11:59265;rport=59265;branch=z9hG4bK1263064096664\r\n" \
+
+#define SIP_MESSAGE \
+ "MESSAGE sip:mamadou@open-ims.test SIP/2.0\r\n" \
+ "Via: SIP/2.0/tcp 127.0.0.1:5082;branch=z9hG4bKc16be5aee32df400d01015675ab911ba,SIP/2.0/udp 127.0.0.1:5082;branch=z9hG4bKeec53b25db240bec92ea250964b8c1fa;received_port_ext=5081;received=192.168.0.13,SIP/2.0/UDP 192.168.0.12:57121;rport=57121;branch=z9hG4bK1274980921982;received_port_ext=5081;received=192.168.0.12\r\n" \
+ "From: Bob <sip:bob@open-ims.test>;tag=mercuro\r\n" \
+ "To: \"Alice\"<sip:alice@open-ims.test>\r\n" \
+ "m: <sip:mamadou@127.0.0.1:5060>\r\n" \
+ "Call-ID: 1262767804423\r\n" \
+ "CSeq: 8 MESSAGE\r\n" \
+ "Refer-To: <sips:a8342043f@atlanta.example.com?Replaces=12345601%40atlanta.example.com%3Bfrom-tag%3D314159%3Bto-tag%3D1234567>\r\n" \
+ "Refer-To: sip:conf44@example.com;isfocus\r\n" \
+ "Referred-By: <sip:referrer@referrer.example>;cid=\"20398823.2UWQFN309shb3@referrer.example\"\r\n" \
+ "Refer-Sub: false;test=45;op\r\n" \
+ "Refer-Sub: true;p\r\n" \
+ "RSeq: 17422\r\n" \
+ "RAck: 776656 1 INVITE\r\n" \
+ "Min-SE: 90;test;y=0\r\n" \
+ "Session-Expires: 95;refresher=uas;y=4\r\n" \
+ "x: 95;refresher=uac;o=7;k\r\n" \
+ "Max-Forwards: 70\r\n" \
+ "Date: Wed, 28 Apr 2010 23:42:50 GMT\r\n" \
+ "Date: Sun, 2 May 2010 20:27:49 GMT\r\n" \
+ "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n" \
+ "User-Agent: IM-client/OMA1.0 TestUA/v4.0.1508.0\r\n" \
+ "c: text/plain; charset=utf-8\r\n" \
+ "Security-Client: ipsec-3gpp;alg=hmac-md5-96;ealg=aes-cbc;prot=esp;mod=trans;port-c=61676;port-s=61662;spi-c=4294967295;spi-s=67890,tls;q=0.2\r\n" \
+ "Security-Client: ipsec-ike;q=0.1,tls;q=0.2;test=123\r\n" \
+ "Security-Server: ipsec-ike;q=0.1,ipsec-3gpp;alg=hmac-md5-96;prot=esp;mod=trans;ealg=aes-cbc;spi-c=5000;spi-s=5001;port-c=78952;port-s=77854\r\n" \
+ "Security-Verify: ipsec-3gpp;alg=hmac-md5-96;prot=esp;mod=trans;ealg=aes-cbc;spi-c=5000;spi-s=5001;port-c=9999;port-s=20000,ipsec-ike;q=0.1;test=458;toto\r\n" \
+ "Service-Route: <sip:orig@open-ims.test:6060;lr;transport=udp>,<sip:atlanta.com>,\"Originating\" <sip:orig2@open-ims.test:6060;lr>\r\n" \
+ "Path: <sip:term@open-ims.test:4060;lr>\r\n" \
+ "Route: \"Prox-CSCF\" <sip:pcscf.open-ims.test:4060;lr;transport=udp>;test=1,\"Originating\" <sip:orig@scscf.open-ims.test:6060;lr>\r\n" \
+ "Record-Route: <sip:mo@pcscf.ims.inexbee.com:4060;lr>,\"Originating\"<sip:pcscf.open-ims.test:4060;lr;transport=udp>;test=2\r\n" \
+ "P-Preferred-Identity: <sip:bob@open-ims.test\r\n" \
+ "Allow-Events: presence, presence.winfo\r\n" \
+ "Event: reg\r\n" \
+ "P-Associated-URI: <sip:bob@open-ims.test>, <sip:0600000001@open-ims.test>, <sip:0100000001@open-ims.test>\r\n" \
+ "P-Charging-Function-Addresses: ccf=pri_ccf_address\r\n" \
+ "Server: Sip EXpress router (2.0.0-dev1 OpenIMSCore (i386/linux))\r\n" \
+ "Warning: 392 192.168.0.15:6060 \"Noisy feedback tells: pid=4521 req_src_ip=192.168.0.15 req_src_port=5060 in_uri=sip:scscf.open-ims.test:6060 out_uri=sip:scscf.open-ims.test:6060 via_cnt==3\"\r\n" \
+ "P-Asserted-Identity: \"Cullen Jennings\" <sip:fluffy@cisco.com>\r\n" \
+ "P-Asserted-Identity: tel:+14085264000\r\n" \
+ "WWW-Authenticate: Digest realm=\"ims.inexbee.com\", nonce=\"iTaxDEv2uO8sKxzVVaRy6IkU9Lra6wAA2xv4BrmCzvY=\", algorithm=AKAv1-MD5, qop=\"auth\"\r\n" \
+ "WWW-Authenticate: Digest realm=\"ims.cingularme.com\",\r\n nonce=\"b7c9036dbf3054aea9404c7286aee9703dc8f84c2008\",\r\n opaque=\"Lss:scsf-stdn.imsgroup0-001.ims1.wtcdca1.mobility.att.net:5060\",\r\n algorithm=MD5,\r\n qop=\"auth\"\r\n" \
+ "Content-Length: 11\r\n" \
+ "Etag: W/'1231-3213213'\r\n" \
+ "\r\n" \
+ "How are you"
+
+
+#define SIP_PUB_GRUU \
+"SIP/2.0 200 OK - SAR succesful and registrar saved\r\n" \
+"Via: SIP/2.0/UDP 192.168.1.103:46268;received=10.19.3.201;received=10.19.3.201;branch=z9hG4bK1431761912;rport=46268;keep\r\n" \
+"From: <sip:1111111111@open-ims.test>;tag=728193295\r\n" \
+"To: <sip:1111111111@open-ims.test>;tag=80332102165c3c2994562ca45e4f4401-b009\r\n" \
+"Call-ID: ecfb4022-eb8f-ca0d-6885-fbeaafa65854\r\n" \
+"CSeq: 1767541515 REGISTER\r\n" \
+"P-Associated-URI: <sip:1111111111@open-ims.test>\r\n" \
+"Contact: <sip:1111111111@192.168.1.103:37761;transport=udp>;expires=1593;pub-gruu=\"sip:1111111111@open-ims.test;gr=urn%3Auuid%3A00000000-0000-AAAA-8000-18879680264c\"\r\n" \
+"Contact: <sip:1111111111@192.168.1.103:46268;transport=udp>;expires=1700;pub-gruu=\"sip:1111111111@open-ims.test;gr=urn%3Auuid%3A00000000-0000-AAAA-8000-18879680264c\"\r\n" \
+"Path: <sip:term@pcscf.open-ims.test:4060;lr>\r\n" \
+"Service-Route: <sip:orig@scscf.open-ims.test:6060;lr>\r\n" \
+"Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, PUBLISH, MESSAGE, INFO\r\n" \
+"P-Charging-Function-Addresses: ccf=pri_ccf_address\r\n" \
+"Server: Sip EXpress router (2.1.0-dev1 OpenIMSCore (x86_64/linux))\r\n" \
+"Content-Length: 0\r\n" \
+"Warning: 392 10.19.3.160:6060 \"Noisy feedback tells: pid=30444 req_src_ip=10.19.3.160 req_src_port=5060 in_uri=sip:scscf.open-ims.test:6060 out_uri=sip:scscf.open-ims.test:6060 via_cnt==3\"\r\n" \
+"\r\n" \
+
+
+#define SIP_OPTIONS \
+"SIP/2.0 200 OK\r\n" \
+"Via: SIP/2.0/TCP 192.168.1.110:49144;received=10.19.3.223;received=10.19.3.223;branch=z9hG4bK580365294;rport=49144\r\n" \
+"From: <sip:bob@open-ims.test>;tag=912385275\r\n" \
+"To: <sip:1947@open-ims.test>;tag=131610378\r\n" \
+"Contact: <sip:bob@192.168.1.135:46716;transport=tcp>;impi=a@example.com\r\n" \
+"Call-ID: cbfac0bb-9426-c8cf-fbd9-96bc91ec8acb\r\n" \
+"CSeq: 756765417 OPTIONS\r\n" \
+"Content-Length: 0\r\n" \
+"Accept-Contact: \r\n" \
+"Accept: application/sdp\r\n" \
+"Accept-Encoding: *\r\n" \
+"Accept-Language: en\r\n" \
+"Allow: INVITE, ACK, CANCEL, BYE, PRACK, UPDATE, REFER, MESSAGE,OPTIONS\r\n" \
+"Supported: gruu\r\n" \
+"P-Asserted-Identity: <sip:1947@open-ims.test>\r\n" \
+"\r\n"
+
+#define SIP_COMPACT \
+"SIP/2.0 200 OK\r\n" \
+"Via: SIP/2.0/TCP 10.51.2.181:51483;branch=z9hG4bK1652501;rport=51483;received=10.51.2.181\r\n" \
+"From: <sip:847...@10.50.4.29>;tag=1656856\r\n" \
+"To: <sip:847...@10.50.4.29>;tag=4553420699375288838\r\n" \
+"Contact: <sip:8475551001@10.51.2.181:51483;transport=tcp>;+g.oma.sip-im;language=\"en,fr\"\r\n" \
+"Call-ID: d1dab636-ff9b-2672-7521-4bea5e73fa7f\r\n" \
+"CSeq: 24466 SUBSCRIBE\r\n" \
+"l: 0\r\n" \
+"Expires: 3600\r\n" \
+"\r\n"
+
+
+
+#define SIP_MSG_2_TEST SIP_OPTIONS
+
+void test_parser()
+{
+ tsk_ragel_state_t state;
+ tsip_message_t *message = tsk_null;
+ tsk_buffer_t *buffer = tsk_buffer_create_null();
+ const tsip_header_Contact_t* header_contact;
+ tsk_size_t i;
+
+ tsk_ragel_state_init(&state, SIP_MSG_2_TEST, tsk_strlen(SIP_MSG_2_TEST));
+ tsip_message_parse(&state, &message, tsk_true);
+
+ for(i = 0; (header_contact = (const tsip_header_Contact_t*)tsip_message_get_headerAt(message, tsip_htype_Contact, i)); ++i){
+ const char* pub_gruu = TSIP_HEADER_GET_PARAM_VALUE(header_contact, "pub-gruu");
+ TSK_DEBUG_INFO("pub-gruu for contact header at index %d = %s", i, (pub_gruu ? pub_gruu : "null"));
+ }
+
+ tsip_message_tostring(message, buffer);
+ TSK_DEBUG_INFO("Buffer=\n%s", TSK_BUFFER_TO_STRING(buffer));
+
+ TSK_OBJECT_SAFE_FREE(message);
+ TSK_OBJECT_SAFE_FREE(buffer);
+}
+
+
+void test_requests()
+{
+ tsk_buffer_t *buffer = tsk_buffer_create_null();
+ tsip_uri_t *from = tsip_uri_parse("sip:mamadou@open-ims.test", tsk_strlen("sip:mamadou@open-ims.test"));
+ tsip_uri_t *request_uri = tsip_uri_parse("sip:open-ims.test", tsk_strlen("sip:open-ims.test"));
+
+
+ tsip_request_t *request = tsip_request_new("REGISTER", request_uri, from, from, "ABCDEFGHIJKLMOPQRSTUVWXYZ", 4521);
+
+ tsip_message_tostring(request, buffer);
+ TSK_DEBUG_INFO("Buffer=\n%s", TSK_BUFFER_TO_STRING(buffer));
+
+
+ TSK_OBJECT_SAFE_FREE(from);
+ TSK_OBJECT_SAFE_FREE(request_uri);
+ TSK_OBJECT_SAFE_FREE(request);
+ TSK_OBJECT_SAFE_FREE(buffer);
+}
+
+void test_responses()
+{
+ tsk_ragel_state_t state;
+ tsip_request_t *request = 0;
+ tsip_request_t *response = 0;
+
+ tsk_ragel_state_init(&state, SIP_MSG_2_TEST, tsk_strlen(SIP_MSG_2_TEST));
+ tsip_message_parse(&state, &request, tsk_true);
+
+ /* Create the response and destroy the request */
+ response = tsip_response_new(200, "OK you can move forward", request);
+ TSK_OBJECT_SAFE_FREE(request);
+
+ {
+ /* DUMP the response */
+ tsk_buffer_t *buffer = tsk_buffer_create_null();
+
+ tsip_message_tostring(response, buffer);
+ TSK_DEBUG_INFO("Response=\n%s", TSK_BUFFER_TO_STRING(buffer));
+
+ TSK_OBJECT_SAFE_FREE(buffer);
+ }
+
+
+ TSK_OBJECT_SAFE_FREE(response);
+}
+
+void test_messages()
+{
+ test_parser();
+ //test_requests();
+ //test_responses();
+}
+
+
+#endif /* _TEST_SIPMESSAGES_H */
diff --git a/tinySIP/test/test_stack.h b/tinySIP/test/test_stack.h
new file mode 100644
index 0000000..7cfc04c
--- /dev/null
+++ b/tinySIP/test/test_stack.h
@@ -0,0 +1,521 @@
+/*
+* Copyright (C) 2009 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.
+*
+*/
+#ifndef _TEST_STACK_H
+#define _TEST_STACK_H
+
+#ifndef LOCAL_IP
+# ifdef ANDROID
+# define LOCAL_IP "10.0.2.15"
+# else
+# define LOCAL_IP TNET_SOCKET_HOST_ANY
+# endif
+#endif
+
+#define TEST_STACK_SDP \
+ "v=0\r\n" \
+ "o=bob 2890844730 2890844731 IN IP4 host.example.com\r\n" \
+ "s=\r\n" \
+ "c=IN IP4 192.168.0.12\r\n" \
+ "t=0 0\r\n" \
+ "m=audio 54344 RTP/AVP 0\r\n" \
+ "a=rtpmap:0 PCMU/8000\r\n"
+
+#define TEST_STACK_PIDF \
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>"\
+ "<presence xmlns:cp=\"urn:ietf:params:xml:ns:pidf:cipid\" xmlns:caps=\"urn:ietf:params:xml:ns:pidf:caps\" xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\" xmlns:pdm=\"urn:ietf:params:xml:ns:pidf:data-model\" xmlns:p=\"urn:ietf:params:xml:ns:pidf-diff\" xmlns:op=\"urn:oma:xml:prs:pidf:oma-pres\" entity=\"sip:mamadou@"DOMAIN"\" xmlns=\"urn:ietf:params:xml:ns:pidf\">"\
+ " <pdm:person id=\"CRUVREZS\">"\
+ " <op:overriding-willingness>"\
+ " <op:basic>open</op:basic>"\
+ " </op:overriding-willingness>"\
+ " <rpid:activities>"\
+ " <rpid:unknown />"\
+ " </rpid:activities>"\
+ " <rpid:mood>"\
+ " <rpid:neutral />"\
+ " </rpid:mood>"\
+ " <pdm:note>Hello world</pdm:note>"\
+ " </pdm:person>"\
+ " <pdm:device id=\"d0001\">"\
+ " <status>"\
+ " <basic>open</basic>"\
+ " </status>"\
+ " <caps:devcaps>"\
+ " <caps:mobility>"\
+ " <caps:supported>"\
+ " <caps:fixed />"\
+ " </caps:supported>"\
+ " </caps:mobility>"\
+ " </caps:devcaps>"\
+ " <op:network-availability>"\
+ " <op:network id=\"IMS\">"\
+ " <op:active />"\
+ " </op:network>"\
+ " </op:network-availability>"\
+ " <pdm:deviceID>urn:uuid:dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc</pdm:deviceID>"\
+ " </pdm:device>"\
+ "</presence>"
+
+int test_stack_callback(const tsip_event_t *sipevent)
+{
+ TSK_DEBUG_INFO("\n====\nSTACK event: %d [%s] with opid=%lld\n=====",
+ sipevent->code, sipevent->phrase, tsip_ssession_get_id(sipevent->ss));
+
+ // For ssessions created by the stack ==> call tsk_object_ref(sipevent->ssession);
+ // to take ownership.
+
+ switch(sipevent->type)
+ {
+ //
+ // REGISTER
+ //
+ case tsip_event_register:
+ {
+ const tsip_register_event_t* _event;
+ TSK_DEBUG_INFO("SIP event(REGISTER)");
+
+ _event = TSIP_REGISTER_EVENT(sipevent);
+ switch(_event->type){
+ case tsip_ao_register: /* Answer to Outgoing REGISTER */
+ {
+ if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){
+ TSK_DEBUG_INFO("Registration succeed.");
+ }
+ else{
+ TSK_DEBUG_INFO("Registration failed.");
+ }
+ break;
+ }
+ case tsip_ao_unregister: /* Answer to Outgoing UNREGISTER */
+ {
+ if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){
+ TSK_DEBUG_INFO("UnRegistration succeed.");
+ }
+ else{
+ TSK_DEBUG_INFO("UnRegistration failed.");
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ break;
+ }
+
+ //
+ // INVITE
+ //
+ case tsip_event_invite:
+ {
+ TSK_DEBUG_INFO("SIP event(INVITE)");
+ break;
+ }
+
+ //
+ // MESSAGE
+ //
+ case tsip_event_message:
+ {
+ const tsip_message_event_t* _event;
+ TSK_DEBUG_INFO("SIP event(MESSAGE)");
+
+ _event = TSIP_MESSAGE_EVENT(sipevent);
+ switch(_event->type)
+ {
+ case tsip_i_message: /* Incoming MESSAGE */
+ {
+ if(TSIP_MESSAGE_HAS_CONTENT(sipevent->sipmessage)){
+ TSK_DEBUG_INFO("MESSAGE Content: %s", TSIP_MESSAGE_CONTENT(sipevent->sipmessage));
+ }
+ break;
+ }
+ case tsip_ao_message: /* Answer to Outgoing MESSAGE */
+ {
+ if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){
+ TSK_DEBUG_INFO("MESSAGE successfully sent.");
+ }
+ else{
+ TSK_DEBUG_INFO("Failed to send MESSAGE (sip code:%d).", TSIP_RESPONSE_CODE(sipevent->sipmessage));
+ }
+ }
+ default:
+ break;
+ }
+
+ break;
+ }
+
+ //
+ // PUBLISH
+ //
+ case tsip_event_publish:
+ {
+ TSK_DEBUG_INFO("SIP event(PUBLISH)");
+ break;
+ }
+
+ //
+ // SUBSCRIBE
+ //
+ case tsip_event_subscribe:
+ {
+ const tsip_subscribe_event_t* _event;
+ TSK_DEBUG_INFO("SIP event(SUBSCRIBE)");
+
+ _event = TSIP_SUBSCRIBE_EVENT(sipevent);
+ switch(_event->type)
+ {
+ case tsip_i_notify: /* Incoming NOTIFY */
+ {
+ if(TSIP_MESSAGE_CONTENT_DATA(sipevent->sipmessage)){
+ TSK_DEBUG_INFO("NOTIFY Content: %s", TSIP_MESSAGE_CONTENT(sipevent->sipmessage));
+ }
+ break;
+ }
+ case tsip_ao_subscribe: /* Answer to Outgoing SUBSCRIBE */
+ {
+ if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){
+ TSK_DEBUG_INFO("Subscription succeed.");
+ }
+ else{
+ TSK_DEBUG_INFO("Subscription failed.");
+ }
+ break;
+ }
+ case tsip_ao_unsubscribe: /* Answer to Outgoing UNSUBSCRIBE */
+ {
+ if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){
+ TSK_DEBUG_INFO("UnSubscription succeed.");
+ }
+ else{
+ TSK_DEBUG_INFO("UnSubscription failed.");
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ break;
+ }
+
+ default:
+ {
+ TSK_DEBUG_INFO("SIP event(UNKNOWN)");
+ break;
+ }
+ }
+
+ //tsk_thread_sleep(1000000);
+
+ return 0;
+}
+
+
+void test_stack()
+{
+#define DOMAIN "ericsson.com"
+//#define DOMAIN "micromethod.com"
+//#define DOMAIN "ims.inexbee.com"
+//#define DOMAIN "sip2sip.info"
+
+ const void* usr_context = tsk_null;
+ int ret;
+ uint16_t AMF = 0x0001;
+/*
+ tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback,
+ TSIP_STACK_SET_DISPLAY_NAME("2233392625"),
+ TSIP_STACK_SET_PUBLIC_IDENTITY("sip:2233392625@"DOMAIN),
+ TSIP_STACK_SET_PRIVATE_IDENTITY("2233392625"),
+ TSIP_STACK_SET_PASSWORD("d3sb7j4fb8"),
+ TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip:
+ TSIP_STACK_SET_LOCAL_IP(LOCAL_IP),
+ //TSIP_STACK_SET_DISCOVERY_NAPTR(1),
+ //TSIP_STACK_SET_PROXY_CSCF("proxy.sipthor.net", "udp", 0),
+ //TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0),
+ TSIP_STACK_SET_PROXY_CSCF_PORT(5060),
+ TSIP_STACK_SET_MOBILITY("fixed"),
+ TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"),
+ TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"),
+ TSIP_STACK_SET_PRIVACY("header;id"),
+*/
+
+ /*
+ tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback,
+ TSIP_STACK_SET_DISPLAY_NAME("Mamadou"),
+ TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@"DOMAIN),
+ TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@"DOMAIN),
+ TSIP_STACK_SET_PASSWORD("mamadou"),
+ TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip:
+ TSIP_STACK_SET_LOCAL_IP(LOCAL_IP),
+ //TSIP_STACK_SET_DISCOVERY_NAPTR(1),
+ TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0),
+ //TSIP_STACK_SET_PROXY_CSCF_PORT(5081),
+ TSIP_STACK_SET_PROXY_CSCF_PORT(5060),
+ //TSIP_STACK_SET_SECAGREE_IPSEC("hmac-md5-96", "null", "trans", "esp"),
+ TSIP_STACK_SET_MOBILITY("fixed"),
+ TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"),
+ TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"),
+ TSIP_STACK_SET_PRIVACY("header;id"),
+*/
+
+
+
+ int32_t port = 4060;
+/*
+ tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, "sip:"DOMAIN, "mamadou@"DOMAIN, "sip:mamadou@"DOMAIN,
+ TSIP_STACK_SET_DISPLAY_NAME("Mamadou"),
+ TSIP_STACK_SET_PASSWORD("mamadou"),
+ TSIP_STACK_SET_IMS_AKA_AMF(AMF),
+ TSIP_STACK_SET_IMS_AKA_OPERATOR_ID("0xff08"),
+ TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"),
+
+ TSIP_STACK_SET_PROXY_CSCF("192.168.16.225", port, "udp", "ipv4"),
+
+ TSIP_STACK_SET_EARLY_IMS(tsk_true),
+*/
+
+ tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, "sip:"DOMAIN, "mamadou@"DOMAIN, "sip:mamadou@"DOMAIN,
+ TSIP_STACK_SET_DISPLAY_NAME("Mamadou"),
+ TSIP_STACK_SET_PASSWORD("mamadou"),
+ TSIP_STACK_SET_IMS_AKA_AMF(AMF),
+ TSIP_STACK_SET_IMS_AKA_OPERATOR_ID("0xff08"),
+ TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"),
+
+ TSIP_STACK_SET_PROXY_CSCF("192.168.0.13", 5081, "tcp", "ipv4"),
+ TSIP_STACK_SET_LOCAL_IP(LOCAL_IP),
+
+ TSIP_STACK_SET_EARLY_IMS(tsk_true),
+
+
+/*
+ tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, "sip:"DOMAIN, "2233392625", "sip:2233392625@"DOMAIN,
+ TSIP_STACK_SET_DISPLAY_NAME("Mamadou"),
+ TSIP_STACK_SET_PASSWORD("d3sb7j4fb8"),
+
+ TSIP_STACK_SET_EARLY_IMS(tsk_true),
+
+ TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"),
+*/
+/*
+ tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback,
+ TSIP_STACK_SET_DISPLAY_NAME("Mamadou"),
+ TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@"DOMAIN),
+ TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@"DOMAIN),
+ TSIP_STACK_SET_PASSWORD("mamadou"),
+ TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip:
+ TSIP_STACK_SET_LOCAL_IP(LOCAL_IP),
+ //TSIP_STACK_SET_DISCOVERY_NAPTR(1),
+ TSIP_STACK_SET_PROXY_CSCF("192.168.16.104", "udp", 0),
+ //TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0),
+ TSIP_STACK_SET_PROXY_CSCF_PORT(5060),
+ //TSIP_STACK_SET_SECAGREE_IPSEC("hmac-md5-96", "null", "trans", "esp"),
+ TSIP_STACK_SET_MOBILITY("fixed"),
+ TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"),
+ TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"),
+ TSIP_STACK_SET_PRIVACY("header;id"),
+*/
+
+ TSIP_STACK_SET_NULL());
+
+
+
+
+ //tsip_ssession_handle_t *op = tsip_ssession_create(stack,
+ // TSIP_SSESSION_SET_CONTEXT(usr_context),
+ // TSIP_SSESSION_SET_HEADER("expires", "30"),
+ // TSIP_SSESSION_SET_HEADER("Persistence", "session"),
+ //
+ // TSIP_SSESSION_SET_CAPS("language", "\"en,fr\""),
+ // TSIP_SSESSION_SET_CAPS("+audio", ""),
+ // TSIP_SSESSION_SET_CAPS("+g.oma.sip-im", ""),
+ //
+ // tsk_null);
+
+
+tsip_ssession_handle_t *op = tsip_ssession_create(stack,
+ TSIP_SSESSION_SET_EXPIRES(30),
+
+ TSIP_SSESSION_SET_CAPS("+g.oma.sip-im", ""),
+ TSIP_SSESSION_SET_CAPS("+audio", ""),
+ TSIP_SSESSION_SET_CAPS("automata", ""),
+ TSIP_SSESSION_SET_CAPS("language", "\"en,fr\""),
+
+ TSIP_SSESSION_SET_HEADER("Supported", "ssl"),
+ TSIP_SSESSION_SET_HEADER("P-Access-Network-Info", "3GPP-UTRAN-TDD;utran-cell-id-3gpp=AAAAA0000BBBB"),
+
+ TSIP_SSESSION_UNSET_HEADER("P-Access-Network-Info"),
+
+ TSIP_SSESSION_SET_NULL());
+
+ //tsip_ssession_id_t opid = tsip_ssession_get_id(op);
+
+ if((ret = tsip_stack_start(stack))){
+ goto bail;
+ }
+
+ tsip_action_REGISTER(op,
+ TSIP_ACTION_SET_HEADER("My-Header-1", "My-Value-1"),
+ TSIP_ACTION_SET_HEADER("My-Header-2", "My-Value-1"),
+
+ TSIP_ACTION_SET_NULL());
+
+ getchar();
+ //tsk_thread_sleep(2000);
+
+ tsip_action_UNREGISTER(op,
+ TSIP_ACTION_SET_NULL()
+ );
+
+ getchar();
+ tsk_thread_sleep(2000);
+
+ //tsip_unregister(op,
+ // TSIP_ACTION_SET_HEADER("Persistence2", "action"),
+ //
+ // tsk_null);
+/*
+ tsip_subscribe(op,
+ TSIP_ACTION_SET_HEADER("Persistence", "action"),
+
+ tsk_null);
+
+ tsk_thread_sleep(5000);
+
+ tsip_unsubscribe(op,
+ TSIP_ACTION_SET_HEADER("Persistence2", "action"),
+
+ tsk_null);
+ */
+
+ /* INVITE */
+ /*
+ {
+ tsip_ssession_handle_t *call = TSIP_SSESSION_CREATE(stack,
+ TSIP_SSESSION_SET_HEADER("to", "sip:samba@"DOMAIN),
+ TSIP_SSESSION_SET_CAPS("+g.3gpp.icsi-ref", "\"urn%3Aurn-7%3gpp-service.ims.icsi.mmtel\""),
+ TSIP_SSESSION_SET_HEADER("Supported", "timer, norefersub, precondition"),
+ TSIP_SSESSION_SET_HEADER("Require", "100rel"),
+
+ TSIP_SSESSION_SET_PARAM("content", TEST_STACK_SDP),
+
+ TSIP_SSESSION_SET_NULL());
+ tsip_invite(stack, call);
+ }
+ */
+
+ /* SUBSCRIBE */
+ //{
+ // tsip_ssession_handle_t *ss2 = tsip_ssession_create(stack,
+ // TSIP_SSESSION_SET_CONTEXT(usr_context),
+ // TSIP_SSESSION_SET_HEADER("expires", "35"),
+ // TSIP_SSESSION_SET_HEADER("Event", "reg"),
+ // TSIP_SSESSION_SET_HEADER("Accept", "application/reginfo+xml"),
+ // TSIP_SSESSION_SET_HEADER("Allow-Events", "refer, presence, presence.winfo, xcap-diff"),
+ // TSIP_SSESSION_SET_HEADER("Allow", "INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER"),
+ //
+ // tsk_null);
+
+ // tsip_subscribe(ss2,
+ // TSIP_ACTION_SET_HEADER("Description", "subscribing"),
+
+ // tsk_null);
+
+ // getchar();
+
+ // tsip_unsubscribe(ss2,
+ // TSIP_ACTION_SET_HEADER("Test", "unsubscribing"),
+ //
+ // tsk_null);
+ //}
+
+ /* MESSAGE */
+ //{
+ // tsip_ssession_handle_t *ss3 = TSIP_SSESSION_CREATE(stack,
+ // TSIP_SSESSION_SET_HEADER("to", "sip:alice@"DOMAIN),
+ // TSIP_SSESSION_SET_HEADER("Accept-Contact", "*;+g.oma.sip-im"),
+ //
+ // tsk_null);
+ // tsip_message(ss3,
+ // TSIP_ACTION_SET_HEADER("Content-Type", "text/plain"),
+ // TSIP_ACTION_SET_PAYLOAD("Hello world!", tsk_strlen("Hello world!")),
+
+ // tsk_null
+ // );
+ //}
+
+ /* PUBLISH */
+ /*{
+ tsip_ssession_handle_t *ss4 = TSIP_SSESSION_CREATE(stack,
+ TSIP_SSESSION_SET_HEADER("expires", "30"),
+ TSIP_SSESSION_SET_HEADER("to", "sip:mamadou@"DOMAIN),
+
+ TSIP_SSESSION_SET_HEADER("Accept-Contact", "*;+g.oma.sip-im"),
+ TSIP_SSESSION_SET_HEADER("Event", "presence"),
+
+ tsk_null);
+
+ tsip_publish(ss4,
+ TSIP_ACTION_SET_HEADER("Description", "publish"),
+ TSIP_ACTION_SET_HEADER("Content-Type", "application/pidf+xml"),
+ TSIP_ACTION_SET_PAYLOAD(TEST_STACK_PIDF, tsk_strlen(TEST_STACK_PIDF)),
+
+ tsk_null);
+
+ getchar();
+
+ tsip_unpublish(ss4,
+ TSIP_ACTION_SET_HEADER("Description", "unpublish"),
+
+ tsk_null);
+ }
+ */
+ // /*getchar();
+ // tsip_ssession_set(op4,
+ // TSIP_SSESSION_SET_PARAM("content", TEST_STACK_PIDF),
+
+ // TSIP_SSESSION_SET_NULL());
+ // tsip_publish(stack, op4);*/
+ //
+ // getchar();
+ // tsip_ssession_hangup(op4);
+ //
+ //}
+bail:
+ //while(1);//tsk_thread_sleep(500);
+ //while(1)
+ //tsk_thread_sleep(50000);
+ getchar();
+
+ tsip_stack_stop(stack);
+
+ TSK_OBJECT_SAFE_FREE(op);
+ TSK_OBJECT_SAFE_FREE(stack);
+
+ TSK_DEBUG_INFO("==================");
+ TSK_DEBUG_INFO("==================");
+ TSK_DEBUG_INFO("==================");
+ TSK_DEBUG_INFO("==================");
+}
+
+
+#endif /* _TEST_STACK_H */
diff --git a/tinySIP/test/test_transac.h b/tinySIP/test/test_transac.h
new file mode 100644
index 0000000..3f31173
--- /dev/null
+++ b/tinySIP/test/test_transac.h
@@ -0,0 +1,34 @@
+/*
+* Copyright (C) 2009 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.
+*
+*/
+#ifndef _TEST_TRANSAC_H
+#define _TEST_TRANSAC_H
+
+void test_transac()
+{
+ //tsip_transac_nict_t transact;
+
+ //tsip_transac_nict_init(&transact);
+
+ //tsk_thread_sleep(2000);
+}
+
+#endif /* _TEST_TRANSAC_H */
diff --git a/tinySIP/test/test_uri.h b/tinySIP/test/test_uri.h
new file mode 100644
index 0000000..befbdfd
--- /dev/null
+++ b/tinySIP/test/test_uri.h
@@ -0,0 +1,177 @@
+/*
+* Copyright (C) 2009 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.
+*
+*/
+#ifndef _TEST_SIPURI_H
+#define _TEST_SIPURI_H
+
+const char* uris[] =
+{
+
+ //== SIP:
+ "sip:123.com",
+ "sip:open-ims.test",
+ "sip:pcscf.open-ims.test:4060;lr;transport=udp",
+ "sip:2233392625@sip2sip.info",
+ "sip:alice@iatlanta.com;p1=23",
+ "sip:*666*@atlanta.com",
+ "sip:#66#@atlanta.com", // should fail: # must be replaced with %23
+ "sip:alice:secretword@atlanta.com",
+ "sip:alice:secretword@atlanta.com:65535;transport=tcp",
+ "sip:+1-212-555-1212:1234@gateway.com;user=phone",
+ "sip:alice@192.0.2.4:5060",
+ "sip:alice@[1111::aaa:bbb:ccc:ddd]:5060",
+ "sip:atlanta.com",
+ "sip:alice@[1111::aaa:bbb:ccc:ddd]",
+ "sip:alice@[1111::aaa:bbb:ccc:ddd]:5060;user=phone",
+ "sip:alice@1111::aaa:bbb:ccc:ddd", // should fail
+ "sip:alice@[::127]",
+ "sip:ss2.biloxi.example.com;lr",// FIXME
+ "sip:atlanta.com;method=REGISTER?to=alice%40atlanta.com",
+ "sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15",
+ "sip:alice@atlanta.com;comp=sigcomp",
+ "sip:atlanta.com;method=REGISTER?to=alice%40atlanta.com",
+ "sip:alice@atlanta.com?subject=project%20x&priority=urgent",
+
+ //== SIPS:
+ "sips:alice@atlanta.com",
+ "sips:alice:secretword@atlanta.com;transport=tcp",
+ "sips:+1-212-555-1212:1234@gateway.com;user=phone",
+ "sips:alice@192.0.2.4",
+ "sips:atlanta.com;method=REGISTER?to=alice%40atlanta.com",
+ "sips:alice@atlanta.com;maddr=239.255.255.1;ttl=15",
+ "sips:alice@atlanta.com;comp=sigcomp",
+ "sips:atlanta.com;method=REGISTER?to=alice%40atlanta.com",
+ "sips:alice@atlanta.com?subject=project%20x&priority=urgent",
+
+ //== TEL:
+ "tel:+1-201-555-0123",
+ "tel:7042;phone-context=example.com;ff=ff",
+ "tel:863-1234;phone-context=+1-914-555",
+ "tel:#666#",
+};
+void test_uri_tostring(const tsip_uri_t *uri)
+{
+ char* ret = tsip_uri_tostring(uri, 1, 1);
+ TSK_DEBUG_INFO("uri_to_string=%s", ret);
+ TSK_FREE(ret);
+}
+
+void test_uri_parser()
+{
+ int i;
+ tsk_list_item_t *item = 0;
+
+ for(i=0; i<sizeof(uris)/sizeof(const char*); i++)
+ {
+ tsip_uri_t *uri = tsip_uri_parse(uris[i], tsk_strlen(uris[i]));
+
+ printf("\n== Parsing {{ %s }} ==\n\n", uris[i]);
+
+ if(uri)
+ {
+ printf("scheme: %s\n", uri->scheme);
+ printf("user-name: %s\n", uri->user_name);
+ printf("password: %s\n", uri->password);
+ printf("host: %s\n", uri->host);
+ printf("port: %d\n", uri->port);
+ printf("host-type: %s\n", uri->host_type == host_ipv4 ? "IPv4" : (uri->host_type == host_ipv6 ? "IPv6" : (uri->host_type == host_hostname ? "HOSTNAME" : "UNKNOWN")) );
+
+ printf("---PARAMS---\n");
+
+ /* dump all parameters */
+ tsk_list_foreach(item, uri->params)
+ {
+ tsk_param_t* param = item->data;
+ printf("-->%s=%s\n", param->name, param->value);
+ }
+
+ printf("Is-secure: %s\n", TSIP_URI_IS_SECURE(uri) ? "YES" : "NO");
+
+ test_uri_tostring(uri);
+ }
+ else
+ {
+ printf("INVALID SIP URI.\n");
+ }
+
+ printf("\n\n");
+ getchar();
+
+ TSK_OBJECT_SAFE_FREE(uri);
+ }
+}
+
+struct test_uri_bundle
+{
+ const char* uri1;
+ const char* uri2;
+
+ unsigned match:1;
+};
+
+// From RFC 3261 - 19.1.4 URI Comparison
+struct test_uri_bundle test_uri_bundles[] =
+{
+ /* Match */
+ { "sip:%61lice@atlanta.com;transport=TCP", "sip:alice@AtLanTa.CoM;Transport=tcp", 1 },
+ { "sip:carol@chicago.com", "sip:carol@chicago.com;newparam=5", 1 },
+ { "sip:carol@chicago.com", "sip:carol@chicago.com;security=on", 1 },
+ { "sip:carol@chicago.com;newparam=5", "sip:carol@chicago.com;security=on", 1 },
+ { "sip:biloxi.com;transport=tcp;method=REGISTER?to=sip:bob%40biloxi.com", "sip:biloxi.com;method=REGISTER;transport=tcp?to=sip:bob%40biloxi.com", 1 },
+ { "sip:alice@atlanta.com?subject=project%20x&priority=urgent", "sip:alice@atlanta.com?priority=urgent&subject=project%20x", 1 },
+
+ /* Do not match */
+ { "SIP:ALICE@AtLanTa.CoM;Transport=udp", "sip:alice@AtLanTa.CoM;Transport=UDP", 0 }, /* different usernames */
+ { "sip:bob@biloxi.com", "sip:bob@biloxi.com:5060", 0 }, /* can resolve to different ports */
+ { "sip:bob@biloxi.com", "sip:bob@biloxi.com;transport=udp", 0 }, /* can resolve to different transports */
+ { "sip:bob@biloxi.com", "sip:bob@biloxi.com:6000;transport=tcp", 0 }, /* can resolve to different port and transports */
+ { "sip:carol@chicago.com", "sip:carol@chicago.com?Subject=next%20meeting", 0 }, /* different header component */
+ { "sip:bob@phone21.boxesbybob.com", "sip:bob@192.0.2.4", 0 }, /* even though that's what phone21.boxesbybob.com resolves to*/
+};
+
+void test_uri_cmp()
+{
+ size_t i;
+
+ for(i=0; i< sizeof(test_uri_bundles)/sizeof(struct test_uri_bundle); i++)
+ {
+ tsip_uri_t *uri1 = tsip_uri_parse(test_uri_bundles[i].uri1, tsk_strlen(test_uri_bundles[i].uri1));
+ tsip_uri_t *uri2 = tsip_uri_parse(test_uri_bundles[i].uri2, tsk_strlen(test_uri_bundles[i].uri2));
+
+ if(tsk_object_cmp(uri1, uri2) && test_uri_bundles[i].match){
+ TSK_DEBUG_ERROR("URI Comparison failed.");
+ }
+ else{
+ TSK_DEBUG_INFO("URI Comparison ok.");
+ }
+
+ TSK_OBJECT_SAFE_FREE(uri1);
+ TSK_OBJECT_SAFE_FREE(uri2);
+ }
+}
+
+void test_uri()
+{
+ test_uri_parser();
+ test_uri_cmp();
+}
+
+#endif /* _TEST_SIPURI_H */
OpenPOWER on IntegriCloud