summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-05-10 20:23:16 +0200
committerHarald Welte <laforge@gnumonks.org>2018-05-10 21:35:01 +0200
commit651fcdc7c04d00daf1a2b5c38d129ede0ea8dcdd (patch)
treee06d240fe5f3e68fd1b230f31dca3fb9fcf75c7b
parent8863fa115204aab0a9ee69d64f093f4967eb2063 (diff)
bsc: Unify encryption related test cases
Rather than having copy+pate code, parameterize it. Change-Id: Ifc554245f80b09309f2da60c9d17c289c331b22e
-rw-r--r--bsc/BSC_Tests.ttcn71
-rw-r--r--bsc/MSC_ConnectionHandler.ttcn16
2 files changed, 31 insertions, 56 deletions
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index 8ab77cf..b3c7c61 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -1434,54 +1434,45 @@ runs on MSC_ConnHdlr {
fn.apply(id);
}
-private function f_tc_assignment_fr_a5_0(charstring id) runs on MSC_ConnHdlr {
- g_pars := valueof(t_def_TestHdlrPars);
+private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
- const OCT8 kc := '0001020304050607'O;
ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
f_establish_fully(ass_cmd, exp_compl);
- f_cipher_mode('01'O, kc);
+ f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
}
-
testcase TC_assignment_fr_a5_0() runs on test_CT {
var MSC_ConnHdlr vc_conn;
+ var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
f_init(1, true);
f_sleep(1.0);
-
- vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_0));
+ vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
vc_conn.done;
}
-
-
-
-private function f_tc_assignment_fr_a5_1(charstring id) runs on MSC_ConnHdlr {
- g_pars := valueof(t_def_TestHdlrPars);
-
- var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
- var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
- var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
- const OCT8 kc := '0001020304050607'O;
-
- ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
- ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
-
- f_establish_fully(ass_cmd, exp_compl);
- f_cipher_mode('02'O, kc);
-}
-
testcase TC_assignment_fr_a5_1() runs on test_CT {
var MSC_ConnHdlr vc_conn;
+ var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
f_init(1, true);
f_sleep(1.0);
+ vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
+ vc_conn.done;
+}
+testcase TC_assignment_fr_a5_3() runs on test_CT {
+ var MSC_ConnHdlr vc_conn;
+ var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
- vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1));
+ f_init(1, true);
+ f_sleep(1.0);
+ vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
vc_conn.done;
}
@@ -1496,7 +1487,6 @@ private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MS
ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
f_establish_fully(ass_cmd, exp_fail);
}
-
testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
var MSC_ConnHdlr vc_conn;
@@ -1507,32 +1497,6 @@ testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
vc_conn.done;
}
-
-private function f_tc_assignment_fr_a5_3(charstring id ) runs on MSC_ConnHdlr {
- g_pars := valueof(t_def_TestHdlrPars);
- var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
- var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
- var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
- const OCT8 kc := '0001020304050607'O;
-
- ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
- ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
-
- f_establish_fully(ass_cmd, exp_compl);
- f_cipher_mode('08'O, kc);
-}
-
-testcase TC_assignment_fr_a5_3() runs on test_CT {
- var MSC_ConnHdlr vc_conn;
-
- f_init(1, true);
- f_sleep(1.0);
-
- vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_3));
- vc_conn.done;
-}
-
-
private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
g_pars := valueof(t_def_TestHdlrPars);
var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
@@ -1547,7 +1511,6 @@ private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
f_cipher_mode('10'O, kc, kc128, true);
/* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
}
-
testcase TC_assignment_fr_a5_4() runs on test_CT {
var MSC_ConnHdlr vc_conn;
diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index efd68a3..c1ff963 100644
--- a/bsc/MSC_ConnectionHandler.ttcn
+++ b/bsc/MSC_ConnectionHandler.ttcn
@@ -346,12 +346,23 @@ private function f_create_bssmap_exp(octetstring l3_enc) runs on MSC_ConnHdlr {
}
}
+type record TestHdlrEncrParams {
+ OCT1 enc_alg,
+ octetstring enc_key
+};
+
+template (value) TestHdlrEncrParams t_EncrParams(OCT1 alg, octetstring key) := {
+ enc_alg := alg,
+ enc_key := key
+}
+
type record TestHdlrParams {
OCT1 ra,
GsmFrameNumber fn,
hexstring imsi,
RslLinkId link_id,
- BSSMAP_IE_SpeechCodecList ass_codec_list optional
+ BSSMAP_IE_SpeechCodecList ass_codec_list optional,
+ TestHdlrEncrParams encr optional
};
template (value) TestHdlrParams t_def_TestHdlrPars := {
@@ -359,7 +370,8 @@ template (value) TestHdlrParams t_def_TestHdlrPars := {
fn := 23,
imsi := '001019876543210'H,
link_id := valueof(ts_RslLinkID_DCCH(0)),
- ass_codec_list := omit
+ ass_codec_list := omit,
+ encr := omit
}
function f_create_chan_and_exp() runs on MSC_ConnHdlr {