|
Public Types |
typedef enum C_ProtocolTlv::_enum_msg_id_type | T_MsgIdType |
typedef enum C_ProtocolTlv::_enum_msg_id_type * | T_pMsgIdType |
typedef C_ProtocolTlv::_cond_value | T_CondPresence |
typedef C_ProtocolTlv::_cond_value * | T_pCondPresence |
typedef map_t< string_t, int > | T_IdMap |
typedef map_t< string_t, int > * | T_pIdMap |
typedef map_t< unsigned long,
int > | T_DecodeMap |
typedef map_t< unsigned long,
int > * | T_pDecodeMap |
typedef C_ProtocolTlv::_struct_header_field | T_HeaderField |
typedef C_ProtocolTlv::_struct_header_field * | T_pHeaderField |
typedef C_ProtocolTlv::_struct_header_value | T_HeaderValue |
typedef C_ProtocolTlv::_struct_header_value * | T_pHeaderValue |
typedef C_ProtocolTlv::_struct_header_body_value | T_HeaderBodyValue |
typedef C_ProtocolTlv::_struct_header_body_value * | T_pHeaderBodyValue |
typedef C_ProtocolTlv::_struct_protocol_counter_data | T_ProtocolCounterData |
typedef C_ProtocolTlv::_struct_protocol_counter_data * | T_pProtocolCounterData |
typedef list_t< T_ProtocolCounterData > | T_ProtocolCounterDataList |
typedef list_t< T_ProtocolCounterData > * | T_pProtocolCounterDataList |
typedef C_ProtocolTlv::_struct_body_value | T_BodyValue |
typedef C_ProtocolTlv::_struct_body_value * | T_pBodyValue |
typedef C_ProtocolTlv::_struct_body_def | T_BodyValueDef |
typedef C_ProtocolTlv::_struct_body_def * | T_pBodyValueDef |
typedef C_ProtocolTlv::_struct_management_session_id | T_ManagementSessionId |
typedef C_ProtocolTlv::_struct_management_session_id * | T_pManagementSessionId |
typedef list_t< T_ManagementSessionId > | T_ManagementSessionIdList |
typedef list_t< T_ManagementSessionId > * | T_pManagementSessionIdList |
typedef C_ProtocolTlv::_struct_update_ctxt_value | T_UpdateCtxtValue |
typedef C_ProtocolTlv::_struct_update_ctxt_value * | T_pUpdateCtxtValue |
typedef C_ProtocolTlv::_struct_update_ctxt_position | T_UpdateCtxtPosition |
typedef C_ProtocolTlv::_struct_update_ctxt_position * | T_pUpdateCtxtPosition |
enum | _enum_msg_id_type { E_MSG_ID_HEADER = 0,
E_MSG_ID_BODY
} |
Public Member Functions |
| C_ProtocolTlv () |
virtual void | construction_data (C_XmlData *P_def, char **P_name, T_pContructorResult P_res) |
| ~C_ProtocolTlv () |
virtual C_MessageFrame * | decode_message (unsigned char *P_buffer, size_t *P_size, C_ProtocolFrame::T_pMsgError P_error) |
C_ProtocolFrame::T_MsgError | encode_message (C_MessageFrame *P_msg, unsigned char *P_buffer, size_t *P_buffer_size) |
virtual C_MessageFrame * | create_new_message (C_MessageFrame *P_msg) |
virtual C_MessageFrame * | create_new_message (void *P_xml, T_pInstanceDataList P_list, int *P_nb_value) |
char * | message_name () |
char * | message_component_name () |
T_pNameAndIdList | message_name_list () |
T_pNameAndIdList | message_component_name_list () |
char * | message_name (int P_headerId) |
void | log_buffer (char *P_header, unsigned char *P_buf, size_t P_size) |
int | find_field (char *P_name) |
T_TypeType | get_field_type (int P_id, int P_sub_id) |
bool | check_sub_entity_needed (int P_id) |
int | retrieve_field_id (int P_id, T_pMsgIdType P_type) |
void | update_stats (T_ProtocolStatDataType P_type, T_ProtocolStatDataAction P_action, int P_id) |
T_MsgIdType | get_msg_id_type () |
int | get_msg_id () |
T_TypeType | get_msg_id_value_type () |
T_MsgIdType | get_out_of_session_id_type () |
int | get_out_of_session_id () |
int | get_header_type_id_body () |
int | get_header_type_id () |
int | get_header_length_id () |
int | get_header_length_index () |
unsigned long | get_nb_field_header () |
unsigned long | get_header_size () |
T_pHeaderField | get_header_field_description (int P_id) |
T_pHeaderField | get_header_field_description (char *P_name) |
T_pHeaderValue | get_header_value_description (int P_id) |
T_pTypeDef | get_type_description (int P_id) |
T_pTypeDef | get_type_description (char *P_name) |
int | get_header_body_type_id () |
int | get_header_body_length_id () |
int | get_header_body_length_index () |
unsigned long | get_nb_field_header_body () |
unsigned long | get_header_body_size () |
T_pHeaderField | get_header_body_field_description (int P_id) |
T_pHeaderField | get_header_body_field_description (char *P_name) |
T_pHeaderBodyValue | get_header_body_value_description (int P_id) |
unsigned long | get_m_max_nb_field_header () |
char * | get_header_name () |
char * | get_header_body_name () |
int | get_header_value_id (char *P_name) |
int | get_header_body_value_id (char *P_name) |
int | set_body_value (int P_id, char *P_value, int P_nb, T_pBodyValue P_res, bool *P_del=NULL) |
int | set_body_sub_value (int P_index, int P_id, char *P_value, T_pBodyValue P_res) |
void | set_body_value (T_pBodyValue P_res, T_pBodyValue P_val) |
void | delete_header_value (T_pValueData P_res) |
void | delete_body_value (T_pBodyValue P_res) |
void | reset_grouped_body_value (T_pBodyValue P_res) |
void | encode_header (int P_id, unsigned char *P_buf, size_t *P_size) |
void | encode_header (int P_id, T_pValueData P_headerVal, unsigned char *P_buf, size_t *P_size, C_ProtocolContext *P_ctxt_protocol, C_ProtocolFrame::T_pMsgError P_error) |
virtual C_ProtocolFrame::T_MsgError | encode_body (int P_nbVal, T_pBodyValue P_val, unsigned char *P_buf, size_t *P_size, C_ProtocolContext *P_ctxt_protocol) |
int | decode_header (unsigned char **P_buf, size_t P_size, T_pValueData P_valDec, int *P_headerId, C_ProtocolContext *P_ctxt_protocol) |
virtual int | decode_body (unsigned char **P_buf, T_pBodyValue P_valDec, int *P_nbValDec, int *P_headerId, C_ProtocolContext *P_ctxt_protocol) |
C_ProtocolContext * | create_protocol_context () |
void | delete_protocol_context (C_ProtocolContext **P_protocol_ctxt) |
void | reset_protocol_context (C_ProtocolContext *P_protocol_context) |
void | update_ctxt_values (C_ProtocolContext *P_protocol_context, unsigned char *P_buf_pos, int P_field_id, int P_size, T_pUpdateCtxtValue P_ctxt_id_v_table, T_pUpdateCtxtPosition P_ctxt_p_table) |
int | update_ctxt_values_decode (C_ProtocolContext *P_protocol_context, int P_field_id, int P_size, T_pUpdateCtxtValue P_ctxt_id_v_table) |
void | propagate_ctxt_global (C_ProtocolContext *P_protocol_context) |
int | find_header_field_id (char *P_name) |
int | find_header_body_id (char *P_name) |
int | find_body_value_id (char *P_name) |
void | get_header_values (int P_id, T_pValueData P_val) |
void | set_header_values (T_pValueData P_dest, T_pValueData P_orig) |
void | set_header_value (int P_id, T_pValueData P_dest, T_pValueData P_orig) |
void | set_body_values (int P_nb, T_pBodyValue P_dest, T_pBodyValue P_orig) |
void | reset_header_values (int P_nb, T_pValueData P_val) |
void | reset_body_values (int P_nb, T_pBodyValue P_val) |
void | get_body_values (int P_id, T_pBodyValue P_val, int *P_nbVal) |
virtual void | get_body_value (T_pValueData P_dest, T_pBodyValue P_orig) |
virtual void | set_body_value (T_pBodyValue P_dest, T_pValueData P_orig) |
virtual T_ManagementSessionId * | get_manage_session_elt (int P_id) |
virtual int | get_nb_management_session () |
virtual bool | check_present_session (int P_msg_id, int P_id) |
virtual bool | find_present_session (int P_msg_id, int P_id) |
iostream_output & | print_header (iostream_output &P_stream, int P_headerId, T_pValueData P_val) |
virtual iostream_output & | print_body (iostream_output &P_stream, int P_nb, T_pBodyValue P_val, int P_level=0) |
T_TypeType | get_body_value_type (int P_id) |
T_TypeType | get_header_value_type (int P_id) |
void | reset_value_data (T_pValueData P_val) |
void | convert_to_string (T_pValueData P_res, T_pValueData P_val) |
void | set_padding (unsigned long P_value) |
bool | get_header_length_excluded () |
unsigned long | get_msg_length_start () |
bool | get_msg_length_start_detected () |
bool | get_complex_header_presence () |
char * | get_header_body_field_separator () |
int | analyze_setfield (C_XmlData *P_data, int *P_fieldId, unsigned long *P_fieldValueUl) |
Protected Types |
typedef map_t< string_t, int > | T_LengthIdMap |
typedef map_t< string_t, int > * | T_pLengthIdMap |
typedef list_t< int > | T_IdCtxtList |
typedef list_t< int > * | T_pIdCtxtList |
Protected Member Functions |
int | update_ctxt_v_field (T_pUpdateCtxtValue P_ctxt_id_v_table, int P_nb_field, T_pProtocolCounterData P_ctxt_table, int P_nb_ctxt_table, T_pUpdateCtxtValue P_ctxt_global_v_table, int P_counter_last_id) |
int | ctrl_length (char *P_length_name, bool P_header) |
int | update_field_length (int P_length_id, int P_field_id, T_pProtocolCounterDataList P_length_list, bool P_header) |
void | propagate_ctxt_local (C_ProtocolContext *P_protocol_context, int P_id_begin, int P_id_end, T_pHeaderField P_field_table, T_pProtocolCounterData P_ctxt_table) |
void | update_ctxt_length (C_ProtocolContext *P_protocol_context, unsigned long P_valueSize) |
int | update_ctxt_length_decode (C_ProtocolContext *P_protocol_context, unsigned long P_data_size) |
int | add_length (char *P_length_name) |
int | check_length (char *P_length_name) |
char * | is_variable (char *P_varibleString) |
int | add_counter_id (char *P_value_string, bool P_header) |
int | add_counter (char *P_name, unsigned long P_init) |
int | add_type (char *P_name, T_TypeType P_type, unsigned long P_size) |
int | add_header_field (char *P_name, unsigned long P_size, unsigned long *P_nb_field, unsigned long *P_header_size, T_pHeaderField P_field_table, T_pIdMap P_map, int P_counter_id=-1, T_pCondPresence P_condPresence=NULL, long P_type_id=-1) |
void | set_header_type_id (int P_id) |
void | set_header_length_id (int P_id) |
void | set_header_body_type_id (int P_id) |
void | set_header_body_length_id (int P_id) |
int | get_header_from_xml (C_XmlData *P_def) |
int | get_types_from_xml (C_XmlData *P_def) |
virtual int | xml_interpretor (C_XmlData *P_def) |
virtual int | analyze_header_from_xml (C_XmlData *P_def) |
virtual int | analyze_types_from_xml (C_XmlData *P_def) |
virtual int | analyze_body_from_xml (C_XmlData *P_def) |
int | analyze_dictionnary_from_xml (C_XmlData *P_def) |
virtual int | analyze_sessions_id_from_xml (C_XmlData *P_def) |
virtual int | get_header_body_values_from_xml (C_XmlData *P_def) |
virtual int | get_header_values_from_xml (C_XmlData *P_def) |
int | get_header_body_from_xml (C_XmlData *P_def) |
int | get_header_body_optional_from_xml (C_XmlData *P_def) |
int | get_counter_from_xml (C_XmlData *P_def) |
bool | check_presence_needed (T_pCondPresence P_condition, unsigned long *P_values) |
int | process_grouped_type (C_XmlData *P_bodyData, int P_body_grouped_val_id, T_pBodyValue P_pBodyVal) |
Protected Attributes |
T_pLengthIdMap | m_length_map |
int | m_length_max |
int | m_nb_protocol_ctxt_values |
T_pUpdateCtxtValue | m_header_ctxt_v_table |
T_pUpdateCtxtValue | m_header_body_ctxt_v_table |
T_pUpdateCtxtPosition | m_header_ctxt_p_table |
T_pUpdateCtxtPosition | m_header_body_ctxt_p_table |
char * | m_header_name |
T_pHeaderField | m_header_field_table |
T_pIdMap | m_header_id_map |
char * | m_header_type_name |
int | m_header_type_id_body |
int | m_header_type_id |
int | m_header_length_id |
int | m_header_length_index |
unsigned long | m_nb_field_header |
unsigned long | m_max_nb_field_header |
unsigned long | m_header_size |
int | m_transport_type |
unsigned long | m_msg_length_start |
bool | m_msg_length_start_detected |
T_pProtocolCounterData | m_header_length_table |
int | m_nb_header_length_table |
int | m_nb_header_length |
int | m_counter_id_last_length |
int | m_ctxt_id_data_size |
T_pProtocolCounterData | m_header_body_length_table |
int | m_nb_header_body_length_table |
int | m_nb_header_body_length |
char * | m_header_body_name |
T_pHeaderField | m_header_body_field_table |
T_pIdMap | m_header_body_id_map |
int | m_header_body_type_id |
int | m_header_body_length_id |
int | m_header_body_length_index |
unsigned long | m_nb_field_header_body |
unsigned long | m_max_nb_field_header_body |
unsigned long | m_header_body_size |
int | m_header_body_start_optional_id |
bool | m_header_complex_type_presence |
T_pNameAndIdList | m_message_name_list |
T_pNameAndIdList | m_message_comp_name_list |
char * | m_header_body_field_separator |
int | m_session_id_position |
T_pTypeDef | m_type_def_table |
unsigned long | m_nb_types |
unsigned long | m_max_nb_types |
T_pIdMap | m_type_id_map |
unsigned long | m_nb_header_values |
T_pHeaderValue | m_header_value_table |
T_pIdMap | m_header_value_id_map |
T_pDecodeMap | m_header_decode_map |
T_pBodyValueDef | m_body_value_table |
unsigned long | m_nb_header_body_values |
T_pHeaderBodyValue | m_header_body_value_table |
T_pIdMap | m_header_body_value_id_map |
T_pDecodeMap | m_header_body_decode_map |
T_MsgIdType | m_msg_id_type |
int | m_msg_id_id |
T_TypeType | m_msg_id_value_type |
T_MsgIdType | m_type_id_out_of_session |
int | m_id_out_of_session |
unsigned long | m_padding_value |
bool | m_header_length_excluded |
list_t< C_MessageFrame * > * | m_messageList |
Classes |
struct | _cond_value |
struct | _struct_body_def |
struct | _struct_body_value |
struct | _struct_header_body_value |
struct | _struct_header_field |
struct | _struct_header_value |
struct | _struct_management_session_id |
struct | _struct_protocol_counter_data |
struct | _struct_update_ctxt_position |
struct | _struct_update_ctxt_value |
|
Create a new message
Implements C_ProtocolFrame.
Definition at line 5276 of file C_ProtocolTlv.cpp.
References analyze_setfield(), delete_body_value(), C_XmlData::find_value(), get_body_value_type(), get_header_body_name(), get_header_body_value_id(), get_header_name(), get_header_value_id(), C_XmlData::get_name(), m_header_body_field_separator, C_ProtocolTlv::_struct_body_value::m_id, _struct_value::m_id, C_ProtocolTlv::_struct_body_value::m_sub_val, _struct_value::m_type, C_ProtocolTlv::_struct_body_value::m_value, _struct_value::m_value, process_grouped_type(), reset_grouped_body_value(), set_body_value(), C_MessageTlv::set_body_value(), C_MessageTlv::set_header_id_value(), and C_MessageTlv::set_header_value(). 05278 {
05279
05280
05281 C_XmlData *L_Xml = (C_XmlData*) P_xml ;
05282
05283 bool L_msgOk = true ;
05284
05285 C_MessageTlv *L_msg ;
05286 char *L_currentName ;
05287
05288
05289 C_ProtocolFrame::T_MsgError L_decode_result ;
05290
05291 unsigned char *L_buf ;
05292 size_t L_size ;
05293
05294 int L_header_val_id ;
05295 int L_body_val_id ;
05296
05297 GEN_DEBUG(1, "C_ProtocolTlv::create_new_message() start: xml");
05298
05299
05300 NEW_VAR(L_msg, C_MessageTlv(this));
05301
05302
05303
05304
05305
05306 L_currentName = L_Xml -> get_name () ;
05307
05308 GEN_DEBUG(1, "C_ProtocolTlv::create_new_message() msg xml name is "
05309 << L_currentName );
05310
05311 if (strcmp(L_currentName, (char*)"CDATA") == 0) {
05312
05313
05314
05315 L_currentName = L_Xml->find_value((char*)"value");
05316
05317 L_buf = convert_hexa_char_to_bin(L_currentName, &L_size);
05318 (void) L_msg -> decode(L_buf, L_size, &L_decode_result);
05319
05320
05321 if (L_decode_result != C_ProtocolFrame::E_MSG_OK) {
05322 GEN_ERROR(E_GEN_FATAL_ERROR,
05323 "Error while decoding direct data buffer ["
05324 << L_currentName << "]");
05325 L_msgOk = false ;
05326 }
05327
05328 } else if (strcmp(L_currentName, get_header_name()) == 0) {
05329
05330
05331 L_currentName = L_Xml -> find_value ((char*) "name") ;
05332 if (L_currentName == NULL) {
05333 GEN_ERROR(E_GEN_FATAL_ERROR,
05334 "name value is mandatory for ["
05335 << get_header_name()
05336 << "]");
05337 L_msgOk = false ;
05338 } else {
05339 GEN_DEBUG(1, "C_ProtocolTlv::create_new_message() "
05340 << "the name of this message is " << L_currentName );
05341
05342 L_header_val_id = get_header_value_id(L_currentName) ;
05343
05344 GEN_DEBUG(1, "C_ProtocolTlv::create_new_message() "
05345 << "L_header_val_id = " << L_header_val_id );
05346
05347 if (L_header_val_id == -1) {
05348 GEN_ERROR(E_GEN_FATAL_ERROR,
05349 "unknown name ["
05350 << L_currentName << "] for [" << get_header_name() << "]");
05351 L_msgOk = false ;
05352
05353 } else {
05354
05355
05356 T_pXmlData_List L_listBodyVal ;
05357 T_XmlData_List::iterator L_bodyValIt ;
05358 C_XmlData *L_bodyData ;
05359
05360 char *L_bodyName, *L_bodyValue ;
05361 C_ProtocolTlv::T_BodyValue L_bodyVal ;
05362 T_TypeType L_type ;
05363
05364 L_msg->set_header_id_value(L_header_val_id);
05365
05366 L_listBodyVal = L_Xml -> get_sub_data() ;
05367 if (L_listBodyVal != NULL) {
05368
05369 for (L_bodyValIt = L_listBodyVal->begin() ;
05370 L_bodyValIt != L_listBodyVal->end() ;
05371 L_bodyValIt++) {
05372 L_bodyData = *L_bodyValIt ;
05373
05374
05375
05376
05377
05378
05379
05380 if (strcmp(L_bodyData->get_name(),
05381 get_header_body_name())==0) {
05382
05383 L_bodyName = L_bodyData->find_value((char*)"name");
05384 if (L_bodyName == NULL) {
05385 GEN_ERROR(E_GEN_FATAL_ERROR,
05386 "name value is mandatory for ["
05387 << get_header_body_name()
05388 << "] definition");
05389 L_msgOk = false ;
05390 }
05391
05392 GEN_DEBUG(1, "C_ProtocolTlv::create_new_message() "
05393 << "L_bodyName is [" << L_bodyName << "]");
05394
05395 L_body_val_id = get_header_body_value_id(L_bodyName) ;
05396 if (L_body_val_id == -1) {
05397 GEN_ERROR(E_GEN_FATAL_ERROR,
05398 "No definition found for ["
05399 << L_bodyName << "]");
05400 L_msgOk = false ;
05401 break ;
05402 }
05403
05404 GEN_DEBUG(1, "C_ProtocolTlv::create_new_message() "
05405 << "L_body_val_id is "
05406 << L_body_val_id );
05407
05408 L_type = get_body_value_type (L_body_val_id) ;
05409 if (L_type
05410 == E_TYPE_GROUPED) {
05411
05412 GEN_DEBUG(1, "C_ProtocolTlv::create_new_message() "
05413 << L_bodyName << " is grouped element" );
05414
05415
05416 if (process_grouped_type(L_bodyData, L_body_val_id,
05417 &L_bodyVal) != 0) {
05418 GEN_ERROR(E_GEN_FATAL_ERROR,
05419 "Grouped Type processing Error for "
05420 << L_bodyName);
05421 L_msgOk = false ;
05422 break ;
05423 }
05424
05425
05426
05427 L_msg->set_body_value(&L_bodyVal);
05428
05429
05430 reset_grouped_body_value(&L_bodyVal);
05431 FREE_TABLE(L_bodyVal.m_sub_val);
05432 } else {
05433 bool L_toBeDelete = false;
05434
05435
05436 L_bodyValue = L_bodyData->find_value((char*)"value");
05437 if (L_bodyValue == NULL) {
05438 GEN_ERROR(E_GEN_FATAL_ERROR,
05439 "value is mandatory for ["
05440 << get_header_body_name()
05441 << "] definition");
05442 L_msgOk = false ;
05443 break ;
05444 }
05445
05446 GEN_DEBUG(1, "C_ProtocolTlv::create_new_message() "
05447 << "L_bodyValue is \"" << L_bodyValue << "\"" );
05448
05449 if (set_body_value(L_body_val_id,
05450 L_bodyValue,
05451 1,
05452 &L_bodyVal,
05453 &L_toBeDelete) == 0) {
05454
05455 if (m_header_body_field_separator == NULL) {
05456 L_msg->set_body_value(&L_bodyVal);
05457 } else {
05458 T_ValueData L_tmp_value ;
05459 bool L_exist ;
05460 L_tmp_value.m_value = L_bodyVal.m_value ;
05461 L_tmp_value.m_id = L_bodyVal.m_id ;
05462 L_tmp_value.m_type = L_type;
05463 L_exist = L_msg->set_body_value(L_body_val_id,&L_tmp_value);
05464 if (L_exist == false) {
05465 L_msg->set_body_value(&L_bodyVal);
05466 }
05467 }
05468
05469 if (L_toBeDelete) {
05470
05471 delete_body_value(&L_bodyVal);
05472 }
05473
05474 } else {
05475 GEN_ERROR(E_GEN_FATAL_ERROR,
05476 "Bad format for ["
05477 << L_bodyValue << "]");
05478 L_msgOk = false ;
05479 break ;
05480 }
05481 }
05482 } else if (strcmp(L_bodyData->get_name(),
05483 (char*)"setfield")==0) {
05484 unsigned long L_val_setfield = 0 ;
05485 int L_id_setfield = 0 ;
05486 L_msgOk = (analyze_setfield(L_bodyData, &L_id_setfield ,&L_val_setfield) == -1)
05487 ? false : true ;
05488 if (L_msgOk) {
05489 L_msg->set_header_value(L_id_setfield, L_val_setfield);
05490 }
05491
05492 } else {
05493 GEN_ERROR(E_GEN_FATAL_ERROR,
05494 "Unkown section ["
05495 << L_bodyData->get_name()
05496 << "]");
05497 L_msgOk = false;
05498 break ;
05499 }
05500 if (L_msgOk == false) break ;
05501 }
05502 }
05503 }
05504 }
05505 }
05506
05507
05508 if (L_msgOk == false) {
05509 DELETE_VAR(L_msg);
05510 } else {
05511
05512 m_messageList->push_back(L_msg);
05513 }
05514
05515 GEN_DEBUG(1, "C_ProtocolTlv::create_new_message() end: xml");
05516
05517 return (L_msg);
05518 }
|