Holger Hans Peter Freyther | f8584a1 | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 6 | * it under the terms of the GNU Affero General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
Holger Hans Peter Freyther | f8584a1 | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 15 | * You should have received a copy of the GNU Affero General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Holger Hans Peter Freyther | f8584a1 | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 17 | * |
| 18 | */ |
| 19 | |
| 20 | #include <stdio.h> |
Harald Welte | cd1c428 | 2009-06-26 20:30:46 +0200 | [diff] [blame] | 21 | #include <stdlib.h> |
Holger Hans Peter Freyther | f8584a1 | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 22 | |
| 23 | #include <assert.h> |
| 24 | |
Pablo Neira Ayuso | dd5fff4 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 25 | #include <osmocom/core/select.h> |
Holger Hans Peter Freyther | f8584a1 | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 26 | #include <openbsc/gsm_subscriber.h> |
| 27 | #include <openbsc/abis_rsl.h> |
| 28 | |
| 29 | /* our handler */ |
| 30 | static int subscr_cb(unsigned int hook, unsigned int event, struct msgb *msg, void *data, void *param) |
| 31 | { |
| 32 | assert(hook == 101); |
| 33 | assert(event == 200); |
| 34 | assert(msg == (void*)0x1323L); |
| 35 | assert(data == (void*)0x4242L); |
| 36 | assert(param == (void*)0x2342L); |
| 37 | printf("Reached, didn't crash, test passed\n"); |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | /* mock object for testing, directly invoke the cb... maybe later through the timer */ |
| 42 | void paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscriber, int type, gsm_cbfn *cbfn, void *data) |
| 43 | { |
| 44 | cbfn(101, 200, (void*)0x1323L, (void*)0x4242L, data); |
| 45 | } |
| 46 | |
| 47 | |
Holger Hans Peter Freyther | dfd61a3 | 2010-09-18 06:44:24 +0800 | [diff] [blame] | 48 | int main(int argc, char **argv) |
Holger Hans Peter Freyther | f8584a1 | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 49 | { |
Harald Welte | cd1c428 | 2009-06-26 20:30:46 +0200 | [diff] [blame] | 50 | struct gsm_network *network; |
| 51 | struct gsm_bts *bts; |
Holger Hans Peter Freyther | f8584a1 | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 52 | |
| 53 | printf("Testing the gsm_subscriber chan logic\n"); |
| 54 | |
| 55 | /* Create a dummy network */ |
Harald Welte | cd1c428 | 2009-06-26 20:30:46 +0200 | [diff] [blame] | 56 | network = gsm_network_init(1, 1, NULL); |
| 57 | if (!network) |
| 58 | exit(1); |
| 59 | bts = gsm_bts_alloc(network, GSM_BTS_TYPE_BS11, 0, 0); |
| 60 | bts->location_area_code = 23; |
Holger Hans Peter Freyther | f8584a1 | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 61 | |
| 62 | /* Create a dummy subscriber */ |
| 63 | struct gsm_subscriber *subscr = subscr_alloc(); |
| 64 | subscr->lac = 23; |
Holger Hans Peter Freyther | 3567284 | 2009-08-20 13:33:51 +0200 | [diff] [blame] | 65 | subscr->net = network; |
Holger Hans Peter Freyther | f8584a1 | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 66 | |
| 67 | /* Ask for a channel... */ |
Holger Hans Peter Freyther | 3567284 | 2009-08-20 13:33:51 +0200 | [diff] [blame] | 68 | subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L); |
Holger Hans Peter Freyther | f8584a1 | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 69 | |
| 70 | while (1) { |
| 71 | bsc_select_main(0); |
| 72 | } |
| 73 | } |
| 74 | |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 75 | void _abis_nm_sendmsg() {} |
Holger Hans Peter Freyther | d035eec | 2009-08-10 06:40:05 +0200 | [diff] [blame] | 76 | void sms_alloc() {} |
Holger Hans Peter Freyther | f0f37f1 | 2010-09-06 09:36:02 +0800 | [diff] [blame] | 77 | void gsm_net_update_ctype(struct gsm_network *network) {} |
Holger Hans Peter Freyther | 1860583 | 2010-12-21 13:43:52 +0100 | [diff] [blame] | 78 | void gsm48_secure_channel() {} |
Holger Hans Peter Freyther | a32e9c1 | 2010-12-28 17:47:43 +0100 | [diff] [blame] | 79 | void paging_request_stop() {} |
Holger Hans Peter Freyther | 0fe0c8c | 2010-12-29 11:07:22 +0100 | [diff] [blame] | 80 | void vty_out() {} |
Holger Hans Peter Freyther | 1860583 | 2010-12-21 13:43:52 +0100 | [diff] [blame] | 81 | |
Holger Hans Peter Freyther | f8584a1 | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 82 | |
Holger Hans Peter Freyther | 648879c | 2010-01-11 16:42:07 +0100 | [diff] [blame] | 83 | struct tlv_definition nm_att_tlvdef; |
| 84 | |