Jonathan Santos | 03fd8d0 | 2011-05-25 13:54:02 -0400 | [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 |
| 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 |
| 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 | * |
| 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/>. |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | #include <stdio.h> |
| 21 | #include <stdlib.h> |
| 22 | |
| 23 | #include <assert.h> |
| 24 | |
| 25 | #include <osmocore/select.h> |
| 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 | |
| 48 | int main(int argc, char **argv) |
| 49 | { |
| 50 | struct gsm_network *network; |
| 51 | struct gsm_bts *bts; |
| 52 | |
| 53 | printf("Testing the gsm_subscriber chan logic\n"); |
| 54 | |
| 55 | /* Create a dummy network */ |
| 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; |
| 61 | |
| 62 | /* Create a dummy subscriber */ |
| 63 | struct gsm_subscriber *subscr = subscr_alloc(); |
| 64 | subscr->lac = 23; |
| 65 | subscr->net = network; |
| 66 | |
| 67 | /* Ask for a channel... */ |
| 68 | subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L); |
| 69 | |
| 70 | while (1) { |
| 71 | bsc_select_main(0); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | void _abis_nm_sendmsg() {} |
| 76 | void sms_alloc() {} |
| 77 | void gsm_net_update_ctype(struct gsm_network *network) {} |
| 78 | void gsm48_secure_channel() {} |
| 79 | void paging_request_stop() {} |
| 80 | void vty_out() {} |
| 81 | |
| 82 | |
| 83 | struct tlv_definition nm_att_tlvdef; |
| 84 | |