Changeset 156:e2dc300819b3 in freeDiameter for libfreeDiameter/messages.c
- Timestamp:
- Jan 20, 2010, 4:04:25 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfreeDiameter/messages.c
r132 r156 691 691 } 692 692 693 #define DUMP_VALUE(_format, _parms...) fd_log_debug(INOBJHDR "value : t:'%s' v:'" _format "'\n", INOBJHDRVAL, typename, ## _parms);694 /* Dump an AVP value that is not a constant */695 static void dump_basic_type(union avp_value * value, enum dict_avp_basetype type, const char * typename, int indent)696 {697 switch (type) {698 case AVP_TYPE_GROUPED:699 DUMP_VALUE("%s", "error: grouped AVP with a value!");700 break;701 702 case AVP_TYPE_OCTETSTRING:703 {704 /* Dump only up to 16 bytes of the buffer */705 unsigned char buf[8];706 memset(buf, 0, sizeof(buf));707 memcpy(buf, value->os.data, value->os.len < sizeof(buf) ? value->os.len : sizeof(buf) );708 DUMP_VALUE("l:%d, v:%02.2X %02.2X %02.2X %02.2X %02.2X %02.2X %02.2X %02.2X ... ('%.*s')",709 value->os.len,710 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7],711 value->os.len, value->os.data712 );713 }714 break;715 716 case AVP_TYPE_INTEGER32:717 DUMP_VALUE("%i",value->i32);718 break;719 720 case AVP_TYPE_INTEGER64:721 DUMP_VALUE("%lli (0x%llx)",value->i64,value->i64);722 break;723 724 case AVP_TYPE_UNSIGNED32:725 DUMP_VALUE("%u",value->u32);726 break;727 728 case AVP_TYPE_UNSIGNED64:729 DUMP_VALUE("%llu",value->u64);730 break;731 732 case AVP_TYPE_FLOAT32:733 DUMP_VALUE("%f",value->f32);734 break;735 736 case AVP_TYPE_FLOAT64:737 DUMP_VALUE("%g",value->f64);738 break;739 740 default:741 DUMP_VALUE("%s %d", "error: invalid type :", type);742 }743 }744 745 /* Dump an AVP value that is a constant */746 #define DUMP_CONST(_format, _parms...) fd_log_debug(INOBJHDR "value : t:'%s' v:'%s' ( " _format " )\n", INOBJHDRVAL, typename, value->enum_name, ## _parms);747 static void dump_constant_type(struct dict_enumval_data * value, enum dict_avp_basetype type, char * typename, int indent)748 {749 switch (type) {750 case AVP_TYPE_GROUPED:751 DUMP_CONST("%s", "error: grouped AVP with a constant value!");752 break;753 case AVP_TYPE_OCTETSTRING:754 DUMP_CONST("%s", "value skipped");755 break;756 757 case AVP_TYPE_INTEGER32:758 DUMP_CONST("%i",value->enum_value.i32);759 break;760 761 case AVP_TYPE_INTEGER64:762 DUMP_CONST("%li",value->enum_value.i64);763 break;764 765 case AVP_TYPE_UNSIGNED32:766 DUMP_CONST("%u",value->enum_value.u32);767 break;768 769 case AVP_TYPE_UNSIGNED64:770 DUMP_CONST("%lu",value->enum_value.u64);771 break;772 773 case AVP_TYPE_FLOAT32:774 DUMP_CONST("%f",value->enum_value.f32);775 break;776 777 case AVP_TYPE_FLOAT64:778 DUMP_CONST("%g",value->enum_value.f64);779 break;780 781 default:782 DUMP_CONST("%s %d", "error: invalid type :", type);783 }784 }785 786 693 /* Dump an avp object */ 787 694 static void obj_dump_avp ( struct avp * avp, int indent ) … … 834 741 fd_log_debug(INOBJHDR "(data set but no model: ERROR)\n", INOBJHDRVAL); 835 742 } else { 836 /* Try and find a constant name for this value */ 837 struct dictionary * dict = NULL; 838 struct dict_object * avp_type = NULL; 839 struct dict_object * avp_constant = NULL; 840 struct dict_type_data type_data; 841 struct dict_enumval_request request; 842 ret = fd_dict_getdict(avp->avp_model, & dict); 843 if (ret != 0) { 844 dump_basic_type(avp->avp_public.avp_value, type, type_base_name[type], indent); 845 goto end; 846 } 847 ret = fd_dict_search(dict, DICT_TYPE, TYPE_OF_AVP, avp->avp_model, &avp_type, ENOENT); 848 if (ret != 0) { 849 dump_basic_type(avp->avp_public.avp_value, type, type_base_name[type], indent); 850 goto end; 851 } 852 ret = fd_dict_getval(avp_type, &type_data); 853 if (ret != 0) { 854 dump_basic_type(avp->avp_public.avp_value, type, "(error getting type data)", indent); 855 goto end; 856 } 857 if (type_data.type_base != type) { 858 dump_basic_type(avp->avp_public.avp_value, type, "(mismatching type information!)", indent); 859 goto end; 860 } 861 /* Create a query for a constant */ 862 memset(&request, 0, sizeof(request)); 863 request.type_obj = avp_type; 864 memcpy(&request.search.enum_value, avp->avp_public.avp_value, sizeof(union avp_value)); 865 ret = fd_dict_search(dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &avp_constant, ENOENT); 866 if (ret != 0) { 867 dump_basic_type(avp->avp_public.avp_value, type, type_data.type_name, indent); 868 goto end; 869 } 870 /* get the constant's information; we re-use request.search field */ 871 ret = fd_dict_getval(avp_constant, &request.search); 872 if (ret != 0) { 873 dump_basic_type(avp->avp_public.avp_value, type, "(error getting constant data)", indent); 874 goto end; 875 } 876 dump_constant_type(&request.search, type, type_data.type_name, indent); 743 fd_dict_dump_avp_value(avp->avp_public.avp_value, avp->avp_model, indent); 877 744 } 878 745 }
Note: See TracChangeset
for help on using the changeset viewer.