Changeset 1093:44f3e48dfe27 in freeDiameter for libfdproto
- Timestamp:
- May 6, 2013, 5:33:22 PM (11 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libfdproto
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdproto/dictionary.c
r1085 r1093 719 719 } 720 720 721 /* For searchs of type "xxx_OF_xxx": if the search object is sentinel list for the "what" object */ 722 #define SEARCH_sentinel( type_of_what, what_list_nr, sentinel_list_nr ) { \ 723 struct dict_object *__what = (struct dict_object *) what; \ 724 CHECK_PARAMS_DO( verify_object(__what) && \ 725 (__what->type == (type_of_what)), \ 726 { ret = EINVAL; goto end; } ); \ 727 ret = 0; \ 728 if (result) { \ 729 /* this is similar to the "container_of" */ \ 730 *result = (struct dict_object *)((char *)(__what->list[what_list_nr].head) - \ 731 (size_t)&(((struct dict_object *)0)->list[sentinel_list_nr])); \ 732 } \ 733 } 734 735 721 736 static int search_vendor ( struct dictionary * dict, int criteria, const void * what, struct dict_object **result ) 722 737 { … … 740 755 /* "what" should be an application object */ 741 756 SEARCH_childs_parent( DICT_APPLICATION, &dict->dict_vendors ); 757 break; 758 759 case VENDOR_OF_AVP: 760 /* "what" should be an avp object */ 761 SEARCH_sentinel( DICT_AVP, 0, 1 ); 742 762 break; 743 763 … … 1248 1268 struct fd_list * li = sentinel; 1249 1269 /* We don't lock here, the caller must have taken the dictionary lock for reading already */ 1250 while (li->next != sentinel) 1251 { 1252 li = li->next; 1253 CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, _O(li->o), parents, depth, indent ), return NULL); 1270 if (FD_IS_LIST_EMPTY(sentinel)) { 1271 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n%*s{empty list}", indent, ""), return NULL); 1272 } else { 1273 while (li->next != sentinel) 1274 { 1275 li = li->next; 1276 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL); 1277 CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, _O(li->o), parents, depth, indent ), return NULL); 1278 } 1254 1279 } 1255 1280 } … … 1260 1285 1261 1286 if (!verify_object(obj)) { 1262 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID/NULL \n"), return NULL);1287 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID/NULL"), return NULL); 1263 1288 return *buf; 1264 1289 } … … 1274 1299 } 1275 1300 1276 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL);1277 1278 1301 if (parents) { 1279 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " %*sparent:", indent + 1, ""), return NULL);1302 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n%*sparent:", indent + 1, ""), return NULL); 1280 1303 CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, obj->parent, parents-1, 0, 0 ), return NULL); 1281 1304 } … … 1285 1308 for (i=0; i<NB_LISTS_PER_OBJ; i++) { 1286 1309 if ((obj->list[i].o == NULL) && (obj->list[i].next != &obj->list[i])) { 1287 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%*slist[%d]:\n", indent + 1, "", i), return NULL);1288 1310 CHECK_MALLOC_DO( dump_list(FD_DUMP_STD_PARAMS, &obj->list[i], 0, depth - 1, indent + 2), return NULL); 1311 break; /* we get duplicate information sorted by another criteria otherwise, which is not very useful */ 1289 1312 } 1290 1313 } … … 1296 1319 DECLARE_FD_DUMP_PROTOTYPE(fd_dict_dump_object, struct dict_object * obj) 1297 1320 { 1298 size_t o = 0; 1299 1300 if (!offset) 1301 offset = &o; 1321 FD_DUMP_HANDLE_OFFSET(); 1302 1322 1303 1323 CHECK_MALLOC_DO( dump_object(FD_DUMP_STD_PARAMS, obj, 1, 2, 0), return NULL); … … 1310 1330 int i; 1311 1331 struct fd_list * li; 1312 size_t o = 0; 1313 1314 if (!offset) 1315 offset = &o; 1332 1333 FD_DUMP_HANDLE_OFFSET(); 1316 1334 1317 1335 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{dictionary}(@%p): ", dict), return NULL); 1318 1336 1319 1337 if ((dict == NULL) || (dict->dict_eyec != DICT_EYECATCHER)) { 1320 return fd_dump_extend(FD_DUMP_STD_PARAMS, "INVALID/NULL \n");1338 return fd_dump_extend(FD_DUMP_STD_PARAMS, "INVALID/NULL"); 1321 1339 } 1322 1340 1323 1341 CHECK_POSIX_DO( pthread_rwlock_rdlock( &dict->dict_lock ), /* ignore */ ); 1324 1342 1325 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict :%p > vendors, AVPs and related rules}\n", dict), goto error);1343 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict(%p) : VENDORS / AVP / RULES}\n", dict), goto error); 1326 1344 CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, &dict->dict_vendors, 0, 3, 3 ), goto error); 1327 for (li = dict->dict_vendors.list[0].next; li != &dict->dict_vendors.list[0]; li = li->next) 1345 for (li = dict->dict_vendors.list[0].next; li != &dict->dict_vendors.list[0]; li = li->next) { 1346 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL); 1328 1347 CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, li->o, 0, 3, 3 ), goto error); 1329 1330 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {dict:%p > applications}\n", dict), goto error); 1348 } 1349 1350 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict(%p) : APPLICATIONS}\n", dict), goto error); 1331 1351 CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, &dict->dict_applications, 0, 1, 3 ), goto error); 1332 for (li = dict->dict_applications.list[0].next; li != &dict->dict_applications.list[0]; li = li->next) 1352 for (li = dict->dict_applications.list[0].next; li != &dict->dict_applications.list[0]; li = li->next) { 1353 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL); 1333 1354 CHECK_MALLOC_DO( dump_object (FD_DUMP_STD_PARAMS, li->o, 0, 1, 3 ), goto error); 1334 1335 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {dict:%p > types}\n", dict), goto error); 1355 } 1356 1357 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict(%p) : TYPES / ENUMVAL}", dict), goto error); 1336 1358 CHECK_MALLOC_DO( dump_list(FD_DUMP_STD_PARAMS, &dict->dict_types, 0, 2, 3 ), goto error); 1337 1359 1338 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {dict:%p > commands}\n", dict), goto error);1360 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict(%p) : COMMANDS / RULES}", dict), goto error); 1339 1361 CHECK_MALLOC_DO( dump_list(FD_DUMP_STD_PARAMS, &dict->dict_cmd_code, 0, 0, 3 ), goto error); 1340 1362 1341 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {dict:%p > statistics}\n", dict), goto error);1363 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {dict(%p) : statistics}", dict), goto error); 1342 1364 for (i=1; i<=DICT_TYPE_MAX; i++) 1343 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " %5d: %s\n", dict->dict_count[i], dict_obj_info[i].name), goto error);1365 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n %5d: %s", dict->dict_count[i], dict_obj_info[i].name), goto error); 1344 1366 1345 1367 CHECK_POSIX_DO( pthread_rwlock_unlock( &dict->dict_lock ), /* ignore */ ); … … 1485 1507 char * type_name = NULL; 1486 1508 char * const_name = NULL; 1487 size_t o = 0; 1488 1489 if (!offset) 1490 offset = &o; 1509 1510 FD_DUMP_HANDLE_OFFSET(); 1491 1511 1492 1512 /* Check the parameters are correct */ -
libfdproto/dictionary_functions.c
r1085 r1093 162 162 } s; 163 163 uint16_t fam; 164 size_t o = 0; 165 166 if (!offset) 167 offset = &o; 164 165 FD_DUMP_HANDLE_OFFSET(); 168 166 169 167 memset(&s, 0, sizeof(s)); … … 213 211 DECLARE_FD_DUMP_PROTOTYPE(fd_dictfct_UTF8String_dump, union avp_value * avp_value) 214 212 { 215 size_t o = 0, l; 216 if (!offset) 217 offset = &o; 213 size_t l; 214 FD_DUMP_HANDLE_OFFSET(); 218 215 219 216 l = avp_value->os.len; … … 305 302 DECLARE_FD_DUMP_PROTOTYPE(fd_dictfct_Time_dump, union avp_value * avp_value) 306 303 { 307 size_t o = 0;308 304 time_t val; 309 305 struct tm conv; 310 306 311 if (!offset) 312 offset = &o; 307 FD_DUMP_HANDLE_OFFSET(); 313 308 314 309 if (avp_value->os.len != 4) { -
libfdproto/fifo.c
r1085 r1093 121 121 DECLARE_FD_DUMP_PROTOTYPE(fd_fifo_dump, char * name, struct fifo * queue, fd_fifo_dump_item_cb dump_item) 122 122 { 123 size_t o = 0; 124 if (!offset) 125 offset = &o; 123 FD_DUMP_HANDLE_OFFSET(); 126 124 127 125 if (name) { … … 132 130 133 131 if (!CHECK_FIFO( queue )) { 134 return fd_dump_extend(FD_DUMP_STD_PARAMS, "INVALID/NULL \n");132 return fd_dump_extend(FD_DUMP_STD_PARAMS, "INVALID/NULL"); 135 133 } 136 134 137 135 CHECK_POSIX_DO( pthread_mutex_lock( &queue->mtx ), /* continue */ ); 138 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "items:%d,%d,%d threads:%d,%d stats:%lld/%ld.%06ld,%ld.%06ld,%ld.%06ld thresholds:%d,%d,%d,%p,%p,%p \n",136 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "items:%d,%d,%d threads:%d,%d stats:%lld/%ld.%06ld,%ld.%06ld,%ld.%06ld thresholds:%d,%d,%d,%p,%p,%p", 139 137 queue->count, queue->highest_ever, queue->max, 140 138 queue->thrs, queue->thrs_push, … … 148 146 for (li = queue->list.next; li != &queue->list; li = li->next) { 149 147 struct fifo_item * fi = (struct fifo_item *)li; 150 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " [#%i](@%p)@%ld.%06ld: ",148 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n [#%i](@%p)@%ld.%06ld: ", 151 149 i++, fi->item.o, (long)fi->posted_on.tv_sec,(long)(fi->posted_on.tv_nsec/1000)), 152 150 goto error); … … 155 153 } 156 154 CHECK_POSIX_DO( pthread_mutex_unlock( &queue->mtx ), /* continue */ ); 155 157 156 return *buf; 158 157 error: -
libfdproto/messages.c
r1092 r1093 721 721 /* Debug functions: dumping */ 722 722 723 /* messages and AVP formatters */ 724 typedef DECLARE_FD_DUMP_PROTOTYPE( (*msg_dump_formatter_msg), struct msg * msg ); 725 typedef DECLARE_FD_DUMP_PROTOTYPE( (*msg_dump_formatter_avp), struct avp * avp, int level ); 726 727 /* Core function to process the dumping */ 728 static DECLARE_FD_DUMP_PROTOTYPE( msg_dump_process, msg_dump_formatter_msg msg_format, msg_dump_formatter_avp avp_format, msg_or_avp *obj, struct dictionary *dict, int force_parsing, int recurse ) 729 { 730 FD_DUMP_HANDLE_OFFSET(); 731 732 if (force_parsing) { 733 (void) fd_msg_parse_dict(obj, dict, NULL); 734 } 735 736 switch (_C(obj)->type) { 737 case MSG_AVP: 738 CHECK_MALLOC_DO( (*avp_format)(FD_DUMP_STD_PARAMS, (struct avp *)obj, 0), return NULL); 739 break; 740 741 case MSG_MSG: 742 CHECK_MALLOC_DO( (*msg_format)(FD_DUMP_STD_PARAMS, (struct msg *)obj), return NULL); 743 break; 744 745 default: 746 ASSERT(0); 747 } 748 749 if (recurse) { 750 struct avp * avp = NULL; 751 CHECK_FCT_DO( fd_msg_browse ( obj, MSG_BRW_FIRST_CHILD, &avp, NULL ), avp = NULL ); 752 while (avp) { 753 CHECK_MALLOC_DO( (*avp_format)(FD_DUMP_STD_PARAMS, avp, 1), return NULL); 754 CHECK_FCT_DO( fd_msg_browse ( avp, MSG_BRW_NEXT, &avp, NULL ), avp = NULL ); 755 }; 756 } 757 758 /* we remove the final \n if any */ 759 FD_DUMP_HANDLE_TRAIL(); 760 761 return *buf; 762 } 763 764 /* 765 * Tree View message dump 766 */ 767 768 static DECLARE_FD_DUMP_PROTOTYPE( msg_format_treeview, struct msg * msg ) 769 { 770 if (!CHECK_MSG(msg)) { 771 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{message}(@%p): INVALID\n", msg), return NULL); 772 return *buf; 773 } 774 775 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{message}(@%p): ", msg), return NULL); 776 if (!msg->msg_model) { 777 if (msg->msg_model_not_found.mnf_code) { 778 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(not found in dictionary)\n"), return NULL); 779 } else { 780 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(not searched in dictionary)\n"), return NULL); 781 } 782 } else { 783 enum dict_object_type dicttype; 784 struct dict_cmd_data dictdata; 785 if (fd_dict_gettype(msg->msg_model, &dicttype) || (dicttype != DICT_COMMAND)) { 786 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(invalid model information)\n"), return NULL); 787 } else if (fd_dict_getval(msg->msg_model, &dictdata)) { 788 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(error getting model information)\n"), return NULL); 789 } else { 790 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "'%s'\n", dictdata.cmd_name), return NULL); 791 } 792 } 793 794 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Version: 0x%02hhX\n", msg->msg_public.msg_version), return NULL); 795 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Length: %d\n", msg->msg_public.msg_length), return NULL); 796 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); 797 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Command Code: %u\n", msg->msg_public.msg_code), return NULL); 798 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " ApplicationId: %d\n", msg->msg_public.msg_appl), return NULL); 799 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Hop-by-Hop Identifier: 0x%8X\n", msg->msg_public.msg_hbhid), return NULL); 800 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " End-to-End Identifier: 0x%8X\n", msg->msg_public.msg_eteid), return NULL); 801 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\n", 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); 802 803 return *buf; 804 } 805 806 static DECLARE_FD_DUMP_PROTOTYPE( avp_format_treeview, struct avp * avp, int level ) 807 { 808 char * name; 809 struct dict_avp_data dictdata; 810 struct dict_avp_data *dictinfo = NULL; 811 struct dict_vendor_data vendordata; 812 struct dict_vendor_data *vendorinfo = NULL; 813 if (!CHECK_AVP(avp)) { 814 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{avp}(@%p): INVALID\n", avp), return NULL); 815 return *buf; 816 } 817 818 if (!level) { 819 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{avp}(@%p): ", avp), return NULL); 820 } else { 821 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%*sAVP: ", level * 3, ""), return NULL); 822 } 823 824 if (!avp->avp_model) { 825 if (avp->avp_model_not_found.mnf_code) { 826 name = "(not found in dictionary)"; 827 } else { 828 name = "(not searched in dictionary)"; 829 } 830 } else { 831 enum dict_object_type dicttype; 832 if (fd_dict_gettype(avp->avp_model, &dicttype) || (dicttype != DICT_AVP)) { 833 name = "(invalid model information)"; 834 } else if (fd_dict_getval(avp->avp_model, &dictdata)) { 835 name = "(error getting model information)"; 836 } else { 837 name = dictdata.avp_name; 838 dictinfo = &dictdata; 839 if (avp->avp_public.avp_flags & AVP_FLAG_VENDOR) { 840 struct dictionary * dict; 841 struct dict_object * vendor; 842 if ((!fd_dict_getdict(avp->avp_model, &dict)) 843 && (!fd_dict_search(dict, DICT_VENDOR, VENDOR_OF_AVP, avp->avp_model, &vendor, ENOENT)) 844 && (!fd_dict_getval(vendor, &vendordata))) { 845 vendorinfo = &vendordata; 846 } 847 } 848 } 849 } 850 851 if (dictinfo) { 852 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "'%s'(%u)", name, avp->avp_public.avp_code), return NULL); 853 } else { 854 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%u%s", avp->avp_public.avp_code, name), return NULL); 855 } 856 857 if (avp->avp_public.avp_flags & AVP_FLAG_VENDOR) { 858 if (vendorinfo) { 859 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " vend='%s'(%u)", vendorinfo->vendor_name, avp->avp_public.avp_vendor), return NULL); 860 } else { 861 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " vend=%u", avp->avp_public.avp_vendor), return NULL); 862 } 863 } 864 865 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " l=%d f=" DUMP_AVPFL_str " val=", avp->avp_public.avp_len, DUMP_AVPFL_val(avp->avp_public.avp_flags)), return NULL); 866 867 if (dictinfo && (dictinfo->avp_basetype == AVP_TYPE_GROUPED)) { 868 struct avp * inavp = NULL; 869 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(grouped)\n"), return NULL); 870 CHECK_FCT_DO( fd_msg_browse ( avp, MSG_BRW_FIRST_CHILD, &inavp, NULL ), inavp = NULL ); 871 while (inavp) { 872 CHECK_MALLOC_DO( avp_format_treeview(FD_DUMP_STD_PARAMS, inavp, level + 1), return NULL); 873 CHECK_FCT_DO( fd_msg_browse ( inavp, MSG_BRW_NEXT, &inavp, NULL ), inavp = NULL ); 874 }; 875 } else { 876 if (avp->avp_public.avp_value) { 877 CHECK_MALLOC_DO( fd_dict_dump_avp_value(FD_DUMP_STD_PARAMS, avp->avp_public.avp_value, avp->avp_model, 0, 0), return NULL); 878 } else if (avp->avp_rawdata) { 879 CHECK_MALLOC_DO( fd_dump_extend_hexdump(FD_DUMP_STD_PARAMS, avp->avp_rawdata, avp->avp_rawlen, 0, 0), return NULL); 880 } else { 881 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "(not set)"), return NULL); 882 } 883 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL); 884 } 885 886 return *buf; 887 } 888 889 /* multi-line human-readable dump similar to wireshark output */ 890 DECLARE_FD_DUMP_PROTOTYPE( fd_msg_dump_treeview, msg_or_avp *obj, struct dictionary *dict, int force_parsing, int recurse ) 891 { 892 return msg_dump_process(FD_DUMP_STD_PARAMS, msg_format_treeview, avp_format_treeview, obj, dict, force_parsing, recurse); 893 } 894 895 723 896 #warning "todo" 724 DECLARE_FD_DUMP_PROTOTYPE( fd_msg_dump_summary, msg_or_avp *obj, struct dictionary *dict, int force_parsing, int recurse )725 {726 return NULL;727 }728 897 /* one-line dump with all the contents of the message */ 729 898 DECLARE_FD_DUMP_PROTOTYPE( fd_msg_dump_full, msg_or_avp *obj, struct dictionary *dict, int force_parsing, int recurse ) … … 731 900 return NULL; 732 901 } 733 /* multi-line human-readable dump similar to wireshark output */ 734 DECLARE_FD_DUMP_PROTOTYPE( fd_msg_dump_treeview, msg_or_avp *obj, struct dictionary *dict, int force_parsing, int recurse ) 902 903 /* This one only prints a short display, does not go into the complete tree */ 904 DECLARE_FD_DUMP_PROTOTYPE( fd_msg_dump_summary, msg_or_avp *obj, struct dictionary *dict, int force_parsing, int recurse ) 735 905 { 736 906 return NULL; -
libfdproto/sessions.c
r1088 r1093 877 877 DECLARE_FD_DUMP_PROTOTYPE(fd_sess_dump, struct session * session, int with_states) 878 878 { 879 size_t o = 0; 880 if (!offset) 881 offset = &o; 879 FD_DUMP_HANDLE_OFFSET(); 882 880 883 881 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{session}(@%p): ", session), return NULL); 884 882 885 883 if (!VALIDATE_SI(session)) { 886 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID/NULL \n"), return NULL);884 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID/NULL"), return NULL); 887 885 } else { 888 886 char timebuf[30]; … … 890 888 891 889 strftime(timebuf, sizeof(timebuf), "%D,%T", localtime_r( &session->timeout.tv_sec , &tm )); 892 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "'%s'(%zd) h:%x m:%d d:%d to:%s.%06ld \n",890 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "'%s'(%zd) h:%x m:%d d:%d to:%s.%06ld", 893 891 session->sid, session->sidlen, session->hash, session->msg_cnt, session->is_destroyed, 894 892 timebuf, session->timeout.tv_nsec/1000), … … 902 900 for (li = session->states.next; li != &session->states; li = li->next) { 903 901 struct state * st = (struct state *)(li->o); 904 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {state i:%d}(@%p): \n", st->hdl->id, st), return NULL);902 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {state i:%d}(@%p): ", st->hdl->id, st), return NULL); 905 903 if (st->hdl->state_dump) { 906 904 CHECK_MALLOC_DO( (*st->hdl->state_dump)( FD_DUMP_STD_PARAMS, st->state), 907 fd_dump_extend( FD_DUMP_STD_PARAMS, "[dumper error] \n"));905 fd_dump_extend( FD_DUMP_STD_PARAMS, "[dumper error]")); 908 906 } else { 909 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "<%p> \n", st->state), return NULL);907 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "<%p>", st->state), return NULL); 910 908 } 911 909 } … … 915 913 } 916 914 } 915 917 916 return *buf; 918 917 } … … 920 919 DECLARE_FD_DUMP_PROTOTYPE(fd_sess_dump_hdl, struct session_handler * handler) 921 920 { 922 size_t o = 0; 923 if (!offset) 924 offset = &o; 921 FD_DUMP_HANDLE_OFFSET(); 925 922 926 923 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{sesshdl}(@%p): ", handler), return NULL); 927 924 928 925 if (!VALIDATE_SH(handler)) { 929 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID/NULL \n"), return NULL);926 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID/NULL"), return NULL); 930 927 } else { 931 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "i:%d cl:%p d:%p o:%p \n", handler->id, handler->cleanup, handler->state_dump, handler->opaque), return NULL);928 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "i:%d cl:%p d:%p o:%p", handler->id, handler->cleanup, handler->state_dump, handler->opaque), return NULL); 932 929 } 933 930 return *buf; -
libfdproto/utils.c
r1085 r1093 39 39 { 40 40 char addrbuf[INET6_ADDRSTRLEN]; 41 size_t o = 0; 42 if (!offset) 43 offset = &o; 41 FD_DUMP_HANDLE_OFFSET(); 44 42 45 43 if (sa) { … … 61 59 char addrbuf[INET6_ADDRSTRLEN]; 62 60 char servbuf[32]; 63 size_t o = 0; 64 if (!offset) 65 offset = &o; 61 FD_DUMP_HANDLE_OFFSET(); 66 62 67 63 if (sa) {
Note: See TracChangeset
for help on using the changeset viewer.