aboutsummaryrefslogtreecommitdiffstats
path: root/sccp/SCCP_Tests_RAW.ttcn
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2022-04-12 22:52:47 +0200
committerHarald Welte <laforge@osmocom.org>2022-04-12 22:52:47 +0200
commit67881aef23a3567aa5cb70364b388041011efbc7 (patch)
tree83ee0e0883efaf19dcc771a1598d9f1e674183b0 /sccp/SCCP_Tests_RAW.ttcn
parent12c4aa8bb7e754c935059740238b4e358b950e02 (diff)
Avoid generating zero-length packets
I used the construct like f_rnd_octstring(f_rnd_int(100)) in a number of places to generate random-length packets with randomized length. The problem I didn't realize is that f_rnd_int() of course can also return '0', which would generate zero-length packets. This may be permitted in some protocols, but it leads to problems e.g. when trying to send a UDP packet of zero length (which the kernel will not do). So let's introduce * f_rnd_int_nonzero() for returning non-zero randomized integers * f_rnd_octstring_rnd_len() for returning a random-length random payload octet string * replace all f_rnd_octstring(f_rnd_int()) call sites with the new function. Change-Id: I818a113ff8d2a2f7cab2ec7d9c8661607c6331d6 Closes: OS#5528
Diffstat (limited to 'sccp/SCCP_Tests_RAW.ttcn')
-rw-r--r--sccp/SCCP_Tests_RAW.ttcn6
1 files changed, 3 insertions, 3 deletions
diff --git a/sccp/SCCP_Tests_RAW.ttcn b/sccp/SCCP_Tests_RAW.ttcn
index 5013ddf3..fd6bad9e 100644
--- a/sccp/SCCP_Tests_RAW.ttcn
+++ b/sccp/SCCP_Tests_RAW.ttcn
@@ -182,7 +182,7 @@ testcase TC_cr_cc() runs on SCCP_Test_RAW_CT {
testcase TC_udt_without_cr_cc() runs on SCCP_Test_RAW_CT {
var SCCP_PAR_Address calling, called;
var SCCP_MTP3_TRANSFERind rx;
- var octetstring data := f_rnd_octstring(f_rnd_int(100));
+ var octetstring data := f_rnd_octstring_rnd_len(100);
/* Keep recommended ratio of T(iar) >= T(ias)*2, but anyway no IT
should be received in this case. */
@@ -215,7 +215,7 @@ testcase TC_udt_without_cr_cc() runs on SCCP_Test_RAW_CT {
testcase TC_tiar_timeout() runs on SCCP_Test_RAW_CT {
var SCCP_PAR_Address calling, called;
var OCT3 remote_lref;
- var octetstring data := f_rnd_octstring(f_rnd_int(100));
+ var octetstring data := f_rnd_octstring_rnd_len(100);
/* Set T(iar) in sccp_demo_user low enough that it will trigger before other side
has time to keep alive with a T(ias). Keep recommended ratio of
@@ -320,7 +320,7 @@ private function f_tx_xudt_exp(SCCP_PAR_Address calling, SCCP_PAR_Address called
/* Test if the IUT SCCP code processes an XUDT [treat it like UDT] and answers back. */
testcase TC_process_rx_xudt() runs on SCCP_Test_RAW_CT {
var SCCP_PAR_Address calling, called;
- var octetstring data := f_rnd_octstring(f_rnd_int(100));
+ var octetstring data := f_rnd_octstring_rnd_len(100);
f_init_raw(mp_sccp_cfg[0]);
f_sleep(1.0);