00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "C_ProtocolBinaryBodyNotInterpreted.hpp"
00021 #include "C_MessageBinaryBodyNotInterpreted.hpp"
00022 #include "GeneratorError.h"
00023 #include "GeneratorTrace.hpp"
00024
00025 #include "BufferUtils.hpp"
00026
00027
00028 C_ProtocolBinaryBodyNotInterpreted::C_ProtocolBinaryBodyNotInterpreted
00029 () : C_ProtocolBinary() {
00030 m_field_present_table = NULL ;
00031 m_value_sessions_table = NULL ;
00032 }
00033
00034 C_ProtocolBinaryBodyNotInterpreted::~C_ProtocolBinaryBodyNotInterpreted() {
00035
00036 unsigned long L_j ;
00037
00038 if (m_field_present_table != NULL ) {
00039 for (L_j = 0; L_j < m_nb_header_values ; L_j++) {
00040 FREE_TABLE (m_field_present_table[L_j]);
00041 }
00042 FREE_TABLE (m_field_present_table) ;
00043 }
00044
00045 if (m_header_body_position_size_map != NULL) {
00046 if (!m_header_body_position_size_map->empty()) {
00047 m_header_body_position_size_map->erase(m_header_body_position_size_map->begin(),
00048 m_header_body_position_size_map->end());
00049 }
00050 }
00051 DELETE_VAR(m_header_body_position_size_map);
00052
00053 if (m_value_sessions_table_size != 0) {
00054 FREE_TABLE(m_value_sessions_table);
00055 m_value_sessions_table_size = 0 ;
00056 }
00057
00058 }
00059
00060 int C_ProtocolBinaryBodyNotInterpreted::get_header_body_values_from_xml (C_XmlData *P_def) {
00061
00062 int L_ret = 0 ;
00063 C_XmlData *L_data ;
00064 char *L_value, *L_name, *L_type, *L_endstr ;
00065 char *L_value_unit, *L_value_size, *L_value_position ;
00066 T_XmlData_List::iterator L_listIt ;
00067 T_pXmlData_List L_subListDefine ;
00068 int L_id ;
00069 T_IdMap::iterator L_IdMapIt ;
00070 int L_typeId ;
00071 int L_fieldDefCpt ;
00072
00073 unsigned long L_size ;
00074 unsigned long L_position ;
00075
00076 T_HeaderBodyPositionSize L_position_size ;
00077
00078
00079
00080 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::get_header_body_values_from_xml() start");
00081
00082
00083 m_nb_header_body_values++ ;
00084
00085 ALLOC_TABLE(m_header_body_value_table,
00086 T_pHeaderBodyValue,
00087 sizeof(T_HeaderBodyValue),
00088 m_nb_header_body_values);
00089
00090 L_id = 0 ;
00091 L_position = 0 ;
00092 L_typeId = 0 ;
00093 L_size = 0 ;
00094
00095 L_fieldDefCpt = 0;
00096 L_subListDefine = P_def->get_sub_data() ;
00097
00098
00099 m_header_body_value_id_map
00100 ->insert(T_IdMap::value_type((char*)"body", L_id));
00101
00102 m_header_body_value_table[L_id].m_id = L_id ;
00103 m_header_body_value_table[L_id].m_name = (char*)"body" ;
00104 m_header_body_value_table[L_id].m_type_id = L_typeId ;
00105 m_header_body_value_table[L_id].m_nb_set=0;
00106
00107 L_position_size.m_position = L_position ;
00108 L_position_size.m_size = L_size ;
00109
00110 m_header_body_decode_map
00111 ->insert(T_DecodeMap::value_type(L_position, L_id));
00112
00113
00114 m_header_body_position_size_map
00115 ->insert(T_HeaderBodyPositionSizeMap::value_type(L_id, L_position_size));
00116
00117
00118 L_id ++ ;
00119
00120 for(L_listIt = L_subListDefine->begin() ;
00121 L_listIt != L_subListDefine->end() ;
00122 L_listIt++, L_fieldDefCpt ++) {
00123
00124 L_position = 0 ;
00125 L_typeId = 0 ;
00126 L_size = 0 ;
00127
00128 L_data = *L_listIt ;
00129 L_value = L_data->get_name() ;
00130
00131 if (strcmp(L_value, (char*)"define") == 0) {
00132
00133 L_name = L_data->find_value((char*)"name") ;
00134 if (L_name == NULL) {
00135 GEN_ERROR(E_GEN_FATAL_ERROR, "define name value is mandatory");
00136 L_ret = -1 ;
00137 break ;
00138 }
00139
00140 L_type = L_data->find_value((char*)"type") ;
00141 if (L_type == NULL) {
00142 GEN_ERROR(E_GEN_FATAL_ERROR, "define type value is mandatory");
00143 L_ret = -1 ;
00144 break ;
00145 }
00146 L_IdMapIt =
00147 m_type_id_map->find(T_IdMap::key_type(L_type));
00148
00149 if (L_IdMapIt != m_type_id_map->end()) {
00150 L_typeId = L_IdMapIt->second ;
00151 } else {
00152 GEN_ERROR(E_GEN_FATAL_ERROR,
00153 "Type ["
00154 << L_type << "] not defined");
00155 L_ret = -1 ;
00156 break;
00157 }
00158
00159
00160 L_value_position = L_data->find_value((char*)"position") ;
00161 if (L_value_position == NULL) {
00162 GEN_ERROR(E_GEN_FATAL_ERROR, "define position value is mandatory");
00163 L_ret = -1 ;
00164 break ;
00165 }
00166
00167
00168 L_position = (int)strtoul_f (L_value_position, &L_endstr, 10);
00169 if (L_endstr[0] != '\0') {
00170 GEN_ERROR(E_GEN_FATAL_ERROR, "bad format, ["
00171 << L_value_position << "] not a number");
00172 L_ret = -1 ;
00173 break;
00174 }
00175
00176
00177 L_value_unit = L_data->find_value((char*)"unit") ;
00178 if (L_value_unit != NULL) {
00179 if (strcmp(L_value_unit, (char*)"octet") != 0) {
00180 GEN_ERROR(E_GEN_FATAL_ERROR, "Unsupported unit ["
00181 << L_value_unit << "] value on fielddef [" << L_fieldDefCpt << "] defintion");
00182 L_ret = -1 ;
00183 break;
00184 }
00185 }
00186
00187 L_value_size = L_data->find_value((char*)"size") ;
00188 if (L_value_size == NULL) {
00189 GEN_ERROR(E_GEN_FATAL_ERROR,
00190 "fielddef [" << L_fieldDefCpt << "] size value is mandatory ["
00191 << L_name << "]");
00192 L_ret = -1 ;
00193 break ;
00194 }
00195
00196 L_size = strtoul_f (L_value_size, &L_endstr,10) ;
00197 GEN_DEBUG(1, "C_ProtocolBinary::get_header_from_xml() field length ["
00198 << L_fieldDefCpt <<"] is " << L_size );
00199
00200 if (L_endstr[0] != '\0') {
00201 L_size = strtoul_f (L_value_size, &L_endstr,16) ;
00202 if (L_endstr[0] != '\0') {
00203 GEN_ERROR(E_GEN_FATAL_ERROR, "typedef size value ["
00204 << L_value_size
00205 << "] bad format on fielddef ["
00206 << L_fieldDefCpt << "] defintion");
00207 L_ret = -1 ;
00208 break ;
00209 }
00210 }
00211
00212 if (!((strcmp(L_type,(char*)"String") == 0 ) ||
00213 (strcmp(L_type,(char*)"string") == 0 ))) {
00214 if ( L_size > sizeof(unsigned long)) {
00215 GEN_ERROR(E_GEN_FATAL_ERROR, "fielddef ["
00216 << L_fieldDefCpt << "] max size value ["
00217 << sizeof(unsigned long) << "]");
00218 L_ret = -1 ;
00219 break ;
00220 }
00221 }
00222
00223 m_header_body_value_table[L_id].m_id = L_id ;
00224 m_header_body_value_table[L_id].m_name = L_name ;
00225 m_header_body_value_table[L_id].m_type_id = L_typeId ;
00226 m_header_body_value_table[L_id].m_nb_set=0;
00227
00228 L_position_size.m_position = L_position ;
00229 L_position_size.m_size = L_size ;
00230 if (L_ret != -1) {
00231 m_header_body_value_id_map
00232 ->insert(T_IdMap::value_type(L_name, L_id));
00233 m_header_body_decode_map
00234 ->insert(T_DecodeMap::value_type(L_position, L_id));
00235
00236 m_header_body_position_size_map
00237 ->insert(T_HeaderBodyPositionSizeMap::value_type(L_id, L_position_size));
00238
00239 L_id ++ ;
00240 }
00241 }
00242 if (L_ret == -1) break ;
00243 }
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260 GEN_DEBUG(1, "C_ProtocolBinary::get_header_body_values_from_xml() end");
00261
00262 return (L_ret);
00263 }
00264
00265
00266 int C_ProtocolBinaryBodyNotInterpreted::analyze_body_from_xml (C_XmlData *P_def) {
00267 int L_ret = -1 ;
00268 C_XmlData *L_data ;
00269
00270 T_pXmlData_List L_subListHeader ;
00271 T_XmlData_List::iterator L_listItHeader ;
00272
00273
00274 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::analyze_body_from_xml() start");
00275
00276 L_subListHeader = P_def->get_sub_data();
00277
00278 if (L_subListHeader != NULL) {
00279
00280 for (L_listItHeader = L_subListHeader->begin() ;
00281 L_listItHeader != L_subListHeader->end() ;
00282 L_listItHeader++) {
00283 L_data = *L_listItHeader ;
00284
00285 if ((L_data->get_name() != NULL ) && (strcmp(L_data->get_name(), (char*)"header") == 0)) {
00286 m_header_body_name = L_data->find_value((char*)"name");
00287 if (m_header_body_name == NULL) {
00288 GEN_ERROR(E_GEN_FATAL_ERROR,"header name value is mandatory");
00289 L_ret = -1 ;
00290 break;
00291 }
00292
00293 if (L_data->get_sub_data() != NULL) {
00294
00295 m_max_nb_field_header_body = (L_data->get_sub_data())->size() ;
00296 if (m_max_nb_field_header_body != 0 ) {
00297 GEN_ERROR(E_GEN_FATAL_ERROR,
00298 "boy not interpreted, you can't define header");
00299 L_ret = -1 ;
00300 break;
00301 }
00302 }
00303
00304 L_ret = 0 ;
00305 }
00306 }
00307 }
00308
00309 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::analyze_body_from_xml() end");
00310 return (L_ret) ;
00311 }
00312
00313
00314 int C_ProtocolBinaryBodyNotInterpreted::xml_interpretor(C_XmlData *P_def) {
00315
00316
00317 C_XmlData *L_data ;
00318 T_pXmlData_List L_subList ;
00319 T_XmlData_List::iterator L_listIt ;
00320 char *L_value ;
00321 int L_ret = 0 ;
00322 bool L_headerFound = false ;
00323
00324 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::xml_interpretor() start");
00325
00326
00327 m_nb_header_values = 0 ;
00328 m_header_value_table = NULL ;
00329 m_body_value_table = NULL ;
00330 NEW_VAR(m_header_value_id_map, T_IdMap());
00331 NEW_VAR(m_header_decode_map, T_DecodeMap());
00332 m_header_value_id_map->clear();
00333 m_header_decode_map->clear();
00334
00335 m_nb_header_body_values = 0 ;
00336 m_header_body_value_table = NULL ;
00337 NEW_VAR(m_header_body_value_id_map, T_IdMap());
00338 NEW_VAR(m_header_body_decode_map, T_DecodeMap());
00339 m_header_body_value_id_map->clear();
00340 m_header_body_decode_map->clear();
00341
00342 NEW_VAR(m_header_body_position_size_map, T_HeaderBodyPositionSizeMap());
00343 m_header_body_position_size_map->clear();
00344
00345 L_subList = P_def->get_sub_data() ;
00346 if (L_subList == NULL) {
00347 GEN_ERROR(E_GEN_FATAL_ERROR, "No protocol definition");
00348 L_ret = -1 ;
00349 } else {
00350
00351 for(L_listIt = L_subList->begin() ;
00352 L_listIt != L_subList->end() ;
00353 L_listIt++) {
00354
00355 L_data = *L_listIt ;
00356 L_value = L_data->get_name() ;
00357
00358
00359 if (strcmp(L_value, "types") == 0) {
00360 L_ret = analyze_types_from_xml (L_data) ;
00361 if (L_ret == -1) break ;
00362 }
00363
00364
00365 if (strcmp(L_value, "header") ==0) {
00366 L_headerFound = true ;
00367 L_ret = analyze_header_from_xml (L_data) ;
00368 if (L_ret == -1) break ;
00369 }
00370
00371
00372 if (strcmp(L_value, "body") ==0) {
00373 L_ret = analyze_body_from_xml (L_data);
00374 if (L_ret == -1) break ;
00375 }
00376
00377
00378 if (strcmp(L_value, (char*)"dictionary") ==0) {
00379 L_ret = analyze_dictionnary_from_xml (L_data);
00380 if (L_ret == -1) break ;
00381 }
00382
00383 }
00384
00385 if (L_headerFound == false) {
00386 L_ret = -1 ;
00387 GEN_ERROR(E_GEN_FATAL_ERROR, "No header definition found for protocol");
00388 }
00389 }
00390
00391 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::xml_interpretor() end");
00392
00393 return (L_ret);
00394 }
00395
00396 int C_ProtocolBinaryBodyNotInterpreted::get_header_values_from_xml (C_XmlData *P_def) {
00397
00398 int L_ret = 0 ;
00399 C_XmlData *L_data ;
00400 char *L_value, *L_name, *L_endstr ;
00401 char *L_fieldName, *L_fieldValue ;
00402 T_XmlData_List::iterator L_listIt, L_listFieldIt ;
00403 T_pXmlData_List L_subListDefine, L_subListSetField ;
00404 int L_id ;
00405
00406 T_IdMap::iterator L_IdMapIt ;
00407 int L_fieldId, L_fieldIdx ;
00408 T_UnsignedInteger32 L_fieldValueUl;
00409 unsigned long L_fieldCode = 0 ;
00410 bool L_codeFound ;
00411 unsigned long L_i, L_j ;
00412
00413 unsigned long L_nb_setfield, L_nb_bodyval ;
00414 char *L_body_name, *L_body_value ;
00415 int L_valueIdx, L_valueId ;
00416
00417 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() start");
00418
00419
00420
00421 if (m_nb_header_values != 0 ) {
00422 ALLOC_TABLE(m_field_present_table,
00423 bool**,
00424 sizeof(bool*),
00425 m_nb_header_values);
00426
00427 if (m_nb_header_body_values != 0) {
00428 for (L_i = 0; L_i < m_nb_header_values ; L_i++) {
00429 ALLOC_TABLE (m_field_present_table[L_i], bool*, sizeof(bool), m_nb_header_body_values);
00430 for (L_j = 0; L_j < m_nb_header_body_values ; L_j++) {
00431 m_field_present_table[L_i][L_j] = true ;
00432 }
00433 }
00434 }
00435 }
00436
00437 L_id = 0 ;
00438 L_subListDefine = P_def->get_sub_data() ;
00439
00440 for(L_listIt = L_subListDefine->begin() ;
00441 L_listIt != L_subListDefine->end() ;
00442 L_listIt++) {
00443
00444 L_data = *L_listIt ;
00445 L_value = L_data->get_name() ;
00446
00447 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() "
00448 << "L_data->get_name() " <<
00449 L_data->get_name() );
00450
00451 if (strcmp(L_value, (char*)"define") == 0) {
00452
00453 m_header_value_table[L_id].m_id = L_id ;
00454
00455 L_name = L_data->find_value((char*)"name") ;
00456 if (L_name == NULL) {
00457 GEN_ERROR(E_GEN_FATAL_ERROR, "define name value is mandatory");
00458 L_ret = -1 ;
00459 break ;
00460 }
00461 m_header_value_table[L_id].m_name = L_name ;
00462
00463 if (L_ret != -1) {
00464
00465 L_subListSetField = L_data->get_sub_data() ;
00466
00467 if (L_subListSetField != NULL) {
00468 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() "
00469 << "L_subListSetField " <<
00470 L_subListSetField );
00471
00472
00473
00474 L_nb_setfield = 0 ;
00475 L_nb_bodyval = 0 ;
00476
00477 for (L_listFieldIt = L_subListSetField->begin();
00478 L_listFieldIt != L_subListSetField->end();
00479 L_listFieldIt++) {
00480 L_data = *L_listFieldIt ;
00481
00482 if (strcmp(L_data->get_name(), (char*)"setfield") == 0) {
00483 L_nb_setfield++ ;
00484 } else if (strcmp(L_data->get_name(), (char*)m_header_body_name) == 0) {
00485 L_nb_bodyval++;
00486 } else {
00487 if (strcmp(L_data->get_name(), (char*)"not-present") != 0) {
00488 GEN_ERROR(E_GEN_FATAL_ERROR, "Unknown ["
00489 << L_data->get_name() << "] section.[setfield] or ["
00490 << m_header_body_name << "] section is mandatory");
00491 L_ret = -1 ;
00492 break ;
00493 }
00494 }
00495 }
00496
00497 if (L_ret == -1) break ;
00498
00499 m_header_value_table[L_id].m_nb_set
00500 = L_nb_setfield ;
00501 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() "
00502 << "m_header_value_table [" <<
00503 L_id << "].m_nb_set "
00504 << m_header_value_table[L_id].m_nb_set );
00505
00506 ALLOC_TABLE(m_header_value_table[L_id].m_values,
00507 T_pValueData,
00508 sizeof(T_ValueData),
00509 m_header_value_table[L_id].m_nb_set);
00510
00511 ALLOC_TABLE(m_header_value_table[L_id].m_value_setted,
00512 bool*,
00513 sizeof(bool),
00514 m_nb_field_header);
00515
00516 ALLOC_TABLE(m_header_value_table[L_id].m_id_value_setted,
00517 int*,
00518 sizeof(int),
00519 m_nb_field_header);
00520
00521 for(L_i = 0; L_i < m_nb_field_header; L_i++) {
00522 m_header_value_table[L_id].m_value_setted[L_i] = false ;
00523 m_header_value_table[L_id].m_id_value_setted[L_i] = -1 ;
00524 }
00525
00526 L_fieldIdx = 0 ;
00527 L_codeFound = false ;
00528
00529 m_body_value_table[L_id].m_nb_values
00530 = L_nb_bodyval ;
00531
00532 ALLOC_TABLE(m_body_value_table[L_id].m_value_table,
00533 T_pBodyValue,
00534 sizeof(T_BodyValue),
00535 L_nb_bodyval);
00536 L_valueIdx = 0 ;
00537
00538 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() "
00539 << "m_body_value_table [ " <<
00540 L_id << "].m_nb_values "
00541 << m_body_value_table[L_id].m_nb_values);
00542
00543
00544 for (L_listFieldIt = L_subListSetField->begin();
00545 L_listFieldIt != L_subListSetField->end();
00546 L_listFieldIt++) {
00547 L_data = *L_listFieldIt ;
00548
00549 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() " <<
00550 "L_data->get_name() is " <<
00551 L_data->get_name() );
00552
00553 if (strcmp(L_data->get_name(), (char*)"setfield") == 0) {
00554
00555 L_fieldName = L_data->find_value((char*)"name") ;
00556 if (L_fieldName == NULL) {
00557 GEN_ERROR(E_GEN_FATAL_ERROR, "setfield name value is mandatory");
00558 L_ret = -1 ;
00559 break ;
00560 }
00561
00562 L_IdMapIt =
00563 m_header_id_map->find(T_IdMap::key_type(L_fieldName));
00564
00565 if (L_IdMapIt != m_header_id_map->end()) {
00566 L_fieldId = L_IdMapIt->second ;
00567 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() L_fieldName is " <<
00568 L_fieldName );
00569 } else {
00570 GEN_ERROR(E_GEN_FATAL_ERROR,
00571 "Field ["
00572 << L_fieldName << "] not defined");
00573 L_ret = -1 ;
00574 break;
00575 }
00576
00577 L_fieldValue = L_data->find_value((char*)"value") ;
00578 if (L_fieldValue == NULL) {
00579 GEN_ERROR(E_GEN_FATAL_ERROR, "setfield value is mandatory");
00580 L_ret = -1 ;
00581 break ;
00582 }
00583 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() L_fieldValue is " <<
00584 L_fieldValue );
00585
00586 L_fieldValueUl = strtoul_f (L_fieldValue, &L_endstr,10) ;
00587
00588
00589 if (L_endstr[0] != '\0') {
00590 L_fieldValueUl = strtoul_f (L_fieldValue, &L_endstr,16) ;
00591 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() typedef size value ["
00592 << L_fieldValueUl << "] format");
00593 if (L_endstr[0] != '\0') {
00594 GEN_ERROR(E_GEN_FATAL_ERROR, "typedef size value ["
00595 << L_fieldValue << "] bad format");
00596 L_ret = -1 ;
00597 break ;
00598 }
00599 }
00600
00601 if (L_ret != -1) {
00602
00603 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() "
00604 << "L_fieldValueUl is " <<
00605 L_fieldValueUl );
00606 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() "
00607 << "L_fieldId is " <<
00608 L_fieldId << " and m_header_type_id "
00609 << m_header_type_id) ;
00610
00611 if (L_fieldId == m_header_type_id) {
00612 L_fieldCode = L_fieldValueUl ;
00613 L_codeFound = true ;
00614 }
00615
00616 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() "
00617 << "L_id = " << L_id );
00618 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() "
00619 << "L_fieldId = " << L_fieldId );
00620 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() "
00621 << "L_fieldIdx = " << L_fieldIdx );
00622
00623 m_header_value_table[L_id]
00624 .m_value_setted[L_fieldId] = true ;
00625 m_header_value_table[L_id]
00626 .m_id_value_setted[L_fieldId] = L_fieldIdx ;
00627
00628 (m_header_value_table[L_id].m_values)[L_fieldIdx].m_id
00629 = L_fieldId ;
00630 (m_header_value_table[L_id].m_values)[L_fieldIdx].m_type
00631 = E_TYPE_NUMBER ;
00632 (m_header_value_table[L_id].m_values)[L_fieldIdx]
00633 .m_value.m_val_number
00634 = L_fieldValueUl ;
00635 L_fieldIdx++;
00636 }
00637
00638 } else if (strcmp(L_data->get_name(), (char*)m_header_body_name) == 0) {
00639
00640 L_body_name = L_data->find_value((char*)"name") ;
00641 if (L_body_name == NULL) {
00642 GEN_ERROR(E_GEN_FATAL_ERROR,
00643 "the name of [" << m_header_body_name <<
00644 "] is mandatory");
00645 L_ret = -1 ;
00646 break ;
00647 }
00648 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() "
00649 << "L_body_name [" << L_body_name << "]");
00650
00651 L_valueId
00652 = get_header_body_value_id(L_body_name);
00653 if (L_valueId == -1) {
00654 GEN_ERROR(E_GEN_FATAL_ERROR,
00655 "No definition found for ["
00656 << L_body_name << "]");
00657 L_ret = -1 ;
00658 break ;
00659 }
00660 if (get_body_value_type (L_valueId)
00661 == E_TYPE_GROUPED) {
00662 GEN_ERROR(E_GEN_FATAL_ERROR,
00663 "Grouped type not supported for body value");
00664 L_ret = -1 ;
00665 break ;
00666 }
00667
00668 L_body_value = L_data->find_value((char*)"value") ;
00669 if (L_body_value == NULL) {
00670 GEN_ERROR(E_GEN_FATAL_ERROR,
00671 "the value of [" << m_header_body_name <<
00672 "] is mandatory");
00673 L_ret = -1 ;
00674 break ;
00675 }
00676 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() "
00677 << "L_body_value [" << L_body_value << "]");
00678
00679 if (C_ProtocolBinary::set_body_value(L_valueId,
00680 L_body_value,
00681 1,
00682 &(m_body_value_table[L_id].m_value_table[L_valueIdx])) == 0) {
00683
00684 if ((m_header_type_id == -1) && (L_valueId == m_header_type_id_body)) {
00685
00686 L_fieldCode = m_body_value_table[L_id].m_value_table[L_valueIdx].m_value.m_val_number ;
00687 L_codeFound = true ;
00688
00689 }
00690
00691
00692 } else {
00693 GEN_ERROR(E_GEN_FATAL_ERROR,
00694 "Bad format for ["
00695 << L_body_value << "]");
00696 L_ret = -1 ;
00697 break ;
00698 }
00699 L_valueIdx ++ ;
00700 } else if (strcmp(L_data->get_name(), (char*)"not-present") == 0) {
00701
00702 L_fieldName = L_data->find_value((char*)"name") ;
00703 if (L_fieldName == NULL) {
00704 GEN_ERROR(E_GEN_FATAL_ERROR, "not-present name value is mandatory");
00705 L_ret = -1 ;
00706 break ;
00707 }
00708
00709 L_ret = get_header_body_value_id(L_fieldName) ;
00710 if (L_ret != -1) {
00711 m_field_present_table[L_id][L_ret] = false ;
00712 L_ret = 0 ;
00713 } else {
00714 GEN_ERROR(E_GEN_FATAL_ERROR,
00715 "Field ["
00716 << L_fieldName << "] not defined");
00717 break;
00718 }
00719 }
00720
00721
00722 if (L_ret == -1) break ;
00723 }
00724 if (L_ret == -1) break ;
00725 } else {
00726 GEN_ERROR(E_GEN_FATAL_ERROR,
00727 "setfield for ["
00728 << m_header_name << "] or [" << m_header_body_name << "] code is mandatory");
00729 L_ret = -1 ;
00730 break ;
00731 }
00732 if (L_ret == -1) break ;
00733 if ((L_codeFound == false) && (m_header_type_id != -1) ) {
00734 GEN_ERROR(E_GEN_FATAL_ERROR,
00735 "No value found for the field ["
00736 << m_header_field_table[m_header_type_id].m_name
00737 << "]");
00738 L_ret = -1 ;
00739 break ;
00740 }
00741 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() L_name = " <<
00742 L_name << " L_fieldCode = " << L_fieldCode <<
00743 " and L_id = " << L_id) ;
00744
00745 m_header_value_id_map
00746 ->insert(T_IdMap::value_type(L_name, L_id));
00747 m_header_decode_map
00748 ->insert(T_DecodeMap::value_type(L_fieldCode, L_id));
00749 L_id ++ ;
00750 }
00751 }
00752
00753 if (L_ret == -1) break ;
00754 }
00755 GEN_DEBUG(1, "C_ProtocolBinary::get_header_values_from_xml() end");
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765 return (L_ret);
00766 }
00767
00768 C_MessageFrame* C_ProtocolBinaryBodyNotInterpreted::create_new_message(C_MessageFrame *P_msg) {
00769
00770 C_MessageBinaryBodyNotInterpreted *L_msg ;
00771
00772 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::create_new_message() start: msg pt");
00773 NEW_VAR(L_msg, C_MessageBinaryBodyNotInterpreted(this));
00774 if (P_msg != NULL) {
00775 (*L_msg) = *((C_MessageBinaryBodyNotInterpreted*)P_msg) ;
00776 }
00777 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::create_new_message() end: msg pt");
00778 return (L_msg);
00779 }
00780
00781 C_MessageFrame* C_ProtocolBinaryBodyNotInterpreted::create_new_message(void *P_xml,
00782 T_pInstanceDataList P_list,
00783 int *P_nb_value) {
00784
00785 C_XmlData *L_Xml = (C_XmlData*) P_xml ;
00786 bool L_msgOk = true ;
00787 C_MessageBinaryBodyNotInterpreted *L_msg ;
00788 char *L_currentName ;
00789 int L_header_val_id ;
00790 int L_body_val_id ;
00791
00792 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::create_new_message() start: xml");
00793
00794
00795 NEW_VAR(L_msg, C_MessageBinaryBodyNotInterpreted(this));
00796
00797
00798 L_currentName = L_Xml -> get_name () ;
00799
00800 if (strcmp(L_currentName, get_header_name()) == 0) {
00801
00802 L_currentName = L_Xml -> find_value ((char*) "name") ;
00803 if (L_currentName == NULL) {
00804 GEN_ERROR(E_GEN_FATAL_ERROR,
00805 "name value is mandatory for ["
00806 << get_header_name()
00807 << "]");
00808 L_msgOk = false ;
00809 } else {
00810 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::create_new_message() "
00811 << "the name of this message is " << L_currentName );
00812
00813 L_header_val_id = get_header_value_id(L_currentName) ;
00814
00815 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::create_new_message() "
00816 << "L_header_val_id = " << L_header_val_id );
00817
00818 if (L_header_val_id == -1) {
00819 GEN_ERROR(E_GEN_FATAL_ERROR,
00820 "unknown name ["
00821 << L_currentName << "] for [" << get_header_name() << "]");
00822 L_msgOk = false ;
00823 } else {
00824
00825 T_pXmlData_List L_listBodyVal ;
00826 T_XmlData_List::iterator L_bodyValIt ;
00827 C_XmlData *L_bodyData ;
00828
00829 char *L_bodyName, *L_bodyValue ;
00830 C_ProtocolBinary::T_BodyValue L_bodyVal ;
00831
00832 L_msg->set_header_id_value(L_header_val_id);
00833
00834 L_listBodyVal = L_Xml -> get_sub_data() ;
00835
00836 if (L_listBodyVal != NULL) {
00837
00838 for (L_bodyValIt = L_listBodyVal->begin() ;
00839 L_bodyValIt != L_listBodyVal->end() ;
00840 L_bodyValIt++) {
00841 L_bodyData = *L_bodyValIt ;
00842
00843 if (strcmp(L_bodyData->get_name(),
00844 get_header_body_name())==0) {
00845 L_bodyName = L_bodyData->find_value((char*)"name");
00846 if (L_bodyName == NULL) {
00847 GEN_ERROR(E_GEN_FATAL_ERROR,
00848 "name value is mandatory for ["
00849 << get_header_body_name()
00850 << "] definition");
00851 L_msgOk = false ;
00852 }
00853
00854 GEN_DEBUG(1, "C_ProtocolBinary::create_new_message() "
00855 << "L_bodyName is [" << L_bodyName << "]");
00856
00857 L_body_val_id = get_header_body_value_id(L_bodyName) ;
00858
00859 if (L_body_val_id == -1) {
00860 GEN_ERROR(E_GEN_FATAL_ERROR,
00861 "No definition found for ["
00862 << L_bodyName << "]");
00863 L_msgOk = false ;
00864 break ;
00865 }
00866
00867 GEN_DEBUG(1, "C_ProtocolBinary::create_new_message() "
00868 << "L_body_val_id is "
00869 << L_body_val_id );
00870
00871 if (get_body_value_type (L_body_val_id)
00872 == E_TYPE_GROUPED) {
00873
00874 GEN_DEBUG(1, "C_ProtocolBinary::create_new_message() "
00875 << L_bodyName << " is grouped element" );
00876
00877 if (process_grouped_type(L_bodyData, L_body_val_id,
00878 &L_bodyVal) != 0) {
00879 GEN_ERROR(E_GEN_FATAL_ERROR,
00880 "Grouped Type processing Error for "
00881 << L_bodyName);
00882 L_msgOk = false ;
00883 break ;
00884 }
00885
00886
00887 L_msg->C_MessageBinary::set_body_value(&L_bodyVal);
00888
00889
00890 reset_grouped_body_value(&L_bodyVal);
00891 FREE_TABLE(L_bodyVal.m_sub_val);
00892 } else {
00893 bool L_toBeDelete = false;
00894
00895
00896 L_bodyValue = L_bodyData->find_value((char*)"value");
00897 if (L_bodyValue == NULL) {
00898 GEN_ERROR(E_GEN_FATAL_ERROR,
00899 "value is mandatory for ["
00900 << get_header_body_name()
00901 << "] definition");
00902 L_msgOk = false ;
00903 break ;
00904 }
00905
00906 GEN_DEBUG(1, "C_ProtocolBinary::create_new_message() "
00907 << "L_bodyValue is \"" << L_bodyValue << "\"" );
00908
00909 if (C_ProtocolBinary::set_body_value(L_body_val_id,
00910 L_bodyValue,
00911 1,
00912 &L_bodyVal,
00913 &L_toBeDelete) == 0) {
00914 L_msg->C_MessageBinary::set_body_value(&L_bodyVal);
00915
00916 if (L_toBeDelete) {
00917
00918 delete_body_value(&L_bodyVal);
00919 }
00920
00921 } else {
00922 GEN_ERROR(E_GEN_FATAL_ERROR,
00923 "Bad format for ["
00924 << L_bodyValue << "]");
00925 L_msgOk = false ;
00926 break ;
00927 }
00928
00929 }
00930
00931 } else if (strcmp(L_bodyData->get_name(),
00932 (char*)"setfield")==0) {
00933 unsigned long L_val_setfield = 0 ;
00934 int L_id_setfield = 0 ;
00935 L_msgOk = (analyze_setfield(L_bodyData, &L_id_setfield ,&L_val_setfield) == -1)
00936 ? false : true ;
00937 if (L_msgOk) {
00938 L_msg->C_MessageBinary::set_header_value(L_id_setfield, L_val_setfield);
00939 }
00940 } else {
00941 GEN_ERROR(E_GEN_FATAL_ERROR,
00942 "Unkown section ["
00943 << L_bodyData->get_name()
00944 << "]");
00945 L_msgOk = false;
00946 break ;
00947 }
00948 if (L_msgOk == false) break ;
00949 }
00950 }
00951 }
00952 }
00953 }
00954
00955
00956 if (L_msgOk == false) {
00957 DELETE_VAR(L_msg);
00958 } else {
00959
00960 m_messageList->push_back(L_msg);
00961 }
00962
00963 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::create_new_message() end: xml");
00964
00965
00966
00967 return (L_msg);
00968 }
00969
00970 void C_ProtocolBinaryBodyNotInterpreted::get_field_position
00971 (T_pHeaderBodyPositionSize P_pos, int P_id) {
00972 T_HeaderBodyPositionSizeMap::iterator L_positionSizeIt ;
00973 L_positionSizeIt = m_header_body_position_size_map
00974 ->find(T_HeaderBodyPositionSizeMap::key_type(P_id));
00975
00976 if (L_positionSizeIt != m_header_body_position_size_map->end()) {
00977 *P_pos = L_positionSizeIt->second ;
00978 } else {
00979 P_pos -> m_size = 0 ;
00980 }
00981 }
00982
00983
00984 C_ProtocolFrame::T_MsgError C_ProtocolBinaryBodyNotInterpreted::encode_body (int P_nbVal,
00985 T_pBodyValue P_val,
00986 unsigned char *P_buf,
00987 size_t *P_size) {
00988
00989 unsigned char *L_ptr = P_buf ;
00990 int L_body_id ;
00991 T_pBodyValue L_body_val ;
00992
00993 unsigned long L_valueSize ;
00994
00995 C_ProtocolFrame::T_MsgError L_error = C_ProtocolFrame::E_MSG_OK;
00996
00997
00998 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::encode_body() start");
00999
01000 L_body_val = &P_val[0] ;
01001 L_body_id = L_body_val->m_id ;
01002
01003 if (m_stats) {
01004 m_stats->updateStats (E_MESSAGE_COMPONENT,
01005 E_SEND,
01006 L_body_id);
01007 }
01008
01009 L_valueSize = L_body_val -> m_value.m_val_binary.m_size ;
01010
01011 if (L_valueSize > *P_size) {
01012 GEN_LOG_EVENT(LOG_LEVEL_TRAFFIC_ERR,
01013 "Buffer maximum size reached [" << *P_size << "]");
01014 L_error = C_ProtocolFrame::E_MSG_ERROR_ENCODING ;
01015 } else {
01016 memcpy(L_ptr, L_body_val->m_value.m_val_binary.m_value, L_valueSize);
01017 L_ptr += L_valueSize ;
01018 *P_size = L_valueSize ;
01019 }
01020
01021 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::encode_body() end");
01022
01023 return (L_error);
01024 }
01025
01026 int C_ProtocolBinaryBodyNotInterpreted::decode_body(unsigned char *P_buf,
01027 size_t P_size,
01028 T_pBodyValue P_valDec,
01029 int *P_nbValDec,
01030 int *P_headerId) {
01031
01032
01033 unsigned char *L_ptr = P_buf ;
01034 int L_ret = 0 ;
01035 unsigned long L_total_size, L_data_size ;
01036 T_DecodeMap::iterator L_decodeIt ;
01037 int L_nbValDec = 0 ;
01038 unsigned long L_type_id_val ;
01039 int L_header_type_id = get_header_type_id();
01040
01041 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::decode_body() start");
01042
01043
01044 L_total_size = 0 ;
01045 *P_nbValDec = 0 ;
01046 L_nbValDec = 0 ;
01047 L_data_size = P_size ;
01048
01049 if (m_stats) {
01050 m_stats->updateStats (E_MESSAGE_COMPONENT,
01051 E_RECEIVE,
01052 0);
01053 }
01054
01055 P_valDec[L_nbValDec].m_id = 0 ;
01056 P_valDec[L_nbValDec].m_value.m_val_binary.m_size = L_data_size ;
01057
01058 ALLOC_TABLE(P_valDec[L_nbValDec].m_value.m_val_binary.m_value,
01059 unsigned char*,
01060 sizeof(unsigned char),
01061 L_data_size);
01062
01063 memcpy(P_valDec[L_nbValDec].m_value.m_val_binary.m_value,
01064 L_ptr,
01065 L_data_size);
01066
01067
01068
01069
01070 if (L_header_type_id == -1) {
01071
01072
01073 if (!m_header_type_id_body) {
01074
01075 L_type_id_val = P_valDec[L_nbValDec].m_value.m_val_number ;
01076
01077 L_decodeIt = m_header_decode_map
01078 ->find(T_DecodeMap::key_type(L_type_id_val));
01079 if (L_decodeIt != m_header_decode_map->end()) {
01080
01081 (*P_headerId) = L_decodeIt->second ;
01082 } else {
01083 GEN_LOG_EVENT_FORCE("not found");
01084 }
01085 }
01086 }
01087
01088 L_ptr += L_data_size ;
01089 L_total_size += L_data_size ;
01090
01091 L_nbValDec ++ ;
01092 *P_nbValDec = L_nbValDec ;
01093
01094 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::decode_body() end nb Val: " << L_nbValDec
01095 << " ret: " << L_ret << "\n");
01096
01097 return (L_ret) ;
01098
01099 }
01100
01101
01102 int C_ProtocolBinaryBodyNotInterpreted::analyze_sessions_id_from_xml (C_XmlData *P_def) {
01103
01104 int L_ret = 0 ;
01105 C_XmlData::T_pXmlField_List L_fields_list ;
01106 C_XmlData::T_XmlField_List::iterator L_fieldIt ;
01107
01108 T_ManagementSessionId L_management_session ;
01109 T_ManagementSessionIdList L_list_management_session ;
01110 char *L_name_value = NULL ;
01111
01112 T_ManagementSessionIdList::iterator L_it ;
01113 int L_msg_id_id ;
01114 T_MsgIdType L_msg_id_type ;
01115 T_TypeType L_msg_id_value_type ;
01116 int L_id ;
01117
01118 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::analyze_sessions_id_from_xml() start");
01119
01120 L_fields_list = P_def->get_fields();
01121 if (!L_fields_list->empty()) {
01122 for(L_fieldIt = L_fields_list->begin() ;
01123 L_fieldIt != L_fields_list->end() ;
01124 L_fieldIt++) {
01125
01126 if((strcmp((*L_fieldIt)->get_name() , (char*)"session-id") == 0 ) ||
01127 (strcmp((*L_fieldIt)->get_name() , (char*)"out-of-session-id") == 0 )) {
01128
01129 L_name_value = (*L_fieldIt)->get_value();
01130 if (L_name_value == NULL) {
01131 GEN_ERROR(E_GEN_FATAL_ERROR,
01132 (*L_fieldIt)->get_name()
01133 << " is mandatory for ["
01134 << m_header_name
01135 << "] section");
01136 L_ret = -1 ;
01137 break ;
01138 }
01139
01140
01141 L_msg_id_id = find_header_field_id (L_name_value) ;
01142
01143 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::analyze_sessions_id_from_xml() "
01144 << "L_msg_id_id is " << L_msg_id_id );
01145
01146 if (L_msg_id_id != -1) {
01147 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::analyze_sessions_id_from_xml() "
01148 << "L_msg_id_id is an header one it type is number");
01149 L_msg_id_type = E_MSG_ID_HEADER ;
01150 L_msg_id_value_type = get_header_value_type (L_msg_id_id) ;
01151 } else {
01152 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::analyze_sessions_id_from_xml() "
01153 << "L_msg_id_id is an body one ");
01154 L_msg_id_id = find_body_value_id (L_name_value) ;
01155 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::analyze_sessions_id_from_xml() "
01156 << "L_msg_id_id is " << L_msg_id_id );
01157 if (L_msg_id_id != -1) {
01158 L_msg_id_type = E_MSG_ID_BODY ;
01159 L_msg_id_value_type = get_body_value_type (L_msg_id_id);
01160 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::analyze_sessions_id_from_xml() "
01161 << "L_msg_id_id is " << L_msg_id_id << " its type is "
01162 << L_msg_id_value_type);
01163 } else {
01164 GEN_ERROR(E_GEN_FATAL_ERROR,
01165 "No definition found for "
01166 << (*L_fieldIt)->get_name()
01167 << " ["
01168 << L_name_value << "]");
01169 L_ret = -1 ;
01170 break ;
01171 }
01172 }
01173 }
01174
01175 L_management_session.m_msg_id_id = L_msg_id_id ;
01176 L_management_session.m_msg_id_type = L_msg_id_type ;
01177 L_management_session.m_msg_id_value_type = L_msg_id_value_type ;
01178
01179 L_list_management_session.push_back(L_management_session);
01180 }
01181
01182 if (L_ret != -1) {
01183 if (!L_list_management_session.empty()) {
01184 m_value_sessions_table_size = L_list_management_session.size() ;
01185 ALLOC_TABLE(m_value_sessions_table,
01186 T_pManagementSessionId,
01187 sizeof(T_ManagementSessionId),
01188 m_value_sessions_table_size);
01189
01190 L_id = 0 ;
01191 for (L_it = L_list_management_session.begin();
01192 L_it != L_list_management_session.end() ;
01193 L_it++) {
01194 m_value_sessions_table[L_id] = *L_it ;
01195 L_id ++ ;
01196 }
01197
01198 L_list_management_session.erase(L_list_management_session.begin(),
01199 L_list_management_session.end());
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214 } else {
01215 GEN_ERROR(E_GEN_FATAL_ERROR,
01216 "No session-id nor out-of-session definition found");
01217 L_ret = -1 ;
01218 }
01219 }
01220 } else {
01221 GEN_ERROR(E_GEN_FATAL_ERROR,
01222 "No session-id nor out-of-session found in dictionary definition");
01223 L_ret = -1 ;
01224 }
01225
01226 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::analyze_sessions_id_from_xml() end");
01227 return (L_ret);
01228 }
01229
01230
01231 C_ProtocolBinary::T_pManagementSessionId
01232 C_ProtocolBinaryBodyNotInterpreted::get_manage_session_elt(int P_id) {
01233
01234 T_ManagementSessionId *L_ret = NULL ;
01235
01236 if ((P_id < m_value_sessions_table_size) && (P_id >= 0)) {
01237 L_ret = &m_value_sessions_table[P_id] ;
01238 }
01239 return (L_ret) ;
01240 }
01241
01242
01243 int C_ProtocolBinaryBodyNotInterpreted::get_nb_management_session () {
01244 return (m_value_sessions_table_size);
01245 }
01246
01247
01248 bool C_ProtocolBinaryBodyNotInterpreted::check_present_session (int P_msg_id,int P_id) {
01249 return (m_field_present_table[P_msg_id][P_id]);
01250 }
01251
01252 bool C_ProtocolBinaryBodyNotInterpreted::find_present_session (int P_msg_id,int P_id) {
01253
01254 bool L_result ;
01255 int L_id = P_id ;
01256
01257 if (L_id < (int)m_max_nb_field_header) {
01258 L_result = true ;
01259 } else {
01260 L_id -= m_max_nb_field_header ;
01261 if (L_id >= 0 ) {
01262 return (check_present_session(P_msg_id,L_id));
01263 } else {
01264 L_result = false ;
01265 }
01266 }
01267 return (L_result);
01268 }
01269
01270
01271
01272
01273 iostream_output& C_ProtocolBinaryBodyNotInterpreted::print_body (iostream_output& P_stream,
01274 int P_nb,
01275 T_pBodyValue P_val,
01276 int P_level) {
01277
01278 int L_i, L_id;
01279 T_pHeaderBodyValue L_body_fieldValues ;
01280 unsigned long L_fieldIdx ;
01281 int L_valueIdx ;
01282
01283 int L_type_id ;
01284 T_TypeType L_type ;
01285 char L_levelStr[255] = "";
01286
01287 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::print_body() start nb: " << P_nb);
01288 GEN_DEBUG(1, "C_ProtocolBinaryBodyNotInterpreted::print_body() m_nb_field_header_body: "
01289 << m_nb_field_header_body);
01290 GEN_DEBUG(1, "C_ProtocolBinary::print_body() Level: " << P_level);
01291
01292 for (L_i = 0; L_i < P_level; L_i++) {
01293 strcat(L_levelStr," |");
01294 }
01295 for (L_i = 0; L_i < P_nb; L_i++) {
01296 L_id = P_val[L_i].m_id ;
01297 L_body_fieldValues = &m_header_body_value_table[L_id] ;
01298
01299 GEN_DEBUG(1, "C_ProtocolBinary::print_body() display " <<
01300 L_body_fieldValues->m_name << "(id: " << L_id << ")");
01301
01302 P_stream << GEN_HEADER_LOG << GEN_HEADER_LEVEL(LOG_LEVEL_MSG) << L_levelStr
01303 << " ";
01304 P_stream << "[" << L_body_fieldValues->m_name << iostream_endl ;
01305
01306
01307 P_stream << GEN_HEADER_LOG << GEN_HEADER_LEVEL(LOG_LEVEL_MSG) << L_levelStr
01308 << " " ;
01309
01310
01311
01312 if (L_body_fieldValues->m_nb_set != 0 ) {
01313 for(L_fieldIdx=0; L_fieldIdx < m_nb_field_header_body; L_fieldIdx++) {
01314
01315 if (L_body_fieldValues->m_value_setted[L_fieldIdx] == true) {
01316 L_valueIdx = L_body_fieldValues
01317 ->m_id_value_setted[L_fieldIdx];
01318
01319 P_stream << "("
01320 << m_header_body_field_table[L_fieldIdx].m_name
01321 << " = "
01322 << L_body_fieldValues
01323 ->m_values[L_valueIdx].m_value.m_val_number
01324 << ")" ;
01325 }
01326 }
01327
01328
01329
01330 if (m_header_body_start_optional_id != -1) {
01331 for(L_fieldIdx=m_header_body_start_optional_id;
01332 L_fieldIdx < m_max_nb_field_header_body; L_fieldIdx++) {
01333
01334 if (L_body_fieldValues->m_value_setted[L_fieldIdx] == true) {
01335
01336 L_valueIdx = L_body_fieldValues
01337 ->m_id_value_setted[L_fieldIdx];
01338 P_stream << "("
01339 << m_header_body_field_table[L_fieldIdx].m_name
01340 << " = "
01341 << L_body_fieldValues
01342 ->m_values[L_valueIdx].m_value.m_val_number
01343 << ")" ;
01344 }
01345 }
01346 }
01347 }
01348
01349 P_stream << "] = [" ;
01350
01351 L_type_id = L_body_fieldValues->m_type_id ;
01352
01353 GEN_DEBUG(1, "C_ProtocolBinary::print_body() display type " <<
01354 m_type_def_table[L_type_id].m_name << "(id: " << L_type_id << ")");
01355
01356 L_type = m_type_def_table[L_type_id].m_type ;
01357
01358 switch (L_type) {
01359 case E_TYPE_NUMBER:
01360 #ifdef MSG_DETAIL_DUMP
01361 P_stream << " size [" << sizeof(T_UnsignedInteger32) << "]";
01362 P_stream << " type [" << m_type_def_table[L_type_id].m_name << "]";
01363 P_stream << " value [";
01364 #endif
01365 P_stream << P_val[L_i].m_value.m_val_number ;
01366 break;
01367 case E_TYPE_SIGNED:
01368 #ifdef MSG_DETAIL_DUMP
01369 P_stream << " size [" << sizeof(T_Integer32) << "]";
01370 P_stream << " type [" << m_type_def_table[L_type_id].m_name << "]";
01371 P_stream << " value [";
01372 #endif
01373 P_stream << P_val[L_i].m_value.m_val_signed ;
01374 break;
01375 case E_TYPE_STRING: {
01376 static char L_hexa_buf [50] ;
01377 static char L_ascii_buf [50] ;
01378 const size_t L_cNum = 16 ;
01379 size_t L_i2, L_nb, L_buffer_size ;
01380 unsigned char*L_cur ;
01381
01382 #ifdef MSG_DETAIL_DUMP
01383 P_stream << " size ["
01384 << P_val[L_i].m_value.m_val_binary.m_size
01385 << "]";
01386 P_stream << " type [" << m_type_def_table[L_type_id].m_name << "]";
01387 P_stream << " value [";
01388 #endif
01389 L_buffer_size = P_val[L_i].m_value.m_val_binary.m_size ;
01390
01391 L_nb = L_buffer_size / L_cNum ;
01392 L_cur = P_val[L_i].m_value.m_val_binary.m_value ;
01393 if (L_cur != NULL)
01394 {
01395 for (L_i2 = 0 ; L_i2 < L_nb; L_i2++) {
01396 P_stream << iostream_endl ;
01397 P_stream << GEN_HEADER_LOG << GEN_HEADER_LEVEL(LOG_LEVEL_MSG)
01398 << L_levelStr << " ";
01399
01400 pretty_binary_printable_buffer(L_cur, L_cNum, L_hexa_buf, L_ascii_buf);
01401 P_stream << "[" ;
01402 P_stream << L_hexa_buf ;
01403 P_stream << "] <=> [" ;
01404 P_stream << L_ascii_buf;
01405 P_stream << "]" ;
01406
01407 L_cur += L_cNum ;
01408 }
01409 L_nb = L_buffer_size % L_cNum ;
01410 if (L_nb != 0) {
01411 P_stream << iostream_endl ;
01412 P_stream << GEN_HEADER_LOG << GEN_HEADER_LEVEL(LOG_LEVEL_MSG)
01413 << L_levelStr << " ";
01414 pretty_binary_printable_buffer(L_cur, L_nb, L_hexa_buf, L_ascii_buf);
01415 P_stream << "[" ;
01416 P_stream << L_hexa_buf ;
01417 P_stream << "] <=> [" ;
01418 P_stream << L_ascii_buf;
01419 P_stream << "]" ;
01420 }
01421
01422
01423 P_stream << iostream_endl ;
01424 P_stream << GEN_HEADER_LOG << GEN_HEADER_LEVEL(LOG_LEVEL_MSG)
01425 << L_levelStr << " ";
01426 } else {
01427 P_stream << "NULL(empty)";
01428 }
01429 }
01430 break;
01431 case E_TYPE_STRUCT:
01432 #ifdef MSG_DETAIL_DUMP
01433 P_stream << " size [" << (2*sizeof(T_Integer32)) << "]";
01434 P_stream << " type [" << m_type_def_table[L_type_id].m_name << "]";
01435 P_stream << " value [";
01436 #endif
01437 P_stream << P_val[L_i].m_value.m_val_struct.m_id_1 << ";"
01438 << P_val[L_i].m_value.m_val_struct.m_id_2 ;
01439 break;
01440 case E_TYPE_GROUPED:
01441 #ifdef MSG_DETAIL_DUMP
01442 P_stream << " grouped";
01443 P_stream << " type [" << m_type_def_table[L_type_id].m_name << "]";
01444 P_stream << " value [";
01445 #endif
01446 P_stream << iostream_endl ;
01447 print_body(P_stream, P_val[L_i].m_value.m_val_number,
01448 P_val[L_i].m_sub_val, P_level+1);
01449 P_stream << GEN_HEADER_LOG << GEN_HEADER_LEVEL(LOG_LEVEL_MSG)
01450 << L_levelStr << " ";
01451 break;
01452 case E_TYPE_NUMBER_64:
01453 #ifdef MSG_DETAIL_DUMP
01454 P_stream << " size [" << sizeof(T_UnsignedInteger64) << "]";
01455 P_stream << " type [" << m_type_def_table[L_type_id].m_name << "]";
01456 P_stream << " value [";
01457 #endif
01458 P_stream << P_val[L_i].m_value.m_val_number_64 ;
01459 break;
01460 case E_TYPE_SIGNED_64:
01461 #ifdef MSG_DETAIL_DUMP
01462 P_stream << " size [" << sizeof(T_UnsignedInteger64) << "]";
01463 P_stream << " type [" << m_type_def_table[L_type_id].m_name << "]";
01464 P_stream << " value [";
01465 #endif
01466 P_stream << P_val[L_i].m_value.m_val_signed_64 ;
01467 break;
01468 default:
01469 GEN_FATAL(E_GEN_FATAL_ERROR, "type " << L_type << " not implemented");
01470 break ;
01471 }
01472
01473 #ifdef MSG_DETAIL_DUMP
01474 P_stream << "]" << iostream_endl ;
01475 P_stream << GEN_HEADER_LOG << GEN_HEADER_LEVEL(LOG_LEVEL_MSG)
01476 << L_levelStr << " ";
01477 #endif
01478
01479 P_stream << "]" << iostream_endl ;
01480
01481 }
01482
01483 GEN_DEBUG(1, "C_ProtocolBinary::print_body() end");
01484
01485 return (P_stream) ;
01486
01487 }
01488