changeset 399:316bb3f38d04

Changed dict_search definition to allow two useful behaviors
author Sebastien Decugis <sdecugis@nict.go.jp>
date Tue, 02 Jun 2009 14:31:42 +0900
parents 11a5d67ee7d4
children 22f29007b931
files extensions/app_test/atst_dict.c extensions/dict_eap/dict_eap.c extensions/dict_nasreq/dict_nasreq.c extensions/radius_gw/rgw_msg.c extensions/rt_any/rt_any.c extensions/rt_default/rt_default.c extensions/sample/sample.c include/waaad/dictionary-api.h waaad/dict-base.c waaad/dictionary.c waaad/dispatch.c waaad/message.c waaad/peer-cer_cea.c waaad/peer-dpr_dpa.c waaad/peer-dwr_dwa.c waaad/tests/testdict.c waaad/tests/testmeq.c waaad/tests/testmesg.c waaad/tests/testrt.c
diffstat 19 files changed, 155 insertions(+), 168 deletions(-) [+]
line wrap: on
line diff
--- a/extensions/app_test/atst_dict.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/extensions/app_test/atst_dict.c	Tue Jun 02 14:31:42 2009 +0900
@@ -96,18 +96,12 @@
 	}
 	
 	/* Now resolve some other useful AVPs */
-	CHECK( dict_search( DICT_AVP, AVP_BY_NAME, "Session-Id", &atst_sess_id) );
-	ASSERT( atst_sess_id != NULL );
-	CHECK( dict_search( DICT_AVP, AVP_BY_NAME, "Origin-Host", &atst_origin_host) );
-	ASSERT( atst_origin_host != NULL );
-	CHECK( dict_search( DICT_AVP, AVP_BY_NAME, "Origin-Realm", &atst_origin_realm) );
-	ASSERT( atst_origin_realm != NULL );
-	CHECK( dict_search( DICT_AVP, AVP_BY_NAME, "Destination-Host", &atst_dest_host) );
-	ASSERT( atst_dest_host != NULL );
-	CHECK( dict_search( DICT_AVP, AVP_BY_NAME, "Destination-Realm", &atst_dest_realm) );
-	ASSERT( atst_dest_realm != NULL );
-	CHECK( dict_search( DICT_AVP, AVP_BY_NAME, "Result-Code", &atst_res_code) );
-	ASSERT( atst_res_code != NULL );
+	CHECK( dict_search( DICT_AVP, AVP_BY_NAME, "Session-Id", &atst_sess_id, ENOENT) );
+	CHECK( dict_search( DICT_AVP, AVP_BY_NAME, "Origin-Host", &atst_origin_host, ENOENT) );
+	CHECK( dict_search( DICT_AVP, AVP_BY_NAME, "Origin-Realm", &atst_origin_realm, ENOENT) );
+	CHECK( dict_search( DICT_AVP, AVP_BY_NAME, "Destination-Host", &atst_dest_host, ENOENT) );
+	CHECK( dict_search( DICT_AVP, AVP_BY_NAME, "Destination-Realm", &atst_dest_realm, ENOENT) );
+	CHECK( dict_search( DICT_AVP, AVP_BY_NAME, "Result-Code", &atst_res_code, ENOENT) );
 	
 	/* Create the rules for Test-Request and Test-Answer */
 	{
--- a/extensions/dict_eap/dict_eap.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/extensions/dict_eap/dict_eap.c	Tue Jun 02 14:31:42 2009 +0900
@@ -69,11 +69,7 @@
 	CHECK_FCT(  dict_new( (_type), (_data), (_parent), (_ref))  );
 
 #define CHECK_dict_search( _type, _criteria, _what, _result )					\
-	CHECK_FCT(  dict_search( (_type), (_criteria), (_what), (_result)) );			\
-	if ( !*(_result) ) {									\
-		TRACE_DEBUG(INFO, "Not found: "#_type ", "#_criteria", "#_what", "#_result );	\
-		return ENOENT;									\
-	}
+	CHECK_FCT(  dict_search( (_type), (_criteria), (_what), (_result), ENOENT) );
 		
 
 typedef struct {
@@ -100,7 +96,7 @@
 			DICT_AVP, 							\
 			AVP_BY_NAME, 							\
 			(_rulearray)[__ar].avp_name, 					\
-			&__data.rule_avp ) );						\
+			&__data.rule_avp, 0 ) );					\
 		if ( !__data.rule_avp ) {						\
 			TRACE_DEBUG(INFO, "AVP Not found: '%s'", (_rulearray)[__ar].avp_name );	\
 			return ENOENT;							\
@@ -123,7 +119,7 @@
 	/* Since we need many AVP from the NASREQ application, check that it is already defined in the dictionary */
 	{
 		application_id_t nasreqid = 1;
-		CHECK_FCT_DO( dict_search( DICT_APPLICATION, APPLICATION_BY_ID_REF, &nasreqid, NULL),
+		CHECK_FCT_DO( dict_search( DICT_APPLICATION, APPLICATION_BY_ID_REF, &nasreqid, NULL, ENOENT),
 		   {
 			log_error("The dict_eap extension needs definitions from NASREQ application (RFC4005).\n"
 				  "Please load the 'dict_nasreq' extension prior to this one.\n");
--- a/extensions/dict_nasreq/dict_nasreq.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/extensions/dict_nasreq/dict_nasreq.c	Tue Jun 02 14:31:42 2009 +0900
@@ -69,11 +69,7 @@
 	CHECK_FCT(  dict_new( (_type), (_data), (_parent), (_ref))  );
 
 #define CHECK_dict_search( _type, _criteria, _what, _result )					\
-	CHECK_FCT(  dict_search( (_type), (_criteria), (_what), (_result)) );			\
-	if ( !*(_result) ) {									\
-		TRACE_DEBUG(INFO, "Not found: "#_type ", "#_criteria", "#_what", "#_result );	\
-		return ENOENT;									\
-	}
+	CHECK_FCT(  dict_search( (_type), (_criteria), (_what), (_result), ENOENT) );
 		
 
 typedef struct {
@@ -100,7 +96,7 @@
 			DICT_AVP, 							\
 			AVP_BY_NAME, 							\
 			(_rulearray)[__ar].avp_name, 					\
-			&__data.rule_avp ) );						\
+			&__data.rule_avp, 0 ) );					\
 		if ( !__data.rule_avp ) {						\
 			TRACE_DEBUG(INFO, "AVP Not found: '%s'", (_rulearray)[__ar].avp_name );	\
 			return ENOENT;							\
--- a/extensions/radius_gw/rgw_msg.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/extensions/radius_gw/rgw_msg.c	Tue Jun 02 14:31:42 2009 +0900
@@ -146,9 +146,9 @@
 int rgw_msg_init(void)
 {
 	TRACE_ENTRY();
-	CHECK_FCT( dict_search(DICT_AVP, AVP_BY_NAME, "Session-Id", &rm_sess_id) );
-	CHECK_FCT( dict_search(DICT_AVP, AVP_BY_NAME, "Origin-Host", &rm_orig_host) );
-	CHECK_FCT( dict_search(DICT_AVP, AVP_BY_NAME, "Origin-Realm", &rm_orig_realm) );
+	CHECK_FCT( dict_search(DICT_AVP, AVP_BY_NAME, "Session-Id", &rm_sess_id, ENOENT) );
+	CHECK_FCT( dict_search(DICT_AVP, AVP_BY_NAME, "Origin-Host", &rm_orig_host, ENOENT) );
+	CHECK_FCT( dict_search(DICT_AVP, AVP_BY_NAME, "Origin-Realm", &rm_orig_realm, ENOENT) );
 	return 0;
 }
 
--- a/extensions/rt_any/rt_any.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/extensions/rt_any/rt_any.c	Tue Jun 02 14:31:42 2009 +0900
@@ -73,4 +73,4 @@
 	rt_out_unregister ( hdl );
 }
 
-EXTENSION_API_INIT( API_MODULE_RT, entry, "rt_any");
+EXTENSION_API_INIT( API_MODULE_RT | API_MODULE_LOG, entry, "rt_any");
--- a/extensions/rt_default/rt_default.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/extensions/rt_default/rt_default.c	Tue Jun 02 14:31:42 2009 +0900
@@ -207,7 +207,7 @@
 }
 
 /* handler */
-static rt_out_hdl_t * hdl = NULL;
+static rt_out_hdl_t * rt_def_hdl = NULL;
 
 /* entry point */
 static int entry(char * conffile)
@@ -216,13 +216,13 @@
 	
 	TRACE_ENTRY("%p", conffile);
 	
-	ret = dict_search( DICT_AVP, AVP_BY_NAME, "Destination-Host",  &dict_avp_DH  );
+	ret = dict_search( DICT_AVP, AVP_BY_NAME, "Destination-Host",  &dict_avp_DH, ENOENT  );
 	if (ret != 0) {
 		log_error("Error initializing extension's dictionary objects: %s\n", strerror(ret));
 		return ret;
 	}
 	
-	ret = dict_search( DICT_AVP, AVP_BY_NAME, "Destination-Realm", &dict_avp_DR  );
+	ret = dict_search( DICT_AVP, AVP_BY_NAME, "Destination-Realm", &dict_avp_DR, ENOENT  );
 	if (ret != 0) {
 		log_error("Error initializing extension's dictionary objects: %s\n", strerror(ret));
 		return ret;
@@ -253,13 +253,13 @@
 		TRACE_DEBUG(INFO, "Extension RT/Default initialized with default configuration");
 	}
 		
-	return rt_out_register( cb_def_out, NULL, RT_OUT_NORMAL, &hdl );
+	return rt_out_register( cb_def_out, NULL, RT_OUT_NORMAL, &rt_def_hdl );
 }
 
 /* Unload */
 void waaad_ext_fini(void)
 {
-	rt_out_unregister ( hdl );
+	rt_out_unregister ( rt_def_hdl );
 	rtd_fini();
 }
 
--- a/extensions/sample/sample.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/extensions/sample/sample.c	Tue Jun 02 14:31:42 2009 +0900
@@ -67,13 +67,13 @@
 		dict_avp_data_t example_avp_data = { 999999, 0, "Example-AVP", AVP_FLAG_VENDOR , 0, AVP_TYPE_GROUPED };
 		int ret = 0;
 
-		ret = dict_search ( DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp);
+		ret = dict_search ( DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp, ENOENT);
 		if (ret != 0) {
 			log_error("An error occured while searching the 'Origin-Host' AVP: %s\n", strerror(ret));
 			/* We don't return an error since this is just a sample */
 			return 0;
 		}
-		ret = dict_search ( DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp);
+		ret = dict_search ( DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp, ENOENT);
 		if (ret != 0) {
 			log_error("An error occured while searching the 'Session-Id' AVP: %s\n", strerror(ret));
 			/* We don't return an error since this is just a sample */
--- a/include/waaad/dictionary-api.h	Tue Jun 02 11:15:00 2009 +0900
+++ b/include/waaad/dictionary-api.h	Tue Jun 02 14:31:42 2009 +0900
@@ -99,19 +99,21 @@
  *  criteria 	: how the object must be searched. See object-related sections bellow for more information.
  *  what 	: depending on criteria, the data that must be searched.
  *  result 	: On successful return, pointer to the object is stored here.
+ *  retval	: this value is returned if the object is not found and result is not NULL.
  *
  * DESCRIPTION: 
  *   Perform a search in the dictionary. 
  *   See the object-specific sections bellow to find how to look for each objects.
  *   If the "result" parameter is NULL, the function is used to check if an object is in the dictionary.
  *   Otherwise, a reference to the object is stored in result if found.
+ *   If result is not NULL and the object is not found, retval is returned (should be 0 or ENOENT usually)
  *
  * RETURN VALUE:
  *  0      	: The object has been found in the dictionary, or *result is NULL.
  *  EINVAL 	: A parameter is invalid.
  *  ENOENT	: No matching object has been found, and result was NULL.
  */
-int dict_search ( dict_object_type_t type, int criteria, void * what, dict_object_t **result );
+int dict_search ( dict_object_type_t type, int criteria, void * what, dict_object_t **result, int retval );
 
 /*
  * FUNCTION:	dict_gettype
@@ -150,7 +152,7 @@
 #endif /* ! IN_EXTENSION */
 
 /* The version of this API, to check binary compatibility -- increment each time a change is made in api_dict_t */
-#define WAAAD_API_DICT_VER	1
+#define WAAAD_API_DICT_VER	2
 
 /* Now define the type of the structure that contains the callback to pass to extensions */
 typedef struct {
@@ -160,7 +162,7 @@
 	
 	/* the remaining is dictionary-specific */
 	int (*dict_new)    ( dict_object_type_t type, void * data, dict_object_t * parent, dict_object_t **ref );
-	int (*dict_search) ( dict_object_type_t type, int criteria, void * what, dict_object_t **result );
+	int (*dict_search) ( dict_object_type_t type, int criteria, void * what, dict_object_t **result, int retval );
 	int (*dict_gettype)( dict_object_t * object, dict_object_type_t * type);
 	int (*dict_getval) ( dict_object_t * object, void * val);
 } api_dict_t;
@@ -183,7 +185,7 @@
 #else /* IN_EXTENSION */
 
 /* From the daemon, we must initialize the API object, in extension.c */
-# define MY_WAAAD_API_DICT_VER 1
+# define MY_WAAAD_API_DICT_VER 2
 # if MY_WAAAD_API_DICT_VER != WAAAD_API_DICT_VER
 #  error "You must update API_INIT_DICTIONARY also"
 # endif
@@ -254,11 +256,11 @@
 	 int ret;
 	 dict_object_t * vendor_found;
 	 vendor_id_t vendor = 23455;
-	 ret = dict_search ( DICT_VENDOR, VENDOR_BY_ID_REF, &vendor, &vendor_found);
+	 ret = dict_search ( DICT_VENDOR, VENDOR_BY_ID_REF, &vendor, &vendor_found, ENOENT);
 	 - or -
-	 ret = dict_search ( DICT_VENDOR, VENDOR_BY_ID_VAL, 23455, &vendor_found);
+	 ret = dict_search ( DICT_VENDOR, VENDOR_BY_ID_VAL, 23455, &vendor_found, ENOENT);
 	 - or -
-	 ret = dict_search ( DICT_VENDOR, VENDOR_BY_NAME, "my vendor name", &vendor_found);
+	 ret = dict_search ( DICT_VENDOR, VENDOR_BY_NAME, "my vendor name", &vendor_found, ENOENT);
  }
  
  - dict_getval:
@@ -267,7 +269,7 @@
 	 int ret;
 	 dict_object_t * myvendor;
 	 dict_vendor_data_t myvendordata;
-	 ret = dict_search ( DICT_VENDOR, VENDOR_BY_ID_VAL, 23455, &myvendor);
+	 ret = dict_search ( DICT_VENDOR, VENDOR_BY_ID_VAL, 23455, &myvendor, ENOENT);
 	 ret = dict_getval ( myvendor, &myvendordata );
 	 printf("myvendor name: %s\n", myvendordata.vendor_name );
  }
@@ -335,8 +337,8 @@
 	 int ret;
 	 dict_object_t * vendor, * appli;
 	 
-	 ret = dict_search ( DICT_APPLICATION, APPLICATION_BY_ID_VAL, (void *)9789, &appli);
-	 ret = dict_search ( DICT_VENDOR, VENDOR_OF_APPLICATION, appli, &vendor);
+	 ret = dict_search ( DICT_APPLICATION, APPLICATION_BY_ID_VAL, (void *)9789, &appli, ENOENT);
+	 ret = dict_search ( DICT_VENDOR, VENDOR_OF_APPLICATION, appli, &vendor, ENOENT);
  }
  
  - dict_getval:
@@ -345,7 +347,7 @@
 	 int ret;
 	 dict_object_t * appli;
 	 dict_application_data_t appl_data;
-	 ret = dict_search ( DICT_APPLICATION, APPLICATION_BY_ID_VAL, (void *)9789, &appli);
+	 ret = dict_search ( DICT_APPLICATION, APPLICATION_BY_ID_VAL, (void *)9789, &appli, ENOENT);
 	 ret = dict_getval ( appli, &appl_data );
 	 printf("my application name: %s\n", appl_data.application_name );
  }
@@ -468,7 +470,7 @@
  {
 	 int ret;
 	 dict_object_t * address_type;
-	 ret = dict_search ( DICT_TYPE, TYPE_BY_NAME, "Address", &address_type);
+	 ret = dict_search ( DICT_TYPE, TYPE_BY_NAME, "Address", &address_type, ENOENT);
  }
  
 */
@@ -546,7 +548,7 @@
 		 .search.enum_value.i32 = -1
 	 	};
 	 
-	 ret = dict_search ( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &boolean_by_value, &value_found);
+	 ret = dict_search ( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &boolean_by_value, &value_found, ENOENT);
  }
  
  - dict_getval:
@@ -555,7 +557,7 @@
 	 int ret;
 	 dict_object_t * myvendor;
 	 dict_vendor_data_t myvendordata;
-	 ret = dict_search ( DICT_VENDOR, VENDOR_BY_ID_VAL, 23455, &myvendor);
+	 ret = dict_search ( DICT_VENDOR, VENDOR_BY_ID_VAL, 23455, &myvendor, ENOENT);
 	 ret = dict_getval ( myvendor, &myvendordata );
 	 printf("myvendor name: %s\n", myvendordata.vendor_name );
  }
@@ -652,7 +654,7 @@
 	 ret = dict_new ( DICT_AVP, &user_name_data, NULL, &user_name_avp );
 	 
 	 -- Create an AVP with a derived type --
-	 ret = dict_search ( DICT_TYPE, TYPE_BY_NAME, "Boolean", &boolean_type);
+	 ret = dict_search ( DICT_TYPE, TYPE_BY_NAME, "Boolean", &boolean_type, ENOENT);
 	 ret = dict_new ( DICT_AVP, &sample_boolean_data , boolean_type, &sample_boolean_avp );
 	 
  }
@@ -669,9 +671,9 @@
 		 .avp_name   = "Sample-Boolean"
 	 	};
 	 
-	 ret = dict_search ( DICT_AVP, AVP_BY_NAME, "User-Name", &avp_username);
+	 ret = dict_search ( DICT_AVP, AVP_BY_NAME, "User-Name", &avp_username, ENOENT);
 	 
-	 ret = dict_search ( DICT_AVP, AVP_BY_NAME_AND_VENDOR, &avp_by_name, &avp_sampleboolean);
+	 ret = dict_search ( DICT_AVP, AVP_BY_NAME_AND_VENDOR, &avp_by_name, &avp_sampleboolean, ENOENT);
 	 
  }
  
@@ -681,7 +683,7 @@
 	 int ret;
 	 dict_object_t * avp_username;
 	 dict_avp_data_t user_name_data;
-	 ret = dict_search ( DICT_AVP, AVP_BY_NAME, "User-Name", &avp_username);
+	 ret = dict_search ( DICT_AVP, AVP_BY_NAME, "User-Name", &avp_username, ENOENT);
 	 ret = dict_getval ( avp_username, &user_name_data );
 	 printf("User-Name code: %d\n", user_name_data.avp_code );
  }
@@ -767,9 +769,9 @@
  {
 	 int ret;
 	 dict_object_t * cer;
-	 ret = dict_search ( DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer);
+	 ret = dict_search ( DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer, ENOENT);
 	 - or -
-	 ret = dict_search ( DICT_COMMAND, CMD_BY_CODE_R_VAL, 257, &cer);
+	 ret = dict_search ( DICT_COMMAND, CMD_BY_CODE_R_VAL, 257, &cer, ENOENT);
  }
  
  - dict_getval:
@@ -779,8 +781,8 @@
 	 dict_object_t * cer;
 	 dict_object_t * cea;
 	 dict_cmd_data_t cea_data;
-	 ret = dict_search ( DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer);
-	 ret = dict_search ( DICT_COMMAND, CMD_ANSWER, cer, &cea);
+	 ret = dict_search ( DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer, ENOENT);
+	 ret = dict_search ( DICT_COMMAND, CMD_ANSWER, cer, &cea, ENOENT);
 	 ret = dict_getval ( cea, &cea_data );
 	 printf("Answer to CER: %s\n", cea_data.cmd_name );
  }
--- a/waaad/dict-base.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/waaad/dict-base.c	Tue Jun 02 14:31:42 2009 +0900
@@ -153,11 +153,7 @@
 	CHECK_FCT(  dict_new( (_type), (_data), (_parent), (_ref))  );
 
 #define CHECK_dict_search( _type, _criteria, _what, _result )					\
-	CHECK_FCT(  dict_search( (_type), (_criteria), (_what), (_result))  );			\
-	if ( !*(_result) ) {									\
-		TRACE_DEBUG(INFO, "Not found: "#_type ", "#_criteria", "#_what", "#_result );	\
-		return ENOENT;									\
-	}
+	CHECK_FCT(  dict_search( (_type), (_criteria), (_what), (_result), ENOENT)  );
 
 typedef struct {
 	char 		*avp_name;
@@ -183,7 +179,7 @@
 			DICT_AVP, 							\
 			AVP_BY_NAME, 							\
 			(_rulearray)[__ar].avp_name, 					\
-			&__data.rule_avp ) );						\
+			&__data.rule_avp, 0 ) );					\
 		if ( !__data.rule_avp ) {						\
 			TRACE_DEBUG(INFO, "AVP Not found: '%s'", (_rulearray)[__ar].avp_name );	\
 			return ENOENT;							\
--- a/waaad/dictionary.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/waaad/dictionary.c	Tue Jun 02 14:31:42 2009 +0900
@@ -1396,7 +1396,7 @@
 	
 	/* For AVP object, we must also check that the "vendor" referenced exists */
 	if (type == DICT_AVP) {
-		CHECK_FCT_DO(  dict_search( DICT_VENDOR, VENDOR_BY_ID_REF, &(((dict_avp_data_t *)data)->avp_vendor), (void*)&vendor ),
+		CHECK_FCT_DO(  dict_search( DICT_VENDOR, VENDOR_BY_ID_REF, &(((dict_avp_data_t *)data)->avp_vendor), (void*)&vendor, ENOENT ),
 				CHECK_PARAMS( vendor = NULL )  );
 		
 		/* Also check if a parent is provided, that the type are the same */
@@ -1501,7 +1501,7 @@
 }
 
 /* Search an object in the dictionary */
-int dict_search ( dict_object_type_t type, int criteria, void * what, dict_object_t **result )
+int dict_search ( dict_object_type_t type, int criteria, void * what, dict_object_t **result, int retval )
 {
 	int ret = 0;
 	
@@ -1519,6 +1519,10 @@
 	/* Unlock */
 	CHECK_POSIX(  pthread_rwlock_unlock(&dict_lock)  );
 	
+	/* Update the return value as needed */
+	if ((result != NULL) && (*result == NULL))
+		ret = retval;
+	
 	return ret;
 }
 
--- a/waaad/dispatch.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/waaad/dispatch.c	Tue Jun 02 14:31:42 2009 +0900
@@ -83,7 +83,7 @@
 	CHECK_FCT(  msg_data(*msg, &hdr)  );
 	
 	/* Now we search the application of the message */
-	CHECK_FCT( dict_search( DICT_APPLICATION, APPLICATION_BY_ID_REF, &hdr->msg_appl, app ) );
+	CHECK_FCT( dict_search( DICT_APPLICATION, APPLICATION_BY_ID_REF, &hdr->msg_appl, app, 0 ) );
 	if (*app == NULL) {
 		/* In case of error, we should answer a DIAMETER_APPLICATION_UNSUPPORTED error */
 		TRACE_DEBUG(INFO, "Error: TODO reply DIAMETER_APPLICATION_UNSUPPORTED if it's a request");
@@ -204,7 +204,7 @@
 				CHECK_FCT_DO(  dict_disp_cb( DICT_AVP, avp_model, &sem ), goto c_error  );
 				
 				/* Check if the AVP has a constant value */
-				CHECK_FCT_DO(  dict_search(DICT_TYPE, TYPE_OF_AVP, avp_model, &avp_type), goto c_error  );
+				CHECK_FCT_DO(  dict_search(DICT_TYPE, TYPE_OF_AVP, avp_model, &avp_type, 0), goto c_error  );
 				if (avp_type) {
 					dict_type_enum_request_t  request;
 					msg_avp_data_t *avp_data;
@@ -214,7 +214,7 @@
 					CHECK_FCT_DO(  msg_avp_data( avp, &avp_data ), goto c_error  );
 					ASSERT( avp_data );
 					memcpy(&request.search.enum_value, avp_data->avp_data, sizeof(avp_value_t));
-					CHECK_FCT_DO( dict_search( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &request, &avp_constant), goto c_error  );
+					CHECK_FCT_DO( dict_search( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &request, &avp_constant, 0), goto c_error  );
 				}
 				
 				/* Call all matching callbacks */
@@ -395,7 +395,7 @@
 		CHECK_FCT( dict_getval( when->app_id, &appl_data) );
 		
 		/* Get the vendor and data */
-		CHECK_FCT( dict_search( DICT_VENDOR, VENDOR_OF_APPLICATION, when->app_id, &vendor) );
+		CHECK_FCT( dict_search( DICT_VENDOR, VENDOR_OF_APPLICATION, when->app_id, &vendor, 0) );
 		if (vendor) {
 			CHECK_FCT( dict_getval( vendor, &vendor_data) );
 		}
--- a/waaad/message.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/waaad/message.c	Tue Jun 02 14:31:42 2009 +0900
@@ -629,8 +629,8 @@
 			dict_object_t * avp_constant = NULL;
 			dict_type_data_t type_data;
 			dict_type_enum_request_t  request;
-			ret = dict_search(DICT_TYPE, TYPE_OF_AVP, avp->avp_model, &avp_type);
-			if ((ret != 0) || (avp_type == NULL)) {
+			ret = dict_search(DICT_TYPE, TYPE_OF_AVP, avp->avp_model, &avp_type, ENOENT);
+			if (ret != 0) {
 				dump_basic_type(avp->avp_public.avp_data, type, type_base_name[type], indent);
 				goto end;
 			}
@@ -647,8 +647,8 @@
 			memset(&request, 0, sizeof(request));
 			request.type_obj = avp_type;
 			memcpy(&request.search.enum_value, avp->avp_public.avp_data, sizeof(avp_value_t));
-			ret = dict_search(DICT_TYPE_ENUM, ENUM_BY_STRUCT, &request, &avp_constant);
-			if ((ret != 0) || (avp_constant == NULL)) {
+			ret = dict_search(DICT_TYPE_ENUM, ENUM_BY_STRUCT, &request, &avp_constant, ENOENT);
+			if (ret != 0)  {
 				dump_basic_type(avp->avp_public.avp_data, type, type_data.type_name, indent);
 				goto end;
 			}
@@ -953,10 +953,10 @@
 		dict_avp_request_t avpreq;
 		avpreq.avp_vendor = avp->avp_public.avp_vendor;
 		avpreq.avp_code = avp->avp_public.avp_code;
-		CHECK_FCT( dict_search ( DICT_AVP, AVP_BY_CODE_AND_VENDOR, &avpreq, &avp->avp_model));
+		CHECK_FCT( dict_search ( DICT_AVP, AVP_BY_CODE_AND_VENDOR, &avpreq, &avp->avp_model, 0));
 	} else {
 		/* no vendor */
-		CHECK_FCT( dict_search ( DICT_AVP, AVP_BY_CODE_REF, &avp->avp_public.avp_code, &avp->avp_model));
+		CHECK_FCT( dict_search ( DICT_AVP, AVP_BY_CODE_REF, &avp->avp_public.avp_code, &avp->avp_model, 0));
 	}
 	
 	/* First handle the case where we have not found this AVP in the dictionary */
@@ -1084,10 +1084,7 @@
 		CHECK_FCT( dict_search ( DICT_COMMAND, 
 				(msg->msg_public.msg_flags & CMD_FLAG_REQUEST) ? CMD_BY_CODE_R_REF : CMD_BY_CODE_A_REF,
 				&msg->msg_public.msg_code,
-				&msg->msg_model) );
-		if (!msg->msg_model) {
-			CHECK_FCT(ENOTSUP); /* log and return this code */
-		}
+				&msg->msg_model, ENOTSUP) );
 	}
 	
 	if (!only_msg) {
@@ -1338,7 +1335,7 @@
 		dict_object_t * conflictrule = NULL;
 		dict_rule_request_t req = { model, data.ruleavp };
 		
-		CHECK_FCT_DO( dict_search ( DICT_RULE, RULE_BY_AVP_AND_PARENT, &req, &conflictrule),  conflictrule = NULL );
+		CHECK_FCT_DO( dict_search ( DICT_RULE, RULE_BY_AVP_AND_PARENT, &req, &conflictrule, ENOENT),  conflictrule = NULL );
 		
 		*rule = conflictrule;
 	}
@@ -1382,14 +1379,14 @@
 	TRACE_ENTRY("");
 	
 	/* Initialize the dictionary objects that we may use frequently */
-	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Origin-Host",     	&dict_avp_OH  )  );
-	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Origin-Realm",    	&dict_avp_OR  )  );
-	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Origin-State-Id", 	&dict_avp_OSI )  );
-	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Result-Code",     	&dict_avp_RC  )  );
-	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Error-Message",   	&dict_avp_EM  )  );
-	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Error-Reporting-Host", &dict_avp_ERH )  );
-	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Failed-AVP",      	&dict_avp_FAVP)  );
-	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Route-Record",      	&dict_avp_RR  )  );
+	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Origin-Host",     	&dict_avp_OH  , ENOENT)  );
+	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Origin-Realm",    	&dict_avp_OR  , ENOENT)  );
+	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Origin-State-Id", 	&dict_avp_OSI , ENOENT)  );
+	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Result-Code",     	&dict_avp_RC  , ENOENT)  );
+	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Error-Message",   	&dict_avp_EM  , ENOENT)  );
+	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Error-Reporting-Host", &dict_avp_ERH , ENOENT)  );
+	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Failed-AVP",      	&dict_avp_FAVP, ENOENT)  );
+	CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Route-Record",      	&dict_avp_RR  , ENOENT)  );
 	
 	/* The End-to-end id */
 	eteid = ((uint32_t)time(NULL) << 20) | ((uint32_t)lrand48() & ( (1 << 20) - 1 ));
@@ -1465,7 +1462,7 @@
 		new->msg_public.msg_code	= dictdata.cmd_code;
 
 		/* Initialize application from the parent, if any */
-		CHECK_FCT(  dict_search( DICT_APPLICATION, APPLICATION_OF_COMMAND, model, &dictappl)  );
+		CHECK_FCT(  dict_search( DICT_APPLICATION, APPLICATION_OF_COMMAND, model, &dictappl, 0)  );
 		if (dictappl != NULL) {
 			dict_application_data_t appdata;
 			CHECK_FCT(  dict_getval(dictappl, &appdata)  );
@@ -1506,7 +1503,7 @@
 	
 	/* Find the model for the answer */
 	CHECK_FCT(  _mpd_do_msg(qry, 0, 1)  );
-	CHECK_FCT(  dict_search ( DICT_COMMAND, CMD_ANSWER, qry->msg_model, &model )  );
+	CHECK_FCT(  dict_search ( DICT_COMMAND, CMD_ANSWER, qry->msg_model, &model, EINVAL )  );
 	
 	/* Create the answer */
 	CHECK_FCT(  msg_new( model, flags, msg )  );
@@ -1878,8 +1875,7 @@
 		CHECK_PARAMS(  type != AVP_TYPE_GROUPED  );
 		
 		/* Then retrieve information about the parent's type (= derived type) */
-		CHECK_FCT(  dict_search(DICT_TYPE, TYPE_OF_AVP, _A(avp)->avp_model, &parenttype)  );
-		CHECK_PARAMS(  parenttype  );
+		CHECK_FCT(  dict_search(DICT_TYPE, TYPE_OF_AVP, _A(avp)->avp_model, &parenttype, EINVAL)  );
 		CHECK_FCT(  dict_getval(parenttype, &type_data)  );
 		if (type_data.type_encode == NULL) {
 			TRACE_DEBUG(INFO, "This AVP type does not provide a callback to encode formatted data. ENOTSUP.");
@@ -1924,8 +1920,7 @@
 	{
 		dict_object_t * parenttype = NULL;
 		
-		CHECK_FCT(  dict_search(DICT_TYPE, TYPE_OF_AVP, _A(avp)->avp_model, &parenttype)  );
-		CHECK_PARAMS(  parenttype  );
+		CHECK_FCT(  dict_search(DICT_TYPE, TYPE_OF_AVP, _A(avp)->avp_model, &parenttype, EINVAL)  );
 		CHECK_FCT(  dict_getval(parenttype, &type_data)  );
 		if (type_data.type_interpret == NULL) {
 			TRACE_DEBUG(INFO, "This AVP type does not provide a callback to interpret value in formatted data. ENOTSUP.");
@@ -2390,11 +2385,11 @@
 		memset(&req, 0, sizeof(dict_type_enum_request_t));
 		
 		/* First, get the enumerated type of the Result-Code AVP */
-		CHECK_FCT(  dict_search( DICT_TYPE, TYPE_OF_AVP, dict_avp_RC, &(req.type_obj)  )  );
+		CHECK_FCT(  dict_search( DICT_TYPE, TYPE_OF_AVP, dict_avp_RC, &(req.type_obj), ENOENT  )  );
 		
 		/* Now search for the value given as parameter */
 		req.search.enum_name = rescode;
-		CHECK_FCT(  dict_search( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &req, &enum_obj)  );
+		CHECK_FCT(  dict_search( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &req, &enum_obj, ENOTSUP)  );
 		
 		/* finally retrieve its data */
 		CHECK_FCT_DO(  dict_getval( enum_obj, &(req.search) ), return EINVAL );
--- a/waaad/peer-cer_cea.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/waaad/peer-cer_cea.c	Tue Jun 02 14:31:42 2009 +0900
@@ -50,8 +50,8 @@
 
 int _peer_cer_cea_init(void)
 {
-	CHECK_FCT( dict_search( DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &dict_CER) );
-	CHECK_FCT( dict_search( DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Answer",  &dict_CEA) );
+	CHECK_FCT( dict_search( DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &dict_CER, ENOENT) );
+	CHECK_FCT( dict_search( DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Answer",  &dict_CEA, ENOENT) );
 	
 	return 0;
 }
@@ -87,7 +87,7 @@
 	/* Add the Host-IP-Address AVP(s) */
 	{
 		/* Find the model for this AVP */
-		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Host-IP-Address", &dict )  );
+		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Host-IP-Address", &dict, ENOENT )  );
 		
 		switch (peer->p_addinfo.pa_proto) {
 			case IPPROTO_TCP: /* In TCP, we have only one endpoint. We must add only one Host-IP-Address AVP */
@@ -170,7 +170,7 @@
 	/* Add the Vendor-Id, Product-Name, and Firmware-Revision AVPs */
 	{
 		/* Find the model for this AVP */
-		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Id", &dict )  );
+		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Id", &dict, ENOENT )  );
 		
 		/* Create the AVP */
 		CHECK_FCT( msg_avp_new( dict, 0, &avp ) );
@@ -185,7 +185,7 @@
 	}
 	{
 		/* Find the model for this AVP */
-		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Product-Name", &dict )  );
+		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Product-Name", &dict, ENOENT )  );
 		
 		/* Create the AVP */
 		CHECK_FCT( msg_avp_new( dict, 0, &avp ) );
@@ -201,7 +201,7 @@
 	}
 	{
 		/* Find the model for this AVP */
-		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Firmware-Revision", &dict )  );
+		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Firmware-Revision", &dict, ENOENT )  );
 		
 		/* Create the AVP */
 		CHECK_FCT( msg_avp_new( dict, 0, &avp ) );
@@ -225,7 +225,7 @@
 		ASSERT( ! IS_LIST_EMPTY(&peer->p_sec_list)  );
 		
 		/* Find the model for this AVP */
-		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Inband-Security-Id", &dict )  );
+		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Inband-Security-Id", &dict, ENOENT )  );
 		
 		/* Create the AVP */
 		CHECK_FCT( msg_avp_new( dict, 0, &avp ) );
@@ -250,7 +250,7 @@
 			
 			if ((array != NULL) && (array[0] != 0)) {
 				/* Find the model for this AVP */
-				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Supported-Vendor-Id", &dict )  );
+				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Supported-Vendor-Id", &dict, ENOENT )  );
 
 				memset(&val, 0, sizeof(val));
 				
@@ -282,11 +282,11 @@
 			/* Create the application AVP */
 			if (g_conf->supported_apps_list[i].t == APP_TYPE_AUTH) {
 				
-				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &dict )  );
+				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &dict, ENOENT )  );
 
 			} else {
 				
-				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Acct-Application-Id", &dict )  );
+				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Acct-Application-Id", &dict, ENOENT )  );
 
 			}
 			
@@ -304,14 +304,14 @@
 				msg_avp_t * avp_a = avp;
 				
 				/* The Vendor-Id AVP */
-				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Id", &dict )  );
+				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Id", &dict, ENOENT )  );
 				CHECK_FCT( msg_avp_new( dict, 0, &avp_v ) );
 				memset(&val, 0, sizeof(val));
 				val.u32 = g_conf->supported_apps_list[i].v;
 				CHECK_FCT( msg_avp_setvalue( avp_v, &val ) );
 				
 				/* The grouped AVP */
-				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Specific-Application-Id", &dict )  );
+				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Specific-Application-Id", &dict, ENOENT )  );
 				CHECK_FCT( msg_avp_new( dict, 0, &avp ) );
 				
 				/* Add the children AVPs */
@@ -329,11 +329,11 @@
 			dict_application_data_t relay;
 			
 			/* Find the Relay application in the dictionary */
-			CHECK_FCT(  dict_search( DICT_APPLICATION, APPLICATION_BY_NAME, "Relay", &apprelay )  );
+			CHECK_FCT(  dict_search( DICT_APPLICATION, APPLICATION_BY_NAME, "Relay", &apprelay, ENOENT )  );
 			CHECK_FCT(  dict_getval( apprelay, &relay )  );
 			
 			/* Find the model for this AVP */
-			CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &dict )  );
+			CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &dict, ENOENT )  );
 
 			/* Create the AVP */
 			CHECK_FCT( msg_avp_new( dict, 0, &avp ) );
@@ -631,7 +631,7 @@
 	/* Add the Host-IP-Address AVP(s) */
 	{
 		/* Find the model for this AVP */
-		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Host-IP-Address", &dict )  );
+		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Host-IP-Address", &dict, ENOENT )  );
 		
 		switch (peer->p_addinfo.pa_proto) {
 			case IPPROTO_TCP: /* In TCP, we have only one endpoint. We must add only one Host-IP-Address AVP */
@@ -699,7 +699,7 @@
 	/* Add the Vendor-Id, Product-Name, and Firmware-Revision AVPs */
 	{
 		/* Find the model for this AVP */
-		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Id", &dict )  );
+		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Id", &dict, ENOENT )  );
 		
 		/* Create the AVP */
 		CHECK_FCT( msg_avp_new( dict, 0, &avp ) );
@@ -714,7 +714,7 @@
 	}
 	{
 		/* Find the model for this AVP */
-		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Product-Name", &dict )  );
+		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Product-Name", &dict, ENOENT )  );
 		
 		/* Create the AVP */
 		CHECK_FCT( msg_avp_new( dict, 0, &avp ) );
@@ -730,7 +730,7 @@
 	}
 	{
 		/* Find the model for this AVP */
-		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Firmware-Revision", &dict )  );
+		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Firmware-Revision", &dict, ENOENT )  );
 		
 		/* Create the AVP */
 		CHECK_FCT( msg_avp_new( dict, 0, &avp ) );
@@ -758,7 +758,7 @@
 		CHECK_FCT(  sec_getmodfromhdl(peer->p_sec_hdl, &mod)  );
 		
 		/* Find the model for this AVP */
-		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Inband-Security-Id", &dict )  );
+		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Inband-Security-Id", &dict, ENOENT )  );
 		
 		/* Create the AVP */
 		CHECK_FCT( msg_avp_new( dict, 0, &avp ) );
@@ -783,7 +783,7 @@
 			
 			if ((array != NULL) && (array[0] != 0)) {
 				/* Find the model for this AVP */
-				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Supported-Vendor-Id", &dict )  );
+				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Supported-Vendor-Id", &dict, ENOENT )  );
 
 				memset(&val, 0, sizeof(val));
 				
@@ -815,11 +815,11 @@
 			/* Create the application AVP */
 			if (g_conf->supported_apps_list[i].t == APP_TYPE_AUTH) {
 				
-				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &dict )  );
+				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &dict, ENOENT )  );
 
 			} else {
 				
-				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Acct-Application-Id", &dict )  );
+				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Acct-Application-Id", &dict, ENOENT )  );
 
 			}
 			
@@ -837,14 +837,14 @@
 				msg_avp_t * avp_a = avp;
 				
 				/* The Vendor-Id AVP */
-				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Id", &dict )  );
+				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Id", &dict, ENOENT )  );
 				CHECK_FCT( msg_avp_new( dict, 0, &avp_v ) );
 				memset(&val, 0, sizeof(val));
 				val.u32 = g_conf->supported_apps_list[i].v;
 				CHECK_FCT( msg_avp_setvalue( avp_v, &val ) );
 				
 				/* The grouped AVP */
-				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Specific-Application-Id", &dict )  );
+				CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Vendor-Specific-Application-Id", &dict, ENOENT )  );
 				CHECK_FCT( msg_avp_new( dict, 0, &avp ) );
 				
 				/* Add the children AVPs */
@@ -862,11 +862,11 @@
 			dict_application_data_t relay;
 			
 			/* Find the Relay application in the dictionary */
-			CHECK_FCT(  dict_search( DICT_APPLICATION, APPLICATION_BY_NAME, "Relay", &apprelay )  );
+			CHECK_FCT(  dict_search( DICT_APPLICATION, APPLICATION_BY_NAME, "Relay", &apprelay, ENOENT )  );
 			CHECK_FCT(  dict_getval( apprelay, &relay )  );
 			
 			/* Find the model for this AVP */
-			CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &dict )  );
+			CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &dict, ENOENT )  );
 
 			/* Create the AVP */
 			CHECK_FCT( msg_avp_new( dict, 0, &avp ) );
--- a/waaad/peer-dpr_dpa.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/waaad/peer-dpr_dpa.c	Tue Jun 02 14:31:42 2009 +0900
@@ -50,8 +50,8 @@
 
 int _peer_dpr_dpa_init(void)
 {
-	CHECK_FCT( dict_search( DICT_COMMAND, CMD_BY_NAME, "Disconnect-Peer-Request", &dict_DPR) );
-	CHECK_FCT( dict_search( DICT_COMMAND, CMD_BY_NAME, "Disconnect-Peer-Answer",  &dict_DPA) );
+	CHECK_FCT( dict_search( DICT_COMMAND, CMD_BY_NAME, "Disconnect-Peer-Request", &dict_DPR, ENOENT) );
+	CHECK_FCT( dict_search( DICT_COMMAND, CMD_BY_NAME, "Disconnect-Peer-Answer",  &dict_DPA, ENOENT) );
 	
 	return 0;
 }
@@ -87,7 +87,7 @@
 		avp_value_t val;
 		
 		/* Find the model for this AVP */
-		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Disconnect-Cause", &dict )  );
+		CHECK_FCT(  dict_search( DICT_AVP, AVP_BY_NAME, "Disconnect-Cause", &dict, ENOENT )  );
 		
 		/* Create the AVP */
 		CHECK_FCT( msg_avp_new( dict, 0, &avp ) );
--- a/waaad/peer-dwr_dwa.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/waaad/peer-dwr_dwa.c	Tue Jun 02 14:31:42 2009 +0900
@@ -50,8 +50,8 @@
 
 int _peer_dwr_dwa_init(void)
 {
-	CHECK_FCT( dict_search( DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dict_DWR) );
-	CHECK_FCT( dict_search( DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Answer",  &dict_DWA) );
+	CHECK_FCT( dict_search( DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dict_DWR, ENOENT) );
+	CHECK_FCT( dict_search( DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Answer",  &dict_DWA, ENOENT) );
 	
 	return 0;
 }
--- a/waaad/tests/testdict.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/waaad/tests/testdict.c	Tue Jun 02 14:31:42 2009 +0900
@@ -70,20 +70,24 @@
 		CHECK( 0, dict_new ( DICT_VENDOR, &vendor2_data , NULL, NULL ) );
 		
 		/* Check we always retrieve the correct vendor object */
-		CHECK( 0, dict_search ( DICT_VENDOR, VENDOR_BY_ID_REF, &vendor_id, &obj2 ) );
+		CHECK( 0, dict_search ( DICT_VENDOR, VENDOR_BY_ID_REF, &vendor_id, &obj2, ENOENT ) );
 		CHECK( obj1, obj2);
-		CHECK( 0, dict_search ( DICT_VENDOR, VENDOR_BY_ID_VAL, (void *)(unsigned long)vendor_id, &obj2 ) );
+		CHECK( 0, dict_search ( DICT_VENDOR, VENDOR_BY_ID_VAL, (void *)(unsigned long)vendor_id, &obj2, ENOENT ) );
 		CHECK( obj1, obj2);
-		CHECK( 0, dict_search ( DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 1", &obj2 ) );
+		CHECK( 0, dict_search ( DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 1", &obj2, ENOENT ) );
 		CHECK( obj1, obj2);
 		
 		/* Check the error conditions */
-		CHECK( 0, dict_search ( DICT_VENDOR, VENDOR_BY_ID_REF, &vendor_id, NULL ) );
+		CHECK( 0, dict_search ( DICT_VENDOR, VENDOR_BY_ID_REF, &vendor_id, NULL, ENOENT ) );
 		
 		vendor_id = 735673; /* Not defined */
-		CHECK( ENOENT, dict_search ( DICT_VENDOR, VENDOR_BY_ID_REF, &vendor_id, NULL ) );
-		CHECK( ENOENT, dict_search ( DICT_VENDOR, VENDOR_BY_ID_VAL, (void *)(unsigned long)vendor_id, NULL ) );
-		CHECK( ENOENT, dict_search ( DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", NULL ) );
+		CHECK( ENOENT, dict_search ( DICT_VENDOR, VENDOR_BY_ID_REF, &vendor_id, NULL, ENOENT ) );
+		CHECK( ENOENT, dict_search ( DICT_VENDOR, VENDOR_BY_ID_VAL, (void *)(unsigned long)vendor_id, NULL, ENOENT ) );
+		CHECK( ENOENT, dict_search ( DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", NULL, ENOENT ) );
+		CHECK( ENOENT, dict_search ( DICT_VENDOR, VENDOR_BY_ID_REF, &vendor_id, &obj2, ENOENT ) );
+		CHECK( ENOENT, dict_search ( DICT_VENDOR, VENDOR_BY_ID_VAL, (void *)(unsigned long)vendor_id, &obj2, ENOENT ) );
+		CHECK( ENOENT, dict_search ( DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", &obj2, ENOENT ) );
+		CHECK( ENOTSUP, dict_search ( DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", &obj2, ENOTSUP ) );
 		
 		/* Check the get_* functions */
 		CHECK( 0, dict_gettype ( obj1, &type ) );
@@ -99,7 +103,7 @@
 		CHECK( EINVAL, dict_new ( DICT_APPLICATION, &app1_data , "bad object", &obj2 ) );
 		CHECK( 0, dict_new ( DICT_APPLICATION, &app1_data , obj1, &obj2 ) );
 		
-		CHECK( 0, dict_search ( DICT_VENDOR, VENDOR_OF_APPLICATION, obj2, &obj3 ) );
+		CHECK( 0, dict_search ( DICT_VENDOR, VENDOR_OF_APPLICATION, obj2, &obj3, ENOENT ) );
 		CHECK( obj1, obj3);
 		
 		/* Creating and searching the other objects is already done in dictionary initialization */
@@ -115,8 +119,8 @@
 		dict_rule_data_t rule_data = { NULL, RULE_REQUIRED, -1, -1, 1 };
 		dict_avp_data_t example_avp_data = { 999999, 0, "Example-AVP", AVP_FLAG_VENDOR , 0, AVP_TYPE_GROUPED };
 
-		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp ) );
-		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp ) );
+		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp, ENOENT ) );
+		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp, ENOENT ) );
 		
 		CHECK( 0, dict_new ( DICT_AVP, &example_avp_data , NULL, &example_avp_avp ) );
 		
--- a/waaad/tests/testmeq.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/waaad/tests/testmeq.c	Tue Jun 02 14:31:42 2009 +0900
@@ -92,9 +92,9 @@
 		dict_object_t * cer_model = NULL;
 		dict_object_t * dwr_model = NULL;
 
-		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", 		&acr_model ) );
-		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", 	&cer_model ) );
-		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request",		&dwr_model ) );
+		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", 		&acr_model, ENOENT ) );
+		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", 	&cer_model, ENOENT ) );
+		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request",		&dwr_model, ENOENT ) );
 		CHECK( 0, msg_new ( acr_model, MSGFL_FROM_TEMPLATE, &msg1 ) );
 		CHECK( 0, msg_new ( cer_model, MSGFL_FROM_TEMPLATE, &msg2 ) );
 		CHECK( 0, msg_new ( dwr_model, MSGFL_FROM_TEMPLATE, &msg3 ) );
@@ -176,7 +176,7 @@
 		ts.tv_sec += 2; /* Set the timeout to 2 second */
 		
 		/* Create the messages */
-		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dwr_model ) );
+		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Device-Watchdog-Request", &dwr_model, ENOENT ) );
 		for (i = 0; i < NBR_MSG * NBR_THREADS * 2; i++) {
 			CHECK( 0, msg_new ( dwr_model, 0, &msgs[i] ) );
 		}
--- a/waaad/tests/testmesg.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/waaad/tests/testmesg.c	Tue Jun 02 14:31:42 2009 +0900
@@ -55,7 +55,7 @@
 		dict_object_t * acr_model = NULL;
 
 		/* Now find the ACR dictionary object */
-		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model ) );
+		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) );
 
 		/* Create the instance, using the templates */
 		CHECK( 0, msg_new ( acr_model, MSGFL_FROM_TEMPLATE, &acr ) );
@@ -72,7 +72,7 @@
 		dict_object_t * pi_model = NULL;
 
 		/* Now find the ACR dictionary object */
-		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Proxy-Info", &pi_model ) );
+		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Proxy-Info", &pi_model, ENOENT ) );
 
 		/* Create the instance, using the templates */
 		CHECK( 0, msg_avp_new ( pi_model, MSGFL_FROM_TEMPLATE, &pi ) );
@@ -131,7 +131,7 @@
 		dict_object_t * rr_model = NULL;
 
 		/* Now find the ACR dictionary object */
-		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Route-Record", &rr_model ) );
+		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Route-Record", &rr_model, ENOENT ) );
 
 		/* Create the instance, using the templates */
 		CHECK( 0, msg_avp_new ( rr_model, MSGFL_FROM_TEMPLATE, &avp1 ) );
@@ -159,7 +159,7 @@
 		dict_object_t * acr_model = NULL;
 
 		/* Now find the ACR dictionary object */
-		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model ) );
+		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) );
 
 		/* Create the instance, using the templates */
 		CHECK( 0, msg_new ( acr_model, 0, &acr ) );
@@ -250,7 +250,7 @@
 				dict_object_t * _avp = NULL;							\
 				dict_avp_request_t _req = { (_vendor), 0, (_avpname) };				\
 				dict_rule_data_t _data;								\
-				CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp ) );	\
+				CHECK( 0, dict_search( DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT));\
 				_data.rule_avp = _avp;								\
 				_data.rule_position = (_pos);							\
 				_data.rule_order = (_ord);							\
@@ -269,7 +269,7 @@
 			dict_object_t * command = NULL;
 			dict_cmd_data_t cmd_data = { 73573, "Test-Command-Request", CMD_FLAG_REQUEST, CMD_FLAG_REQUEST };
 			
-			CHECK( 0, dict_search ( DICT_APPLICATION, APPLICATION_BY_NAME, "Application test", &application ) );
+			CHECK( 0, dict_search ( DICT_APPLICATION, APPLICATION_BY_NAME, "Application test", &application, ENOENT ) );
 			CHECK( 0, dict_new ( DICT_COMMAND, &cmd_data , application, &command ) );
 			ADD_RULE(command, 0,     "AVP Test - no vendor - f32", 	RULE_FIXED_HEAD, -1,  1,  0, 1);
 			ADD_RULE(command, 73565, "AVP Test - i64",		RULE_REQUIRED,   -1, -1,  0, 0);
@@ -311,11 +311,11 @@
 		msg_avp_t     * avp = NULL;
 		avp_value_t	value;
 		
-		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model ) );
+		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model, ENOENT ) );
 		
 		/* Check an error is trigged if the AVP has no value set */
 		{
-			CHECK( 0, dict_search ( DICT_AVP,     AVP_BY_NAME,     "AVP Test - no vendor - f32", &avp_model ) );
+			CHECK( 0, dict_search ( DICT_AVP,     AVP_BY_NAME,     "AVP Test - no vendor - f32", &avp_model, ENOENT ) );
 			
 			CHECK( 0, msg_new ( cmd_model, 0, &msg ) );
 			CHECK( 0, msg_avp_new ( avp_model, 0, &avp ) );
@@ -337,7 +337,7 @@
 			#define ADD_AVP( _parent, _position, _avpi, _avpvendor, _avpname) {			\
 				dict_object_t * _avp = NULL;							\
 				dict_avp_request_t _req = { (_avpvendor), 0, (_avpname) };			\
-				CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp ) );	\
+				CHECK( 0, dict_search( DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT));\
 				CHECK( 0, msg_avp_new ( _avp, 0, &_avpi ) );					\
 				CHECK( 0, msg_avp_add ( (_parent), (_position), _avpi ) );			\
 			}
@@ -386,11 +386,11 @@
 				dict_type_enum_request_t request;
 				
 				CHECK( 0, msg_model ( avpi, &avp_model ) );
-				CHECK( 0, dict_search ( DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model ) );
+				CHECK( 0, dict_search ( DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );
 				memset(&request, 0, sizeof(request));
 				request.type_obj = type_model;
 				request.search.enum_name = "i32 const test (val 2)";
-				CHECK( 0, dict_search ( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &request, &value_model ) );
+				CHECK( 0, dict_search ( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &request, &value_model, ENOENT ) );
 				CHECK( 0, dict_getval ( value_model, &request.search ) );
 				CHECK( 0, msg_avp_setvalue ( avpi, &request.search.enum_value ) );
 				#if 0
@@ -407,11 +407,11 @@
 				dict_type_enum_request_t request;
 				
 				CHECK( 0, msg_model ( avpi, &avp_model ) );
-				CHECK( 0, dict_search ( DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model ) );
+				CHECK( 0, dict_search ( DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );
 				memset(&request, 0, sizeof(request));
 				request.type_obj = type_model;
 				request.search.enum_name = "i32 const test (val -5)";
-				CHECK( 0, dict_search ( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &request, &value_model ) );
+				CHECK( 0, dict_search ( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &request, &value_model, ENOENT ) );
 				CHECK( 0, dict_getval ( value_model, &request.search ) );
 				CHECK( 0, msg_avp_setvalue ( avpi, &request.search.enum_value ) );
 				#if 0
@@ -465,11 +465,11 @@
 				dict_type_enum_request_t request;
 				
 				CHECK( 0, msg_model ( avpi, &avp_model ) );
-				CHECK( 0, dict_search ( DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model ) );
+				CHECK( 0, dict_search ( DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );
 				memset(&request, 0, sizeof(request));
 				request.type_obj = type_model;
 				request.search.enum_name = "os const test (waaad)";
-				CHECK( 0, dict_search ( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &request, &value_model ) );
+				CHECK( 0, dict_search ( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &request, &value_model, ENOENT ) );
 				CHECK( 0, dict_getval ( value_model, &request.search ) );
 				CHECK( 0, msg_avp_setvalue ( avpi, &request.search.enum_value ) );
 				#if 0
@@ -490,11 +490,11 @@
 				dict_type_enum_request_t request;
 				
 				CHECK( 0, msg_model ( avpi, &avp_model ) );
-				CHECK( 0, dict_search ( DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model ) );
+				CHECK( 0, dict_search ( DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );
 				memset(&request, 0, sizeof(request));
 				request.type_obj = type_model;
 				request.search.enum_name = "os const test (waa)";
-				CHECK( 0, dict_search ( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &request, &value_model ) );
+				CHECK( 0, dict_search ( DICT_TYPE_ENUM, ENUM_BY_STRUCT, &request, &value_model, ENOENT ) );
 				CHECK( 0, dict_getval ( value_model, &request.search ) );
 				CHECK( 0, msg_avp_setvalue ( avpi, &request.search.enum_value ) );
 				#if 0
@@ -764,7 +764,7 @@
 						dict_rule_data_t _ruledata;							\
 						dict_object_t * _avp;								\
 						dict_avp_request_t _req = { (_avpvendor), 0, (_ruleavp) };			\
-						CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp ) );	\
+						CHECK( 0, dict_search(DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT));	\
 						CHECK( 0, dict_getval( _rule, &_ruledata ) );					\
 						CHECK( _avp, _ruledata.rule_avp );						\
 					}											\
@@ -861,10 +861,10 @@
 		struct sockaddr_in6 sin6, *psin6;
 		
 		/* Find the CER dictionary object */
-		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer_model ) );
+		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer_model, ENOENT ) );
 
 		/* Now find the Host-IP-Address dictionary object */
-		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Host-IP-Address", &hia_model ) );
+		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Host-IP-Address", &hia_model, ENOENT ) );
 
 		/* Create the msg instance */
 		CHECK( 0, msg_new ( cer_model, 0, &cer ) );
@@ -1006,7 +1006,7 @@
 			msg_avp_data_t * avpdata = NULL;
 			msg_data_t * msgdata = NULL;
 
-			CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model ) );
+			CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model, ENOENT ) );
 
 			/* Create a message */
 			CHECK( 0, msg_new ( cmd_model, 0, &msg ) );
--- a/waaad/tests/testrt.c	Tue Jun 02 11:15:00 2009 +0900
+++ b/waaad/tests/testrt.c	Tue Jun 02 14:31:42 2009 +0900
@@ -192,14 +192,14 @@
 		sess_id_t * session = NULL;
 
 		/* Now find the dictionary objects */
-		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &model ) );
+		CHECK( 0, dict_search ( DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &model, ENOENT ) );
 
 		/* Create the instance */
 		CHECK( 0, msg_new ( model, MSGFL_ALLOW_ETEID, &msg ) );
 		
 		/* Add a new session id */
 		CHECK( 0, sess_new( &session, SESSION_NEW_DEFAULT, __FILE__ ) );
-		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Session-Id", &model ) );
+		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Session-Id", &model, ENOENT ) );
 		CHECK( 0, msg_avp_new( model, 0, &avp ) );
 		memset(&val, 0, sizeof(val));
 		CHECK( 0, sess_getsid( session, (void *) &val.os.data ) );
@@ -208,7 +208,7 @@
 		CHECK( 0, msg_avp_add( msg, MSG_BRW_FIRST_CHILD, avp ) );
 		
 		/* Add destination info */
-		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Destination-Realm", &model ) );
+		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Destination-Realm", &model, ENOENT ) );
 		CHECK( 0, msg_avp_new( model, 0, &avp ) );
 		memset(&val, 0, sizeof(val));
 		val.os.data = (unsigned char *)"otherrealm";
@@ -220,14 +220,14 @@
 		CHECK( 0, msg_add_origin( msg, 1 )  );
 		
 		/* Add record info */
-		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Accounting-Record-Type", &model ) );
+		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Accounting-Record-Type", &model, ENOENT ) );
 		CHECK( 0, msg_avp_new( model, 0, &avp ) );
 		memset(&val, 0, sizeof(val));
 		val.i32 = 2;
 		CHECK( 0, msg_avp_setvalue( avp, &val ) );
 		CHECK( 0, msg_avp_add( msg, MSG_BRW_LAST_CHILD, avp ) );
 
-		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Accounting-Record-Number", &model ) );
+		CHECK( 0, dict_search ( DICT_AVP, AVP_BY_NAME, "Accounting-Record-Number", &model, ENOENT ) );
 		CHECK( 0, msg_avp_new( model, 0, &avp ) );
 		memset(&val, 0, sizeof(val));
 		val.u32 = 1;
"Welcome to our mercurial repository"