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