summaryrefslogtreecommitdiffstats
path: root/tinyMSRP/test
diff options
context:
space:
mode:
authorMamadou DIOP <bossiel@yahoo.fr>2015-08-17 01:56:35 +0200
committerMamadou DIOP <bossiel@yahoo.fr>2015-08-17 01:56:35 +0200
commit631fffee8a28b1bec5ed1f1d26a20e0135967f99 (patch)
tree74afe3bf3efe15aa82bcd0272b2b0f4d48c2d837 /tinyMSRP/test
parent7908865936604036e6f200f1b5e069f8752f3a3a (diff)
downloaddoubango-631fffee8a28b1bec5ed1f1d26a20e0135967f99.zip
doubango-631fffee8a28b1bec5ed1f1d26a20e0135967f99.tar.gz
-
Diffstat (limited to 'tinyMSRP/test')
-rw-r--r--tinyMSRP/test/test/stdafx.c26
-rw-r--r--tinyMSRP/test/test/stdafx.h41
-rw-r--r--tinyMSRP/test/test/targetver.h14
-rw-r--r--tinyMSRP/test/test/test.c73
-rw-r--r--tinyMSRP/test/test/test.vcproj223
-rw-r--r--tinyMSRP/test/test/test.vcproj.mamadou-PC.mamadou.user65
-rw-r--r--tinyMSRP/test/test/test_parser.h150
-rw-r--r--tinyMSRP/test/test/test_session.h125
-rw-r--r--tinyMSRP/test/test/test_uri.h113
9 files changed, 830 insertions, 0 deletions
diff --git a/tinyMSRP/test/test/stdafx.c b/tinyMSRP/test/test/stdafx.c
new file mode 100644
index 0000000..cc34b11
--- /dev/null
+++ b/tinyMSRP/test/test/stdafx.c
@@ -0,0 +1,26 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)yahoo.fr>
+*
+* 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/tinyMSRP/test/test/stdafx.h b/tinyMSRP/test/test/stdafx.h
new file mode 100644
index 0000000..38723b5
--- /dev/null
+++ b/tinyMSRP/test/test/stdafx.h
@@ -0,0 +1,41 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)yahoo.fr>
+*
+* 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_TMSRP_STDAFX_H
+#define TEST_TMSRP_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_TMSRP_STDAFX_H */
diff --git a/tinyMSRP/test/test/targetver.h b/tinyMSRP/test/test/targetver.h
new file mode 100644
index 0000000..2ad5194
--- /dev/null
+++ b/tinyMSRP/test/test/targetver.h
@@ -0,0 +1,14 @@
+#ifndef TMSRP_TEST_TARGETVER_H
+#define TMSRP_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 /* TMSRP_TEST_TARGETVER_H */
diff --git a/tinyMSRP/test/test/test.c b/tinyMSRP/test/test/test.c
new file mode 100644
index 0000000..9389936
--- /dev/null
+++ b/tinyMSRP/test/test/test.c
@@ -0,0 +1,73 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)yahoo.fr>
+*
+* 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 "tnet.h"
+
+#include "tsk.h"
+
+#include "tinymsrp.h"
+
+
+#include "test_parser.h"
+#include "test_uri.h"
+//#include "test_session.h"
+
+
+#define RUN_TEST_LOOP 1
+
+#define RUN_TEST_ALL 0
+#define RUN_TEST_URI 0
+#define RUN_TEST_PARSER 1
+#define RUN_TEST_SESSION 0
+
+#ifdef _WIN32_WCE
+int _tmain(int argc, _TCHAR* argv[])
+#else
+int main()
+#endif
+{
+#if RUN_TEST_LOOP
+ for(;;)
+#endif
+ {
+ tnet_startup();
+
+ /* Print copyright information */
+ printf("Doubango Project\nCopyright (C) 2009 - 2010 Mamadou Diop \n\n");
+
+#if RUN_TEST_ALL || RUN_TEST_URI
+ test_uri();
+#endif
+
+#if RUN_TEST_ALL || RUN_TEST_PARSER
+ test_parser();
+#endif
+
+#if RUN_TEST_ALL || RUN_TEST_SESSION
+ test_session();
+#endif
+
+ tnet_cleanup();
+ }
+} \ No newline at end of file
diff --git a/tinyMSRP/test/test/test.vcproj b/tinyMSRP/test/test/test.vcproj
new file mode 100644
index 0000000..0dec82e
--- /dev/null
+++ b/tinyMSRP/test/test/test.vcproj
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="test"
+ ProjectGUID="{C7732B19-4EF5-40EB-939B-4F1F5F2D3B18}"
+ RootNamespace="test"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\..\thirdparties\win32\include;&quot;$(SolutionDir)\include&quot;;..\..\..\tinySAK\src;..\..\..\tinyNET\src;..\..\..\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)\tinyNET.lib $(OutDir)\tinyMSRP.lib $(OutDir)\tinyMEDIA.lib $(OutDir)\tinySDP.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ 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>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="source"
+ 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="include"
+ 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_parser.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_session.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_uri.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/tinyMSRP/test/test/test.vcproj.mamadou-PC.mamadou.user b/tinyMSRP/test/test/test.vcproj.mamadou-PC.mamadou.user
new file mode 100644
index 0000000..b401e4b
--- /dev/null
+++ b/tinyMSRP/test/test/test.vcproj.mamadou-PC.mamadou.user
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+ ProjectType="Visual C++"
+ Version="9,00"
+ ShowAllFiles="false"
+ >
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ >
+ <DebugSettings
+ Command="$(TargetPath)"
+ WorkingDirectory=""
+ CommandArguments=""
+ Attach="false"
+ DebuggerType="3"
+ Remote="1"
+ RemoteMachine="MAMADOU-PC"
+ RemoteCommand=""
+ HttpUrl=""
+ PDBPath=""
+ SQLDebugging=""
+ Environment=""
+ EnvironmentMerge="true"
+ DebuggerFlavor=""
+ MPIRunCommand=""
+ MPIRunArguments=""
+ MPIRunWorkingDirectory=""
+ ApplicationCommand=""
+ ApplicationArguments=""
+ ShimCommand=""
+ MPIAcceptMode=""
+ MPIAcceptFilter=""
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ >
+ <DebugSettings
+ Command="$(TargetPath)"
+ WorkingDirectory=""
+ CommandArguments=""
+ Attach="false"
+ DebuggerType="3"
+ Remote="1"
+ RemoteMachine="MAMADOU-PC"
+ RemoteCommand=""
+ HttpUrl=""
+ PDBPath=""
+ SQLDebugging=""
+ Environment=""
+ EnvironmentMerge="true"
+ DebuggerFlavor=""
+ MPIRunCommand=""
+ MPIRunArguments=""
+ MPIRunWorkingDirectory=""
+ ApplicationCommand=""
+ ApplicationArguments=""
+ ShimCommand=""
+ MPIAcceptMode=""
+ MPIAcceptFilter=""
+ />
+ </Configuration>
+ </Configurations>
+</VisualStudioUserFile>
diff --git a/tinyMSRP/test/test/test_parser.h b/tinyMSRP/test/test/test_parser.h
new file mode 100644
index 0000000..30eacfa
--- /dev/null
+++ b/tinyMSRP/test/test/test_parser.h
@@ -0,0 +1,150 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)yahoo.fr>
+*
+* 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_MSRPPARSER_H
+#define _TEST_MSRPPARSER_H
+
+#include "tinymsrp/headers/tmsrp_header_Dummy.h"
+
+#define MSRP_MSG_REQUEST \
+ "MSRP a786hjs2 SEND\r\n" \
+ "To-Path: msrp://biloxi.example.com:12763/kjhd37s2s20w2a;tcp\r\n" \
+ "From-Path: msrp://atlanta.example.com:7654/jshA7weztas;tcp\r\n" \
+ "Message-ID: 87652491\r\n" \
+ "Byte-Dummy: 1-25/25\r\n" \
+ "Byte-Range: 1-5/3\r\n" \
+ "Byte-Range: 1-25/*\r\n" \
+ "Byte-Range: 1-*/*\r\n" \
+ "Failure-Report: partial\r\n" \
+ "Success-Report: yes\r\n" \
+ "Content-Type: text/plain;charset=utf8\r\n" \
+ "\r\n" \
+ "ab\r\nc\r\n" \
+ "-------a786hjs2$\r\nMSRP"
+
+#define MSRP_MSG_RESPONSE \
+ "MSRP a786hjs2 200 OK\r\n" \
+ "To-Path: msrp://atlanta.example.com:7654/jshA7weztas;tcp\r\n" \
+ "From-Path: msrp://biloxi.example.com:12763/kjhd37s2s20w2a;tcp\r\n" \
+ "-------a786hjs2$\r\nMSRP 000"
+
+#define MSRP_MSG_REPORT \
+ "MSRP dkei38sd REPORT\r\n" \
+ "To-Path: msrp://alicepc.example.com:7777/iau39soe2843z;tcp\r\n" \
+ "From-Path: msrp://bob.example.com:8888/9di4eae923wzd;tcp\r\n" \
+ "Message-ID: 12339sdqwer\r\n" \
+ "Byte-Range: 1-106/106\r\n" \
+ "Status: 000 200 OK\r\n" \
+ "-------dkei38sd$\r\nMSRP 000"
+
+#define MSRP_MSG_TO_TEST MSRP_MSG_REQUEST
+
+void test_parser()
+{
+ tmsrp_message_t *message;
+ const tmsrp_header_Dummy_t* header;
+ size_t msg_size;
+ char* str;
+
+ //
+ // Serialization / Deserialization
+ //
+ /* deserialize the message */
+ if((message = tmsrp_message_parse_2(MSRP_MSG_TO_TEST, strlen(MSRP_MSG_TO_TEST), &msg_size))){
+
+ tmsrp_message_add_headers(message,
+ TMSRP_HEADER_DUMMY_VA_ARGS("NS", "imdn <urn:ietf:params:imdn>"),
+ TMSRP_HEADER_DUMMY_VA_ARGS("imdn.Message-ID", "MsgiQqFZqTYAA"),
+ TMSRP_HEADER_DUMMY_VA_ARGS("DateTime", "2012-10-25T18:02:08.000Z"),
+ TMSRP_HEADER_DUMMY_VA_ARGS("imdn.Disposition-Notification", "positive-delivery, display"),
+
+ tsk_null);
+
+ if((header = (const tmsrp_header_Dummy_t*)tmsrp_message_get_headerByName(message, "NS"))){
+ TSK_DEBUG_INFO("NS=%s\n", header->value);
+ }
+ if((header = (const tmsrp_header_Dummy_t*)tmsrp_message_get_headerByName(message, "imdn.Message-ID"))){
+ TSK_DEBUG_INFO("imdn.Message-ID=%s\n", header->value);
+ }
+
+ /* serialize the message */
+ if((str = tmsrp_message_tostring(message))){
+ TSK_DEBUG_INFO("\nMSRP Message=\n%s\n\n", str);
+ TSK_FREE(str);
+ }
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to parse MSRP message(1).");
+ }
+ TSK_OBJECT_SAFE_FREE(message);
+
+ //
+ // Create Response from Request
+ //
+ if((message = tmsrp_message_parse(MSRP_MSG_REQUEST, strlen(MSRP_MSG_REQUEST)))){
+ tmsrp_response_t* response = tmsrp_create_response(message, 202, "Accepted");
+
+ if((str = tmsrp_message_tostring(response))){
+ TSK_DEBUG_INFO("\nMSRP Response=\n%s\n\n", str);
+ TSK_FREE(str);
+ }
+
+ TSK_OBJECT_SAFE_FREE(response);
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to parse MSRP message(2).");
+ }
+ TSK_OBJECT_SAFE_FREE(message);
+
+ //
+ // Create Report from Request
+ //
+ if((message = tmsrp_message_parse(MSRP_MSG_REQUEST, strlen(MSRP_MSG_REQUEST)))){
+ tmsrp_request_t* report = tmsrp_create_report(message, 403, "Stop-sending-message");
+
+ if((str = tmsrp_message_tostring(report))){
+ TSK_DEBUG_INFO("\nMSRP Response=\n%s\n\n", str);
+ TSK_FREE(str);
+ }
+
+ TSK_OBJECT_SAFE_FREE(report);
+ }
+ else{
+ TSK_DEBUG_ERROR("Failed to parse MSRP message(2).");
+ }
+ TSK_OBJECT_SAFE_FREE(message);
+
+ //
+ // Create bodiless Request
+ //
+ {
+ tmsrp_request_t* bodiless = tmsrp_create_bodiless(tsk_null, tsk_null);
+
+ if((str = tmsrp_message_tostring(bodiless))){
+ TSK_DEBUG_INFO("\nMSRP Bodiless=\n%s\n\n", str);
+ TSK_FREE(str);
+ }
+
+ TSK_OBJECT_SAFE_FREE(bodiless);
+ }
+}
+
+#endif /* _TEST_MSRPPARSER_H */
diff --git a/tinyMSRP/test/test/test_session.h b/tinyMSRP/test/test/test_session.h
new file mode 100644
index 0000000..6ee1a56
--- /dev/null
+++ b/tinyMSRP/test/test/test_session.h
@@ -0,0 +1,125 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)yahoo.fr>
+*
+* 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_MSRPSESSION_H
+#define _TEST_MSRPSESSION_H
+
+#include "tinySDP/headers/tsdp_header_M.h"
+#include "tinySDP/headers/tsdp_header_Dummy.h"
+
+#include "tinySDP/parsers/tsdp_parser_message.h"
+
+#define REMOTE_SDP1 \
+ "c=IN IP4 192.168.0.15\r\n" \
+ "m=message 2000 TCP/MSRP *\r\n" \
+ "a=accept-types:text/plain\r\n" \
+ "a=path:msrp://atlanta.example.com:7654/jshA7weztas;tcp\r\n" \
+ "a=setup:passive\r\n" \
+ "a=connection:new\r\n"
+
+#define REMOTE_SDP2 \
+ "m=message 2000 TCP/MSRP *\r\n" \
+ "c=IN IP4 192.168.0.15\r\n" \
+ "a=accept-types:text/plain\r\n" \
+ "a=path:msrp://atlanta.example.com:7654/jshA7weztas;tcp\r\n" \
+ "a=setup:passive\r\n" \
+ "a=connection:new\r\n"
+
+#define REMOTE_SDP REMOTE_SDP1
+
+void test_session()
+{
+ tmedia_t* msrp = tsk_null;
+ char* str;
+ const tsdp_header_M_t *m;
+ tsdp_message_t* remote;
+
+ // Register dummy media
+ tmedia_plugin_register(tmsrp_media_plugin_def_t);
+
+ if((msrp = tmedia_factory_create("msrp", TNET_SOCKET_HOST_ANY, tnet_socket_type_tcp_ipv4))){
+
+ // Get offer
+ if((m = tmedia_get_local_offer(msrp,
+ TSDP_HEADER_I_VA_ARGS("This is my latest picture"),
+ TSDP_HEADER_A_VA_ARGS("sendonly", tsk_null),
+ TSDP_HEADER_A_VA_ARGS("file-selector", "\"My cool picture.jpg\" type:image/jpeg size:32349 hash:sha-1:72:24:5F:E8:65:3D:DA:F3:71:36:2F:86:D4:71:91:3E:E4:A2:CE:2E"),
+ TSDP_HEADER_A_VA_ARGS("file-transfer-id", "vBnG916bdberum2fFEABR1FR3ExZMUrd"),
+ TSDP_HEADER_A_VA_ARGS("file-disposition", "attachment"),
+ TSDP_HEADER_A_VA_ARGS("file-date", "creation:\"Mon, 15 May 2006 15:01:31 +0300\""),
+ TSDP_HEADER_A_VA_ARGS("file-icon", "cid:id2@alicepc.example.com"),
+ TSDP_HEADER_A_VA_ARGS("file-range", "1-32349"),
+
+ TSDP_HEADER_DUMMY_VA_ARGS("x", "007"),
+
+ tsk_null
+ ))){
+ if((str = tsdp_header_tostring(TSDP_HEADER(m)))){
+ TSK_DEBUG_INFO("m(offer)=%s", str);
+ TSK_FREE(str);
+ }
+ }
+
+ /*if((m = tmedia_get_local_offer(msrp,
+ TSDP_HEADER_I_VA_ARGS("Message Transfer"),
+ TSDP_HEADER_A_VA_ARGS("accept-types", "text/plain")
+
+ tsk_null
+ ))){
+ if((str = tsdp_header_tostring(TSDP_HEADER(m)))){
+ TSK_DEBUG_INFO("m(offer)=%s", str);
+ TSK_FREE(str);
+ }
+ }*/
+
+ // Set offer
+ if((remote = tsdp_message_parse(REMOTE_SDP, strlen(REMOTE_SDP)))){
+ tmedia_set_remote_offer(msrp, remote);
+ TSK_OBJECT_SAFE_FREE(remote);
+ }
+
+ tmedia_get_negotiated_offer(msrp);
+
+ tmedia_start(msrp);
+ //tmedia_pause(msrp);
+
+ /*
+ tmedia_perform(msrp, tma_msrp_send_data,
+ TSK_PARAM_VA_ARGS("Content", "hello world!"),
+
+ tsk_null);
+ */
+
+ tmedia_perform(msrp, tma_msrp_send_file,
+ TSK_PARAM_VA_ARGS("Path", "C:\\Projects\\Doubango\\doubango.ncb"),
+
+ tsk_null);
+
+
+ getchar();
+
+ tmedia_stop(msrp);
+
+ TSK_OBJECT_SAFE_FREE(msrp);
+ }
+}
+
+#endif /* _TEST_MSRPSESSION_H */
diff --git a/tinyMSRP/test/test/test_uri.h b/tinyMSRP/test/test/test_uri.h
new file mode 100644
index 0000000..1b4c1b3
--- /dev/null
+++ b/tinyMSRP/test/test/test_uri.h
@@ -0,0 +1,113 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)yahoo.fr>
+*
+* 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_MSRPURI_H
+#define _TEST_MSRPURI_H
+
+#include "tinymsrp/parsers/tmsrp_parser_uri.h"
+
+const char* uris[] =
+{
+ "msrp://atlanta.example.com:7654/jshA7weztas;tcp;p1=1;p2=2",
+ "msrps://atlanta.example.com:7654/jshA7weztas;tcp",
+
+ // hostname, IPv4 and IPv6 (without userinfo and with port)
+ "msrp://biloxi.msrp.com:12763/kjhd37s2s20w2a;sctp",
+ "msrps://192.168.0.10:7654/jshA7weztas;tcp;p3=4",
+ "msrps://[::127]:7654/jshA7weztas;tcp;p=0",
+
+ // hostname, IPv4 and IPv6 (without userinfo and without port)
+ "msrp://biloxi.msrp.com/kjhd37s2s20w2a;sctp",
+ "msrps://192.168.0.10/jshA7weztas;tcp;p3=4",
+ "msrps://[::127]/jshA7weztas;tcp;p=0",
+
+ // hostname, IPv4 and IPv6 (with userinfo and with port)
+ "msrp://bob@biloxi.msrp.com:12763/kjhd37s2s20w2a;sctp",
+ "msrps://alice@192.168.0.10:7654/jshA7weztas;tcp;p3=4",
+ "msrps://carol@[::127]:7654/jshA7weztas;tcp;p=0",
+
+ // hostname, IPv4 and IPv6 (with userinfo and without port)
+ "msrp://bob@biloxi.msrp.com/kjhd37s2s20w2a;sctp",
+ "msrps://alice@192.168.0.10/jshA7weztas;tcp;p3=4",
+ "msrps://carol@[::127]/jshA7weztas;tcp;p=0",
+
+ // without session_id
+ "msrps://[::127]:7654;tcp;p=0",
+};
+
+void test_uri_tostring(const tmsrp_uri_t *uri)
+{
+ char* ret = tmsrp_uri_tostring(uri);
+ 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++)
+ {
+ tmsrp_uri_t *uri = tmsrp_uri_parse(uris[i], strlen(uris[i]));
+
+ printf("\n== Parsing {{ %s }} ==\n\n", uris[i]);
+
+ if(uri)
+ {
+ printf("scheme: %s\n", uri->scheme);
+ printf("userinfo: %s\n", uri->authority.userinfo);
+ printf("host: %s\n", uri->authority.host);
+ printf("port: %d\n", uri->authority.port);
+ printf("host-type: %s\n", uri->authority.host_type == tmsrp_host_ipv4 ? "IPv4" : (uri->authority.host_type == tmsrp_host_ipv6 ? "IPv6" : (uri->authority.host_type == tmsrp_host_hostname ? "HOSTNAME" : "UNKNOWN")) );
+ printf("session-id: %s\n", uri->session_id);
+ printf("transport: %s\n", uri->transport);
+
+ 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", TMSRP_URI_IS_SECURE(uri) ? "YES" : "NO");
+
+ test_uri_tostring(uri);
+ }
+ else{
+ printf("INVALID MSRP URI.\n");
+ }
+
+ printf("\n\n");
+ getchar();
+
+ TSK_OBJECT_SAFE_FREE(uri);
+ }
+}
+
+
+void test_uri()
+{
+ test_uri_parser();
+}
+
+#endif /* _TEST_MSRPURI_H */
OpenPOWER on IntegriCloud