changeset 127:8ee43cf85a5f

Added User-Name AVP in test_app extension
author Sebastien Decugis <sdecugis@nict.go.jp>
date Thu, 10 Dec 2009 14:39:55 +0900
parents 0ad5825eccdb
children 0b58b533d4f6
files doc/test_app.conf.sample extensions/test_app/ta_cli.c extensions/test_app/ta_conf.l extensions/test_app/ta_conf.y extensions/test_app/ta_dict.c extensions/test_app/test_app.h
diffstat 6 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/doc/test_app.conf.sample	Thu Dec 10 14:34:31 2009 +0900
+++ b/doc/test_app.conf.sample	Thu Dec 10 14:39:55 2009 +0900
@@ -48,6 +48,10 @@
 # (default is not providing this AVP).
 # dest-host = "server.foreign.net";
 
+# The User-Name for the message (may be useful for some routing tests).
+# (default is not providing this AVP).
+# user-name = "user@server.foreign.net";
+
 # The signal that triggers sending the test message
 # Note: Symbolic names are now recognized, you must use integers
 # signal = 10;
--- a/extensions/test_app/ta_cli.c	Thu Dec 10 14:34:31 2009 +0900
+++ b/extensions/test_app/ta_cli.c	Thu Dec 10 14:39:55 2009 +0900
@@ -195,6 +195,14 @@
 	/* Set Origin-Host & Origin-Realm */
 	CHECK_FCT_DO( fd_msg_add_origin ( req, 0 ), goto out  );
 	
+	/* Set the User-Name AVP if needed*/
+	if (ta_conf->user_name) {
+		CHECK_FCT_DO( fd_msg_avp_new ( ta_user_name, 0, &avp ), goto out  );
+		val.os.data = (unsigned char *)(ta_conf->user_name);
+		val.os.len  = strlen(ta_conf->user_name);
+		CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out  );
+		CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out  );
+	}
 	
 	/* Set the Test-AVP AVP */
 	{
--- a/extensions/test_app/ta_conf.l	Thu Dec 10 14:34:31 2009 +0900
+++ b/extensions/test_app/ta_conf.l	Thu Dec 10 14:39:55 2009 +0900
@@ -144,6 +144,10 @@
 				return DEST_HOST;
 			}
 
+(?i:"user-name")	{
+				return USER_NAME;
+			}
+
 (?i:"Signal")		{
 				return SIGNAL;
 			}
--- a/extensions/test_app/ta_conf.y	Thu Dec 10 14:34:31 2009 +0900
+++ b/extensions/test_app/ta_conf.y	Thu Dec 10 14:39:55 2009 +0900
@@ -123,6 +123,7 @@
 %token 		MODE
 %token 		DEST_REALM
 %token 		DEST_HOST
+%token 		USER_NAME
 %token 		SIGNAL
 
 /* Tokens and types for routing table definition */
@@ -146,6 +147,7 @@
 			| conffile mode
 			| conffile dstrealm
 			| conffile dsthost
+			| conffile usrname
 			| conffile signal
 			;
 
@@ -193,6 +195,13 @@
 			}
 			;
 
+usrname:		USER_NAME '=' QSTRING ';'
+			{
+				free(ta_conf->user_name);
+				ta_conf->user_name = $3;
+			}
+			;
+
 signal:			SIGNAL '=' INTEGER ';'
 			{
 				ta_conf->signal = $3;
--- a/extensions/test_app/ta_dict.c	Thu Dec 10 14:34:31 2009 +0900
+++ b/extensions/test_app/ta_dict.c	Thu Dec 10 14:39:55 2009 +0900
@@ -48,6 +48,7 @@
 struct dict_object * ta_origin_realm = NULL;
 struct dict_object * ta_dest_host = NULL;
 struct dict_object * ta_dest_realm = NULL;
+struct dict_object * ta_user_name = NULL;
 struct dict_object * ta_res_code = NULL;
 
 int ta_dict_init(void)
@@ -101,6 +102,7 @@
 	CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Realm", &ta_origin_realm, ENOENT) );
 	CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Host", &ta_dest_host, ENOENT) );
 	CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Realm", &ta_dest_realm, ENOENT) );
+	CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "User-Name", &ta_user_name, ENOENT) );
 	CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Result-Code", &ta_res_code, ENOENT) );
 	
 	/* Create the rules for Test-Request and Test-Answer */
--- a/extensions/test_app/test_app.h	Thu Dec 10 14:34:31 2009 +0900
+++ b/extensions/test_app/test_app.h	Thu Dec 10 14:39:55 2009 +0900
@@ -60,6 +60,7 @@
 	int		mode;		/* default MODE_SERV | MODE_CLI */
 	char 	*	dest_realm;	/* default local realm */
 	char 	*	dest_host;	/* default NULL */
+	char 	*	user_name;	/* default NULL */
 	int 		signal;		/* default TEST_APP_DEFAULT_SIGNAL */
 };
 extern struct ta_conf * ta_conf;
@@ -95,4 +96,5 @@
 extern struct dict_object * ta_origin_realm;
 extern struct dict_object * ta_dest_host;
 extern struct dict_object * ta_dest_realm;
+extern struct dict_object * ta_user_name;
 extern struct dict_object * ta_res_code;
"Welcome to our mercurial repository"