blob: 8939cad297baaaf74094c583a0283c37ebbe501b [file] [log] [blame]
Harald Welte3a194402017-07-22 17:07:51 +02001module Test {
2
3 import from BSSGP_Helper_Functions all;
4 import from BSSGP_Types all;
Harald Welte6fff3642017-07-22 21:36:13 +02005 import from NS_Types all;
Harald Welte3a194402017-07-22 17:07:51 +02006
7 type component dummy_CT {
8 }
9
Harald Welte6fff3642017-07-22 21:36:13 +020010 function f_bssgp_assert_prepr(in octetstring a, in octetstring b) {
11 log("BSSGP Input: ", a);
12 log("BSSGP Expected: ", b);
Harald Weltef1fd0162017-07-22 20:34:05 +020013 var octetstring a_preprocessed := f_BSSGP_expand_len(a);
Harald Welte6fff3642017-07-22 21:36:13 +020014 log("BSSGP Preprocessed: ", a_preprocessed);
Harald Welte3a194402017-07-22 17:07:51 +020015
16 if (a_preprocessed != b) {
17 setverdict(fail);
18 } else {
19 setverdict(pass);
20 }
21 }
22
Harald Welte6fff3642017-07-22 21:36:13 +020023 function f_bssgp_dec_and_log(in octetstring inp) {
24 log("BSSGP Input: ", inp);
Harald Weltef1fd0162017-07-22 20:34:05 +020025 var octetstring inp_p := f_BSSGP_expand_len(inp);
Harald Welte6fff3642017-07-22 21:36:13 +020026 log("BSSGP Preprocessed: ", inp_p);
Harald Welte3a194402017-07-22 17:07:51 +020027 var BssgpPdu dec := dec_BssgpPdu(inp_p);
Harald Welte6fff3642017-07-22 21:36:13 +020028 log("BSSGP Decoded: ", dec);
Harald Welte3a194402017-07-22 17:07:51 +020029 }
30
Harald Welte6fff3642017-07-22 21:36:13 +020031 testcase TC_selftest_bssgp() runs on dummy_CT {
Harald Welte3a194402017-07-22 17:07:51 +020032 const octetstring c_bvc_reset_pcu := '2204820000078108088832f44000c80051e0'O;
33 const octetstring c_bvc_reset_q := '2204820000078100'O;
34 const octetstring c_status_pcu := '4107810515882204820000078103'O;
35 const octetstring c_reset_ack_q := '2304820000'O;
36 const octetstring c_reset_ack_pcu := '23048200c4'O;
37 const octetstring c_unblock_pcu := '24048200c4'O;
38 const octetstring c_unblock_ack_q := '25048200c4'O;
39 const octetstring c_fc_bvc_pcu := '261e8101058200fa038200c8018200fa1c8200c806820000'O;
40 const octetstring c_fc_bvc_ack_q := '271e8101'O;
41 const octetstring c_gmm_mo_att_req := '01bb146ddd000004088832f44000c80051e000800e003b01c001080103e5e000110a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c0002017057bf0ec'O;
42 const octetstring c_gmm_mt_ac_req := '00bb146ddd0050001682ffff0a8204030e9c41c001081200102198c72477ea104895e8b959acc58b108182f4d045'O;
43 const octetstring c_gmm_mo_ac_resp := '01bb146ddd000004088832f44000c80051e000800e000e01c00508130122fa361f5fdd623d'O;
44 const octetstring c_gmm_mt_att_acc := '00bb146ddd0050001682ffff0a8204030e9841c005080201340432f44000c8001805f4fb146ddd0967d0'O;
45 const octetstring c_gmm_mt_det_req := '00bb146ddd0050001682ffff0a8204030e8941c00908050215f0b6'O;
46 const octetstring c_gmm_mo_att_cpl := '01fb146ddd000004088832f44000c80051e000800e000801c009080339d7bc'O;
47
48 /* single byte length to two byte length */
Harald Welte6fff3642017-07-22 21:36:13 +020049 f_bssgp_assert_prepr('04058101'O, '0405000101'O);
50 f_bssgp_assert_prepr('040589000102030405060708'O, '04050009000102030405060708'O);
Harald Welte3a194402017-07-22 17:07:51 +020051 /* two byte length to two byte length */
Harald Welte6fff3642017-07-22 21:36:13 +020052 f_bssgp_assert_prepr('0405000101'O, '0405000101'O);
Harald Welte3a194402017-07-22 17:07:51 +020053 /* special case: DL-UD + UL-UD */
Harald Welte6fff3642017-07-22 21:36:13 +020054 f_bssgp_assert_prepr('00aabbccddeeffaa29822342'O, '00aabbccddeeffaa2900022342'O);
55 f_bssgp_assert_prepr('01aabbccddeeffaa29822342'O, '01aabbccddeeffaa2900022342'O);
Harald Welte3a194402017-07-22 17:07:51 +020056 /* multiple TLVs */
Harald Welte6fff3642017-07-22 21:36:13 +020057 f_bssgp_assert_prepr('234281aa4382bbbb'O, '23420001aa430002bbbb'O);
58 f_bssgp_assert_prepr('230080'O, '23000000'O);
Harald Welte3a194402017-07-22 17:07:51 +020059
Harald Welte6fff3642017-07-22 21:36:13 +020060 f_bssgp_dec_and_log(c_bvc_reset_pcu);
61 f_bssgp_dec_and_log(c_bvc_reset_q);
62 f_bssgp_dec_and_log(c_status_pcu);
63 f_bssgp_dec_and_log(c_reset_ack_q);
64 f_bssgp_dec_and_log(c_reset_ack_pcu);
65 f_bssgp_dec_and_log(c_unblock_pcu);
66 f_bssgp_dec_and_log(c_unblock_ack_q);
67 f_bssgp_dec_and_log(c_fc_bvc_pcu);
68 f_bssgp_dec_and_log(c_fc_bvc_ack_q);
69 f_bssgp_dec_and_log(c_gmm_mo_att_req);
70 f_bssgp_dec_and_log(c_gmm_mt_ac_req);
71 f_bssgp_dec_and_log(c_gmm_mo_ac_resp);
72 f_bssgp_dec_and_log(c_gmm_mt_att_acc);
73 f_bssgp_dec_and_log(c_gmm_mt_det_req);
74 f_bssgp_dec_and_log(c_gmm_mo_att_cpl);
75 }
76
77 function f_ns_assert_prepr(in octetstring a, in octetstring b) {
78 log("NS Input: ", a);
79 log("NS Expected: ", b);
80 var octetstring a_preprocessed := f_NS_expand_len(a);
81 log("NS Preprocessed: ", a_preprocessed);
82
83 if (a_preprocessed != b) {
84 setverdict(fail);
85 } else {
86 setverdict(pass);
87 }
88 }
89
90 function f_ns_dec_and_log(in octetstring inp) {
91 log("NS Input: ", inp);
92 var octetstring inp_p := f_NS_expand_len(inp);
93 log("NS Preprocessed: ", inp_p);
94 var NsPdu dec := dec_NsPdu(inp_p);
95 log("NS Decoded: ", dec);
96 }
97
98 testcase TC_selftest_ns() runs on dummy_CT {
99 const octetstring c_ns_reset_pcu := '000000c4271e813d'O;
100
101 /* single byte length to two byte length */
102 f_ns_assert_prepr('04058101'O, '0405000101'O);
103 f_ns_assert_prepr('040589000102030405060708'O, '04050009000102030405060708'O);
104 /* two byte length to two byte length */
105 f_ns_assert_prepr('0405000101'O, '0405000101'O);
106 /* special case: NS-UNITDATA */
107 f_ns_assert_prepr('00aabbccddeeffaa29822342'O, '00aabbccddeeffaa2900022342'O);
108 /* multiple TLVs */
109 f_ns_assert_prepr('234281aa4382bbbb'O, '23420001aa430002bbbb'O);
110 /* zero-length */
111 f_ns_assert_prepr('230080'O, '23000000'O);
112
113 f_ns_dec_and_log(c_ns_reset_pcu);
Harald Welte3a194402017-07-22 17:07:51 +0200114 }
115
116 control {
Harald Welte6fff3642017-07-22 21:36:13 +0200117 execute(TC_selftest_bssgp());
118 execute(TC_selftest_ns());
Harald Welte3a194402017-07-22 17:07:51 +0200119 }
120};