blob: d74d9fb9986d0d23fa01088765a9e517940e605d [file] [log] [blame]
Harald Welte936f6722016-05-03 18:51:18 +02001/* (C) 2016 by Harald Welte <laforge@gnumonks.org>
2 *
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 Affero 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
Harald Welteaabae9e2016-04-28 12:48:14 +020020#include <signal.h>
Harald Weltee687be52016-05-03 18:49:27 +020021#include <errno.h>
Maxea8b0d42017-02-14 16:53:04 +010022#include <stdbool.h>
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +010023#include <getopt.h>
24
Harald Weltee72cf552016-04-28 07:18:49 +020025#include <osmocom/core/msgb.h>
26#include <osmocom/core/logging.h>
27#include <osmocom/core/application.h>
28#include <osmocom/gsm/gsup.h>
Max2fc63a62016-12-20 16:49:20 +010029#include <osmocom/gsm/apn.h>
Neels Hofmeyr627de842016-12-19 13:16:06 +010030#include <osmocom/gsm/gsm48_ie.h>
Neels Hofmeyr7685a782017-01-30 23:30:26 +010031#include <osmocom/vty/vty.h>
32#include <osmocom/vty/command.h>
33#include <osmocom/vty/telnet_interface.h>
34#include <osmocom/vty/ports.h>
Harald Weltee72cf552016-04-28 07:18:49 +020035
36#include "db.h"
37#include "logging.h"
38#include "gsup_server.h"
Harald Weltee687be52016-05-03 18:49:27 +020039#include "gsup_router.h"
Harald Weltee72cf552016-04-28 07:18:49 +020040#include "rand.h"
Maxea8b0d42017-02-14 16:53:04 +010041#include "luop.h"
Neels Hofmeyr7685a782017-01-30 23:30:26 +010042#include "hlr_vty.h"
Harald Weltee72cf552016-04-28 07:18:49 +020043
44static struct db_context *g_dbc;
45
Harald Weltee687be52016-05-03 18:49:27 +020046/***********************************************************************
47 * Send Auth Info handling
48 ***********************************************************************/
49
Harald Weltee72cf552016-04-28 07:18:49 +020050/* process an incoming SAI request */
51static int rx_send_auth_info(struct osmo_gsup_conn *conn,
52 const struct osmo_gsup_message *gsup)
53{
54 struct osmo_gsup_message gsup_out;
55 struct msgb *msg_out;
56 int rc;
57
58 /* initialize return message structure */
59 memset(&gsup_out, 0, sizeof(gsup_out));
Harald Weltee72cf552016-04-28 07:18:49 +020060 memcpy(&gsup_out.imsi, &gsup->imsi, sizeof(gsup_out.imsi));
61
62 rc = db_get_auc(g_dbc, gsup->imsi, gsup_out.auth_vectors,
63 ARRAY_SIZE(gsup_out.auth_vectors),
Harald Welte9be0d2f2016-06-10 17:34:02 +020064 gsup->rand, gsup->auts);
Harald Weltecfc752b2016-05-05 16:38:14 +020065 if (rc < 0) {
Harald Weltee72cf552016-04-28 07:18:49 +020066 gsup_out.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR;
Harald Weltecfc752b2016-05-05 16:38:14 +020067 gsup_out.cause = GMM_CAUSE_NET_FAIL;
68 } else if (rc == 0) {
69 gsup_out.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR;
70 gsup_out.cause = GMM_CAUSE_IMSI_UNKNOWN;
Harald Welte15db8262016-05-05 16:50:39 +020071 } else {
72 gsup_out.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT;
73 gsup_out.num_auth_vectors = rc;
Harald Weltee72cf552016-04-28 07:18:49 +020074 }
75
Harald Weltee687be52016-05-03 18:49:27 +020076 msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP AUC response");
Harald Weltee72cf552016-04-28 07:18:49 +020077 osmo_gsup_encode(msg_out, &gsup_out);
78 return osmo_gsup_conn_send(conn, msg_out);
79}
80
Harald Weltee687be52016-05-03 18:49:27 +020081/***********************************************************************
82 * LU Operation State / Structure
83 ***********************************************************************/
84
85static LLIST_HEAD(g_lu_ops);
86
Harald Weltee687be52016-05-03 18:49:27 +020087/*! Receive Cancel Location Result from old VLR/SGSN */
88void lu_op_rx_cancel_old_ack(struct lu_operation *luop,
Maxea8b0d42017-02-14 16:53:04 +010089 const struct osmo_gsup_message *gsup)
Harald Weltee687be52016-05-03 18:49:27 +020090{
91 OSMO_ASSERT(luop->state == LU_S_CANCEL_SENT);
92 /* FIXME: Check for spoofing */
93
94 osmo_timer_del(&luop->timer);
95
96 /* FIXME */
97
98 lu_op_tx_insert_subscr_data(luop);
99}
100
Harald Weltee687be52016-05-03 18:49:27 +0200101/*! Receive Insert Subscriber Data Result from new VLR/SGSN */
102static void lu_op_rx_insert_subscr_data_ack(struct lu_operation *luop,
103 const struct osmo_gsup_message *gsup)
104{
105 OSMO_ASSERT(luop->state == LU_S_ISD_SENT);
106 /* FIXME: Check for spoofing */
107
108 osmo_timer_del(&luop->timer);
109
110 /* Subscriber_Present_HLR */
111 /* CS only: Check_SS_required? -> MAP-FW-CHECK_SS_IND.req */
112
113 /* Send final ACK towards inquiring VLR/SGSN */
114 lu_op_tx_ack(luop);
115}
116
117/*! Receive GSUP message for given \ref lu_operation */
118void lu_op_rx_gsup(struct lu_operation *luop,
119 const struct osmo_gsup_message *gsup)
120{
121 switch (gsup->message_type) {
122 case OSMO_GSUP_MSGT_INSERT_DATA_ERROR:
123 /* FIXME */
124 break;
125 case OSMO_GSUP_MSGT_INSERT_DATA_RESULT:
126 lu_op_rx_insert_subscr_data_ack(luop, gsup);
127 break;
128 case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR:
129 /* FIXME */
130 break;
131 case OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT:
132 lu_op_rx_cancel_old_ack(luop, gsup);
133 break;
134 default:
135 LOGP(DMAIN, LOGL_ERROR, "Unhandled GSUP msg_type 0x%02x\n",
136 gsup->message_type);
137 break;
138 }
139}
140
Harald Weltee687be52016-05-03 18:49:27 +0200141/*! Receive Update Location Request, creates new \ref lu_operation */
142static int rx_upd_loc_req(struct osmo_gsup_conn *conn,
143 const struct osmo_gsup_message *gsup)
144{
Maxea8b0d42017-02-14 16:53:04 +0100145 struct lu_operation *luop = lu_op_alloc_conn(conn);
146 if (!luop) {
Harald Weltee687be52016-05-03 18:49:27 +0200147 LOGP(DMAIN, LOGL_ERROR, "LU REQ from conn without addr?\n");
Maxea8b0d42017-02-14 16:53:04 +0100148 return -EINVAL;
Harald Weltee687be52016-05-03 18:49:27 +0200149 }
150
Harald Weltee687be52016-05-03 18:49:27 +0200151 lu_op_statechg(luop, LU_S_LU_RECEIVED);
Maxea8b0d42017-02-14 16:53:04 +0100152
Harald Weltee687be52016-05-03 18:49:27 +0200153 if (gsup->cn_domain == OSMO_GSUP_CN_DOMAIN_PS)
154 luop->is_ps = true;
155 llist_add(&luop->list, &g_lu_ops);
156
157 /* Roughly follwing "Process Update_Location_HLR" of TS 09.02 */
158
159 /* check if subscriber is known at all */
Maxea8b0d42017-02-14 16:53:04 +0100160 if (!lu_op_fill_subscr(luop, g_dbc, gsup->imsi)) {
Harald Weltee687be52016-05-03 18:49:27 +0200161 /* Send Error back: Subscriber Unknown in HLR */
162 strcpy(luop->subscr.imsi, gsup->imsi);
163 lu_op_tx_error(luop, GMM_CAUSE_IMSI_UNKNOWN);
164 return 0;
165 }
166
Harald Welte99909272016-05-05 18:24:15 +0200167 /* Check if subscriber is generally permitted on CS or PS
168 * service (as requested) */
Maxea8b0d42017-02-14 16:53:04 +0100169 if (!luop->is_ps && !luop->subscr.nam_cs) {
Harald Weltee687be52016-05-03 18:49:27 +0200170 lu_op_tx_error(luop, GMM_CAUSE_PLMN_NOTALLOWED);
171 return 0;
Maxea8b0d42017-02-14 16:53:04 +0100172 } else if (luop->is_ps && !luop->subscr.nam_ps) {
Harald Weltee687be52016-05-03 18:49:27 +0200173 lu_op_tx_error(luop, GMM_CAUSE_GPRS_NOTALLOWED);
174 return 0;
175 }
176
177 /* TODO: Set subscriber tracing = deactive in VLR/SGSN */
178
179#if 0
180 /* Cancel in old VLR/SGSN, if new VLR/SGSN differs from old */
181 if (luop->is_ps == false &&
182 strcmp(subscr->vlr_number, vlr_number)) {
Harald Weltee687be52016-05-03 18:49:27 +0200183 lu_op_tx_cancel_old(luop);
184 } else if (luop->is_ps == true &&
185 strcmp(subscr->sgsn_number, sgsn_number)) {
Harald Weltee687be52016-05-03 18:49:27 +0200186 lu_op_tx_cancel_old(luop);
187 } else
188#endif
189 {
190 /* TODO: Subscriber allowed to roam in PLMN? */
191 /* TODO: Update RoutingInfo */
192 /* TODO: Reset Flag MS Purged (cs/ps) */
193 /* TODO: Control_Tracing_HLR / Control_Tracing_HLR_with_SGSN */
194 lu_op_tx_insert_subscr_data(luop);
195 }
196 return 0;
197}
198
Harald Welteb18f0e02016-05-05 21:03:03 +0200199static int rx_purge_ms_req(struct osmo_gsup_conn *conn,
200 const struct osmo_gsup_message *gsup)
201{
202 struct osmo_gsup_message gsup_reply = {0};
203 struct msgb *msg_out;
204 bool is_ps = false;
205 int rc;
206
207 LOGP(DAUC, LOGL_INFO, "%s: Purge MS (%s)\n", gsup->imsi,
208 is_ps ? "PS" : "CS");
209
210 memcpy(gsup_reply.imsi, gsup->imsi, sizeof(gsup_reply.imsi));
211
212 if (gsup->cn_domain == OSMO_GSUP_CN_DOMAIN_PS)
213 is_ps = true;
214
215 /* FIXME: check if the VLR that sends the purge is the same that
216 * we have on record. Only update if yes */
217
218 /* Perform the actual update of the DB */
219 rc = db_subscr_purge(g_dbc, gsup->imsi, is_ps);
220
221 if (rc == 1)
222 gsup_reply.message_type = OSMO_GSUP_MSGT_PURGE_MS_RESULT;
223 else if (rc == 0) {
224 gsup_reply.message_type = OSMO_GSUP_MSGT_PURGE_MS_ERROR;
225 gsup_reply.cause = GMM_CAUSE_IMSI_UNKNOWN;
226 } else {
227 gsup_reply.message_type = OSMO_GSUP_MSGT_PURGE_MS_ERROR;
228 gsup_reply.cause = GMM_CAUSE_NET_FAIL;
229 }
230
231 msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP AUC response");
232 osmo_gsup_encode(msg_out, &gsup_reply);
233 return osmo_gsup_conn_send(conn, msg_out);
234}
235
Harald Weltee72cf552016-04-28 07:18:49 +0200236static int read_cb(struct osmo_gsup_conn *conn, struct msgb *msg)
237{
238 static struct osmo_gsup_message gsup;
239 int rc;
240
Harald Weltee687be52016-05-03 18:49:27 +0200241 rc = osmo_gsup_decode(msgb_l2(msg), msgb_l2len(msg), &gsup);
Harald Weltee72cf552016-04-28 07:18:49 +0200242 if (rc < 0) {
243 LOGP(DMAIN, LOGL_ERROR, "error in GSUP decode: %d\n", rc);
244 return rc;
245 }
246
247 switch (gsup.message_type) {
248 /* requests sent to us */
249 case OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST:
250 rx_send_auth_info(conn, &gsup);
251 break;
252 case OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST:
Harald Weltee687be52016-05-03 18:49:27 +0200253 rx_upd_loc_req(conn, &gsup);
Harald Weltee72cf552016-04-28 07:18:49 +0200254 break;
Harald Welteb18f0e02016-05-05 21:03:03 +0200255 case OSMO_GSUP_MSGT_PURGE_MS_REQUEST:
256 rx_purge_ms_req(conn, &gsup);
257 break;
Harald Weltee72cf552016-04-28 07:18:49 +0200258 /* responses to requests sent by us */
259 case OSMO_GSUP_MSGT_INSERT_DATA_ERROR:
Harald Weltee72cf552016-04-28 07:18:49 +0200260 case OSMO_GSUP_MSGT_INSERT_DATA_RESULT:
Harald Weltee687be52016-05-03 18:49:27 +0200261 case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR:
262 case OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT:
263 {
Maxea8b0d42017-02-14 16:53:04 +0100264 struct lu_operation *luop = lu_op_by_imsi(gsup.imsi,
265 &g_lu_ops);
Harald Weltee687be52016-05-03 18:49:27 +0200266 if (!luop) {
Maxaa0fefd2017-02-16 12:25:22 +0100267 LOGP(DMAIN, LOGL_ERROR, "GSUP message %s for "
268 "unknown IMSI %s\n",
269 osmo_gsup_message_type_name(gsup.message_type),
Harald Weltee687be52016-05-03 18:49:27 +0200270 gsup.imsi);
271 break;
272 }
273 lu_op_rx_gsup(luop, &gsup);
274 }
Harald Weltee72cf552016-04-28 07:18:49 +0200275 break;
276 default:
Maxaa0fefd2017-02-16 12:25:22 +0100277 LOGP(DMAIN, LOGL_DEBUG, "Unhandled GSUP message type %s\n",
278 osmo_gsup_message_type_name(gsup.message_type));
Harald Weltee72cf552016-04-28 07:18:49 +0200279 break;
280 }
Harald Welte5341b5d2016-04-28 12:48:39 +0200281 msgb_free(msg);
Harald Weltee72cf552016-04-28 07:18:49 +0200282 return 0;
283}
284
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100285static void print_usage()
286{
287 printf("Usage: osmo-hlr\n");
288}
289
290static void print_help()
291{
292 printf(" -h --help This text.\n");
Neels Hofmeyr7685a782017-01-30 23:30:26 +0100293 printf(" -c --config-file filename The config file to use.\n");
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100294 printf(" -l --database db-name The database to use.\n");
295 printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM Enable debugging.\n");
296 printf(" -D --daemonize Fork the process into a background daemon.\n");
297 printf(" -s --disable-color Do not print ANSI colors in the log\n");
298 printf(" -T --timestamp Prefix every log line with a timestamp.\n");
299 printf(" -e --log-level number Set a global loglevel.\n");
Neels Hofmeyr7685a782017-01-30 23:30:26 +0100300 printf(" -V --version Print the version of OsmoHLR.\n");
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100301}
302
303static struct {
Neels Hofmeyr7685a782017-01-30 23:30:26 +0100304 const char *config_file;
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100305 const char *db_file;
306 bool daemonize;
307} cmdline_opts = {
Neels Hofmeyr7685a782017-01-30 23:30:26 +0100308 .config_file = "osmo-hlr.cfg",
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100309 .db_file = "hlr.db",
310 .daemonize = false,
311};
312
313static void handle_options(int argc, char **argv)
314{
315 while (1) {
316 int option_index = 0, c;
317 static struct option long_options[] = {
318 {"help", 0, 0, 'h'},
Neels Hofmeyr7685a782017-01-30 23:30:26 +0100319 {"config-file", 1, 0, 'c'},
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100320 {"database", 1, 0, 'l'},
321 {"debug", 1, 0, 'd'},
322 {"daemonize", 0, 0, 'D'},
323 {"disable-color", 0, 0, 's'},
324 {"log-level", 1, 0, 'e'},
325 {"timestamp", 0, 0, 'T'},
Neels Hofmeyr7685a782017-01-30 23:30:26 +0100326 {"version", 0, 0, 'V' },
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100327 {0, 0, 0, 0}
328 };
329
Neels Hofmeyr7685a782017-01-30 23:30:26 +0100330 c = getopt_long(argc, argv, "hc:l:d:Dse:TV",
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100331 long_options, &option_index);
332 if (c == -1)
333 break;
334
335 switch (c) {
336 case 'h':
337 print_usage();
338 print_help();
339 exit(0);
Neels Hofmeyr7685a782017-01-30 23:30:26 +0100340 case 'c':
341 cmdline_opts.config_file = optarg;
342 break;
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100343 case 'l':
344 cmdline_opts.db_file = optarg;
345 break;
346 case 'd':
347 log_parse_category_mask(osmo_stderr_target, optarg);
348 break;
349 case 'D':
350 cmdline_opts.daemonize = 1;
351 break;
352 case 's':
353 log_set_use_color(osmo_stderr_target, 0);
354 break;
355 case 'e':
356 log_set_log_level(osmo_stderr_target, atoi(optarg));
357 break;
358 case 'T':
359 log_set_print_timestamp(osmo_stderr_target, 1);
360 break;
Neels Hofmeyr7685a782017-01-30 23:30:26 +0100361 case 'V':
362 print_version(1);
363 exit(0);
364 break;
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100365 default:
366 /* catch unknown options *as well as* missing arguments. */
367 fprintf(stderr, "Error in command line options. Exiting.\n");
368 exit(-1);
369 break;
370 }
371 }
372}
373
Neels Hofmeyrca43e302017-01-30 13:18:23 +0100374static void *hlr_ctx = NULL;
Harald Welteaabae9e2016-04-28 12:48:14 +0200375static struct osmo_gsup_server *gs;
376
377static void signal_hdlr(int signal)
378{
379 switch (signal) {
380 case SIGINT:
381 LOGP(DMAIN, LOGL_NOTICE, "Terminating due to SIGINT\n");
382 osmo_gsup_server_destroy(gs);
383 db_close(g_dbc);
384 log_fini();
Neels Hofmeyrca43e302017-01-30 13:18:23 +0100385 talloc_report_full(hlr_ctx, stderr);
Harald Welteaabae9e2016-04-28 12:48:14 +0200386 exit(0);
387 break;
388 case SIGUSR1:
389 LOGP(DMAIN, LOGL_DEBUG, "Talloc Report due to SIGUSR1\n");
Neels Hofmeyrca43e302017-01-30 13:18:23 +0100390 talloc_report_full(hlr_ctx, stderr);
Harald Welteaabae9e2016-04-28 12:48:14 +0200391 break;
392 }
393}
Harald Weltee72cf552016-04-28 07:18:49 +0200394
Neels Hofmeyr7685a782017-01-30 23:30:26 +0100395static struct vty_app_info vty_info = {
396 .name = "OsmoHLR",
397 .version = PACKAGE_VERSION,
398 .is_config_node = hlr_vty_is_config_node,
399};
400
Harald Weltee72cf552016-04-28 07:18:49 +0200401int main(int argc, char **argv)
402{
Harald Weltee72cf552016-04-28 07:18:49 +0200403 int rc;
404
Neels Hofmeyrca43e302017-01-30 13:18:23 +0100405 hlr_ctx = talloc_named_const(NULL, 1, "OsmoHLR");
406 msgb_talloc_ctx_init(hlr_ctx, 0);
Harald Welteaabae9e2016-04-28 12:48:14 +0200407
Harald Weltee72cf552016-04-28 07:18:49 +0200408 rc = osmo_init_logging(&hlr_log_info);
409 if (rc < 0) {
410 fprintf(stderr, "Error initializing logging\n");
411 exit(1);
412 }
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100413
Neels Hofmeyr7685a782017-01-30 23:30:26 +0100414 vty_init(&vty_info);
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100415 handle_options(argc, argv);
Neels Hofmeyr7685a782017-01-30 23:30:26 +0100416 hlr_vty_init(&hlr_log_info);
417
418 rc = vty_read_config_file(cmdline_opts.config_file, NULL);
419 if (rc < 0) {
420 LOGP(DMAIN, LOGL_FATAL,
421 "Failed to parse the config file: '%s'\n",
422 cmdline_opts.config_file);
423 return rc;
424 }
425
426 /* start telnet after reading config for vty_get_bind_addr() */
427 rc = telnet_init_dynif(hlr_ctx, NULL, vty_get_bind_addr(),
428 OSMO_VTY_PORT_HLR);
429 if (rc < 0)
430 return rc;
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100431
Harald Weltee72cf552016-04-28 07:18:49 +0200432 LOGP(DMAIN, LOGL_NOTICE, "hlr starting\n");
433
434 rc = rand_init();
435 if (rc < 0) {
436 LOGP(DMAIN, LOGL_FATAL, "Error initializing random source\n");
437 exit(1);
438 }
439
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100440 g_dbc = db_open(hlr_ctx, cmdline_opts.db_file);
Harald Weltee72cf552016-04-28 07:18:49 +0200441 if (!g_dbc) {
442 LOGP(DMAIN, LOGL_FATAL, "Error opening database\n");
443 exit(1);
444 }
445
Neels Hofmeyrca43e302017-01-30 13:18:23 +0100446 gs = osmo_gsup_server_create(hlr_ctx, NULL, 2222, read_cb);
Harald Weltee72cf552016-04-28 07:18:49 +0200447 if (!gs) {
448 LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n");
449 exit(1);
450 }
451
Harald Welteaabae9e2016-04-28 12:48:14 +0200452 osmo_init_ignore_signals();
453 signal(SIGINT, &signal_hdlr);
454 signal(SIGUSR1, &signal_hdlr);
455
Neels Hofmeyr7f9491f2017-01-30 13:30:47 +0100456 if (cmdline_opts.daemonize) {
457 rc = osmo_daemonize();
458 if (rc < 0) {
459 perror("Error during daemonize");
460 exit(1);
461 }
462 }
Harald Welteaabae9e2016-04-28 12:48:14 +0200463
Harald Weltee72cf552016-04-28 07:18:49 +0200464 while (1) {
465 osmo_select_main(0);
466 }
467
468 db_close(g_dbc);
469
470 log_fini();
471
472 exit(0);
473}