Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/Adapter.prj
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/Adapter.prj	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/Adapter.prj	(revision 20)
@@ -0,0 +1,95 @@
+[Project ID]
+Signature=UE Proj: v.1
+[Open Files]
+Open File0=C:\Program Files\Elvior\MessageMagic5\mmagic_codec_log.txt
+Active File Display Mode=3
+Open File Pos0=0
+Open File Line0=2663
+Open File Window Pos0=2,3,-1,-1,-4,-30,88,116,961,519
+Open File1=D:\cygwin\home\yann\dev\g++\STF 370\codec\c++\sip_codets.cpp
+Open File Pos1=53160
+Open File Line1=52644
+Open File Window Pos1=0,1,-1,-1,-4,-30,110,145,987,552
+Open File2=D:\cygwin\home\yann\dev\g++\STF 370\adapter\tmp\gen\gen_classes.h
+Open File Pos2=64146
+Open File Line2=63468
+Open File Window Pos2=0,1,-1,-1,-4,-30,132,174,1009,581
+Open File3=D:\cygwin\home\yann\dev\g++\STF 370\codec\c++\Regex.h
+Open File Pos3=1948
+Open File Line3=1835
+Active File Index=0
+Open File Window Pos3=0,1,-1,-1,-4,-30,0,0,877,407
+Open File4=
+Open File Pos4=14349
+Open File Line4=13919
+Open File Window Pos4=0,1,-1,-1,-4,-30,22,29,899,436
+Open File5=
+Open File Pos5=0
+Open File Line5=0
+Open File Window Pos5=0,1,-1,-1,-4,-30,132,174,1019,581
+Open File6=
+Open File Pos6=5267
+Open File Line6=4743
+Open File Window Pos6=0,1,-1,-1,-4,-30,110,145,1019,521
+Open File7=D:\cygwin\home\yann\dev\g++\STF 370\adapter\validation\TestExecution.ttcn
+Open File Pos7=4045
+Open File Line7=4007
+Open File Window Pos7=2,3,-1,-1,-4,-30,0,0,909,376
+Open File8=
+Open File Pos8=23209
+Open File Line8=22507
+Open File Window Pos8=0,1,-1,-1,-4,-30,44,58,953,434
+Open File9=D:\cygwin\home\yann\dev\g++\STF 370\adapter\src\UpperTestAdapter\TriggerCommandsGUI\TriggerCommands.cpp
+Open File Pos9=989
+Open File Line9=217
+Open File Window Pos9=0,1,-1,-1,-4,-30,66,87,975,463
+Open File10=D:\cygwin\home\yann\dev\g++\STF 370\adapter\src\Helper\GeneralConfigurationParams.h
+Open File Pos10=665
+Open File Line10=358
+Open File Window Pos10=0,1,-1,-1,-4,-30,88,116,997,492
+Open File11=
+[Project Information]
+Use Relative Directory=1
+Relative to Project File=1
+Project Start=D907090003001000160010001300000035
+Include Sub Directories=1
+Project Tagfile=
+Project Wordfile=
+Filter=
+Create Tagfile=0
+Working Time=1030139
+[Files]
+0=.\src\
+1=..\ttcn\
+2=Makefile
+3=..\codec\c++\
+4=.\validation\
+5=.\tmp\gen\
+6=..\codec\validation\
+7=..\LibSip\
+[Group Filter]
+- src=*.cpp;*.h
+- STF 370=*.ttcn
+- codec=*.ttcn
+..\codec\c++\=*.cpp;*.h;Make*
+- validation=*.ttcn
+- gen=*.cpp;*.h
+- TriggerCommandsGUI=*.cpp;*.h
+ - STF 370=*.ttcn
+[Folders]
+..\codec\c++\ - tmp - gen=1
+.\src\UpperTestAdapter\TriggerCommandsGUI\=1
+.\validation\ - generic_interface_configuration=1
+.\validation\ - LibUpperTester=1
+.\validation\ - LibIms_ConfigAndTrigger=1
+.\validation\ - AtsImsIot=1
+.\validation\ - LibIot=1
+..\codec\c++\ - tmp=1
+..\ttcn\ - LibIot=1
+..\ttcn\ - AtsImsIot=1
+..\ttcn\ - LibIms_ConfigAndTrigger=1
+.\src\ - UpperTestAdapter - Processors=1
+.\src\ - UpperTestAdapter - TriggerCommandsGUI=1
+..\LibSip\ - ttcn=1
+.\tmp\gen\=1
+..\codec\c++\=1
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/Doxygen.conf
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/Doxygen.conf	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/Doxygen.conf	(revision 20)
@@ -0,0 +1,165 @@
+# Doxygen configuration
+# $Id$
+#---------------------------------------------------------------------------
+# General configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME           = STF370_Adapter
+PROJECT_NUMBER         = 
+OUTPUT_DIRECTORY       = ./doc
+OUTPUT_LANGUAGE        = English
+EXTRACT_ALL            = YES
+EXTRACT_PRIVATE        = YES
+EXTRACT_STATIC         = YES
+HIDE_UNDOC_MEMBERS     = NO
+HIDE_UNDOC_CLASSES     = NO
+BRIEF_MEMBER_DESC      = YES
+REPEAT_BRIEF           = YES
+ALWAYS_DETAILED_SEC    = NO
+FULL_PATH_NAMES        = NO
+STRIP_FROM_PATH        = 
+INTERNAL_DOCS          = NO
+CLASS_DIAGRAMS         = YES
+SOURCE_BROWSER         = NO
+INLINE_SOURCES         = NO
+STRIP_CODE_COMMENTS    = YES
+CASE_SENSE_NAMES       = YES
+HIDE_SCOPE_NAMES       = NO
+VERBATIM_HEADERS       = YES
+SHOW_INCLUDE_FILES     = YES
+JAVADOC_AUTOBRIEF      = YES
+INHERIT_DOCS           = YES
+INLINE_INFO            = YES
+SORT_MEMBER_DOCS       = YES
+DISTRIBUTE_GROUP_DOC   = NO
+TAB_SIZE               = 2
+ENABLED_SECTIONS       = 
+GENERATE_TODOLIST      = YES
+GENERATE_TESTLIST      = YES
+ALIASES                = 
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET                  = NO
+WARNINGS               = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_FORMAT            = "$file:$line: $text"
+WARN_LOGFILE           = 
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = ./ \
+                         ./src/Ports \
+                         ./src/LowerTestAdapter \
+                         ./src/Messages \
+                         ./src/PacketFilter \
+                         ./src/UpperTestAdapter \
+                         ./src/UpperTestAdapter/Processors \
+                         ./src/UpperTestAdapter/TriggerCommandsOffLine \
+                         ./src/UpperTestAdapter/TriggerCommandsGUI \
+                         ./src/Helper \
+                         ./src/Logger
+                         
+FILE_PATTERNS          = *.cpp \
+                         *.c \
+                         *.h \
+                         *.hpp \
+                         *.inl
+RECURSIVE              = YES
+EXCLUDE                = 
+EXCLUDE_PATTERNS       = 
+EXAMPLE_PATH           = 
+EXAMPLE_PATTERNS       = 
+IMAGE_PATH             = 
+INPUT_FILTER           = 
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX     = NO
+COLS_IN_ALPHA_INDEX    = 5
+IGNORE_PREFIX          = 
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML          = YES
+HTML_OUTPUT            = html
+HTML_HEADER            = 
+HTML_FOOTER            = 
+HTML_STYLESHEET        = 
+HTML_ALIGN_MEMBERS     = YES
+GENERATE_HTMLHELP      = NO
+DISABLE_INDEX          = NO
+ENUM_VALUES_PER_LINE   = 4
+GENERATE_TREEVIEW      = NO
+TREEVIEW_WIDTH         = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX         = NO
+LATEX_OUTPUT           = latex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4wide
+EXTRA_PACKAGES         = 
+LATEX_HEADER           = 
+PDF_HYPERLINKS         = NO
+USE_PDFLATEX           = NO
+LATEX_BATCHMODE        = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF           = YES
+RTF_OUTPUT             = rtf
+COMPACT_RTF            = NO
+RTF_HYPERLINKS         = NO
+RTF_STYLESHEET_FILE    = 
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN           = YES
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML           = NO
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = NO
+EXPAND_ONLY_PREDEF     = NO
+SEARCH_INCLUDES        = YES
+INCLUDE_PATH           = 
+INCLUDE_FILE_PATTERNS  = 
+PREDEFINED             = 
+EXPAND_AS_DEFINED      = 
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references   
+#---------------------------------------------------------------------------
+TAGFILES               = 
+GENERATE_TAGFILE       = 
+ALLEXTERNALS           = NO
+PERL_PATH              = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+HAVE_DOT               = NO
+CLASS_GRAPH            = YES
+COLLABORATION_GRAPH    = YES
+INCLUDE_GRAPH          = YES
+INCLUDED_BY_GRAPH      = YES
+GRAPHICAL_HIERARCHY    = YES
+DOT_PATH               = 
+MAX_DOT_GRAPH_WIDTH    = 1024
+MAX_DOT_GRAPH_HEIGHT   = 1024
+GENERATE_LEGEND        = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine   
+#---------------------------------------------------------------------------
+SEARCHENGINE           = NO
+CGI_NAME               = search.cgi
+CGI_URL                = 
+DOC_URL                = 
+DOC_ABSPATH            = 
+BIN_ABSPATH            = /usr/local/bin/
+EXT_DOC_PATHS          = 
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/STF370_ATS/STF370_ATS.mmsln
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/STF370_ATS/STF370_ATS.mmsln	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/STF370_ATS/STF370_ATS.mmsln	(revision 20)
@@ -0,0 +1,248 @@
+<?xml version="1.0" encoding="utf-8"?>
+<solution>
+ <metaclasses>
+  <enc>
+   <plain>
+    <byte_order>le</byte_order>
+    <signed />
+    <int>dword</int>
+    <float>double</float>
+    <custom_int>8</custom_int>
+    <string>null</string>
+    <custom_str>32</custom_str>
+    <char>UTF8</char>
+    <bool>dword</bool>
+    <bin>dword</bin>
+    <custom_bin>16</custom_bin>
+    <align>1</align>
+    <coll>ext</coll>
+    <str_unit>bytes</str_unit>
+    <str_end>\r\n</str_end>
+    <uni_end>\r\n</uni_end>
+    <any>word</any>
+   </plain>
+  </enc>
+  <items />
+ </metaclasses>
+ <comp_module>
+  <file>STF370_ATS.mmtcs</file>
+ </comp_module>
+ <tes>
+  <items>
+   <te>
+    <file>TestingEnvironment1.xmmte</file>
+   </te>
+  </items>
+ </tes>
+ <scripts>
+  <items>
+   <script>
+    <name>AtsImsIot_Behavior</name>
+    <file>..\..\..\ttcn\AtsImsIot\AtsImsIot_Behavior.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_Functions</name>
+    <file>..\..\..\ttcn\AtsImsIot\AtsImsIot_Functions.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_Templates</name>
+    <file>..\..\..\ttcn\AtsImsIot\AtsImsIot_Templates.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_TestCases_MESS</name>
+    <file>..\..\..\ttcn\AtsImsIot\AtsImsIot_TestCases_MESS.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_TestConfiguration</name>
+    <file>..\..\..\ttcn\AtsImsIot\AtsImsIot_TestConfiguration.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_TestSystem</name>
+    <file>..\..\..\ttcn\AtsImsIot\AtsImsIot_TestSystem.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_TypesAndValues</name>
+    <file>..\..\..\ttcn\AtsImsIot\AtsImsIot_TypesAndValues.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibIms_UpperTester</name>
+    <file>..\..\..\ttcn\LibIms_ConfigAndTrigger\LibIms_UpperTester.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibIot_Functions</name>
+    <file>..\..\..\ttcn\LibIot\LibIot_Functions.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibIot_PIXITS</name>
+    <file>..\..\..\ttcn\LibIot\LibIot_PIXITS.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibIot_TestConfiguration</name>
+    <file>..\..\..\ttcn\LibIot\LibIot_TestConfiguration.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibIot_TestInterface</name>
+    <file>..\..\..\ttcn\LibIot\LibIot_TestInterface.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibIot_TypesAndValues</name>
+    <file>..\..\..\ttcn\LibIot\LibIot_TypesAndValues.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibUpperTester</name>
+    <file>..\..\..\ttcn\LibUpperTester\LibUpperTester.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_AbstractData</name>
+    <file>..\..\validation\LibCommon\LibCommon_AbstractData.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_BasicTypesAndValues</name>
+    <file>..\..\validation\LibCommon\LibCommon_BasicTypesAndValues.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_DataStrings</name>
+    <file>..\..\validation\LibCommon\LibCommon_DataStrings.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_Sync</name>
+    <file>..\..\validation\LibCommon\LibCommon_Sync.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_TextStrings</name>
+    <file>..\..\validation\LibCommon\LibCommon_TextStrings.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_Time</name>
+    <file>..\..\validation\LibCommon\LibCommon_Time.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_VerdictControl</name>
+    <file>..\..\validation\LibCommon\LibCommon_VerdictControl.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_TestControl</name>
+    <file>..\..\..\ttcn\AtsImsIot\AtsImsIot_TestControl.ttcn3</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_TestCases_CALL</name>
+    <file>..\..\..\ttcn\AtsImsIot\AtsImsIot_TestCases_CALL.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_TestCases_REG</name>
+    <file>..\..\..\ttcn\AtsImsIot\AtsImsIot_TestCases_REG.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_TestCases_SS</name>
+    <file>..\..\..\ttcn\AtsImsIot\AtsImsIot_TestCases_SS.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>XSDAUX</name>
+    <file>..\..\..\LibSip\ttcn\XSDAUX.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibSip_Interface</name>
+    <file>..\..\..\LibSip\ttcn\LibSip_Interface.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibSip_PIXITS</name>
+    <file>..\..\..\LibSip\ttcn\LibSip_PIXITS.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibSip_SDPTypes</name>
+    <file>..\..\..\LibSip\ttcn\LibSip_SDPTypes.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibSip_SIPTypesAndValues</name>
+    <file>..\..\..\LibSip\ttcn\LibSip_SIPTypesAndValues.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibSip_Steps</name>
+    <file>..\..\..\LibSip\ttcn\LibSip_Steps.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibSip_Templates</name>
+    <file>..\..\..\LibSip\ttcn\LibSip_Templates.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibSip_XMLTypes</name>
+    <file>..\..\..\LibSip\ttcn\LibSip_XMLTypes.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+  </items>
+ </scripts>
+ <messages>
+  <items />
+ </messages>
+ <scenarios>
+  <items />
+ </scenarios>
+ <verstool />
+ <timer>
+  <int>1000</int>
+ </timer>
+ <sut>
+  <exe>D:\cygwin\home\yann\dev\g++\STF 370\adapter\TestExecution-SA.exe</exe>
+  <port>7777</port>
+  <ctime>60</ctime>
+  <htime>30</htime>
+  <count>1</count>
+  <rtime>20</rtime>
+ </sut>
+ <codec_rules>CodecRules_STF370_ATS.txt</codec_rules>
+ <ExternalAttributeFiles>
+  <items />
+ </ExternalAttributeFiles>
+ <ModuleParFiles>
+  <items />
+ </ModuleParFiles>
+ <TestcaseSelections>
+  <items />
+ </TestcaseSelections>
+ <TestCampaigns>
+  <items />
+ </TestCampaigns>
+ <ttcn3_settings>
+  <tc_block />
+  <ttcn3_version>Ttcn3_2009</ttcn3_version>
+  <ext_codec />
+  <ext_cdpath>D:\cygwin\home\yann\dev\g++\STF 370\adapter\TestExecution-CD.dll</ext_cdpath>
+  <asn>BER</asn>
+  <no_internal_codec />
+  <sa_traffic />
+  <codec_timeout>10000</codec_timeout>
+  <log_reject />
+ </ttcn3_settings>
+</solution>
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/STF370_ATS/STF370_ATS.mmsln.user
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/STF370_ATS/STF370_ATS.mmsln.user	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/STF370_ATS/STF370_ATS.mmsln.user	(revision 20)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<user_space>
+ <logs>
+  <items>
+   <log>TestingEnvironment1_200909251138282\ttcn3_log.xmmlog</log>
+  </items>
+ </logs>
+ <open>
+  <metaclasses />
+  <tes />
+  <scripts />
+  <scenarios />
+  <mis />
+  <logs>
+   <item>
+    <name>TestingEnvironment1_200909251138282\ttcn3_log.xmmlog</name>
+    <tab>
+     <pos>0</pos>
+     <active />
+    </tab>
+   </item>
+  </logs>
+ </open>
+ <main_script>AtsImsIot_TestControl</main_script>
+ <campaigns />
+ <ext_att />
+ <ext_mp />
+ <tc_sel />
+</user_space>
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/STF370_ATS/STF370_ATS.mmtcs
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/STF370_ATS/STF370_ATS.mmtcs	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/STF370_ATS/STF370_ATS.mmtcs	(revision 20)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<tctypes>
+ <items>
+  <cls>
+   <name>TSystemAdapter</name>
+   <tcc>
+    <ports>
+     <cls>
+      <name>port1</name>
+      <port />
+      <null />
+      <auto />
+     </cls>
+    </ports>
+    <log />
+    <open />
+   </tcc>
+  </cls>
+  <cls>
+   <name>TMainTC</name>
+   <tcc>
+    <ports>
+     <cls>
+      <name>port1</name>
+      <port />
+      <null />
+      <auto />
+     </cls>
+    </ports>
+    <log />
+    <open />
+   </tcc>
+  </cls>
+ </items>
+</tctypes>
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/TestExecution.mmsln
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/TestExecution.mmsln	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/TestExecution.mmsln	(revision 20)
@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="utf-8"?>
+<solution>
+ <metaclasses>
+  <enc>
+   <plain>
+    <byte_order>le</byte_order>
+    <signed />
+    <int>dword</int>
+    <float>double</float>
+    <custom_int>8</custom_int>
+    <string>null</string>
+    <custom_str>32</custom_str>
+    <char>UTF8</char>
+    <bool>dword</bool>
+    <bin>dword</bin>
+    <custom_bin>16</custom_bin>
+    <align>1</align>
+    <coll>ext</coll>
+    <str_unit>bytes</str_unit>
+    <str_end>\r\n</str_end>
+    <uni_end>\r\n</uni_end>
+    <any>word</any>
+   </plain>
+  </enc>
+  <items />
+ </metaclasses>
+ <comp_module>
+  <file>TestExecution.mmtcs</file>
+ </comp_module>
+ <tes>
+  <items>
+   <te>
+    <file>TestingEnvironment1.xmmte</file>
+   </te>
+  </items>
+ </tes>
+ <scripts>
+  <items>
+   <script>
+    <name>LibSip_Interface</name>
+    <file>..\..\LibSip\LibSip_Interface.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibSip_PIXITS</name>
+    <file>..\..\LibSip\LibSip_PIXITS.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibSip_SDPTypes</name>
+    <file>..\..\LibSip\LibSip_SDPTypes.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibSip_SIPTypesAndValues</name>
+    <file>..\..\LibSip\LibSip_SIPTypesAndValues.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibSip_Steps</name>
+    <file>..\..\LibSip\LibSip_Steps.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibSip_Templates</name>
+    <file>..\..\LibSip\LibSip_Templates.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibSip_XMLTypes</name>
+    <file>..\..\LibSip\LibSip_XMLTypes.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>XSDAUX</name>
+    <file>..\..\LibSip\XSDAUX.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibIot_TestConfiguration</name>
+    <file>..\..\ttcn\LibIot\LibIot_TestConfiguration.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibIot_Functions</name>
+    <file>..\..\ttcn\LibIot\LibIot_Functions.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibIot_TypesAndValues</name>
+    <file>..\..\ttcn\LibIot\LibIot_TypesAndValues.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibIot_PIXITS</name>
+    <file>..\..\ttcn\LibIot\LibIot_PIXITS.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibIot_TestInterface</name>
+    <file>..\..\ttcn\LibIot\LibIot_TestInterface.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibUpperTester</name>
+    <file>..\..\ttcn\LibUpperTester\LibUpperTester.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibIms_UpperTester</name>
+    <file>..\..\ttcn\LibIms_ConfigAndTrigger\LibIms_UpperTester.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_Templates</name>
+    <file>..\..\ttcn\AtsImsIot\AtsImsIot_Templates.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_Behavior</name>
+    <file>..\..\ttcn\AtsImsIot\AtsImsIot_Behavior.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_TestSystem</name>
+    <file>..\..\ttcn\AtsImsIot\AtsImsIot_TestSystem.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_TestConfiguration</name>
+    <file>..\..\ttcn\AtsImsIot\AtsImsIot_TestConfiguration.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_TypesAndValues</name>
+    <file>..\..\ttcn\AtsImsIot\AtsImsIot_TypesAndValues.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_Functions</name>
+    <file>..\..\ttcn\AtsImsIot\AtsImsIot_Functions.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_BasicTypesAndValues</name>
+    <file>..\validation\LibCommon\LibCommon_BasicTypesAndValues.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_Sync</name>
+    <file>..\validation\LibCommon\LibCommon_Sync.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_AbstractData</name>
+    <file>..\validation\LibCommon\LibCommon_AbstractData.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_Time</name>
+    <file>..\validation\LibCommon\LibCommon_Time.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_VerdictControl</name>
+    <file>..\validation\LibCommon\LibCommon_VerdictControl.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_DataStrings</name>
+    <file>..\validation\LibCommon\LibCommon_DataStrings.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>LibCommon_TextStrings</name>
+    <file>..\validation\LibCommon\LibCommon_TextStrings.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>TestExecution</name>
+    <file>..\validation\TestExecution.ttcn</file>
+    <type>ttcn3</type>
+   </script>
+   <script>
+    <name>AtsImsIot_TestControl</name>
+    <file>..\..\ttcn\AtsImsIot\AtsImsIot_TestControl.ttcn3</file>
+    <type>ttcn3</type>
+   </script>
+  </items>
+ </scripts>
+ <messages>
+  <items />
+ </messages>
+ <scenarios>
+  <items />
+ </scenarios>
+ <verstool>
+  <vers_item>
+   <vers>
+   </vers>
+   <date>8/27/2009</date>
+   <auth>
+   </auth>
+   <comm>
+   </comm>
+  </vers_item>
+ </verstool>
+ <timer>
+  <int>1000</int>
+ </timer>
+ <sut>
+  <port>7777</port>
+  <ctime>60</ctime>
+  <htime>30</htime>
+  <count>1</count>
+  <rtime>20</rtime>
+ </sut>
+ <codec_rules>CodecRules_TestExecution.txt</codec_rules>
+ <ExternalAttributeFiles>
+  <items />
+ </ExternalAttributeFiles>
+ <ModuleParFiles>
+  <items />
+ </ModuleParFiles>
+ <TestcaseSelections>
+  <items />
+ </TestcaseSelections>
+ <TestCampaigns>
+  <items />
+ </TestCampaigns>
+ <ttcn3_settings>
+  <tc_block />
+  <ttcn3_version>Ttcn3_2009</ttcn3_version>
+  <ext_codec />
+  <ext_cdpath>D:\cygwin\home\yann\dev\g++\STF 370\adapter\TestExecution-CD.dll</ext_cdpath>
+  <asn>BER</asn>
+  <no_internal_codec />
+  <sa_traffic />
+  <codec_timeout>10000</codec_timeout>
+  <log_reject />
+ </ttcn3_settings>
+</solution>
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/TestExecution.mmsln.user
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/TestExecution.mmsln.user	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/TestExecution.mmsln.user	(revision 20)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<user_space>
+ <logs>
+  <items />
+ </logs>
+ <open>
+  <metaclasses />
+  <tes />
+  <scripts />
+  <scenarios />
+  <mis />
+  <logs />
+ </open>
+ <main_script>TestExecution</main_script>
+ <campaigns />
+ <ext_att />
+ <ext_mp />
+ <tc_sel />
+</user_space>
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/TestExecution.mmtcs
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/TestExecution.mmtcs	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/TestExecution.mmtcs	(revision 20)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<tctypes>
+ <items>
+  <cls>
+   <name>TSystemAdapter</name>
+   <tcc>
+    <ports>
+     <cls>
+      <name>port1</name>
+      <port />
+      <null />
+      <auto />
+     </cls>
+    </ports>
+    <log />
+    <open />
+   </tcc>
+  </cls>
+  <cls>
+   <name>TMainTC</name>
+   <tcc>
+    <ports>
+     <cls>
+      <name>port1</name>
+      <port />
+      <null />
+      <auto />
+     </cls>
+    </ports>
+    <log />
+    <open />
+   </tcc>
+  </cls>
+ </items>
+</tctypes>
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/TestingEnvironment1.xmmte
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/TestingEnvironment1.xmmte	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/MMagic/TestingEnvironment1.xmmte	(revision 20)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<te>
+ <name>TestingEnvironment1</name>
+ <system>
+  <tc>
+   <class>TSystemAdapter</class>
+  </tc>
+ </system>
+ <mtc>
+  <tc>
+   <class>TMainTC</class>
+  </tc>
+ </mtc>
+ <tcs />
+ <def />
+ <port_map>
+  <item>
+   <p1>
+    <tc>system</tc>
+    <port>port1</port>
+   </p1>
+   <p2>
+    <tc>mtc</tc>
+    <port>port1</port>
+   </p2>
+  </item>
+ </port_map>
+</te>
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/Makefile
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/Makefile	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/Makefile	(revision 20)
@@ -0,0 +1,95 @@
+ifeq '$(T3DK_TOOL)' 'mmagic'
+BOOST_LIB_SUFFIX  = -mt
+TOOL_SPECIFIC_LIBS  = -lws2_32
+TOOL_SPECIFIC_LDFLAGS = -L/opt/boost-mingw/lib
+else
+BOOST_LIB_SUFFIX  = $(if $(shell uname -o | grep Cygwin),-gcc-mt,-mt)
+endif
+
+# Original STF 370 TTCN-3 source code
+T3DK_TTCN_SOURCES_STF370 = $(wildcard validation/*.ttcn \
+      ../../LibCommon/*.ttcn \
+      ../LibSip/ttcn/LibSip_Interface.ttcn \
+      ../LibSip/ttcn/LibSip_SDPTypes.ttcn \
+      ../LibSip/ttcn/LibSip_SIPTypesAndValues.ttcn \
+      ../codec/validation/LibSip_DummyXMLTypes.ttcn \
+      ../ttcn/LibIot/*.ttcn \
+      ../ttcn/LibUpperTester/LibUpperTester.ttcn \
+      ../ttcn/LibIms_ConfigAndTrigger/LibIms_UpperTester.ttcn \
+      ../ttcn/AtsImsIot/AtsImsIot_Functions.ttcn \
+      ../ttcn/AtsImsIot/AtsImsIot_TypesAndValues.ttcn \
+      ../ttcn/AtsImsIot/AtsImsIot_TestConfiguration.ttcn )
+
+# Modified STF 370 TTCN-3 source code to make adapter running properly
+T3DK_TTCN_SOURCES_VALIDATION = $(wildcard validation/*.ttcn \
+      validation/LibCommon/*.ttcn \
+      validation/LibIot/*.ttcn \
+      validation/LibUpperTester/LibUpperTester.ttcn \
+      validation/generic_interface_configuration/Interface_configuration.ttcn \
+      validation/LibIms_ConfigAndTrigger/LibIms_UpperTester.ttcn \
+      validation/AtsImsIot/AtsImsIot_TypesAndValues.ttcn \
+      validation/AtsImsIot/AtsImsIot_TestSystem.ttcn \
+      validation/AtsImsIot/AtsImsIot_TestConfiguration.ttcn \
+      validation/AtsImsIot/AtsImsIot_Functions.ttcn \
+      validation/AtsImsIot/AtsImsIot_Templates.ttcn \
+      ../codec/validation/LibSip_Interface.ttcn \
+      ../codec/validation/LibSip_SDPTypes.ttcn \
+      ../codec/validation/LibSip_SIPTypesAndValues.ttcn \
+      ../codec/validation/LibSip_DummyXMLTypes.ttcn )
+
+T3DK_TTCN_SOURCES = $(T3DK_TTCN_SOURCES_STF370) #$(T3DK_TTCN_SOURCES_VALIDATION)
+
+T3DK_ROOT_MODULE  = TestExecution
+
+T3DK_C_SOURCES    = $(wildcard src/*.c)
+T3DK_CXX_SOURCES  = $(T3DK_CXX_TCI_SOURCES) $(T3DK_CXX_TRI_SOURCES)
+T3DK_CXX_TCI_SOURCES  = $(wildcard src/libiot_codets.cpp ../codec/c++/s*.cpp)
+T3DK_CXX_TRI_SOURCES  = $(wildcard src/init.cpp \
+      src/Ports/*.cpp \
+      src/LowerTestAdapter/*.cpp \
+      src/Messages/*.cpp \
+      src/PacketFilter/*.cpp \
+      src/UpperTestAdapter/*.cpp \
+      src/UpperTestAdapter/Processors/*.cpp \
+      src/UpperTestAdapter/TriggerCommandsOffLine/*.cpp \
+      src/UpperTestAdapter/TriggerCommandsGUI/*.cpp \
+      src/Helper/*.cpp \
+      src/Logger/*.cpp \
+      src/Dispatcher/*.cpp \
+      )
+
+T3DK_LIBS   = $(TOOL_SPECIFIC_LIBS) \
+      -lboost_date_time$(BOOST_LIB_SUFFIX) \
+      -lboost_thread$(BOOST_LIB_SUFFIX) \
+      -lboost_regex$(BOOST_LIB_SUFFIX)
+
+T3DK_CDGEN_HEADER       = src/codec.h
+T3DK_CODETS             = $(wildcard src/codec.h src/libiot_codets.h src/libiot_codets.cpp ../codec/c++/s*.h ../codec/c++/s*.cpp ../codec/c++/libcommon_codets.h)
+
+T3DK_DEBUG   = 1
+
+CPPFLAGS    = -Isrc \
+      -Isrc/LowerTestAdapter \
+      -Isrc/UpperTestAdapter \
+      -Isrc/Helper \
+      -Isrc/Logger \
+      -Isrc/Dispatcher \
+      -I../codec/c++
+ 
+CC      = gcc
+CXX     = g++
+
+CFLAGS      = -g -O2
+CXXFLAGS    = -g -O2 
+T3DK_LDFLAGS    = $(TOOL_SPECIFIC_LDFLAGS)
+
+ifeq '$(T3DK_TOOL)' 'mmagic'
+include $(shell mingw32-t3devkit-config --mk)
+else
+ifeq '$(T3DK_TOOL)' 'ttwb'
+include $(shell mingw32-t3devkit-config --mk)
+else
+include $(shell t3devkit-config --mk)
+endif
+endif
+
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/mm/Adapter.cpp
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/mm/Adapter.cpp	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/mm/Adapter.cpp	(revision 20)
@@ -0,0 +1,166 @@
+extern "C"
+{
+	#include "TriChannel.h"
+}
+#ifdef WIN32
+#include <Windows.h>
+#endif
+#include <boost/thread/thread.hpp>
+#include <boost/thread/condition.hpp>
+#include "tri-sa.h"
+#include "tri-pa.h"
+#include "Logger/Logger.h"
+#include <iostream>
+
+static boost::mutex exitMutex;
+static boost::condition exitCondition;
+
+void onConnectionClosed()
+{
+	boost::mutex::scoped_lock localLock(exitMutex);
+	exitCondition.notify_one();
+}
+
+int main(int argc, char **argv)
+{
+	if (argc == 2 && strcmp(argv[1], "-help") == 0)
+	{
+		std::cout << "Usage: Adapter [-a address][-p port_number]" << std::endl;
+		std::cout << "-a address       Specifies MessageMagic IP address. 127.0.0.1 is used by" << std::endl;
+		std::cout << "                 default." << std::endl;
+		std::cout << "-p port_number   Specifies MessageMagic port. 7777 is used by default." << std::endl;
+		std::cout << "-L*              Sets the log level. Log levels can be combined together." << std::endl;
+		std::cout << "                 The following log levels are available:" << std::endl;
+		std::cout << "   -Linfo        Displays information messages" << std::endl;
+		std::cout << "   -Lerr         Displays errors" << std::endl;
+		std::cout << "   -Lwarn        Displays warnings" << std::endl;
+		std::cout << "   -Ldebug       Displays debugging information" << std::endl;
+		std::cout << "   -Lall         Displays all information" << std::endl;
+		std::cout << "   -Lnone        No messages are displayed" << std::endl;
+		return 0;
+	}
+
+	int nLogMode = 0;
+	bool bLogModeSet = false;
+	bool bError = false;
+	Logger::Instance().SetLoggingMode(Logger::LOG_ERRORS);
+	char * pszAddr = "127.0.0.1";
+	int nPort = 7777;
+	for (int i = 1; i < argc; ++i)
+	{
+		bool bLog = false;
+		char * pszArg = argv[i];
+		if (strcmp(pszArg, "-p") == 0)
+		{
+			if (bError = i + 1 == argc)
+				std::cout << "Port value missing" << std::endl;
+			else
+			{
+				pszArg = argv[++i];
+				nPort = atoi(pszArg);
+			}
+		}
+		else if (strcmp(pszArg, "-a") == 0)
+		{
+			if (bError = i + 1 == argc)
+				std::cout << "Address value missing" << std::endl;
+			else
+			{
+				pszArg = argv[++i];
+				pszAddr = pszArg;
+			}
+		}
+		else if (bLog = strcmp(pszArg, "-Linfo") == 0)
+			nLogMode |= Logger::LOG_INFO;
+		else if (bLog = strcmp(pszArg, "-Lerr") == 0)
+			nLogMode |= Logger::LOG_ERRORS;
+		else if (bLog = strcmp(pszArg, "-Lwarn") == 0)
+			nLogMode |= Logger::LOG_WARNINGS;
+		else if (bLog = strcmp(pszArg, "-Ldebug") == 0)
+			nLogMode |= Logger::LOG_DEBUG | Logger::LOG_INFO;
+		else if (bLog = strcmp(pszArg, "-Lall") == 0)
+			nLogMode = Logger::LOG_ALL;
+		else if (bLog = strcmp(pszArg, "-Lnone") == 0)
+			nLogMode = Logger::LOG_NOTHING;
+		else
+		{
+			bError = true;
+			std::string s = "Unknown command line parameter \"";
+			s += pszArg;
+			s += "\"";
+			std::cout << s << std::endl;
+		}
+		if (bLog)
+			bLogModeSet = true;
+	}
+	if (bError)
+		return 1;
+	if (!bLogModeSet)
+		nLogMode = Logger::LOG_INFO | Logger::LOG_ERRORS;
+	Logger::Instance().SetLoggingMode(nLogMode);
+	Logger::Instance().LogDebug("Command line parameters processed successfully");
+
+
+#ifdef WIN32
+	// Winsock init
+	WSADATA w;
+	if (WSAStartup(0x0002, &w))
+	{
+		std::cout << "Error initiating Winsock library" << std::endl;
+		return 1;
+	}
+#endif
+	// Map callbacks
+	setTriSAResetCallback (triSAReset);
+	setTriExecuteTestCaseCallback (triExecuteTestCase);
+	setTriMapCallback (triMap);
+	setTriUnmapCallback (triUnmap);
+	setTriEndTestCaseCallback (triEndTestcase);
+	setTriSendCallback (triSend);
+	//setTriSendBCCallback (triSendBC);
+	//setTriSendMCCallback (triSendMC);
+	setTriCallCallback (triCall);
+	//setTriCallBCCallback (triCallBC);
+	//setTriCallMCCallback (triCallMC);
+	setTriReplyCallback (triReply);
+	//setTriReplyBCCallback (triReplyBC);
+	//setTriReplyMCCallback (triReplyMC);
+	setTriRaiseCallback (triRaise);
+	//setTriRaiseBCCallback (triRaiseBC);
+	//setTriRaiseMCCallback (triRaiseMC);
+	//setTriSUTActionInformalCallback (triSUTActionInformal);
+	//setTriPAResetCallback (triPAReset);
+	//setTriStartTimerCallback (triStartTimer);
+	//setTriStopTimerCallback (triStopTimer);
+	//setTriReadTimerCallback (triReadTimer);
+	//setTriTimerRunningCallback (triTimerRunning);
+	//setTriExternalFunctionCallback (triExternalFunction);
+
+	// Callback for monitoring connection termination
+	setOnConnectionClosedCallback(onConnectionClosed);
+
+	int nRes = 0;
+	// Create TCP/IP connection
+	if (openTriChannel(pszAddr, nPort, -1, -1, L"Generic T3devkit Adapter"))
+	{
+		std::cout << "TCP/IP connection with MessageMagic established" << std::endl;
+		// Local lock for monitoring exit condition
+		boost::mutex::scoped_lock exitLock(exitMutex);
+		// Waiting for exit condition
+		exitCondition.wait(exitLock);
+		closeTriChannel();
+		std::cout << "TCP/IP connection with MessageMagic closed" << std::endl;
+	}
+	else
+	{
+		std::cout << "Failed to open TRI channel" << std::endl;
+		nRes = 2;
+	}
+#ifdef WIN32
+	// Winsock cleanup
+	WSACleanup();
+#endif
+	return 2;
+}
+
+
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/mm/tri-pa.h
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/mm/tri-pa.h	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/mm/tri-pa.h	(revision 20)
@@ -0,0 +1,15 @@
+#ifndef MM_TRI_PA
+#define MM_TRI_PA
+
+#include "TriStructs.h"
+
+TriStatus triPAReset();
+TriStatus triExternalFunction (const TriFunctionId* functionId,
+			       TriParameterList* parameterList,
+			       TriParameter* returnValue);
+TriStatus triStartTimer (const TriTimerId* timerId, TriTimerDuration timerDuration);
+TriStatus triStopTimer (const TriTimerId* timerId);
+TriStatus triReadTimer (const TriTimerId* timerId, TriTimerDuration* elapsedTime);
+TriStatus triTimerRunning (const TriTimerId* timerId, unsigned char* running);
+
+#endif
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/mm/tri-sa.h
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/mm/tri-sa.h	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/mm/tri-sa.h	(revision 20)
@@ -0,0 +1,88 @@
+#ifndef MM_TRI_SA
+#define MM_TRI_SA
+
+#include "TriStructs.h"
+
+TriStatus triSAReset();
+
+TriStatus triExecuteTestCase (const TriTestCaseId*     testCaseId,
+				const TriPortIdList*     tsiPortList);
+
+TriStatus triMap (const TriPortId*         compPortId,
+		  const TriPortId*         tsiPortId);
+
+TriStatus triUnmap (const TriPortId* compPortId, const TriPortId* tsiPortId);
+
+TriStatus triSend (const TriComponentId*      componentId,
+				   const TriPortId*           tsiPortId,
+				   const TriAddress*          sutAddress,
+				   const TriMessage*          sendMessage);
+
+TriStatus triCall (const TriComponentId*      componentId,
+ 				   const TriPortId*           tsiPortId, 
+ 				   const TriAddress*          sutAddress, 
+ 				   const TriSignatureId*      signatureId, 
+ 				   const TriParameterList*    parameterList);
+
+TriStatus triReply (const TriComponentId*     componentId,
+  					const TriPortId*          tsiPortId,
+  					const TriAddress*         sutAddress,
+  					const TriSignatureId*     signatureId,
+  					const TriParameterList*   parameterList,
+  					const TriParameter*       returnValue);
+
+TriStatus triRaise (const TriComponentId*     componentId,
+  					const TriPortId*          tsiPortId,
+  					const TriAddress*         sutAddress,
+  					const TriSignatureId*     signatureId,
+  					const TriException*       exception);
+
+TriStatus triSUTActionInformal (const char* description);
+
+TriStatus triSendMC (const TriComponentId    *componentId,
+					 const TriPortId         *tsiPortId,
+					 const TriAddressList    *sutAddresses,
+					 const TriMessage        *sendMessage);
+
+TriStatus triSendBC (const TriComponentId    *componentId,
+					 const TriPortId         *tsiPortId,
+					 const TriMessage        *sendMessage);
+
+TriStatus triCallMC (const TriComponentId    *componentId,
+					 const TriPortId         *tsiPortId,
+					 const TriAddressList    *sutAddresses,
+					 const TriSignatureId    *signatureId,
+					 const TriParameterList  *parameterList);
+
+TriStatus triCallBC (const TriComponentId    *componentId,
+					 const TriPortId         *tsiPortId,
+					 const TriSignatureId    *signatureId,
+					 const TriParameterList  *parameterList);
+
+TriStatus triReplyMC (const TriComponentId   *componentId,
+					  const TriPortId        *tsiPortId,
+					  const TriAddressList   *sutAddresses,
+					  const TriSignatureId   *signatureId,
+					  const TriParameterList *parameterList,
+					  const TriParameter     *returnValue);
+
+TriStatus triReplyBC (const TriComponentId   *componentId,
+					  const TriPortId        *tsiPortId, 
+					  const TriSignatureId   *signatureId, 
+					  const TriParameterList *parameterList, 
+					  const TriParameter     *returnValue);
+
+TriStatus triRaiseMC (const TriComponentId   *componentId, 
+					  const TriPortId        *tsiPortId, 
+					  const TriAddressList   *sutAddresses, 
+					  const TriSignatureId   *signatureId, 
+					  const TriException     *exception);
+
+TriStatus triRaiseBC (const TriComponentId   *componentId, 
+					  const TriPortId        *tsiPortId, 
+					  const TriSignatureId   *signatureId, 
+					  const TriException     *exception);
+
+TriStatus triEndTestcase(void);
+
+#endif
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/CaptureDispatch.h
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/CaptureDispatch.h	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/CaptureDispatch.h	(revision 20)
@@ -0,0 +1,31 @@
+/**
+ * @file CaptureDispatch.h
+ * This header file defines the CaptureDispatch class.
+ * @author Tomas Urban
+ * @version 0.1
+ * @date 16/07/2009
+ */
+#ifndef CAPTURE_DISPATCH_H
+#define CAPTURE_DISPATCH_H
+
+#include "Messages/CapturedData.h"
+
+/**
+ * An abstract class providing a generic interface for dispatching captured data. The
+ * exact way how the dispatching mechanism works is defined in child classes 
+ * (strategy design pattern).
+ */
+class CaptureDispatch
+{
+protected:
+	CaptureDispatch(void) {};
+public:
+	virtual ~CaptureDispatch(void) {};
+	/**
+	 * Dispatches captured data to the recipient.
+	 * @param pData Captured data to be dispatched
+	 */
+	virtual void DispatchData(CapturedData * pData) = 0;
+};
+
+#endif
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/CaptureFactory.cpp
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/CaptureFactory.cpp	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/CaptureFactory.cpp	(revision 20)
@@ -0,0 +1,51 @@
+/**
+ * @file CaptureFactory.cpp
+ * @author Tomas Urban
+ * @version 0.1
+ * @date 16/07/2009
+ */
+#include "CaptureFactory.h"
+#include "PCAPLiveCapture.h"
+#include "PCAPOfflineCapture.h"
+#include "Logger/Logger.h"
+
+CaptureFactory::CaptureFactory(void)
+{
+}
+
+CaptureFactory::~CaptureFactory(void)
+{
+}
+
+GenericCapture * CaptureFactory::CreateCaptureInstance(ECaptureType captureType,
+		ECaptureMode captureMode)
+{
+	GenericCapture * pInst = NULL;
+	std::string s = "Capture instance created: ";
+	switch (captureType)
+	{
+		case ECaptureType_PCAP:
+			if (captureMode == ECaptureMode_Live)
+			{
+				pInst = new PCAPLiveCapture();
+				s += "PCAP live";
+			}
+			else
+			{
+				pInst = new PCAPOfflineCapture();
+				s += "PCAP offline";
+			}
+			break;
+	}
+	if (pInst)
+		Logger::Instance().LogDebug(s);
+	else
+		Logger::Instance().LogError("Unknown capture type");
+	return pInst;
+}
+void CaptureFactory::DisposeCaptureInstance(GenericCapture * pInstance)
+{
+	delete pInstance;
+}
+
+
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/CaptureFactory.h
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/CaptureFactory.h	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/CaptureFactory.h	(revision 20)
@@ -0,0 +1,43 @@
+/**
+ * @file CaptureFactory.h
+ * This header file defines the CaptureFactory class.
+ * @author Tomas Urban
+ * @version 0.1
+ * @date 16/07/2009
+ */
+#ifndef CAPTURE_FACTORY_H
+#define CAPTURE_FACTORY_H
+
+#include "GenericCapture.h"
+#include "Helper/Singleton.h"
+
+/**
+ * A singleton factory class for instantiating received data messages.
+ */
+class CaptureFactory  : public Singleton<CaptureFactory>
+{
+private:
+	friend class Singleton<CaptureFactory>;
+	CaptureFactory(void);
+public:
+	~CaptureFactory(void);
+	/**
+	 * The factory method for creating capture device instances based on supplied
+	 * device type and mode. The objects returned by this method are allocated on the heap, so they
+	 * have to be disposed when they are not needed anymore by the \c delete operator or
+	 * calling the #DisposeCaptureInstance method.
+	 * @param captureType Type of the capturing device
+	 * @param captureMode Capturing mode (live or offline)
+	 * @return Created device instance or \c NULL if any error has ocurred (e.g. unknown
+	 * or unsupported device).
+	 */
+	GenericCapture * CreateCaptureInstance(ECaptureType captureType,
+		ECaptureMode captureMode);
+	/**
+	 * This method is used for disposing instances allocated by the #CreateCaptureInstance method.
+	 * @param pInstance Capture device instance to be disposed
+	 */
+	void DisposeCaptureInstance(GenericCapture * pInstance);
+};
+
+#endif
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/ConnectionController.cpp
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/ConnectionController.cpp	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/ConnectionController.cpp	(revision 20)
@@ -0,0 +1,261 @@
+/**
+ * @file ConnectionController.cpp
+ * @author Tomas Urban
+ * @version 0.5
+ * @date 23/07/2009
+ */
+#include "ConnectionController.h"
+#include "PCAPLiveCapture.h"
+#include "Logger/Logger.h"
+#include "CaptureFactory.h"
+#include "Messages/TrafficCaptureMessageFactory.h"
+#include "Messages/CommonTrafficCaptureMessages.h"
+#include <boost/filesystem.hpp>
+
+ConnectionController::ConnectionController(SOCKET_TYPE hSocket) :
+	m_hSocket(hSocket),
+	m_pCapture(0)
+{
+}
+
+ConnectionController::~ConnectionController(void)
+{
+	CaptureFactory::Instance().DisposeCaptureInstance(m_pCapture);
+}
+
+void ConnectionController::SendSimpleReply(CommonReplyMessage & reply, bool bRes)
+{
+	reply.SetResult(bRes);
+	send(m_hSocket, reply.GetEncodedMessage(), reply.GetEncodedDataLength(), 0);
+}
+
+void ConnectionController::ProcessMessage(const struct TMessageHeader & header, const char * pPayload,
+										  TcpipDispatch &td)
+{
+	std::string s = "Control message received (id: ";
+	s += boost::lexical_cast<std::string>(header.nMsgType);
+	s += ", len: ";
+	s += boost::lexical_cast<std::string>(header.nMsgLen);
+	s += ")";
+	Logger::Instance().LogDebug(s);
+	TrafficCaptureMessage * pMsg = TrafficCaptureMessageFactory::Instance().CreateMessage(
+		header.nMsgType, pPayload, header.nMsgLen);
+	if (!pMsg)
+		return;
+	const char * pszIgnoreWarn = "Warning: message ignored; the capturing device hasn't been created yet";
+	switch (pMsg->GetId())
+	{
+	case OPEN_DEVICE_REQ:
+		{
+			Logger::Instance().LogInfo("OpenDeviceRequest message received");
+			ECaptureInitResult res = ECaptureInit_Failed;
+			if (m_pCapture == 0)
+			{
+				Logger::Instance().LogDebug("Creating capture instance...");
+				OpenDeviceRequest * pReq = dynamic_cast<OpenDeviceRequest*>(pMsg);
+				m_pCapture = CaptureFactory::Instance().CreateCaptureInstance(
+					pReq->GetCaptureType(), pReq->GetCaptureMode());				
+				if (m_pCapture != 0)
+				{
+					m_pCapture->InitDispatch(&td);
+					m_pCapture->SetStartOffset(pReq->GetTimestamp());
+					Logger::Instance().LogDebug("Initializing capture instance...");
+					res = m_pCapture->OpenDevice(pReq->GetParameters());
+					std::string sFile = pReq->GetCaptureFile();
+					if (res != ECaptureInit_Failed && sFile.length() > 0)
+					{
+						if (!m_pCapture->SetCaptureFile(sFile))
+							res = ECaptureInit_Failed;
+					}
+					if (res == ECaptureInit_Failed)
+					{
+						CaptureFactory::Instance().DisposeCaptureInstance(m_pCapture);
+						m_pCapture = 0;
+					}
+				}				
+			}
+			else
+				Logger::Instance().LogWarning("Capture device has been already created");
+			OpenDeviceReply reply;
+			reply.SetResult(res);
+			send(m_hSocket, reply.GetEncodedMessage(), reply.GetEncodedDataLength(), 0);
+			Logger::Instance().LogDebug("OpenDeviceReply message sent");
+		}
+		break;
+	case SET_FILTER_REQ:
+		Logger::Instance().LogInfo("SetFilterRequest message received");
+		{
+			bool bRes = (m_pCapture != 0);
+			if (bRes)
+			{
+				SetFilterRequest * pReq = dynamic_cast<SetFilterRequest*>(pMsg);
+				std::string sFilter = pReq->GetFilter();
+				std::string s = "The received filter value is: ";
+				s += sFilter;
+				Logger::Instance().LogDebug(s);
+				bRes = m_pCapture->SetFilter(sFilter);
+			}
+			else 
+				Logger::Instance().LogWarning(pszIgnoreWarn);
+			SetFilterReply reply;
+			SendSimpleReply(reply, !bRes);
+			Logger::Instance().LogDebug("SetFilterReply message sent");
+		}
+		break;
+	case START_CAPTURE_REQ:
+		{
+			Logger::Instance().LogInfo("StartCaptureRequest message received");
+			if (m_pCapture)
+				m_pCapture->StartCapture();
+			else 
+				Logger::Instance().LogWarning(pszIgnoreWarn);
+			StartCaptureReply reply;
+			SendSimpleReply(reply, m_pCapture == 0);
+		}
+		Logger::Instance().LogDebug("StartCaptureReply message sent");
+		break;
+	case STOP_CAPTURE_REQ:
+		{
+			Logger::Instance().LogInfo("StopCaptureRequest message received");
+			if (m_pCapture)
+				m_pCapture->StopCapture();
+			else 
+				Logger::Instance().LogWarning(pszIgnoreWarn);
+			StopCaptureReply reply;
+			SendSimpleReply(reply, m_pCapture == 0);
+			Logger::Instance().LogDebug("StopCaptureReply message sent");
+		}
+		break;
+	case MERGE_FILES_REQ:
+		{
+			MergePcapFilesRequest * pReq = dynamic_cast<MergePcapFilesRequest*>(pMsg);
+			Logger::Instance().LogInfo("MergePcapFilesRequest message received");
+			MergePcapFilesReply reply;
+			bool bRes;
+			std::vector<std::string> vsFiles = pReq->GetFilesToMerge();
+			if (bRes = vsFiles.size() > 0)
+			{
+				boost::filesystem::path targetFile = pReq->GetMergePath();
+				targetFile /= "mergefile.pcap";				
+				if (boost::filesystem::exists(targetFile))
+					try
+					{
+						boost::filesystem::remove(targetFile);
+						Logger::Instance().LogDebug(
+							"Merge file from a previous session has been successfully removed");
+					}
+					catch (boost::filesystem::filesystem_error)					
+					{
+						Logger::Instance().LogError(
+							"Merge file from a previous session could not be removed");
+						bRes = false;
+					}
+				else
+					Logger::Instance().LogDebug("No merge file from a previous session");
+				if (bRes)
+				{
+					boost::filesystem::path mergecapPath = pReq->GetMergecapDirectory();
+					mergecapPath /= "mergecap";
+					std::string sCmd = "\"";
+#ifdef WIN32
+					sCmd += "\"";
+#endif
+					sCmd += mergecapPath.string();
+					sCmd += "\" -w \"";
+					sCmd += targetFile.string();
+					sCmd += "\"";
+					for (unsigned int i = 0; i < vsFiles.size(); ++i)
+					{
+						sCmd += " \"";
+						sCmd += vsFiles[i];
+						sCmd += "\"";
+					}
+#ifdef WIN32
+					sCmd += "\"";
+#endif
+					Logger::Instance().LogDebug("Starting mergecap...");
+					Logger::Instance().LogDebug(sCmd);
+					system(sCmd.c_str());
+					reply.SetMergeFile(targetFile.string());
+					if (bRes = boost::filesystem::exists(targetFile))
+						Logger::Instance().LogDebug("Files merged successfully");
+					else
+						Logger::Instance().LogError("File merging failed");
+				}
+					
+			}
+			SendSimpleReply(reply, bRes);
+			Logger::Instance().LogDebug("MergePcapFilesReply message sent");
+		}
+		break;
+	default:
+		Logger::Instance().LogWarning("Warning: the received control message is not supported");
+	}	
+	TrafficCaptureMessageFactory::Instance().DisposeMessage(pMsg);
+}
+
+void ConnectionController::Run()
+{
+	TcpipDispatch td(m_hSocket);
+	Logger::Instance().LogInfo("Waiting for control messages to inialize capturing...");
+
+	// infinite receiving loop: interrupted when the connection is closed
+	TMessageHeader header;
+	int nReceived = 0, nLen, nRemaining;
+	char * pBuf = NULL;
+	while (-1)
+	{
+		if (nReceived < sizeof(header))
+		{
+			nRemaining = sizeof(header) - nReceived;
+			if ((nLen = recv(m_hSocket, reinterpret_cast<char*>(&header) + nReceived, nRemaining, 0)) <= 0)
+				break;
+			nReceived += nLen;
+		}
+		else
+		{
+			if (header.nMsgLen > 0)
+			{
+				if (pBuf == NULL)
+					pBuf = new char[header.nMsgLen];
+				nRemaining = sizeof(header) + header.nMsgLen - nReceived;
+				if ((nLen = recv(m_hSocket, pBuf + nReceived - sizeof(header), nRemaining , 0)) <= 0)
+					break;
+				nReceived += nLen;
+			}
+			if (nReceived == sizeof(header) + header.nMsgLen)
+			{
+				ProcessMessage(header, pBuf, td);
+				delete[] pBuf;
+				pBuf = NULL;
+				nReceived = 0;
+				if (!m_hSocket)
+					break;
+			}
+		}
+	}
+
+	boost::mutex::scoped_lock cond(m_mutex);
+	td.Stop();
+	CaptureFactory::Instance().DisposeCaptureInstance(m_pCapture);
+	m_pCapture = NULL;
+	Logger::Instance().LogInfo("Client connection terminated");
+	if (m_hSocket != SOCKET_CALL_ERROR)
+	{
+		CLOSE_SOCKET(m_hSocket);
+		m_hSocket = SOCKET_CALL_ERROR;
+	}
+	m_captureClosed.notify_one();
+	
+}
+
+void ConnectionController::Stop()
+{
+	boost::mutex::scoped_lock cond(m_mutex);
+	if (m_hSocket != SOCKET_CALL_ERROR)
+	{
+		CLOSE_SOCKET(m_hSocket);
+		m_hSocket = SOCKET_CALL_ERROR;
+		m_captureClosed.wait(cond);		
+	}
+}
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/ConnectionController.h
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/ConnectionController.h	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/ConnectionController.h	(revision 20)
@@ -0,0 +1,50 @@
+/**
+ * @file ConnectionController.h
+ * This header file defines the TcpipServer class.
+ * @author Tomas Urban
+ * @version 0.2
+ * @date 23/07/2009
+ */
+#ifndef CONNECTION_CONTROLLER_H
+#define CONNECTION_CONTROLLER_H
+
+#include "TcpipDefs.h"
+#include "GenericCapture.h"
+#include "Messages/TrafficCaptureMessage.h"
+#include "TcpipDispatch.h"
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+
+/**
+ * ConnectionController is class which handles a single client TCP/IP connection. It reads requests from
+ * the client, decodes and processes them and replies to them if needed.
+ */
+class ConnectionController
+{
+private:
+	SOCKET_TYPE m_hSocket;
+	GenericCapture * m_pCapture;
+	boost::mutex m_mutex;
+	boost::condition m_captureClosed;
+	void SendSimpleReply(CommonReplyMessage & reply, bool bRes);
+	void ProcessMessage(const struct TMessageHeader & header, const char * pPayload, TcpipDispatch & td);
+public:
+	/**
+	 * Class constructor.
+	 * @param hSocket Handle to client's socket
+	 */
+	ConnectionController(SOCKET_TYPE hSocket);
+	~ConnectionController(void);
+	/**
+	 * The method starts waiting for client's requests and processing them. It is a blocking method
+	 * and it returns only if the connection is interrupted or on client's request to terminate the whole
+	 * session.
+	 */
+	void Run();
+	/**
+	 * The method is used for stopping a running connection controller.
+	 */
+	void Stop();
+};
+
+#endif
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/GenericCapture.cpp
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/GenericCapture.cpp	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/GenericCapture.cpp	(revision 20)
@@ -0,0 +1,68 @@
+/**
+ * @file GenericCapture.cpp
+ * @author Tomas Urban
+ * @version 0.3
+ * @date 23/07/2009
+ */
+#include "GenericCapture.h"
+#include "Logger/Logger.h"
+
+GenericCapture::GenericCapture() :
+	m_pDispatch(0)
+{
+	m_startPoint.tv_sec = 0;
+	m_startPoint.tv_usec = 0;
+	m_offset.tv_sec = 0;
+	m_offset.tv_usec = 0;
+	m_timestamp.tv_sec = 0;
+	m_timestamp.tv_usec = 0;
+}
+
+GenericCapture::~GenericCapture(void)
+{
+	
+}
+
+void GenericCapture::UpdateTimestamp()
+{
+	m_timestamp.tv_sec = m_startPoint.tv_sec + m_offset.tv_sec;
+	m_timestamp.tv_usec = m_startPoint.tv_usec + m_offset.tv_usec;
+	int nSec = m_timestamp.tv_usec / 1000000;
+	if (nSec > 0)
+	{
+		m_timestamp.tv_sec += nSec;
+		m_timestamp.tv_usec -= nSec * 1000000;
+	}
+}
+
+void GenericCapture::SetStartPoint(struct timeval timestamp)
+{
+	m_startPoint = timestamp;
+	UpdateTimestamp();
+}
+
+void GenericCapture::SetStartOffset(struct timeval offset) 
+{ 
+	m_offset = offset;
+	UpdateTimestamp();
+}
+
+void GenericCapture::ProcessCapturedData(CapturedData * pData)
+{
+	if (!m_pDispatch)
+		return;
+	timeval msgTime = pData->GetTimestamp();
+	if (msgTime.tv_sec > m_timestamp.tv_sec ||
+		msgTime.tv_sec == m_timestamp.tv_sec && msgTime.tv_usec >= m_timestamp.tv_usec)
+	{
+		pData->SetCaptureType(GetCaptureType());
+		m_pDispatch->DispatchData(pData);
+	}
+	else
+		Logger::Instance().LogDebug("Captured message discarded (older than start point)");
+}
+
+bool GenericCapture::SetCaptureFile(const std::string sFile) 
+{ 
+	return sFile.length() == 0; 
+}
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/GenericCapture.h
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/GenericCapture.h	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/GenericCapture.h	(revision 20)
@@ -0,0 +1,107 @@
+/**
+ * @file GenericCapture.h
+ * This header file defines the GenericCapture class.
+ * @author Tomas Urban
+ * @version 0.2
+ * @date 21/07/2009
+ */
+#ifndef GENERIC_CAPTURE_H
+#define GENERIC_CAPTURE_H
+
+#include "Messages/CapturedData.h"
+#include "CaptureDispatch.h"
+
+
+/**
+ * Abstract class describing a capturing device. It defines the common interface and several
+ * useful methods. However, the capturing code itself must be implemented in child classes
+ * according to the means used for capture (strategy design pattern).
+ */
+class GenericCapture
+{
+private:
+	CaptureDispatch * m_pDispatch;
+	struct timeval m_offset;
+	struct timeval m_startPoint;
+	struct timeval m_timestamp;
+	void UpdateTimestamp();
+protected:
+	GenericCapture();
+	/**
+	 * This method is used for processing the captured data, passing it to an associated
+	 * CaptureDispatch object.
+	 * @param pData Data to process
+	 */
+	void ProcessCapturedData(CapturedData * pData);
+	/**
+	 * Sets the capture start point timestamp which is used in time-based filtering
+	 * @param timestamp Timestamp of the beginning of capture
+	 */
+	void SetStartPoint(struct timeval timestamp);
+public:	
+	virtual ~GenericCapture(void);
+	/**
+	 * Sets the object used for delivering captured data to the final recipient.
+	 */
+	void InitDispatch(CaptureDispatch * pDispatch) { m_pDispatch = pDispatch; }
+	/**
+	 * Initializes capturing object. The parameter contains additional initialization
+	 * data. The format of the data is device specific.
+	 * @param sParams Start-up parameters of the device
+	 * @return Operation success
+	 */
+	virtual ECaptureInitResult OpenDevice(const std::string sParams) = 0;
+	/**
+	 * Sets the path to an associated capture file. This call is used only by devices
+	 * capable of saving traffic into a file. In the default case, the method
+	 * doesn't cause any traffic to be saved.
+	 * @param sFile Name of the target file or empty string if the traffic should not 
+	 * be saved.
+	 * @return \c true if the operation succeeds, \c false otherwise.
+	 */
+	virtual bool SetCaptureFile(const std::string sFile);
+	/**
+	 * Contains device-specific clean-up code.
+	 */
+	virtual void CloseDevice() = 0;	
+	/**
+	 * Sets up the capture filter. If the string is empty, no filtering should be applied.
+	 * The format of the filtering parameter is device specific.
+	 * @param sFilter Filtering data
+	 * @return \c true if the operation was successful, \c false otherwise (e.g. in case
+	 * of invalid filter format)
+	 **/
+	virtual bool SetFilter(const std::string sFilter) = 0;
+	/**
+	 * Starts or resumes data capture on the device
+	 * @return \c true if the operation was successful, \c false otherwise
+	 */	
+	virtual bool StartCapture() = 0;
+	/**
+	 * Stops or suspends data capture on the device
+	 * @return \c true if the operation was successful, \c false otherwise
+	 */	
+	virtual bool StopCapture() = 0;
+	/**
+	 * Returns the type of the capturing device.
+	 * @return Capture type
+	 */
+	virtual ECaptureType GetCaptureType() = 0;
+	/**
+	 * Returns the offset of the time-based capturing filter. If the returned value is equal
+	 * to zero, no time-based filter is applied.
+	 * @return Offset used for time-based filtering
+	 */
+	struct timeval GetStartOffset() const { return m_offset; }
+	/**
+	 * Sets the offset of the time-based capturing filter. If the timestamp value is equal
+	 * to zero, no time-based filter is applied. Otherwise the capturing device automatically
+	 * discards captured messages whose timestamp is smaller than the specified offset. The
+	 * offset is related to the first captured message.
+	 * @param offset Offset used for time-based filtering
+	 */
+	void SetStartOffset(struct timeval offset);
+};
+
+#endif
+
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/PCAPCapture.cpp
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/PCAPCapture.cpp	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/PCAPCapture.cpp	(revision 20)
@@ -0,0 +1,255 @@
+/**
+ * @file PCAPCapture.cpp
+ * @author Tomas Urban
+ * @version 0.4
+ * @date 23/07/2009
+ */
+#include "PCAPCapture.h"
+#include <boost/thread/thread.hpp>
+#include <boost/tokenizer.hpp>
+#include "Logger/Logger.h"
+
+PCAPCapture::PCAPCapture() :
+	m_fp(NULL),
+	m_nHandleCount(0),
+	m_bRunning(false),
+	m_dumpFiles(0),
+	m_threadRunning(0)
+{
+}
+
+PCAPCapture::~PCAPCapture() 
+{
+	CloseDevice();	
+}
+
+pcap_t * PCAPCapture::OpenPcapSource(const std::string sSource)
+{
+	char errbuf[PCAP_ERRBUF_SIZE];
+	return pcap_open(sSource.c_str(), SNAP_LEN, PCAP_OPENFLAG_PROMISCUOUS,
+		1000, NULL, errbuf);
+}
+
+void PCAPCapture::CloseDevice()
+{
+	if (m_fp != NULL)
+	{
+		StopCapture();
+		CloseCaptureFile();
+		for (int i = 0; i < m_nHandleCount; i++)
+			pcap_close(m_fp[i]);
+		delete m_fp;
+		m_fp = NULL;
+		m_threadRunning = NULL;
+		m_nHandleCount = 0;
+	}
+}
+void PCAPCapture::SetPcapHandles(pcap_t ** srcBuf, int nLen)
+{
+	CloseDevice();
+	m_fp = new pcap_t*[nLen];
+	m_nHandleCount = nLen;
+	memcpy(m_fp, srcBuf, nLen * sizeof(pcap_t*));
+	m_threadRunning = new bool[nLen];
+	memset(m_threadRunning, 0, nLen * sizeof(bool));
+}
+
+void PCAPCapture::DispatcherHandler(u_char *temp1, 
+                        const struct pcap_pkthdr *header, const u_char *pkt_data)
+{	
+	PCAPCapture::CapturingThread * pThread = reinterpret_cast<PCAPCapture::CapturingThread*>(temp1);
+	PCAPCapture * pObj = pThread->m_pCapture;
+	int nIndex = pThread->m_nHandleIndex;
+	if (pObj->m_dumpFiles)
+	{
+		boost::mutex::scoped_lock lock(pObj->m_mutex);
+		pcap_dump(reinterpret_cast <u_char*>(pObj->m_dumpFiles[nIndex]), header, pkt_data);
+	}
+	CapturedData cd;
+	cd.SetData(header->caplen, reinterpret_cast <const char*> (pkt_data));
+	cd.SetTimestamp(header->ts);
+	if (pObj->m_fp)
+		pObj->ProcessCapturedData(&cd);
+}
+
+PCAPCapture::CapturingThread::CapturingThread(PCAPCapture * pCapture, int nHandleIndex) :
+	m_pCapture(pCapture),
+	m_nHandleIndex(nHandleIndex)
+{
+}
+
+void PCAPCapture::CapturingThread::operator()()
+{
+	std::string s = "Packet capture started";
+	std::string s2 = "";
+	if (m_pCapture->m_nHandleCount > 1)
+	{
+		s2 = " (source #";
+		s2 += boost::lexical_cast<std::string>(m_nHandleIndex + 1);
+		s2 += ")";
+		s += s2;
+	}
+	Logger::Instance().LogDebug(s);
+
+	pcap_loop(m_pCapture->m_fp[m_nHandleIndex], 0, PCAPCapture::DispatcherHandler, 
+		reinterpret_cast <u_char*> (this));
+
+	s = "Packet capture ended";
+	s += s2;
+	Logger::Instance().LogDebug(s);
+	{
+		boost::mutex::scoped_lock(m_pCapture->m_mutex);
+		m_pCapture->m_threadRunning[m_nHandleIndex] = false;
+		if (m_pCapture->m_bRunning)
+			m_pCapture->m_threadClosed.notify_one();
+	}
+}
+
+bool PCAPCapture::StartCapture()
+{
+	if (m_bRunning)
+		return true;
+	m_bRunning = true;
+	if (m_fp)		
+	{
+		for (int i = 0; i < m_nHandleCount; i++)
+		{
+			m_threadRunning[i] = true;
+			boost::thread thread(CapturingThread(this, i));
+		}
+	}
+	return true;
+}
+
+bool PCAPCapture::StopCapture()
+{	
+	if (!m_bRunning)
+		return true;
+	m_bRunning = false;
+	if (m_fp)
+	{
+		for (int i = 0; i < m_nHandleCount; i++)
+		{
+			boost::mutex::scoped_lock cond(m_mutex);
+			if (m_threadRunning[i])
+			{
+				pcap_breakloop(m_fp[i]);
+				m_threadClosed.wait(cond);
+			}
+		}
+	}
+	return true;
+}
+
+bool PCAPCapture::SetFilter(const std::string sFilter)
+{
+	if (!m_fp)
+	{
+		Logger::Instance().LogWarning("Cannot apply filter; the capture device is not open");
+		return false;
+	}
+	
+	std::string sFormattedFilter = sFilter;
+
+	// compile the filter		
+	struct bpf_program fcode;
+	std::string s = "Setting PCAP filter (";
+	s += sFormattedFilter;
+	s += ")...";
+	Logger::Instance().LogDebug(s);
+	bool bRes = true;
+	for (int i = 0; i < m_nHandleCount; i++)
+	{		
+		if (m_nHandleCount > 1)
+		{
+			s = "Applying filter to source #";
+			s += boost::lexical_cast<std::string>(i + 1);
+			s += "...";
+			Logger::Instance().LogDebug(s);
+		}				
+		if (pcap_compile(m_fp[i], &fcode, sFormattedFilter.c_str(), 1, 0) < 0)
+		{
+			Logger::Instance().LogError("Error compiling packet filter");
+			bRes = false;
+			continue;
+		}
+	    
+		//set the filter
+		int nRes = pcap_setfilter(m_fp[i], &fcode);
+		pcap_freecode(&fcode);
+		if (nRes < 0)
+		{
+			Logger::Instance().LogError("Error setting packet filter");
+			bRes = false;
+			continue;
+		}		
+		Logger::Instance().LogInfo("Filter applied successfully");
+	}
+	Logger::Instance().LogDebug("PCAP filter ready");
+	return bRes;
+}
+
+void PCAPCapture::CloseCaptureFile()
+{
+	if (m_dumpFiles)
+	{
+		boost::mutex::scoped_lock lock(m_mutex);
+		for (int i = 0; i < m_nHandleCount; i++)
+			pcap_dump_close(m_dumpFiles[i]);
+		delete m_dumpFiles;
+		m_dumpFiles = 0;
+	}
+}
+
+bool PCAPCapture::InitCaptureFile(const std::string sFile)
+{
+	if (!m_nHandleCount)
+		return false;
+	CloseCaptureFile();
+	bool bRes = true;
+	if (sFile.length() > 0)
+	{
+		boost::mutex::scoped_lock lock(m_mutex);
+		m_dumpFiles = new pcap_dumper_t * [m_nHandleCount];
+		memset(m_dumpFiles, 0, sizeof(pcap_dumper_t*) * m_nHandleCount);
+
+		std::string sName = sFile;
+		std::string sExt = "";
+		if (m_nHandleCount > 1)
+		{
+			size_t nSize = sFile.find_last_of('.');
+			if (nSize < sFile.length())
+			{
+				sName = sFile.substr(0, nSize);
+				sExt = sFile.substr(nSize);
+			}
+		}
+		
+		for (int i = 0; i < m_nHandleCount; i++)
+		{
+			std::string sTmp = sFile;
+			if (m_nHandleCount > 1)
+			{
+				sTmp = sName;
+				sTmp += boost::lexical_cast<std::string>(i + 1);
+				sTmp += sExt;
+			}
+			m_dumpFiles[i] = pcap_dump_open(m_fp[i], sTmp.c_str());
+			if (!m_dumpFiles[i])
+			{
+				std::string s = "Failed to create dump file \"";
+				s += sTmp;
+				s += "\"";
+				Logger::Instance().LogError(s);
+				return false;
+			}
+		}
+		Logger::Instance().LogDebug("PCAP dump file successfully initialized");
+	}
+	else
+		Logger::Instance().LogDebug("Dump file disabled");
+	return true;;
+}
+
+
+
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/PCAPCapture.h
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/PCAPCapture.h	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/PCAPCapture.h	(revision 20)
@@ -0,0 +1,77 @@
+/**
+ * @file PCAPCapture.h
+ * This header file defines the PCAPCapture class.
+ * @author Tomas Urban
+ * @version 0.2
+ * @date 22/07/2009
+ */
+#ifndef PCAP_CAPTURE_H
+#define PCAP_CAPTURE_H
+
+#include "GenericCapture.h"
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+
+#define HAVE_REMOTE
+#include "pcap/pcap.h"
+
+/**
+ * This abstract class describes capturing based on the pcap library.
+ */
+class PCAPCapture :	public GenericCapture
+{
+private:
+	static const int SNAP_LEN = 0x1000; 
+	pcap_t ** m_fp; //array of pcap handles
+	int m_nHandleCount;
+	bool * m_threadRunning;
+	static void DispatcherHandler(u_char * temp1, const struct pcap_pkthdr *header, const u_char *pkt_data);
+	boost::mutex m_mutex;
+	boost::condition m_threadClosed;
+	bool m_bRunning;
+	pcap_dumper_t ** m_dumpFiles;
+	void CloseCaptureFile();	
+	class CapturingThread
+	{ 
+	public:
+		PCAPCapture * m_pCapture;
+		int m_nHandleIndex;
+		CapturingThread(PCAPCapture * pCapture, int nHandleIndex);
+		void operator()();
+	}; 
+protected:
+	PCAPCapture();	
+	/**
+	 * Saves supplied array of pcap sources for later use. This method is usually called
+	 * by the #OpenDevice method of child classes.
+	 * @param srcBuf Source array
+	 * @param nLen Number of elements in the source array
+	 */
+	void SetPcapHandles(pcap_t ** srcBuf, int nLen);
+	/**
+	 * Helper method for opening a pcap data source
+	 * @return Pointer to the pcap source or \c NULL if the operation is not successful.
+	 */
+	pcap_t * OpenPcapSource(const std::string sSource);
+	/**
+	 * Helper method for setting up data saving into a file. It is used by child classes
+	 * that allow data saving into a file.
+	 * @param sFile Path to the capture file
+	 */
+	bool InitCaptureFile(const std::string sFile);
+public:
+	virtual ~PCAPCapture(void);
+	virtual ECaptureType GetCaptureType() { return ECaptureType_PCAP; }
+	/**
+	 * Sets a traffic filter. The filter must follow pcap library syntax for filtering expressions.
+	 * @param sFilter Filtering data in pcap format
+	 * @return \c true if the operation was successful, \c false otherwise (e.g. in case
+	 * of invalid filter format)
+	 */
+	virtual bool SetFilter(const std::string sFilter);
+	virtual void CloseDevice();
+	virtual bool StartCapture();
+	virtual bool StopCapture();
+};
+
+#endif
Index: /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/makefile
===================================================================
--- /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/makefile	(revision 20)
+++ /trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Capture/makefile	(revision 20)
@@ -0,0 +1,90 @@
+OBJECTS = CapturedData.o GenericCapture.o PCAPCapture.o Logger.o \
+  PCAPOfflineCapture.o PCAPLiveCapture.o TcpipServer.o TcpipDispatch.o ConnectionController.o \
+  TrafficCapture.o CaptureFactory.o TrafficCaptureMessage.o CommonTrafficCaptureMessages.o \
+  TrafficCaptureMessageFactory.o
+INCLUDES = -I/usr/include/pcap \
+  -I/usr/local/boost_1_39_0 \
+  -I.. \
+# -I/opt/boost-mingw-gcc345-1.38.0/include \
+
+LIBPATH = #-L/usr/lib -L/opt/boost-mingw-gcc345-1.38.0/lib
+#-L/usr/local/boost/stage
+
+CPPFLAGS = #-mno-cygwin 
+
+TrafficCapture.exe: $(OBJECTS)
+	g++ $(CPPFLAGS) $(OBJECTS) $(LIBPATH) -o TrafficCapture.exe -lwpcap -lboost_thread-gcc34-mt -lboost_system-gcc34-mt -lboost_filesystem-gcc34-mt
+#-lboost_system-mt -lboost_thread-mt -lws2_32
+
+TrafficCaptureMessage.o : ../Messages/TrafficCaptureMessage.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c ../Messages/TrafficCaptureMessage.cpp
+
+../Messages/CommonTrafficCaptureMessages.h : ../Messages/TrafficCaptureMessageId.h ../Messages/TrafficCaptureMessage.h
+
+CommonTrafficCaptureMessages.o : ../Messages/CommonTrafficCaptureMessages.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c ../Messages/CommonTrafficCaptureMessages.cpp
+
+../Messages/CaptureData.h : ../Messages/TrafficCaptureMessageId.h ../Messages/TrafficCaptureMessage.h
+
+CapturedData.o : ../Messages/CapturedData.cpp ../Messages/CapturedData.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c ../Messages/CapturedData.cpp
+
+../Messages/TrafficCaptureMessageFactory.h : ../Helper/Singleton.h ../Messages/TrafficCaptureMessage.h
+
+TrafficCaptureMessageFactory.o : ../Messages/TrafficCaptureMessageFactory.h ../Messages/TrafficCaptureMessageId.h \
+  ../Messages/CommonTrafficCaptureMessages.h ../Logger/Logger.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c ../Messages/TrafficCaptureMessageFactory.cpp
+
+../Logger/Logger.h : ../Messages/CapturedData.h
+
+Logger.o : ../Logger/Logger.cpp ../Logger/Logger.h ../Helper/Singleton.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c ../Logger/Logger.cpp
+
+CaptureDispatch.h : ../Messages/CapturedData.h
+
+GenericCapture.h : ../Messages/CapturedData.h CaptureDispatch.h
+
+GenericCapture.o : GenericCapture.cpp GenericCapture.h ../Logger/Logger.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c GenericCapture.cpp
+
+PCAPCapture.h : GenericCapture.h
+
+PCAPCapture.o : PCAPCapture.cpp PCAPCapture.h ../Logger/Logger.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c PCAPCapture.cpp
+
+PCAPOfflineCapture.h : PCAPCapture.h
+
+PCAPOfflineCapture.o : PCAPOfflineCapture.cpp PCAPOfflineCapture.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c PCAPOfflineCapture.cpp
+
+PCAPLiveCapture.h : PCAPCapture.h ../Logger/Logger.h
+
+PCAPLiveCapture.o : PCAPLiveCapture.cpp PCAPLiveCapture.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c PCAPLiveCapture.cpp
+
+CaptureFactory.h : GenericCapture.h ../Helper/Singleton.h
+
+CaptureFactory.o : CaptureFactory.cpp CaptureFactory.h PCAPLiveCapture.h PCAPOfflineCapture.h ../Logger/Logger.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c CaptureFactory.cpp
+
+ConnectionController.h : TcpipDefs.h GenericCapture.h ../Messages/TrafficCaptureMessage.h TcpipDispatch.h
+
+ConnectionController.o : ConnectionController.cpp ConnectionController.h  ../Logger/Logger.h \
+  ../Messages/TrafficCaptureMessageFactory.h ../Messages/CommonTrafficCaptureMessages.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c ConnectionController.cpp
+
+TcpipServer.h : TcpipDefs.h
+
+TcpipServer.o : TcpipServer.cpp TcpipServer.h ConnectionController.h ../Logger/Logger.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c TcpipServer.cpp
+
+TcpipDispatch.h : TcpipDefs.h CaptureDispatch.h
+
+TcpipDispatch.o : TcpipDispatch.cpp TcpipDispatch.h ../Logger/Logger.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c TcpipDispatch.cpp
+
+TrafficCapture.o : TrafficCapture.cpp TcpipServer.h
+	g++ $(CPPFLAGS) $(INCLUDES) -c TrafficCapture.cpp
+
+clean:
+	rm -f *.o TrafficCapture.exe
