blob: 0d23073294f9f41001fb8ae518f27ce42c3f89dc [file] [log] [blame]
Vadim Yanitskiy92015542018-05-29 21:55:01 +07001module USSD_Helpers {
2
3/* USSD helpers for composing messages, building on top
4 * of both L3_Templates and USSD_Templates.
5 *
6 * (C) 2018 by Vadim Yanitskiy <axilirator@gmail.com>
7 * All rights reserved.
8 *
9 * Released under the terms of GNU General Public License, Version 2 or
10 * (at your option) any later version.
Harald Welte34b5a952019-05-27 11:54:11 +020011 *
12 * SPDX-License-Identifier: GPL-2.0-or-later
Vadim Yanitskiy92015542018-05-29 21:55:01 +070013 */
14
15import from General_Types all;
16import from TCCEncoding_Functions all;
17
18import from SS_Templates all;
19import from SS_Types all;
20
21function f_USSD_FACILITY_IE_INVOKE(
22 integer invoke_id := 1,
23 SS_Op_Code op_code := SS_OP_CODE_PROCESS_USS_REQ,
24 charstring ussd_string := "*#100#"
25) return octetstring {
26 var SS_FacilityInformation facility_ie;
27 var octetstring ussd_string_enc;
28
29 /* Encode input string with GSM 7-bit encoding */
30 ussd_string_enc := f_encGSM7bit(ussd_string);
31
32 /* Encode Facility IE */
33 facility_ie := valueof(ts_SS_USSD_FACILITY_INVOKE(
34 invoke_id := invoke_id,
35 op_code := op_code,
36 ussd_dcs := SS_USSD_DEFAULT_DCS,
37 ussd_string := ussd_string_enc
38 ));
39
40 return enc_SS_FacilityInformation(facility_ie);
41}
42
43function f_USSD_FACILITY_IE_RETURN_RESULT(
44 integer invoke_id := 1,
45 SS_Op_Code op_code := SS_OP_CODE_PROCESS_USS_REQ,
46 charstring ussd_string := "Lorem Ipsum"
47) return octetstring {
48 var SS_FacilityInformation facility_ie;
49 var octetstring ussd_string_enc;
50
51 /* Encode input string with GSM 7-bit encoding */
52 ussd_string_enc := f_encGSM7bit(ussd_string);
53
54 /* Encode Facility IE */
55 facility_ie := valueof(ts_SS_USSD_FACILITY_RETURN_RESULT(
56 invoke_id := invoke_id,
57 op_code := op_code,
58 ussd_dcs := SS_USSD_DEFAULT_DCS,
59 ussd_string := ussd_string_enc
60 ));
61
62 return enc_SS_FacilityInformation(facility_ie);
63}
64
Vadim Yanitskiyc3cb5332018-06-06 05:27:32 +070065function f_USSD_FACILITY_IE_RETURN_ERROR(
66 integer invoke_id := 1,
67 SS_Err_Code err_code := SS_ERR_CODE_UNEXPECTED_DATA_VALUE
68) return octetstring {
69 var SS_FacilityInformation facility_ie;
70
71 /* Encode Facility IE */
72 facility_ie := valueof(ts_SS_FACILITY_RETURN_ERROR(
73 invoke_id := invoke_id,
74 err_code := err_code
75 ));
76
77 return enc_SS_FacilityInformation(facility_ie);
78}
79
Vadim Yanitskiy92015542018-05-29 21:55:01 +070080}