blob: 95b2cc27d9687ddcc95ff045cdd7f5a262ec5405 [file] [log] [blame]
Harald Weltedf327232017-12-28 22:51:51 +01001module GSUP_Types {
2
Harald Welte35bb7162018-01-03 21:07:52 +01003/* GSUP_Types, defining abstract TTCN-3 data types for the GSUP protocol.
4 *
5 * GSUP is a non-standard protocol used between OsmoMSC/OsmoSGSN and OsmoHLR
6 * in order to replace the complex TCAP/MAP protocol.
7 *
8 * (C) 2017 by Harald Welte <laforge@gnumonks.org>
9 * All rights reserved.
10 *
11 * Released under the terms of GNU General Public License, Version 2 or
12 * (at your option) any later version.
13 */
14
Harald Weltedf327232017-12-28 22:51:51 +010015import from General_Types all;
16import from Osmocom_Types all;
17
18type enumerated GSUP_IEI {
19 OSMO_GSUP_IMSI_IE ('01'O),
20 OSMO_GSUP_CAUSE_IE ('02'O),
21 OSMO_GSUP_AUTH_TUPLE_IE ('03'O),
22 OSMO_GSUP_PDP_INFO_COMPL_IE ('04'O),
23 OSMO_GSUP_PDP_INFO_IE ('05'O),
24 OSMO_GSUP_CANCEL_TYPE_IE ('06'O),
25 OSMO_GSUP_FREEZE_PTMSI_IE ('07'O),
26 OSMO_GSUP_MSISDN_IE ('08'O),
27 OSMO_GSUP_HLR_NUMBER_IE ('09'O),
28 OSMO_GSUP_PDP_CONTEXT_ID_IE ('10'O),
29 OSMO_GSUP_PDP_TYPE_IE ('11'O),
30 OSMO_GSUP_ACCESS_POINT_NAME_IE ('12'O),
31 OSMO_GSUP_PDP_QOS_IE ('13'O),
32 OSMO_GSUP_CHARG_CHAR_IE ('14'O),
33
34 OSMO_GSUP_RAND_IE ('20'O),
35 OSMO_GSUP_SRES_IE ('21'O),
36 OSMO_GSUP_KC_IE ('22'O),
37 OSMO_GSUP_IK_IE ('23'O),
38 OSMO_GSUP_CK_IE ('24'O),
39 OSMO_GSUP_AUTN_IE ('25'O),
40 OSMO_GSUP_AUTS_IE ('26'O),
41 OSMO_GSUP_RES_IE ('27'O),
42 OSMO_GSUP_CN_DOMAIN_IE ('28'O)
43} with { variant "FIELDLENGTH(8)" };
44
45type enumerated GSUP_MessageType {
46 OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST ('00000100'B),
47 OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR ('00000101'B),
48 OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT ('00000110'B),
49
50 OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST ('00001000'B),
51 OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR ('00001001'B),
52 OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT ('00001010'B),
53
54 OSMO_GSUP_MSGT_AUTH_FAIL_REPORT ('00001011'B),
55
56 OSMO_GSUP_MSGT_PURGE_MS_REQUEST ('00001100'B),
57 OSMO_GSUP_MSGT_PURGE_MS_ERROR ('00001101'B),
58 OSMO_GSUP_MSGT_PURGE_MS_RESULT ('00001110'B),
59
60 OSMO_GSUP_MSGT_INSERT_DATA_REQUEST ('00010000'B),
61 OSMO_GSUP_MSGT_INSERT_DATA_ERROR ('00010001'B),
62 OSMO_GSUP_MSGT_INSERT_DATA_RESULT ('00010010'B),
63
64 OSMO_GSUP_MSGT_DELETE_DATA_REQUEST ('00010100'B),
65 OSMO_GSUP_MSGT_DELETE_DATA_ERROR ('00010101'B),
66 OSMO_GSUP_MSGT_DELETE_DATA_RESULT ('00010110'B),
67
68 OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST ('00011100'B),
69 OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR ('00011101'B),
70 OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT ('00011110'B)
71} with { variant "FIELDLENGTH(8)" };
72
73type enumerated GSUP_CancelType {
74 OSMO_GSUP_CANCEL_TYPE_UPDATE (1),
75 OSMO_GSUP_CANCEL_TYPE_WITHDRAW (2)
76} with { variant "FIELDLENGTH(8)" };
77
78type enumerated GSUP_CnDomain {
79 OSMO_GSUP_CN_DOMAIN_PS (1),
80 OSMO_GSUP_CN_DOMAIN_CS (2)
81} with { variant "FIELDLENGTH(8)" };
82
83type record GSUP_IE {
84 GSUP_IEI tag,
85 uint8_t len,
86 GSUP_IeValue val
87} with { variant (len) "LENGTHTO(val)"
88 variant (val) "CROSSTAG(imsi, tag = OSMO_GSUP_IMSI_IE;
89 cause, tag = OSMO_GSUP_CAUSE_IE;
90 cancel_type, tag = OSMO_GSUP_CANCEL_TYPE_IE;
91 auts, tag = OSMO_GSUP_AUTS_IE;
92 rand, tag = OSMO_GSUP_RAND_IE;
93 msisdn, tag = OSMO_GSUP_MSISDN_IE;
94 hlr_number, tag = OSMO_GSUP_HLR_NUMBER_IE;
95 cn_domain, tag = OSMO_GSUP_CN_DOMAIN_IE;
96 charg_char, tag = OSMO_GSUP_CHARG_CHAR_IE)"
97};
98
99type record of GSUP_IE GSUP_IEs;
100
101type union GSUP_IeValue {
102 hexstring imsi,
103 integer cause,
104 GSUP_CancelType cancel_type,
105 //boolean pdp_info_compl,
106 //boolean freeze_ptmsi,
107 GSUP_IEs pdp_info,
108 GSUP_IEs auth_tuple,
109 octetstring auts,
110 octetstring rand,
111 hexstring msisdn,
112 octetstring hlr_number,
113 GSUP_CnDomain cn_domain,
114 octetstring charg_char
115};
116
117type record GSUP_PDU {
118 GSUP_MessageType msg_type,
119 GSUP_IEs ies
120};
121
122external function enc_GSUP_PDU(in GSUP_PDU msg) return octetstring
123 with { extension "prototype(convert) encode(RAW)" };
124
125external function dec_GSUP_PDU(in octetstring msg) return GSUP_PDU
126 with { extension "prototype(convert) decode(RAW)" };
127
128
129template GSUP_PDU tr_GSUP(template GSUP_MessageType msgt := ?, template GSUP_IEs ies := *) := {
130 msg_type := msgt,
131 ies := ies
132}
133
134template GSUP_PDU ts_GSUP(GSUP_MessageType msgt, GSUP_IEs ies := {}) := {
135 msg_type := msgt,
136 ies := ies
137}
138
139template GSUP_PDU ts_GSUP_SAI_REQ(hexstring imsi) :=
140 ts_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, { valueof(ts_GSUP_IE_IMSI(imsi)) });
141
142template GSUP_PDU tr_GSUP_SAI_ERR(template hexstring imsi, template integer cause) :=
143 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
144 tr_GSUP_IE_IMSI(imsi), tr_GSUP_IE_Cause(cause) });
145
146template GSUP_PDU tr_GSUP_SAI_RES(template hexstring imsi) :=
147 tr_GSUP(OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST, {
148 tr_GSUP_IE_IMSI(imsi), *, tr_GSUP_IE(OSMO_GSUP_AUTH_TUPLE_IE), * });
149
Harald Weltedfe94dd2018-01-21 13:55:22 +0100150template GSUP_PDU tr_GSUP_UL_REQ(template hexstring imsi) :=
151 tr_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST, {
152 tr_GSUP_IE_IMSI(imsi), * });
153
154template GSUP_PDU ts_GSUP_UL_RES(hexstring imsi) :=
155 ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, { valueof(ts_GSUP_IE_IMSI(imsi)) });
156
157template GSUP_PDU tr_GSUP_ISD_REQ(template hexstring imsi) :=
158 tr_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, {
159 tr_GSUP_IE_IMSI(imsi), * });
Harald Weltedf327232017-12-28 22:51:51 +0100160
161
162template GSUP_IE tr_GSUP_IE(template GSUP_IEI iei, template GSUP_IeValue val := ?) := {
163 tag := iei,
164 len := ?,
165 val := val
166}
167
168template (value) GSUP_IE ts_GSUP_IE_IMSI(hexstring imsi) := {
169 tag := OSMO_GSUP_IMSI_IE,
170 len := 0, /* overwritten */
171 val := {
172 imsi := imsi
173 }
174}
175
176template GSUP_IE tr_GSUP_IE_IMSI(template hexstring imsi) := {
177 tag := OSMO_GSUP_IMSI_IE,
178 len := ?,
179 val := {
180 imsi := imsi
181 }
182}
183
184template (value) GSUP_IE ts_GSUP_IE_Cause(integer cause) := {
185 tag := OSMO_GSUP_CAUSE_IE,
186 len := 0, /* overwritten */
187 val := {
188 cause := cause
189 }
190}
191
192template GSUP_IE tr_GSUP_IE_Cause(template integer cause) := {
193 tag := OSMO_GSUP_CAUSE_IE,
194 len := ?,
195 val := {
196 cause := cause
197 }
198}
199
200template (value) GSUP_IE ts_GSUP_IE_AUTS(octetstring auts) := {
201 tag := OSMO_GSUP_AUTS_IE,
202 len := 0, /* overwritten */
203 val := {
204 auts := auts
205 }
206}
207
208template (value) GSUP_IE ts_GSUP_IE_RAND(octetstring rand) := {
209 tag := OSMO_GSUP_RAND_IE,
210 len := 0, /* overwritten */
211 val := {
212 rand := rand
213 }
214}
215
216
217
218
219} with { encode "RAW"; variant "FIELDORDER(msb)" }