blob: 35044518c74af59174db57a0effd6c9be6a3654b [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
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (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
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 */
22
23
24#include <sys/types.h>
25
26#include <openbsc/gsm_04_08.h>
27#include <openbsc/signal.h>
28#include <openbsc/gsm_subscriber.h>
Holger Hans Peter Freyther8b77a342009-10-22 15:42:19 +020029#include <openbsc/chan_alloc.h>
Harald Welte (local)b8afe812009-08-16 13:18:51 +020030
Harald Welteeab84a12009-12-13 10:53:12 +010031/* RRLP msPositionReq, nsBased,
32 * Accuracy=60, Method=gps, ResponseTime=2, oneSet */
Harald Welte (local)b8afe812009-08-16 13:18:51 +020033static const u_int8_t ms_based_pos_req[] = { 0x40, 0x01, 0x78, 0xa8 };
34
Harald Welteeab84a12009-12-13 10:53:12 +010035/* RRLP msPositionReq, msBasedPref,
36 Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */
37static const u_int8_t ms_pref_pos_req[] = { 0x40, 0x02, 0x79, 0x50 };
38
39/* RRLP msPositionReq, msAssistedPref,
40 Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */
41static const u_int8_t ass_pref_pos_req[] = { 0x40, 0x03, 0x79, 0x50 };
42
43static int send_rrlp_req(struct gsm_lchan *lchan)
44{
45 struct gsm_network *net = lchan->ts->trx->bts->network;
46 const u_int8_t *req;
47
48 switch (net->rrlp.mode) {
49 case RRLP_MODE_MS_BASED:
50 req = ms_based_pos_req;
51 break;
52 case RRLP_MODE_MS_PREF:
53 req = ms_pref_pos_req;
54 break;
55 case RRLP_MODE_ASS_PREF:
56 req = ass_pref_pos_req;
57 break;
58 case RRLP_MODE_NONE:
59 default:
60 return 0;
61 }
62
63 return gsm48_send_rr_app_info(lchan, 0x00,
64 sizeof(ms_based_pos_req), req);
65}
66
Harald Welte (local)b8afe812009-08-16 13:18:51 +020067static int subscr_sig_cb(unsigned int subsys, unsigned int signal,
68 void *handler_data, void *signal_data)
69{
70 struct gsm_subscriber *subscr;
71 struct gsm_lchan *lchan;
72
73 switch (signal) {
74 case S_SUBSCR_ATTACHED:
75 /* A subscriber has attached. */
76 subscr = signal_data;
77 lchan = lchan_for_subscr(subscr);
78 if (!lchan)
79 break;
Harald Welteeab84a12009-12-13 10:53:12 +010080 send_rrlp_req(lchan);
Harald Welte (local)b8afe812009-08-16 13:18:51 +020081 break;
82 }
83 return 0;
84}
85
86static int paging_sig_cb(unsigned int subsys, unsigned int signal,
87 void *handler_data, void *signal_data)
88{
89 struct paging_signal_data *psig_data = signal_data;
90
91 switch (signal) {
Sylvain Munautef24dff2009-12-19 12:38:10 +010092 case S_PAGING_SUCCEEDED:
Harald Welte (local)b8afe812009-08-16 13:18:51 +020093 /* A subscriber has attached. */
Harald Welteeab84a12009-12-13 10:53:12 +010094 send_rrlp_req(psig_data->lchan);
Harald Welte (local)b8afe812009-08-16 13:18:51 +020095 break;
Sylvain Munautef24dff2009-12-19 12:38:10 +010096 case S_PAGING_EXPIRED:
97 break;
Harald Welte (local)b8afe812009-08-16 13:18:51 +020098 }
99 return 0;
100}
101
102void on_dso_load_rrlp(void)
103{
104 register_signal_handler(SS_SUBSCR, subscr_sig_cb, NULL);
105 register_signal_handler(SS_PAGING, paging_sig_cb, NULL);
106}