changeset 280:3019f6220122

Provide more useful debug information for non-ABNF-compliant messages
author Sebastien Decugis <sdecugis@nict.go.jp>
date Tue, 27 Apr 2010 10:44:43 +0900
parents a26655da5c14
children 50aaa4028967
files libfreeDiameter/messages.c
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libfreeDiameter/messages.c	Mon Apr 26 17:41:53 2010 +0900
+++ b/libfreeDiameter/messages.c	Tue Apr 27 10:44:43 2010 +0900
@@ -1872,17 +1872,20 @@
 {
 	int count, first, last, min;
 	struct parserules_data * pr_data = data;
+	char * avp_name = "<unresolved name>";
 	
 	TRACE_ENTRY("%p %p", data, rule);
 	
 	/* Get statistics of the AVP concerned by this rule in the parent instance */
 	parserules_stat_avps( rule->rule_avp, pr_data->sentinel, &count, &first, &last);
 	
-	if (TRACE_BOOL(ANNOYING))
+	if (TRACE_BOOL(INFO))
 	{
 		struct dict_avp_data avpdata;
 		int ret;
 		ret = fd_dict_getval(rule->rule_avp, &avpdata);
+		if (ret == 0)
+			avp_name = avpdata.avp_name;
 		
 		TRACE_DEBUG(ANNOYING, "Checking rule: p:%d(%d) m/M:%2d/%2d. Counted %d (first: %d, last:%d) of AVP '%s'", 
 					rule->rule_position,
@@ -1892,7 +1895,7 @@
 					count, 
 					first, 
 					last,
-					(ret == 0) ? avpdata.avp_name : "???"
+					avp_name
 				);
 	}
 	
@@ -1906,7 +1909,7 @@
 			min = 1;
 	}
 	if (count < min) {
-		TRACE_DEBUG(INFO, "Conflicting rule: the number of occurences (%d) is < the rule min (%d).", count, min);
+		TRACE_DEBUG(INFO, "Conflicting rule: the number of occurences (%d) is < the rule min (%d) for '%s'.", count, min, avp_name);
 		if (pr_data->pei) {
 			pr_data->pei->pei_errcode = "DIAMETER_MISSING_AVP";
 			pr_data->pei->pei_avp = empty_avp(rule->rule_avp);
@@ -1916,7 +1919,7 @@
 	
 	/* Check the "max" value */
 	if ((rule->rule_max != -1) && (count > rule->rule_max)) {
-		TRACE_DEBUG(INFO, "Conflicting rule: the number of occurences (%d) is > the rule max (%d).", count, rule->rule_max);
+		TRACE_DEBUG(INFO, "Conflicting rule: the number of occurences (%d) is > the rule max (%d) for '%s'.", count, rule->rule_max, avp_name);
 		if (pr_data->pei) {
 			if (rule->rule_max == 0)
 				pr_data->pei->pei_errcode = "DIAMETER_AVP_NOT_ALLOWED";
@@ -1937,7 +1940,7 @@
 		case RULE_FIXED_HEAD:
 			/* Since "0*1<fixed>" is a valid rule specifier, we only reject cases where the AVP appears *after* its fixed position */
 			if (first > rule->rule_order) {
-				TRACE_DEBUG(INFO, "Conflicting rule: the FIXED_HEAD AVP appears first in (%d) position, the rule requires (%d).", first, rule->rule_order);
+				TRACE_DEBUG(INFO, "Conflicting rule: the FIXED_HEAD AVP appears first in (%d) position, the rule requires (%d) for '%s'.", first, rule->rule_order, avp_name);
 				if (pr_data->pei) {
 					pr_data->pei->pei_errcode = "DIAMETER_MISSING_AVP";
 					pr_data->pei->pei_message = "AVP was not in its fixed position";
@@ -1950,7 +1953,7 @@
 		case RULE_FIXED_TAIL:
 			/* Since "0*1<fixed>" is a valid rule specifier, we only reject cases where the AVP appears *before* its fixed position */
 			if (last > rule->rule_order) {	/* We have a ">" here because we count in reverse order (i.e. from the end) */
-				TRACE_DEBUG(INFO, "Conflicting rule: the FIXED_TAIL AVP appears last in (%d) position, the rule requires (%d).", last, rule->rule_order);
+				TRACE_DEBUG(INFO, "Conflicting rule: the FIXED_TAIL AVP appears last in (%d) position, the rule requires (%d) for '%s'.", last, rule->rule_order, avp_name);
 				if (pr_data->pei) {
 					pr_data->pei->pei_errcode = "DIAMETER_MISSING_AVP";
 					pr_data->pei->pei_message = "AVP was not in its fixed position";
"Welcome to our mercurial repository"