From 36650b872fe9f125bc1a96b768d54407909a262b Mon Sep 17 00:00:00 2001 From: Holger Freyther Date: Sun, 19 Apr 2009 06:35:16 +0000 Subject: [PATCH] [db] Keep track of the current gsm_network --- include/openbsc/db.h | 2 +- src/bsc_hack.c | 2 +- src/db.c | 4 +++- tests/db/db_test.c | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/openbsc/db.h b/include/openbsc/db.h index 61a3ac47c..203683257 100644 --- a/include/openbsc/db.h +++ b/include/openbsc/db.h @@ -26,7 +26,7 @@ #include /* one time initialisation */ -int db_init(const char *name); +int db_init(const char *name, struct gsm_network *network); int db_prepare(); int db_fini(); diff --git a/src/bsc_hack.c b/src/bsc_hack.c index 3fbc7f645..8bc1c6b95 100644 --- a/src/bsc_hack.c +++ b/src/bsc_hack.c @@ -916,7 +916,7 @@ static int bootstrap_network(void) paging_init(bts); bts->paging.channel_allocated = bsc_hack_channel_allocated; - if (db_init(database_name)) { + if (db_init(database_name, gsmnet)) { printf("DB: Failed to init database. Please check the option settings.\n"); return -1; } diff --git a/src/db.c b/src/db.c index a761364fd..9c4c3784d 100644 --- a/src/db.c +++ b/src/db.c @@ -32,6 +32,7 @@ static char *db_basename = NULL; static char *db_dirname = NULL; dbi_conn conn; +static struct gsm_network *current_network = NULL; static char *create_stmts[] = { "CREATE TABLE IF NOT EXISTS Meta (" @@ -86,7 +87,7 @@ void db_error_func(dbi_conn conn, void* data) { printf("DBI: %s\n", msg); } -int db_init(const char *name) { +int db_init(const char *name, struct gsm_network *network) { dbi_initialize(NULL); conn = dbi_conn_new("sqlite3"); if (conn==NULL) { @@ -117,6 +118,7 @@ int db_init(const char *name) { return 1; } + current_network = network; return 0; } diff --git a/tests/db/db_test.c b/tests/db/db_test.c index 2ccf243d6..93bf15235 100644 --- a/tests/db/db_test.c +++ b/tests/db/db_test.c @@ -50,7 +50,7 @@ int main() { - if (db_init("hlr.sqlite3")) { + if (db_init("hlr.sqlite3", NULL)) { printf("DB: Failed to init database. Please check the option settings.\n"); return 1; }