Main Page   Class Hierarchy   Compound List   File List   Compound Members  

C_ScenarioControl.cpp

00001 /*
00002  *  This program is free software; you can redistribute it and/or modify
00003  *  it under the terms of the GNU General Public License as published by
00004  *  the Free Software Foundation; either version 2 of the License, or
00005  *  (at your option) any later version.
00006  *
00007  *  This program is distributed in the hope that it will be useful,
00008  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00009  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010  *  GNU General Public License for more details.
00011  *
00012  *  You should have received a copy of the GNU General Public License
00013  *  along with this program; if not, write to the Free Software
00014  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00015  *
00016  * (c)Copyright 2006 Hewlett-Packard Development Company, LP.
00017  *
00018  */
00019 
00020 #include "C_ScenarioControl.hpp"
00021 #include "Utils.hpp"
00022 #include "ProtocolData.hpp"
00023 #include "GeneratorTrace.hpp"
00024 #include "GeneratorError.h"
00025 #include "C_ReadControl.hpp"
00026 #include "BufferUtils.hpp"
00027 
00028 #include "C_ScenarioStats.hpp"
00029 #include "C_CommandActionFactory.hpp"
00030 #include "C_GeneratorStats.hpp"
00031 #include "C_CommandAction.hpp"
00032 
00033 #include "list_t.hpp"
00034 #include "integer_t.hpp" // For strtoul_f
00035 #include <regex.h>
00036 
00037 
00038 
00039 #define XML_SCENARIO_SECTION               (char*)"scenario"
00040 #define XML_SCENARIO_COUNTER_SECTION       (char*)"counter"
00041 #define XML_SCENARIO_TRAFFIC_SECTION       (char*)"traffic"
00042 #define XML_SCENARIO_DEFAULT_SECTION       (char*)"default"
00043 #define XML_SCENARIO_INIT_SECTION          (char*)"init"
00044 #define XML_SCENARIO_ABORT_SECTION         (char*)"abort"
00045 
00046 static const T_CmdAction no_cmd_action = {
00047   E_ACTION_SCEN_OPEN,
00048   NULL,
00049   -1, -1, -1, -1, -1, -1,
00050   NULL,
00051   -1, -1,
00052   NULL,
00053   E_CHECK_BEHAVIOUR_WARNING,
00054   -1,
00055   NULL,
00056   NULL
00057 } ;
00058   
00059 C_ScenarioControl::C_ScenarioControl(C_ProtocolControl  *P_protocol_control,
00060                                      C_TransportControl *P_transport_control,
00061                                      C_ChannelControl   *P_channel_control) {
00062   m_traffic_scen = NULL ;
00063   m_init_scen = NULL ;
00064   m_abort_scen = NULL ;
00065   m_default_scen = NULL ;
00066   m_traffic_type = E_TRAFFIC_UNKNOWN ;
00067   m_init_type = E_TRAFFIC_UNKNOWN ;
00068   m_max_default = 0 ;
00069   m_nb_default  = 0 ;
00070   m_nb_scenario = 0 ;
00071   NEW_VAR(m_memory_map, T_MemoryIdMap());
00072   m_memory_map->clear();
00073   m_memory_max = 0 ;
00074   m_save_traffic_scen = NULL ;
00075   m_config = NULL ;
00076   m_log = NULL ;
00077   NEW_VAR(m_wait_values, T_waitValuesSet());
00078 
00079   m_retrans_enabled = false;
00080   NEW_VAR(m_retrans_delay_values, T_retransDelayValuesSet());
00081 
00082   m_external_data = NULL ;
00083   m_external_data_used = false ;
00084 
00085   m_check_level = 0 ;
00086   m_check_behaviour = E_CHECK_BEHAVIOUR_WARNING ;
00087 
00088   // generator model
00089   m_protocol_ctrl = P_protocol_control ;
00090   m_transport_ctrl = P_transport_control ;
00091   m_channel_ctrl = P_channel_control ;
00092 
00093   NEW_VAR(m_counter_map, T_CounterMap()) ;
00094   m_nb_counter = 0 ;
00095   m_counter_table = NULL ;
00096   m_action_check_abort = false ;
00097 }
00098 
00099 C_ScenarioControl::~C_ScenarioControl() {
00100 
00101   int L_i ;
00102 
00103   if (m_init_scen == m_traffic_scen) {
00104     m_traffic_scen = m_save_traffic_scen ;
00105   }
00106 
00107   if (m_traffic_scen) {
00108     m_traffic_scen->delete_stats();
00109   }
00110   DELETE_VAR(m_traffic_scen);
00111   
00112   if (m_init_scen) {
00113     m_init_scen->delete_stats();
00114   }
00115   DELETE_VAR(m_init_scen);
00116 
00117   if (m_abort_scen) {
00118     m_abort_scen->delete_stats();
00119   }
00120   DELETE_VAR(m_abort_scen);
00121 
00122   if (m_nb_default) {
00123     for(L_i=0; L_i < m_nb_default; L_i++) {
00124       if (m_default_scen[L_i]) {
00125         m_default_scen[L_i]->delete_stats() ;
00126       }
00127     }
00128   }
00129   FREE_TABLE(m_default_scen);
00130 
00131   m_traffic_type = E_TRAFFIC_UNKNOWN ;
00132   m_init_type = E_TRAFFIC_UNKNOWN ;
00133   m_max_default = 0 ;
00134   m_nb_default = 0 ;
00135   m_memory_max = 0 ;
00136   if (!m_memory_map->empty()) {
00137     m_memory_map->erase(m_memory_map->begin(), m_memory_map->end());
00138   }
00139   DELETE_VAR(m_memory_map);
00140 
00141   m_save_traffic_scen = NULL ;
00142   m_config = NULL ;
00143   if (!m_wait_values->empty()) {
00144     m_wait_values->erase(m_wait_values->begin(), m_wait_values->end());
00145   }
00146   DELETE_VAR(m_wait_values);
00147 
00148   if (!m_retrans_delay_values->empty()) {
00149     m_retrans_delay_values->erase(m_retrans_delay_values->begin(), m_retrans_delay_values->end());
00150   }
00151   DELETE_VAR(m_retrans_delay_values);
00152 
00153   if (m_nb_counter != 0){
00154     for (L_i = 0; L_i < m_nb_counter; L_i++) {
00155       FREE_VAR(m_counter_table[L_i]);
00156     }
00157     FREE_TABLE(m_counter_table);
00158     m_nb_counter = 0 ;
00159   }
00160   if (!m_counter_map->empty()) {
00161     m_counter_map->erase(m_counter_map->begin(), m_counter_map->end());
00162   }
00163   DELETE_VAR(m_counter_map);
00164 
00165   m_action_check_abort = false ;
00166 
00167 }
00168 
00169 void C_ScenarioControl::set_data_log_controller (C_DataLogControl *P_log) {
00170 
00171   int L_i ;
00172 
00173   GEN_DEBUG(1, "C_ScenarioControl::set_data_log_controller() start");
00174   m_log = P_log ;
00175   if (m_traffic_scen) { 
00176           m_traffic_scen->set_data_log_controller(m_log); 
00177   }
00178   if (m_save_traffic_scen) { 
00179           m_save_traffic_scen->set_data_log_controller(m_log); 
00180   }
00181   if (m_init_scen) { 
00182           m_init_scen->set_data_log_controller(m_log);
00183   }
00184   if (m_abort_scen) { 
00185           m_abort_scen->set_data_log_controller(m_log); 
00186   }
00187   if (m_nb_default) {
00188     for (L_i = 0; L_i < m_nb_default; L_i++) {
00189       m_default_scen[L_i]->set_data_log_controller(m_log);
00190     }
00191   }
00192   GEN_DEBUG(1, "C_ScenarioControl::set_data_log_controller() end");
00193 }
00194 
00195 void C_ScenarioControl::set_external_data_controller (C_ExternalDataControl *P_external_data) {
00196   GEN_DEBUG(1, "C_ScenarioControl::set_external_data_controller() start");
00197   m_external_data = P_external_data ;  
00198   GEN_DEBUG(1, "C_ScenarioControl::set_external_data_controller() end");
00199 }
00200 
00201 
00202 void C_ScenarioControl::set_default_scenarii (int P_nb) {
00203   if (m_nb_default == 0) {
00204     m_max_default = P_nb ;
00205     ALLOC_TABLE(m_default_scen,
00206                 T_pC_Scenario*,
00207                 sizeof(T_pC_Scenario),
00208                 m_max_default);
00209   } else {
00210     GEN_FATAL(E_GEN_FATAL_ERROR, "Default number already setted");
00211   }
00212 }
00213 
00214 T_pC_Scenario C_ScenarioControl::outgoing_scenario () {
00215   T_pC_Scenario L_scen = NULL ;
00216   if (m_traffic_type == E_TRAFFIC_CLIENT) {
00217     L_scen = m_traffic_scen ;
00218   }
00219   return (L_scen);
00220 }
00221 
00222 T_pC_Scenario C_ScenarioControl::find_scenario (T_pReceiveMsgContext P_rcvMsg) {
00223 
00224   T_pC_Scenario L_ret ;
00225   
00226   GEN_DEBUG(1, "C_ScenarioControl::find_scenario() start");
00227 
00228   //GEN_DEBUG(1, "P_msg [" << (*P_msg) << "]");
00229 
00230   L_ret = (m_traffic_scen->check_msg_received(P_rcvMsg)) 
00231     ? m_traffic_scen : find_default_scenario(P_rcvMsg) ;
00232   GEN_DEBUG(1, "C_ScenarioControl::find_scenario() end");
00233   return (L_ret);
00234 
00235 }
00236 
00237 T_pC_Scenario C_ScenarioControl::get_default_scenario (int P_index) {
00238 
00239   T_pC_Scenario L_ret = NULL ;
00240 
00241   if (P_index < m_nb_default) {
00242     L_ret = m_default_scen[P_index];
00243   }
00244   
00245   return (L_ret);
00246 
00247 }
00248 
00249 
00250 T_pC_Scenario C_ScenarioControl::find_default_scenario (T_pReceiveMsgContext P_rcvMsg) {
00251 
00252   T_pC_Scenario L_ret = NULL ;
00253   int           L_i ;
00254 
00255   GEN_DEBUG(1, "C_ScenarioControl::find_default_scenario() start");
00256   GEN_DEBUG(1, "m_nb_default " << m_nb_default);
00257   
00258   for (L_i = 0 ;
00259        L_i < m_nb_default;
00260        L_i++) {
00261     if (m_default_scen[L_i]->check_msg_received(P_rcvMsg)) {
00262       L_ret = m_default_scen[L_i];
00263       break ;
00264     }
00265   }
00266   
00267   GEN_DEBUG(1, "C_ScenarioControl::find_default_scenario() end");
00268   return (L_ret);
00269 
00270 }
00271 
00272 T_pC_Scenario C_ScenarioControl::get_abort_scenario () {
00273   return (m_abort_scen);
00274 }
00275 
00276 
00277 T_pC_Scenario C_ScenarioControl::get_init_scenario () {
00278   return (m_init_scen);
00279 }
00280 
00281 T_pC_Scenario C_ScenarioControl::get_traffic_scenario () {
00282   if (m_save_traffic_scen != NULL) {
00283     return (m_save_traffic_scen);
00284   } else {
00285     return (m_traffic_scen);
00286   }
00287 }
00288 
00289 
00290 
00291 char* C_ScenarioControl::get_behaviour_scenario(C_XmlData     *P_scen) {
00292 
00293   char                                *L_value = NULL    ;
00294   C_XmlData::T_pXmlField_List          L_fields_list     ;
00295   C_XmlData::T_XmlField_List::iterator L_fieldIt         ;
00296 
00297   L_fields_list = P_scen->get_fields();
00298   if (!L_fields_list->empty()) {
00299     for(L_fieldIt  = L_fields_list->begin() ;
00300         L_fieldIt != L_fields_list->end() ;
00301         L_fieldIt++) {
00302       if(strcmp((*L_fieldIt)->get_name() , (char *)"behaviour") == 0) {
00303         L_value = (*L_fieldIt)->get_value() ;
00304         break ;
00305       }
00306     }
00307   }
00308 
00309   return (L_value);
00310 
00311 }
00312 
00313 int C_ScenarioControl::add_scenario
00314 
00315 (T_scenario_type           P_type,
00316  C_XmlData                *P_scen,
00317  T_pTrafficType            P_trafficType,
00318  int                      *P_nbOpen,
00319  bool                     *P_data_mesure,
00320  bool                      P_checkMsgRecv) {
00321 
00322   C_XmlData                        *L_data ;
00323   T_pXmlData_List                   L_subList ;  
00324   T_XmlData_List::iterator          L_subListIt ;
00325   char                             *L_value ;
00326 
00327   T_cmd_type                        L_cmd_type = E_NB_CMD_SCEN ;
00328   bool                              L_cmd_ok = false ;
00329   size_t                            L_nb_cmd ;
00330   int                               L_i ; 
00331   int                               L_ret = 0 ;
00332 
00333   T_CmdAction                       L_action_end_init ;
00334   C_CommandAction**                 L_action_end_init_table = NULL ;
00335   T_pC_Scenario                     L_current_scen = NULL ;
00336   C_ScenarioStats                  *L_current_stat = NULL ;
00337 
00338   unsigned int                      L_check_level = 0 ;
00339   T_CheckBehaviour                  L_check_behave = E_CHECK_BEHAVIOUR_WARNING ;
00340   bool                              L_selectline_added = false ;
00341 
00342   bool                              *L_add_map_inserted = NULL ;
00343   T_pTrafficType                     L_channel_usage = NULL ;
00344   int                                L_primary_channel_id = -1 ;
00345   int                                L_nb_channel ;
00346 
00347 
00348   char                              *L_behaviour_scen = NULL ;
00349 
00350 
00351   T_Controllers            L_controllers ;
00352 
00353   L_controllers.m_log = m_log ;
00354   L_controllers.m_scenario_control = this ;
00355   L_controllers.m_stat = C_GeneratorStats::instance() ;
00356   L_controllers.m_external_data = m_external_data ;
00357   L_controllers.m_check_mask      = m_check_level ;
00358   L_controllers.m_check_behaviour      = m_check_behaviour ;
00359   L_controllers.m_channel_ctrl = m_channel_ctrl ;
00360 
00361   C_CommandActionFactory    L_CommandActionFactory(&L_controllers) ;
00362 
00363 
00364   GEN_DEBUG(1, "C_ScenarioControl::add_scenario() start");
00365   (*P_nbOpen) = 0 ;
00366 
00367   if (m_config != NULL) {
00368     m_retrans_enabled = m_config -> get_retrans_enabled();
00369   }
00370 
00371   L_behaviour_scen = get_behaviour_scenario(P_scen) ;
00372   if (L_behaviour_scen != NULL) {
00373     if ((strcmp(L_behaviour_scen, (char*)"failed")  != 0) && 
00374         (strcmp(L_behaviour_scen, (char*)"success") != 0) && 
00375         (strcmp(L_behaviour_scen, (char*)"ignore") != 0) ) {
00376       GEN_ERROR(E_GEN_FATAL_ERROR, "Unknown behaviour scenario " << L_behaviour_scen);
00377       L_ret = -1 ;
00378       return (L_ret);
00379     }
00380   }
00381 
00382   L_nb_channel = m_channel_ctrl->nb_channel();
00383   ALLOC_TABLE(L_add_map_inserted,
00384               bool*,
00385               sizeof(bool),
00386               L_nb_channel);
00387   ALLOC_TABLE(L_channel_usage,
00388               T_pTrafficType,
00389               sizeof(T_TrafficType),
00390               L_nb_channel);
00391   for(L_i = 0 ; L_i < L_nb_channel; L_i++) {
00392     L_add_map_inserted[L_i] = false ;
00393     L_channel_usage[L_i] = E_TRAFFIC_UNKNOWN ;
00394   }
00395 
00396   switch (P_type) {
00397   case E_SCENARIO_TRAFFIC:
00398     if (m_config != NULL) {
00399       m_config->get_value(E_CFG_OPT_CHECK_LEVEL, &L_check_level);
00400       m_config->get_value(E_CFG_OPT_CHECK_BEHAVIOUR, 
00401                           (unsigned int*)&L_check_behave);
00402     }
00403     m_check_level = L_check_level ;
00404     m_check_behaviour = L_check_behave ;
00405     NEW_VAR(m_traffic_scen, 
00406             C_Scenario(this, m_channel_ctrl, 
00407                        m_external_data,
00408                        E_EXE_TRAFFIC_END,
00409                        L_behaviour_scen,
00410                        m_retrans_enabled,
00411                        L_check_level,
00412                        L_check_behave
00413                        ));
00414     L_current_scen = m_traffic_scen ;
00415     m_nb_scenario++;
00416     GEN_DEBUG(1, "C_ScenarioControl::add_scenario() E_SCENARIO_TRAFFIC ");
00417     break ;
00418 
00419   case E_SCENARIO_INIT:
00420     NEW_VAR(m_init_scen, C_Scenario(this, m_channel_ctrl, 
00421                                     m_external_data,
00422                                     E_EXE_INIT_END,
00423                                     L_behaviour_scen,
00424                                     m_retrans_enabled)) ;
00425 
00426     L_current_scen = m_init_scen ;
00427     m_nb_scenario++;
00428     GEN_DEBUG(1, "C_ScenarioControl::add_scenario() E_SCENARIO_INIT ");
00429     break ;
00430 
00431   case E_SCENARIO_DEFAULT:
00432     if (m_nb_default == m_max_default) {
00433       GEN_FATAL(E_GEN_FATAL_ERROR, "Maximum number of default scenario reached");
00434     }
00435     NEW_VAR(m_default_scen[m_nb_default], 
00436             C_Scenario(this, m_channel_ctrl, 
00437                        m_external_data,
00438                        E_EXE_DEFAULT_END,
00439                        L_behaviour_scen,
00440                        m_retrans_enabled));
00441     L_current_scen = m_default_scen[m_nb_default] ;
00442     GEN_DEBUG(1, "C_ScenarioControl::add_scenario() E_SCENARIO_DEFAULT ");
00443     m_nb_default ++ ;
00444     m_nb_scenario++;
00445     break ;
00446 
00447   case E_SCENARIO_ABORT:
00448     NEW_VAR(m_abort_scen, 
00449             C_Scenario(this, m_channel_ctrl, 
00450                        m_external_data,
00451                        E_EXE_ABORT_END,
00452                        L_behaviour_scen,
00453                        m_retrans_enabled));
00454     L_current_scen = m_abort_scen ;
00455     m_nb_scenario++;
00456     GEN_DEBUG(1, "C_ScenarioControl::add_scenario() E_SCENARIO_ABORT ");
00457     break ;
00458   }
00459 
00460   GEN_DEBUG(1, "C_ScenarioControl::add_scenario() nb scenario: " << m_nb_scenario);
00461 
00462   *P_trafficType = E_TRAFFIC_UNKNOWN;
00463 
00464   L_subList = P_scen->get_sub_data () ;
00465   if (!L_subList->empty()) {
00466     
00467     L_current_scen->set_size(L_subList->size()+1) ;
00468     
00469     for(L_subListIt  = L_subList->begin() ;
00470         L_subListIt != L_subList->end() ;
00471         L_subListIt++) {
00472 
00473       L_cmd_ok = false ;
00474       L_data = *L_subListIt ;
00475       L_value = L_data->get_name() ;
00476 
00477       for(L_i = 0;
00478           L_i < (int)E_NB_CMD_SCEN ;
00479           L_i++) {
00480         
00481         GEN_DEBUG(1, "C_ScenarioControl::add_scenario() command_name_table[" << 
00482                         L_i << "] is " << command_name_table[L_i]);
00483         GEN_DEBUG(1, "C_ScenarioControl::add_scenario() L_value is " << L_value);
00484         if (strcmp(L_value, command_name_table[L_i])==0) {
00485           L_cmd_ok = true ;
00486           L_cmd_type = (T_cmd_type) L_i ;
00487           break ;
00488         }
00489       }
00490 
00491       if (L_cmd_ok == true) {
00492         L_ret = add_command(L_cmd_type, 
00493                             L_data,
00494                             P_trafficType,
00495                             L_current_scen,
00496                             P_nbOpen,
00497                             P_data_mesure,
00498                             L_add_map_inserted,
00499                             &L_selectline_added,
00500                             L_channel_usage,
00501                             &L_primary_channel_id,
00502                             P_checkMsgRecv);
00503       } else {
00504         GEN_ERROR(E_GEN_FATAL_ERROR, "Unknown command " << L_value);
00505         L_ret = -1 ;
00506         break ;
00507       }
00508      
00509       if (L_ret == -1) break ;
00510 
00511     }
00512   }
00513 
00514   if (L_ret != -1) {
00515     // add final scenario end
00516     L_nb_cmd = L_current_scen->add_cmd(E_CMD_SCEN_END) ;
00517 
00518     switch (P_type) {
00519     case E_SCENARIO_TRAFFIC:
00520       m_traffic_type = *P_trafficType ;
00521       break ;
00522     case E_SCENARIO_INIT:
00523       m_init_type = *P_trafficType;
00524 
00525       L_action_end_init = no_cmd_action ;
00526       // add init done action at the end of the command
00527       L_action_end_init.m_type        = E_ACTION_SCEN_INTERNAL_INIT_DONE ;
00528       
00529       ALLOC_TABLE(L_action_end_init_table, 
00530                   C_CommandAction**, sizeof(C_CommandAction*),1);
00531       L_action_end_init_table[0] 
00532         = L_CommandActionFactory.create(L_action_end_init);
00533       L_nb_cmd = L_current_scen
00534         ->define_post_actions(1, (C_CommandAction**)L_action_end_init_table);
00535       break ;
00536 
00537     case E_SCENARIO_DEFAULT:
00538       if (*P_trafficType != E_TRAFFIC_SERVER) {
00539         L_ret = -1 ;
00540         GEN_ERROR(E_GEN_FATAL_ERROR, "Default scenario must be server");
00541       }
00542 
00543       if (L_nb_cmd > 3) { 
00544         L_ret = -1 ;
00545         GEN_ERROR(E_GEN_FATAL_ERROR, "Default scenario must have two commands");
00546       }
00547       break ;
00548 
00549     case E_SCENARIO_ABORT:
00550       if (*P_trafficType != E_TRAFFIC_CLIENT) {
00551         L_ret = -1 ;
00552         GEN_ERROR(E_GEN_FATAL_ERROR, "Abort scenario must be client");
00553       }
00554       break ;
00555     }
00556   }
00557 
00558   FREE_TABLE(L_add_map_inserted);
00559   
00560   if (L_ret != -1) {
00561     L_ret = check_channel_usage (L_channel_usage, L_primary_channel_id, L_nb_channel);
00562   }
00563   FREE_TABLE(L_channel_usage);
00564 
00565 
00566   if (m_config->get_display_scenario_stat() == true) {
00567     NEW_VAR(L_current_stat, C_ScenarioStats(L_current_scen));
00568   }
00569 
00570   GEN_DEBUG(1, "C_ScenarioControl::add_scenario() end");
00571 
00572   return (L_ret);
00573   
00574 }
00575 
00576 int C_ScenarioControl::add_command (T_cmd_type                P_cmd_type, 
00577                                     C_XmlData                *P_data,
00578                                     T_pTrafficType            P_trafficType,
00579                                     T_pC_Scenario             P_scen,
00580                                     int                      *P_nbOpen,
00581                                     bool                     *P_data_mesure,
00582                                     bool                     *P_map_inserted,
00583                                     bool                     *P_selectLine_added,
00584                                     T_pTrafficType            P_channelTrafficTable,
00585                                     int                      *P_channel_primary_id,
00586                                     bool                      P_checkMsgRecv) {
00587 
00588   
00589   int                            L_channel_id        = -1       ;
00590 
00591   char                          *L_value                        ;
00592   int                            L_ret               = 0        ;
00593   C_CommandAction**             L_CommandActionTable    = NULL     ;
00594   int                            L_nb_action         = 0        ;
00595   // T_CmdActionList                L_cmdActionList                ;
00596   T_CommandActionLst             L_commandActionList            ;
00597 
00598   bool                           L_map_inserted      = false    ;
00599 
00600   bool                           L_pre_action        = false    ;
00601   bool                           L_cmd_inserted      = false    ;
00602   bool                           L_pre_action_done   = false    ;
00603 
00604 
00605   T_pXmlData_List                L_subList           = NULL     ;
00606   T_XmlData_List::iterator       L_listIt                       ;
00607   C_XmlData                     *L_msgData                      ;
00608   char                          *L_currentName                  ;
00609   C_ProtocolFrame               *L_protocol          = NULL     ;
00610   T_InstanceDataList             L_instance_list                ;
00611   int                            L_nb_body_value     = -1       ;
00612 
00613   int                            L_msg_id            = -1       ;
00614 
00615   char                          *L_value_retrans     = NULL     ;
00616   unsigned long                  L_retrans_delay     = 0        ;
00617   char                          *L_end_str                      ;
00618 
00619 
00620   T_Controllers            L_controllers ;
00621 
00622   L_controllers.m_log = m_log ;
00623   L_controllers.m_scenario_control = this ;
00624   L_controllers.m_stat = C_GeneratorStats::instance() ;
00625   L_controllers.m_external_data = m_external_data ;
00626   L_controllers.m_check_mask      = m_check_level ;
00627   L_controllers.m_check_behaviour      = m_check_behaviour ;
00628   L_controllers.m_channel_ctrl = m_channel_ctrl ;
00629 
00630   C_CommandActionFactory    L_CommandActionFactory(&L_controllers) ;
00631 
00632 
00633   GEN_DEBUG(1, "C_ScenarioControl::add_command() start");
00634 
00635   // L_cmdActionList.clear() ;
00636   L_commandActionList.clear() ;
00637 
00638   switch (P_cmd_type) {
00639 
00640   case E_CMD_SCEN_RECEIVE:
00641     if (P_checkMsgRecv == true) {
00642       T_CmdAction L_action_check ;
00643       L_action_check = no_cmd_action ;
00644       L_action_check.m_type = E_ACTION_SCEN_CHECK_ALL_MSG ;
00645       L_commandActionList.push_back
00646         (L_CommandActionFactory.create(L_action_check));
00647       L_nb_action++ ;
00648       GEN_DEBUG(1, "C_ScenarioControl::add_command() E_CMD_SCEN_RECEIVE");
00649     }
00650   case E_CMD_SCEN_SEND: {
00651           
00652     C_MessageFrame           *L_msg = NULL ;
00653     char                     *L_msg_name = NULL ;
00654     char                      L_no_msg_name [1] ;
00655 
00656     
00657     //    L_transid = -1 ;
00658     L_no_msg_name [0] = '\0' ;
00659     L_value = P_data->find_value((char*)"channel");
00660     if (L_value != NULL) {
00661       L_channel_id = m_channel_ctrl->get_channel_id(L_value);
00662       if (L_channel_id  == ERROR_CHANNEL_UNKNOWN) {
00663         GEN_ERROR(E_GEN_FATAL_ERROR, 
00664                   "Chanel [" << L_value << "] unknowm for the send command");
00665         L_ret = -1 ;
00666         break ;
00667       }
00668       L_map_inserted = (P_map_inserted[L_channel_id] == true);
00669       if ((*P_channel_primary_id) == -1) {
00670         *P_channel_primary_id = L_channel_id ;
00671       }
00672       if (P_channelTrafficTable[L_channel_id] == E_TRAFFIC_UNKNOWN) {
00673         switch(P_cmd_type) {
00674         case E_CMD_SCEN_SEND:
00675           P_channelTrafficTable[L_channel_id]=E_TRAFFIC_CLIENT;
00676           break ;
00677         case E_CMD_SCEN_RECEIVE:
00678           P_channelTrafficTable[L_channel_id]=E_TRAFFIC_SERVER;
00679           break;
00680         default:
00681           break;
00682         }
00683       }
00684     } else {
00685       GEN_ERROR(E_GEN_FATAL_ERROR, "Channel not specified for command");
00686       L_ret = -1 ;
00687       break ;
00688     }
00689     
00690     L_protocol = m_channel_ctrl->get_channel_protocol(L_channel_id) ;
00691 
00692     L_value_retrans = P_data->find_value((char*)"retrans");
00693     if (L_value_retrans != NULL) {
00694       L_retrans_delay = strtoul_f (L_value_retrans, &L_end_str, 10);
00695       if (L_end_str[0] != '\0') {
00696         GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
00697                   << L_value_retrans << "] not a number");
00698         L_ret = -1 ;
00699         break;
00700       }
00701     }
00702 
00703     L_subList = P_data -> get_sub_data() ;
00704     for(L_listIt  = L_subList->begin() ;
00705         L_listIt != L_subList->end() ;
00706         L_listIt++) {
00707       
00708       L_msgData = *L_listIt ;
00709       L_currentName = L_msgData -> get_name () ;
00710 
00711       L_msg_name = (L_protocol->message_name() == NULL) 
00712         ? L_no_msg_name : L_protocol->message_name() ;
00713 
00714       GEN_DEBUG(1, "C_ScenarioControl::add_command() msgData Name is "
00715                     << L_currentName );
00716 
00717       if (    (strcmp(L_currentName, (char*)"CDATA") == 0) 
00718            || (strcmp(L_currentName, L_msg_name) == 0) ) {
00719 
00720         L_msg = L_protocol -> create_new_message ((void*)L_msgData,
00721                                                   &L_instance_list,
00722                                                   &L_nb_body_value) ;
00723         if (L_msg == NULL) {
00724           GEN_ERROR(E_GEN_FATAL_ERROR, 
00725                     "Error while creating message");
00726           L_ret = -1 ;
00727           break ;
00728         }
00729 
00730         L_msg_id = L_msg->get_id_message() ;
00731 
00732         if ( L_msg_id == -1) {
00733           GEN_ERROR(E_GEN_FATAL_ERROR, 
00734                     "Error while creating message[" 
00735                     << L_msg_id 
00736                     << "]");
00737           L_ret = -1 ;
00738           break ;
00739         }
00740 
00741         // finally add message on the scenario sequence
00742         if ((L_msg != NULL) && (L_channel_id != -1)) {
00743           (void) P_scen
00744             ->add_cmd (P_cmd_type, 
00745                        L_channel_id,
00746                        L_msg,
00747                        0,
00748                        NULL,
00749                        L_retrans_delay);
00750           
00751           L_cmd_inserted = true ;
00752 
00753           if (L_retrans_delay > 0 ) {
00754             m_retrans_delay_values->insert(T_retransDelayValuesSet::value_type(L_retrans_delay));
00755           }
00756 
00757           if (*P_trafficType == E_TRAFFIC_UNKNOWN) {
00758             switch (P_cmd_type) {
00759             case E_CMD_SCEN_RECEIVE:
00760               *P_trafficType=E_TRAFFIC_SERVER;
00761               break;
00762             case E_CMD_SCEN_SEND:
00763               *P_trafficType=E_TRAFFIC_CLIENT;
00764               break;
00765             default:
00766               break;
00767             }
00768           }
00769         }
00770 
00771       } else if (strcmp(L_currentName, (char*) "action") == 0) {
00772 
00773         if (L_cmd_inserted == false) { 
00774           L_pre_action = true ; 
00775         // } else {
00776         //   L_post_action = true ;
00777         }
00778         
00779       } else {
00780         GEN_ERROR(E_GEN_FATAL_ERROR, 
00781               "Unsupported message [" << L_currentName << "]");
00782         L_ret = -1 ;
00783       }
00784       if (L_ret == -1) break;
00785     }
00786   }
00787 
00788     break ;
00789     
00790   case E_CMD_SCEN_WAIT:
00791 
00792     L_value = P_data->find_value((char*)"value");
00793     if (L_value == NULL) {
00794       GEN_ERROR(E_GEN_FATAL_ERROR, "value is mandatory for wait-ms command");
00795       L_ret = -1 ;
00796     }
00797     if (L_ret != -1) {
00798       unsigned long  L_value_ms ;
00799       char          *L_end_str = NULL ;
00800       L_value_ms = strtoul_f (L_value, &L_end_str, 10);
00801       if (L_end_str[0] != '\0') {
00802         GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
00803               << L_value << "] not a number");
00804         L_ret = -1 ;
00805       } else {
00806         (void) P_scen->add_cmd(P_cmd_type, L_value_ms);
00807         // update the number of wait values
00808         m_wait_values->insert(T_waitValuesSet::value_type(L_value_ms));
00809       }
00810     }
00811     break ;
00812     
00813   default:
00814     break ;
00815     
00816   }
00817 
00818   if (L_ret != -1) {
00819     switch (P_cmd_type) {
00820 
00821     case E_CMD_SCEN_RECEIVE:
00822     case E_CMD_SCEN_SEND: {
00823 
00824 
00825       for(L_listIt  = L_subList->begin() ;
00826           L_listIt != L_subList->end() ;
00827           L_listIt++) {
00828         
00829         L_msgData = *L_listIt ;
00830         L_currentName = L_msgData -> get_name () ;
00831         
00832         if (strcmp(L_currentName, (char*) "action") == 0) {
00833 
00834           // action decoding 
00835           L_ret = add_actions(L_msgData,
00836                               L_instance_list,
00837                               L_protocol,
00838                               P_scen,
00839                               P_nbOpen,
00840                               P_data_mesure,
00841                               P_map_inserted,
00842                               P_selectLine_added,
00843                               L_channel_id,
00844                               L_pre_action,
00845                               L_pre_action_done,
00846                               //                              L_CmdActionTable,
00847                               L_nb_action,
00848                               //L_cmdActionList,
00849                               L_map_inserted,
00850                               L_nb_body_value,
00851                               L_msg_id,
00852                               L_CommandActionFactory,
00853                               L_commandActionList,
00854                               L_CommandActionTable
00855                               );
00856           if (L_ret == -1) break ;
00857         }
00858       }
00859 
00860 
00861       if (L_map_inserted == false) {
00862         // no action on the scenario => add post action with add in call map
00863 
00864         T_CmdAction L_action_map ;
00865         C_CommandAction** L_action_map_table ;
00866         ALLOC_TABLE(L_action_map_table, C_CommandAction**, sizeof(C_CommandAction*),1);
00867         L_action_map = no_cmd_action ;
00868         L_action_map.m_type = E_ACTION_SCEN_ADD_IN_CALL_MAP ;
00869         L_action_map.m_id = L_channel_id ;
00870         L_action_map_table[0] = L_CommandActionFactory.create(L_action_map) ;
00871 
00872         P_scen -> define_post_actions(1, (C_CommandAction**)L_action_map_table);
00873         L_map_inserted = true ;
00874       }
00875 
00876     }
00877     break ;
00878 
00879     default:
00880       break ;
00881 
00882     }
00883   }
00884 
00885   GEN_DEBUG(1, "C_ScenarioControl::add_command() end");
00886   
00887   if (L_map_inserted == true) { P_map_inserted[L_channel_id] = true ; }
00888 
00889   return (L_ret);
00890   
00891 } // add_command
00892 
00893 int C_ScenarioControl::add_actions (C_XmlData                *P_msgData,
00894                                     T_InstanceDataList&       P_instance_list,
00895                                     C_ProtocolFrame          *P_protocol,
00896                                     T_pC_Scenario             P_scen,
00897                                     int                      *P_nbOpen,
00898                                     bool                     *P_data_mesure,
00899                                     bool                     *P_map_inserted,
00900                                     bool                     *P_selectLine_added,
00901 
00902                                     int&                      P_channel_id,
00903                                     bool&                     P_pre_action,
00904                                     bool&                     P_pre_action_done,
00905                                     //                              T_pCmdAction&             P_CmdActionTable,
00906                                     int&                      P_nb_action,
00907                                     //          T_CmdActionList&          P_cmdActionList,
00908                                     bool&                     P_inserted,
00909                                     int                       P_nb_value,
00910                                     int                       P_msg_id,
00911                                     C_CommandActionFactory&   P_CmdActionFactory,
00912                                     T_CommandActionLst&       P_CommandActionLst,
00913                                     C_CommandAction**&         P_CommandActionTable
00914                                     ) {
00915 
00916   int                       L_ret                   = 0      ;
00917   int                       L_i                              ;
00918   T_pXmlData_List           L_actionList                     ;  
00919   T_XmlData_List::iterator  L_actionListIt                   ;
00920   char                     *L_actionName                     ;
00921   char                     *L_actionArg, *L_actionArg2       ;
00922   C_XmlData                *L_action                         ;
00923   bool                      L_actionFound                    ;
00924   T_action_type             L_actionType  = E_NB_ACTION_SCEN ;
00925   T_pCmdAction              L_actionData             = NULL  ;
00926   bool                      L_memoryRefFound         = false ;
00927 
00928 
00929   bool                      L_entityFieldFound       = false ;
00930   T_CmdAction               L_select_line_action             ;
00931   int                       L_field_id                       ;
00932   char                     *L_end_str                        ;
00933   bool                      L_begin_present          = false ;
00934   int                       L_position                       ;
00935 
00936 
00937   T_pXmlData_List           L_reg_action_list        = NULL  ;  
00938   T_XmlData_List::iterator  L_reg_action_it                  ;
00939   C_XmlData                *L_regexp                 = NULL  ;
00940   T_pActionRegExpStr        L_regexp_data            = NULL  ;
00941   C_RegExp                 *L_cRegExp                = NULL  ;
00942   int                       L_error_comp             = 0     ;
00943   int                       L_value_set_bit                  ;
00944 
00945   GEN_DEBUG(1, "C_ScenarioControl::add_actions() start");
00946 
00947   L_actionList = P_msgData -> get_sub_data() ;
00948   
00949   if (L_actionList != NULL) {
00950     for (L_actionListIt  = L_actionList->begin();
00951          L_actionListIt != L_actionList->end();
00952          L_actionListIt++) {
00953       L_action = *L_actionListIt ;
00954 
00955       L_actionName = L_action -> get_name() ;
00956       L_actionFound = false ;
00957       L_begin_present=false ;
00958       for(L_i=0;
00959           L_i< (T_action_type)E_NB_ACTION_SCEN ;
00960           L_i++) {
00961         
00962         if (strcmp(L_actionName, action_name_table[L_i])==0) {
00963           L_actionType=(T_action_type)L_i ;
00964           L_actionFound = true ;
00965           break ;
00966         }
00967       }
00968       if (L_actionFound == true) {
00969 
00970         ALLOC_VAR(L_actionData, T_pCmdAction, sizeof(T_CmdAction));
00971         *L_actionData = no_cmd_action ;
00972         L_actionData -> m_type            = L_actionType ;
00973         L_actionData -> m_instance_id     = 0            ;
00974                 
00975         switch (L_actionType) {
00976           
00977         case E_ACTION_SCEN_OPEN :
00978           L_actionArg = L_action -> find_value((char*) "args");
00979           if (L_actionArg == NULL) {
00980             GEN_ERROR(E_GEN_FATAL_ERROR, "args value mandatory for action ["
00981                       << L_actionName << "]");
00982             L_ret = -1 ;
00983             break ; 
00984           }
00985 
00986           if (strlen(L_actionArg) > 0 ) {
00987             L_actionData -> m_args = L_actionArg ;
00988           }
00989 
00990           (*P_nbOpen) ++ ;
00991           break ;
00992 
00993         case E_ACTION_SCEN_SET_NEW_SESSION_ID :
00994         case E_ACTION_SCEN_MEMORY_STORE :
00995         case E_ACTION_SCEN_MEMORY_RESTORE : 
00996           L_actionArg = L_action -> find_value((char*) "name");
00997           if (L_actionArg == NULL) {
00998             GEN_ERROR(E_GEN_FATAL_ERROR, "name value mandatory for action ["
00999                       << L_actionName << "]");
01000             L_ret = -1 ;
01001             break ; 
01002           }
01003 
01004 
01005           L_actionArg2 = L_action -> find_value((char*) "entity");
01006           if (L_actionArg2 == NULL) {
01007             GEN_ERROR(E_GEN_FATAL_ERROR, "entity value mandatory for action ["
01008                       << L_actionName << "]");
01009             L_ret = -1 ;
01010             break ; 
01011           }
01012           L_memoryRefFound = false ;
01013           
01014           L_actionData->m_id 
01015             = P_protocol->find_field (L_actionArg2) ;
01016           if (L_actionData->m_id != -1) {
01017             L_memoryRefFound = true ;
01018           }
01019 
01020           if (L_memoryRefFound == true) {
01021             L_actionData->m_mem_id = 
01022               add_memory (L_actionArg);
01023           } else {
01024             GEN_ERROR(E_GEN_FATAL_ERROR, "Unable to find definition for ["
01025                       << L_actionArg2 << "]");
01026             L_ret = -1 ;
01027             break;
01028           }
01029           
01030           if (P_protocol->find_present_session (P_msg_id,L_actionData->m_id) == false) {
01031             GEN_ERROR(E_GEN_FATAL_ERROR, "Unable to present definition for ["
01032                       << L_actionArg2 << "] in body of message");
01033             L_ret = -1 ;
01034             break;
01035           }
01036 
01037 
01038           L_actionArg = L_action -> find_value((char*) "instance");
01039           if (L_actionArg != NULL) {
01040             T_InstanceDataList::iterator L_instance_it ;
01041             bool L_instance_found = false ;
01042             for (L_instance_it = P_instance_list.begin();
01043                  L_instance_it != P_instance_list.end();
01044                  L_instance_it++) {
01045               if (strcmp(L_actionArg, L_instance_it->m_instance_name)==0) {
01046                 L_actionData->m_instance_id = L_instance_it->m_instance_id;
01047                 L_instance_found = true ;
01048                 break ;
01049               }
01050             }
01051             if (L_instance_found == false) {
01052               GEN_ERROR(E_GEN_FATAL_ERROR, "Unable to find instance name ["
01053                         << L_actionArg << "]");
01054               L_ret = -1 ;
01055               break ;
01056             } else {
01057               if (L_instance_it->m_id != L_actionData->m_id) {
01058                 GEN_ERROR(E_GEN_FATAL_ERROR, "Bad instance name ["
01059                           << L_actionArg << "]");
01060                 L_ret = -1 ;
01061                 break ;
01062               }
01063             }
01064           }
01065           
01066           L_actionArg = L_action -> find_value((char*) "sub-entity");
01067           if (L_actionArg != NULL) {
01068             
01069             L_actionData->m_sub_id 
01070               = P_protocol->find_field (L_actionArg) ;
01071             if (L_actionData->m_sub_id == -1) {
01072               GEN_ERROR(E_GEN_FATAL_ERROR,
01073                         "No definition found for ["
01074                         << L_actionArg << "]");
01075               L_ret = -1 ;
01076               break ;
01077             }
01078             // std::cerr << "***** " <<L_actionData->m_sub_id << std::endl;  
01079             // id correct => > header+body_value
01080             //            L_actionData->m_sub_id = ;
01081           } // else id >header+body_value => error
01082 
01083           if (P_protocol->check_sub_entity_needed(L_actionData->m_id) == true) {
01084 
01085             if (L_actionData->m_sub_id == -1) {
01086               GEN_ERROR(E_GEN_FATAL_ERROR,
01087                         "sub entity needed for  ["
01088                         << L_actionArg2 
01089                         << "]");
01090               L_ret = -1 ;
01091               break ;
01092             }
01093           }
01094 
01095           
01096           // TO DO 
01097           L_actionArg = L_action -> find_value((char*) "begin");
01098           if (L_actionArg != NULL) {
01099 
01100             // check type field == STRING || BINARY
01101             if (P_protocol->get_field_type(L_actionData->m_id, 
01102                                            L_actionData->m_sub_id)
01103                 != E_TYPE_STRING ) {
01104               GEN_ERROR(E_GEN_FATAL_ERROR,
01105                         "Type field of entity ["
01106                         << L_actionArg2 
01107                         << "] is not STRING");
01108               L_ret = -1 ;
01109               break ;
01110             }
01111 
01112             unsigned long  L_begin ;
01113             char          *L_end_str = NULL ;
01114             L_begin = strtoul_f (L_actionArg, &L_end_str, 10);
01115             if (L_end_str[0] != '\0') {
01116               GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
01117                         << L_actionArg << "] not a number");
01118               L_ret = -1 ;
01119               break ;
01120             } else {
01121               L_actionData->m_begin = (int)L_begin ;
01122               L_begin_present = true ;
01123             }
01124           }
01125           
01126           L_actionArg = L_action -> find_value((char*) "end");
01127           if (L_actionArg != NULL) {
01128 
01129             if (L_begin_present == true) {
01130               unsigned long  L_end ;
01131               char          *L_end_str = NULL ;
01132               L_end = strtoul_f (L_actionArg, &L_end_str, 10);
01133               if (L_end_str[0] != '\0') {
01134                 GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
01135                           << L_actionArg << "] not a number");
01136                 L_ret = -1 ;
01137               } else {
01138                 if ((int)L_end > L_actionData->m_begin) {
01139                   L_actionData->m_size = L_end - L_actionData->m_begin ;
01140                 } else {
01141                   GEN_ERROR(E_GEN_FATAL_ERROR, "End before begin index");
01142                   L_ret = -1 ;
01143                 }
01144               }
01145               
01146             } else {
01147               GEN_ERROR(E_GEN_FATAL_ERROR, "End index defined without begin index");
01148               L_ret = -1 ;
01149             }
01150           }
01151           
01152           // analyze of regexp
01153           L_reg_action_list = L_action->get_sub_data() ;
01154           for(L_reg_action_it  = L_reg_action_list->begin() ;
01155               L_reg_action_it != L_reg_action_list->end() ;
01156               L_reg_action_it++) {
01157 
01158             L_regexp = *L_reg_action_it ;
01159             if (strcmp(L_regexp->get_name(), (char*)"regexp") == 0) {
01160   
01161               NEW_VAR(L_regexp_data, T_ActionRegExpStr());  
01162 
01163               L_regexp_data->m_expr = L_regexp->find_value((char*)"expr") ;
01164 
01165               if (L_regexp_data->m_expr == NULL ) {
01166                 GEN_ERROR(E_GEN_FATAL_ERROR,
01167                           "no expression defined for this regexp");
01168                 L_ret = -1;
01169                 DELETE_VAR(L_regexp_data);
01170               } 
01171               
01172               if (L_ret != -1) {
01173                 // default values ?
01174                 L_regexp_data->m_nb_match = (L_regexp->find_value((char*)"nbexpr") == NULL) ?
01175                   1 : atoi(L_regexp->find_value((char*)"nbexpr")) ;
01176                 L_regexp_data->m_sub_match = (L_regexp->find_value((char*)"subexpr") == NULL) ? 
01177                   0 : atoi(L_regexp->find_value((char*)"subexpr")) ;
01178                 L_regexp_data->m_line = (L_regexp->find_value((char*)"line") == NULL) ?
01179                   -1 : atoi(L_regexp->find_value((char*)"line")) ;
01180               
01181 
01182                 // std::cerr << " L_regexp_data->m_expr " << L_regexp_data->m_expr
01183                 //          << " L_regexp_data->m_nb_match " << L_regexp_data->m_nb_match
01184                 //          << " L_regexp_data->m_sub_match " << L_regexp_data->m_sub_match
01185                 //          << " L_regexp_data->m_line " << L_regexp_data->m_line 
01186                 //          << std::endl;
01187               
01188                 NEW_VAR(L_cRegExp, C_RegExp(L_regexp_data->m_expr, 
01189                                             &L_error_comp,
01190                                             L_regexp_data->m_nb_match,
01191                                             L_regexp_data->m_sub_match,
01192                                             L_regexp_data->m_line));
01193               
01194                 if (L_error_comp == 0) {
01195                   L_actionData->m_regexp_data = L_cRegExp ;
01196                 } else {
01197                   GEN_ERROR(E_GEN_FATAL_ERROR, 
01198                             "Bad regular expression ["
01199                             << L_regexp_data->m_expr 
01200                             << "] for action ["
01201                             << L_actionName 
01202                             << "]");
01203                   L_ret = -1 ;
01204                 }
01205               } // if (L_ret != -1)
01206               break;
01207             } // if (strcmp(L_regexp->get_name(), (char*)"regexp") == 0)
01208           }
01209           
01210         
01211           break ;
01212         
01213         case E_ACTION_SCEN_START_TIMER :
01214           break ;
01215 
01216         case E_ACTION_SCEN_STOP_TIMER :
01217           (*P_data_mesure) = true ;
01218           break ;
01219 
01220         case E_ACTION_SCEN_CLOSE :
01221           break ;
01222 
01223         case E_ACTION_SCEN_SET_VALUE :
01224           
01225           L_actionArg = L_action -> find_value((char*) "name");
01226           if (L_actionArg == NULL) {
01227             GEN_ERROR(E_GEN_FATAL_ERROR, "name value mandatory for action ["
01228                       << L_actionName << "]");
01229             L_ret = -1 ;
01230             break ; 
01231           } 
01232           
01233           L_actionArg2 = L_action -> find_value((char*) "format");
01234           if (L_actionArg2 == NULL) {
01235             GEN_ERROR(E_GEN_FATAL_ERROR, 
01236                       "format value mandatory for action ["
01237                       << L_actionName << "]");
01238             L_ret = -1 ;
01239             break ; 
01240           } 
01241           
01242           
01243           L_actionData->m_id 
01244             = P_protocol->find_field (L_actionArg) ;
01245           if (L_actionData->m_id == -1) {
01246             GEN_ERROR(E_GEN_FATAL_ERROR,
01247                       "No definition found for ["
01248                       << L_actionArg << "]");
01249             L_ret = -1 ;
01250             break ;
01251           }
01252           
01253           L_ret = add_expression(L_actionArg2, P_protocol,
01254                                  &L_actionData->m_string_expr) ;
01255           
01256           
01257           if (L_ret == -1) {
01258             GEN_ERROR(E_GEN_FATAL_ERROR,
01259                       "Format error for ["
01260                       << L_actionArg2 << "]");
01261             break ;
01262           }
01263           
01264           if (L_ret != -1) {
01265             L_actionArg2 = L_action -> find_value((char*) "fill-pattern");
01266             if (L_actionArg2 != NULL) {
01267               if ((strlen(L_actionArg2)>2) 
01268                   && (L_actionArg2[0] == '0') 
01269                   && (L_actionArg2[1] == 'x')) { // hexa buffer value
01270                 
01271                 char  *L_ptr = L_actionArg2 + 2 ;
01272                 size_t L_res_size ;
01273                 
01274                 L_actionData -> m_pattern 
01275                   = convert_hexa_char_to_bin(L_ptr, &L_res_size);
01276                 
01277                 if (L_actionData -> m_pattern  == NULL ) {
01278                   GEN_ERROR(E_GEN_FATAL_ERROR, 
01279                             "Bad buffer size for hexadecimal buffer ["
01280                             << L_actionArg2 << "]" ); 
01281                   L_ret = -1 ;
01282                   break;
01283                 } else {
01284                   L_actionData -> m_pattern_size = L_res_size ;   
01285                 }
01286                 
01287               } else { // direct string value
01288                 L_actionData -> m_pattern_size = strlen(L_actionArg2) ;
01289                 L_actionData -> m_pattern = (unsigned char*)L_actionArg2 ;                       
01290               }
01291             } 
01292           }
01293 
01294           if (L_ret != -1) {
01295             unsigned long  L_size ;
01296             char          *L_end_str = NULL ;
01297             L_actionArg2 = L_action -> find_value((char*) "fill-size");
01298             if (L_actionArg2 != NULL) {
01299               L_size = strtoul_f (L_actionArg2, &L_end_str, 10);
01300               if (L_end_str[0] != '\0') {
01301                 GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
01302                           << L_actionArg2 << "] not a number");
01303                 L_ret = -1 ;
01304                 break ;
01305               } else {
01306                 L_actionData->m_size = (int)L_size ;
01307               }
01308             } 
01309           }
01310 
01311           if (L_ret != -1) {
01312             L_actionArg2 = L_action -> find_value((char*)"method");
01313             if (L_actionArg2 != NULL) {
01314               L_actionData->m_external_method = 
01315                 P_protocol->find_method_extern(L_actionArg2);
01316               if (L_actionData->m_external_method == NULL) {
01317                 GEN_ERROR(E_GEN_FATAL_ERROR,
01318                           "No method extern found for ["
01319                           << L_actionArg2 << "]");
01320                 L_ret = -1 ;
01321                 break ;
01322               } else {
01323                 L_actionData->m_type =  E_ACTION_SCEN_SET_VALUE_METHOD_EXTERN ;
01324               }
01325             } 
01326           }
01327 
01328           L_ret = check_expression (L_actionData, P_protocol) ;
01329           if (L_ret == -1) {
01330             GEN_ERROR(E_GEN_FATAL_ERROR,
01331                       "Expression error for ["
01332                       << L_actionArg2 << "]");
01333             break ;
01334           }
01335           break ;
01336           
01337         case E_ACTION_SCEN_INC_COUNTER:
01338           L_actionArg = L_action -> find_value((char*) "name");
01339           if (L_actionArg == NULL) {
01340             GEN_ERROR(E_GEN_FATAL_ERROR, "name value mandatory for action ["
01341                       << L_actionName << "]");
01342             L_ret = -1 ;
01343             break ; 
01344           } else {
01345             L_actionData -> m_id 
01346               = get_counter_id (L_actionArg);
01347             if (L_actionData->m_id == -1) {
01348               GEN_ERROR(E_GEN_FATAL_ERROR,
01349                         "Counter ["
01350                         << L_actionArg << "] not found");
01351               L_ret = -1 ;
01352               break ;
01353             }
01354           }
01355           break ;
01356           
01357         case E_ACTION_SCEN_CHECK_PRESENCE:
01358           L_actionArg = L_action -> find_value((char*) "name");
01359           if (L_actionArg == NULL) {
01360             GEN_ERROR(E_GEN_FATAL_ERROR, "name value mandatory for action ["
01361                       << L_actionName << "]");
01362             L_ret = -1 ;
01363             break ; 
01364           } 
01365           L_actionArg2 = L_action -> find_value((char*) "behaviour");
01366           if (L_actionArg2 == NULL) {
01367             GEN_ERROR(E_GEN_FATAL_ERROR, 
01368                       "behaviour value mandatory for action ["
01369                       << L_actionName << "]");
01370             L_ret = -1 ;
01371             break ; 
01372           } 
01373           
01374           L_actionData->m_id 
01375             = P_protocol->find_field (L_actionArg) ;
01376           if (L_actionData->m_id == -1) {
01377             GEN_ERROR(E_GEN_FATAL_ERROR,
01378                       "No definition found for ["
01379                       << L_actionArg << "]");
01380             L_ret = -1 ;
01381             break ;
01382           }
01383 
01384           L_actionArg = L_action -> find_value((char*) "instance");
01385           if (L_actionArg != NULL) {
01386             T_InstanceDataList::iterator L_instance_it ;
01387             bool L_instance_found = false ;
01388             for (L_instance_it = P_instance_list.begin();
01389                  L_instance_it != P_instance_list.end();
01390                  L_instance_it++) {
01391               if (strcmp(L_actionArg, L_instance_it->m_instance_name)==0) {
01392                 L_actionData->m_instance_id = L_instance_it->m_instance_id;
01393                 L_instance_found = true ;
01394                 break ;
01395               }
01396             }
01397             if (L_instance_found == false) {
01398               GEN_ERROR(E_GEN_FATAL_ERROR, "Unable to find instance name ["
01399                         << L_actionArg << "]");
01400               L_ret = -1 ;
01401               break ;
01402             } else {
01403               if (L_instance_it->m_id != L_actionData->m_id) {
01404                 GEN_ERROR(E_GEN_FATAL_ERROR, "Bad instance name ["
01405                           << L_actionArg << "]");
01406                 L_ret = -1 ;
01407                 break ;
01408               }
01409             }
01410           }
01411 
01412 
01413           // decode behaviour
01414           if (strcmp (L_actionArg2, (char*)"warning") == 0) {
01415             L_actionData->m_check_behaviour = E_CHECK_BEHAVIOUR_WARNING ;
01416           } else if (strcmp (L_actionArg2, (char*)"error") == 0) {
01417             L_actionData->m_check_behaviour = E_CHECK_BEHAVIOUR_ERROR ;
01418           } else if (strcmp (L_actionArg2, (char*)"abort") == 0) {
01419             L_actionData->m_check_behaviour = E_CHECK_BEHAVIOUR_ABORT ;
01420              m_action_check_abort = true ;
01421           } else {
01422             GEN_ERROR(E_GEN_FATAL_ERROR,
01423                       "bad value for ["
01424                       << L_actionArg << "] (warning or error)");
01425             L_ret = -1 ;
01426             break ;
01427           }
01428           break ;
01429           
01430         case E_ACTION_SCEN_GET_EXTERNAL_DATA:
01431           
01432           if (m_external_data != NULL) {
01433             L_actionArg = L_action -> find_value((char*) "field");
01434             if (L_actionArg == NULL) {
01435               GEN_ERROR(E_GEN_FATAL_ERROR, "field value mandatory for action ["
01436                         << L_actionName << "]");
01437               L_ret = -1 ;
01438               break ; 
01439             }
01440             L_field_id = (int)strtoul_f (L_actionArg, &L_end_str, 10);
01441             if (L_end_str[0] != '\0') {
01442               GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
01443                         << L_actionArg << "] not a number");
01444               L_ret = -1 ;
01445               break;
01446             }
01447             
01448             // ctrl number field
01449             if (L_field_id >= (int)(m_external_data -> get_nb_field())) {
01450               GEN_ERROR(E_GEN_FATAL_ERROR, "bad value ["
01451                         << L_actionArg << "] greater or equal than ["
01452                         << m_external_data -> get_nb_field() 
01453                         << "] for max field number");
01454               L_ret = -1 ;
01455               break;
01456             }
01457 
01458             L_actionArg = L_action -> find_value((char*)"name");
01459             if (L_actionArg != NULL) {
01460               L_actionData -> m_type = E_ACTION_SCEN_GET_EXTERNAL_DATA_TO_MEM  ;
01461               
01462               L_actionData->m_mem_id = 
01463                 add_memory (L_actionArg);
01464               
01465               if (*P_selectLine_added == false) {
01466                 
01467                 L_select_line_action = no_cmd_action ;
01468                 // Add a new action for select data line
01469                 L_select_line_action.m_type = E_ACTION_SCEN_SELECT_EXTERNAL_DATA_LINE ;
01470                 P_CommandActionLst.push_back
01471                   (P_CmdActionFactory.create(L_select_line_action));
01472                 P_nb_action++ ;
01473                 
01474                 // once time
01475                 *(P_selectLine_added) = true ;
01476               }
01477               m_external_data_used = true ;
01478               L_actionData->m_field_data_num = L_field_id;
01479             } else {    
01480               L_actionArg2 = L_action -> find_value((char*) "entity");
01481               if (L_actionArg2 == NULL) {
01482                 GEN_ERROR(E_GEN_FATAL_ERROR, "entity value mandatory for action ["
01483                           << L_actionName << "]");
01484                 L_ret = -1 ;
01485                 break ; 
01486               }
01487               
01488               L_entityFieldFound = false ;
01489               L_actionData->m_id 
01490                 = P_protocol->find_field (L_actionArg2) ;
01491               if (L_actionData->m_id == -1) {
01492                 GEN_ERROR(E_GEN_FATAL_ERROR,
01493                           "No definition found for ["
01494                           << L_actionArg2 << "]");
01495                 L_ret = -1 ;
01496                 break ;
01497               } else {
01498                 L_entityFieldFound = true ;
01499                 
01500               }
01501               
01502               
01503               L_actionArg = L_action -> find_value((char*) "instance");
01504               if (L_actionArg != NULL) {
01505                 T_InstanceDataList::iterator L_instance_it ;
01506                 bool L_instance_found = false ;
01507                 for (L_instance_it = P_instance_list.begin();
01508                      L_instance_it != P_instance_list.end();
01509                      L_instance_it++) {
01510                   if (strcmp(L_actionArg, L_instance_it->m_instance_name)==0) {
01511                     L_actionData->m_instance_id = L_instance_it->m_instance_id;
01512                     L_instance_found = true ;
01513                     break ;
01514                   }
01515                 }
01516                 if (L_instance_found == false) {
01517                   GEN_ERROR(E_GEN_FATAL_ERROR, "Unable to find instance name ["
01518                             << L_actionArg << "]");
01519                   L_ret = -1 ;
01520                   break ;
01521                 } else {
01522                   if (L_instance_it->m_id != L_actionData->m_id) {
01523                     GEN_ERROR(E_GEN_FATAL_ERROR, "Bad instance name ["
01524                               << L_actionArg << "]");
01525                     L_ret = -1 ;
01526                     break ;
01527                   }
01528                 }
01529               } // ctrl instance
01530               
01531               L_actionArg = L_action -> find_value((char*) "sub-entity");
01532               if (L_actionArg != NULL) {        
01533                 
01534                 
01535                 L_actionData->m_sub_id 
01536                   = P_protocol->find_field (L_actionArg) ;
01537                 if (L_actionData->m_sub_id == -1) {
01538                   GEN_ERROR(E_GEN_FATAL_ERROR,
01539                             "No definition found for ["
01540                             << L_actionArg << "]");
01541                   L_ret = -1 ;
01542                   break ;
01543                 }
01544               } 
01545               
01546               if (P_protocol->check_sub_entity_needed(L_actionData->m_id) == true) {
01547                 if (L_actionData->m_sub_id == -1) {
01548                   GEN_ERROR(E_GEN_FATAL_ERROR,
01549                             "sub entity needed for  ["
01550                             << L_actionArg2 
01551                             << "]");
01552                   
01553                   L_ret = -1 ;
01554                   break ;
01555                 }
01556               }
01557               
01558               L_actionArg = L_action -> find_value((char*) "begin");
01559               if (L_actionArg != NULL) {
01560                 
01561                 // check type field == STRING || BINARY       
01562                 
01563                 if (P_protocol->get_field_type(L_actionData->m_id, 
01564                                                L_actionData->m_sub_id)
01565                     != E_TYPE_STRING ) {
01566                   GEN_ERROR(E_GEN_FATAL_ERROR,
01567                             "Type field of entity ["
01568                             << L_actionArg2 
01569                             << "] is not STRING");
01570                   L_ret = -1 ;
01571                   break ;
01572                 }
01573                 
01574                 unsigned long  L_begin ;
01575                 char          *L_end_str = NULL ;
01576                 L_begin = strtoul_f (L_actionArg, &L_end_str, 10);
01577                 if (L_end_str[0] != '\0') {
01578                   GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
01579                             << L_actionArg << "] not a number");
01580                   L_ret = -1 ;
01581                   break ;
01582                 } else {
01583                   L_actionData->m_begin = (int)L_begin ;
01584                   L_begin_present = true ;
01585                 }
01586               }
01587               
01588               L_actionArg = L_action -> find_value((char*) "end");
01589               if (L_actionArg != NULL) {
01590                 
01591                 if (L_begin_present == true) {
01592                   
01593                   unsigned long  L_end ;
01594                   char          *L_end_str = NULL ;
01595                   L_end = strtoul_f (L_actionArg, &L_end_str, 10);
01596                   if (L_end_str[0] != '\0') {
01597                     GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
01598                               << L_actionArg << "] not a number");
01599                     L_ret = -1 ;
01600                     break ;
01601                   } else {
01602                     if ((int)L_end > L_actionData->m_begin) {
01603                       
01604                       L_actionData->m_size = L_end - L_actionData->m_begin ;
01605                       
01606                     } else {
01607                       GEN_ERROR(E_GEN_FATAL_ERROR, "End before begin index");
01608                       L_ret = -1 ;
01609                       break ;
01610                     }
01611                   }
01612                 } else {
01613                   GEN_ERROR(E_GEN_FATAL_ERROR, "End index defined without begin index");
01614                   L_ret = -1 ;
01615                   break ;
01616                 }
01617               }
01618           
01619               // ctrl type of field
01620               if (P_protocol->get_field_type(L_actionData->m_id, 
01621                                              L_actionData->m_sub_id)
01622                   != m_external_data->get_field_type(L_field_id)) {
01623                 // P_sub_id
01624                 T_TypeType L_type=P_protocol->get_field_type(L_actionData->m_id, 
01625                                                              L_actionData->m_sub_id);
01626                 GEN_ERROR(E_GEN_FATAL_ERROR,
01627                           "Incompatible type between external data field ["
01628                           << m_external_data->get_field_type(L_field_id)
01629                           << "] and entity ["
01630                           << L_type
01631                           << "]");
01632                 L_ret = -1 ;
01633                 break ;
01634               }
01635               
01636               
01637               if (L_entityFieldFound == true) {
01638                 
01639                 if (*P_selectLine_added == false) {
01640                   
01641                   L_select_line_action = no_cmd_action ;
01642                   // Add a new action for select data line
01643                   L_select_line_action . m_type = E_ACTION_SCEN_SELECT_EXTERNAL_DATA_LINE ;
01644                   P_CommandActionLst.push_back
01645                     (P_CmdActionFactory.create(L_select_line_action));
01646                   P_nb_action++ ;
01647                   
01648                   // once time
01649                   *(P_selectLine_added) = true ;
01650                 }
01651                 m_external_data_used = true ;
01652                 
01653                 L_actionData->m_field_data_num = L_field_id;
01654                 
01655               } else {
01656                 GEN_ERROR(E_GEN_FATAL_ERROR, "Unable to find definition for ["
01657                           << L_actionArg2 << "]");
01658                 L_ret = -1 ;
01659               }
01660             }
01661           } else {
01662             GEN_ERROR(E_GEN_FATAL_ERROR, 
01663                       "Using restore-from-external action with no external data defined");
01664             L_ret = -1 ;
01665           }
01666           
01667           break ;
01668           
01669           
01670 
01671         case E_ACTION_SCEN_INC_VAR:
01672             
01673             L_actionArg = L_action -> find_value((char*) "name");
01674             if (L_actionArg == NULL) {
01675               GEN_ERROR(E_GEN_FATAL_ERROR, "name value mandatory for action ["
01676                         << L_actionName << "]");
01677               L_ret = -1 ;
01678               break ; 
01679             }
01680 
01681             L_actionData->m_mem_id = 
01682               add_memory (L_actionArg);
01683             
01684             break ;
01685             
01686         case E_ACTION_SCEN_CHECK_VALUE:
01687           L_actionArg = L_action -> find_value((char*) "name");
01688           if (L_actionArg == NULL) {
01689             GEN_ERROR(E_GEN_FATAL_ERROR, "name value mandatory for action ["
01690                       << L_actionName << "]");
01691             L_ret = -1 ;
01692             break ; 
01693           } 
01694 
01695           L_actionArg2 = L_action -> find_value((char*) "behaviour");
01696           if (L_actionArg2 == NULL) {
01697             GEN_ERROR(E_GEN_FATAL_ERROR, 
01698                       "behaviour value mandatory for action ["
01699                       << L_actionName << "]");
01700             L_ret = -1 ;
01701             break ; 
01702           } 
01703           
01704           L_actionData->m_id 
01705             = P_protocol->find_field (L_actionArg) ;
01706           if (L_actionData->m_id == -1) {
01707             GEN_ERROR(E_GEN_FATAL_ERROR,
01708                       "No definition found for ["
01709                       << L_actionArg << "]");
01710             L_ret = -1 ;
01711             break ;
01712           }
01713           
01714           L_actionArg = L_action -> find_value((char*) "sub-entity");
01715           if (L_actionArg != NULL) {
01716             
01717             L_actionData->m_sub_id 
01718               = P_protocol->find_field (L_actionArg) ;
01719             if (L_actionData->m_sub_id == -1) {
01720               GEN_ERROR(E_GEN_FATAL_ERROR,
01721                         "No definition found for ["
01722                         << L_actionArg << "]");
01723               L_ret = -1 ;
01724               break ;
01725             }
01726             // std::cerr << "***** " <<L_actionData->m_sub_id << std::endl;  
01727             // id correct => > header+body_value
01728             //            L_actionData->m_sub_id = ;
01729           } // else id >header+body_value => error
01730           
01731           
01732 
01733           L_actionArg = L_action -> find_value((char*) "instance");
01734           if (L_actionArg != NULL) {
01735             T_InstanceDataList::iterator L_instance_it ;
01736             bool L_instance_found = false ;
01737             for (L_instance_it = P_instance_list.begin();
01738                  L_instance_it != P_instance_list.end();
01739                  L_instance_it++) {
01740               if (strcmp(L_actionArg, L_instance_it->m_instance_name)==0) {
01741                 L_actionData->m_instance_id = L_instance_it->m_instance_id;
01742                 L_instance_found = true ;
01743                 break ;
01744               }
01745             }
01746             if (L_instance_found == false) {
01747               GEN_ERROR(E_GEN_FATAL_ERROR, "Unable to find instance name ["
01748                         << L_actionArg << "]");
01749               L_ret = -1 ;
01750               break ;
01751             } else {
01752               if (L_instance_it->m_id != L_actionData->m_id) {
01753                 GEN_ERROR(E_GEN_FATAL_ERROR, "Bad instance name ["
01754                           << L_actionArg << "]");
01755                 L_ret = -1 ;
01756                 break ;
01757               }
01758             }
01759           }
01760 
01761           
01762           // decode behaviour
01763           if (strcmp (L_actionArg2, (char*)"warning") == 0) {
01764             L_actionData->m_check_behaviour = E_CHECK_BEHAVIOUR_WARNING ;
01765           } else if (strcmp (L_actionArg2, (char*)"error") == 0) {
01766             L_actionData->m_check_behaviour = E_CHECK_BEHAVIOUR_ERROR ;
01767           } else if (strcmp (L_actionArg2, (char*)"abort") == 0) {
01768             L_actionData->m_check_behaviour = E_CHECK_BEHAVIOUR_ABORT ;
01769              m_action_check_abort = true ;
01770           } else {
01771             GEN_ERROR(E_GEN_FATAL_ERROR,
01772                       "bad value for ["
01773                       << L_actionArg << "] (warning or error)");
01774             L_ret = -1 ;
01775             break ;
01776           }
01777           break ;
01778 
01779         case E_ACTION_SCEN_TRANSPORT_OPTION : 
01780           L_actionArg = L_action -> find_value((char*) "channel");
01781           if (L_actionArg == NULL) {
01782             GEN_ERROR(E_GEN_FATAL_ERROR, "name value mandatory for action ["
01783                       << L_actionName << "]");
01784             L_ret = -1 ;
01785             break ; 
01786           }
01787 
01788           L_actionData->m_id = m_channel_ctrl->get_channel_id(L_actionArg);
01789           if (L_actionData->m_id  == ERROR_CHANNEL_UNKNOWN) {
01790             GEN_ERROR(E_GEN_FATAL_ERROR, 
01791                       "Channel [" << L_actionArg << "] unknowm for action ["
01792                       << L_actionName << "]");
01793             L_ret = -1 ;
01794             break ;
01795           }
01796 
01797 
01798           L_actionArg2 = L_action -> find_value((char*) "value");
01799           if (L_actionArg2 == NULL) {
01800             GEN_ERROR(E_GEN_FATAL_ERROR, "value mandatory for action ["
01801                       << L_actionName << "]");
01802             L_ret = -1 ;
01803             break ; 
01804           } else {
01805             if (strlen(L_actionArg2) > 0 ) {
01806               L_actionData -> m_args = L_actionArg2 ;
01807             } else {
01808               GEN_ERROR(E_GEN_FATAL_ERROR, "no value for action ["
01809                         << L_actionName << "]");
01810               L_ret = -1 ;
01811             }
01812           }
01813 
01814         break;
01815 
01816         case E_ACTION_SCEN_CHECK_ORDER:
01817           L_actionArg = L_action -> find_value((char*) "name");
01818           if (L_actionArg == NULL) {
01819             GEN_ERROR(E_GEN_FATAL_ERROR, "name value mandatory for action ["
01820                       << L_actionName << "]");
01821             L_ret = -1 ;
01822             break ; 
01823           } 
01824           L_actionArg2 = L_action -> find_value((char*) "behaviour");
01825           if (L_actionArg2 == NULL) {
01826             GEN_ERROR(E_GEN_FATAL_ERROR, 
01827                       "behaviour value mandatory for action ["
01828                       << L_actionName << "]");
01829             L_ret = -1 ;
01830             break ; 
01831           } 
01832           
01833           L_actionData->m_id 
01834             = P_protocol->find_field (L_actionArg) ;
01835           if (L_actionData->m_id == -1) {
01836             GEN_ERROR(E_GEN_FATAL_ERROR,
01837                       "No definition found for ["
01838                       << L_actionArg << "]");
01839             L_ret = -1 ;
01840             break ;
01841           }
01842 
01843           L_actionArg = L_action -> find_value((char*) "position");
01844           if (L_actionArg == NULL) {
01845             GEN_ERROR(E_GEN_FATAL_ERROR, "position value mandatory for action ["
01846                       << L_actionName << "]");
01847             L_ret = -1 ;
01848             break ; 
01849           } 
01850 
01851           L_position = (int)strtoul_f (L_actionArg, &L_end_str, 10);
01852           if (L_end_str[0] != '\0') {
01853             GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
01854                       << L_actionArg << "] not a number");
01855             L_ret = -1 ;
01856             break;
01857           }
01858             
01859           // ctrl number field
01860           if (L_position > P_nb_value) {
01861             GEN_ERROR(E_GEN_FATAL_ERROR, "bad value ["
01862                       << L_actionArg << "] greater or equal than ["
01863                       << P_nb_value 
01864                       << "] for max number of body value");
01865             L_ret = -1 ;
01866             break;
01867           }
01868 
01869           L_actionData->m_position = L_position ;
01870           
01871 
01872            
01873           // decode behaviour
01874           if (strcmp (L_actionArg2, (char*)"warning") == 0) {
01875             L_actionData->m_check_behaviour = E_CHECK_BEHAVIOUR_WARNING ;
01876           } else if (strcmp (L_actionArg2, (char*)"error") == 0) {
01877             L_actionData->m_check_behaviour = E_CHECK_BEHAVIOUR_ERROR ;
01878           } else if (strcmp (L_actionArg2, (char*)"abort") == 0) {
01879             L_actionData->m_check_behaviour = E_CHECK_BEHAVIOUR_ABORT ;
01880              m_action_check_abort = true ;
01881           } else {
01882             GEN_ERROR(E_GEN_FATAL_ERROR,
01883                       "bad value for ["
01884                       << L_actionArg << "] (warning or error)");
01885             L_ret = -1 ;
01886             break ;
01887           }
01888           break ;
01889           
01890         case E_ACTION_SCEN_SET_BIT : 
01891           
01892           L_actionArg = L_action -> find_value((char*) "name");
01893           if (L_actionArg == NULL) {
01894             GEN_ERROR(E_GEN_FATAL_ERROR, "name value mandatory for action ["
01895                       << L_actionName << "]");
01896             L_ret = -1 ;
01897             break ; 
01898           }
01899           
01900           L_actionArg2 = L_action -> find_value((char*) "entity");
01901           if (L_actionArg2 == NULL) {
01902             GEN_ERROR(E_GEN_FATAL_ERROR, "entity value mandatory for action ["
01903                       << L_actionName << "]");
01904             L_ret = -1 ;
01905             break ; 
01906           }
01907           L_memoryRefFound = false ;
01908           
01909           L_actionData->m_id 
01910             = P_protocol->find_field (L_actionArg2) ;
01911           if (L_actionData->m_id != -1) {
01912             L_memoryRefFound = true ;
01913           }
01914           
01915           if (L_memoryRefFound == true) {
01916             L_actionData->m_mem_id = 
01917               add_memory (L_actionArg);
01918           } else {
01919             GEN_ERROR(E_GEN_FATAL_ERROR, "Unable to find definition for ["
01920                       << L_actionArg2 << "]");
01921             L_ret = -1 ;
01922             break;
01923           }
01924           
01925           L_actionArg = L_action -> find_value((char*) "instance");
01926           if (L_actionArg != NULL) {
01927             T_InstanceDataList::iterator L_instance_it ;
01928             bool L_instance_found = false ;
01929             for (L_instance_it = P_instance_list.begin();
01930                  L_instance_it != P_instance_list.end();
01931                  L_instance_it++) {
01932               if (strcmp(L_actionArg, L_instance_it->m_instance_name)==0) {
01933                 L_actionData->m_instance_id = L_instance_it->m_instance_id;
01934                 L_instance_found = true ;
01935                 break ;
01936               }
01937             }
01938             if (L_instance_found == false) {
01939               GEN_ERROR(E_GEN_FATAL_ERROR, "Unable to find instance name ["
01940                         << L_actionArg << "]");
01941               L_ret = -1 ;
01942               break ;
01943             } else {
01944               if (L_instance_it->m_id != L_actionData->m_id) {
01945                 GEN_ERROR(E_GEN_FATAL_ERROR, "Bad instance name ["
01946                           << L_actionArg << "]");
01947                 L_ret = -1 ;
01948                 break ;
01949               }
01950             }
01951           }
01952           
01953           L_actionArg = L_action -> find_value((char*) "sub-entity");
01954           if (L_actionArg != NULL) {        
01955             L_actionData->m_sub_id 
01956               = P_protocol->find_field (L_actionArg) ;
01957             if (L_actionData->m_sub_id == -1) {
01958               GEN_ERROR(E_GEN_FATAL_ERROR,
01959                         "No definition found for ["
01960                         << L_actionArg << "]");
01961               L_ret = -1 ;
01962               break ;
01963             }
01964           }
01965           
01966           
01967           if (P_protocol->check_sub_entity_needed(L_actionData->m_id) == true) {
01968             
01969             if (L_actionData->m_sub_id == -1) {
01970               GEN_ERROR(E_GEN_FATAL_ERROR,
01971                         "sub entity needed for  ["
01972                         << L_actionArg2 
01973                         << "]");
01974               L_ret = -1 ;
01975               break ;
01976             }
01977           }
01978           
01979           // check type field == STRING || BINARY
01980 //        if (P_protocol->get_field_type(L_actionData->m_id, 
01981 //                                           L_actionData->m_sub_id)
01982 //                != E_TYPE_STRING ) {
01983 //              GEN_ERROR(E_GEN_FATAL_ERROR,
01984 //                        "Type field of entity ["
01985 //                        << L_actionArg2 
01986 //                        << "] is not STRING");
01987 //              L_ret = -1 ;
01988 //              break ;
01989 //        }
01990           
01991           L_actionArg = L_action -> find_value((char*) "position");
01992           if (L_actionArg == NULL) {
01993             GEN_ERROR(E_GEN_FATAL_ERROR, "position value mandatory for action ["
01994                       << L_actionName << "]");
01995             L_ret = -1 ;
01996             break ; 
01997           } 
01998           
01999           L_position = (int)strtoul_f (L_actionArg, &L_end_str, 10);
02000           if (L_end_str[0] != '\0') {
02001             GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
02002                       << L_actionArg << "] not a number");
02003             L_ret = -1 ;
02004             break;
02005           }
02006           
02007           L_actionData->m_position = L_position ;
02008           
02009           L_actionArg = L_action -> find_value((char*) "value");
02010           if (L_actionArg == NULL) {
02011             GEN_ERROR(E_GEN_FATAL_ERROR, "value mandatory for action ["
02012                       << L_actionName << "]");
02013             L_ret = -1 ;
02014             break ; 
02015           } 
02016           
02017           L_value_set_bit = (int)strtoul_f (L_actionArg, &L_end_str, 10);
02018           if (L_end_str[0] != '\0') {
02019             GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
02020                       << L_actionArg << "] not a number");
02021             L_ret = -1 ;
02022             break;
02023           }
02024           
02025           if ((L_value_set_bit != 0) && (L_value_set_bit !=1)) {
02026             GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
02027                       << L_actionArg << "] value must be 0 or 1");
02028             L_ret = -1 ;
02029             break;
02030           }
02031           
02032           L_actionData->m_field_data_num = L_value_set_bit;
02033           break;
02034 
02035         case E_ACTION_SCEN_SET_VALUE_BIT : 
02036           
02037           L_actionArg = L_action -> find_value((char*) "entity");
02038           if (L_actionArg == NULL) {
02039             GEN_ERROR(E_GEN_FATAL_ERROR, "entity value mandatory for action ["
02040                       << L_actionName << "]");
02041             L_ret = -1 ;
02042             break ; 
02043           }
02044           
02045           L_actionData->m_id 
02046             = P_protocol->find_field (L_actionArg) ;
02047           
02048           L_actionArg = L_action -> find_value((char*) "instance");
02049           if (L_actionArg != NULL) {
02050             T_InstanceDataList::iterator L_instance_it ;
02051             bool L_instance_found = false ;
02052             for (L_instance_it = P_instance_list.begin();
02053                  L_instance_it != P_instance_list.end();
02054                  L_instance_it++) {
02055               if (strcmp(L_actionArg, L_instance_it->m_instance_name)==0) {
02056                 L_actionData->m_instance_id = L_instance_it->m_instance_id;
02057                 L_instance_found = true ;
02058                 break ;
02059               }
02060             }
02061             if (L_instance_found == false) {
02062               GEN_ERROR(E_GEN_FATAL_ERROR, "Unable to find instance name ["
02063                         << L_actionArg << "]");
02064               L_ret = -1 ;
02065               break ;
02066             } else {
02067               if (L_instance_it->m_id != L_actionData->m_id) {
02068                 GEN_ERROR(E_GEN_FATAL_ERROR, "Bad instance name ["
02069                           << L_actionArg << "]");
02070                 L_ret = -1 ;
02071                 break ;
02072               }
02073             }
02074           }
02075           
02076           L_actionArg = L_action -> find_value((char*) "sub-entity");
02077           if (L_actionArg != NULL) {        
02078             L_actionData->m_sub_id 
02079               = P_protocol->find_field (L_actionArg) ;
02080             if (L_actionData->m_sub_id == -1) {
02081               GEN_ERROR(E_GEN_FATAL_ERROR,
02082                         "No definition found for ["
02083                         << L_actionArg << "]");
02084               L_ret = -1 ;
02085               break ;
02086             }
02087           }
02088           
02089           
02090           if (P_protocol->check_sub_entity_needed(L_actionData->m_id) == true) {
02091             
02092             if (L_actionData->m_sub_id == -1) {
02093               GEN_ERROR(E_GEN_FATAL_ERROR,
02094                         "sub entity needed for  ["
02095                         << L_actionArg2 
02096                         << "]");
02097               L_ret = -1 ;
02098               break ;
02099             }
02100           }
02101           
02102           // check type field == STRING || BINARY
02103 //        if (P_protocol->get_field_type(L_actionData->m_id, 
02104 //                                           L_actionData->m_sub_id)
02105 //                != E_TYPE_STRING ) {
02106 //              GEN_ERROR(E_GEN_FATAL_ERROR,
02107 //                        "Type field of entity ["
02108 //                        << L_actionArg2 
02109 //                        << "] is not STRING");
02110 //              L_ret = -1 ;
02111 //              break ;
02112 //        }
02113           
02114           
02115           L_actionArg = L_action -> find_value((char*) "position");
02116           if (L_actionArg == NULL) {
02117             GEN_ERROR(E_GEN_FATAL_ERROR, "position value mandatory for action ["
02118                       << L_actionName << "]");
02119             L_ret = -1 ;
02120             break ; 
02121           } 
02122           
02123           L_position = (int)strtoul_f (L_actionArg, &L_end_str, 10);
02124           if (L_end_str[0] != '\0') {
02125             GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
02126                       << L_actionArg << "] not a number");
02127             L_ret = -1 ;
02128             break;
02129           }
02130           
02131           L_actionData->m_position = L_position ;
02132           
02133           L_actionArg = L_action -> find_value((char*) "value");
02134           if (L_actionArg == NULL) {
02135             GEN_ERROR(E_GEN_FATAL_ERROR, "value mandatory for action ["
02136                       << L_actionName << "]");
02137             L_ret = -1 ;
02138             break ; 
02139           } 
02140           
02141           L_value_set_bit = (int)strtoul_f (L_actionArg, &L_end_str, 10);
02142           if (L_end_str[0] != '\0') {
02143             GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
02144                       << L_actionArg << "] not a number");
02145             L_ret = -1 ;
02146             break;
02147           }
02148           
02149           if ((L_value_set_bit != 0) && (L_value_set_bit !=1)) {
02150             GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
02151                       << L_actionArg << "] value must be 0 or 1");
02152             L_ret = -1 ;
02153             break;
02154           }
02155           
02156           L_actionData->m_field_data_num = L_value_set_bit;
02157           break;
02158 
02159 
02160         default:
02161           GEN_ERROR(E_GEN_FATAL_ERROR, "Action not implemented");
02162           L_ret = -1 ;
02163           break ;
02164         } // switch L_actionType
02165         
02166         if (L_ret != -1) {
02167           if ( m_config->get_execute_check_action() == false) {
02168             switch (L_actionType) {
02169             case E_ACTION_SCEN_CHECK_PRESENCE:
02170             case E_ACTION_SCEN_CHECK_VALUE:
02171             case E_ACTION_SCEN_CHECK_ORDER:
02172               FREE_VAR(L_actionData);
02173               break ;
02174             default:
02175               P_CommandActionLst.push_back(P_CmdActionFactory.create(*L_actionData));
02176               FREE_VAR(L_actionData);
02177               P_nb_action++ ;
02178               break ;
02179             }
02180           } else {
02181             P_CommandActionLst.push_back(P_CmdActionFactory.create(*L_actionData));
02182             FREE_VAR(L_actionData);
02183             P_nb_action++ ;
02184           }
02185         } 
02186         
02187       } else {
02188         GEN_ERROR(E_GEN_FATAL_ERROR, "Unknown action name [" << L_actionName << "]");
02189         L_ret = -1 ;
02190         break ;
02191       }
02192       if (L_ret == -1) break ;
02193 
02194     } // for (L_actionListIt
02195     
02196     if (L_ret != -1) {
02197       if ((P_pre_action == true) && (P_pre_action_done == false)) {
02198         
02199         // pre actions settings
02200         if (P_nb_action != 0) {
02201           T_CommandActionLst::iterator L_cmdActionIt ;
02202           int                       L_actionIdx = 0 ;
02203           
02204           ALLOC_TABLE(P_CommandActionTable, 
02205                       C_CommandAction**,
02206                       sizeof(C_CommandAction*),
02207                       P_nb_action);
02208           for (L_cmdActionIt  = P_CommandActionLst.begin();
02209                L_cmdActionIt != P_CommandActionLst.end();
02210                L_cmdActionIt++) {
02211             P_CommandActionTable[L_actionIdx] = *L_cmdActionIt ;
02212             L_actionIdx ++ ;
02213           }
02214           if (!P_CommandActionLst.empty()) {
02215             P_CommandActionLst.erase(P_CommandActionLst.begin(),P_CommandActionLst.end());
02216           }
02217 
02218           P_scen -> define_pre_actions(P_nb_action, P_CommandActionTable);
02219           P_nb_action = 0 ;
02220           P_CommandActionTable = NULL ;
02221         }
02222         P_pre_action_done = true ;      
02223         
02224       } else {  
02225         // post actions settings
02226         // post actions in the command => add in call map added if needed 
02227         // (== if not already inserted for this channel)
02228         P_inserted = P_map_inserted[P_channel_id];
02229         if (P_inserted == false) {
02230           T_CmdAction L_action_map ;
02231           L_action_map = no_cmd_action ;
02232           L_action_map . m_type = E_ACTION_SCEN_ADD_IN_CALL_MAP ;
02233           L_action_map . m_id = P_channel_id ;
02234           P_CommandActionLst.push_back(P_CmdActionFactory.create(L_action_map));
02235           P_nb_action++ ;
02236           P_inserted = true ;
02237 
02238           for (L_actionListIt  = L_actionList->begin();
02239                L_actionListIt != L_actionList->end();
02240                L_actionListIt++) {
02241             L_action = *L_actionListIt ;
02242             L_actionName = L_action -> get_name() ;
02243             L_actionFound = false ;
02244             for(L_i=0;
02245                 L_i< (T_action_type)E_NB_ACTION_SCEN ;
02246                 L_i++) {
02247               
02248               if (strcmp(L_actionName, action_name_table[L_i])==0) {
02249                 L_actionType=(T_action_type)L_i ;
02250                 L_actionFound = true ;
02251                 break ;
02252               }
02253             }
02254             if (L_actionFound == true) {
02255               if (L_actionType == E_ACTION_SCEN_SET_NEW_SESSION_ID) {
02256                 GEN_ERROR(E_GEN_FATAL_ERROR, "Action ["
02257                           << L_actionName << "] is not allowed on the first command");
02258                 L_ret = -1 ;
02259                 break ; 
02260               }
02261             }
02262           }
02263           if (L_ret == -1) {
02264             return (L_ret);
02265           }
02266         }
02267 
02268         
02269         if (P_nb_action != 0) {
02270           T_CommandActionLst::iterator L_cmdActionIt ;
02271           int                          L_actionIdx = 0 ;
02272           
02273           ALLOC_TABLE(P_CommandActionTable, 
02274                       C_CommandAction**,
02275                       sizeof(C_CommandAction*),
02276                       P_nb_action);
02277 
02278           for (L_cmdActionIt  = P_CommandActionLst.begin();
02279                L_cmdActionIt != P_CommandActionLst.end();
02280                L_cmdActionIt++) {
02281             P_CommandActionTable[L_actionIdx] = *L_cmdActionIt ;
02282             L_actionIdx ++ ;
02283           }
02284           if (!P_CommandActionLst.empty()) {
02285             P_CommandActionLst.erase(P_CommandActionLst.begin(),P_CommandActionLst.end());
02286           }
02287           
02288           P_scen -> define_post_actions(P_nb_action, P_CommandActionTable);
02289         }
02290         
02291       }
02292     
02293     }
02294   }
02295 
02296   GEN_DEBUG(1, "C_ScenarioControl::add_actions() end with " << L_ret);
02297   return (L_ret);
02298         
02299 } // add_actions
02300 
02301 
02302 
02303 int C_ScenarioControl::memory_used() {
02304   return(m_memory_max);
02305 }
02306 
02307 iostream_output& operator<<(iostream_output& P_ostream , 
02308                                 C_ScenarioControl& P_scenControl) {
02309 
02310   P_ostream << (*P_scenControl.m_traffic_scen) ;
02311   return (P_ostream) ;
02312   
02313 }
02314 
02315 int C_ScenarioControl::add_expression (char       *P_arg,
02316                                        C_ProtocolFrame *P_protocol,
02317                                        T_pStringExpression *P_strExpr) {
02318 
02319   int L_ret = 0 ;
02320 
02321   char *L_ptr; 
02322   size_t L_size, L_i, L_j ;
02323   int    L_type;
02324 
02325   char   L_value[100] ;
02326   size_t L_value_size = 0 ;
02327 
02328   list_t<T_pStringValue> L_list ;
02329   list_t<T_pStringValue>::iterator L_it ;
02330 
02331   T_pStringValue L_string_val ;
02332   T_pStringExpression L_string_expr ;
02333 
02334   L_ptr = P_arg ;
02335   L_size = strlen(L_ptr) ;
02336 
02337   //  std::cerr << "size   *****" << L_size << std::endl;
02338   // std::cerr << "buffer *****" << L_ptr << std::endl;
02339 
02340   L_type = 0 ; // 0: normal string
02341                // 1: $ found => need ( for dynamic def
02342                // 2: $( found => dynamic def
02343 
02344   *P_strExpr = NULL ;
02345 
02346   L_i = 0 ;
02347   while (L_i < L_size) {
02348     switch (L_ptr[L_i]) {
02349     case '$':
02350       if (L_value_size != 0) {
02351         L_value[L_value_size] = 0 ;
02352         L_value_size++ ;
02353         ALLOC_VAR(L_string_val, T_pStringValue, sizeof(T_StringValue));
02354         L_string_val->m_type = E_STR_STATIC ;
02355         ALLOC_TABLE(L_string_val->m_data.m_value,
02356                     char*,
02357                     sizeof(char),
02358                     strlen(L_value)+1);
02359         strcpy(L_string_val->m_data.m_value, L_value);
02360         L_list.push_back(L_string_val);
02361         L_value_size = 0 ;
02362       }
02363       if (L_type == 0) {
02364         L_type = 1 ;
02365       }
02366       break ;
02367     case '(':
02368       if (L_type == 1) {
02369         L_type = 2 ;
02370       } else {
02371         L_value[L_value_size] = L_ptr[L_i] ;
02372         L_value_size++ ;
02373       } 
02374       break ;
02375     case ')':
02376       if (L_type == 2) {
02377         if (L_value_size != 0) {
02378           L_value[L_value_size] = 0 ;
02379           L_value_size++ ;
02380           ALLOC_VAR(L_string_val, T_pStringValue, sizeof(T_StringValue));
02381           L_string_val->m_type = E_STR_COUNTER ;
02382           L_string_val->m_data.m_id 
02383             = get_counter_id (L_value) ;
02384           if (L_string_val->m_data.m_id == -1) {
02385             L_string_val->m_data.m_id 
02386               = check_memory (L_value) ;
02387             if (L_string_val->m_data.m_id == -1) {
02388               GEN_ERROR(E_GEN_FATAL_ERROR,
02389                         "Unable to find definition for ["
02390                         << L_value << "]");
02391               L_ret = -1 ;
02392               break ;
02393             } else {
02394               L_string_val->m_type = E_STR_MEMORY ;
02395               L_list.push_back(L_string_val);
02396               L_value_size = 0 ;
02397 
02398             }
02399           } else {
02400             L_list.push_back(L_string_val);
02401             L_value_size = 0 ;
02402           }
02403         }
02404         L_type = 0 ;
02405       } else {
02406         L_value[L_value_size] = L_ptr[L_i] ;
02407         L_value_size++ ;
02408       }
02409       break ;
02410 
02411     default :
02412       switch (L_type) {
02413       case 0:
02414         // add static value ;
02415         L_value[L_value_size] = L_ptr[L_i] ;
02416         L_value_size++ ;
02417         // std::cerr << "L_i " << L_i << "and L_value_size *****" << L_value_size << std::endl;
02418         break ;
02419       case 1:
02420         L_type = 0 ;
02421         break ;
02422       case 2:
02423         // add value counter
02424         L_value[L_value_size] = L_ptr[L_i] ;
02425         L_value_size++ ;
02426         break ;
02427       }
02428       break ;
02429     }
02430     if (L_ret == -1) break ;
02431     L_i ++ ;
02432   }
02433 
02434   if (L_ret == 0) {
02435     if (L_value_size != 0) {
02436       L_value[L_value_size] = 0 ;
02437       L_value_size++ ;
02438       ALLOC_VAR(L_string_val, T_pStringValue, sizeof(T_StringValue));
02439       L_string_val->m_type = E_STR_STATIC ;
02440       ALLOC_TABLE(L_string_val->m_data.m_value,
02441                   char*,
02442                   sizeof(char),
02443                   strlen(L_value)+1);
02444       strcpy(L_string_val->m_data.m_value, L_value);
02445       L_list.push_back(L_string_val);
02446       L_value_size = 0 ;
02447     } 
02448 
02449     ALLOC_VAR(L_string_expr,
02450               T_pStringExpression,
02451               sizeof(T_StringExpression));
02452 
02453     L_string_expr->m_nb_portion = L_list.size() ;
02454 
02455 
02456     //    std::cerr << "m_nb_portion *****" << L_string_expr->m_nb_portion << std::endl;
02457 
02458     if (L_string_expr->m_nb_portion != 0) {
02459       ALLOC_TABLE(L_string_expr->m_portions,
02460                   T_pStringValue,
02461                   sizeof(T_StringValue),
02462                   L_string_expr->m_nb_portion);
02463       L_j = 0 ;
02464       for (L_it  = L_list.begin();
02465            L_it != L_list.end();
02466            L_it++) {
02467         L_string_expr->m_portions[L_j] = *(*L_it);
02468         FREE_VAR (*L_it);
02469         L_j ++ ;
02470       }
02471       *P_strExpr = L_string_expr ;
02472       L_list.erase(L_list.begin(), L_list.end());
02473       
02474     } else {
02475       L_string_expr->m_portions = NULL ;
02476     }
02477     
02478   }
02479 
02480   // analysis of arg2 => format expression
02481 
02482   return (L_ret) ;
02483 }
02484 
02485 int C_ScenarioControl::check_expression (T_pCmdAction  P_action, 
02486                                          C_ProtocolFrame   *P_protocol) {
02487 
02488   int L_ret = 0 ;
02489 
02490   regex_t    L_regExpr ;
02491   regmatch_t L_pmatch ;
02492   int        L_status ;
02493   char       L_buffer[1024] ;
02494   char      *L_search       ;
02495 
02496   L_ret = ((P_action->m_type != E_ACTION_SCEN_SET_VALUE) &&
02497            (P_action->m_type != E_ACTION_SCEN_SET_VALUE_METHOD_EXTERN))
02498            ? -1 : 0 ;
02499 
02500   if (L_ret == 0) {
02501     switch (P_protocol->get_field_type(P_action->m_id,0)) {
02502 
02503     case E_TYPE_NUMBER:
02504     case E_TYPE_SIGNED:
02505     case E_TYPE_NUMBER_64:
02506     case E_TYPE_SIGNED_64:
02507       if (P_action->m_string_expr->m_nb_portion != 1) {
02508         GEN_ERROR(E_GEN_FATAL_ERROR, 
02509                   "Just one value allowed for this kind of field");
02510         L_ret = -1 ;
02511         break ;
02512       }
02513       if (P_action->m_string_expr->m_portions[0].m_type != E_STR_COUNTER) {
02514         GEN_ERROR(E_GEN_FATAL_ERROR, 
02515                   "Just one counter value allowed for this kind of field");
02516         L_ret = -1 ;
02517         break ;
02518       }
02519       break ;
02520 
02521     case E_TYPE_STRING:
02522       // nothing to check: everything is allowed
02523       break ;
02524 
02525     case E_TYPE_STRUCT: {
02526       
02527       if (P_action->m_string_expr->m_nb_portion > 3 ) {
02528         GEN_ERROR(E_GEN_FATAL_ERROR, 
02529                   "One or two values allowed for this kind of field");
02530         L_ret = -1 ;
02531         break ;
02532       } 
02533       
02534       if (P_action->m_string_expr->m_nb_portion ==1) {
02535         if ((P_action->m_string_expr->m_portions[0].m_type != E_STR_STATIC) ) { 
02536           GEN_ERROR(E_GEN_FATAL_ERROR, 
02537                     "Just one string value allowed for this kind of field :" << 
02538                     " [0;0], [;0] or [0;]");
02539           L_ret = -1 ;
02540           break ;
02541         } else {
02542           
02543           L_search = P_action->m_string_expr->m_portions[0].m_data.m_value;
02544           
02545           L_status = regcomp (&L_regExpr, "[[:blank:]]*[[:digit:]]*[[:blank:]]*[;][[:blank:]]*[[:digit:]]*[[:blank:]]*", REG_EXTENDED) ;
02546           if (L_status != 0 ) {
02547             regerror(L_status, &L_regExpr, L_buffer, 1024);
02548             regfree (&L_regExpr) ;
02549             GEN_ERROR(E_GEN_FATAL_ERROR, 
02550                       "Just one string value allowed for this kind of field :" << 
02551                       " [0;0], [;0] or [0;]");
02552             L_ret = -1 ;
02553             break ;
02554           }  
02555           L_pmatch.rm_eo = 0 ;
02556           L_pmatch.rm_so = 0 ;
02557            
02558           L_status = regexec (&L_regExpr, L_search, 1, &L_pmatch, 0) ;
02559           regfree (&L_regExpr) ;
02560           if ((L_status != 0 ) || (L_pmatch.rm_eo != (int )strlen(L_search)) || (L_pmatch.rm_so != 0)) { 
02561             GEN_ERROR(E_GEN_FATAL_ERROR, 
02562                       "Just one string value allowed for this kind of field :" << 
02563                       " [0;0], [;0] or [0;]");
02564             L_ret = -1 ;
02565             break ;
02566           }
02567         }
02568       }
02569       
02570       if (P_action->m_string_expr->m_nb_portion ==2) {
02571         switch (P_action->m_string_expr->m_portions[0].m_type) {
02572         case E_STR_STATIC:
02573           if( P_action->m_string_expr->m_portions[1].m_type != E_STR_COUNTER)  {
02574             GEN_ERROR(E_GEN_FATAL_ERROR, 
02575                       "One string value and one counter are allowed for this kind of field :" << 
02576                       "[0;counter] or [;counter]");
02577             L_ret = -1 ;
02578             break ;
02579           } else {
02580             
02581             L_search = P_action->m_string_expr->m_portions[0].m_data.m_value;
02582             L_status = regcomp (&L_regExpr, "[[:blank:]]*[[:digit:]]*[[:blank:]]*[;][[:blank:]]*", REG_EXTENDED) ;
02583             if (L_status != 0 ) {
02584               regerror(L_status, &L_regExpr, L_buffer, 1024);
02585               regfree (&L_regExpr) ;
02586               GEN_ERROR(E_GEN_FATAL_ERROR, 
02587                         "One string value and one counter are allowed for this kind of field :" << 
02588                         "[0;counter] or [;counter]");
02589               L_ret = -1 ;
02590               break ;
02591             }   
02592             L_status = regexec (&L_regExpr, L_search, 1, &L_pmatch, 0) ;
02593             regfree (&L_regExpr) ;
02594             if ((L_status != 0 ) || (L_pmatch.rm_eo != (int )strlen(L_search)) || (L_pmatch.rm_so != 0)) { 
02595               GEN_ERROR(E_GEN_FATAL_ERROR, 
02596                         "One string value and one counter are allowed for this kind of field :" << 
02597                         "[0;counter] or [;counter]");
02598               L_ret = -1 ;
02599               break ;
02600             }
02601           }
02602           
02603           break ;
02604         case E_STR_COUNTER:
02605           if( P_action->m_string_expr->m_portions[1].m_type != E_STR_STATIC ) { 
02606             
02607             GEN_ERROR(E_GEN_FATAL_ERROR, 
02608                       "One counter and one string value are allowed for this kind of field :" << 
02609                       "[counter;0] or [counter;]");
02610             L_ret = -1 ;
02611             break ;
02612           } else {
02613             
02614             L_search = P_action->m_string_expr->m_portions[1].m_data.m_value;
02615             L_status = regcomp (&L_regExpr, "[[:blank:]]*[;][[:blank:]]*[[:digit:]]*[[:blank:]]*", REG_EXTENDED) ;
02616             if (L_status != 0 ) {
02617               regerror(L_status, &L_regExpr, L_buffer, 1024);
02618               regfree (&L_regExpr) ;
02619               GEN_ERROR(E_GEN_FATAL_ERROR, 
02620                         "One counter and one string value are allowed for this kind of field :" << 
02621                         "[counter;0] or [counter;]");
02622               L_ret = -1 ;
02623               break ;
02624             }   
02625             L_status = regexec (&L_regExpr, L_search, 1, &L_pmatch, 0) ;
02626             regfree (&L_regExpr) ;
02627             if ((L_status != 0 ) || (L_pmatch.rm_eo != (int )strlen(L_search)) || (L_pmatch.rm_so != 0)) { 
02628               GEN_ERROR(E_GEN_FATAL_ERROR, 
02629                         "One counter and one string value are allowed for this kind of field :" << 
02630                         "[counter;0] or [counter;]");
02631               L_ret = -1 ;
02632               break ;
02633             }
02634           }
02635           break ;
02636           
02637         default :
02638           // nothing to do
02639           break ;
02640         }
02641         
02642       }
02643 
02644       if (P_action->m_string_expr->m_nb_portion == 3) {
02645         if( (P_action->m_string_expr->m_portions[0].m_type != E_STR_COUNTER)  ||
02646             (P_action->m_string_expr->m_portions[1].m_type != E_STR_STATIC)  ||
02647             (P_action->m_string_expr->m_portions[2].m_type != E_STR_COUNTER)  ) {
02648           GEN_ERROR(E_GEN_FATAL_ERROR, 
02649                     "One counter, one string value and one counter are allowed for this kind of field :" << 
02650                     "[counter;counter] ");
02651           L_ret = -1 ;
02652           break ;
02653         } else {
02654           L_search = P_action->m_string_expr->m_portions[1].m_data.m_value;
02655           L_status = regcomp (&L_regExpr, "[[:blank:]]*[;][[:blank:]]*", REG_EXTENDED) ;
02656           if (L_status != 0 ) {
02657             regerror(L_status, &L_regExpr, L_buffer, 1024);
02658             regfree (&L_regExpr) ;
02659             GEN_ERROR(E_GEN_FATAL_ERROR, 
02660                       "One counter, one string value and one counter are allowed for this kind of field :" << 
02661                       "[counter;counter] ");
02662             L_ret = -1 ;
02663             break ;
02664           }   
02665           L_status = regexec (&L_regExpr, L_search, 1, &L_pmatch, 0) ;
02666           regfree (&L_regExpr) ;
02667           if ((L_status != 0 ) || (L_pmatch.rm_eo != (int )strlen(L_search)) || (L_pmatch.rm_so != 0)) { 
02668             GEN_ERROR(E_GEN_FATAL_ERROR, 
02669                       "One counter, one string value and one counter are allowed for this kind of field :" << 
02670                       "[counter;counter] ");
02671             L_ret = -1 ;
02672             break ;
02673           }
02674         }
02675       }
02676     }
02677       
02678       break ;
02679       
02680       
02681     default:
02682       GEN_ERROR(E_GEN_FATAL_ERROR, "Unsupported type for expression");
02683       L_ret = -1 ;
02684       break ;
02685     }
02686   } else {
02687     GEN_ERROR(E_GEN_FATAL_ERROR, "Action type incorrect");
02688   }
02689   
02690 
02691   return (L_ret) ;
02692   
02693 }
02694 
02695 T_pC_Scenario C_ScenarioControl::init_scenario_defined (T_pTrafficType P_type) {
02696   *P_type = m_init_type ;
02697   return (m_init_scen);
02698 }
02699 
02700 
02701 int C_ScenarioControl::check_memory (char *P_mem_name) {
02702 
02703   int L_mem_id = -1 ;
02704   T_MemoryIdMap::iterator
02705     L_it = m_memory_map->find (T_MemoryIdMap::key_type(P_mem_name)) ;
02706 
02707 
02708   if (L_it != m_memory_map->end()) {
02709     L_mem_id = L_it->second ;
02710   }
02711 
02712   return (L_mem_id) ;
02713 
02714 }
02715 
02716 
02717 int C_ScenarioControl::add_memory (char *P_mem_name) {
02718 
02719   int L_mem_id = check_memory (P_mem_name) ;
02720 
02721   if (L_mem_id == -1) {
02722     L_mem_id = m_memory_max ;
02723     m_memory_map->insert(T_MemoryIdMap::value_type(P_mem_name, L_mem_id));
02724     m_memory_max++;
02725   }
02726 
02727   return (L_mem_id) ;
02728 
02729 }
02730 
02731 
02732 void C_ScenarioControl::switch_to_init () {
02733   GEN_DEBUG(1, "C_ScenarioControl::switch_to_init() start");
02734   if (m_init_scen != NULL) {
02735     m_save_traffic_scen = m_traffic_scen ;
02736     m_traffic_scen = m_init_scen ;
02737   }
02738   GEN_DEBUG(1, "C_ScenarioControl::switch_to_init() m_trafiic_scen is " << m_traffic_scen);
02739   GEN_DEBUG(1, "C_ScenarioControl::switch_to_init() end");
02740 }
02741 
02742 void C_ScenarioControl::switch_to_traffic() {
02743   if (m_save_traffic_scen != NULL) {
02744     m_traffic_scen = m_save_traffic_scen ;
02745     m_save_traffic_scen = NULL ;
02746   }
02747 }
02748 
02749 
02750 void C_ScenarioControl::set_config (C_GeneratorConfig *P_config) {
02751   m_config = P_config ;
02752 }
02753 
02754 T_pWaitValuesSet C_ScenarioControl::get_wait_values() {
02755   return (m_wait_values);
02756 }
02757 
02758 
02759 T_pRetransDelayValuesSet C_ScenarioControl::get_retrans_delay_values () {
02760   return (m_retrans_delay_values);
02761 }
02762 
02763 void  C_ScenarioControl::update_retrans_delay_cmd (size_t P_nb, 
02764                                                    unsigned long *P_table) {
02765 
02766   int L_i ;
02767   if (m_abort_scen != NULL) {
02768     m_abort_scen -> update_retrans_delay_cmd (P_nb, P_table);
02769   }
02770   if (m_traffic_scen != NULL) {
02771     m_traffic_scen -> update_retrans_delay_cmd (P_nb, P_table);
02772   }
02773   if (m_save_traffic_scen != NULL) {
02774     m_save_traffic_scen -> update_retrans_delay_cmd(P_nb, P_table);
02775   }
02776   if (m_init_scen != NULL) {
02777     m_init_scen -> update_retrans_delay_cmd (P_nb, P_table);
02778   }
02779   if (m_nb_default != 0) {
02780     for(L_i=0; L_i < m_nb_default; L_i++) {
02781       m_default_scen[L_i] -> update_retrans_delay_cmd (P_nb, P_table);
02782     }
02783   }
02784 }
02785 
02786 
02787 void  C_ScenarioControl::update_wait_cmd (size_t P_nb, 
02788                                           unsigned long *P_table) {
02789 
02790   int L_i ;
02791   if (m_abort_scen != NULL) {
02792     m_abort_scen -> update_wait_cmd (P_nb, P_table);
02793   }
02794   if (m_traffic_scen != NULL) {
02795     m_traffic_scen -> update_wait_cmd (P_nb, P_table);
02796   }
02797   if (m_save_traffic_scen != NULL) {
02798     m_save_traffic_scen -> update_wait_cmd (P_nb, P_table);
02799   }
02800   if (m_init_scen != NULL) {
02801     m_init_scen -> update_wait_cmd (P_nb, P_table);
02802   }
02803   if (m_nb_default != 0) {
02804     for(L_i=0; L_i < m_nb_default; L_i++) {
02805       m_default_scen[L_i] -> update_wait_cmd (P_nb, P_table);
02806     }
02807   }
02808   
02809 }
02810 
02811 bool C_ScenarioControl::fromXml (C_XmlData     *P_data, 
02812                                  bool           P_check_msg,
02813                                  bool          *P_data_mesure,
02814                                  T_pTrafficType P_traffic_type,
02815                                  bool          *P_action_check_abort) {
02816   
02817   bool L_XmlOk = true ;
02818 
02819   C_XmlData               *L_data  = P_data ;
02820   T_pXmlData_List          L_subList, L_subscen ;
02821   T_XmlData_List::iterator L_subListIt, L_subscen_it ;
02822   C_XmlData               *L_scen_data ;
02823 
02824   C_XmlData               *L_xml_traffic_scen = NULL ;
02825   C_XmlData               *L_xml_init_scen    = NULL ;
02826   C_XmlData               *L_xml_abort_scen   = NULL ;
02827   list_t<C_XmlData*>       L_xml_default_scen ;
02828   list_t<C_XmlData*>::iterator     L_default_it ;
02829   C_XmlData                       *L_current_default_scen = NULL ;
02830 
02831 
02832   int                      L_nb_open ;
02833   T_TrafficType            L_trafficType, L_initTrafficType ;
02834   T_TrafficType            L_scenarioTrafType ;
02835   
02836   if (L_data != NULL) {
02837 
02838     L_subList = L_data->get_sub_data() ;
02839 
02840     for(L_subListIt  = L_subList->begin() ;
02841         L_subListIt != L_subList->end() ;
02842         L_subListIt++) {
02843 
02844       L_data = *L_subListIt ;
02845 
02846       if (strcmp(L_data->get_name(), XML_SCENARIO_SECTION)==0) {
02847         
02848         // multi-scenarii management 
02849         L_subscen = L_data->get_sub_data() ;
02850         if (L_subscen != NULL) {
02851           for (L_subscen_it = L_subscen->begin();
02852                L_subscen_it != L_subscen->end();
02853                L_subscen_it++) {
02854             L_scen_data = *L_subscen_it ;
02855 
02856             if (strcmp (L_scen_data->get_name(), 
02857                         XML_SCENARIO_TRAFFIC_SECTION) == 0) {
02858               if (L_xml_traffic_scen == NULL) {
02859                 L_xml_traffic_scen = L_scen_data;
02860               } else {
02861                 GEN_ERROR(E_GEN_FATAL_ERROR,
02862                       "One traffic scenario allowed");
02863                 L_XmlOk = false ;
02864               }
02865             } else if (strcmp (L_scen_data->get_name(), 
02866                                XML_SCENARIO_DEFAULT_SECTION) == 0) {
02867               L_xml_default_scen.push_back(L_scen_data);
02868             } else if (strcmp (L_scen_data->get_name(), 
02869                                XML_SCENARIO_INIT_SECTION) == 0) {
02870               if (L_xml_init_scen == NULL) {
02871                 L_xml_init_scen = L_scen_data;
02872               } else {
02873                 GEN_ERROR(E_GEN_FATAL_ERROR,
02874                       "One init scenario allowed");
02875                 L_XmlOk = false ;
02876               }
02877             } else if (strcmp (L_scen_data->get_name(), 
02878                                XML_SCENARIO_ABORT_SECTION) == 0) {
02879               if (L_xml_abort_scen == NULL) {
02880                 L_xml_abort_scen = L_scen_data;
02881               } else {
02882                 GEN_ERROR(E_GEN_FATAL_ERROR,
02883                       "One abort scenario allowed");
02884                 L_XmlOk = false ;
02885               }
02886             } else if (strcmp (L_scen_data->get_name(), 
02887                                XML_SCENARIO_COUNTER_SECTION) == 0) {
02888               L_XmlOk = set_counters (L_scen_data);
02889             } else {
02890               GEN_ERROR(E_GEN_FATAL_ERROR, "Unkown section ["
02891                     << L_scen_data->get_name() 
02892                     << "] while traffic, init or default is expected");
02893                 L_XmlOk = false ;
02894             }
02895             if (L_XmlOk == false) break ;
02896           }
02897         }
02898       }
02899     }
02900 
02901     if (L_XmlOk == true) {
02902       if (L_xml_traffic_scen == NULL) {
02903         GEN_ERROR(E_GEN_FATAL_ERROR, 
02904                   "Section [scenario] with [traffic] is mandatory");
02905         L_XmlOk = false ;
02906       }
02907     }
02908 
02909     // add scenario traffic (mandatory)
02910     if(L_XmlOk == true) {
02911       if (add_scenario (E_SCENARIO_TRAFFIC, 
02912                         L_xml_traffic_scen,
02913                         &L_trafficType,
02914                         &L_nb_open,
02915                         P_data_mesure,
02916                         P_check_msg) == 0) {
02917         L_scenarioTrafType = L_trafficType ;
02918         *P_traffic_type = L_scenarioTrafType ;
02919         GEN_DEBUG(1, "L_trafficType [" << L_trafficType << "]");
02920         switch (L_trafficType) {
02921         case E_TRAFFIC_CLIENT:
02922           C_GeneratorStats::instance()->info_msg((char*)"Outgoing traffic");
02923           break ;
02924         case E_TRAFFIC_SERVER:
02925           C_GeneratorStats::instance()->info_msg((char*)"Incomming traffic");
02926           break ;
02927         default:
02928           break ;
02929         }
02930       } else {
02931         GEN_ERROR(E_GEN_FATAL_ERROR, "Traffic scenario error");
02932         L_XmlOk = false ;
02933       }
02934     }
02935 
02936 
02937     // add scenario init if defined
02938     if(L_XmlOk == true) {
02939       if (L_xml_init_scen != NULL) {
02940         if (add_scenario (E_SCENARIO_INIT, 
02941                           L_xml_init_scen,
02942                           &L_initTrafficType,
02943                           &L_nb_open, P_data_mesure) != 0) {
02944           GEN_ERROR(E_GEN_FATAL_ERROR, "Init scenario error");
02945           L_XmlOk = false ;
02946         } else {
02947           if (L_initTrafficType != L_trafficType) {
02948             GEN_ERROR(E_GEN_FATAL_ERROR, 
02949                       "Traffic scenario and Init scenario must be"
02950                       << " of the same type (client or server)");
02951             L_XmlOk = false ;
02952           } 
02953         }
02954       }
02955     }
02956 
02957 
02958     // add abort scenario if defined
02959     if (L_XmlOk == true) {
02960       if (L_xml_abort_scen != NULL) {
02961         if (add_scenario (E_SCENARIO_ABORT, 
02962                           L_xml_abort_scen,
02963                           &L_trafficType,
02964                           &L_nb_open, P_data_mesure) != 0) {
02965           GEN_ERROR(E_GEN_FATAL_ERROR, "Abort scenario error");
02966           L_XmlOk = false ;
02967         }
02968       }
02969     }
02970 
02971 
02972     if (L_XmlOk == true) {
02973       if ((m_abort_scen == NULL) && 
02974           (m_action_check_abort == true) && 
02975           (m_config->get_execute_check_action() == true)
02976           ) {
02977         *P_action_check_abort = true ;
02978       }
02979     }
02980 
02981 
02982     // add default scenarii if defined
02983     if (L_XmlOk == true) {
02984       set_default_scenarii (L_xml_default_scen.size());
02985       if (m_max_default != 0) {
02986         for (L_default_it  = L_xml_default_scen.begin();
02987              L_default_it != L_xml_default_scen.end () ;
02988              L_default_it++) {
02989           L_current_default_scen = *L_default_it ;
02990           if (add_scenario (E_SCENARIO_DEFAULT, 
02991                             L_current_default_scen,
02992                             &L_trafficType,
02993                             &L_nb_open, P_data_mesure) != 0) {
02994             GEN_ERROR(E_GEN_FATAL_ERROR, "Default scenario error");
02995             L_XmlOk = false ;
02996             break ;
02997           } 
02998         }
02999       }
03000     }
03001 
03002   } else {
03003     L_XmlOk = false ;
03004   }
03005 
03006 
03007 
03008   return (L_XmlOk);
03009 
03010 }
03011 
03012 bool C_ScenarioControl::set_counters (C_XmlData *P_xml_counter_def) {
03013 
03014   C_XmlData                      *L_data ;
03015   T_XmlData_List::iterator        L_listIt ;
03016   T_pXmlData_List                 L_subList ;
03017   char                           *L_value, *L_value_init ;
03018   bool                            L_ret = true ;
03019   unsigned long                   L_init    ;
03020 
03021   list_t<T_pCounterDef>           L_counter_list ;
03022   list_t<T_pCounterDef>::iterator L_counter_it ;
03023   T_pCounterDef                   L_counter ;
03024   int                             L_id = 0 ;
03025   T_CounterMap::iterator          L_counter_m_it ;
03026   
03027   GEN_DEBUG(1, "C_ScenarioControl::set_counters() start");
03028 
03029   L_subList = P_xml_counter_def->get_sub_data() ;
03030 
03031   for(L_listIt  = L_subList->begin() ;
03032       L_listIt != L_subList->end() ;
03033       L_listIt++) {
03034 
03035     L_data = *L_listIt ;
03036     L_value = L_data->get_name() ;
03037 
03038     if (strcmp(L_value, (char*)"counterdef") == 0) {
03039       char *L_endstr ;
03040 
03041       L_value = L_data->find_value((char*)"name") ;
03042       if (L_value == NULL) {
03043         GEN_ERROR(E_GEN_FATAL_ERROR, "counterdef name value is mandatory");
03044         L_ret = false ;
03045         break ;
03046       }
03047       L_counter_m_it = m_counter_map->find(T_CounterMap::key_type(L_value));
03048       if (L_counter_m_it != m_counter_map->end()) {
03049         GEN_ERROR(E_GEN_FATAL_ERROR, "counter name ["
03050                   << L_value << "] already defined");
03051         L_ret = false ;
03052         break ;
03053       }
03054       L_value_init = L_data->find_value((char*)"init") ;
03055       if (L_value_init == NULL) {
03056         GEN_ERROR(E_GEN_FATAL_ERROR, 
03057               "counterdef init value is mandatory ["
03058               << L_value << "]");
03059         L_ret = false ;
03060         break ;
03061       } else {
03062         L_init = strtoul_f (L_value_init, &L_endstr,10) ;
03063         if (L_endstr[0] != '\0') {
03064           GEN_ERROR(E_GEN_FATAL_ERROR, "Bad format for value ["
03065                 << L_value_init << "]");
03066           L_ret = false ;
03067           break ;
03068         }
03069       }
03070 
03071       if (L_ret == true) {
03072         ALLOC_VAR(L_counter, T_pCounterDef, sizeof(T_CounterDef));
03073         L_counter->m_id = L_id ;
03074         L_id ++ ;
03075         L_counter->m_name = L_value ;
03076         L_counter->m_init = L_init ;
03077         L_counter->m_value = L_counter->m_init ;
03078         L_counter_list.push_back(L_counter);
03079         m_counter_map->insert(T_CounterMap::value_type(L_value, L_counter));
03080       }
03081     }
03082   }
03083 
03084   if (!L_counter_list.empty()) {
03085     if (L_ret == true) {
03086       m_nb_counter = L_counter_list.size();
03087       ALLOC_TABLE(m_counter_table,
03088                   T_pCounterDef*,
03089                   sizeof(T_pCounterDef),
03090                   m_nb_counter);
03091       for (L_counter_it = L_counter_list.begin();
03092            L_counter_it != L_counter_list.end();
03093            L_counter_it ++) {
03094         L_counter = *L_counter_it ;
03095         m_counter_table[L_counter->m_id] = L_counter ;
03096       }
03097     } else {
03098       for (L_counter_it = L_counter_list.begin();
03099            L_counter_it != L_counter_list.end();
03100            L_counter_it ++) {
03101         L_counter = *L_counter_it ;
03102         FREE_VAR(L_counter);
03103       }
03104     }
03105     L_counter_list.erase(L_counter_list.begin(), 
03106                          L_counter_list.end());
03107   }
03108 
03109   
03110 
03111   GEN_DEBUG(1, "C_ScenarioControl::set_counters() return " << L_ret);
03112   
03113   return (L_ret);
03114 }
03115 
03116 T_UnsignedInteger32 C_ScenarioControl::get_counter_value (int P_id) {
03117   return (m_counter_table[P_id]->m_value);
03118 }
03119 
03120 void          C_ScenarioControl::increase_counter  (int P_id) {
03121   (m_counter_table[P_id]->m_value)++;
03122 }
03123 
03124 int           C_ScenarioControl::get_counter_id (char *P_name) {
03125   int                    L_id = -1 ;
03126   T_CounterMap::iterator L_counter_m_it ;
03127 
03128   L_counter_m_it = m_counter_map->find(T_CounterMap::key_type(P_name));
03129   if (L_counter_m_it != m_counter_map->end()) {
03130     L_id = (L_counter_m_it->second)->m_id ;
03131   }
03132 
03133   return (L_id);
03134 }
03135 
03136 bool C_ScenarioControl::external_data_used() {
03137   return (m_external_data_used);
03138 }
03139 
03140 int C_ScenarioControl::check_channel_usage (T_pTrafficType P_channelUsageTable,
03141                                             int            P_primary_channel_id,
03142                                             int            P_nb_channel) {
03143   int L_ret = 0 ;
03144   int L_i ;
03145   T_TrafficType L_traffic_type = E_TRAFFIC_UNKNOWN;
03146 
03147   if (P_primary_channel_id != -1) {
03148     L_traffic_type = P_channelUsageTable[P_primary_channel_id];
03149   } else {
03150     L_ret = -1 ;
03151   }
03152     
03153   if (L_ret != -1) {
03154 
03155     for (L_i = 0; L_i < P_nb_channel; L_i++) {
03156       if (L_i != P_primary_channel_id) {
03157         switch (L_traffic_type) {
03158         case E_TRAFFIC_CLIENT:
03159           L_ret = (P_channelUsageTable[L_i] == E_TRAFFIC_SERVER) ? -1 : 0 ;
03160           if (L_ret == -1) {
03161             GEN_ERROR(E_GEN_FATAL_ERROR, "The primary channel is in send mode");
03162             GEN_ERROR(E_GEN_FATAL_ERROR, "No receive mode possible for secondary channel(s)");
03163           }
03164           break ;
03165         case E_TRAFFIC_SERVER:
03166           L_ret = (P_channelUsageTable[L_i] == E_TRAFFIC_SERVER) ? -1 : 0 ;
03167           if (L_ret == -1) {
03168             GEN_ERROR(E_GEN_FATAL_ERROR, "The primary channel is in receive mode");
03169             GEN_ERROR(E_GEN_FATAL_ERROR, "No receive mode possible for secondary channel(s)");
03170           }
03171           break ;
03172         default:
03173           L_ret = -1 ;
03174           break ;
03175         }
03176       }
03177       if (L_ret == -1) break ;
03178     }
03179     
03180   }
03181 
03182   return (L_ret) ;
03183 }
03184 
03185 int C_ScenarioControl::get_nb_scenario () {
03186   return (m_nb_scenario);
03187 }
03188 
03189 
03190 int C_ScenarioControl::get_nb_default_scenario () {
03191   return (m_nb_default);
03192 }
03193 
03194 int C_ScenarioControl::get_max_nb_retrans () {
03195 
03196   int L_i ;
03197   int L_res = 0 ;
03198   int L_max = 0 ;
03199   if (m_abort_scen != NULL) {
03200     L_res = m_abort_scen->get_nb_retrans ();
03201   }
03202   if (L_res > L_max) { L_max = L_res ; }
03203   if (m_traffic_scen != NULL) {
03204     L_res = m_traffic_scen->get_nb_retrans();
03205   }
03206   if (L_res > L_max) { L_max = L_res ; }
03207   if (m_save_traffic_scen != NULL) {
03208     L_res = m_save_traffic_scen->get_nb_retrans();
03209   }
03210   if (L_res > L_max) { L_max = L_res ; }
03211   if (m_init_scen != NULL) {
03212     L_res = m_init_scen->get_nb_retrans () ;
03213   }
03214   if (L_res > L_max) { L_max = L_res ; }
03215   if (m_nb_default != 0) {
03216     for(L_i=0; L_i < m_nb_default ; L_i++) {
03217       L_res = m_default_scen[L_i]->get_nb_retrans();
03218       if (L_res > L_max) { L_max = L_res ; }
03219     }
03220   }
03221 
03222   return (L_max);
03223 }
03224 
03225 
03226 
03227 int C_ScenarioControl::get_max_nb_send () {
03228 
03229   int L_i ;
03230   int L_res = 0 ;
03231   int L_max = 0 ;
03232   if (m_abort_scen != NULL) {
03233     L_res = m_abort_scen->get_nb_send_per_scen ();
03234   }
03235   if (L_res > L_max) { L_max = L_res ; }
03236   if (m_traffic_scen != NULL) {
03237     L_res = m_traffic_scen->get_nb_send_per_scen();
03238   }
03239   if (L_res > L_max) { L_max = L_res ; }
03240   if (m_save_traffic_scen != NULL) {
03241     L_res = m_save_traffic_scen->get_nb_send_per_scen();
03242   }
03243   if (L_res > L_max) { L_max = L_res ; }
03244   if (m_init_scen != NULL) {
03245     L_res = m_init_scen->get_nb_send_per_scen () ;
03246   }
03247   if (L_res > L_max) { L_max = L_res ; }
03248   if (m_nb_default != 0) {
03249     for(L_i=0; L_i < m_nb_default ; L_i++) {
03250       L_res = m_default_scen[L_i]->get_nb_send_per_scen();
03251       if (L_res > L_max) { L_max = L_res ; }
03252     }
03253   }
03254 
03255   return (L_max);
03256 }
03257 
03258 
03259 int C_ScenarioControl::get_max_nb_recv () {
03260 
03261   int L_i ;
03262   int L_res = 0 ;
03263   int L_max = 0 ;
03264   if (m_abort_scen != NULL) {
03265     L_res = m_abort_scen->get_nb_recv_per_scen ();
03266   }
03267   if (L_res > L_max) { L_max = L_res ; }
03268   if (m_traffic_scen != NULL) {
03269     L_res = m_traffic_scen->get_nb_recv_per_scen();
03270   }
03271   if (L_res > L_max) { L_max = L_res ; }
03272   if (m_save_traffic_scen != NULL) {
03273     L_res = m_save_traffic_scen->get_nb_recv_per_scen();
03274   }
03275   if (L_res > L_max) { L_max = L_res ; }
03276   if (m_init_scen != NULL) {
03277     L_res = m_init_scen->get_nb_recv_per_scen () ;
03278   }
03279   if (L_res > L_max) { L_max = L_res ; }
03280   if (m_nb_default != 0) {
03281     for(L_i=0; L_i < m_nb_default ; L_i++) {
03282       L_res = m_default_scen[L_i]->get_nb_recv_per_scen();
03283       if (L_res > L_max) { L_max = L_res ; }
03284     }
03285   }
03286 
03287   return (L_max);
03288 }
03289 
03290 

Generated on Wed Mar 7 14:44:58 2007 for Seagull by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002