This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Max gerrit-no-reply at lists.osmocom.orgHello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1856 to look at the new patch set (#4). Add global HLR struct Introduce g_hlr of type 'struct hlr' which holds pointers to all globally accessible variables. Change-Id: I275d3d54482f696e3378606b2406c7e0ad939e0f Related: OS#1645 --- M src/db_test.c M src/hlr.c M src/hlr.h 3 files changed, 37 insertions(+), 24 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/56/1856/4 diff --git a/src/db_test.c b/src/db_test.c index 75fcb62..998a37a 100644 --- a/src/db_test.c +++ b/src/db_test.c @@ -4,12 +4,13 @@ #include <osmocom/core/application.h> #include "db.h" +#include "hlr.h" #include "rand.h" #include "logging.h" -static struct db_context *g_dbc; +static struct hlr *g_hlr; -static int test(const char *imsi) +static int test(const char *imsi, struct db_context *dbc) { struct osmo_auth_vector vec[3]; int rc, i; @@ -19,7 +20,7 @@ for (i = 0; i < ARRAY_SIZE(vec); i++) vec[i].res_len = 0; - rc = db_get_auc(g_dbc, imsi, vec, ARRAY_SIZE(vec), NULL, NULL); + rc = db_get_auc(dbc, imsi, vec, ARRAY_SIZE(vec), NULL, NULL); if (rc <= 0) { LOGP(DMAIN, LOGL_ERROR, "Cannot obtain auth tuples for '%s'\n", imsi); return rc; @@ -46,6 +47,8 @@ { int rc; + g_hlr = talloc_zero(NULL, struct hlr); + rc = osmo_init_logging(&hlr_log_info); if (rc < 0) { fprintf(stderr, "Error initializing logging\n"); @@ -59,24 +62,24 @@ exit(1); } - g_dbc = db_open(NULL, "hlr.db"); - if (!g_dbc) { + g_hlr->dbc = db_open(NULL, "hlr.db"); + if (!g_hlr->dbc) { LOGP(DMAIN, LOGL_ERROR, "Error opening database\n"); exit(1); } /* non-existing subscriber */ - rc = test("901990123456789"); + rc = test("901990123456789", g_hlr->dbc); /* 2G only AUC data (COMP128v1 / MILENAGE) */ - rc = test("901990000000001"); + rc = test("901990000000001", g_hlr->dbc); /* 2G + 3G AUC data (COMP128v1 / MILENAGE) */ - rc = test("901990000000002"); + rc = test("901990000000002", g_hlr->dbc); /* 3G AUC data (MILENAGE) */ - rc = test("901990000000003"); + rc = test("901990000000003", g_hlr->dbc); LOGP(DMAIN, LOGL_NOTICE, "Exiting\n"); - db_close(g_dbc); + db_close(g_hlr->dbc); log_fini(); diff --git a/src/hlr.c b/src/hlr.c index 5c59b88..2bc3125 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -42,7 +42,7 @@ #include "luop.h" #include "hlr_vty.h" -static struct db_context *g_dbc; +static struct hlr *g_hlr; /*********************************************************************** * Send Auth Info handling @@ -50,7 +50,8 @@ /* process an incoming SAI request */ static int rx_send_auth_info(struct osmo_gsup_conn *conn, - const struct osmo_gsup_message *gsup) + const struct osmo_gsup_message *gsup, + struct db_context *dbc) { struct osmo_gsup_message gsup_out; struct msgb *msg_out; @@ -60,7 +61,7 @@ memset(&gsup_out, 0, sizeof(gsup_out)); memcpy(&gsup_out.imsi, &gsup->imsi, sizeof(gsup_out.imsi)); - rc = db_get_auc(g_dbc, gsup->imsi, gsup_out.auth_vectors, + rc = db_get_auc(dbc, gsup->imsi, gsup_out.auth_vectors, ARRAY_SIZE(gsup_out.auth_vectors), gsup->rand, gsup->auts); if (rc < 0) { @@ -158,7 +159,7 @@ /* Roughly follwing "Process Update_Location_HLR" of TS 09.02 */ /* check if subscriber is known at all */ - if (!lu_op_fill_subscr(luop, g_dbc, gsup->imsi)) { + if (!lu_op_fill_subscr(luop, g_hlr->dbc, gsup->imsi)) { /* Send Error back: Subscriber Unknown in HLR */ strcpy(luop->subscr.imsi, gsup->imsi); lu_op_tx_error(luop, GMM_CAUSE_IMSI_UNKNOWN); @@ -217,7 +218,7 @@ * we have on record. Only update if yes */ /* Perform the actual update of the DB */ - rc = db_subscr_purge(g_dbc, gsup->imsi, is_ps); + rc = db_subscr_purge(g_hlr->dbc, gsup->imsi, is_ps); if (rc == 1) gsup_reply.message_type = OSMO_GSUP_MSGT_PURGE_MS_RESULT; @@ -248,7 +249,7 @@ switch (gsup.message_type) { /* requests sent to us */ case OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST: - rx_send_auth_info(conn, &gsup); + rx_send_auth_info(conn, &gsup, g_hlr->dbc); break; case OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST: rx_upd_loc_req(conn, &gsup); @@ -363,15 +364,14 @@ } static void *hlr_ctx = NULL; -static struct osmo_gsup_server *gs; static void signal_hdlr(int signal) { switch (signal) { case SIGINT: LOGP(DMAIN, LOGL_NOTICE, "Terminating due to SIGINT\n"); - osmo_gsup_server_destroy(gs); - db_close(g_dbc); + osmo_gsup_server_destroy(g_hlr->gs); + db_close(g_hlr->dbc); log_fini(); talloc_report_full(hlr_ctx, stderr); exit(0); @@ -397,6 +397,7 @@ hlr_ctx = talloc_named_const(NULL, 1, "OsmoHLR"); msgb_talloc_ctx_init(hlr_ctx, 0); + g_hlr = talloc_zero(hlr_ctx, struct hlr); c_opts = talloc_zero(hlr_ctx, struct cmdline_opts); c_opts->config_file = "osmo-hlr.cfg"; @@ -434,14 +435,14 @@ exit(1); } - g_dbc = db_open(hlr_ctx, c_opts->db_file); - if (!g_dbc) { + g_hlr->dbc = db_open(hlr_ctx, c_opts->db_file); + if (!g_hlr->dbc) { LOGP(DMAIN, LOGL_FATAL, "Error opening database\n"); exit(1); } - gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); - if (!gs) { + g_hlr->gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb); + if (!g_hlr->gs) { LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n"); exit(1); } @@ -462,7 +463,7 @@ osmo_select_main(0); } - db_close(g_dbc); + db_close(g_hlr->dbc); log_fini(); diff --git a/src/hlr.h b/src/hlr.h index 23e7188..6d7a436 100644 --- a/src/hlr.h +++ b/src/hlr.h @@ -1,6 +1,7 @@ /* OsmoHLR generic header */ /* (C) 2016 by Harald Welte <laforge at gnumonks.org> + * (C) 2017 sysmocom s.f.m.c. GmbH <info at sysmocom.de> * All Rights Reserved * * Author: Max Suraev <msuraev at sysmocom.de> @@ -29,3 +30,11 @@ const char *db_file; bool daemonize; }; + +struct hlr { + /* GSUP server pointer */ + struct osmo_gsup_server *gs; + + /* DB context */ + struct db_context *dbc; +}; -- To view, visit https://gerrit.osmocom.org/1856 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I275d3d54482f696e3378606b2406c7e0ad939e0f Gerrit-PatchSet: 4 Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Owner: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>