blob: 27ddbab0b64082b6a958b1aad2372cb3b9c04191 [file] [log] [blame]
Jan Luebbefaaa49c2008-12-27 01:07:07 +00001/* (C) 2008 by Jan Luebbe <jluebbe@debian.org>
2 * All Rights Reserved
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19
20#include <openbsc/db.h>
Jan Luebbe7398eb92008-12-27 00:45:41 +000021
22#include <stdio.h>
Jan Luebbe5c15c852008-12-27 15:59:25 +000023#include <string.h>
Jan Luebbe7398eb92008-12-27 00:45:41 +000024
25int main() {
26
Jan Luebbe5c15c852008-12-27 15:59:25 +000027 if (db_init()) {
28 printf("DB: Failed to init database. Please check the option settings.\n");
29 return 1;
30 }
31 printf("DB: Database initialized.\n");
Jan Luebbe7398eb92008-12-27 00:45:41 +000032
Jan Luebbe5c15c852008-12-27 15:59:25 +000033 if (db_prepare()) {
34 printf("DB: Failed to prepare database.\n");
35 return 1;
36 }
37 printf("DB: Database prepared.\n");
Jan Luebbe7398eb92008-12-27 00:45:41 +000038
Jan Luebbe5c15c852008-12-27 15:59:25 +000039 struct gsm_subscriber *alice = NULL;
Jan Luebbe7398eb92008-12-27 00:45:41 +000040
Jan Luebbe5c15c852008-12-27 15:59:25 +000041 alice = db_create_subscriber("3243245432345");
Jan Luebbe5c15c852008-12-27 15:59:25 +000042 db_set_subscriber(alice);
43 db_get_subscriber(GSM_SUBSCRIBER_IMSI, alice);
44 free(alice);
Jan Luebbe7398eb92008-12-27 00:45:41 +000045
Jan Luebbe5c15c852008-12-27 15:59:25 +000046 alice = db_create_subscriber("3693245423445");
Jan Luebbe391d86e2008-12-27 22:33:34 +000047 db_subscriber_assoc_imei(alice, "1234567890");
Jan Luebbe5c15c852008-12-27 15:59:25 +000048 db_subscriber_alloc_tmsi(alice);
49 alice->lac=42;
50 db_set_subscriber(alice);
51 db_get_subscriber(GSM_SUBSCRIBER_IMSI, alice);
52 free(alice);
Jan Luebbe7398eb92008-12-27 00:45:41 +000053
Jan Luebbe5c15c852008-12-27 15:59:25 +000054 alice = db_create_subscriber("9993245423445");
55 db_subscriber_alloc_tmsi(alice);
56 alice->lac=42;
57 db_set_subscriber(alice);
Jan Luebbefac25fc2008-12-27 18:04:34 +000058 db_subscriber_assoc_imei(alice, "1234567890");
59 db_subscriber_assoc_imei(alice, "6543560920");
Jan Luebbe5c15c852008-12-27 15:59:25 +000060 db_get_subscriber(GSM_SUBSCRIBER_IMSI, alice);
61 free(alice);
62
63 db_fini();
64
65 return 0;
Jan Luebbe7398eb92008-12-27 00:45:41 +000066}