Harald Welte | 52af195 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 1 | /* Radio Resource LCS (Location) Protocol, GMS TS 04.31 */ |
Harald Welte (local) | 9571378 | 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 | 0e3e88e | 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) | 9571378 | 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 | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 15 | * GNU Affero General Public License for more details. |
Harald Welte (local) | 9571378 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 16 | * |
Harald Welte | 0e3e88e | 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) | 9571378 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 19 | * |
| 20 | */ |
| 21 | |
| 22 | |
Harald Welte (local) | 9571378 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 23 | |
| 24 | #include <openbsc/gsm_04_08.h> |
| 25 | #include <openbsc/signal.h> |
| 26 | #include <openbsc/gsm_subscriber.h> |
Holger Hans Peter Freyther | d70da87 | 2009-10-22 15:42:19 +0200 | [diff] [blame] | 27 | #include <openbsc/chan_alloc.h> |
Harald Welte (local) | 9571378 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 28 | |
Harald Welte | 52af195 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 29 | /* RRLP msPositionReq, nsBased, |
| 30 | * Accuracy=60, Method=gps, ResponseTime=2, oneSet */ |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 31 | static const uint8_t ms_based_pos_req[] = { 0x40, 0x01, 0x78, 0xa8 }; |
Harald Welte (local) | 9571378 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 32 | |
Harald Welte | 52af195 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 33 | /* RRLP msPositionReq, msBasedPref, |
| 34 | Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */ |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 35 | static const uint8_t ms_pref_pos_req[] = { 0x40, 0x02, 0x79, 0x50 }; |
Harald Welte | 52af195 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 36 | |
| 37 | /* RRLP msPositionReq, msAssistedPref, |
| 38 | Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */ |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 39 | static const uint8_t ass_pref_pos_req[] = { 0x40, 0x03, 0x79, 0x50 }; |
Harald Welte | 52af195 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 40 | |
Holger Hans Peter Freyther | 92f1b2d | 2010-06-16 13:52:55 +0800 | [diff] [blame] | 41 | static int send_rrlp_req(struct gsm_subscriber_connection *conn) |
Harald Welte | 52af195 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 42 | { |
Holger Hans Peter Freyther | 92f1b2d | 2010-06-16 13:52:55 +0800 | [diff] [blame] | 43 | struct gsm_network *net = conn->bts->network; |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 44 | const uint8_t *req; |
Harald Welte | 52af195 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 45 | |
| 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 Freyther | 92f1b2d | 2010-06-16 13:52:55 +0800 | [diff] [blame] | 61 | return gsm48_send_rr_app_info(conn, 0x00, |
Harald Welte | 52af195 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 62 | sizeof(ms_based_pos_req), req); |
| 63 | } |
| 64 | |
Harald Welte (local) | 9571378 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 65 | static int subscr_sig_cb(unsigned int subsys, unsigned int signal, |
| 66 | void *handler_data, void *signal_data) |
| 67 | { |
| 68 | struct gsm_subscriber *subscr; |
Holger Hans Peter Freyther | 2f4af77 | 2010-06-16 13:23:55 +0800 | [diff] [blame] | 69 | struct gsm_subscriber_connection *conn; |
Harald Welte (local) | 9571378 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 70 | |
| 71 | switch (signal) { |
| 72 | case S_SUBSCR_ATTACHED: |
| 73 | /* A subscriber has attached. */ |
| 74 | subscr = signal_data; |
Holger Hans Peter Freyther | 2f4af77 | 2010-06-16 13:23:55 +0800 | [diff] [blame] | 75 | conn = connection_for_subscr(subscr); |
| 76 | if (!conn) |
Harald Welte (local) | 9571378 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 77 | break; |
Holger Hans Peter Freyther | 92f1b2d | 2010-06-16 13:52:55 +0800 | [diff] [blame] | 78 | send_rrlp_req(conn); |
Harald Welte (local) | 9571378 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 79 | break; |
| 80 | } |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | static 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 Munaut | 4ff936f | 2009-12-19 12:38:10 +0100 | [diff] [blame] | 90 | case S_PAGING_SUCCEEDED: |
Harald Welte (local) | 9571378 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 91 | /* A subscriber has attached. */ |
Holger Hans Peter Freyther | d3aaf66 | 2010-06-17 15:05:57 +0800 | [diff] [blame] | 92 | send_rrlp_req(psig_data->conn); |
Harald Welte (local) | 9571378 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 93 | break; |
Sylvain Munaut | 4ff936f | 2009-12-19 12:38:10 +0100 | [diff] [blame] | 94 | case S_PAGING_EXPIRED: |
| 95 | break; |
Harald Welte (local) | 9571378 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 96 | } |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | void on_dso_load_rrlp(void) |
| 101 | { |
Pablo Neira Ayuso | ef717c6 | 2011-05-06 12:12:31 +0200 | [diff] [blame] | 102 | osmo_signal_register_handler(SS_SUBSCR, subscr_sig_cb, NULL); |
| 103 | osmo_signal_register_handler(SS_PAGING, paging_sig_cb, NULL); |
Harald Welte (local) | 9571378 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 104 | } |