blob: ae5ca478e5cfa6fe94a281e88c7efcfd2d1e254a [file] [log] [blame]
Jonathan Santos03fd8d02011-05-25 13:54:02 -04001/* Radio Resource LCS (Location) Protocol, GMS TS 04.31 */
2
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 Affero General Public License as published by
9 * the Free Software Foundation; either version 3 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 Affero General Public License for more details.
16 *
17 * 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/>.
19 *
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>
28#include <openbsc/chan_alloc.h>
29
30/* RRLP msPositionReq, nsBased,
31 * Accuracy=60, Method=gps, ResponseTime=2, oneSet */
32static const u_int8_t ms_based_pos_req[] = { 0x40, 0x01, 0x78, 0xa8 };
33
34/* RRLP msPositionReq, msBasedPref,
35 Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */
36static const u_int8_t ms_pref_pos_req[] = { 0x40, 0x02, 0x79, 0x50 };
37
38/* RRLP msPositionReq, msAssistedPref,
39 Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */
40static const u_int8_t ass_pref_pos_req[] = { 0x40, 0x03, 0x79, 0x50 };
41
42static int send_rrlp_req(struct gsm_subscriber_connection *conn)
43{
44 struct gsm_network *net = conn->bts->network;
45 const u_int8_t *req;
46
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
62 return gsm48_send_rr_app_info(conn, 0x00,
63 sizeof(ms_based_pos_req), req);
64}
65
66static int subscr_sig_cb(unsigned int subsys, unsigned int signal,
67 void *handler_data, void *signal_data)
68{
69 struct gsm_subscriber *subscr;
70 struct gsm_subscriber_connection *conn;
71
72 switch (signal) {
73 case S_SUBSCR_ATTACHED:
74 /* A subscriber has attached. */
75 subscr = signal_data;
76 conn = connection_for_subscr(subscr);
77 if (!conn)
78 break;
79 send_rrlp_req(conn);
80 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) {
91 case S_PAGING_SUCCEEDED:
92 /* A subscriber has attached. */
93 send_rrlp_req(psig_data->conn);
94 break;
95 case S_PAGING_EXPIRED:
96 break;
97 }
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}