blob: 43da27ee5c8877f2dfff497f251579b6e194c77a [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file gsm_04_08_gprs.c */
2/*
3 * (C) 2009-2016 by Harald Welte <laforge@gnumonks.org>
Harald Welte64f38c02016-04-20 17:12:24 +02004 * (C) 2010 by On-Waves
5 * (C) 2014-2015 by Sysmocom s.f.m.c. GmbH
6 *
7 * All Rights Reserved
8 *
9 * This program is free software; you can redistribute it and/or modify
Harald Welte5e5954d2016-12-22 14:57:13 +010010 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
Harald Welte64f38c02016-04-20 17:12:24 +020012 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte5e5954d2016-12-22 14:57:13 +010017 * GNU General Public License for more details.
Harald Welte64f38c02016-04-20 17:12:24 +020018 *
Harald Welte5e5954d2016-12-22 14:57:13 +010019 * You should have received a copy of the GNU General Public License
Harald Welte64f38c02016-04-20 17:12:24 +020020 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 *
22 */
23
24
25#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
Maxa337b9c2016-06-27 15:51:34 +020026#include <osmocom/crypt/gprs_cipher.h>
Harald Welte64f38c02016-04-20 17:12:24 +020027#include <osmocom/core/utils.h>
28
Maxa337b9c2016-06-27 15:51:34 +020029#include <stdbool.h>
30
Harald Welte96e2a002017-06-12 21:44:18 +020031/*! \addtogroup gsm0408
32 * @{
33 */
Harald Welte64f38c02016-04-20 17:12:24 +020034
Neels Hofmeyr87e45502017-06-20 00:17:59 +020035/*! 10.5.5.14 GPRS MM Cause / Table 10.5.147 */
Harald Welte64f38c02016-04-20 17:12:24 +020036const struct value_string gsm48_gmm_cause_names_[] = {
37 { GMM_CAUSE_IMSI_UNKNOWN, "IMSI unknown in HLR" },
38 { GMM_CAUSE_ILLEGAL_MS, "Illegal MS" },
Harald Welte82f94ef2016-05-05 23:33:27 +020039 { GMM_CAUSE_IMEI_NOT_ACCEPTED, "IMEI not accepted" },
Harald Welte64f38c02016-04-20 17:12:24 +020040 { GMM_CAUSE_ILLEGAL_ME, "Illegal ME" },
41 { GMM_CAUSE_GPRS_NOTALLOWED, "GPRS services not allowed" },
42 { GMM_CAUSE_GPRS_OTHER_NOTALLOWED,
43 "GPRS services and non-GPRS services not allowed" },
44 { GMM_CAUSE_MS_ID_NOT_DERIVED,
45 "MS identity cannot be derived by the network" },
46 { GMM_CAUSE_IMPL_DETACHED, "Implicitly detached" },
47 { GMM_CAUSE_PLMN_NOTALLOWED, "PLMN not allowed" },
48 { GMM_CAUSE_LA_NOTALLOWED, "Location Area not allowed" },
49 { GMM_CAUSE_ROAMING_NOTALLOWED,
50 "Roaming not allowed in this location area" },
51 { GMM_CAUSE_NO_GPRS_PLMN,
52 "GPRS services not allowed in this PLMN" },
Harald Welte82f94ef2016-05-05 23:33:27 +020053 { GMM_CAUSE_NO_SUIT_CELL_IN_LA, "No suitable cell in LA" },
Harald Welte64f38c02016-04-20 17:12:24 +020054 { GMM_CAUSE_MSC_TEMP_NOTREACH, "MSC temporarily not reachable" },
55 { GMM_CAUSE_NET_FAIL, "Network failure" },
Harald Welte82f94ef2016-05-05 23:33:27 +020056 { GMM_CAUSE_MAC_FAIL, "MAC failure" },
57 { GMM_CAUSE_SYNC_FAIL, "SYNC failure" },
Harald Welte64f38c02016-04-20 17:12:24 +020058 { GMM_CAUSE_CONGESTION, "Congestion" },
Harald Welte82f94ef2016-05-05 23:33:27 +020059 { GMM_CAUSE_GSM_AUTH_UNACCEPT, "GSM authentication unacceptable" },
60 { GMM_CAUSE_NOT_AUTH_FOR_CSG, "Not authorized for this CSG" },
61 { GMM_CAUSE_SMS_VIA_GPRS_IN_RA, "SMS provided via GPRS in this RA" },
62 { GMM_CAUSE_NO_PDP_ACTIVATED, "No PDP context activated" },
Harald Welte64f38c02016-04-20 17:12:24 +020063 { GMM_CAUSE_SEM_INCORR_MSG, "Semantically incorrect message" },
64 { GMM_CAUSE_INV_MAND_INFO, "Invalid mandatory information" },
65 { GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL,
66 "Message type non-existant or not implemented" },
67 { GMM_CAUSE_MSGT_INCOMP_P_STATE,
68 "Message type not compatible with protocol state" },
69 { GMM_CAUSE_IE_NOTEXIST_NOTIMPL,
70 "Information element non-existent or not implemented" },
71 { GMM_CAUSE_COND_IE_ERR, "Conditional IE error" },
72 { GMM_CAUSE_MSG_INCOMP_P_STATE,
73 "Message not compatible with protocol state " },
74 { GMM_CAUSE_PROTO_ERR_UNSPEC, "Protocol error, unspecified" },
75 { 0, NULL }
76};
77
78const struct value_string *gsm48_gmm_cause_names = gsm48_gmm_cause_names_;
79
Neels Hofmeyr87e45502017-06-20 00:17:59 +020080/*! 10.5.6.6 SM Cause / Table 10.5.157 */
Harald Welte64f38c02016-04-20 17:12:24 +020081const struct value_string gsm48_gsm_cause_names_[] = {
Daniel Willmann6959e3c2017-05-12 11:20:53 +020082 { GSM_CAUSE_OPER_DET_BARR, "Operator Determined Barring" },
83 { GSM_CAUSE_MBMS_CAP_INSUF, "MBMS bearer capabilities insufficient for the service" },
84 { GSM_CAUSE_LLC_SNDCP_FAIL, "LLC or SNDCP failure" },
Harald Welte64f38c02016-04-20 17:12:24 +020085 { GSM_CAUSE_INSUFF_RSRC, "Insufficient resources" },
86 { GSM_CAUSE_MISSING_APN, "Missing or unknown APN" },
87 { GSM_CAUSE_UNKNOWN_PDP, "Unknown PDP address or PDP type" },
88 { GSM_CAUSE_AUTH_FAILED, "User Authentication failed" },
89 { GSM_CAUSE_ACT_REJ_GGSN, "Activation rejected by GGSN" },
90 { GSM_CAUSE_ACT_REJ_UNSPEC, "Activation rejected, unspecified" },
91 { GSM_CAUSE_SERV_OPT_NOTSUPP, "Service option not supported" },
92 { GSM_CAUSE_REQ_SERV_OPT_NOTSUB,
93 "Requested service option not subscribed" },
94 { GSM_CAUSE_SERV_OPT_TEMP_OOO,
95 "Service option temporarily out of order" },
96 { GSM_CAUSE_NSAPI_IN_USE, "NSAPI already used" },
97 { GSM_CAUSE_DEACT_REGULAR, "Regular deactivation" },
98 { GSM_CAUSE_QOS_NOT_ACCEPTED, "QoS not accepted" },
99 { GSM_CAUSE_NET_FAIL, "Network Failure" },
100 { GSM_CAUSE_REACT_RQD, "Reactivation required" },
101 { GSM_CAUSE_FEATURE_NOTSUPP, "Feature not supported " },
102 { GSM_CAUSE_INVALID_TRANS_ID, "Invalid transaction identifier" },
103 { GSM_CAUSE_SEM_INCORR_MSG, "Semantically incorrect message" },
104 { GSM_CAUSE_INV_MAND_INFO, "Invalid mandatory information" },
105 { GSM_CAUSE_MSGT_NOTEXIST_NOTIMPL,
106 "Message type non-existant or not implemented" },
107 { GSM_CAUSE_MSGT_INCOMP_P_STATE,
108 "Message type not compatible with protocol state" },
109 { GSM_CAUSE_IE_NOTEXIST_NOTIMPL,
110 "Information element non-existent or not implemented" },
111 { GSM_CAUSE_COND_IE_ERR, "Conditional IE error" },
112 { GSM_CAUSE_MSG_INCOMP_P_STATE,
113 "Message not compatible with protocol state " },
114 { GSM_CAUSE_PROTO_ERR_UNSPEC, "Protocol error, unspecified" },
115 { 0, NULL }
116};
117
118const struct value_string *gsm48_gsm_cause_names = gsm48_gsm_cause_names_;
119
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200120/*! Check if MS supports particular version of GEA by inspecting
Maxa337b9c2016-06-27 15:51:34 +0200121 * MS network capability IE specified in 3GPP TS 24.008
122 * \param[in] ms_net_cap Buffer with raw MS network capability IE value,
123 * 3 - 10 bytes
124 * \param[in] cap_len Length of ms_net_cap, in bytes
125 * \param[in] gea Version of GEA to check
126 * \returns true if given version is supported by MS, false otherwise
127 */
128bool gprs_ms_net_cap_gea_supported(const uint8_t *ms_net_cap, uint8_t cap_len,
129 enum gprs_ciph_algo gea)
130{
131 switch (gea) {
132 case GPRS_ALGO_GEA0:
133 return true;
134 case GPRS_ALGO_GEA1: /* 1st bit is GEA1: */
135 return 0x80 & ms_net_cap[0];
136 case GPRS_ALGO_GEA2: /* extended GEA bits start from 2nd bit */
137 return 0x40 & ms_net_cap[1]; /* of the next byte */
138 case GPRS_ALGO_GEA3:
139 return 0x20 & ms_net_cap[1];
140 case GPRS_ALGO_GEA4:
141 return 0x10 & ms_net_cap[1];
142 default:
143 return false;
144 }
145}
146
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200147/*! String names of GMM message types */
Maxf5f773f2016-07-05 19:17:19 +0200148const struct value_string gprs_msgt_gmm_names[] = {
149 { GSM48_MT_GMM_ATTACH_REQ, "ATTACH REQUEST" },
150 { GSM48_MT_GMM_ATTACH_ACK, "ATTACH ACK" },
151 { GSM48_MT_GMM_ATTACH_COMPL, "ATTACH COMPLETE" },
152 { GSM48_MT_GMM_ATTACH_REJ, "ATTACH REJECT" },
153 { GSM48_MT_GMM_DETACH_REQ, "DETACH REQUEST" },
154 { GSM48_MT_GMM_DETACH_ACK, "DETACH ACK" },
155 { GSM48_MT_GMM_RA_UPD_REQ, "RA UPDATE REQUEST" },
156 { GSM48_MT_GMM_RA_UPD_ACK, "RA UPDATE ACK" },
157 { GSM48_MT_GMM_RA_UPD_COMPL, "RA UPDATE COMPLETE" },
158 { GSM48_MT_GMM_RA_UPD_REJ, "RA UPDATE REJECT" },
159 { GSM48_MT_GMM_PTMSI_REALL_CMD, "PTMSI REALLOC CMD" },
160 { GSM48_MT_GMM_PTMSI_REALL_COMPL, "PTMSI REALLOC COMPLETE" },
161 { GSM48_MT_GMM_AUTH_CIPH_REQ, "AUTH & CIPHER REQUEST" },
162 { GSM48_MT_GMM_AUTH_CIPH_RESP, "AUTH & CIPHER RESPONSE" },
163 { GSM48_MT_GMM_AUTH_CIPH_REJ, "AUTH & CIPHER REJECT" },
164 { GSM48_MT_GMM_AUTH_CIPH_FAIL, "AUTH & CIPHER FAILURE" },
165 { GSM48_MT_GMM_ID_REQ, "IDENTITY REQUEST" },
166 { GSM48_MT_GMM_ID_RESP, "IDENTITY RESPONSE" },
167 { GSM48_MT_GMM_STATUS, "STATUS" },
168 { GSM48_MT_GMM_INFO, "INFO" },
169 { 0, NULL }
170};
171
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200172/*! String names of GPRS Attach types according to 10.5.5.2 */
Harald Welte64f38c02016-04-20 17:12:24 +0200173const struct value_string gprs_att_t_strs_[] = {
174 { GPRS_ATT_T_ATTACH, "GPRS attach" },
175 { GPRS_ATT_T_ATT_WHILE_IMSI, "GPRS attach while IMSI attached" },
176 { GPRS_ATT_T_COMBINED, "Combined GPRS/IMSI attach" },
177 { 0, NULL }
178};
179
180const struct value_string *gprs_att_t_strs = gprs_att_t_strs_;
181
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200182/*! String names of GPRS Location Update Types */
Harald Welte64f38c02016-04-20 17:12:24 +0200183const struct value_string gprs_upd_t_strs_[] = {
184 { GPRS_UPD_T_RA, "RA updating" },
185 { GPRS_UPD_T_RA_LA, "combined RA/LA updating" },
186 { GPRS_UPD_T_RA_LA_IMSI_ATT, "combined RA/LA updating + IMSI attach" },
187 { GPRS_UPD_T_PERIODIC, "periodic updating" },
188 { 0, NULL }
189};
190
191const struct value_string *gprs_upd_t_strs = gprs_upd_t_strs_;
192
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200193/*! String names of GMM MO Detach Types according to 10.5.5.5 */
Harald Welte64f38c02016-04-20 17:12:24 +0200194const struct value_string gprs_det_t_mo_strs_[] = {
195 { GPRS_DET_T_MO_GPRS, "GPRS detach" },
196 { GPRS_DET_T_MO_IMSI, "IMSI detach" },
197 { GPRS_DET_T_MO_COMBINED, "Combined GPRS/IMSI detach" },
198 { 0, NULL }
199};
200
201const struct value_string *gprs_det_t_mo_strs = gprs_det_t_mo_strs_;
202
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200203/*! String names of GMM MT Detach Types according to 10.5.5.5 */
Harald Welte64f38c02016-04-20 17:12:24 +0200204const struct value_string gprs_det_t_mt_strs_[] = {
205 { GPRS_DET_T_MT_REATT_REQ, "re-attach required" },
206 { GPRS_DET_T_MT_REATT_NOTREQ, "re-attach not required" },
207 { GPRS_DET_T_MT_IMSI, "IMSI detach (after VLR failure)" },
208 { 0, NULL }
209};
210
211const struct value_string *gprs_det_t_mt_strs = gprs_det_t_mt_strs_;
Neels Hofmeyr0318f6b2016-08-29 13:18:56 +0200212
Neels Hofmeyr87e45502017-06-20 00:17:59 +0200213/*! String names of GMM Service Types */
Neels Hofmeyr0318f6b2016-08-29 13:18:56 +0200214const struct value_string gprs_service_t_strs_[] = {
215 { GPRS_SERVICE_T_SIGNALLING, "signalling" },
216 { GPRS_SERVICE_T_DATA, "data" },
217 { GPRS_SERVICE_T_PAGING_RESP, "paging response" },
218 { GPRS_SERVICE_T_MBMS_MC_SERV, "MBMS multicast service" },
219 { GPRS_SERVICE_T_MBMS_BC_SERV, "MBMS broadcast service" },
220 { 0, NULL }
221};
222
223const struct value_string *gprs_service_t_strs = gprs_service_t_strs_;
Harald Welte96e2a002017-06-12 21:44:18 +0200224
225/*! @} */