blob: 3467293bed2896532dc4ac3ff6e58afb237553a2 [file] [log] [blame]
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +01001/* MS subscriber data handling */
2
3/* (C) 2014 by sysmocom s.f.m.c. GmbH
Holger Hans Peter Freyther9ba273d2015-04-23 09:53:53 -04004 * (C) 2015 by Holger Hans Peter Freyther
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +01005 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#include <openbsc/gsm_subscriber.h>
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010024#include <openbsc/gprs_gsup_client.h>
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +010025
26#include <openbsc/sgsn.h>
27#include <openbsc/gprs_sgsn.h>
28#include <openbsc/gprs_gmm.h>
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +010029#include <openbsc/gprs_gsup_messages.h>
Jacob Erlbeck0e8add62014-12-17 14:03:35 +010030#include <openbsc/gprs_utils.h>
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +010031
32#include <openbsc/debug.h>
33
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010034#include <netinet/in.h>
35#include <arpa/inet.h>
36
Jacob Erlbeck743dec42015-01-08 15:18:39 +010037#define SGSN_SUBSCR_MAX_RETRIES 3
38#define SGSN_SUBSCR_RETRY_INTERVAL 10
39
Jacob Erlbeck929acdf2015-01-27 13:47:24 +010040#define LOGGSUPP(level, gsup, fmt, args...) \
41 LOGP(DGPRS, level, "GSUP(%s) " fmt, \
42 (gsup)->imsi, \
43 ## args)
44
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +010045extern void *tall_bsc_ctx;
46
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010047static int gsup_read_cb(struct gprs_gsup_client *gsupc, struct msgb *msg);
48
49/* TODO: Some functions are specific to the SGSN, but this file is more general
50 * (it has gprs_* name). Either move these functions elsewhere, split them and
51 * move a part, or replace the gprs_ prefix by sgsn_. The applies to
52 * gprs_subscr_init, gsup_read_cb, and gprs_subscr_tx_gsup_message.
53 */
54
55int gprs_subscr_init(struct sgsn_instance *sgi)
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +010056{
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010057 const char *addr_str;
58
59 if (!sgi->cfg.gsup_server_addr.sin_addr.s_addr)
60 return 0;
61
62 addr_str = inet_ntoa(sgi->cfg.gsup_server_addr.sin_addr);
63
64 sgi->gsup_client = gprs_gsup_client_create(
65 addr_str, sgi->cfg.gsup_server_port,
Neels Hofmeyr9c534fd2015-10-12 11:57:37 +020066 &gsup_read_cb,
67 &sgi->cfg.oap);
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010068
69 if (!sgi->gsup_client)
70 return -1;
71
72 return 1;
73}
74
75static int gsup_read_cb(struct gprs_gsup_client *gsupc, struct msgb *msg)
76{
77 int rc;
78
79 rc = gprs_subscr_rx_gsup_message(msg);
Jacob Erlbecke154d8b2014-12-19 19:15:55 +010080 msgb_free(msg);
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010081 if (rc < 0)
82 return -1;
83
84 return rc;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +010085}
86
Jacob Erlbeck0f47b8f2015-01-06 16:32:41 +010087int gprs_subscr_purge(struct gsm_subscriber *subscr);
88
Jacob Erlbecka1e03732014-12-02 11:28:38 +010089static struct sgsn_subscriber_data *sgsn_subscriber_data_alloc(void *ctx)
90{
91 struct sgsn_subscriber_data *sdata;
Jacob Erlbeck7921ab12014-12-08 15:52:00 +010092 int idx;
Jacob Erlbecka1e03732014-12-02 11:28:38 +010093
94 sdata = talloc_zero(ctx, struct sgsn_subscriber_data);
95
Jacob Erlbeckd6267d12015-01-19 11:10:04 +010096 sdata->error_cause = SGSN_ERROR_CAUSE_NONE;
97
Jacob Erlbeck7921ab12014-12-08 15:52:00 +010098 for (idx = 0; idx < ARRAY_SIZE(sdata->auth_triplets); idx++)
99 sdata->auth_triplets[idx].key_seq = GSM_KEY_SEQ_INVAL;
100
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100101 INIT_LLIST_HEAD(&sdata->pdp_list);
102
Jacob Erlbecka1e03732014-12-02 11:28:38 +0100103 return sdata;
104}
105
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100106struct sgsn_subscriber_pdp_data* sgsn_subscriber_pdp_data_alloc(
107 struct sgsn_subscriber_data *sdata)
108{
109 struct sgsn_subscriber_pdp_data* pdata;
110
111 pdata = talloc_zero(sdata, struct sgsn_subscriber_pdp_data);
112
113 llist_add_tail(&pdata->list, &sdata->pdp_list);
114
115 return pdata;
116}
117
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100118struct gsm_subscriber *gprs_subscr_get_or_create(const char *imsi)
119{
120 struct gsm_subscriber *subscr;
121
122 subscr = subscr_get_or_create(NULL, imsi);
123 if (!subscr)
124 return NULL;
125
Jacob Erlbecka1e03732014-12-02 11:28:38 +0100126 if (!subscr->sgsn_data)
127 subscr->sgsn_data = sgsn_subscriber_data_alloc(subscr);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100128 return subscr;
129}
130
131struct gsm_subscriber *gprs_subscr_get_by_imsi(const char *imsi)
132{
133 return subscr_active_by_imsi(NULL, imsi);
134}
135
Jacob Erlbeck3e4e58f2015-01-26 11:07:24 +0100136void gprs_subscr_cleanup(struct gsm_subscriber *subscr)
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100137{
Jacob Erlbecka1e03732014-12-02 11:28:38 +0100138 if (subscr->sgsn_data->mm) {
139 subscr_put(subscr->sgsn_data->mm->subscr);
140 subscr->sgsn_data->mm->subscr = NULL;
141 subscr->sgsn_data->mm = NULL;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100142 }
143
Holger Hans Peter Freyther1d778fd2015-01-20 21:14:03 +0100144 if (subscr->flags & GPRS_SUBSCRIBER_ENABLE_PURGE) {
145 gprs_subscr_purge(subscr);
146 subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE;
Jacob Erlbeck0f47b8f2015-01-06 16:32:41 +0100147 }
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100148}
149
Jacob Erlbeck37139e52015-01-23 13:52:55 +0100150void gprs_subscr_cancel(struct gsm_subscriber *subscr)
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100151{
152 subscr->authorized = 0;
153 subscr->flags |= GPRS_SUBSCRIBER_CANCELLED;
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100154 subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100155
156 gprs_subscr_update(subscr);
Jacob Erlbeck3e4e58f2015-01-26 11:07:24 +0100157 gprs_subscr_cleanup(subscr);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100158}
159
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100160static int gprs_subscr_tx_gsup_message(struct gsm_subscriber *subscr,
161 struct gprs_gsup_message *gsup_msg)
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100162{
Jacob Erlbeck39f040d2014-12-18 12:46:47 +0100163 struct msgb *msg = gprs_gsup_msgb_alloc();
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100164
Jacob Erlbeck9999fd92015-01-15 17:08:30 +0100165 if (strlen(gsup_msg->imsi) == 0 && subscr)
166 strncpy(gsup_msg->imsi, subscr->imsi, sizeof(gsup_msg->imsi) - 1);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100167
168 gprs_gsup_encode(msg, gsup_msg);
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100169
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100170 LOGGSUBSCRP(LOGL_INFO, subscr,
Jacob Erlbeck9999fd92015-01-15 17:08:30 +0100171 "Sending GSUP, will send: %s\n", msgb_hexdump(msg));
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100172
Jacob Erlbeck39f040d2014-12-18 12:46:47 +0100173 if (!sgsn->gsup_client) {
174 msgb_free(msg);
175 return -ENOTSUP;
176 }
177
178 return gprs_gsup_client_send(sgsn->gsup_client, msg);
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100179}
180
Jacob Erlbeck9999fd92015-01-15 17:08:30 +0100181static int gprs_subscr_tx_gsup_error_reply(struct gsm_subscriber *subscr,
182 struct gprs_gsup_message *gsup_orig,
183 enum gsm48_gmm_cause cause)
184{
185 struct gprs_gsup_message gsup_reply = {0};
186
187 strncpy(gsup_reply.imsi, gsup_orig->imsi, sizeof(gsup_reply.imsi) - 1);
188 gsup_reply.cause = cause;
189 gsup_reply.message_type =
190 GPRS_GSUP_TO_MSGT_ERROR(gsup_orig->message_type);
191
192 return gprs_subscr_tx_gsup_message(subscr, &gsup_reply);
193}
194
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100195static int gprs_subscr_handle_gsup_auth_res(struct gsm_subscriber *subscr,
196 struct gprs_gsup_message *gsup_msg)
197{
198 unsigned idx;
199 struct sgsn_subscriber_data *sdata = subscr->sgsn_data;
200
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100201 LOGGSUBSCRP(LOGL_INFO, subscr,
Holger Hans Peter Freyther8e6ecc92015-04-23 11:55:23 -0400202 "Got SendAuthenticationInfoResult, num_auth_tuples = %zu\n",
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100203 gsup_msg->num_auth_tuples);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100204
205 if (gsup_msg->num_auth_tuples > 0) {
206 memset(sdata->auth_triplets, 0, sizeof(sdata->auth_triplets));
207
208 for (idx = 0; idx < ARRAY_SIZE(sdata->auth_triplets); idx++)
209 sdata->auth_triplets[idx].key_seq = GSM_KEY_SEQ_INVAL;
210 }
211
212 for (idx = 0; idx < gsup_msg->num_auth_tuples; idx++) {
213 size_t key_seq = gsup_msg->auth_tuples[idx].key_seq;
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100214 LOGGSUBSCRP(LOGL_DEBUG, subscr,
Holger Hans Peter Freyther8e6ecc92015-04-23 11:55:23 -0400215 "Adding auth tuple, cksn = %zu\n", key_seq);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100216 if (key_seq >= ARRAY_SIZE(sdata->auth_triplets)) {
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100217 LOGGSUBSCRP(LOGL_NOTICE, subscr,
Holger Hans Peter Freyther8e6ecc92015-04-23 11:55:23 -0400218 "Skipping auth triplet with invalid cksn %zu\n",
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100219 key_seq);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100220 continue;
221 }
222 sdata->auth_triplets[key_seq] = gsup_msg->auth_tuples[idx];
223 }
224
225 sdata->auth_triplets_updated = 1;
Jacob Erlbeckd6267d12015-01-19 11:10:04 +0100226 sdata->error_cause = SGSN_ERROR_CAUSE_NONE;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100227
228 gprs_subscr_update_auth_info(subscr);
229
230 return 0;
231}
232
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100233static int gprs_subscr_pdp_data_clear(struct gsm_subscriber *subscr)
234{
235 struct sgsn_subscriber_pdp_data *pdp, *pdp2;
236 int count = 0;
237
238 llist_for_each_entry_safe(pdp, pdp2, &subscr->sgsn_data->pdp_list, list) {
239 llist_del(&pdp->list);
240 talloc_free(pdp);
241 count += 1;
242 }
243
244 return count;
245}
246
247static struct sgsn_subscriber_pdp_data *gprs_subscr_pdp_data_get_by_id(
248 struct gsm_subscriber *subscr, unsigned context_id)
249{
250 struct sgsn_subscriber_pdp_data *pdp;
251
252 llist_for_each_entry(pdp, &subscr->sgsn_data->pdp_list, list) {
253 if (pdp->context_id == context_id)
254 return pdp;
255 }
256
257 return NULL;
258}
259
260
261static void gprs_subscr_gsup_insert_data(struct gsm_subscriber *subscr,
262 struct gprs_gsup_message *gsup_msg)
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100263{
Holger Hans Peter Freyther9ba273d2015-04-23 09:53:53 -0400264 struct sgsn_subscriber_data *sdata = subscr->sgsn_data;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100265 unsigned idx;
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100266 int rc;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100267
Holger Hans Peter Freyther9ba273d2015-04-23 09:53:53 -0400268 if (gsup_msg->msisdn_enc) {
269 if (gsup_msg->msisdn_enc_len > sizeof(sdata->msisdn)) {
270 LOGP(DGPRS, LOGL_ERROR, "MSISDN too long (%zu)\n",
271 gsup_msg->msisdn_enc_len);
272 sdata->msisdn_len = 0;
273 } else {
274 memcpy(sdata->msisdn, gsup_msg->msisdn_enc,
275 gsup_msg->msisdn_enc_len);
276 sdata->msisdn_len = gsup_msg->msisdn_enc_len;
277 }
278 }
279
Holger Hans Peter Freyther10c0f562015-05-17 20:58:40 +0200280 if (gsup_msg->hlr_enc) {
281 if (gsup_msg->hlr_enc_len > sizeof(sdata->hlr)) {
282 LOGP(DGPRS, LOGL_ERROR, "HLR-Number too long (%zu)\n",
283 gsup_msg->hlr_enc_len);
284 sdata->hlr_len = 0;
285 } else {
286 memcpy(sdata->hlr, gsup_msg->hlr_enc,
287 gsup_msg->hlr_enc_len);
288 sdata->hlr_len = gsup_msg->hlr_enc_len;
289 }
290 }
291
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100292 if (gsup_msg->pdp_info_compl) {
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100293 rc = gprs_subscr_pdp_data_clear(subscr);
294 if (rc > 0)
295 LOGP(DGPRS, LOGL_INFO, "Cleared existing PDP info\n");
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100296 }
297
298 for (idx = 0; idx < gsup_msg->num_pdp_infos; idx++) {
299 struct gprs_gsup_pdp_info *pdp_info = &gsup_msg->pdp_infos[idx];
300 size_t ctx_id = pdp_info->context_id;
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100301 struct sgsn_subscriber_pdp_data *pdp_data;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100302
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100303 if (pdp_info->apn_enc_len >= sizeof(pdp_data->apn_str)-1) {
304 LOGGSUBSCRP(LOGL_ERROR, subscr,
Holger Hans Peter Freyther8e6ecc92015-04-23 11:55:23 -0400305 "APN too long, context id = %zu, APN = %s\n",
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100306 ctx_id, osmo_hexdump(pdp_info->apn_enc,
307 pdp_info->apn_enc_len));
308 continue;
309 }
310
Holger Hans Peter Freyther8cedded2015-04-23 11:33:35 -0400311 if (pdp_info->qos_enc_len > sizeof(pdp_data->qos_subscribed)) {
312 LOGGSUBSCRP(LOGL_ERROR, subscr,
313 "QoS info too long (%zu)\n",
314 pdp_info->qos_enc_len);
315 continue;
316 }
317
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100318 LOGGSUBSCRP(LOGL_INFO, subscr,
Holger Hans Peter Freyther8e6ecc92015-04-23 11:55:23 -0400319 "Will set PDP info, context id = %zu, APN = %s\n",
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100320 ctx_id, osmo_hexdump(pdp_info->apn_enc, pdp_info->apn_enc_len));
321
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100322 /* Set PDP info [ctx_id] */
323 pdp_data = gprs_subscr_pdp_data_get_by_id(subscr, ctx_id);
324 if (!pdp_data) {
325 pdp_data = sgsn_subscriber_pdp_data_alloc(subscr->sgsn_data);
326 pdp_data->context_id = ctx_id;
327 }
328
329 OSMO_ASSERT(pdp_data != NULL);
330 pdp_data->pdp_type = pdp_info->pdp_type;
331 gprs_apn_to_str(pdp_data->apn_str,
332 pdp_info->apn_enc, pdp_info->apn_enc_len);
Holger Hans Peter Freyther8cedded2015-04-23 11:33:35 -0400333 memcpy(pdp_data->qos_subscribed, pdp_info->qos_enc, pdp_info->qos_enc_len);
334 pdp_data->qos_subscribed_len = pdp_info->qos_enc_len;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100335 }
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100336}
337
338static int gprs_subscr_handle_gsup_upd_loc_res(struct gsm_subscriber *subscr,
339 struct gprs_gsup_message *gsup_msg)
340{
341 gprs_subscr_gsup_insert_data(subscr, gsup_msg);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100342
343 subscr->authorized = 1;
Jacob Erlbeckd6267d12015-01-19 11:10:04 +0100344 subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100345
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100346 subscr->flags |= GPRS_SUBSCRIBER_ENABLE_PURGE;
347
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100348 gprs_subscr_update(subscr);
349 return 0;
350}
351
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100352static int check_cause(int cause)
353{
354 switch (cause) {
355 case GMM_CAUSE_IMSI_UNKNOWN ... GMM_CAUSE_ILLEGAL_ME:
356 case GMM_CAUSE_GPRS_NOTALLOWED ... GMM_CAUSE_NO_GPRS_PLMN:
357 return EACCES;
358
359 case GMM_CAUSE_MSC_TEMP_NOTREACH ... GMM_CAUSE_CONGESTION:
Jacob Erlbeckf06fe292015-01-05 16:20:47 +0100360 return EHOSTUNREACH;
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100361
362 case GMM_CAUSE_SEM_INCORR_MSG ... GMM_CAUSE_PROTO_ERR_UNSPEC:
363 default:
364 return EINVAL;
365 }
366}
367
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100368static int gprs_subscr_handle_gsup_auth_err(struct gsm_subscriber *subscr,
369 struct gprs_gsup_message *gsup_msg)
370{
371 unsigned idx;
372 struct sgsn_subscriber_data *sdata = subscr->sgsn_data;
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100373 int cause_err;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100374
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100375 cause_err = check_cause(gsup_msg->cause);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100376
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100377 LOGGSUBSCRP(LOGL_DEBUG, subscr,
378 "Send authentication info has failed with cause %d, "
379 "handled as: %s\n",
380 gsup_msg->cause, strerror(cause_err));
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100381
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100382 switch (cause_err) {
383 case EACCES:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100384 LOGGSUBSCRP(LOGL_NOTICE, subscr,
385 "GPRS send auth info req failed, access denied, "
386 "GMM cause = '%s' (%d)\n",
387 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
388 gsup_msg->cause);
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100389 /* Clear auth tuples */
390 memset(sdata->auth_triplets, 0, sizeof(sdata->auth_triplets));
391 for (idx = 0; idx < ARRAY_SIZE(sdata->auth_triplets); idx++)
392 sdata->auth_triplets[idx].key_seq = GSM_KEY_SEQ_INVAL;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100393
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100394 subscr->authorized = 0;
395 sdata->error_cause = gsup_msg->cause;
396 gprs_subscr_update_auth_info(subscr);
397 break;
398
Jacob Erlbeckf06fe292015-01-05 16:20:47 +0100399 case EHOSTUNREACH:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100400 LOGGSUBSCRP(LOGL_NOTICE, subscr,
401 "GPRS send auth info req failed, GMM cause = '%s' (%d)\n",
402 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
403 gsup_msg->cause);
Jacob Erlbeckf06fe292015-01-05 16:20:47 +0100404
405 sdata->error_cause = gsup_msg->cause;
406 gprs_subscr_update_auth_info(subscr);
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100407 break;
408
409 default:
410 case EINVAL:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100411 LOGGSUBSCRP(LOGL_ERROR, subscr,
412 "GSUP protocol remote error, GMM cause = '%s' (%d)\n",
413 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
414 gsup_msg->cause);
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100415 break;
416 }
417
418 return -gsup_msg->cause;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100419}
420
421static int gprs_subscr_handle_gsup_upd_loc_err(struct gsm_subscriber *subscr,
422 struct gprs_gsup_message *gsup_msg)
423{
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100424 int cause_err;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100425
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100426 cause_err = check_cause(gsup_msg->cause);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100427
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100428 LOGGSUBSCRP(LOGL_DEBUG, subscr,
429 "Update location has failed with cause %d, handled as: %s\n",
430 gsup_msg->cause, strerror(cause_err));
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100431
432 switch (cause_err) {
433 case EACCES:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100434 LOGGSUBSCRP(LOGL_NOTICE, subscr,
435 "GPRS update location failed, access denied, "
436 "GMM cause = '%s' (%d)\n",
437 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
438 gsup_msg->cause);
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100439
440 subscr->authorized = 0;
441 subscr->sgsn_data->error_cause = gsup_msg->cause;
442 gprs_subscr_update_auth_info(subscr);
443 break;
444
Jacob Erlbeckf06fe292015-01-05 16:20:47 +0100445 case EHOSTUNREACH:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100446 LOGGSUBSCRP(LOGL_NOTICE, subscr,
447 "GPRS update location failed, GMM cause = '%s' (%d)\n",
448 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
449 gsup_msg->cause);
Jacob Erlbeckf06fe292015-01-05 16:20:47 +0100450
451 subscr->sgsn_data->error_cause = gsup_msg->cause;
452 gprs_subscr_update_auth_info(subscr);
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100453 break;
454
455 default:
456 case EINVAL:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100457 LOGGSUBSCRP(LOGL_ERROR, subscr,
458 "GSUP protocol remote error, GMM cause = '%s' (%d)\n",
459 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
460 gsup_msg->cause);
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100461 break;
462 }
463
464 return -gsup_msg->cause;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100465}
466
Jacob Erlbeck929acdf2015-01-27 13:47:24 +0100467static int gprs_subscr_handle_gsup_purge_no_subscr(
468 struct gprs_gsup_message *gsup_msg)
469{
470 if (GPRS_GSUP_IS_MSGT_ERROR(gsup_msg->message_type)) {
471 LOGGSUPP(LOGL_NOTICE, gsup_msg,
472 "Purge MS has failed with cause '%s' (%d)\n",
473 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
474 gsup_msg->cause);
475 return -gsup_msg->cause;
476 }
477
478 LOGGSUPP(LOGL_INFO, gsup_msg, "Completing purge MS\n");
479 return 0;
480}
481
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100482static int gprs_subscr_handle_gsup_purge_res(struct gsm_subscriber *subscr,
483 struct gprs_gsup_message *gsup_msg)
484{
485 LOGGSUBSCRP(LOGL_INFO, subscr, "Completing purge MS\n");
486
487 /* Force silent cancellation */
Jacob Erlbeckd6267d12015-01-19 11:10:04 +0100488 subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE;
Jacob Erlbeck37139e52015-01-23 13:52:55 +0100489 gprs_subscr_cancel(subscr);
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100490
491 return 0;
492}
493
494static int gprs_subscr_handle_gsup_purge_err(struct gsm_subscriber *subscr,
495 struct gprs_gsup_message *gsup_msg)
496{
497 LOGGSUBSCRP(LOGL_NOTICE, subscr,
498 "Purge MS has failed with cause '%s' (%d)\n",
499 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
500 gsup_msg->cause);
501
502 /* In GSM 09.02, 19.1.4.4, the text and the SDL diagram imply that
503 * the subscriber data is not removed if the request has failed. On the
504 * other hand, keeping the subscriber data in either error case
505 * (subscriber unknown, syntactical message error, connection error)
506 * doesn't seem to give any advantage, since the data will be restored
507 * on the next Attach Request anyway.
508 * This approach ensures, that the subscriber record will not stick if
509 * an error happens.
510 */
511
512 /* TODO: Check whether this behaviour is acceptable and either just
513 * remove this TODO-notice or change the implementation to not delete
514 * the subscriber data (eventually resetting the ENABLE_PURGE flag and
515 * restarting the expiry timer based on the cause).
516 *
517 * Subscriber Unknown: cancel subscr
518 * Temporary network problems: do nothing (handled by timer based retry)
519 * Message problems (syntax, nyi, ...): cancel subscr (retry won't help)
520 */
521
522 gprs_subscr_handle_gsup_purge_res(subscr, gsup_msg);
523
524 return -gsup_msg->cause;
525}
526
Jacob Erlbeck87c7ffc2015-01-08 15:29:01 +0100527static int gprs_subscr_handle_loc_cancel_req(struct gsm_subscriber *subscr,
528 struct gprs_gsup_message *gsup_msg)
529{
530 struct gprs_gsup_message gsup_reply = {0};
Jacob Erlbeck5b512052015-04-07 17:49:48 +0200531 int is_update_procedure = !gsup_msg->cancel_type ||
532 gsup_msg->cancel_type == GPRS_GSUP_CANCEL_TYPE_UPDATE;
Jacob Erlbeck87c7ffc2015-01-08 15:29:01 +0100533
Jacob Erlbeck8000e0e2015-01-27 14:56:40 +0100534 LOGGSUBSCRP(LOGL_INFO, subscr, "Cancelling MS subscriber (%s)\n",
535 is_update_procedure ?
536 "update procedure" : "subscription withdraw");
Jacob Erlbeck87c7ffc2015-01-08 15:29:01 +0100537
538 gsup_reply.message_type = GPRS_GSUP_MSGT_LOCATION_CANCEL_RESULT;
539 gprs_subscr_tx_gsup_message(subscr, &gsup_reply);
540
Jacob Erlbeck8000e0e2015-01-27 14:56:40 +0100541 if (is_update_procedure)
542 subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE;
543 else
544 /* Since a withdraw cause is not specified, just abort the
545 * current attachment. The following re-attachment should then
546 * be rejected with a proper cause value.
547 */
548 subscr->sgsn_data->error_cause = GMM_CAUSE_IMPL_DETACHED;
549
Jacob Erlbeck37139e52015-01-23 13:52:55 +0100550 gprs_subscr_cancel(subscr);
Jacob Erlbeck87c7ffc2015-01-08 15:29:01 +0100551
552 return 0;
553}
554
Jacob Erlbeck9999fd92015-01-15 17:08:30 +0100555static int gprs_subscr_handle_unknown_imsi(struct gprs_gsup_message *gsup_msg)
556{
557 if (GPRS_GSUP_IS_MSGT_REQUEST(gsup_msg->message_type)) {
558 gprs_subscr_tx_gsup_error_reply(NULL, gsup_msg,
559 GMM_CAUSE_IMSI_UNKNOWN);
560 LOGP(DGPRS, LOGL_NOTICE,
561 "Unknown IMSI %s, discarding GSUP request "
562 "of type 0x%02x\n",
563 gsup_msg->imsi, gsup_msg->message_type);
564 } else if (GPRS_GSUP_IS_MSGT_ERROR(gsup_msg->message_type)) {
565 LOGP(DGPRS, LOGL_NOTICE,
566 "Unknown IMSI %s, discarding GSUP error "
567 "of type 0x%02x, cause '%s' (%d)\n",
568 gsup_msg->imsi, gsup_msg->message_type,
569 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
570 gsup_msg->cause);
571 } else {
572 LOGP(DGPRS, LOGL_NOTICE,
573 "Unknown IMSI %s, discarding GSUP response "
574 "of type 0x%02x\n",
575 gsup_msg->imsi, gsup_msg->message_type);
576 }
577
578 return -GMM_CAUSE_IMSI_UNKNOWN;
579}
580
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100581int gprs_subscr_rx_gsup_message(struct msgb *msg)
582{
583 uint8_t *data = msgb_l2(msg);
584 size_t data_len = msgb_l2len(msg);
585 int rc = 0;
586
587 struct gprs_gsup_message gsup_msg = {0};
588 struct gsm_subscriber *subscr;
589
590 rc = gprs_gsup_decode(data, data_len, &gsup_msg);
591 if (rc < 0) {
592 LOGP(DGPRS, LOGL_ERROR,
Jacob Erlbeckbce20612015-01-05 18:57:32 +0100593 "decoding GSUP message fails with error '%s' (%d)\n",
594 get_value_string(gsm48_gmm_cause_names, -rc), -rc);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100595 return rc;
596 }
597
Jacob Erlbeck07f6e362015-01-29 14:00:28 +0100598 if (!gsup_msg.imsi[0]) {
599 LOGP(DGPRS, LOGL_ERROR, "Missing IMSI in GSUP message\n");
600
601 if (GPRS_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type))
602 gprs_subscr_tx_gsup_error_reply(NULL, &gsup_msg,
603 GMM_CAUSE_INV_MAND_INFO);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100604 return -GMM_CAUSE_INV_MAND_INFO;
Jacob Erlbeck07f6e362015-01-29 14:00:28 +0100605 }
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100606
Jacob Erlbeck9ff82892015-01-29 14:17:51 +0100607 if (!gsup_msg.cause && GPRS_GSUP_IS_MSGT_ERROR(gsup_msg.message_type))
608 gsup_msg.cause = GMM_CAUSE_NET_FAIL;
609
Jacob Erlbeck4dedb272015-01-15 17:50:16 +0100610 subscr = gprs_subscr_get_by_imsi(gsup_msg.imsi);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100611
Jacob Erlbeck929acdf2015-01-27 13:47:24 +0100612 if (!subscr) {
613 switch (gsup_msg.message_type) {
614 case GPRS_GSUP_MSGT_PURGE_MS_RESULT:
615 case GPRS_GSUP_MSGT_PURGE_MS_ERROR:
616 return gprs_subscr_handle_gsup_purge_no_subscr(&gsup_msg);
617 default:
618 return gprs_subscr_handle_unknown_imsi(&gsup_msg);
619 }
620 }
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100621
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100622 LOGGSUBSCRP(LOGL_INFO, subscr,
623 "Received GSUP message of type 0x%02x\n", gsup_msg.message_type);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100624
625 switch (gsup_msg.message_type) {
626 case GPRS_GSUP_MSGT_LOCATION_CANCEL_REQUEST:
Jacob Erlbeck87c7ffc2015-01-08 15:29:01 +0100627 rc = gprs_subscr_handle_loc_cancel_req(subscr, &gsup_msg);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100628 break;
629
630 case GPRS_GSUP_MSGT_SEND_AUTH_INFO_RESULT:
Jacob Erlbeckbce20612015-01-05 18:57:32 +0100631 rc = gprs_subscr_handle_gsup_auth_res(subscr, &gsup_msg);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100632 break;
633
634 case GPRS_GSUP_MSGT_SEND_AUTH_INFO_ERROR:
Jacob Erlbeckbce20612015-01-05 18:57:32 +0100635 rc = gprs_subscr_handle_gsup_auth_err(subscr, &gsup_msg);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100636 break;
637
638 case GPRS_GSUP_MSGT_UPDATE_LOCATION_RESULT:
Jacob Erlbeckbce20612015-01-05 18:57:32 +0100639 rc = gprs_subscr_handle_gsup_upd_loc_res(subscr, &gsup_msg);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100640 break;
641
642 case GPRS_GSUP_MSGT_UPDATE_LOCATION_ERROR:
Jacob Erlbeckbce20612015-01-05 18:57:32 +0100643 rc = gprs_subscr_handle_gsup_upd_loc_err(subscr, &gsup_msg);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100644 break;
645
646 case GPRS_GSUP_MSGT_PURGE_MS_ERROR:
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100647 rc = gprs_subscr_handle_gsup_purge_err(subscr, &gsup_msg);
648 break;
649
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100650 case GPRS_GSUP_MSGT_PURGE_MS_RESULT:
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100651 rc = gprs_subscr_handle_gsup_purge_res(subscr, &gsup_msg);
652 break;
653
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100654 case GPRS_GSUP_MSGT_INSERT_DATA_REQUEST:
655 case GPRS_GSUP_MSGT_DELETE_DATA_REQUEST:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100656 LOGGSUBSCRP(LOGL_ERROR, subscr,
657 "Rx GSUP message type %d not yet implemented\n",
658 gsup_msg.message_type);
Jacob Erlbeck9999fd92015-01-15 17:08:30 +0100659 gprs_subscr_tx_gsup_error_reply(subscr, &gsup_msg,
660 GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100661 rc = -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL;
662 break;
663
664 default:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100665 LOGGSUBSCRP(LOGL_ERROR, subscr,
666 "Rx GSUP message type %d not valid at SGSN\n",
667 gsup_msg.message_type);
Jacob Erlbeck9999fd92015-01-15 17:08:30 +0100668 if (GPRS_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type))
669 gprs_subscr_tx_gsup_error_reply(
670 subscr, &gsup_msg, GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL);
671 rc = -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100672 break;
673 };
674
Jacob Erlbeck87c7ffc2015-01-08 15:29:01 +0100675 subscr_put(subscr);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100676
677 return rc;
678}
679
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100680int gprs_subscr_purge(struct gsm_subscriber *subscr)
681{
Holger Hans Peter Freyther10c0f562015-05-17 20:58:40 +0200682 struct sgsn_subscriber_data *sdata = subscr->sgsn_data;
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100683 struct gprs_gsup_message gsup_msg = {0};
684
685 LOGGSUBSCRP(LOGL_INFO, subscr, "purging MS subscriber\n");
686
687 gsup_msg.message_type = GPRS_GSUP_MSGT_PURGE_MS_REQUEST;
Holger Hans Peter Freyther10c0f562015-05-17 20:58:40 +0200688
689 /* Provide the HLR number in case it is known */
690 gsup_msg.hlr_enc_len = sdata->hlr_len;
691 gsup_msg.hlr_enc = sdata->hlr;
692
Jacob Erlbeckca69b0f2015-02-03 19:45:46 +0100693 return gprs_subscr_tx_gsup_message(subscr, &gsup_msg);
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100694}
695
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100696int gprs_subscr_query_auth_info(struct gsm_subscriber *subscr)
697{
698 struct gprs_gsup_message gsup_msg = {0};
699
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100700 LOGGSUBSCRP(LOGL_INFO, subscr,
701 "subscriber auth info is not available\n");
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100702
703 gsup_msg.message_type = GPRS_GSUP_MSGT_SEND_AUTH_INFO_REQUEST;
704 return gprs_subscr_tx_gsup_message(subscr, &gsup_msg);
705}
706
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100707int gprs_subscr_location_update(struct gsm_subscriber *subscr)
708{
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100709 struct gprs_gsup_message gsup_msg = {0};
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100710
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100711 LOGGSUBSCRP(LOGL_INFO, subscr,
712 "subscriber data is not available\n");
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100713
714 gsup_msg.message_type = GPRS_GSUP_MSGT_UPDATE_LOCATION_REQUEST;
715 return gprs_subscr_tx_gsup_message(subscr, &gsup_msg);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100716}
717
718void gprs_subscr_update(struct gsm_subscriber *subscr)
719{
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100720 LOGGSUBSCRP(LOGL_DEBUG, subscr, "Updating subscriber data\n");
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100721
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100722 subscr->flags &= ~GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100723 subscr->flags &= ~GSM_SUBSCRIBER_FIRST_CONTACT;
724
Jacob Erlbeck555b2e52015-01-26 13:52:42 +0100725 if (subscr->sgsn_data->mm)
726 sgsn_update_subscriber_data(subscr->sgsn_data->mm);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100727}
728
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100729void gprs_subscr_update_auth_info(struct gsm_subscriber *subscr)
730{
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100731 LOGGSUBSCRP(LOGL_DEBUG, subscr,
732 "Updating subscriber authentication info\n");
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100733
734 subscr->flags &= ~GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING;
735 subscr->flags &= ~GSM_SUBSCRIBER_FIRST_CONTACT;
736
Jacob Erlbeck555b2e52015-01-26 13:52:42 +0100737 if (subscr->sgsn_data->mm)
738 sgsn_update_subscriber_data(subscr->sgsn_data->mm);
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100739}
740
741struct gsm_subscriber *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mmctx)
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100742{
743 struct gsm_subscriber *subscr = NULL;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100744
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100745 if (mmctx->subscr)
746 return subscr_get(mmctx->subscr);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100747
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100748 if (mmctx->imsi[0])
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100749 subscr = gprs_subscr_get_by_imsi(mmctx->imsi);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100750
751 if (!subscr) {
752 subscr = gprs_subscr_get_or_create(mmctx->imsi);
753 subscr->flags |= GSM_SUBSCRIBER_FIRST_CONTACT;
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100754 subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100755 }
756
757 if (strcpy(subscr->equipment.imei, mmctx->imei) != 0) {
758 strncpy(subscr->equipment.imei, mmctx->imei, GSM_IMEI_LENGTH-1);
759 subscr->equipment.imei[GSM_IMEI_LENGTH-1] = 0;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100760 }
761
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100762 if (subscr->lac != mmctx->ra.lac)
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100763 subscr->lac = mmctx->ra.lac;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100764
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100765 subscr->sgsn_data->mm = mmctx;
766 mmctx->subscr = subscr_get(subscr);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100767
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100768 return subscr;
769}
770
771int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx)
772{
773 struct gsm_subscriber *subscr = NULL;
774 int rc;
775
776 LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber data update\n");
777
778 subscr = gprs_subscr_get_or_create_by_mmctx(mmctx);
779
780 subscr->flags |= GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING;
781
782 rc = gprs_subscr_location_update(subscr);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100783 subscr_put(subscr);
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100784 return rc;
785}
786
787int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx)
788{
789 struct gsm_subscriber *subscr = NULL;
790 int rc;
791
792 LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber authentication info\n");
793
794 subscr = gprs_subscr_get_or_create_by_mmctx(mmctx);
795
796 subscr->flags |= GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING;
797
798 rc = gprs_subscr_query_auth_info(subscr);
799 subscr_put(subscr);
800 return rc;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100801}