aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Freyther <zecke@selfish.org>2009-04-19 06:35:16 +0000
committerHolger Freyther <zecke@selfish.org>2009-04-19 06:35:16 +0000
commit36650b872fe9f125bc1a96b768d54407909a262b (patch)
treef3a649d7acc5a33682066d386930fb5b305ab596
parentef7f7ce45219328e044479101aae732ac3979521 (diff)
[db] Keep track of the current gsm_network
-rw-r--r--include/openbsc/db.h2
-rw-r--r--src/bsc_hack.c2
-rw-r--r--src/db.c4
-rw-r--r--tests/db/db_test.c2
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 <openbsc/gsm_subscriber.h>
/* 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;
}