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 |
| 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 Freyther | 8b77a34 | 2009-10-22 15:42:19 +0200 | [diff] [blame] | 29 | #include <openbsc/chan_alloc.h> |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 30 | |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 31 | /* RRLP msPositionReq, nsBased, |
| 32 | * Accuracy=60, Method=gps, ResponseTime=2, oneSet */ |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 33 | static const u_int8_t ms_based_pos_req[] = { 0x40, 0x01, 0x78, 0xa8 }; |
| 34 | |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 35 | /* RRLP msPositionReq, msBasedPref, |
| 36 | Accuracy=60, Method=gpsOrEOTD, ResponseTime=5, multipleSets */ |
| 37 | static 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 */ |
| 41 | static const u_int8_t ass_pref_pos_req[] = { 0x40, 0x03, 0x79, 0x50 }; |
| 42 | |
Holger Hans Peter Freyther | 9ce1b27 | 2010-06-16 13:52:55 +0800 | [diff] [blame] | 43 | static int send_rrlp_req(struct gsm_subscriber_connection *conn) |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 44 | { |
Holger Hans Peter Freyther | 9ce1b27 | 2010-06-16 13:52:55 +0800 | [diff] [blame] | 45 | struct gsm_network *net = conn->bts->network; |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 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 | |
Holger Hans Peter Freyther | 9ce1b27 | 2010-06-16 13:52:55 +0800 | [diff] [blame] | 63 | return gsm48_send_rr_app_info(conn, 0x00, |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 64 | sizeof(ms_based_pos_req), req); |
| 65 | } |
| 66 | |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 67 | static int subscr_sig_cb(unsigned int subsys, unsigned int signal, |
| 68 | void *handler_data, void *signal_data) |
| 69 | { |
| 70 | struct gsm_subscriber *subscr; |
Holger Hans Peter Freyther | b2be195 | 2010-06-16 13:23:55 +0800 | [diff] [blame] | 71 | struct gsm_subscriber_connection *conn; |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 72 | |
| 73 | switch (signal) { |
| 74 | case S_SUBSCR_ATTACHED: |
| 75 | /* A subscriber has attached. */ |
| 76 | subscr = signal_data; |
Holger Hans Peter Freyther | b2be195 | 2010-06-16 13:23:55 +0800 | [diff] [blame] | 77 | conn = connection_for_subscr(subscr); |
| 78 | if (!conn) |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 79 | break; |
Holger Hans Peter Freyther | 9ce1b27 | 2010-06-16 13:52:55 +0800 | [diff] [blame] | 80 | send_rrlp_req(conn); |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 81 | break; |
| 82 | } |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | static 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 Munaut | ef24dff | 2009-12-19 12:38:10 +0100 | [diff] [blame] | 92 | case S_PAGING_SUCCEEDED: |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 93 | /* A subscriber has attached. */ |
Holger Hans Peter Freyther | 9ce1b27 | 2010-06-16 13:52:55 +0800 | [diff] [blame] | 94 | send_rrlp_req(&psig_data->lchan->conn); |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 95 | break; |
Sylvain Munaut | ef24dff | 2009-12-19 12:38:10 +0100 | [diff] [blame] | 96 | case S_PAGING_EXPIRED: |
| 97 | break; |
Harald Welte (local) | b8afe81 | 2009-08-16 13:18:51 +0200 | [diff] [blame] | 98 | } |
| 99 | return 0; |
| 100 | } |
| 101 | |
| 102 | void 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 | } |