Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 1 | /* (C) 2009-2011 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 2 | * (C) 2009-2011 by On-Waves |
Holger Hans Peter Freyther | 5bb874d | 2010-11-05 11:21:18 +0100 | [diff] [blame] | 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 6 | * it under the terms of the GNU Affero General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
Holger Hans Peter Freyther | 5bb874d | 2010-11-05 11:21:18 +0100 | [diff] [blame] | 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 13 | * GNU Affero General Public License for more details. |
Holger Hans Peter Freyther | 5bb874d | 2010-11-05 11:21:18 +0100 | [diff] [blame] | 14 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 15 | * You should have received a copy of the GNU Affero General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Holger Hans Peter Freyther | 5bb874d | 2010-11-05 11:21:18 +0100 | [diff] [blame] | 17 | * |
| 18 | */ |
| 19 | |
| 20 | #include <openbsc/osmo_bsc.h> |
Holger Hans Peter Freyther | 52d42ab | 2010-11-05 18:41:04 +0100 | [diff] [blame] | 21 | #include <openbsc/osmo_msc_data.h> |
| 22 | #include <openbsc/gsm_04_80.h> |
Holger Hans Peter Freyther | 16e958d | 2010-11-15 13:34:03 +0100 | [diff] [blame] | 23 | #include <openbsc/gsm_subscriber.h> |
Holger Hans Peter Freyther | d65305f | 2010-11-05 11:31:08 +0100 | [diff] [blame] | 24 | #include <openbsc/debug.h> |
Holger Hans Peter Freyther | 16e958d | 2010-11-15 13:34:03 +0100 | [diff] [blame] | 25 | #include <openbsc/paging.h> |
| 26 | |
| 27 | #include <stdlib.h> |
Holger Hans Peter Freyther | d65305f | 2010-11-05 11:31:08 +0100 | [diff] [blame] | 28 | |
| 29 | static void handle_lu_request(struct gsm_subscriber_connection *conn, |
| 30 | struct msgb *msg) |
| 31 | { |
| 32 | struct gsm48_hdr *gh; |
| 33 | struct gsm48_loc_upd_req *lu; |
| 34 | struct gsm48_loc_area_id lai; |
| 35 | struct gsm_network *net; |
| 36 | |
| 37 | if (msgb_l3len(msg) < sizeof(*gh) + sizeof(*lu)) { |
| 38 | LOGP(DMSC, LOGL_ERROR, "LU too small to look at: %u\n", msgb_l3len(msg)); |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | net = conn->bts->network; |
| 43 | |
| 44 | gh = msgb_l3(msg); |
| 45 | lu = (struct gsm48_loc_upd_req *) gh->data; |
| 46 | |
| 47 | gsm48_generate_lai(&lai, net->country_code, net->network_code, |
| 48 | conn->bts->location_area_code); |
| 49 | |
| 50 | if (memcmp(&lai, &lu->lai, sizeof(lai)) != 0) { |
| 51 | LOGP(DMSC, LOGL_DEBUG, "Marking con for welcome USSD.\n"); |
| 52 | conn->sccp_con->new_subscriber = 1; |
| 53 | } |
| 54 | } |
Holger Hans Peter Freyther | 5bb874d | 2010-11-05 11:21:18 +0100 | [diff] [blame] | 55 | |
Holger Hans Peter Freyther | f67d9a9 | 2011-06-07 20:12:33 +0200 | [diff] [blame] | 56 | /* extract a subscriber from the paging response */ |
| 57 | static struct gsm_subscriber *extract_sub(struct gsm_subscriber_connection *conn, |
| 58 | struct msgb *msg) |
Holger Hans Peter Freyther | 16e958d | 2010-11-15 13:34:03 +0100 | [diff] [blame] | 59 | { |
| 60 | uint8_t mi_type; |
| 61 | char mi_string[GSM48_MI_SIZE]; |
| 62 | struct gsm48_hdr *gh; |
| 63 | struct gsm48_pag_resp *resp; |
| 64 | struct gsm_subscriber *subscr; |
| 65 | |
| 66 | if (msgb_l3len(msg) < sizeof(*gh) + sizeof(*resp)) { |
| 67 | LOGP(DMSC, LOGL_ERROR, "PagingResponse too small: %u\n", msgb_l3len(msg)); |
Holger Hans Peter Freyther | f67d9a9 | 2011-06-07 20:12:33 +0200 | [diff] [blame] | 68 | return NULL; |
Holger Hans Peter Freyther | 16e958d | 2010-11-15 13:34:03 +0100 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | gh = msgb_l3(msg); |
| 72 | resp = (struct gsm48_pag_resp *) &gh->data[0]; |
| 73 | |
| 74 | gsm48_paging_extract_mi(resp, msgb_l3len(msg) - sizeof(*gh), |
| 75 | mi_string, &mi_type); |
| 76 | DEBUGP(DRR, "PAGING RESPONSE: mi_type=0x%02x MI(%s)\n", |
| 77 | mi_type, mi_string); |
| 78 | |
| 79 | switch (mi_type) { |
| 80 | case GSM_MI_TYPE_TMSI: |
| 81 | subscr = subscr_active_by_tmsi(conn->bts->network, |
| 82 | tmsi_from_string(mi_string)); |
| 83 | break; |
| 84 | case GSM_MI_TYPE_IMSI: |
| 85 | subscr = subscr_active_by_imsi(conn->bts->network, mi_string); |
| 86 | break; |
Holger Hans Peter Freyther | 3fbd244 | 2011-01-16 18:18:56 +0100 | [diff] [blame] | 87 | default: |
| 88 | subscr = NULL; |
| 89 | break; |
Holger Hans Peter Freyther | 16e958d | 2010-11-15 13:34:03 +0100 | [diff] [blame] | 90 | } |
| 91 | |
Holger Hans Peter Freyther | f67d9a9 | 2011-06-07 20:12:33 +0200 | [diff] [blame] | 92 | return subscr; |
| 93 | } |
| 94 | |
| 95 | /* we will need to stop the paging request */ |
| 96 | static int handle_page_resp(struct gsm_subscriber_connection *conn, struct msgb *msg) |
| 97 | { |
| 98 | struct gsm_subscriber *subscr = extract_sub(conn, msg); |
| 99 | |
Holger Hans Peter Freyther | 16e958d | 2010-11-15 13:34:03 +0100 | [diff] [blame] | 100 | if (!subscr) { |
| 101 | LOGP(DMSC, LOGL_ERROR, "Non active subscriber got paged.\n"); |
| 102 | return -1; |
| 103 | } |
| 104 | |
Harald Welte | f604bba | 2010-12-15 15:33:08 +0100 | [diff] [blame] | 105 | paging_request_stop(conn->bts, subscr, conn, msg); |
Holger Hans Peter Freyther | 16e958d | 2010-11-15 13:34:03 +0100 | [diff] [blame] | 106 | subscr_put(subscr); |
| 107 | return 0; |
| 108 | } |
Holger Hans Peter Freyther | 18fa70a | 2011-06-08 19:25:38 +0200 | [diff] [blame] | 109 | |
| 110 | static int is_cm_service_for_emerg(struct msgb *msg) |
| 111 | { |
| 112 | struct gsm48_service_request *cm; |
| 113 | struct gsm48_hdr *gh = msgb_l3(msg); |
| 114 | |
| 115 | if (msgb_l3len(msg) < sizeof(*gh) + sizeof(*cm)) { |
| 116 | LOGP(DMSC, LOGL_ERROR, "CM ServiceRequest does not fit.\n"); |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | cm = (struct gsm48_service_request *) &gh->data[0]; |
| 121 | return cm->cm_service_type == GSM48_CMSERV_EMERGENCY; |
| 122 | } |
| 123 | |
Holger Hans Peter Freyther | 076af1c | 2011-06-07 19:57:02 +0200 | [diff] [blame] | 124 | struct osmo_msc_data *bsc_find_msc(struct gsm_subscriber_connection *conn, |
| 125 | struct msgb *msg) |
| 126 | { |
Holger Hans Peter Freyther | f67d9a9 | 2011-06-07 20:12:33 +0200 | [diff] [blame] | 127 | struct gsm48_hdr *gh; |
| 128 | int8_t pdisc; |
| 129 | uint8_t mtype; |
Holger Hans Peter Freyther | 076af1c | 2011-06-07 19:57:02 +0200 | [diff] [blame] | 130 | struct osmo_bsc_data *bsc; |
Holger Hans Peter Freyther | f67d9a9 | 2011-06-07 20:12:33 +0200 | [diff] [blame] | 131 | struct osmo_msc_data *msc, *pag_msc; |
| 132 | struct gsm_subscriber *subscr; |
Holger Hans Peter Freyther | 18fa70a | 2011-06-08 19:25:38 +0200 | [diff] [blame] | 133 | int is_emerg = 0; |
Holger Hans Peter Freyther | 076af1c | 2011-06-07 19:57:02 +0200 | [diff] [blame] | 134 | |
| 135 | bsc = conn->bts->network->bsc_data; |
Holger Hans Peter Freyther | f67d9a9 | 2011-06-07 20:12:33 +0200 | [diff] [blame] | 136 | |
| 137 | if (msgb_l3len(msg) < sizeof(*gh)) { |
| 138 | LOGP(DMSC, LOGL_ERROR, "There is no GSM48 header here.\n"); |
| 139 | return NULL; |
| 140 | } |
| 141 | |
| 142 | gh = msgb_l3(msg); |
| 143 | pdisc = gh->proto_discr & 0x0f; |
| 144 | mtype = gh->msg_type & 0xbf; |
| 145 | |
| 146 | /* |
| 147 | * We are asked to select a MSC here but they are not equal. We |
| 148 | * want to respond to a paging request on the MSC where we got the |
| 149 | * request from. This is where we need to decide where this connection |
| 150 | * will go. |
| 151 | */ |
| 152 | if (pdisc == GSM48_PDISC_RR && mtype == GSM48_MT_RR_PAG_RESP) |
| 153 | goto paging; |
Holger Hans Peter Freyther | 18fa70a | 2011-06-08 19:25:38 +0200 | [diff] [blame] | 154 | else if (pdisc == GSM48_PDISC_MM && mtype == GSM48_MT_MM_CM_SERV_REQ) { |
| 155 | is_emerg = is_cm_service_for_emerg(msg); |
| 156 | goto round_robin; |
| 157 | } else |
Holger Hans Peter Freyther | f67d9a9 | 2011-06-07 20:12:33 +0200 | [diff] [blame] | 158 | goto round_robin; |
| 159 | |
| 160 | round_robin: |
Holger Hans Peter Freyther | 076af1c | 2011-06-07 19:57:02 +0200 | [diff] [blame] | 161 | llist_for_each_entry(msc, &bsc->mscs, entry) { |
| 162 | if (!msc->msc_con->is_authenticated) |
| 163 | continue; |
Holger Hans Peter Freyther | 18fa70a | 2011-06-08 19:25:38 +0200 | [diff] [blame] | 164 | if (!is_emerg && msc->type != MSC_CON_TYPE_NORMAL) |
| 165 | continue; |
| 166 | if (is_emerg && !msc->allow_emerg) |
Holger Hans Peter Freyther | 210565e | 2011-06-07 20:56:18 +0200 | [diff] [blame] | 167 | continue; |
Holger Hans Peter Freyther | 076af1c | 2011-06-07 19:57:02 +0200 | [diff] [blame] | 168 | |
| 169 | /* force round robin by moving it to the end */ |
| 170 | llist_move_tail(&msc->entry, &bsc->mscs); |
| 171 | return msc; |
| 172 | } |
| 173 | |
| 174 | return NULL; |
Holger Hans Peter Freyther | f67d9a9 | 2011-06-07 20:12:33 +0200 | [diff] [blame] | 175 | |
| 176 | paging: |
| 177 | subscr = extract_sub(conn, msg); |
| 178 | |
| 179 | if (!subscr) { |
| 180 | LOGP(DMSC, LOGL_ERROR, "Got paged but no subscriber found.\n"); |
| 181 | return NULL; |
| 182 | } |
| 183 | |
| 184 | pag_msc = paging_get_data(conn->bts, subscr); |
| 185 | subscr_put(subscr); |
| 186 | |
| 187 | llist_for_each_entry(msc, &bsc->mscs, entry) { |
| 188 | if (msc != pag_msc) |
| 189 | continue; |
| 190 | |
| 191 | /* |
| 192 | * We don't check if the MSC is connected. In case it |
| 193 | * is not the connection will be dropped. |
| 194 | */ |
| 195 | |
| 196 | /* force round robin by moving it to the end */ |
| 197 | llist_move_tail(&msc->entry, &bsc->mscs); |
| 198 | return msc; |
| 199 | } |
| 200 | |
| 201 | LOGP(DMSC, LOGL_ERROR, "Got paged but no request found.\n"); |
| 202 | return NULL; |
Holger Hans Peter Freyther | 076af1c | 2011-06-07 19:57:02 +0200 | [diff] [blame] | 203 | } |
| 204 | |
Holger Hans Peter Freyther | 16e958d | 2010-11-15 13:34:03 +0100 | [diff] [blame] | 205 | |
Holger Hans Peter Freyther | 5bb874d | 2010-11-05 11:21:18 +0100 | [diff] [blame] | 206 | /** |
| 207 | * This is used to scan a message for extra functionality of the BSC. This |
| 208 | * includes scanning for location updating requests/acceptd and then send |
| 209 | * a welcome USSD message to the subscriber. |
| 210 | */ |
| 211 | int bsc_scan_bts_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) |
| 212 | { |
Holger Hans Peter Freyther | d65305f | 2010-11-05 11:31:08 +0100 | [diff] [blame] | 213 | struct gsm48_hdr *gh = msgb_l3(msg); |
| 214 | uint8_t pdisc = gh->proto_discr & 0x0f; |
| 215 | uint8_t mtype = gh->msg_type & 0xbf; |
| 216 | |
| 217 | if (pdisc == GSM48_PDISC_MM) { |
| 218 | if (mtype == GSM48_MT_MM_LOC_UPD_REQUEST) |
| 219 | handle_lu_request(conn, msg); |
Holger Hans Peter Freyther | 16e958d | 2010-11-15 13:34:03 +0100 | [diff] [blame] | 220 | } else if (pdisc == GSM48_PDISC_RR) { |
| 221 | if (mtype == GSM48_MT_RR_PAG_RESP) |
| 222 | handle_page_resp(conn, msg); |
Holger Hans Peter Freyther | d65305f | 2010-11-05 11:31:08 +0100 | [diff] [blame] | 223 | } |
| 224 | |
Holger Hans Peter Freyther | 5bb874d | 2010-11-05 11:21:18 +0100 | [diff] [blame] | 225 | return 0; |
| 226 | } |
Holger Hans Peter Freyther | a54732d | 2010-11-05 18:11:19 +0100 | [diff] [blame] | 227 | |
Holger Hans Peter Freyther | d2361d9 | 2012-12-03 15:32:54 +0100 | [diff] [blame] | 228 | static int send_welcome_ussd(struct gsm_subscriber_connection *conn) |
Holger Hans Peter Freyther | 52d42ab | 2010-11-05 18:41:04 +0100 | [diff] [blame] | 229 | { |
Holger Hans Peter Freyther | 383d3c3 | 2012-07-19 14:22:42 +0200 | [diff] [blame] | 230 | struct osmo_bsc_sccp_con *bsc_con; |
Holger Hans Peter Freyther | 52d42ab | 2010-11-05 18:41:04 +0100 | [diff] [blame] | 231 | |
Holger Hans Peter Freyther | 383d3c3 | 2012-07-19 14:22:42 +0200 | [diff] [blame] | 232 | bsc_con = conn->sccp_con; |
Holger Hans Peter Freyther | f589221 | 2012-08-30 13:05:15 +0200 | [diff] [blame] | 233 | if (!bsc_con) { |
| 234 | LOGP(DMSC, LOGL_DEBUG, "No SCCP connection associated.\n"); |
Holger Hans Peter Freyther | d2361d9 | 2012-12-03 15:32:54 +0100 | [diff] [blame] | 235 | return 0; |
Holger Hans Peter Freyther | f589221 | 2012-08-30 13:05:15 +0200 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | if (!bsc_con->msc->ussd_welcome_txt) { |
| 239 | LOGP(DMSC, LOGL_DEBUG, "No USSD Welcome text defined.\n"); |
Holger Hans Peter Freyther | d2361d9 | 2012-12-03 15:32:54 +0100 | [diff] [blame] | 240 | return 0; |
Holger Hans Peter Freyther | f589221 | 2012-08-30 13:05:15 +0200 | [diff] [blame] | 241 | } |
Holger Hans Peter Freyther | 52d42ab | 2010-11-05 18:41:04 +0100 | [diff] [blame] | 242 | |
Holger Hans Peter Freyther | d2361d9 | 2012-12-03 15:32:54 +0100 | [diff] [blame] | 243 | return BSS_SEND_USSD; |
| 244 | } |
| 245 | |
| 246 | int bsc_send_welcome_ussd(struct gsm_subscriber_connection *conn) |
| 247 | { |
| 248 | gsm0480_send_ussdNotify(conn, 1, conn->sccp_con->msc->ussd_welcome_txt); |
Holger Hans Peter Freyther | 52d42ab | 2010-11-05 18:41:04 +0100 | [diff] [blame] | 249 | gsm0480_send_releaseComplete(conn); |
Holger Hans Peter Freyther | d2361d9 | 2012-12-03 15:32:54 +0100 | [diff] [blame] | 250 | |
| 251 | return 0; |
Holger Hans Peter Freyther | 52d42ab | 2010-11-05 18:41:04 +0100 | [diff] [blame] | 252 | } |
| 253 | |
Jacob Erlbeck | 946d141 | 2013-09-17 13:59:29 +0200 | [diff] [blame] | 254 | static int bsc_patch_mm_info(struct gsm_subscriber_connection *conn, |
| 255 | uint8_t *data, unsigned int length) |
| 256 | { |
| 257 | struct tlv_parsed tp; |
| 258 | int parse_res; |
| 259 | struct gsm_bts *bts = conn->bts; |
| 260 | int tzunits; |
| 261 | uint8_t tzbsd = 0; |
| 262 | uint8_t dst = 0; |
| 263 | |
| 264 | parse_res = tlv_parse(&tp, &gsm48_mm_att_tlvdef, data, length, 0, 0); |
| 265 | if (parse_res <= 0 && parse_res != -3) |
| 266 | return 0; |
| 267 | |
| 268 | /* Is TZ patching enabled? */ |
| 269 | if (!bts->tz.override) |
| 270 | return 0; |
| 271 | |
| 272 | /* Convert tz.hr and tz.mn to units */ |
| 273 | if (bts->tz.hr < 0) { |
| 274 | tzunits = -bts->tz.hr*4; |
| 275 | tzbsd |= 0x08; |
| 276 | } else |
| 277 | tzunits = bts->tz.hr*4; |
| 278 | |
| 279 | tzunits = tzunits + (bts->tz.mn/15); |
| 280 | |
| 281 | tzbsd |= (tzunits % 10)*0x10 + (tzunits / 10); |
| 282 | |
| 283 | /* Convert DST value */ |
| 284 | if (bts->tz.dst >= 0 && bts->tz.dst <= 2) |
| 285 | dst = bts->tz.dst; |
| 286 | |
| 287 | if (TLVP_PRESENT(&tp, GSM48_IE_UTC)) { |
| 288 | LOGP(DMSC, LOGL_DEBUG, |
| 289 | "Changing 'Local time zone' from 0x%02x to 0x%02x.\n", |
| 290 | TLVP_VAL(&tp, GSM48_IE_UTC)[6], tzbsd); |
| 291 | ((uint8_t *)(TLVP_VAL(&tp, GSM48_IE_UTC)))[0] = tzbsd; |
| 292 | } |
| 293 | if (TLVP_PRESENT(&tp, GSM48_IE_NET_TIME_TZ)) { |
| 294 | LOGP(DMSC, LOGL_DEBUG, |
| 295 | "Changing 'Universal time and local time zone' TZ from " |
| 296 | "0x%02x to 0x%02x.\n", |
| 297 | TLVP_VAL(&tp, GSM48_IE_NET_TIME_TZ)[6], tzbsd); |
| 298 | ((uint8_t *)(TLVP_VAL(&tp, GSM48_IE_NET_TIME_TZ)))[6] = tzbsd; |
| 299 | } |
| 300 | #ifdef GSM48_IE_NET_DST |
| 301 | if (TLVP_PRESENT(&tp, GSM48_IE_NET_DST)) { |
| 302 | LOGP(DMSC, LOGL_DEBUG, |
| 303 | "Changing 'Network daylight saving time' from " |
| 304 | "0x%02x to 0x%02x.\n", |
| 305 | TLVP_VAL(&tp, GSM48_IE_NET_DST)[0], dst); |
| 306 | ((uint8_t *)(TLVP_VAL(&tp, GSM48_IE_NET_DST)))[0] = dst; |
| 307 | } |
| 308 | #endif |
| 309 | |
| 310 | return 0; |
| 311 | } |
| 312 | |
Holger Hans Peter Freyther | a54732d | 2010-11-05 18:11:19 +0100 | [diff] [blame] | 313 | /** |
| 314 | * Messages coming back from the MSC. |
| 315 | */ |
| 316 | int bsc_scan_msc_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) |
| 317 | { |
Holger Hans Peter Freyther | f936fb4 | 2011-06-04 15:12:57 +0200 | [diff] [blame] | 318 | struct osmo_msc_data *msc; |
Holger Hans Peter Freyther | 52d42ab | 2010-11-05 18:41:04 +0100 | [diff] [blame] | 319 | struct gsm_network *net; |
| 320 | struct gsm48_loc_area_id *lai; |
| 321 | struct gsm48_hdr *gh; |
| 322 | uint8_t mtype; |
Jacob Erlbeck | 946d141 | 2013-09-17 13:59:29 +0200 | [diff] [blame] | 323 | int length = msgb_l3len(msg); |
Holger Hans Peter Freyther | 52d42ab | 2010-11-05 18:41:04 +0100 | [diff] [blame] | 324 | |
Jacob Erlbeck | 946d141 | 2013-09-17 13:59:29 +0200 | [diff] [blame] | 325 | if (length < sizeof(*gh)) { |
Holger Hans Peter Freyther | 52d42ab | 2010-11-05 18:41:04 +0100 | [diff] [blame] | 326 | LOGP(DMSC, LOGL_ERROR, "GSM48 header does not fit.\n"); |
| 327 | return -1; |
| 328 | } |
| 329 | |
| 330 | gh = (struct gsm48_hdr *) msgb_l3(msg); |
Jacob Erlbeck | 946d141 | 2013-09-17 13:59:29 +0200 | [diff] [blame] | 331 | length -= (const char *)&gh->data[0] - (const char *)gh; |
| 332 | |
Holger Hans Peter Freyther | 52d42ab | 2010-11-05 18:41:04 +0100 | [diff] [blame] | 333 | mtype = gh->msg_type & 0xbf; |
| 334 | net = conn->bts->network; |
Holger Hans Peter Freyther | f936fb4 | 2011-06-04 15:12:57 +0200 | [diff] [blame] | 335 | msc = conn->sccp_con->msc; |
Holger Hans Peter Freyther | 52d42ab | 2010-11-05 18:41:04 +0100 | [diff] [blame] | 336 | |
| 337 | if (mtype == GSM48_MT_MM_LOC_UPD_ACCEPT) { |
Holger Hans Peter Freyther | f936fb4 | 2011-06-04 15:12:57 +0200 | [diff] [blame] | 338 | if (msc->core_ncc != -1 || msc->core_mcc != -1) { |
Holger Hans Peter Freyther | 52d42ab | 2010-11-05 18:41:04 +0100 | [diff] [blame] | 339 | if (msgb_l3len(msg) >= sizeof(*gh) + sizeof(*lai)) { |
| 340 | lai = (struct gsm48_loc_area_id *) &gh->data[0]; |
| 341 | gsm48_generate_lai(lai, net->country_code, |
| 342 | net->network_code, |
| 343 | conn->bts->location_area_code); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | if (conn->sccp_con->new_subscriber) |
Holger Hans Peter Freyther | d2361d9 | 2012-12-03 15:32:54 +0100 | [diff] [blame] | 348 | return send_welcome_ussd(conn); |
| 349 | return 0; |
Jacob Erlbeck | 946d141 | 2013-09-17 13:59:29 +0200 | [diff] [blame] | 350 | } else if (mtype == GSM48_MT_MM_INFO) { |
| 351 | bsc_patch_mm_info(conn, &gh->data[0], length); |
Holger Hans Peter Freyther | 52d42ab | 2010-11-05 18:41:04 +0100 | [diff] [blame] | 352 | } |
| 353 | |
Holger Hans Peter Freyther | a54732d | 2010-11-05 18:11:19 +0100 | [diff] [blame] | 354 | return 0; |
| 355 | } |