Harald Welte | df32723 | 2017-12-28 22:51:51 +0100 | [diff] [blame] | 1 | module GSUP_Types { |
| 2 | |
Harald Welte | 35bb716 | 2018-01-03 21:07:52 +0100 | [diff] [blame] | 3 | /* 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 Welte | df32723 | 2017-12-28 22:51:51 +0100 | [diff] [blame] | 15 | import from General_Types all; |
| 16 | import from Osmocom_Types all; |
| 17 | |
| 18 | type 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 | |
| 45 | type 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 | |
| 73 | type enumerated GSUP_CancelType { |
| 74 | OSMO_GSUP_CANCEL_TYPE_UPDATE (1), |
| 75 | OSMO_GSUP_CANCEL_TYPE_WITHDRAW (2) |
| 76 | } with { variant "FIELDLENGTH(8)" }; |
| 77 | |
| 78 | type enumerated GSUP_CnDomain { |
| 79 | OSMO_GSUP_CN_DOMAIN_PS (1), |
| 80 | OSMO_GSUP_CN_DOMAIN_CS (2) |
| 81 | } with { variant "FIELDLENGTH(8)" }; |
| 82 | |
| 83 | type 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 | |
| 99 | type record of GSUP_IE GSUP_IEs; |
| 100 | |
| 101 | type 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 | |
| 117 | type record GSUP_PDU { |
| 118 | GSUP_MessageType msg_type, |
| 119 | GSUP_IEs ies |
| 120 | }; |
| 121 | |
| 122 | external function enc_GSUP_PDU(in GSUP_PDU msg) return octetstring |
| 123 | with { extension "prototype(convert) encode(RAW)" }; |
| 124 | |
| 125 | external function dec_GSUP_PDU(in octetstring msg) return GSUP_PDU |
| 126 | with { extension "prototype(convert) decode(RAW)" }; |
| 127 | |
| 128 | |
| 129 | template GSUP_PDU tr_GSUP(template GSUP_MessageType msgt := ?, template GSUP_IEs ies := *) := { |
| 130 | msg_type := msgt, |
| 131 | ies := ies |
| 132 | } |
| 133 | |
| 134 | template GSUP_PDU ts_GSUP(GSUP_MessageType msgt, GSUP_IEs ies := {}) := { |
| 135 | msg_type := msgt, |
| 136 | ies := ies |
| 137 | } |
| 138 | |
| 139 | template 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 | |
| 142 | template 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 | |
| 146 | template 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 Welte | dfe94dd | 2018-01-21 13:55:22 +0100 | [diff] [blame] | 150 | template 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 | |
| 154 | template GSUP_PDU ts_GSUP_UL_RES(hexstring imsi) := |
| 155 | ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT, { valueof(ts_GSUP_IE_IMSI(imsi)) }); |
| 156 | |
Harald Welte | 6ff8190 | 2018-01-21 19:09:08 +0100 | [diff] [blame] | 157 | template GSUP_PDU ts_GSUP_UL_ERR(hexstring imsi, integer cause) := |
| 158 | ts_GSUP(OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR, { |
| 159 | valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_Cause(cause)) }); |
| 160 | |
| 161 | template GSUP_PDU ts_GSUP_ISD_REQ(hexstring imsi, hexstring msisdn) := |
| 162 | ts_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_REQUEST, { |
| 163 | valueof(ts_GSUP_IE_IMSI(imsi)), valueof(ts_GSUP_IE_MSISDN(msisdn)) }); |
| 164 | |
| 165 | template GSUP_PDU tr_GSUP_ISD_RES(template hexstring imsi) := |
| 166 | tr_GSUP(OSMO_GSUP_MSGT_INSERT_DATA_RESULT, { |
Harald Welte | dfe94dd | 2018-01-21 13:55:22 +0100 | [diff] [blame] | 167 | tr_GSUP_IE_IMSI(imsi), * }); |
Harald Welte | df32723 | 2017-12-28 22:51:51 +0100 | [diff] [blame] | 168 | |
| 169 | |
| 170 | template GSUP_IE tr_GSUP_IE(template GSUP_IEI iei, template GSUP_IeValue val := ?) := { |
| 171 | tag := iei, |
| 172 | len := ?, |
| 173 | val := val |
| 174 | } |
| 175 | |
| 176 | template (value) GSUP_IE ts_GSUP_IE_IMSI(hexstring imsi) := { |
| 177 | tag := OSMO_GSUP_IMSI_IE, |
| 178 | len := 0, /* overwritten */ |
| 179 | val := { |
| 180 | imsi := imsi |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | template GSUP_IE tr_GSUP_IE_IMSI(template hexstring imsi) := { |
| 185 | tag := OSMO_GSUP_IMSI_IE, |
| 186 | len := ?, |
| 187 | val := { |
| 188 | imsi := imsi |
| 189 | } |
| 190 | } |
| 191 | |
Harald Welte | 6ff8190 | 2018-01-21 19:09:08 +0100 | [diff] [blame] | 192 | template (value) GSUP_IE ts_GSUP_IE_MSISDN(hexstring msisdn) := { |
| 193 | tag := OSMO_GSUP_MSISDN_IE, |
| 194 | len := 0, /* overwritten */ |
| 195 | val := { |
| 196 | msisdn := msisdn |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | template GSUP_IE tr_GSUP_IE_MSISDN(template hexstring msisdn) := { |
| 201 | tag := OSMO_GSUP_MSISDN_IE, |
| 202 | len := ?, |
| 203 | val := { |
| 204 | msisdn := msisdn |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | |
Harald Welte | df32723 | 2017-12-28 22:51:51 +0100 | [diff] [blame] | 209 | template (value) GSUP_IE ts_GSUP_IE_Cause(integer cause) := { |
| 210 | tag := OSMO_GSUP_CAUSE_IE, |
| 211 | len := 0, /* overwritten */ |
| 212 | val := { |
| 213 | cause := cause |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | template GSUP_IE tr_GSUP_IE_Cause(template integer cause) := { |
| 218 | tag := OSMO_GSUP_CAUSE_IE, |
| 219 | len := ?, |
| 220 | val := { |
| 221 | cause := cause |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | template (value) GSUP_IE ts_GSUP_IE_AUTS(octetstring auts) := { |
| 226 | tag := OSMO_GSUP_AUTS_IE, |
| 227 | len := 0, /* overwritten */ |
| 228 | val := { |
| 229 | auts := auts |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | template (value) GSUP_IE ts_GSUP_IE_RAND(octetstring rand) := { |
| 234 | tag := OSMO_GSUP_RAND_IE, |
| 235 | len := 0, /* overwritten */ |
| 236 | val := { |
| 237 | rand := rand |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | } with { encode "RAW"; variant "FIELDORDER(msb)" } |