summaryrefslogtreecommitdiffstats
path: root/library/SS_Templates.ttcn
blob: 6d8fcf2a3c581ea60cf48b522776d16c2bae331a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
module SS_Templates {

/* SS/USSD Facility IE templates, building on top of SS_Types.
 *
 * (C) 2018 by Vadim Yanitskiy <axilirator@gmail.com>
 * All rights reserved.
 *
 * Released under the terms of GNU General Public License, Version 2 or
 * (at your option) any later version.
 */

import from General_Types all;
import from SS_Types all;

/* GSM TS 04.80, section 4.5, SS operation code */
type enumerated SS_Op_Code {
	SS_OP_CODE_REGISTER_SS			('0A'O),
	SS_OP_CODE_ERASE_SS			('0B'O),
	SS_OP_CODE_ACTIVATE_SS			('0C'O),
	SS_OP_CODE_DEACTIVATE_SS		('0D'O),
	SS_OP_CODE_INTERROGATE_SS		('0E'O),
	SS_OP_CODE_NOTIFY_SS			('10'O),
	SS_OP_CODE_REGISTER_PASSWORD		('11'O),
	SS_OP_CODE_GET_PASSWORD			('12'O),
	SS_OP_CODE_PROCESS_USS_DATA		('13'O),
	SS_OP_CODE_FORWARD_CHECK_SS_IND		('26'O),
	SS_OP_CODE_PROCESS_USS_REQ		('3B'O),
	SS_OP_CODE_USS_REQUEST			('3C'O),
	SS_OP_CODE_USS_NOTIFY			('3D'O),
	SS_OP_CODE_FORWARD_CUG_INFO		('78'O),
	SS_OP_CODE_SPLIT_MPTY			('79'O),
	SS_OP_CODE_RETRIEVE_MPTY		('7A'O),
	SS_OP_CODE_HOLD_MPTY			('7B'O),
	SS_OP_CODE_BUILD_MPTY			('7C'O),
	SS_OP_CODE_FORWARD_CHARGE_ADVICE	('7D'O)
}

/* GSM TS 04.80, section 4.5, SS error code */
type enumerated SS_Err_Code {
	SS_ERR_CODE_UNKNOWN_SUBSCRIBER			('01'O),
	SS_ERR_CODE_ILLEGAL_SUBSCRIBER			('09'O),
	SS_ERR_CODE_BEARER_SERVICE_NOT_PROVISIONED	('0A'O),
	SS_ERR_CODE_TELESERVICE_NOT_PROVISIONED		('0B'O),
	SS_ERR_CODE_ILLEGAL_EQUIPMENT			('0C'O),
	SS_ERR_CODE_CALL_BARRED				('0D'O),
	SS_ERR_CODE_ILLEGAL_SS_OPERATION		('10'O),
	SS_ERR_CODE_SS_ERROR_STATUS			('11'O),
	SS_ERR_CODE_SS_NOT_AVAILABLE			('12'O),
	SS_ERR_CODE_SS_SUBSCRIPTION_VIOLATION		('13'O),
	SS_ERR_CODE_SS_INCOMPATIBILITY			('14'O),
	SS_ERR_CODE_FACILITY_NOT_SUPPORTED		('15'O),
	SS_ERR_CODE_ABSENT_SUBSCRIBER			('1B'O),
	SS_ERR_CODE_SYSTEM_FAILURE			('22'O),
	SS_ERR_CODE_DATA_MISSING			('23'O),
	SS_ERR_CODE_UNEXPECTED_DATA_VALUE		('24'O),
	SS_ERR_CODE_PW_REGISTRATION_FAILURE		('25'O),
	SS_ERR_CODE_NEGATIVE_PW_CHECK			('26'O),
	SS_ERR_CODE_NUM_PW_ATTEMPTS_VIOLATION		('2B'O),
	SS_ERR_CODE_UNKNOWN_ALPHABET			('47'O),
	SS_ERR_CODE_USSD_BUSY				('48'O),
	SS_ERR_CODE_MAX_MPTY_PARTICIPANTS		('7E'O),
	SS_ERR_CODE_RESOURCES_NOT_AVAILABLE		('7F'O)
}

/**
 * According to GSM TS 02.90, section 4.1.1,
 * the mobile initiated USSD request shall contain
 * an alphabet indicator set to "SMS default alphabet"
 * and language indicator set to "language unspecified".
 *
 * This DCS value is used quite often, so it makes
 * sense to define it here as a constant.
 */
const octetstring SS_USSD_DEFAULT_DCS := '0F'O;

template (value) SS_FacilityInformation ts_SS_USSD_FACILITY_INVOKE(
	integer invoke_id := 1,
	SS_Op_Code op_code := SS_OP_CODE_PROCESS_USS_REQ,
	octetstring ussd_dcs := SS_USSD_DEFAULT_DCS,
	octetstring ussd_string := 'AA180C3602'O // *#100#
) := {
	{
		invoke := {
			invokeId := { present_ := invoke_id },
			linkedId := omit,
			opcode := {
				local := enum2int(op_code)
			},
			argument := {
				uSSD_Arg := {
					ussd_DataCodingScheme := ussd_dcs,
					ussd_String := ussd_string,
					alertingPattern := omit,
					msisdn := omit
				}
			}
		}
	}
}
template SS_FacilityInformation tr_SS_USSD_FACILITY_INVOKE(
	template integer invoke_id := ?,
	template integer op_code := ?,
	template octetstring ussd_dcs := ?,
	template octetstring ussd_string := ?
) := {
	{
		invoke := {
			invokeId := { present_ := invoke_id },
			linkedId := omit,
			opcode := {
				local := op_code
			},
			argument := {
				uSSD_Arg := {
					ussd_DataCodingScheme := ussd_dcs,
					ussd_String := ussd_string,
					alertingPattern := omit,
					msisdn := omit
				}
			}
		}
	}
}

template (value) SS_FacilityInformation ts_SS_FACILITY_INVOKE(
	integer invoke_id := 1,
	SS_Op_Code op_code,
	OCT1 ss_code
) := {
	{
		invoke := {
			invokeId := { present_ := invoke_id },
			linkedId := omit,
			opcode := { local := enum2int(op_code) },
			argument := {
				sS_ForBS_Code := {
					ss_Code := ss_code,
					basicService := omit,
					longFTN_Supported := omit
				}
			}
		}
	}
}
template SS_FacilityInformation tr_SS_FACILITY_INVOKE(
	template integer invoke_id := 1,
	template integer op_code := ?,
	template OCT1 ss_code := ?
) := {
	{
		invoke := {
			invokeId := { present_ := invoke_id },
			linkedId := omit,
			opcode := { local := op_code },
			argument := {
				sS_ForBS_Code := {
					ss_Code := ss_code,
					basicService := omit,
					longFTN_Supported := omit
				}
			}
		}
	}
}

template (value) SS_FacilityInformation ts_SS_USSD_FACILITY_RETURN_RESULT(
	integer invoke_id := 1,
	SS_Op_Code op_code := SS_OP_CODE_PROCESS_USS_REQ,
	octetstring ussd_dcs,
	octetstring ussd_string
) := {
	{
		returnResult := {
			invokeId := { present_ := invoke_id },
			result := {
				opcode := {
					local := enum2int(op_code)
				},
				result := {
					uSSD_Res := {
						ussd_DataCodingScheme := ussd_dcs,
						ussd_String := ussd_string
					}
				}
			}
		}
	}
}
template SS_FacilityInformation tr_SS_USSD_FACILITY_RETURN_RESULT(
	template integer invoke_id := ?,
	template integer op_code := ?,
	template octetstring ussd_dcs := ?,
	template octetstring ussd_string := ?
) := {
	{
		returnResult := {
			invokeId := { present_ := invoke_id },
			result := {
				opcode := {
					local := op_code
				},
				result := {
					uSSD_Res := {
						ussd_DataCodingScheme := ussd_dcs,
						ussd_String := ussd_string
					}
				}
			}
		}
	}
}

template (value) SS_FacilityInformation ts_SS_USSD_FACILITY_RETURN_RESULT_EMPTY(
	integer invoke_id := 1
) := {
	{
		returnResult := {
			invokeId := { present_ := invoke_id },
			result := omit
		}
	}
}
template SS_FacilityInformation tr_SS_USSD_FACILITY_RETURN_RESULT_EMPTY(
	template integer invoke_id := ?
) := {
	{
		returnResult := {
			invokeId := { present_ := invoke_id },
			result := omit
		}
	}
}

/* Common for both structured and unstructured SS */
template (value) SS_FacilityInformation ts_SS_FACILITY_RETURN_ERROR(
	integer invoke_id := 1,
	SS_Err_Code err_code
) := {
	{
		returnError := {
			invokeId := { present_ := invoke_id },
			errcode := {
				local := enum2int(err_code)
			},
			parameter := omit
		}
	}
}
template SS_FacilityInformation tr_SS_FACILITY_RETURN_ERROR(
	template integer invoke_id := ?,
	template integer err_code := ?
) := {
	{
		returnError := {
			invokeId := { present_ := invoke_id },
			errcode := {
				local := err_code
			},
			parameter := omit
		}
	}
}

}