# HG changeset patch # User Sebastien Decugis # Date 1371544065 -28800 # Node ID c2fbaf2985f4d8a1d7e77cb5075cb187fbc0eb75 # Parent b1c4876b1896443a750aa12e31c051c6375796d9 New options to test_app extension to generate long Diameter messages diff -r b1c4876b1896 -r c2fbaf2985f4 doc/test_app.conf.sample --- a/doc/test_app.conf.sample Tue Jun 18 12:44:30 2013 +0800 +++ b/doc/test_app.conf.sample Tue Jun 18 16:27:45 2013 +0800 @@ -28,6 +28,13 @@ # The AVP id for the test. # avp-id = 345678; +# Another AVP id for long payload test. default to value 0, meaning this is not used. +# long-avp-id = 0; + +# Define the payload length of the long-avp. Default 5000 bytes. +# long-avp-len = 5000; + + ####################### # Configuration of the extension behavior diff -r b1c4876b1896 -r c2fbaf2985f4 extensions/test_app/ta_cli.c --- a/extensions/test_app/ta_cli.c Tue Jun 18 12:44:30 2013 +0800 +++ b/extensions/test_app/ta_cli.c Tue Jun 18 16:27:45 2013 +0800 @@ -181,7 +181,7 @@ TRACE_DEBUG(FULL, "Creating a new message for sending."); - /* Create the request from template */ + /* Create the request */ CHECK_FCT_DO( fd_msg_new( ta_cmd_r, MSGFL_ALLOC_ETEID, &req ), goto out ); /* Create a new session */ @@ -238,6 +238,19 @@ CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out ); } + /* Set the Test-Payload-AVP AVP */ + if (ta_conf->long_avp_id) { + int l; + CHECK_FCT_DO( fd_msg_avp_new ( ta_avp_long, 0, &avp ), goto out ); + CHECK_MALLOC_DO( val.os.data = malloc(ta_conf->long_avp_len), goto out); + val.os.len = ta_conf->long_avp_len; + for (l=0; l < ta_conf->long_avp_len; l++) + val.os.data[l]=l; + CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); + free(val.os.data); + CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out ); + } + CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &mi->ts), goto out ); /* Keep a pointer to the session data for debug purpose, in real life we would not need it */ diff -r b1c4876b1896 -r c2fbaf2985f4 extensions/test_app/ta_conf.l --- a/extensions/test_app/ta_conf.l Tue Jun 18 12:44:30 2013 +0800 +++ b/extensions/test_app/ta_conf.l Tue Jun 18 16:27:45 2013 +0800 @@ -117,6 +117,14 @@ return AVP_ID; } +(?i:"long-avp-id") { + return LONG_AVP_ID; + } + +(?i:"long-avp-len") { + return LONG_AVP_LEN; + } + (?i:"mode") { return MODE; } diff -r b1c4876b1896 -r c2fbaf2985f4 extensions/test_app/ta_conf.y --- a/extensions/test_app/ta_conf.y Tue Jun 18 12:44:30 2013 +0800 +++ b/extensions/test_app/ta_conf.y Tue Jun 18 16:27:45 2013 +0800 @@ -120,6 +120,8 @@ %token APPLI_ID %token CMD_ID %token AVP_ID +%token LONG_AVP_ID +%token LONG_AVP_LEN %token MODE %token DEST_REALM %token DEST_HOST @@ -145,6 +147,8 @@ | conffile appli | conffile cmd | conffile avp + | conffile long_avp_id + | conffile long_avp_len | conffile mode | conffile dstrealm | conffile dsthost @@ -177,6 +181,18 @@ } ; +long_avp_id: LONG_AVP_ID '=' INTEGER ';' + { + ta_conf->long_avp_id = $3; + } + ; + +long_avp_len: LONG_AVP_LEN '=' INTEGER ';' + { + ta_conf->long_avp_len = $3; + } + ; + mode: MODE '=' INTEGER ';' { ta_conf->mode = $3 | (ta_conf->mode & ~3); /* overwrite the 2 lsb */ diff -r b1c4876b1896 -r c2fbaf2985f4 extensions/test_app/ta_dict.c --- a/extensions/test_app/ta_dict.c Tue Jun 18 12:44:30 2013 +0800 +++ b/extensions/test_app/ta_dict.c Tue Jun 18 16:27:45 2013 +0800 @@ -42,6 +42,7 @@ struct dict_object * ta_cmd_r = NULL; struct dict_object * ta_cmd_a = NULL; struct dict_object * ta_avp = NULL; +struct dict_object * ta_avp_long = NULL; struct dict_object * ta_sess_id = NULL; struct dict_object * ta_origin_host = NULL; @@ -96,6 +97,18 @@ CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_AVP, &data, NULL, &ta_avp)); } + /* Create the Test Payload AVP */ + if (ta_conf->long_avp_id) { + struct dict_avp_data data; + data.avp_code = ta_conf->long_avp_id; + data.avp_vendor = ta_conf->vendor_id; + data.avp_name = "Test-Payload-AVP"; + data.avp_flag_mask = AVP_FLAG_VENDOR; + data.avp_flag_val = AVP_FLAG_VENDOR; + data.avp_basetype = AVP_TYPE_OCTETSTRING; + CHECK_FCT(fd_dict_new( fd_g_config->cnf_dict, DICT_AVP, &data, NULL, &ta_avp_long)); + } + /* Now resolve some other useful AVPs */ CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &ta_sess_id, ENOENT) ); CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &ta_origin_host, ENOENT) ); diff -r b1c4876b1896 -r c2fbaf2985f4 extensions/test_app/ta_serv.c --- a/extensions/test_app/ta_serv.c Tue Jun 18 12:44:30 2013 +0800 +++ b/extensions/test_app/ta_serv.c Tue Jun 18 16:27:45 2013 +0800 @@ -94,6 +94,20 @@ CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, avp ) ); } + /* Set the Test-Payload-AVP AVP */ + if (ta_conf->long_avp_id) { + struct avp * src = NULL; + struct avp_hdr * hdr = NULL; + + CHECK_FCT( fd_msg_search_avp ( qry, ta_avp_long, &src) ); + CHECK_FCT( fd_msg_avp_hdr( src, &hdr ) ); + + CHECK_FCT( fd_msg_avp_new ( ta_avp_long, 0, &avp ) ); + CHECK_FCT( fd_msg_avp_setvalue( avp, hdr->avp_value ) ); + CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, avp ) ); + } + + /* Set the Origin-Host, Origin-Realm, Result-Code AVPs */ CHECK_FCT( fd_msg_rescode_set( ans, "DIAMETER_SUCCESS", NULL, NULL, 1 ) ); diff -r b1c4876b1896 -r c2fbaf2985f4 extensions/test_app/test_app.c --- a/extensions/test_app/test_app.c Tue Jun 18 12:44:30 2013 +0800 +++ b/extensions/test_app/test_app.c Tue Jun 18 16:27:45 2013 +0800 @@ -54,6 +54,7 @@ ta_conf->appli_id = 0xffffff; /* dummy value */ ta_conf->cmd_id = 0xfffffe; /* Experimental */ ta_conf->avp_id = 0xffffff; /* dummy value */ + ta_conf->long_avp_len = 5000; ta_conf->mode = MODE_SERV | MODE_CLI; ta_conf->dest_realm = strdup(fd_g_config->cnf_diamrlm); ta_conf->dest_host = NULL; @@ -76,6 +77,8 @@ fd_log_debug( " Application Id ..... : %u", ta_conf->appli_id); fd_log_debug( " Command Id ......... : %u", ta_conf->cmd_id); fd_log_debug( " AVP Id ............. : %u", ta_conf->avp_id); + fd_log_debug( " Long AVP Id ........ : %u", ta_conf->long_avp_id); + fd_log_debug( " Long AVP len ....... : %zu", ta_conf->long_avp_len); fd_log_debug( " Mode ............... : %s%s%s", ta_conf->mode & MODE_SERV ? "Serv" : "", ta_conf->mode & MODE_CLI ? "Cli" : "", ta_conf->mode & MODE_BENCH ? " (Benchmark)" : ""); fd_log_debug( " Destination Realm .. : %s", ta_conf->dest_realm ?: "- none -"); fd_log_debug( " Destination Host ... : %s", ta_conf->dest_host ?: "- none -"); diff -r b1c4876b1896 -r c2fbaf2985f4 extensions/test_app/test_app.h --- a/extensions/test_app/test_app.h Tue Jun 18 12:44:30 2013 +0800 +++ b/extensions/test_app/test_app.h Tue Jun 18 16:27:45 2013 +0800 @@ -59,6 +59,8 @@ uint32_t appli_id; /* default 123456 */ uint32_t cmd_id; /* default 234567 */ uint32_t avp_id; /* default 345678 */ + uint32_t long_avp_id; /* default 0 */ + size_t long_avp_len; /* default 5000 */ int mode; /* default MODE_SERV | MODE_CLI */ char * dest_realm; /* default local realm */ char * dest_host; /* default NULL */ @@ -104,6 +106,7 @@ extern struct dict_object * ta_cmd_r; extern struct dict_object * ta_cmd_a; extern struct dict_object * ta_avp; +extern struct dict_object * ta_avp_long; extern struct dict_object * ta_sess_id; extern struct dict_object * ta_origin_host;