blob: 37f7f3eda74bb62e14aa379b6baa2c79cfc7b440 [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
23#include <sys/types.h>
24
25#include <openbsc/gsm_04_08.h>
26#include <openbsc/signal.h>
27#include <openbsc/gsm_subscriber.h>
Holger Hans Peter Freyther8b77a342009-10-22 15:42:19 +020028#include <openbsc/chan_alloc.h>
Harald Welte (local)b8afe812009-08-16 13:18:51 +020029
Harald Welteeab84a12009-12-13 10:53:12 +010030/* RRLP msPositionReq, nsBased,
31 * Accuracy=60, Method=gps, ResponseTime=2, oneSet */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020032static const uint8_t ms_based_pos_req[] = { 0x40, 0x01, 0x78, 0xa8 };
Harald Welte (local)b8afe812009-08-16 13:18:51 +020033
Harald Welteeab84a12009-12-13 10:53:12 +010034/* RRLP msPositionReq, msBasedPref,
35 Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020036static const uint8_t ms_pref_pos_req[] = { 0x40, 0x02, 0x79, 0x50 };
Harald Welteeab84a12009-12-13 10:53:12 +010037
38/* RRLP msPositionReq, msAssistedPref,
39 Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020040static const uint8_t ass_pref_pos_req[] = { 0x40, 0x03, 0x79, 0x50 };
Harald Welteeab84a12009-12-13 10:53:12 +010041
Holger Hans Peter Freyther9ce1b272010-06-16 13:52:55 +080042static int send_rrlp_req(struct gsm_subscriber_connection *conn)
Harald Welteeab84a12009-12-13 10:53:12 +010043{
Holger Hans Peter Freyther9ce1b272010-06-16 13:52:55 +080044 struct gsm_network *net = conn->bts->network;
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020045 const uint8_t *req;
Harald Welteeab84a12009-12-13 10:53:12 +010046
47 switch (net->rrlp.mode) {
48 case RRLP_MODE_MS_BASED:
49 req = ms_based_pos_req;
50 break;
51 case RRLP_MODE_MS_PREF:
52 req = ms_pref_pos_req;
53 break;
54 case RRLP_MODE_ASS_PREF:
55 req = ass_pref_pos_req;
56 break;
57 case RRLP_MODE_NONE:
58 default:
59 return 0;
60 }
61
Holger Hans Peter Freyther9ce1b272010-06-16 13:52:55 +080062 return gsm48_send_rr_app_info(conn, 0x00,
Harald Welteeab84a12009-12-13 10:53:12 +010063 sizeof(ms_based_pos_req), req);
64}
65
Harald Welte (local)b8afe812009-08-16 13:18:51 +020066static int subscr_sig_cb(unsigned int subsys, unsigned int signal,
67 void *handler_data, void *signal_data)
68{
69 struct gsm_subscriber *subscr;
Holger Hans Peter Freytherb2be1952010-06-16 13:23:55 +080070 struct gsm_subscriber_connection *conn;
Harald Welte (local)b8afe812009-08-16 13:18:51 +020071
72 switch (signal) {
73 case S_SUBSCR_ATTACHED:
74 /* A subscriber has attached. */
75 subscr = signal_data;
Holger Hans Peter Freytherb2be1952010-06-16 13:23:55 +080076 conn = connection_for_subscr(subscr);
77 if (!conn)
Harald Welte (local)b8afe812009-08-16 13:18:51 +020078 break;
Holger Hans Peter Freyther9ce1b272010-06-16 13:52:55 +080079 send_rrlp_req(conn);
Harald Welte (local)b8afe812009-08-16 13:18:51 +020080 break;
81 }
82 return 0;
83}
84
85static int paging_sig_cb(unsigned int subsys, unsigned int signal,
86 void *handler_data, void *signal_data)
87{
88 struct paging_signal_data *psig_data = signal_data;
89
90 switch (signal) {
Sylvain Munautef24dff2009-12-19 12:38:10 +010091 case S_PAGING_SUCCEEDED:
Harald Welte (local)b8afe812009-08-16 13:18:51 +020092 /* A subscriber has attached. */
Holger Hans Peter Freyther86481c22010-06-17 15:05:57 +080093 send_rrlp_req(psig_data->conn);
Harald Welte (local)b8afe812009-08-16 13:18:51 +020094 break;
Sylvain Munautef24dff2009-12-19 12:38:10 +010095 case S_PAGING_EXPIRED:
96 break;
Harald Welte (local)b8afe812009-08-16 13:18:51 +020097 }
98 return 0;
99}
100
101void on_dso_load_rrlp(void)
102{
103 register_signal_handler(SS_SUBSCR, subscr_sig_cb, NULL);
104 register_signal_handler(SS_PAGING, paging_sig_cb, NULL);
105}