Holger Hans Peter Freyther | 5bb874d | 2010-11-05 11:21:18 +0100 | [diff] [blame] | 1 | /* (C) 2009-2010 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 2 | * (C) 2009-2010 by On-Waves |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 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 |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #include <openbsc/osmo_bsc.h> |
Holger Hans Peter Freyther | d65305f | 2010-11-05 11:31:08 +0100 | [diff] [blame^] | 22 | #include <openbsc/debug.h> |
| 23 | |
| 24 | static void handle_lu_request(struct gsm_subscriber_connection *conn, |
| 25 | struct msgb *msg) |
| 26 | { |
| 27 | struct gsm48_hdr *gh; |
| 28 | struct gsm48_loc_upd_req *lu; |
| 29 | struct gsm48_loc_area_id lai; |
| 30 | struct gsm_network *net; |
| 31 | |
| 32 | if (msgb_l3len(msg) < sizeof(*gh) + sizeof(*lu)) { |
| 33 | LOGP(DMSC, LOGL_ERROR, "LU too small to look at: %u\n", msgb_l3len(msg)); |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | net = conn->bts->network; |
| 38 | |
| 39 | gh = msgb_l3(msg); |
| 40 | lu = (struct gsm48_loc_upd_req *) gh->data; |
| 41 | |
| 42 | gsm48_generate_lai(&lai, net->country_code, net->network_code, |
| 43 | conn->bts->location_area_code); |
| 44 | |
| 45 | if (memcmp(&lai, &lu->lai, sizeof(lai)) != 0) { |
| 46 | LOGP(DMSC, LOGL_DEBUG, "Marking con for welcome USSD.\n"); |
| 47 | conn->sccp_con->new_subscriber = 1; |
| 48 | } |
| 49 | } |
Holger Hans Peter Freyther | 5bb874d | 2010-11-05 11:21:18 +0100 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * This is used to scan a message for extra functionality of the BSC. This |
| 53 | * includes scanning for location updating requests/acceptd and then send |
| 54 | * a welcome USSD message to the subscriber. |
| 55 | */ |
| 56 | int bsc_scan_bts_msg(struct gsm_subscriber_connection *conn, struct msgb *msg) |
| 57 | { |
Holger Hans Peter Freyther | d65305f | 2010-11-05 11:31:08 +0100 | [diff] [blame^] | 58 | struct gsm48_hdr *gh = msgb_l3(msg); |
| 59 | uint8_t pdisc = gh->proto_discr & 0x0f; |
| 60 | uint8_t mtype = gh->msg_type & 0xbf; |
| 61 | |
| 62 | if (pdisc == GSM48_PDISC_MM) { |
| 63 | if (mtype == GSM48_MT_MM_LOC_UPD_REQUEST) |
| 64 | handle_lu_request(conn, msg); |
| 65 | } |
| 66 | |
Holger Hans Peter Freyther | 5bb874d | 2010-11-05 11:21:18 +0100 | [diff] [blame] | 67 | return 0; |
| 68 | } |