Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 1 | /* Radio Resource LCS (Location) Protocol, GMS TS 04.31 */ |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 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 |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 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 |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 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 |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 15 | * GNU Affero General Public License for more details. |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 16 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 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/>. |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 19 | * |
| 20 | */ |
| 21 | |
| 22 | |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 23 | |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 24 | #include <osmocom/msc/gsm_04_08.h> |
| 25 | #include <osmocom/msc/signal.h> |
| 26 | #include <osmocom/msc/gsm_subscriber.h> |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 27 | |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 28 | /* RRLP msPositionReq, nsBased, |
| 29 | * Accuracy=60, Method=gps, ResponseTime=2, oneSet */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 30 | static const uint8_t ms_based_pos_req[] = { 0x40, 0x01, 0x78, 0xa8 }; |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 31 | |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 32 | /* RRLP msPositionReq, msBasedPref, |
| 33 | Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 34 | static const uint8_t ms_pref_pos_req[] = { 0x40, 0x02, 0x79, 0x50 }; |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 35 | |
| 36 | /* RRLP msPositionReq, msAssistedPref, |
| 37 | Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 38 | static const uint8_t ass_pref_pos_req[] = { 0x40, 0x03, 0x79, 0x50 }; |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 39 | |
Holger Hans Peter Freyther | 9ce1b27 | 2010-06-16 13:52:55 +0800 | [diff] [blame] | 40 | static int send_rrlp_req(struct gsm_subscriber_connection *conn) |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 41 | { |
Neels Hofmeyr | a9f2bb5 | 2016-05-09 21:09:47 +0200 | [diff] [blame] | 42 | struct gsm_network *net = conn->network; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 43 | const uint8_t *req; |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 44 | |
| 45 | switch (net->rrlp.mode) { |
| 46 | case RRLP_MODE_MS_BASED: |
| 47 | req = ms_based_pos_req; |
| 48 | break; |
| 49 | case RRLP_MODE_MS_PREF: |
| 50 | req = ms_pref_pos_req; |
| 51 | break; |
| 52 | case RRLP_MODE_ASS_PREF: |
| 53 | req = ass_pref_pos_req; |
| 54 | break; |
| 55 | case RRLP_MODE_NONE: |
| 56 | default: |
| 57 | return 0; |
| 58 | } |
| 59 | |
Holger Hans Peter Freyther | 9ce1b27 | 2010-06-16 13:52:55 +0800 | [diff] [blame] | 60 | return gsm48_send_rr_app_info(conn, 0x00, |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 61 | sizeof(ms_based_pos_req), req); |
| 62 | } |
| 63 | |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 64 | static int subscr_sig_cb(unsigned int subsys, unsigned int signal, |
| 65 | void *handler_data, void *signal_data) |
| 66 | { |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 67 | struct vlr_subscr *vsub; |
Holger Hans Peter Freyther | b2be195 | 2010-06-16 13:23:55 +0800 | [diff] [blame] | 68 | struct gsm_subscriber_connection *conn; |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 69 | |
| 70 | switch (signal) { |
| 71 | case S_SUBSCR_ATTACHED: |
| 72 | /* A subscriber has attached. */ |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 73 | vsub = signal_data; |
| 74 | conn = connection_for_subscr(vsub); |
Holger Hans Peter Freyther | b2be195 | 2010-06-16 13:23:55 +0800 | [diff] [blame] | 75 | if (!conn) |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 76 | break; |
Holger Hans Peter Freyther | 9ce1b27 | 2010-06-16 13:52:55 +0800 | [diff] [blame] | 77 | send_rrlp_req(conn); |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 78 | break; |
| 79 | } |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | static int paging_sig_cb(unsigned int subsys, unsigned int signal, |
| 84 | void *handler_data, void *signal_data) |
| 85 | { |
| 86 | struct paging_signal_data *psig_data = signal_data; |
| 87 | |
| 88 | switch (signal) { |
Sylvain Munaut | ef24dff | 2009-12-19 12:38:10 +0100 | [diff] [blame] | 89 | case S_PAGING_SUCCEEDED: |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 90 | /* A subscriber has attached. */ |
Holger Hans Peter Freyther | 86481c2 | 2010-06-17 15:05:57 +0800 | [diff] [blame] | 91 | send_rrlp_req(psig_data->conn); |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 92 | break; |
Sylvain Munaut | ef24dff | 2009-12-19 12:38:10 +0100 | [diff] [blame] | 93 | case S_PAGING_EXPIRED: |
| 94 | break; |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 95 | } |
| 96 | return 0; |
| 97 | } |
| 98 | |
| 99 | void on_dso_load_rrlp(void) |
| 100 | { |
Pablo Neira Ayuso | bbc5b99 | 2011-05-06 12:12:31 +0200 | [diff] [blame] | 101 | osmo_signal_register_handler(SS_SUBSCR, subscr_sig_cb, NULL); |
| 102 | osmo_signal_register_handler(SS_PAGING, paging_sig_cb, NULL); |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 103 | } |