blob: cd3da066b5440a30cdd8d5f8aafec8ed4bf270f4 [file] [log] [blame]
Harald Welteeab84a12009-12-13 10:53:12 +01001/* Radio Resource LCS (Location) Protocol, GMS TS 04.31 */
Harald Welte (local)b8afe812009-08-16 13:18:51 +02002
3/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
4 *
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01008 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
Harald Welte (local)b8afe812009-08-16 13:18:51 +020010 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010015 * GNU Affero General Public License for more details.
Harald Welte (local)b8afe812009-08-16 13:18:51 +020016 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010017 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte (local)b8afe812009-08-16 13:18:51 +020019 *
20 */
21
22
Harald Welte (local)b8afe812009-08-16 13:18:51 +020023
24#include <openbsc/gsm_04_08.h>
25#include <openbsc/signal.h>
26#include <openbsc/gsm_subscriber.h>
Holger Hans Peter Freyther8b77a342009-10-22 15:42:19 +020027#include <openbsc/chan_alloc.h>
Harald Welte (local)b8afe812009-08-16 13:18:51 +020028
Harald Welteeab84a12009-12-13 10:53:12 +010029/* RRLP msPositionReq, nsBased,
30 * Accuracy=60, Method=gps, ResponseTime=2, oneSet */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020031static const uint8_t ms_based_pos_req[] = { 0x40, 0x01, 0x78, 0xa8 };
Harald Welte (local)b8afe812009-08-16 13:18:51 +020032
Harald Welteeab84a12009-12-13 10:53:12 +010033/* RRLP msPositionReq, msBasedPref,
34 Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020035static const uint8_t ms_pref_pos_req[] = { 0x40, 0x02, 0x79, 0x50 };
Harald Welteeab84a12009-12-13 10:53:12 +010036
37/* RRLP msPositionReq, msAssistedPref,
38 Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020039static const uint8_t ass_pref_pos_req[] = { 0x40, 0x03, 0x79, 0x50 };
Harald Welteeab84a12009-12-13 10:53:12 +010040
Holger Hans Peter Freyther9ce1b272010-06-16 13:52:55 +080041static int send_rrlp_req(struct gsm_subscriber_connection *conn)
Harald Welteeab84a12009-12-13 10:53:12 +010042{
Neels Hofmeyra9f2bb52016-05-09 21:09:47 +020043 struct gsm_network *net = conn->network;
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020044 const uint8_t *req;
Harald Welteeab84a12009-12-13 10:53:12 +010045
46 switch (net->rrlp.mode) {
47 case RRLP_MODE_MS_BASED:
48 req = ms_based_pos_req;
49 break;
50 case RRLP_MODE_MS_PREF:
51 req = ms_pref_pos_req;
52 break;
53 case RRLP_MODE_ASS_PREF:
54 req = ass_pref_pos_req;
55 break;
56 case RRLP_MODE_NONE:
57 default:
58 return 0;
59 }
60
Holger Hans Peter Freyther9ce1b272010-06-16 13:52:55 +080061 return gsm48_send_rr_app_info(conn, 0x00,
Harald Welteeab84a12009-12-13 10:53:12 +010062 sizeof(ms_based_pos_req), req);
63}
64
Harald Welte (local)b8afe812009-08-16 13:18:51 +020065static int subscr_sig_cb(unsigned int subsys, unsigned int signal,
66 void *handler_data, void *signal_data)
67{
Harald Welte2483f1b2016-06-19 18:06:02 +020068 struct vlr_subscr *vsub;
Holger Hans Peter Freytherb2be1952010-06-16 13:23:55 +080069 struct gsm_subscriber_connection *conn;
Harald Welte (local)b8afe812009-08-16 13:18:51 +020070
71 switch (signal) {
72 case S_SUBSCR_ATTACHED:
73 /* A subscriber has attached. */
Harald Welte2483f1b2016-06-19 18:06:02 +020074 vsub = signal_data;
75 conn = connection_for_subscr(vsub);
Holger Hans Peter Freytherb2be1952010-06-16 13:23:55 +080076 if (!conn)
Harald Welte (local)b8afe812009-08-16 13:18:51 +020077 break;
Holger Hans Peter Freyther9ce1b272010-06-16 13:52:55 +080078 send_rrlp_req(conn);
Harald Welte (local)b8afe812009-08-16 13:18:51 +020079 break;
80 }
81 return 0;
82}
83
84static int paging_sig_cb(unsigned int subsys, unsigned int signal,
85 void *handler_data, void *signal_data)
86{
87 struct paging_signal_data *psig_data = signal_data;
88
89 switch (signal) {
Sylvain Munautef24dff2009-12-19 12:38:10 +010090 case S_PAGING_SUCCEEDED:
Harald Welte (local)b8afe812009-08-16 13:18:51 +020091 /* A subscriber has attached. */
Holger Hans Peter Freyther86481c22010-06-17 15:05:57 +080092 send_rrlp_req(psig_data->conn);
Harald Welte (local)b8afe812009-08-16 13:18:51 +020093 break;
Sylvain Munautef24dff2009-12-19 12:38:10 +010094 case S_PAGING_EXPIRED:
95 break;
Harald Welte (local)b8afe812009-08-16 13:18:51 +020096 }
97 return 0;
98}
99
100void on_dso_load_rrlp(void)
101{
Pablo Neira Ayusobbc5b992011-05-06 12:12:31 +0200102 osmo_signal_register_handler(SS_SUBSCR, subscr_sig_cb, NULL);
103 osmo_signal_register_handler(SS_PAGING, paging_sig_cb, NULL);
Harald Welte (local)b8afe812009-08-16 13:18:51 +0200104}