Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 1 | /* MS subscriber data handling */ |
| 2 | |
| 3 | /* (C) 2014 by sysmocom s.f.m.c. GmbH |
Holger Hans Peter Freyther | 786cfee | 2015-04-23 09:53:53 -0400 | [diff] [blame] | 4 | * (C) 2015 by Holger Hans Peter Freyther |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 5 | * |
| 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 | |
Harald Welte | 35ade5e | 2016-04-20 17:11:43 +0200 | [diff] [blame] | 23 | #include <osmocom/gsm/protocol/gsm_04_08_gprs.h> |
Harald Welte | 4e349d6 | 2016-04-25 19:07:34 +0200 | [diff] [blame] | 24 | #include <osmocom/gsm/gsup.h> |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 25 | #include <openbsc/gsm_subscriber.h> |
Jacob Erlbeck | 233715c | 2014-12-18 12:46:47 +0100 | [diff] [blame] | 26 | #include <openbsc/gprs_gsup_client.h> |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 27 | |
| 28 | #include <openbsc/sgsn.h> |
| 29 | #include <openbsc/gprs_sgsn.h> |
| 30 | #include <openbsc/gprs_gmm.h> |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 31 | #include <openbsc/gprs_utils.h> |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 32 | |
| 33 | #include <openbsc/debug.h> |
| 34 | |
Jacob Erlbeck | 233715c | 2014-12-18 12:46:47 +0100 | [diff] [blame] | 35 | #include <netinet/in.h> |
| 36 | #include <arpa/inet.h> |
| 37 | |
Jacob Erlbeck | 8797266 | 2015-01-08 15:18:39 +0100 | [diff] [blame] | 38 | #define SGSN_SUBSCR_MAX_RETRIES 3 |
| 39 | #define SGSN_SUBSCR_RETRY_INTERVAL 10 |
| 40 | |
Jacob Erlbeck | c7c990c | 2015-01-27 13:47:24 +0100 | [diff] [blame] | 41 | #define LOGGSUPP(level, gsup, fmt, args...) \ |
| 42 | LOGP(DGPRS, level, "GSUP(%s) " fmt, \ |
| 43 | (gsup)->imsi, \ |
| 44 | ## args) |
| 45 | |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 46 | extern void *tall_bsc_ctx; |
| 47 | |
Jacob Erlbeck | 233715c | 2014-12-18 12:46:47 +0100 | [diff] [blame] | 48 | static int gsup_read_cb(struct gprs_gsup_client *gsupc, struct msgb *msg); |
| 49 | |
| 50 | /* TODO: Some functions are specific to the SGSN, but this file is more general |
| 51 | * (it has gprs_* name). Either move these functions elsewhere, split them and |
| 52 | * move a part, or replace the gprs_ prefix by sgsn_. The applies to |
| 53 | * gprs_subscr_init, gsup_read_cb, and gprs_subscr_tx_gsup_message. |
| 54 | */ |
| 55 | |
| 56 | int gprs_subscr_init(struct sgsn_instance *sgi) |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 57 | { |
Jacob Erlbeck | 233715c | 2014-12-18 12:46:47 +0100 | [diff] [blame] | 58 | const char *addr_str; |
| 59 | |
| 60 | if (!sgi->cfg.gsup_server_addr.sin_addr.s_addr) |
| 61 | return 0; |
| 62 | |
| 63 | addr_str = inet_ntoa(sgi->cfg.gsup_server_addr.sin_addr); |
| 64 | |
| 65 | sgi->gsup_client = gprs_gsup_client_create( |
| 66 | addr_str, sgi->cfg.gsup_server_port, |
Neels Hofmeyr | 38b5e27 | 2015-10-12 11:57:37 +0200 | [diff] [blame] | 67 | &gsup_read_cb, |
| 68 | &sgi->cfg.oap); |
Jacob Erlbeck | 233715c | 2014-12-18 12:46:47 +0100 | [diff] [blame] | 69 | |
| 70 | if (!sgi->gsup_client) |
| 71 | return -1; |
| 72 | |
| 73 | return 1; |
| 74 | } |
| 75 | |
| 76 | static int gsup_read_cb(struct gprs_gsup_client *gsupc, struct msgb *msg) |
| 77 | { |
| 78 | int rc; |
| 79 | |
| 80 | rc = gprs_subscr_rx_gsup_message(msg); |
Jacob Erlbeck | edb67a1 | 2014-12-19 19:15:55 +0100 | [diff] [blame] | 81 | msgb_free(msg); |
Jacob Erlbeck | 233715c | 2014-12-18 12:46:47 +0100 | [diff] [blame] | 82 | if (rc < 0) |
| 83 | return -1; |
| 84 | |
| 85 | return rc; |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 86 | } |
| 87 | |
Jacob Erlbeck | 9bf4be9 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 88 | int gprs_subscr_purge(struct gsm_subscriber *subscr); |
| 89 | |
Jacob Erlbeck | 359cafa | 2014-12-02 11:28:38 +0100 | [diff] [blame] | 90 | static struct sgsn_subscriber_data *sgsn_subscriber_data_alloc(void *ctx) |
| 91 | { |
| 92 | struct sgsn_subscriber_data *sdata; |
Jacob Erlbeck | b1332b6 | 2014-12-08 15:52:00 +0100 | [diff] [blame] | 93 | int idx; |
Jacob Erlbeck | 359cafa | 2014-12-02 11:28:38 +0100 | [diff] [blame] | 94 | |
| 95 | sdata = talloc_zero(ctx, struct sgsn_subscriber_data); |
| 96 | |
Jacob Erlbeck | f96779f | 2015-01-19 11:10:04 +0100 | [diff] [blame] | 97 | sdata->error_cause = SGSN_ERROR_CAUSE_NONE; |
| 98 | |
Jacob Erlbeck | b1332b6 | 2014-12-08 15:52:00 +0100 | [diff] [blame] | 99 | for (idx = 0; idx < ARRAY_SIZE(sdata->auth_triplets); idx++) |
| 100 | sdata->auth_triplets[idx].key_seq = GSM_KEY_SEQ_INVAL; |
| 101 | |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 102 | INIT_LLIST_HEAD(&sdata->pdp_list); |
| 103 | |
Jacob Erlbeck | 359cafa | 2014-12-02 11:28:38 +0100 | [diff] [blame] | 104 | return sdata; |
| 105 | } |
| 106 | |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 107 | struct sgsn_subscriber_pdp_data* sgsn_subscriber_pdp_data_alloc( |
| 108 | struct sgsn_subscriber_data *sdata) |
| 109 | { |
| 110 | struct sgsn_subscriber_pdp_data* pdata; |
| 111 | |
| 112 | pdata = talloc_zero(sdata, struct sgsn_subscriber_pdp_data); |
| 113 | |
| 114 | llist_add_tail(&pdata->list, &sdata->pdp_list); |
| 115 | |
| 116 | return pdata; |
| 117 | } |
| 118 | |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 119 | struct gsm_subscriber *gprs_subscr_get_or_create(const char *imsi) |
| 120 | { |
| 121 | struct gsm_subscriber *subscr; |
| 122 | |
| 123 | subscr = subscr_get_or_create(NULL, imsi); |
| 124 | if (!subscr) |
| 125 | return NULL; |
| 126 | |
Jacob Erlbeck | 359cafa | 2014-12-02 11:28:38 +0100 | [diff] [blame] | 127 | if (!subscr->sgsn_data) |
| 128 | subscr->sgsn_data = sgsn_subscriber_data_alloc(subscr); |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 129 | return subscr; |
| 130 | } |
| 131 | |
| 132 | struct gsm_subscriber *gprs_subscr_get_by_imsi(const char *imsi) |
| 133 | { |
| 134 | return subscr_active_by_imsi(NULL, imsi); |
| 135 | } |
| 136 | |
Jacob Erlbeck | e71ab2f | 2015-01-26 11:07:24 +0100 | [diff] [blame] | 137 | void gprs_subscr_cleanup(struct gsm_subscriber *subscr) |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 138 | { |
Jacob Erlbeck | 359cafa | 2014-12-02 11:28:38 +0100 | [diff] [blame] | 139 | if (subscr->sgsn_data->mm) { |
| 140 | subscr_put(subscr->sgsn_data->mm->subscr); |
| 141 | subscr->sgsn_data->mm->subscr = NULL; |
| 142 | subscr->sgsn_data->mm = NULL; |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 143 | } |
| 144 | |
Holger Hans Peter Freyther | d95cb73 | 2015-01-20 21:14:03 +0100 | [diff] [blame] | 145 | if (subscr->flags & GPRS_SUBSCRIBER_ENABLE_PURGE) { |
| 146 | gprs_subscr_purge(subscr); |
| 147 | subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE; |
Jacob Erlbeck | 9bf4be9 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 148 | } |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 149 | } |
| 150 | |
Jacob Erlbeck | 7a7d881 | 2015-01-23 13:52:55 +0100 | [diff] [blame] | 151 | void gprs_subscr_cancel(struct gsm_subscriber *subscr) |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 152 | { |
| 153 | subscr->authorized = 0; |
| 154 | subscr->flags |= GPRS_SUBSCRIBER_CANCELLED; |
Jacob Erlbeck | b3982c1 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 155 | subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE; |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 156 | |
| 157 | gprs_subscr_update(subscr); |
Jacob Erlbeck | e71ab2f | 2015-01-26 11:07:24 +0100 | [diff] [blame] | 158 | gprs_subscr_cleanup(subscr); |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 159 | } |
| 160 | |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 161 | static int gprs_subscr_tx_gsup_message(struct gsm_subscriber *subscr, |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 162 | struct osmo_gsup_message *gsup_msg) |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 163 | { |
Jacob Erlbeck | 233715c | 2014-12-18 12:46:47 +0100 | [diff] [blame] | 164 | struct msgb *msg = gprs_gsup_msgb_alloc(); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 165 | |
Jacob Erlbeck | 4f41486 | 2015-01-15 17:08:30 +0100 | [diff] [blame] | 166 | if (strlen(gsup_msg->imsi) == 0 && subscr) |
| 167 | strncpy(gsup_msg->imsi, subscr->imsi, sizeof(gsup_msg->imsi) - 1); |
Max | 92d8d0a | 2016-07-01 15:24:44 +0200 | [diff] [blame] | 168 | gsup_msg->cn_domain = OSMO_GSUP_CN_DOMAIN_PS; |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 169 | osmo_gsup_encode(msg, gsup_msg); |
Jacob Erlbeck | 828059f | 2014-11-28 14:55:25 +0100 | [diff] [blame] | 170 | |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 171 | LOGGSUBSCRP(LOGL_INFO, subscr, |
Jacob Erlbeck | 4f41486 | 2015-01-15 17:08:30 +0100 | [diff] [blame] | 172 | "Sending GSUP, will send: %s\n", msgb_hexdump(msg)); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 173 | |
Jacob Erlbeck | 233715c | 2014-12-18 12:46:47 +0100 | [diff] [blame] | 174 | if (!sgsn->gsup_client) { |
| 175 | msgb_free(msg); |
| 176 | return -ENOTSUP; |
| 177 | } |
| 178 | |
| 179 | return gprs_gsup_client_send(sgsn->gsup_client, msg); |
Jacob Erlbeck | 828059f | 2014-11-28 14:55:25 +0100 | [diff] [blame] | 180 | } |
| 181 | |
Jacob Erlbeck | 4f41486 | 2015-01-15 17:08:30 +0100 | [diff] [blame] | 182 | static int gprs_subscr_tx_gsup_error_reply(struct gsm_subscriber *subscr, |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 183 | struct osmo_gsup_message *gsup_orig, |
Jacob Erlbeck | 4f41486 | 2015-01-15 17:08:30 +0100 | [diff] [blame] | 184 | enum gsm48_gmm_cause cause) |
| 185 | { |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 186 | struct osmo_gsup_message gsup_reply = {0}; |
Jacob Erlbeck | 4f41486 | 2015-01-15 17:08:30 +0100 | [diff] [blame] | 187 | |
| 188 | strncpy(gsup_reply.imsi, gsup_orig->imsi, sizeof(gsup_reply.imsi) - 1); |
| 189 | gsup_reply.cause = cause; |
| 190 | gsup_reply.message_type = |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 191 | OSMO_GSUP_TO_MSGT_ERROR(gsup_orig->message_type); |
Jacob Erlbeck | 4f41486 | 2015-01-15 17:08:30 +0100 | [diff] [blame] | 192 | |
| 193 | return gprs_subscr_tx_gsup_message(subscr, &gsup_reply); |
| 194 | } |
| 195 | |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 196 | static int gprs_subscr_handle_gsup_auth_res(struct gsm_subscriber *subscr, |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 197 | struct osmo_gsup_message *gsup_msg) |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 198 | { |
| 199 | unsigned idx; |
| 200 | struct sgsn_subscriber_data *sdata = subscr->sgsn_data; |
| 201 | |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 202 | LOGGSUBSCRP(LOGL_INFO, subscr, |
Harald Welte | 34ef4c5 | 2016-04-20 13:13:19 +0200 | [diff] [blame] | 203 | "Got SendAuthenticationInfoResult, num_auth_vectors = %zu\n", |
| 204 | gsup_msg->num_auth_vectors); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 205 | |
Harald Welte | 34ef4c5 | 2016-04-20 13:13:19 +0200 | [diff] [blame] | 206 | if (gsup_msg->num_auth_vectors > 0) { |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 207 | memset(sdata->auth_triplets, 0, sizeof(sdata->auth_triplets)); |
| 208 | |
| 209 | for (idx = 0; idx < ARRAY_SIZE(sdata->auth_triplets); idx++) |
| 210 | sdata->auth_triplets[idx].key_seq = GSM_KEY_SEQ_INVAL; |
| 211 | } |
| 212 | |
Harald Welte | 34ef4c5 | 2016-04-20 13:13:19 +0200 | [diff] [blame] | 213 | for (idx = 0; idx < gsup_msg->num_auth_vectors; idx++) { |
| 214 | size_t key_seq = idx; |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 215 | LOGGSUBSCRP(LOGL_DEBUG, subscr, |
Holger Hans Peter Freyther | 844f4b8 | 2015-04-23 11:55:23 -0400 | [diff] [blame] | 216 | "Adding auth tuple, cksn = %zu\n", key_seq); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 217 | if (key_seq >= ARRAY_SIZE(sdata->auth_triplets)) { |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 218 | LOGGSUBSCRP(LOGL_NOTICE, subscr, |
Holger Hans Peter Freyther | 844f4b8 | 2015-04-23 11:55:23 -0400 | [diff] [blame] | 219 | "Skipping auth triplet with invalid cksn %zu\n", |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 220 | key_seq); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 221 | continue; |
| 222 | } |
Harald Welte | 34ef4c5 | 2016-04-20 13:13:19 +0200 | [diff] [blame] | 223 | sdata->auth_triplets[key_seq].vec = gsup_msg->auth_vectors[idx]; |
| 224 | sdata->auth_triplets[key_seq].key_seq = key_seq; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | sdata->auth_triplets_updated = 1; |
Jacob Erlbeck | f96779f | 2015-01-19 11:10:04 +0100 | [diff] [blame] | 228 | sdata->error_cause = SGSN_ERROR_CAUSE_NONE; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 229 | |
| 230 | gprs_subscr_update_auth_info(subscr); |
| 231 | |
| 232 | return 0; |
| 233 | } |
| 234 | |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 235 | static int gprs_subscr_pdp_data_clear(struct gsm_subscriber *subscr) |
| 236 | { |
| 237 | struct sgsn_subscriber_pdp_data *pdp, *pdp2; |
| 238 | int count = 0; |
| 239 | |
| 240 | llist_for_each_entry_safe(pdp, pdp2, &subscr->sgsn_data->pdp_list, list) { |
| 241 | llist_del(&pdp->list); |
| 242 | talloc_free(pdp); |
| 243 | count += 1; |
| 244 | } |
| 245 | |
| 246 | return count; |
| 247 | } |
| 248 | |
| 249 | static struct sgsn_subscriber_pdp_data *gprs_subscr_pdp_data_get_by_id( |
| 250 | struct gsm_subscriber *subscr, unsigned context_id) |
| 251 | { |
| 252 | struct sgsn_subscriber_pdp_data *pdp; |
| 253 | |
| 254 | llist_for_each_entry(pdp, &subscr->sgsn_data->pdp_list, list) { |
| 255 | if (pdp->context_id == context_id) |
| 256 | return pdp; |
| 257 | } |
| 258 | |
| 259 | return NULL; |
| 260 | } |
| 261 | |
| 262 | |
| 263 | static void gprs_subscr_gsup_insert_data(struct gsm_subscriber *subscr, |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 264 | struct osmo_gsup_message *gsup_msg) |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 265 | { |
Holger Hans Peter Freyther | 786cfee | 2015-04-23 09:53:53 -0400 | [diff] [blame] | 266 | struct sgsn_subscriber_data *sdata = subscr->sgsn_data; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 267 | unsigned idx; |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 268 | int rc; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 269 | |
Holger Hans Peter Freyther | 786cfee | 2015-04-23 09:53:53 -0400 | [diff] [blame] | 270 | if (gsup_msg->msisdn_enc) { |
| 271 | if (gsup_msg->msisdn_enc_len > sizeof(sdata->msisdn)) { |
| 272 | LOGP(DGPRS, LOGL_ERROR, "MSISDN too long (%zu)\n", |
| 273 | gsup_msg->msisdn_enc_len); |
| 274 | sdata->msisdn_len = 0; |
| 275 | } else { |
| 276 | memcpy(sdata->msisdn, gsup_msg->msisdn_enc, |
| 277 | gsup_msg->msisdn_enc_len); |
| 278 | sdata->msisdn_len = gsup_msg->msisdn_enc_len; |
| 279 | } |
| 280 | } |
| 281 | |
Holger Hans Peter Freyther | fe4a9f6 | 2015-05-17 20:58:40 +0200 | [diff] [blame] | 282 | if (gsup_msg->hlr_enc) { |
| 283 | if (gsup_msg->hlr_enc_len > sizeof(sdata->hlr)) { |
| 284 | LOGP(DGPRS, LOGL_ERROR, "HLR-Number too long (%zu)\n", |
| 285 | gsup_msg->hlr_enc_len); |
| 286 | sdata->hlr_len = 0; |
| 287 | } else { |
| 288 | memcpy(sdata->hlr, gsup_msg->hlr_enc, |
| 289 | gsup_msg->hlr_enc_len); |
| 290 | sdata->hlr_len = gsup_msg->hlr_enc_len; |
| 291 | } |
| 292 | } |
| 293 | |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 294 | if (gsup_msg->pdp_info_compl) { |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 295 | rc = gprs_subscr_pdp_data_clear(subscr); |
| 296 | if (rc > 0) |
| 297 | LOGP(DGPRS, LOGL_INFO, "Cleared existing PDP info\n"); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | for (idx = 0; idx < gsup_msg->num_pdp_infos; idx++) { |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 301 | struct osmo_gsup_pdp_info *pdp_info = &gsup_msg->pdp_infos[idx]; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 302 | size_t ctx_id = pdp_info->context_id; |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 303 | struct sgsn_subscriber_pdp_data *pdp_data; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 304 | |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 305 | if (pdp_info->apn_enc_len >= sizeof(pdp_data->apn_str)-1) { |
| 306 | LOGGSUBSCRP(LOGL_ERROR, subscr, |
Holger Hans Peter Freyther | 844f4b8 | 2015-04-23 11:55:23 -0400 | [diff] [blame] | 307 | "APN too long, context id = %zu, APN = %s\n", |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 308 | ctx_id, osmo_hexdump(pdp_info->apn_enc, |
| 309 | pdp_info->apn_enc_len)); |
| 310 | continue; |
| 311 | } |
| 312 | |
Holger Hans Peter Freyther | 532b09d | 2015-04-23 11:33:35 -0400 | [diff] [blame] | 313 | if (pdp_info->qos_enc_len > sizeof(pdp_data->qos_subscribed)) { |
| 314 | LOGGSUBSCRP(LOGL_ERROR, subscr, |
| 315 | "QoS info too long (%zu)\n", |
| 316 | pdp_info->qos_enc_len); |
| 317 | continue; |
| 318 | } |
| 319 | |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 320 | LOGGSUBSCRP(LOGL_INFO, subscr, |
Holger Hans Peter Freyther | 844f4b8 | 2015-04-23 11:55:23 -0400 | [diff] [blame] | 321 | "Will set PDP info, context id = %zu, APN = %s\n", |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 322 | ctx_id, osmo_hexdump(pdp_info->apn_enc, pdp_info->apn_enc_len)); |
| 323 | |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 324 | /* Set PDP info [ctx_id] */ |
| 325 | pdp_data = gprs_subscr_pdp_data_get_by_id(subscr, ctx_id); |
| 326 | if (!pdp_data) { |
| 327 | pdp_data = sgsn_subscriber_pdp_data_alloc(subscr->sgsn_data); |
| 328 | pdp_data->context_id = ctx_id; |
| 329 | } |
| 330 | |
| 331 | OSMO_ASSERT(pdp_data != NULL); |
| 332 | pdp_data->pdp_type = pdp_info->pdp_type; |
| 333 | gprs_apn_to_str(pdp_data->apn_str, |
| 334 | pdp_info->apn_enc, pdp_info->apn_enc_len); |
Holger Hans Peter Freyther | 532b09d | 2015-04-23 11:33:35 -0400 | [diff] [blame] | 335 | memcpy(pdp_data->qos_subscribed, pdp_info->qos_enc, pdp_info->qos_enc_len); |
| 336 | pdp_data->qos_subscribed_len = pdp_info->qos_enc_len; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 337 | } |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | static int gprs_subscr_handle_gsup_upd_loc_res(struct gsm_subscriber *subscr, |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 341 | struct osmo_gsup_message *gsup_msg) |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 342 | { |
Harald Welte | c21455b | 2016-05-05 18:25:12 +0200 | [diff] [blame] | 343 | /* contrary to MAP, we allow piggy-backing subscriber data onto |
| 344 | * the UPDATE LOCATION RESULT, and don't mandate the use of a |
| 345 | * separate nested INSERT SUBSCRIBER DATA transaction */ |
Jacob Erlbeck | 94a346a | 2014-12-17 14:03:35 +0100 | [diff] [blame] | 346 | gprs_subscr_gsup_insert_data(subscr, gsup_msg); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 347 | |
| 348 | subscr->authorized = 1; |
Jacob Erlbeck | f96779f | 2015-01-19 11:10:04 +0100 | [diff] [blame] | 349 | subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 350 | |
Jacob Erlbeck | b3982c1 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 351 | subscr->flags |= GPRS_SUBSCRIBER_ENABLE_PURGE; |
| 352 | |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 353 | gprs_subscr_update(subscr); |
| 354 | return 0; |
| 355 | } |
| 356 | |
Harald Welte | c21455b | 2016-05-05 18:25:12 +0200 | [diff] [blame] | 357 | static int gprs_subscr_handle_gsup_isd_req(struct gsm_subscriber *subscr, |
| 358 | struct osmo_gsup_message *gsup_msg) |
| 359 | { |
| 360 | struct osmo_gsup_message gsup_reply = {0}; |
| 361 | |
| 362 | gprs_subscr_gsup_insert_data(subscr, gsup_msg); |
| 363 | |
| 364 | subscr->authorized = 1; |
| 365 | subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE; |
| 366 | subscr->flags |= GPRS_SUBSCRIBER_ENABLE_PURGE; |
| 367 | gprs_subscr_update(subscr); |
| 368 | |
| 369 | gsup_reply.message_type = OSMO_GSUP_MSGT_INSERT_DATA_RESULT; |
| 370 | return gprs_subscr_tx_gsup_message(subscr, &gsup_reply); |
| 371 | } |
| 372 | |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 373 | static int check_cause(int cause) |
| 374 | { |
| 375 | switch (cause) { |
| 376 | case GMM_CAUSE_IMSI_UNKNOWN ... GMM_CAUSE_ILLEGAL_ME: |
| 377 | case GMM_CAUSE_GPRS_NOTALLOWED ... GMM_CAUSE_NO_GPRS_PLMN: |
| 378 | return EACCES; |
| 379 | |
| 380 | case GMM_CAUSE_MSC_TEMP_NOTREACH ... GMM_CAUSE_CONGESTION: |
Jacob Erlbeck | e4dc7fc | 2015-01-05 16:20:47 +0100 | [diff] [blame] | 381 | return EHOSTUNREACH; |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 382 | |
| 383 | case GMM_CAUSE_SEM_INCORR_MSG ... GMM_CAUSE_PROTO_ERR_UNSPEC: |
| 384 | default: |
| 385 | return EINVAL; |
| 386 | } |
| 387 | } |
| 388 | |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 389 | static int gprs_subscr_handle_gsup_auth_err(struct gsm_subscriber *subscr, |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 390 | struct osmo_gsup_message *gsup_msg) |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 391 | { |
| 392 | unsigned idx; |
| 393 | struct sgsn_subscriber_data *sdata = subscr->sgsn_data; |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 394 | int cause_err; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 395 | |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 396 | cause_err = check_cause(gsup_msg->cause); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 397 | |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 398 | LOGGSUBSCRP(LOGL_DEBUG, subscr, |
| 399 | "Send authentication info has failed with cause %d, " |
| 400 | "handled as: %s\n", |
| 401 | gsup_msg->cause, strerror(cause_err)); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 402 | |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 403 | switch (cause_err) { |
| 404 | case EACCES: |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 405 | LOGGSUBSCRP(LOGL_NOTICE, subscr, |
| 406 | "GPRS send auth info req failed, access denied, " |
| 407 | "GMM cause = '%s' (%d)\n", |
| 408 | get_value_string(gsm48_gmm_cause_names, gsup_msg->cause), |
| 409 | gsup_msg->cause); |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 410 | /* Clear auth tuples */ |
| 411 | memset(sdata->auth_triplets, 0, sizeof(sdata->auth_triplets)); |
| 412 | for (idx = 0; idx < ARRAY_SIZE(sdata->auth_triplets); idx++) |
| 413 | sdata->auth_triplets[idx].key_seq = GSM_KEY_SEQ_INVAL; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 414 | |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 415 | subscr->authorized = 0; |
| 416 | sdata->error_cause = gsup_msg->cause; |
| 417 | gprs_subscr_update_auth_info(subscr); |
| 418 | break; |
| 419 | |
Jacob Erlbeck | e4dc7fc | 2015-01-05 16:20:47 +0100 | [diff] [blame] | 420 | case EHOSTUNREACH: |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 421 | LOGGSUBSCRP(LOGL_NOTICE, subscr, |
| 422 | "GPRS send auth info req failed, GMM cause = '%s' (%d)\n", |
| 423 | get_value_string(gsm48_gmm_cause_names, gsup_msg->cause), |
| 424 | gsup_msg->cause); |
Jacob Erlbeck | e4dc7fc | 2015-01-05 16:20:47 +0100 | [diff] [blame] | 425 | |
| 426 | sdata->error_cause = gsup_msg->cause; |
| 427 | gprs_subscr_update_auth_info(subscr); |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 428 | break; |
| 429 | |
| 430 | default: |
| 431 | case EINVAL: |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 432 | LOGGSUBSCRP(LOGL_ERROR, subscr, |
| 433 | "GSUP protocol remote error, GMM cause = '%s' (%d)\n", |
| 434 | get_value_string(gsm48_gmm_cause_names, gsup_msg->cause), |
| 435 | gsup_msg->cause); |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 436 | break; |
| 437 | } |
| 438 | |
| 439 | return -gsup_msg->cause; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | static int gprs_subscr_handle_gsup_upd_loc_err(struct gsm_subscriber *subscr, |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 443 | struct osmo_gsup_message *gsup_msg) |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 444 | { |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 445 | int cause_err; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 446 | |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 447 | cause_err = check_cause(gsup_msg->cause); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 448 | |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 449 | LOGGSUBSCRP(LOGL_DEBUG, subscr, |
| 450 | "Update location has failed with cause %d, handled as: %s\n", |
| 451 | gsup_msg->cause, strerror(cause_err)); |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 452 | |
| 453 | switch (cause_err) { |
| 454 | case EACCES: |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 455 | LOGGSUBSCRP(LOGL_NOTICE, subscr, |
| 456 | "GPRS update location failed, access denied, " |
| 457 | "GMM cause = '%s' (%d)\n", |
| 458 | get_value_string(gsm48_gmm_cause_names, gsup_msg->cause), |
| 459 | gsup_msg->cause); |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 460 | |
| 461 | subscr->authorized = 0; |
| 462 | subscr->sgsn_data->error_cause = gsup_msg->cause; |
| 463 | gprs_subscr_update_auth_info(subscr); |
| 464 | break; |
| 465 | |
Jacob Erlbeck | e4dc7fc | 2015-01-05 16:20:47 +0100 | [diff] [blame] | 466 | case EHOSTUNREACH: |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 467 | LOGGSUBSCRP(LOGL_NOTICE, subscr, |
| 468 | "GPRS update location failed, GMM cause = '%s' (%d)\n", |
| 469 | get_value_string(gsm48_gmm_cause_names, gsup_msg->cause), |
| 470 | gsup_msg->cause); |
Jacob Erlbeck | e4dc7fc | 2015-01-05 16:20:47 +0100 | [diff] [blame] | 471 | |
| 472 | subscr->sgsn_data->error_cause = gsup_msg->cause; |
| 473 | gprs_subscr_update_auth_info(subscr); |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 474 | break; |
| 475 | |
| 476 | default: |
| 477 | case EINVAL: |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 478 | LOGGSUBSCRP(LOGL_ERROR, subscr, |
| 479 | "GSUP protocol remote error, GMM cause = '%s' (%d)\n", |
| 480 | get_value_string(gsm48_gmm_cause_names, gsup_msg->cause), |
| 481 | gsup_msg->cause); |
Jacob Erlbeck | d1892d4 | 2015-01-05 18:38:41 +0100 | [diff] [blame] | 482 | break; |
| 483 | } |
| 484 | |
| 485 | return -gsup_msg->cause; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 486 | } |
| 487 | |
Jacob Erlbeck | c7c990c | 2015-01-27 13:47:24 +0100 | [diff] [blame] | 488 | static int gprs_subscr_handle_gsup_purge_no_subscr( |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 489 | struct osmo_gsup_message *gsup_msg) |
Jacob Erlbeck | c7c990c | 2015-01-27 13:47:24 +0100 | [diff] [blame] | 490 | { |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 491 | if (OSMO_GSUP_IS_MSGT_ERROR(gsup_msg->message_type)) { |
Jacob Erlbeck | c7c990c | 2015-01-27 13:47:24 +0100 | [diff] [blame] | 492 | LOGGSUPP(LOGL_NOTICE, gsup_msg, |
| 493 | "Purge MS has failed with cause '%s' (%d)\n", |
| 494 | get_value_string(gsm48_gmm_cause_names, gsup_msg->cause), |
| 495 | gsup_msg->cause); |
| 496 | return -gsup_msg->cause; |
| 497 | } |
| 498 | |
| 499 | LOGGSUPP(LOGL_INFO, gsup_msg, "Completing purge MS\n"); |
| 500 | return 0; |
| 501 | } |
| 502 | |
Jacob Erlbeck | b3982c1 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 503 | static int gprs_subscr_handle_gsup_purge_res(struct gsm_subscriber *subscr, |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 504 | struct osmo_gsup_message *gsup_msg) |
Jacob Erlbeck | b3982c1 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 505 | { |
| 506 | LOGGSUBSCRP(LOGL_INFO, subscr, "Completing purge MS\n"); |
| 507 | |
| 508 | /* Force silent cancellation */ |
Jacob Erlbeck | f96779f | 2015-01-19 11:10:04 +0100 | [diff] [blame] | 509 | subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE; |
Jacob Erlbeck | 7a7d881 | 2015-01-23 13:52:55 +0100 | [diff] [blame] | 510 | gprs_subscr_cancel(subscr); |
Jacob Erlbeck | b3982c1 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 511 | |
| 512 | return 0; |
| 513 | } |
| 514 | |
| 515 | static int gprs_subscr_handle_gsup_purge_err(struct gsm_subscriber *subscr, |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 516 | struct osmo_gsup_message *gsup_msg) |
Jacob Erlbeck | b3982c1 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 517 | { |
| 518 | LOGGSUBSCRP(LOGL_NOTICE, subscr, |
| 519 | "Purge MS has failed with cause '%s' (%d)\n", |
| 520 | get_value_string(gsm48_gmm_cause_names, gsup_msg->cause), |
| 521 | gsup_msg->cause); |
| 522 | |
| 523 | /* In GSM 09.02, 19.1.4.4, the text and the SDL diagram imply that |
| 524 | * the subscriber data is not removed if the request has failed. On the |
| 525 | * other hand, keeping the subscriber data in either error case |
| 526 | * (subscriber unknown, syntactical message error, connection error) |
| 527 | * doesn't seem to give any advantage, since the data will be restored |
| 528 | * on the next Attach Request anyway. |
| 529 | * This approach ensures, that the subscriber record will not stick if |
| 530 | * an error happens. |
| 531 | */ |
| 532 | |
| 533 | /* TODO: Check whether this behaviour is acceptable and either just |
| 534 | * remove this TODO-notice or change the implementation to not delete |
| 535 | * the subscriber data (eventually resetting the ENABLE_PURGE flag and |
| 536 | * restarting the expiry timer based on the cause). |
| 537 | * |
| 538 | * Subscriber Unknown: cancel subscr |
| 539 | * Temporary network problems: do nothing (handled by timer based retry) |
| 540 | * Message problems (syntax, nyi, ...): cancel subscr (retry won't help) |
| 541 | */ |
| 542 | |
| 543 | gprs_subscr_handle_gsup_purge_res(subscr, gsup_msg); |
| 544 | |
| 545 | return -gsup_msg->cause; |
| 546 | } |
| 547 | |
Jacob Erlbeck | 00b8b91 | 2015-01-08 15:29:01 +0100 | [diff] [blame] | 548 | static int gprs_subscr_handle_loc_cancel_req(struct gsm_subscriber *subscr, |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 549 | struct osmo_gsup_message *gsup_msg) |
Jacob Erlbeck | 00b8b91 | 2015-01-08 15:29:01 +0100 | [diff] [blame] | 550 | { |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 551 | struct osmo_gsup_message gsup_reply = {0}; |
Jacob Erlbeck | e7fea45 | 2015-04-07 17:49:48 +0200 | [diff] [blame] | 552 | int is_update_procedure = !gsup_msg->cancel_type || |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 553 | gsup_msg->cancel_type == OSMO_GSUP_CANCEL_TYPE_UPDATE; |
Jacob Erlbeck | 00b8b91 | 2015-01-08 15:29:01 +0100 | [diff] [blame] | 554 | |
Jacob Erlbeck | 3b0d0c0 | 2015-01-27 14:56:40 +0100 | [diff] [blame] | 555 | LOGGSUBSCRP(LOGL_INFO, subscr, "Cancelling MS subscriber (%s)\n", |
| 556 | is_update_procedure ? |
| 557 | "update procedure" : "subscription withdraw"); |
Jacob Erlbeck | 00b8b91 | 2015-01-08 15:29:01 +0100 | [diff] [blame] | 558 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 559 | gsup_reply.message_type = OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT; |
Jacob Erlbeck | 00b8b91 | 2015-01-08 15:29:01 +0100 | [diff] [blame] | 560 | gprs_subscr_tx_gsup_message(subscr, &gsup_reply); |
| 561 | |
Jacob Erlbeck | 3b0d0c0 | 2015-01-27 14:56:40 +0100 | [diff] [blame] | 562 | if (is_update_procedure) |
| 563 | subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE; |
| 564 | else |
| 565 | /* Since a withdraw cause is not specified, just abort the |
| 566 | * current attachment. The following re-attachment should then |
| 567 | * be rejected with a proper cause value. |
| 568 | */ |
| 569 | subscr->sgsn_data->error_cause = GMM_CAUSE_IMPL_DETACHED; |
| 570 | |
Jacob Erlbeck | 7a7d881 | 2015-01-23 13:52:55 +0100 | [diff] [blame] | 571 | gprs_subscr_cancel(subscr); |
Jacob Erlbeck | 00b8b91 | 2015-01-08 15:29:01 +0100 | [diff] [blame] | 572 | |
| 573 | return 0; |
| 574 | } |
| 575 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 576 | static int gprs_subscr_handle_unknown_imsi(struct osmo_gsup_message *gsup_msg) |
Jacob Erlbeck | 4f41486 | 2015-01-15 17:08:30 +0100 | [diff] [blame] | 577 | { |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 578 | if (OSMO_GSUP_IS_MSGT_REQUEST(gsup_msg->message_type)) { |
Jacob Erlbeck | 4f41486 | 2015-01-15 17:08:30 +0100 | [diff] [blame] | 579 | gprs_subscr_tx_gsup_error_reply(NULL, gsup_msg, |
| 580 | GMM_CAUSE_IMSI_UNKNOWN); |
| 581 | LOGP(DGPRS, LOGL_NOTICE, |
| 582 | "Unknown IMSI %s, discarding GSUP request " |
| 583 | "of type 0x%02x\n", |
| 584 | gsup_msg->imsi, gsup_msg->message_type); |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 585 | } else if (OSMO_GSUP_IS_MSGT_ERROR(gsup_msg->message_type)) { |
Jacob Erlbeck | 4f41486 | 2015-01-15 17:08:30 +0100 | [diff] [blame] | 586 | LOGP(DGPRS, LOGL_NOTICE, |
| 587 | "Unknown IMSI %s, discarding GSUP error " |
| 588 | "of type 0x%02x, cause '%s' (%d)\n", |
| 589 | gsup_msg->imsi, gsup_msg->message_type, |
| 590 | get_value_string(gsm48_gmm_cause_names, gsup_msg->cause), |
| 591 | gsup_msg->cause); |
| 592 | } else { |
| 593 | LOGP(DGPRS, LOGL_NOTICE, |
| 594 | "Unknown IMSI %s, discarding GSUP response " |
| 595 | "of type 0x%02x\n", |
| 596 | gsup_msg->imsi, gsup_msg->message_type); |
| 597 | } |
| 598 | |
| 599 | return -GMM_CAUSE_IMSI_UNKNOWN; |
| 600 | } |
| 601 | |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 602 | int gprs_subscr_rx_gsup_message(struct msgb *msg) |
| 603 | { |
| 604 | uint8_t *data = msgb_l2(msg); |
| 605 | size_t data_len = msgb_l2len(msg); |
| 606 | int rc = 0; |
| 607 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 608 | struct osmo_gsup_message gsup_msg = {0}; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 609 | struct gsm_subscriber *subscr; |
| 610 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 611 | rc = osmo_gsup_decode(data, data_len, &gsup_msg); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 612 | if (rc < 0) { |
| 613 | LOGP(DGPRS, LOGL_ERROR, |
Jacob Erlbeck | 092bbc8 | 2015-01-05 18:57:32 +0100 | [diff] [blame] | 614 | "decoding GSUP message fails with error '%s' (%d)\n", |
| 615 | get_value_string(gsm48_gmm_cause_names, -rc), -rc); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 616 | return rc; |
| 617 | } |
| 618 | |
Jacob Erlbeck | 6c8c8ab | 2015-01-29 14:00:28 +0100 | [diff] [blame] | 619 | if (!gsup_msg.imsi[0]) { |
| 620 | LOGP(DGPRS, LOGL_ERROR, "Missing IMSI in GSUP message\n"); |
| 621 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 622 | if (OSMO_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type)) |
Jacob Erlbeck | 6c8c8ab | 2015-01-29 14:00:28 +0100 | [diff] [blame] | 623 | gprs_subscr_tx_gsup_error_reply(NULL, &gsup_msg, |
| 624 | GMM_CAUSE_INV_MAND_INFO); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 625 | return -GMM_CAUSE_INV_MAND_INFO; |
Jacob Erlbeck | 6c8c8ab | 2015-01-29 14:00:28 +0100 | [diff] [blame] | 626 | } |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 627 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 628 | if (!gsup_msg.cause && OSMO_GSUP_IS_MSGT_ERROR(gsup_msg.message_type)) |
Jacob Erlbeck | 9ca3ace | 2015-01-29 14:17:51 +0100 | [diff] [blame] | 629 | gsup_msg.cause = GMM_CAUSE_NET_FAIL; |
| 630 | |
Jacob Erlbeck | 629dacc | 2015-01-15 17:50:16 +0100 | [diff] [blame] | 631 | subscr = gprs_subscr_get_by_imsi(gsup_msg.imsi); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 632 | |
Jacob Erlbeck | c7c990c | 2015-01-27 13:47:24 +0100 | [diff] [blame] | 633 | if (!subscr) { |
| 634 | switch (gsup_msg.message_type) { |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 635 | case OSMO_GSUP_MSGT_PURGE_MS_RESULT: |
| 636 | case OSMO_GSUP_MSGT_PURGE_MS_ERROR: |
Jacob Erlbeck | c7c990c | 2015-01-27 13:47:24 +0100 | [diff] [blame] | 637 | return gprs_subscr_handle_gsup_purge_no_subscr(&gsup_msg); |
| 638 | default: |
| 639 | return gprs_subscr_handle_unknown_imsi(&gsup_msg); |
| 640 | } |
| 641 | } |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 642 | |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 643 | LOGGSUBSCRP(LOGL_INFO, subscr, |
| 644 | "Received GSUP message of type 0x%02x\n", gsup_msg.message_type); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 645 | |
| 646 | switch (gsup_msg.message_type) { |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 647 | case OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST: |
Jacob Erlbeck | 00b8b91 | 2015-01-08 15:29:01 +0100 | [diff] [blame] | 648 | rc = gprs_subscr_handle_loc_cancel_req(subscr, &gsup_msg); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 649 | break; |
| 650 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 651 | case OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT: |
Jacob Erlbeck | 092bbc8 | 2015-01-05 18:57:32 +0100 | [diff] [blame] | 652 | rc = gprs_subscr_handle_gsup_auth_res(subscr, &gsup_msg); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 653 | break; |
| 654 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 655 | case OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR: |
Jacob Erlbeck | 092bbc8 | 2015-01-05 18:57:32 +0100 | [diff] [blame] | 656 | rc = gprs_subscr_handle_gsup_auth_err(subscr, &gsup_msg); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 657 | break; |
| 658 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 659 | case OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT: |
Jacob Erlbeck | 092bbc8 | 2015-01-05 18:57:32 +0100 | [diff] [blame] | 660 | rc = gprs_subscr_handle_gsup_upd_loc_res(subscr, &gsup_msg); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 661 | break; |
| 662 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 663 | case OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR: |
Jacob Erlbeck | 092bbc8 | 2015-01-05 18:57:32 +0100 | [diff] [blame] | 664 | rc = gprs_subscr_handle_gsup_upd_loc_err(subscr, &gsup_msg); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 665 | break; |
| 666 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 667 | case OSMO_GSUP_MSGT_PURGE_MS_ERROR: |
Jacob Erlbeck | b3982c1 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 668 | rc = gprs_subscr_handle_gsup_purge_err(subscr, &gsup_msg); |
| 669 | break; |
| 670 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 671 | case OSMO_GSUP_MSGT_PURGE_MS_RESULT: |
Jacob Erlbeck | b3982c1 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 672 | rc = gprs_subscr_handle_gsup_purge_res(subscr, &gsup_msg); |
| 673 | break; |
| 674 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 675 | case OSMO_GSUP_MSGT_INSERT_DATA_REQUEST: |
Harald Welte | c21455b | 2016-05-05 18:25:12 +0200 | [diff] [blame] | 676 | rc = gprs_subscr_handle_gsup_isd_req(subscr, &gsup_msg); |
| 677 | break; |
| 678 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 679 | case OSMO_GSUP_MSGT_DELETE_DATA_REQUEST: |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 680 | LOGGSUBSCRP(LOGL_ERROR, subscr, |
| 681 | "Rx GSUP message type %d not yet implemented\n", |
| 682 | gsup_msg.message_type); |
Jacob Erlbeck | 4f41486 | 2015-01-15 17:08:30 +0100 | [diff] [blame] | 683 | gprs_subscr_tx_gsup_error_reply(subscr, &gsup_msg, |
| 684 | GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 685 | rc = -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL; |
| 686 | break; |
| 687 | |
| 688 | default: |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 689 | LOGGSUBSCRP(LOGL_ERROR, subscr, |
| 690 | "Rx GSUP message type %d not valid at SGSN\n", |
| 691 | gsup_msg.message_type); |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 692 | if (OSMO_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type)) |
Jacob Erlbeck | 4f41486 | 2015-01-15 17:08:30 +0100 | [diff] [blame] | 693 | gprs_subscr_tx_gsup_error_reply( |
| 694 | subscr, &gsup_msg, GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL); |
| 695 | rc = -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 696 | break; |
| 697 | }; |
| 698 | |
Jacob Erlbeck | 00b8b91 | 2015-01-08 15:29:01 +0100 | [diff] [blame] | 699 | subscr_put(subscr); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 700 | |
| 701 | return rc; |
| 702 | } |
| 703 | |
Jacob Erlbeck | b3982c1 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 704 | int gprs_subscr_purge(struct gsm_subscriber *subscr) |
| 705 | { |
Holger Hans Peter Freyther | fe4a9f6 | 2015-05-17 20:58:40 +0200 | [diff] [blame] | 706 | struct sgsn_subscriber_data *sdata = subscr->sgsn_data; |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 707 | struct osmo_gsup_message gsup_msg = {0}; |
Jacob Erlbeck | b3982c1 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 708 | |
| 709 | LOGGSUBSCRP(LOGL_INFO, subscr, "purging MS subscriber\n"); |
| 710 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 711 | gsup_msg.message_type = OSMO_GSUP_MSGT_PURGE_MS_REQUEST; |
Holger Hans Peter Freyther | fe4a9f6 | 2015-05-17 20:58:40 +0200 | [diff] [blame] | 712 | |
| 713 | /* Provide the HLR number in case it is known */ |
| 714 | gsup_msg.hlr_enc_len = sdata->hlr_len; |
| 715 | gsup_msg.hlr_enc = sdata->hlr; |
| 716 | |
Jacob Erlbeck | 0c8e6bd | 2015-02-03 19:45:46 +0100 | [diff] [blame] | 717 | return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); |
Jacob Erlbeck | b3982c1 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 718 | } |
| 719 | |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 720 | int gprs_subscr_query_auth_info(struct gsm_subscriber *subscr) |
| 721 | { |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 722 | struct osmo_gsup_message gsup_msg = {0}; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 723 | |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 724 | LOGGSUBSCRP(LOGL_INFO, subscr, |
| 725 | "subscriber auth info is not available\n"); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 726 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 727 | gsup_msg.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 728 | return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); |
| 729 | } |
| 730 | |
Jacob Erlbeck | 828059f | 2014-11-28 14:55:25 +0100 | [diff] [blame] | 731 | int gprs_subscr_location_update(struct gsm_subscriber *subscr) |
| 732 | { |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 733 | struct osmo_gsup_message gsup_msg = {0}; |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 734 | |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 735 | LOGGSUBSCRP(LOGL_INFO, subscr, |
| 736 | "subscriber data is not available\n"); |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 737 | |
Harald Welte | e2b5349 | 2016-04-25 14:53:43 +0200 | [diff] [blame] | 738 | gsup_msg.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST; |
Jacob Erlbeck | 5641cfc | 2014-12-12 15:01:37 +0100 | [diff] [blame] | 739 | return gprs_subscr_tx_gsup_message(subscr, &gsup_msg); |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | void gprs_subscr_update(struct gsm_subscriber *subscr) |
| 743 | { |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 744 | LOGGSUBSCRP(LOGL_DEBUG, subscr, "Updating subscriber data\n"); |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 745 | |
Jacob Erlbeck | 828059f | 2014-11-28 14:55:25 +0100 | [diff] [blame] | 746 | subscr->flags &= ~GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING; |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 747 | subscr->flags &= ~GSM_SUBSCRIBER_FIRST_CONTACT; |
| 748 | |
Jacob Erlbeck | 428f1ec | 2015-01-26 13:52:42 +0100 | [diff] [blame] | 749 | if (subscr->sgsn_data->mm) |
| 750 | sgsn_update_subscriber_data(subscr->sgsn_data->mm); |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 751 | } |
| 752 | |
Jacob Erlbeck | 828059f | 2014-11-28 14:55:25 +0100 | [diff] [blame] | 753 | void gprs_subscr_update_auth_info(struct gsm_subscriber *subscr) |
| 754 | { |
Jacob Erlbeck | 387d6d9 | 2014-12-23 14:24:16 +0100 | [diff] [blame] | 755 | LOGGSUBSCRP(LOGL_DEBUG, subscr, |
| 756 | "Updating subscriber authentication info\n"); |
Jacob Erlbeck | 828059f | 2014-11-28 14:55:25 +0100 | [diff] [blame] | 757 | |
| 758 | subscr->flags &= ~GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING; |
| 759 | subscr->flags &= ~GSM_SUBSCRIBER_FIRST_CONTACT; |
| 760 | |
Jacob Erlbeck | 428f1ec | 2015-01-26 13:52:42 +0100 | [diff] [blame] | 761 | if (subscr->sgsn_data->mm) |
| 762 | sgsn_update_subscriber_data(subscr->sgsn_data->mm); |
Jacob Erlbeck | 828059f | 2014-11-28 14:55:25 +0100 | [diff] [blame] | 763 | } |
| 764 | |
| 765 | struct gsm_subscriber *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mmctx) |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 766 | { |
| 767 | struct gsm_subscriber *subscr = NULL; |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 768 | |
Jacob Erlbeck | 828059f | 2014-11-28 14:55:25 +0100 | [diff] [blame] | 769 | if (mmctx->subscr) |
| 770 | return subscr_get(mmctx->subscr); |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 771 | |
Jacob Erlbeck | 828059f | 2014-11-28 14:55:25 +0100 | [diff] [blame] | 772 | if (mmctx->imsi[0]) |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 773 | subscr = gprs_subscr_get_by_imsi(mmctx->imsi); |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 774 | |
| 775 | if (!subscr) { |
| 776 | subscr = gprs_subscr_get_or_create(mmctx->imsi); |
| 777 | subscr->flags |= GSM_SUBSCRIBER_FIRST_CONTACT; |
Jacob Erlbeck | b3982c1 | 2015-01-06 16:32:41 +0100 | [diff] [blame] | 778 | subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE; |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 779 | } |
| 780 | |
| 781 | if (strcpy(subscr->equipment.imei, mmctx->imei) != 0) { |
Harald Welte | 02884f2 | 2016-04-20 17:50:17 +0200 | [diff] [blame] | 782 | strncpy(subscr->equipment.imei, mmctx->imei, |
| 783 | sizeof(subscr->equipment.imei)-1); |
| 784 | subscr->equipment.imei[sizeof(subscr->equipment.imei)-1] = 0; |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 785 | } |
| 786 | |
Jacob Erlbeck | 828059f | 2014-11-28 14:55:25 +0100 | [diff] [blame] | 787 | if (subscr->lac != mmctx->ra.lac) |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 788 | subscr->lac = mmctx->ra.lac; |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 789 | |
Jacob Erlbeck | 828059f | 2014-11-28 14:55:25 +0100 | [diff] [blame] | 790 | subscr->sgsn_data->mm = mmctx; |
| 791 | mmctx->subscr = subscr_get(subscr); |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 792 | |
Jacob Erlbeck | 828059f | 2014-11-28 14:55:25 +0100 | [diff] [blame] | 793 | return subscr; |
| 794 | } |
| 795 | |
| 796 | int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx) |
| 797 | { |
| 798 | struct gsm_subscriber *subscr = NULL; |
| 799 | int rc; |
| 800 | |
| 801 | LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber data update\n"); |
| 802 | |
| 803 | subscr = gprs_subscr_get_or_create_by_mmctx(mmctx); |
| 804 | |
| 805 | subscr->flags |= GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING; |
| 806 | |
| 807 | rc = gprs_subscr_location_update(subscr); |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 808 | subscr_put(subscr); |
Jacob Erlbeck | 828059f | 2014-11-28 14:55:25 +0100 | [diff] [blame] | 809 | return rc; |
| 810 | } |
| 811 | |
| 812 | int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx) |
| 813 | { |
| 814 | struct gsm_subscriber *subscr = NULL; |
| 815 | int rc; |
| 816 | |
| 817 | LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber authentication info\n"); |
| 818 | |
| 819 | subscr = gprs_subscr_get_or_create_by_mmctx(mmctx); |
| 820 | |
| 821 | subscr->flags |= GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING; |
| 822 | |
| 823 | rc = gprs_subscr_query_auth_info(subscr); |
| 824 | subscr_put(subscr); |
| 825 | return rc; |
Jacob Erlbeck | e8b6968 | 2014-11-12 10:12:11 +0100 | [diff] [blame] | 826 | } |