Browse code

core: function to print xavus for debugging

Daniel-Constantin Mierla authored on 01/04/2020 11:36:24
Showing 2 changed files
... ...
@@ -570,60 +570,66 @@ sr_xavp_t **xavp_get_crt_list(void)
570 570
 	return _xavp_list_crt;
571 571
 }
572 572
 
573
-void xavp_print_list_content(sr_xavp_t **head, int level)
573
+void xavx_print_list_content(char *name, sr_xavp_t **head, sr_xavp_t **rlist, int level)
574 574
 {
575 575
 	sr_xavp_t *avp=0;
576 576
 	sr_xavp_t *start=0;
577 577
 
578
-	if(head!=NULL)
578
+	if(head!=NULL) {
579 579
 		start = *head;
580
-	else
581
-		start=*_xavp_list_crt;
582
-	LM_INFO("+++++ start XAVP list: %p (%p) (level=%d)\n", start, head, level);
580
+	} else {
581
+		start=*rlist;
582
+	}
583
+	LM_INFO("+++++ start %s list: %p (%p) (level=%d)\n", name, start, head, level);
583 584
 	avp = start;
584 585
 	while(avp)
585 586
 	{
586
-		LM_INFO("     *** (l:%d - %p) XAVP name: %s\n", level, avp, avp->name.s);
587
-		LM_INFO("     XAVP id: %u\n", avp->id);
588
-		LM_INFO("     XAVP value type: %d\n", avp->val.type);
587
+		LM_INFO("     *** (l:%d - %p) %s name: %s\n", level, avp, name, avp->name.s);
588
+		LM_INFO("     %s id: %u\n", name, avp->id);
589
+		LM_INFO("     %s value type: %d\n", name, avp->val.type);
589 590
 		switch(avp->val.type) {
590 591
 			case SR_XTYPE_NULL:
591
-				LM_INFO("     XAVP value: <null>\n");
592
+				LM_INFO("     %s value: <null>\n", name);
592 593
 			break;
593 594
 			case SR_XTYPE_INT:
594
-				LM_INFO("     XAVP value (int): %d\n", avp->val.v.i);
595
+				LM_INFO("     %s value (int): %d\n", name, avp->val.v.i);
595 596
 			break;
596 597
 			case SR_XTYPE_STR:
597
-				LM_INFO("     XAVP value (str): %s\n", avp->val.v.s.s);
598
+				LM_INFO("     %s value (str): %s\n", name, avp->val.v.s.s);
598 599
 			break;
599 600
 			case SR_XTYPE_TIME:
600
-				LM_INFO("     XAVP value (time): %lu\n",
601
+				LM_INFO("     %s value (time): %lu\n", name,
601 602
 						(long unsigned int)avp->val.v.t);
602 603
 			break;
603 604
 			case SR_XTYPE_LONG:
604
-				LM_INFO("     XAVP value (long): %ld\n", avp->val.v.l);
605
+				LM_INFO("     %s value (long): %ld\n", name, avp->val.v.l);
605 606
 			break;
606 607
 			case SR_XTYPE_LLONG:
607
-				LM_INFO("     XAVP value (llong): %lld\n", avp->val.v.ll);
608
+				LM_INFO("     %s value (llong): %lld\n", name, avp->val.v.ll);
608 609
 			break;
609 610
 			case SR_XTYPE_XAVP:
610
-				LM_INFO("     XAVP value: <xavp:%p>\n", avp->val.v.xavp);
611
-				xavp_print_list_content(&avp->val.v.xavp, level+1);
611
+				LM_INFO("     %s value: <xavp:%p>\n", name, avp->val.v.xavp);
612
+				xavx_print_list_content(name, &avp->val.v.xavp, rlist, level+1);
612 613
 			break;
613 614
 			case SR_XTYPE_VPTR:
614
-				LM_INFO("     XAVP value: <vptr:%p>\n", avp->val.v.vptr);
615
+				LM_INFO("     %s value: <vptr:%p>\n", name, avp->val.v.vptr);
615 616
 			break;
616 617
 			case SR_XTYPE_SPTR:
617
-				LM_INFO("     XAVP value: <sptr:%p>\n", avp->val.v.vptr);
618
+				LM_INFO("     %s value: <sptr:%p>\n", name, avp->val.v.vptr);
618 619
 			break;
619 620
 			case SR_XTYPE_DATA:
620
-				LM_INFO("     XAVP value: <data:%p>\n", avp->val.v.data);
621
+				LM_INFO("     %s value: <data:%p>\n", name, avp->val.v.data);
621 622
 			break;
622 623
 		}
623 624
 		LM_INFO("     *** (l:%d - %p) end\n", level, avp);
624 625
 		avp = avp->next;
625 626
 	}
626
-	LM_INFO("----- end XAVP list: %p (level=%d)\n", start, level);
627
+	LM_INFO("----- end %s list: %p (level=%d)\n", name, start, level);
628
+}
629
+
630
+void xavp_print_list_content(sr_xavp_t **head, int level)
631
+{
632
+	xavx_print_list_content("XAVP", head, _xavp_list_crt, level);
627 633
 }
628 634
 
629 635
 void xavp_print_list(sr_xavp_t **head)
... ...
@@ -1088,6 +1094,13 @@ int xavp_serialize_fields(str *rname, char *obuf, int olen)
1088 1094
  */
1089 1095
 /*** XAVU - eXtended Attribute Value Unique pair - implementation ***/
1090 1096
 
1097
+/**
1098
+ *
1099
+ */
1100
+void xavu_print_list_content(sr_xavp_t **head, int level)
1101
+{
1102
+	xavx_print_list_content("XAVU", head, _xavu_list_crt, level);
1103
+}
1091 1104
 
1092 1105
 /**
1093 1106
  *
... ...
@@ -1164,7 +1177,7 @@ sr_xavp_t *xavu_get(str *name, sr_xavp_t *start)
1164 1177
 	return xavu_get_internal(name, (start)?&start:NULL, NULL);
1165 1178
 }
1166 1179
 
1167
-sr_xavp_t *xavp_lookup(str *name, sr_xavp_t **start)
1180
+sr_xavp_t *xavu_lookup(str *name, sr_xavp_t **start)
1168 1181
 {
1169 1182
 	return xavu_get_internal(name, start, NULL);
1170 1183
 }
... ...
@@ -113,6 +113,7 @@ int xavp_set_child_ival(str *rname, str *cname, int ival);
113 113
 int xavp_set_child_sval(str *rname, str *cname, str *sval);
114 114
 
115 115
 /** xavu api */
116
+void xavu_print_list_content(sr_xavp_t **head, int level);
116 117
 #define xavu_destroy_list_unsafe xavp_destroy_list_unsafe
117 118
 #define xavu_destroy_list xavp_destroy_list
118 119
 void xavu_reset_list(void);