template <class T_TIndexCommand> C_CommandLine<T_TIndexCommand>::~C_CommandLine() {
  f_command_description = NULL ;
  f_noHelpIndex         = true ;
  f_internalHelpCode    = -1   ;
  FREE_VAR (f_programName);
  FREE_VAR (f_option_flags);
}
C_ChannelControl::~C_ChannelControl() {

  int L_i ;

  GEN_DEBUG(1, "C_ChannelControl::~C_ChannelControl() start");
  if (!m_name_map->empty()) {
    m_name_map->erase(m_name_map->begin(), m_name_map->end());
  }
  DELETE_VAR(m_name_map);
  if (m_channel_table_size != 0) {
    for (L_i = 0 ; L_i < m_channel_table_size; L_i++) {
      FREE_VAR(m_channel_table[L_i]);
    }
    FREE_TABLE(m_channel_table);
    m_channel_table_size = 0 ;
  }
  DELETE_VAR(m_id_gen) ;
  m_nb_global_channel = 0 ;
  FREE_TABLE(m_channel_to_ctxt_table);
  FREE_TABLE(m_ctxt_to_channel_table);
  m_nb_transport = 0 ;
  FREE_TABLE(m_transport_table);
  DELETE_VAR(m_sem_reconnect);
  GEN_DEBUG(1, "C_ChannelControl::~C_ChannelControl() end");
}
void wait_thread_control_end (pthread_t *P_thread) {

  void *L_return ;
  pthread_join (*P_thread, &L_return);

  // Delete thread
  FREE_VAR(P_thread);
}
bool C_ProtocolControl::fromXml (C_XmlData *P_data,
				 T_pConfigValueList P_config_value_list,
				 bool               P_display_protocol_stats) {
  
  bool                          L_ret       = true   ;
  T_pXmlData_List               L_subList            ;
  T_XmlData_List::iterator      L_subListIt          ;
  C_XmlData                    *L_data               ;
  char                         *L_protocol_name, 
                               *L_protocol_type      ;
  int                           L_protocol_id        ;
  T_ProtocolInstList            L_protocol_inst_list ;
  T_pProtocolInstanceInfo       L_protocol_info      ;
  T_ProtocolInstList::iterator  L_it                 ;

  

  GEN_DEBUG(1, "C_ProtocolControl::fromXml() start");
  if (P_data != NULL) {
    if ((L_subList = P_data->get_sub_data()) != NULL) {
      for (L_subListIt = L_subList->begin() ;
	   L_subListIt != L_subList->end() ;
	   L_subListIt++) {

	L_data = *L_subListIt ;

	if (L_data != NULL) {
	  if (strcmp(L_data->get_name(), XML_PROTOCOL_SECTION) == 0) {
	    // protocol section definition found
	    L_protocol_name = get_protocol_name (L_data) ;
	    // check protocol type for creation
	    L_protocol_type = get_protocol_type (L_data) ;
	    
	    // check name/type presence
	    if (L_protocol_name == NULL) {
	      GEN_ERROR(E_GEN_FATAL_ERROR, 
			"name mandatory for section " << XML_PROTOCOL_SECTION);
	      L_ret = false ;
	      break ;
	    }
	    if (L_protocol_type == NULL) {
	      GEN_ERROR(E_GEN_FATAL_ERROR, 
			"type mandatory for section " << XML_PROTOCOL_SECTION);
	      L_ret = false ;
	      break ;
	    }

	    // check protocol name unicity
	    if (m_name_map->find(T_ProtocolNameMap::key_type(L_protocol_name)) 
		!= m_name_map->end()) {
	      GEN_ERROR(E_GEN_FATAL_ERROR, 
		        XML_PROTOCOL_SECTION << " with name ["
			<< L_protocol_name << "] already defined");
	      L_ret = false ;
	      break ;
	    }

	    // check protocol type or sub type
	    if (strcmp(L_protocol_type, "binary") == 0) {
	      // create protocol instance
	      
	      C_ProtocolBinary    *L_protocol_instance = NULL ;
	      T_ConstructorResult  L_res ;

	      NEW_VAR(L_protocol_instance,
		      C_ProtocolBinary());
              
              L_protocol_instance->construction_data(L_data, &L_protocol_name, &L_res) ;

	      if (L_res != E_CONSTRUCTOR_OK) {
		GEN_ERROR(E_GEN_FATAL_ERROR,
			  "Error found in protocol definition");
		DELETE_VAR(L_protocol_instance);
		L_ret = false ;
		break ;
	      } else {
		// store new instance
		if (P_display_protocol_stats == true) {
		  C_ProtocolStats  *L_protocol_stats ;
		  NEW_VAR(L_protocol_stats,C_ProtocolStats(L_protocol_instance));
		  L_protocol_instance->set_stats(L_protocol_stats);
		}

		L_protocol_id = m_id_gen->new_id() ;
		ALLOC_VAR(L_protocol_info,
			  T_pProtocolInstanceInfo,
			  sizeof(T_ProtocolInstanceInfo));

		L_protocol_info->m_instance = L_protocol_instance ;
		L_protocol_info->m_id = L_protocol_id ;
		L_protocol_info->m_name = L_protocol_name ;
		L_protocol_inst_list.push_back(L_protocol_info);
		m_name_map
		  ->insert(T_ProtocolNameMap::value_type(L_protocol_name,
							 L_protocol_id)) ;
	      }
	    } else if (strcmp(L_protocol_type, "binary-tlv") == 0) {
	      // create protocol instance
	      C_ProtocolTlv    *L_protocol_instance = NULL ;
	      T_ConstructorResult  L_res ;

	      NEW_VAR(L_protocol_instance,
		      C_ProtocolTlv());
              
              L_protocol_instance->construction_data(L_data, &L_protocol_name, &L_res) ;
              
	      if (L_res != E_CONSTRUCTOR_OK) {
		GEN_ERROR(E_GEN_FATAL_ERROR,
			  "Error found in protocol definition");
		DELETE_VAR(L_protocol_instance);
		L_ret = false ;
		break ;
	      } else {
		// store new instance
		if (P_display_protocol_stats == true) {
		  C_ProtocolStats  *L_protocol_stats ;
		  NEW_VAR(L_protocol_stats,C_ProtocolStats(L_protocol_instance));
		  L_protocol_instance->set_stats(L_protocol_stats);
		}
                
		L_protocol_id = m_id_gen->new_id() ;
		ALLOC_VAR(L_protocol_info,
			  T_pProtocolInstanceInfo,
			  sizeof(T_ProtocolInstanceInfo));
                
		L_protocol_info->m_instance = L_protocol_instance ;
		L_protocol_info->m_id = L_protocol_id ;
		L_protocol_info->m_name = L_protocol_name ;
		L_protocol_inst_list.push_back(L_protocol_info);
		m_name_map
		  ->insert(T_ProtocolNameMap::value_type(L_protocol_name,
							 L_protocol_id)) ;
	      }
	    } else if (strcmp(L_protocol_type, "binary-body-not-interpreted") == 0) {
	      // create protocol instance
	      C_ProtocolBinaryBodyNotInterpreted    *L_protocol_instance = NULL ;

	      T_ConstructorResult  L_res ;


	      NEW_VAR(L_protocol_instance,
		      C_ProtocolBinaryBodyNotInterpreted());
              
              L_protocol_instance->construction_data(L_data, &L_protocol_name, &L_res) ;
              
	      if (L_res != E_CONSTRUCTOR_OK) {
		GEN_ERROR(E_GEN_FATAL_ERROR,
			  "Error found in protocol definition");
		DELETE_VAR(L_protocol_instance);
		L_ret = false ;
		break ;
	      } else {
		// store new instance
		if (P_display_protocol_stats == true) {
		  C_ProtocolStats  *L_protocol_stats ;
		  NEW_VAR(L_protocol_stats,C_ProtocolStats(L_protocol_instance));
		  L_protocol_instance->set_stats(L_protocol_stats);
		}
                
		L_protocol_id = m_id_gen->new_id() ;
		ALLOC_VAR(L_protocol_info,
			  T_pProtocolInstanceInfo,
			  sizeof(T_ProtocolInstanceInfo));
                
		L_protocol_info->m_instance = L_protocol_instance ;
		L_protocol_info->m_id = L_protocol_id ;
		L_protocol_info->m_name = L_protocol_name ;
		L_protocol_inst_list.push_back(L_protocol_info);
		m_name_map
		  ->insert(T_ProtocolNameMap::value_type(L_protocol_name,
							 L_protocol_id)) ;
	      }

	    } else if (strcmp(L_protocol_type, "binary-separator") == 0) {

	      // create protocol instance
	      C_ProtocolBinarySeparator    *L_protocol_instance = NULL ;

	      T_ConstructorResult  L_res ;


	      NEW_VAR(L_protocol_instance,
		      C_ProtocolBinarySeparator());
              
              L_protocol_instance
		->construction_data(L_data, &L_protocol_name, &L_res) ;
              
	      if (L_res != E_CONSTRUCTOR_OK) {
		GEN_ERROR(E_GEN_FATAL_ERROR,
			  "Error found in protocol definition");
		DELETE_VAR(L_protocol_instance);
		L_ret = false ;
		break ;
	      } else {
		// store new instance
		if (P_display_protocol_stats == true) {
		  C_ProtocolStats  *L_protocol_stats ;
		  NEW_VAR(L_protocol_stats,C_ProtocolStats(L_protocol_instance));
		  L_protocol_instance->set_stats(L_protocol_stats);
		}
                
		L_protocol_id = m_id_gen->new_id() ;
		ALLOC_VAR(L_protocol_info,
			  T_pProtocolInstanceInfo,
			  sizeof(T_ProtocolInstanceInfo));
                
		L_protocol_info->m_instance = L_protocol_instance ;
		L_protocol_info->m_id = L_protocol_id ;
		L_protocol_info->m_name = L_protocol_name ;
		L_protocol_inst_list.push_back(L_protocol_info);
		m_name_map
		  ->insert(T_ProtocolNameMap::value_type(L_protocol_name,
							 L_protocol_id)) ;
	      }
	    } else if (strcmp(L_protocol_type, "external-library") == 0) {
              
	      C_ProtocolExternal    *L_protocol_instance = NULL ;
	      T_ConstructorResult    L_res = E_CONSTRUCTOR_OK ;
	      NEW_VAR(L_protocol_instance,
		      C_ProtocolExternal(m_transport_control, 
					 L_data, &L_protocol_name, 
					 P_config_value_list,
					 &L_res));

	      if (L_res != E_CONSTRUCTOR_OK) {
		GEN_ERROR(E_GEN_FATAL_ERROR,
			  "Error found in protocol definition");
		DELETE_VAR(L_protocol_instance);
		L_ret = false ;
		break ;
	      } else {

		if (P_display_protocol_stats == true) {
		  C_ProtocolStats  *L_protocol_stats ;
		  NEW_VAR(L_protocol_stats,C_ProtocolStats(L_protocol_instance));
		  L_protocol_instance->set_stats(L_protocol_stats);
		}

		// store new instance
		L_protocol_id = m_id_gen->new_id() ;
		ALLOC_VAR(L_protocol_info,
			  T_pProtocolInstanceInfo,
			  sizeof(T_ProtocolInstanceInfo));

		L_protocol_info->m_instance = L_protocol_instance ;
		L_protocol_info->m_id = L_protocol_id ;
		L_protocol_info->m_name = L_protocol_name ;
		L_protocol_inst_list.push_back(L_protocol_info);
		m_name_map
		  ->insert(T_ProtocolNameMap::value_type(L_protocol_name,
							 L_protocol_id)) ;
	      }
	    }  else if (strcmp(L_protocol_type, "text") == 0) {
              
	      C_ProtocolText    *L_protocol_instance = NULL ;
	      T_ConstructorResult    L_res = E_CONSTRUCTOR_OK ;

	      NEW_VAR(L_protocol_instance,
		      C_ProtocolText());
              
              L_protocol_instance->analyze_data(L_data, 
                                                &L_protocol_name, 
                                                P_config_value_list,
                                                &L_res);

            if (L_res != E_CONSTRUCTOR_OK) {
		GEN_ERROR(E_GEN_FATAL_ERROR,
			  "Error found in protocol definition");
		DELETE_VAR(L_protocol_instance);
		L_ret = false ;
		break ;
	      } else {

		if (P_display_protocol_stats == true) {
		  C_ProtocolStats  *L_protocol_stats ;
		  NEW_VAR(L_protocol_stats,C_ProtocolStats(L_protocol_instance));
		  L_protocol_instance->set_stats(L_protocol_stats);
		}

		// store new instance
		L_protocol_id = m_id_gen->new_id() ;
		ALLOC_VAR(L_protocol_info,
			  T_pProtocolInstanceInfo,
			  sizeof(T_ProtocolInstanceInfo));

		L_protocol_info->m_instance = L_protocol_instance ;
		L_protocol_info->m_id = L_protocol_id ;
		L_protocol_info->m_name = L_protocol_name ;
		L_protocol_inst_list.push_back(L_protocol_info);
		m_name_map
		  ->insert(T_ProtocolNameMap::value_type(L_protocol_name,
							 L_protocol_id)) ;
	      }
	    } else {
	      GEN_ERROR(E_GEN_FATAL_ERROR,
		        XML_PROTOCOL_SECTION 
			<< " [" 
			<< L_protocol_name
			<< "] with type ["
			<< L_protocol_type << "] unsupported");
	      L_ret = false ;
	    }
	  }
	}
      }
      if (L_ret != false) {
	if (!L_protocol_inst_list.empty()) {
	  m_protocol_table_size = L_protocol_inst_list.size() ;
	  ALLOC_TABLE(m_protocol_table,
		      T_pC_ProtocolFrame*,
		      sizeof(T_pC_ProtocolFrame),
		      m_protocol_table_size) ;
	  ALLOC_TABLE(m_protocol_name_table,
		      char**,
		      sizeof(char*),
		      m_protocol_table_size) ;
	  for (L_it  = L_protocol_inst_list.begin();
	       L_it != L_protocol_inst_list.end()  ;
	       L_it++) {
	    L_protocol_info = *L_it ;
	    m_protocol_table[L_protocol_info->m_id] 
	      = L_protocol_info->m_instance ;
	    m_protocol_name_table[L_protocol_info->m_id]
	      = L_protocol_info->m_name ;
	  }
	} else {
	  GEN_ERROR(E_GEN_FATAL_ERROR,
		    "No protocol definition found"); 
	  L_ret = false ;
	}
      } // if L_ret != false 
      
      if (!L_protocol_inst_list.empty()) {
	  for (L_it  = L_protocol_inst_list.begin();
	       L_it != L_protocol_inst_list.end()  ;
	       L_it++) {
	    FREE_VAR(*L_it);
	  }
	  L_protocol_inst_list.erase(L_protocol_inst_list.begin(),
				     L_protocol_inst_list.end());
      }
    } 
예제 #5
0
C_Semaphore::~C_Semaphore() {
  GEN_DEBUG(0,"C_Semaphore::~C_Semaphore() start");
  destroy () ;
  FREE_VAR (m_impl) ;
  GEN_DEBUG(0,"C_Semaphore::~C_Semaphore() end");
}
예제 #6
0
/* Returns: DRBG_SUCCESS or DRBG_FAILURE */
static int Hash_gen(DRBG* drbg, byte* out, word32 outSz, const byte* V)
{
    int ret = DRBG_FAILURE;
    byte data[DRBG_SEED_LEN];
    int i;
    int len;
    word32 checkBlock;
    Sha256 sha;
    DECLARE_VAR(digest, byte, SHA256_DIGEST_SIZE, drbg->heap);

    /* Special case: outSz is 0 and out is NULL. wc_Generate a block to save for
     * the continuous test. */

    if (outSz == 0) outSz = 1;

    len = (outSz / OUTPUT_BLOCK_LEN) + ((outSz % OUTPUT_BLOCK_LEN) ? 1 : 0);

    XMEMCPY(data, V, sizeof(data));
    for (i = 0; i < len; i++) {
    #ifdef WOLFSSL_ASYNC_CRYPT
        ret = wc_InitSha256_ex(&sha, drbg->heap, drbg->devId);
    #else
        ret = wc_InitSha256(&sha);
    #endif
        if (ret == 0)
            ret = wc_Sha256Update(&sha, data, sizeof(data));
        if (ret == 0)
            ret = wc_Sha256Final(&sha, digest);
        wc_Sha256Free(&sha);

        if (ret == 0) {
            XMEMCPY(&checkBlock, digest, sizeof(word32));
            if (drbg->reseedCtr > 1 && checkBlock == drbg->lastBlock) {
                if (drbg->matchCount == 1) {
                    return DRBG_CONT_FAILURE;
                }
                else {
                    if (i == len) {
                        len++;
                    }
                    drbg->matchCount = 1;
                }
            }
            else {
                drbg->matchCount = 0;
                drbg->lastBlock = checkBlock;
            }

            if (out != NULL && outSz != 0) {
                if (outSz >= OUTPUT_BLOCK_LEN) {
                    XMEMCPY(out, digest, OUTPUT_BLOCK_LEN);
                    outSz -= OUTPUT_BLOCK_LEN;
                    out += OUTPUT_BLOCK_LEN;
                    array_add_one(data, DRBG_SEED_LEN);
                }
                else {
                    XMEMCPY(out, digest, outSz);
                    outSz = 0;
                }
            }
        }
    }
    ForceZero(data, sizeof(data));

    FREE_VAR(digest, drbg->heap);

    return (ret == 0) ? DRBG_SUCCESS : DRBG_FAILURE;
}
예제 #7
0
/* Returns: DRBG_SUCCESS or DRBG_FAILURE */
static int Hash_df(DRBG* drbg, byte* out, word32 outSz, byte type,
                                                  const byte* inA, word32 inASz,
                                                  const byte* inB, word32 inBSz)
{
    int ret = DRBG_FAILURE;
    byte ctr;
    int i;
    int len;
    word32 bits = (outSz * 8); /* reverse byte order */
    Sha256 sha;
    DECLARE_VAR(digest, byte, SHA256_DIGEST_SIZE, drbg->heap);

    (void)drbg;
#ifdef WOLFSSL_ASYNC_CRYPT
    if (digest == NULL)
        return DRBG_FAILURE;
#endif

#ifdef LITTLE_ENDIAN_ORDER
    bits = ByteReverseWord32(bits);
#endif
    len = (outSz / OUTPUT_BLOCK_LEN)
        + ((outSz % OUTPUT_BLOCK_LEN) ? 1 : 0);

    for (i = 0, ctr = 1; i < len; i++, ctr++) {
    #ifdef WOLFSSL_ASYNC_CRYPT
        ret = wc_InitSha256_ex(&sha, drbg->heap, drbg->devId);
    #else
        ret = wc_InitSha256(&sha);
    #endif
        if (ret != 0)
            break;

        if (ret == 0)
            ret = wc_Sha256Update(&sha, &ctr, sizeof(ctr));
        if (ret == 0)
            ret = wc_Sha256Update(&sha, (byte*)&bits, sizeof(bits));

        if (ret == 0) {
            /* churning V is the only string that doesn't have the type added */
            if (type != drbgInitV)
                ret = wc_Sha256Update(&sha, &type, sizeof(type));
        }
        if (ret == 0)
            ret = wc_Sha256Update(&sha, inA, inASz);
        if (ret == 0) {
            if (inB != NULL && inBSz > 0)
                ret = wc_Sha256Update(&sha, inB, inBSz);
        }
        if (ret == 0)
            ret = wc_Sha256Final(&sha, digest);

        wc_Sha256Free(&sha);
        if (ret == 0) {
            if (outSz > OUTPUT_BLOCK_LEN) {
                XMEMCPY(out, digest, OUTPUT_BLOCK_LEN);
                outSz -= OUTPUT_BLOCK_LEN;
                out += OUTPUT_BLOCK_LEN;
            }
            else {
                XMEMCPY(out, digest, outSz);
            }
        }
    }

    ForceZero(digest, SHA256_DIGEST_SIZE);

    FREE_VAR(digest, drbg->heap);

    return (ret == 0) ? DRBG_SUCCESS : DRBG_FAILURE;
}
int         C_GeneratorConfig::analyze_protocol_stat(char          *P_logProtocolStat,
						     T_charPlist   *P_protocol_list,
						     bool           *P_all_found) {
  regex_t                 *L_regExpr = NULL   ;
  regmatch_t               L_pmatch           ;

  char                    *L_search  = NULL   ;
  char                     L_buffer[100]      ;
  char                    *L_search_begin     ;
  char                    *L_search_end       ;
  char                    *L_string  = NULL   ;

  int                      L_status           ;
  int                      L_size             ;
  int                      L_ret      = 0     ;

  int                      L_result   = 0     ;

  ALLOC_VAR(L_regExpr, regex_t*, sizeof(regex_t));

  L_status = regcomp (L_regExpr, "[^;][^;]*[;]*", REG_EXTENDED) ;

  if (L_status != 0) {
    regerror(L_status, L_regExpr, L_buffer, 100);
    regfree (L_regExpr) ;
    FREE_VAR(L_regExpr);
    GEN_ERROR(E_GEN_FATAL_ERROR, "regcomp error: [" << L_buffer << "]");
    L_result = -1 ;
  } else {
    L_search = P_logProtocolStat ;
    do {
      L_status = regexec (L_regExpr, L_search, 1, &L_pmatch, 0) ;
      
      // matching is OK
      if (L_status == 0) {
	L_ret  = L_pmatch.rm_eo ;
	L_size = (L_pmatch.rm_eo - L_pmatch.rm_so) ;
	
	L_search_begin = L_search ;
	L_search_end = L_search + L_size - 1 ;
	
	while (L_search_end[0] == ';') L_search_end--;
	while (L_search_end[0] == ' ') L_search_end--;

	L_size = L_search_end - L_search + 1 ;

	while(isspace(*L_search_begin)) {
	  L_search_begin++;
	  L_size--;
	}

	if (L_size > 0) {
	  ALLOC_TABLE(L_string, char*, sizeof(char), L_size+1);
	  snprintf(L_string, L_size, "%s", L_search_begin);
	  L_string[L_size] = 0 ;
	  if (strcmp(L_string, (char*)"all") == 0) {
	    (*P_all_found) = true ;	    
	    break;
	  }
	  P_protocol_list ->push_back(L_string) ;
	}
 
	L_search += L_ret ;	

	if (L_search[0] == '\0') break ;
	
      } else {
bool C_ChannelControl::fromXml (C_XmlData *P_data, 
				C_ProtocolControl  *P_protocol_ctrl,
				C_TransportControl *P_transport_ctrl) {
  
  bool                          L_ret       = true   ;
  T_pXmlData_List               L_sectionList, L_subSectionList            ;
  T_XmlData_List::iterator      L_sectionListIt, L_subSectionListIt ;
  C_XmlData                    *L_section, *L_subSection ;
  char                         *L_entity_value ;
  char                         *L_name, 
                               *L_open_args,
                               *L_transport_name,
                               *L_protocol_name ,
                               *L_reconnect;
  int                           L_channel_id ;
  T_ChannelType                 L_channel_type ;
  T_pChannelInfo                L_channel_info = NULL ;
  T_ChannelInfoList             L_channel_info_list ;
  T_ChannelInfoList::iterator   L_it ;
  T_pChannelData                L_data ;

  GEN_DEBUG(1, "C_ChannelControl::fromXml() start");

  if (P_data != NULL) {
    if ((L_sectionList = P_data->get_sub_data()) != NULL) {
      
      for(L_sectionListIt  = L_sectionList->begin() ;
	  L_sectionListIt != L_sectionList->end() ;
	  L_sectionListIt++) {

	L_section = *L_sectionListIt ;
	if (L_section != NULL) {
	  if (strcmp(L_section->get_name(), XML_CHANNEL_SECTION) == 0) {

	    L_subSectionList = L_section->get_sub_data() ;
	    for(L_subSectionListIt  = L_subSectionList->begin() ;
		L_subSectionListIt != L_subSectionList->end() ;
		L_subSectionListIt++) {
	      L_subSection = *L_subSectionListIt ;
	      
	      if (strcmp(L_subSection->get_name(), XML_CHANNEL_SUBSECTION) == 0) {

		L_entity_value = L_subSection->find_value(XML_CHANNEL_ENTITY) ;
		if (L_entity_value != NULL) {
		  if (strcmp(L_entity_value, XML_CHANNEL_ENTITY_VALUE) == 0) {

		    L_name = L_subSection->find_value(XML_CHANNEL_NAME); 
		    if (L_name == NULL) {
		      GEN_ERROR(E_GEN_FATAL_ERROR, "[" 
				<< L_name << "] value is mandatory for section ["
				<< XML_CHANNEL_SECTION << "], sub section ["
				<< XML_CHANNEL_SUBSECTION << "]");
		      L_ret = false ;
		      break ;
		    }

		    L_open_args = L_subSection->find_value(XML_CHANNEL_OPEN);
		    if (L_open_args == NULL) {
		      GEN_ERROR(E_GEN_FATAL_ERROR, "[" 
				<< L_open_args << "] value is mandatory for section ["
				<< XML_CHANNEL_SECTION << "], sub section ["
				<< XML_CHANNEL_SUBSECTION << "]");
		      L_ret = false ;
		      break ;
		    }
		    L_protocol_name = L_subSection->find_value(XML_CHANNEL_PROTOCOL);
		    if (L_protocol_name == NULL) {
		      GEN_ERROR(E_GEN_FATAL_ERROR, "[" 
				<< L_protocol_name << "] value is mandatory for section ["
				<< XML_CHANNEL_SECTION << "], sub section ["
				<< XML_CHANNEL_SUBSECTION << "]");
		      L_ret = false ;
		      break ;
		    }

		    L_reconnect = L_subSection->find_value(XML_CHANNEL_RECONNECT);

		    L_transport_name = L_subSection->find_value(XML_CHANNEL_TRANSPORT);
		    if (L_transport_name == NULL) {
		      GEN_ERROR(E_GEN_FATAL_ERROR, "[" 
				<< L_transport_name << "] value is mandatory for section ["
				<< XML_CHANNEL_SECTION << "], sub section ["
				<< XML_CHANNEL_SUBSECTION << "]");
		      L_ret = false ;
		      break ;
		    }
		    if (L_subSection->find_value(XML_CHANNEL_GLOBAL) != NULL) {
		      if (strcmp(L_subSection->find_value(XML_CHANNEL_GLOBAL), XML_CHANNEL_GLOBAL_VALUE) == 0) {
			L_channel_type = E_CHANNEL_GLOBAL ;
		      } else {
			L_channel_type = E_CHANNEL_LOCAL ;
		      }
		    } else {
		      L_channel_type = E_CHANNEL_GLOBAL ;
		    }

		    // check channel name unicity
		    if (m_name_map->find(T_ChannelNameMap::key_type(L_name)) 
			!= m_name_map->end()) {
		      GEN_ERROR(E_GEN_FATAL_ERROR, 
				XML_CHANNEL_SECTION << " with name ["
				<< L_name << "] already defined");
		      L_ret = false ;
		      break ;
		    }

		    // check transport and protocol definition
		    if (P_protocol_ctrl->get_protocol_id(L_protocol_name) 
			== ERROR_PROTOCOL_UNKNOWN) {
		      GEN_ERROR(E_GEN_FATAL_ERROR, 
				"Protocol ["
				<< L_protocol_name << "] unknown for channel ["
				<< L_name << "]");
		      L_ret = false ;
		      break ;
		    }
		    if (P_transport_ctrl->get_transport_id(L_transport_name) 
			== ERROR_TRANSPORT_UNKNOWN) {
		      GEN_ERROR(E_GEN_FATAL_ERROR, 
				"Transport ["
				<< L_transport_name << "] unknown for channel ["
				<< L_name << "]");
		      L_ret = false ;
		      break ;
		    }
		    
		    L_channel_id = m_id_gen->new_id() ;
		    ALLOC_VAR(L_channel_info,
			      T_pChannelInfo,
			      sizeof(T_ChannelInfo));

		    L_channel_info->m_id = L_channel_id ;
		    L_channel_info->m_open_args = L_open_args ;
		    L_channel_info->m_protocol_name = L_protocol_name ; 
		    L_channel_info->m_transport_name = L_transport_name ; 
		    L_channel_info->m_type = L_channel_type ;
		    L_channel_info->m_name = L_name ;
		    L_channel_info->m_reconnect = L_reconnect ;
		    L_channel_info_list.push_back(L_channel_info);
		    m_name_map
		      ->insert(T_TransportNameMap::value_type(L_name,
							      L_channel_id)) ;
		    
		  }

		}
		
	      }

	    }

	  }
	}
      }

      if (L_ret != false) {
	if (!L_channel_info_list.empty()) {
	  m_channel_table_size = L_channel_info_list.size () ;
	  ALLOC_TABLE(m_channel_table,
		      T_pChannelData*,
		      sizeof(T_pChannelData),
		      m_channel_table_size);
	  for (L_it  = L_channel_info_list.begin();
	       L_it != L_channel_info_list.end()  ;
	       L_it++) {
	    L_channel_info = *L_it ;
	    ALLOC_VAR(m_channel_table[L_channel_info->m_id], 
		      T_pChannelData, 
		      sizeof(T_ChannelData));
	    L_data = m_channel_table[L_channel_info->m_id] ;

	    L_data->m_id = L_channel_info->m_id ;
	    L_data->m_type = L_channel_info->m_type ;
	    L_data->m_protocol_id = P_protocol_ctrl->get_protocol_id(L_channel_info->m_protocol_name) ;
	    L_data->m_transport_id = P_transport_ctrl->get_transport_id(L_channel_info->m_transport_name) ;
	    L_data->m_protocol = P_protocol_ctrl->get_protocol(L_channel_info->m_protocol_name) ;
	    L_data->m_transport = P_transport_ctrl->get_transport(L_channel_info->m_transport_name) ;
	    L_data->m_open_args = L_channel_info->m_open_args ;
	    L_data->m_open_status = E_CHANNEL_CLOSED ;

	    L_data->m_reconnect = (L_channel_info->m_reconnect == NULL) ?
	      false : (strcmp(L_channel_info->m_reconnect, "yes") == 0) ;

	    if (L_data->m_reconnect == true) { m_reconnect = true ; }

	    L_data->m_name = L_channel_info->m_name ;

	    if (L_data->m_type == E_CHANNEL_GLOBAL) {
	      m_nb_global_channel++ ;
	    }

	  }
	} else {
	  GEN_ERROR(E_GEN_FATAL_ERROR,
		    "No channel definition found");
	  L_ret = false ;
	}
      }

      if (!L_channel_info_list.empty()) {
	for (L_it  = L_channel_info_list.begin();
	     L_it != L_channel_info_list.end()  ;
	     L_it++) {
	  if (L_ret == false) { // error
	    if (m_channel_table_size > 0) {
	      L_channel_info = *L_it ;
	      FREE_VAR(m_channel_table[L_channel_info->m_id]);
	    }
	  }
	  FREE_VAR(*L_it);
	}
	L_channel_info_list.erase(L_channel_info_list.begin(),
				    L_channel_info_list.end());
      }

      if (L_ret == false) {
	// delete structures
	if (m_channel_table_size > 0) {
	  FREE_TABLE(m_channel_table);
	  m_channel_table_size = 0 ;
	}
      }
    }