changeset 602:0b5d21c87855

Added new AVP search criteria in the dictionary: AVP_BY_NAME_ALL_VENDORS
author Sebastien Decugis <sdecugis@nict.go.jp>
date Thu, 25 Nov 2010 16:27:54 +0900
parents 73d7588870b9
children 4df4119a51b1
files include/freeDiameter/libfreeDiameter.h libfreeDiameter/dictionary.c
diffstat 2 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/include/freeDiameter/libfreeDiameter.h	Fri Nov 19 17:36:52 2010 +0900
+++ b/include/freeDiameter/libfreeDiameter.h	Thu Nov 25 16:27:54 2010 +0900
@@ -1209,7 +1209,8 @@
 	AVP_BY_CODE = 50,	/* "what" points to an avp_code_t, vendor is always 0 */
 	AVP_BY_NAME,		/* "what" points to a string, vendor is always 0 */
 	AVP_BY_CODE_AND_VENDOR,	/* "what" points to a struct dict_avp_request (see bellow), where avp_vendor and avp_code are set */
-	AVP_BY_NAME_AND_VENDOR	/* "what" points to a struct dict_avp_request (see bellow), where avp_vendor and avp_name are set */
+	AVP_BY_NAME_AND_VENDOR,	/* "what" points to a struct dict_avp_request (see bellow), where avp_vendor and avp_name are set */
+	AVP_BY_NAME_ALL_VENDORS /* "what" points to a string. Might be quite slow... */
 };
 
 /* Struct used for some researchs */
--- a/libfreeDiameter/dictionary.c	Fri Nov 19 17:36:52 2010 +0900
+++ b/libfreeDiameter/dictionary.c	Thu Nov 25 16:27:54 2010 +0900
@@ -591,11 +591,11 @@
 	int __cmp;								\
 	struct fd_list * __li;							\
 	ret = 0;								\
-	for  (__li = (sentinel); __li->next != (sentinel); __li = __li->next) {	\
-		__cmp = strcmp(__str, _O(__li->next->o)->data. datafield );	\
+	for  (__li = (sentinel)->next; __li != (sentinel); __li = __li->next) {	\
+		__cmp = strcmp(__str, _O(__li->o)->data. datafield );		\
 		if (__cmp == 0) {						\
 			if (result)						\
-				*result = _O(__li->next->o);			\
+				*result = _O(__li->o);				\
 			goto end;						\
 		}								\
 		if ((isindex) && (__cmp < 0))					\
@@ -973,6 +973,20 @@
 			}
 			break;
 		
+		case AVP_BY_NAME_ALL_VENDORS:
+			{
+				struct fd_list * li;
+				
+				/* First, search for vendor 0 */
+				SEARCH_string( what, &dict->dict_vendors.list[2], avp.avp_name, 1);
+				
+				/* If not found, loop for all vendors, until found */
+				for (li = dict->dict_vendors.list[0].next; li != &dict->dict_vendors.list[0]; li = li->next) {
+					SEARCH_string( what, &_O(li->o)->list[2], avp.avp_name, 1);
+				}
+			}
+			break;
+		
 		default:
 			/* Invalid criteria */
 			CHECK_PARAMS( criteria = 0 );
"Welcome to our mercurial repository"