diff extensions/test_app/ta_bench.c @ 1230:992437a90bda

Enable mix of short and long messages in test_app
author Sebastien Decugis <sdecugis@freediameter.net>
date Thu, 20 Jun 2013 11:01:19 +0800
parents ef7c5e39badf
children
line wrap: on
line diff
--- a/extensions/test_app/ta_bench.c	Thu Jun 20 10:20:29 2013 +0800
+++ b/extensions/test_app/ta_bench.c	Thu Jun 20 11:01:19 2013 +0800
@@ -121,6 +121,7 @@
 	struct avp * avp;
 	union avp_value val;
 	struct ta_mess_info * mi = NULL;
+	static uint8_t * long_payload = NULL;
 	
 	TRACE_DEBUG(FULL, "Creating a new message for sending.");
 	
@@ -180,6 +181,19 @@
 		CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out  );
 	}
 	
+	/* Set the Test-Payload-AVP AVP if requested */
+	if ((ta_conf->long_avp_id) &&
+		(!(ta_conf->mode & MODE_MIXSIZE) || (!(mi->randval & 0x3)))) {
+		CHECK_FCT_DO( fd_msg_avp_new ( ta_avp_long, 0, &avp ), goto out  );
+		if (!long_payload) {
+			CHECK_MALLOC_DO( long_payload = calloc(1, ta_conf->long_avp_len), goto out);
+		}
+		val.os.data = long_payload;
+		val.os.len = ta_conf->long_avp_len;
+		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  );
+	}
+	
 	CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &mi->ts), goto out );
 	
 	/* Send the request */
"Welcome to our mercurial repository"