Jonathan Santos | 03fd8d0 | 2011-05-25 13:54:02 -0400 | [diff] [blame] | 1 | /* 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 | |
Jonathan Santos | 03fd8d0 | 2011-05-25 13:54:02 -0400 | [diff] [blame] | 23 | |
| 24 | #include <openbsc/gsm_04_08.h> |
| 25 | #include <openbsc/signal.h> |
| 26 | #include <openbsc/gsm_subscriber.h> |
| 27 | #include <openbsc/chan_alloc.h> |
| 28 | |
| 29 | /* RRLP msPositionReq, nsBased, |
| 30 | * Accuracy=60, Method=gps, ResponseTime=2, oneSet */ |
Jonathan Santos | 5a45b15 | 2011-08-17 15:33:57 -0400 | [diff] [blame^] | 31 | static const uint8_t ms_based_pos_req[] = { 0x40, 0x01, 0x78, 0xa8 }; |
Jonathan Santos | 03fd8d0 | 2011-05-25 13:54:02 -0400 | [diff] [blame] | 32 | |
| 33 | /* RRLP msPositionReq, msBasedPref, |
| 34 | Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */ |
Jonathan Santos | 5a45b15 | 2011-08-17 15:33:57 -0400 | [diff] [blame^] | 35 | static const uint8_t ms_pref_pos_req[] = { 0x40, 0x02, 0x79, 0x50 }; |
Jonathan Santos | 03fd8d0 | 2011-05-25 13:54:02 -0400 | [diff] [blame] | 36 | |
| 37 | /* RRLP msPositionReq, msAssistedPref, |
| 38 | Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */ |
Jonathan Santos | 5a45b15 | 2011-08-17 15:33:57 -0400 | [diff] [blame^] | 39 | static const uint8_t ass_pref_pos_req[] = { 0x40, 0x03, 0x79, 0x50 }; |
Jonathan Santos | 03fd8d0 | 2011-05-25 13:54:02 -0400 | [diff] [blame] | 40 | |
| 41 | static int send_rrlp_req(struct gsm_subscriber_connection *conn) |
| 42 | { |
| 43 | struct gsm_network *net = conn->bts->network; |
Jonathan Santos | 5a45b15 | 2011-08-17 15:33:57 -0400 | [diff] [blame^] | 44 | const uint8_t *req; |
Jonathan Santos | 03fd8d0 | 2011-05-25 13:54:02 -0400 | [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 | |
| 61 | return gsm48_send_rr_app_info(conn, 0x00, |
| 62 | sizeof(ms_based_pos_req), req); |
| 63 | } |
| 64 | |
| 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; |
| 69 | struct gsm_subscriber_connection *conn; |
| 70 | |
| 71 | switch (signal) { |
| 72 | case S_SUBSCR_ATTACHED: |
| 73 | /* A subscriber has attached. */ |
| 74 | subscr = signal_data; |
| 75 | conn = connection_for_subscr(subscr); |
| 76 | if (!conn) |
| 77 | break; |
| 78 | send_rrlp_req(conn); |
| 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) { |
| 90 | case S_PAGING_SUCCEEDED: |
| 91 | /* A subscriber has attached. */ |
| 92 | send_rrlp_req(psig_data->conn); |
| 93 | break; |
| 94 | case S_PAGING_EXPIRED: |
| 95 | break; |
| 96 | } |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | void on_dso_load_rrlp(void) |
| 101 | { |
Jonathan Santos | 5a45b15 | 2011-08-17 15:33:57 -0400 | [diff] [blame^] | 102 | osmo_signal_register_handler(SS_SUBSCR, subscr_sig_cb, NULL); |
| 103 | osmo_signal_register_handler(SS_PAGING, paging_sig_cb, NULL); |
Jonathan Santos | 03fd8d0 | 2011-05-25 13:54:02 -0400 | [diff] [blame] | 104 | } |