aboutsummaryrefslogtreecommitdiffstats
path: root/stp/STP_Tests.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 /stp/STP_Tests.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 'stp/STP_Tests.ttcn')
-rw-r--r--stp/STP_Tests.ttcn8
1 files changed, 4 insertions, 4 deletions
diff --git a/stp/STP_Tests.ttcn b/stp/STP_Tests.ttcn
index 004af050..ac45b1d4 100644
--- a/stp/STP_Tests.ttcn
+++ b/stp/STP_Tests.ttcn
@@ -73,7 +73,7 @@ testcase TC_m3ua_to_ipa() runs on IPA_M3UA_CT {
f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx
/* send a well-formed, encoded SCCP message via M3UA */
- var octetstring data := f_rnd_octstring(f_rnd_int(100));
+ var octetstring data := f_rnd_octstring_rnd_len(100);
var SCCP_PAR_Address called := valueof(ts_SccpAddr_GT('1234'H));
var SCCP_PAR_Address calling := valueof(ts_SccpAddr_GT('5678'H));
var PDU_SCCP sccp := valueof(ts_SCCP_UDT(called, calling, data));
@@ -105,7 +105,7 @@ testcase TC_ipa_to_m3ua() runs on IPA_M3UA_CT {
f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx
/* send a well-formed, encoded SCCP message via IPA */
- var octetstring data := f_rnd_octstring(f_rnd_int(100));
+ var octetstring data := f_rnd_octstring_rnd_len(100);
var SCCP_PAR_Address called := valueof(ts_SccpAddr_GT('1234'H));
var SCCP_PAR_Address calling := valueof(ts_SccpAddr_GT('5678'H));
var PDU_SCCP sccp := valueof(ts_SCCP_UDT(called, calling, data));
@@ -137,7 +137,7 @@ testcase TC_ipa_to_m3ua_ni() runs on IPA_M3UA_CT {
f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx
/* send a well-formed, encoded SCCP message via IPA */
- var octetstring data := f_rnd_octstring(f_rnd_int(100));
+ var octetstring data := f_rnd_octstring_rnd_len(100);
var SCCP_PAR_Address called := valueof(ts_SccpAddr_GT('1234'H));
var SCCP_PAR_Address calling := valueof(ts_SccpAddr_GT('5678'H));
var PDU_SCCP sccp := valueof(ts_SCCP_UDT(called, calling, data));
@@ -173,7 +173,7 @@ testcase TC_ipa_to_m3ua_patch_sccp() runs on IPA_M3UA_CT {
f_M3UA_asp_up_act(0, omit, omit); // TODO: rctx
/* send a well-formed, encoded SCCP message via IPA */
- var octetstring data := f_rnd_octstring(f_rnd_int(100));
+ var octetstring data := f_rnd_octstring_rnd_len(100);
var SCCP_PAR_Address called := valueof(ts_SccpAddr_GT('1234'H));
var SCCP_PAR_Address calling := valueof(ts_SccpAddr_GT('5678'H));
var PDU_SCCP sccp := valueof(ts_SCCP_UDT(called, calling, data));