Mercurial > hg > freeDiameter
comparison libfdproto/messages.c @ 1125:98d1ad9bf85a
Fix initialization of random number; Cleanup the dump message display
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Wed, 15 May 2013 10:04:58 +0800 |
parents | ccbd1426e04a |
children | 83d55d26ae80 |
comparison
equal
deleted
inserted
replaced
1124:769b867c8637 | 1125:98d1ad9bf85a |
---|---|
773 * Tree View message dump | 773 * Tree View message dump |
774 */ | 774 */ |
775 static DECLARE_FD_DUMP_PROTOTYPE( msg_format_treeview, struct msg * msg ) | 775 static DECLARE_FD_DUMP_PROTOTYPE( msg_format_treeview, struct msg * msg ) |
776 { | 776 { |
777 if (!CHECK_MSG(msg)) { | 777 if (!CHECK_MSG(msg)) { |
778 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{message}(@%p): INVALID", msg), return NULL); | 778 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID MESSAGE"), return NULL); |
779 return *buf; | 779 return *buf; |
780 } | 780 } |
781 | 781 |
782 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{message}(@%p): ", msg), return NULL); | |
783 if (!msg->msg_model) { | 782 if (!msg->msg_model) { |
784 if (msg->msg_model_not_found.mnf_code) { | 783 if (msg->msg_model_not_found.mnf_code) { |
785 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(not found in dictionary)\n"), return NULL); | 784 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(not found in dictionary)\n"), return NULL); |
786 } else { | 785 } else { |
787 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(not searched in dictionary)\n"), return NULL); | 786 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(not searched in dictionary)\n"), return NULL); |
803 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Flags: 0x%02hhX (" DUMP_CMDFL_str ")\n", msg->msg_public.msg_flags, DUMP_CMDFL_val(msg->msg_public.msg_flags)), return NULL); | 802 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Flags: 0x%02hhX (" DUMP_CMDFL_str ")\n", msg->msg_public.msg_flags, DUMP_CMDFL_val(msg->msg_public.msg_flags)), return NULL); |
804 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Command Code: %u\n", msg->msg_public.msg_code), return NULL); | 803 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Command Code: %u\n", msg->msg_public.msg_code), return NULL); |
805 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " ApplicationId: %d\n", msg->msg_public.msg_appl), return NULL); | 804 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " ApplicationId: %d\n", msg->msg_public.msg_appl), return NULL); |
806 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Hop-by-Hop Identifier: 0x%08X\n", msg->msg_public.msg_hbhid), return NULL); | 805 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Hop-by-Hop Identifier: 0x%08X\n", msg->msg_public.msg_hbhid), return NULL); |
807 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " End-to-End Identifier: 0x%08X\n", msg->msg_public.msg_eteid), return NULL); | 806 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " End-to-End Identifier: 0x%08X\n", msg->msg_public.msg_eteid), return NULL); |
808 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {debug data}: src:%s(%zd) rwb:%p rt:%d cb:%p,%p(%p) qry:%p asso:%d sess:%p", msg->msg_src_id?:"(nil)", msg->msg_src_id_len, msg->msg_rawbuffer, msg->msg_routable, msg->msg_cb.anscb, msg->msg_cb.expirecb, msg->msg_cb.data, msg->msg_query, msg->msg_associated, msg->msg_sess), return NULL); | 807 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {internal data}: src:%s(%zd) rwb:%p rt:%d cb:%p,%p(%p) qry:%p asso:%d sess:%p", msg->msg_src_id?:"(nil)", msg->msg_src_id_len, msg->msg_rawbuffer, msg->msg_routable, msg->msg_cb.anscb, msg->msg_cb.expirecb, msg->msg_cb.data, msg->msg_query, msg->msg_associated, msg->msg_sess), return NULL); |
809 | 808 |
810 return *buf; | 809 return *buf; |
811 } | 810 } |
812 | 811 |
813 static DECLARE_FD_DUMP_PROTOTYPE( avp_format_treeview, struct avp * avp, int level, int first, int last ) | 812 static DECLARE_FD_DUMP_PROTOTYPE( avp_format_treeview, struct avp * avp, int level, int first, int last ) |
821 if (level) { | 820 if (level) { |
822 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL); | 821 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL); |
823 } | 822 } |
824 | 823 |
825 if (!CHECK_AVP(avp)) { | 824 if (!CHECK_AVP(avp)) { |
826 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{avp}(@%p): INVALID", avp), return NULL); | 825 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID AVP"), return NULL); |
827 return *buf; | 826 return *buf; |
828 } | 827 } |
829 | 828 |
830 if (!level) { | 829 if (level) { |
831 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{avp}(@%p): ", avp), return NULL); | |
832 } else { | |
833 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%*sAVP: ", level * 3, ""), return NULL); | 830 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%*sAVP: ", level * 3, ""), return NULL); |
834 } | 831 } |
835 | 832 |
836 if (!avp->avp_model) { | 833 if (!avp->avp_model) { |
837 if (avp->avp_model_not_found.mnf_code) { | 834 if (avp->avp_model_not_found.mnf_code) { |
1033 * One-line dumper for compact but complete traces | 1030 * One-line dumper for compact but complete traces |
1034 */ | 1031 */ |
1035 static DECLARE_FD_DUMP_PROTOTYPE( msg_format_summary, struct msg * msg ) | 1032 static DECLARE_FD_DUMP_PROTOTYPE( msg_format_summary, struct msg * msg ) |
1036 { | 1033 { |
1037 if (!CHECK_MSG(msg)) { | 1034 if (!CHECK_MSG(msg)) { |
1038 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{message}(@%p): INVALID", msg), return NULL); | 1035 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID MESSAGE"), return NULL); |
1039 return *buf; | 1036 return *buf; |
1040 } | 1037 } |
1041 | 1038 |
1042 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{message}(@%p): ", msg), return NULL); | |
1043 if (!msg->msg_model) { | 1039 if (!msg->msg_model) { |
1044 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(no model)"), return NULL); | 1040 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(no model)"), return NULL); |
1045 } else { | 1041 } else { |
1046 enum dict_object_type dicttype; | 1042 enum dict_object_type dicttype; |
1047 struct dict_cmd_data dictdata; | 1043 struct dict_cmd_data dictdata; |
1072 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, ","), return NULL); | 1068 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, ","), return NULL); |
1073 } | 1069 } |
1074 } | 1070 } |
1075 | 1071 |
1076 if (!CHECK_AVP(avp)) { | 1072 if (!CHECK_AVP(avp)) { |
1077 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID"), return NULL); | 1073 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID AVP"), return NULL); |
1078 goto end; | 1074 goto end; |
1079 } | 1075 } |
1080 | 1076 |
1081 if (!level) { | 1077 if (!level) { |
1082 /* We have been called to explicitely dump this AVP, so we parse its name if available */ | 1078 /* We have been called to explicitely dump this AVP, so we parse its name if available */ |
1510 static uint32_t fd_eteid; | 1506 static uint32_t fd_eteid; |
1511 static pthread_mutex_t fd_eteid_lck = PTHREAD_MUTEX_INITIALIZER; | 1507 static pthread_mutex_t fd_eteid_lck = PTHREAD_MUTEX_INITIALIZER; |
1512 | 1508 |
1513 void fd_msg_eteid_init(void) | 1509 void fd_msg_eteid_init(void) |
1514 { | 1510 { |
1515 fd_eteid = ((uint32_t)time(NULL) << 20) | ((uint32_t)lrand48() & ( (1 << 20) - 1 )); | 1511 uint32_t t = (uint32_t)time(NULL); |
1512 srand48(t); | |
1513 fd_eteid = (t << 20) | ((uint32_t)lrand48() & ( (1 << 20) - 1 )); | |
1516 } | 1514 } |
1517 | 1515 |
1518 uint32_t fd_msg_eteid_get ( void ) | 1516 uint32_t fd_msg_eteid_get ( void ) |
1519 { | 1517 { |
1520 uint32_t ret; | 1518 uint32_t ret; |