blob: 35178999205779116ea611ab48df04ab613689c5 [file] [log] [blame]
Harald Welte59b04682009-06-10 05:40:52 +08001/* A hackish minimal BSC (+MSC +HLR) implementation */
2
Harald Welte1c369472010-01-12 10:46:27 +01003/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
Holger Hans Peter Freyther5faf1d32012-05-11 23:28:19 +02004 * (C) 2009-2012 by Holger Hans Peter Freyther <zecke@selfish.org>
Harald Welte59b04682009-06-10 05:40:52 +08005 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
Harald Welte0e3e88e2011-01-01 15:25:50 +01008 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
Harald Welte59b04682009-06-10 05:40:52 +080010 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte0e3e88e2011-01-01 15:25:50 +010015 * GNU Affero General Public License for more details.
Harald Welte59b04682009-06-10 05:40:52 +080016 *
Harald Welte0e3e88e2011-01-01 15:25:50 +010017 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte59b04682009-06-10 05:40:52 +080019 *
20 */
21
22#include <unistd.h>
Harald Welte59b04682009-06-10 05:40:52 +080023#include <time.h>
Harald Welte59b04682009-06-10 05:40:52 +080024#include <errno.h>
25#include <signal.h>
26#include <fcntl.h>
27#include <sys/stat.h>
28
29#define _GNU_SOURCE
30#include <getopt.h>
31
32#include <openbsc/db.h>
Holger Hans Peter Freyther2d59cc62011-05-12 16:02:07 +020033#include <osmocom/core/application.h>
Pablo Neira Ayusodd5fff42011-03-22 16:47:59 +010034#include <osmocom/core/select.h>
Harald Welte59b04682009-06-10 05:40:52 +080035#include <openbsc/debug.h>
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +020036#include <osmocom/abis/abis.h>
37#include <osmocom/abis/e1_input.h>
Pablo Neira Ayusodd5fff42011-03-22 16:47:59 +010038#include <osmocom/core/talloc.h>
Harald Welted21adfe2009-11-30 19:37:18 +010039#include <openbsc/signal.h>
Holger Hans Peter Freytherc7efbe42010-06-30 14:30:35 +080040#include <openbsc/osmo_msc.h>
Ciaby38abd7b2014-03-06 17:20:55 +010041#include <openbsc/osmo_msc_data.h>
Harald Welte30f93fb2011-02-19 16:48:17 +010042#include <openbsc/sms_queue.h>
Holger Hans Peter Freyther19ce77c2010-08-26 15:38:42 +080043#include <openbsc/vty.h>
Pablo Neira Ayuso5bd96a72011-05-14 11:32:48 +020044#include <openbsc/bss.h>
Harald Welte28dce912011-05-24 13:25:38 +020045#include <openbsc/mncc.h>
Alexander Huemeree8e7ee2011-09-06 00:09:48 +020046#include <openbsc/token_auth.h>
47#include <openbsc/handover_decision.h>
48#include <openbsc/rrlp.h>
Harald Welte5919b6a2014-08-20 23:47:15 +020049#include <osmocom/ctrl/control_if.h>
Harald Welte6bcd3032014-08-24 17:54:49 +020050#include <osmocom/ctrl/ports.h>
Harald Welte5919b6a2014-08-20 23:47:15 +020051#include <openbsc/ctrl.h>
Holger Hans Peter Freyther5faf1d32012-05-11 23:28:19 +020052#include <openbsc/osmo_bsc_rf.h>
Harald Weltebad8ffc2015-01-01 12:32:03 +010053#include <openbsc/smpp.h>
Harald Welte40152872010-05-16 20:52:23 +020054
Harald Welted9dea592011-03-04 13:53:51 +010055#include "../../bscconfig.h"
Harald Welte40152872010-05-16 20:52:23 +020056
Harald Welte59b04682009-06-10 05:40:52 +080057/* MCC and MNC for the Location Area Identifier */
Holger Hans Peter Freythercad370f2009-08-17 06:55:10 +020058struct gsm_network *bsc_gsmnet = 0;
Harald Welte59b04682009-06-10 05:40:52 +080059static const char *database_name = "hlr.sqlite3";
Holger Hans Peter Freyther4fa91d02009-08-10 08:39:27 +020060static const char *config_file = "openbsc.cfg";
Holger Hans Peter Freyther5faf1d32012-05-11 23:28:19 +020061static const char *rf_ctrl_name = NULL;
Harald Welte40152872010-05-16 20:52:23 +020062extern const char *openbsc_copyright;
Harald Weltec4ae1762010-08-25 19:43:54 +020063static int daemonize = 0;
Harald Weltee532fb72010-12-23 01:31:07 +010064static int use_mncc_sock = 0;
Harald Weltecfa26852011-11-13 19:02:06 +010065static int use_db_counter = 1;
Holger Hans Peter Freyther76037f02009-12-23 05:29:04 +010066
67/* timer to store statistics */
68#define DB_SYNC_INTERVAL 60, 0
Jan Luebbe0f1f95e2012-12-27 00:40:32 +010069#define EXPIRE_INTERVAL 10, 0
70
Pablo Neira Ayuso840ccf62011-05-06 12:11:06 +020071static struct osmo_timer_list db_sync_timer;
Holger Hans Peter Freyther76037f02009-12-23 05:29:04 +010072
Harald Welte59b04682009-06-10 05:40:52 +080073static void create_pcap_file(char *file)
74{
75 mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
76 int fd = open(file, O_WRONLY|O_TRUNC|O_CREAT, mode);
77
78 if (fd < 0) {
79 perror("Failed to open file for pcap");
80 return;
81 }
82
83 e1_set_pcap_fd(fd);
84}
85
86static void print_usage()
87{
Harald Weltefaae5b82013-11-27 01:28:21 +010088 printf("Usage: osmo-nitb\n");
Harald Welte59b04682009-06-10 05:40:52 +080089}
90
91static void print_help()
92{
93 printf(" Some useful help...\n");
Harald Welte62868882009-08-08 16:12:58 +020094 printf(" -h --help this text\n");
Harald Welte59b04682009-06-10 05:40:52 +080095 printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM enable debugging\n");
Harald Weltec4ae1762010-08-25 19:43:54 +020096 printf(" -D --daemonize Fork the process into a background daemon\n");
Holger Hans Peter Freyther4fa91d02009-08-10 08:39:27 +020097 printf(" -c --config-file filename The config file to use.\n");
Holger Hans Peter Freytherb913c4d2010-03-25 02:41:38 +010098 printf(" -s --disable-color\n");
Harald Welte59b04682009-06-10 05:40:52 +080099 printf(" -l --database db-name The database to use\n");
Holger Hans Peter Freytherb913c4d2010-03-25 02:41:38 +0100100 printf(" -a --authorize-everyone. Authorize every new subscriber. Dangerous!.\n");
Harald Weltebea12fe2009-08-12 21:52:11 +0200101 printf(" -T --timestamp Prefix every log line with a timestamp\n");
Holger Hans Peter Freytherb913c4d2010-03-25 02:41:38 +0100102 printf(" -V --version. Print the version of OpenBSC.\n");
Harald Weltedae9a012009-12-18 15:05:02 +0100103 printf(" -P --rtp-proxy Enable the RTP Proxy code inside OpenBSC\n");
Holger Hans Peter Freyther38e15c02010-03-25 02:39:15 +0100104 printf(" -e --log-level number. Set a global loglevel.\n");
Harald Weltee532fb72010-12-23 01:31:07 +0100105 printf(" -m --mncc-sock Disable built-in MNCC handler and offer socket\n");
Harald Weltecfa26852011-11-13 19:02:06 +0100106 printf(" -C --no-dbcounter Disable regular syncing of counters to database\n");
Holger Hans Peter Freyther5faf1d32012-05-11 23:28:19 +0200107 printf(" -r --rf-ctl NAME. A unix domain socket to listen for cmds.\n");
Harald Welte59b04682009-06-10 05:40:52 +0800108}
109
Holger Hans Peter Freytherdfd61a32010-09-18 06:44:24 +0800110static void handle_options(int argc, char **argv)
Harald Welte59b04682009-06-10 05:40:52 +0800111{
112 while (1) {
Harald Weltea8379772009-06-20 22:36:41 +0200113 int option_index = 0, c;
Harald Welte59b04682009-06-10 05:40:52 +0800114 static struct option long_options[] = {
115 {"help", 0, 0, 'h'},
116 {"debug", 1, 0, 'd'},
Harald Weltec4ae1762010-08-25 19:43:54 +0200117 {"daemonize", 0, 0, 'D'},
Holger Hans Peter Freyther4fa91d02009-08-10 08:39:27 +0200118 {"config-file", 1, 0, 'c'},
Harald Welte59b04682009-06-10 05:40:52 +0800119 {"disable-color", 0, 0, 's'},
Harald Welte59b04682009-06-10 05:40:52 +0800120 {"database", 1, 0, 'l'},
121 {"authorize-everyone", 0, 0, 'a'},
Harald Welte59b04682009-06-10 05:40:52 +0800122 {"pcap", 1, 0, 'p'},
Harald Welte59b04682009-06-10 05:40:52 +0800123 {"timestamp", 0, 0, 'T'},
Harald Weltefa13cad2010-03-23 00:09:32 +0800124 {"version", 0, 0, 'V' },
Harald Welte3c062072009-07-28 18:25:29 +0200125 {"rtp-proxy", 0, 0, 'P'},
Holger Hans Peter Freyther38e15c02010-03-25 02:39:15 +0100126 {"log-level", 1, 0, 'e'},
Harald Weltee532fb72010-12-23 01:31:07 +0100127 {"mncc-sock", 0, 0, 'm'},
Harald Weltecfa26852011-11-13 19:02:06 +0100128 {"no-dbcounter", 0, 0, 'C'},
Holger Hans Peter Freyther5faf1d32012-05-11 23:28:19 +0200129 {"rf-ctl", 1, 0, 'r'},
Harald Welte59b04682009-06-10 05:40:52 +0800130 {0, 0, 0, 0}
131 };
132
Holger Hans Peter Freyther5faf1d32012-05-11 23:28:19 +0200133 c = getopt_long(argc, argv, "hd:Dsl:ar:p:TPVc:e:mCr:",
Harald Welte59b04682009-06-10 05:40:52 +0800134 long_options, &option_index);
135 if (c == -1)
136 break;
137
138 switch (c) {
139 case 'h':
140 print_usage();
141 print_help();
142 exit(0);
143 case 's':
Holger Hans Peter Freyther2d59cc62011-05-12 16:02:07 +0200144 log_set_use_color(osmo_stderr_target, 0);
Harald Welte59b04682009-06-10 05:40:52 +0800145 break;
146 case 'd':
Holger Hans Peter Freyther2d59cc62011-05-12 16:02:07 +0200147 log_parse_category_mask(osmo_stderr_target, optarg);
Harald Welte59b04682009-06-10 05:40:52 +0800148 break;
Harald Weltec4ae1762010-08-25 19:43:54 +0200149 case 'D':
150 daemonize = 1;
151 break;
Harald Welte59b04682009-06-10 05:40:52 +0800152 case 'l':
Daniel Willmannc415da52014-05-21 15:46:44 +0200153 database_name = optarg;
Harald Welte59b04682009-06-10 05:40:52 +0800154 break;
Holger Hans Peter Freyther4fa91d02009-08-10 08:39:27 +0200155 case 'c':
Daniel Willmannc415da52014-05-21 15:46:44 +0200156 config_file = optarg;
Holger Hans Peter Freyther4fa91d02009-08-10 08:39:27 +0200157 break;
Harald Welte59b04682009-06-10 05:40:52 +0800158 case 'p':
159 create_pcap_file(optarg);
160 break;
Harald Welte59b04682009-06-10 05:40:52 +0800161 case 'T':
Holger Hans Peter Freyther2d59cc62011-05-12 16:02:07 +0200162 log_set_print_timestamp(osmo_stderr_target, 1);
Harald Welte59b04682009-06-10 05:40:52 +0800163 break;
Harald Welte3c062072009-07-28 18:25:29 +0200164 case 'P':
165 ipacc_rtp_direct = 0;
166 break;
Holger Hans Peter Freyther38e15c02010-03-25 02:39:15 +0100167 case 'e':
Holger Hans Peter Freyther2d59cc62011-05-12 16:02:07 +0200168 log_set_log_level(osmo_stderr_target, atoi(optarg));
Holger Hans Peter Freyther38e15c02010-03-25 02:39:15 +0100169 break;
Harald Weltee532fb72010-12-23 01:31:07 +0100170 case 'm':
171 use_mncc_sock = 1;
172 break;
Harald Weltecfa26852011-11-13 19:02:06 +0100173 case 'C':
174 use_db_counter = 0;
175 break;
Harald Weltefa13cad2010-03-23 00:09:32 +0800176 case 'V':
Harald Welte10c29f62010-05-16 19:20:24 +0200177 print_version(1);
Harald Weltefa13cad2010-03-23 00:09:32 +0800178 exit(0);
179 break;
Holger Hans Peter Freyther5faf1d32012-05-11 23:28:19 +0200180 case 'r':
181 rf_ctrl_name = optarg;
182 break;
Harald Welte59b04682009-06-10 05:40:52 +0800183 default:
184 /* ignore */
185 break;
186 }
187 }
188}
189
Harald Welte0c836602009-12-24 10:51:56 +0100190extern void *tall_vty_ctx;
Harald Welte59b04682009-06-10 05:40:52 +0800191static void signal_handler(int signal)
192{
193 fprintf(stdout, "signal %u received\n", signal);
194
195 switch (signal) {
Harald Welte3b714502009-08-06 17:43:50 +0200196 case SIGINT:
Holger Hans Peter Freythercad370f2009-08-17 06:55:10 +0200197 bsc_shutdown_net(bsc_gsmnet);
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +0200198 osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
Harald Welte3b714502009-08-06 17:43:50 +0200199 sleep(3);
200 exit(0);
Harald Welte59b04682009-06-10 05:40:52 +0800201 break;
Harald Welte4d5e6d52009-08-07 00:29:44 +0200202 case SIGABRT:
203 /* in case of abort, we want to obtain a talloc report
204 * and then return to the caller, who will abort the process */
Harald Weltea8379772009-06-20 22:36:41 +0200205 case SIGUSR1:
Harald Welte0c836602009-12-24 10:51:56 +0100206 talloc_report(tall_vty_ctx, stderr);
Harald Weltea8379772009-06-20 22:36:41 +0200207 talloc_report_full(tall_bsc_ctx, stderr);
208 break;
Harald Welte0c836602009-12-24 10:51:56 +0100209 case SIGUSR2:
210 talloc_report_full(tall_vty_ctx, stderr);
211 break;
Harald Welte59b04682009-06-10 05:40:52 +0800212 default:
213 break;
214 }
215}
216
Holger Hans Peter Freyther76037f02009-12-23 05:29:04 +0100217/* timer handling */
Pablo Neira Ayuso1c450742011-05-06 12:13:10 +0200218static int _db_store_counter(struct osmo_counter *counter, void *data)
Holger Hans Peter Freyther76037f02009-12-23 05:29:04 +0100219{
220 return db_store_counter(counter);
221}
222
223static void db_sync_timer_cb(void *data)
224{
225 /* store counters to database and re-schedule */
Pablo Neira Ayuso1c450742011-05-06 12:13:10 +0200226 osmo_counters_for_each(_db_store_counter, NULL);
Pablo Neira Ayuso840ccf62011-05-06 12:11:06 +0200227 osmo_timer_schedule(&db_sync_timer, DB_SYNC_INTERVAL);
Holger Hans Peter Freyther76037f02009-12-23 05:29:04 +0100228}
229
Jan Luebbe0f1f95e2012-12-27 00:40:32 +0100230static void subscr_expire_cb(void *data)
231{
Jacob Erlbeckda8770b2014-12-03 09:28:24 +0100232 subscr_expire(bsc_gsmnet->subscr_group);
Jan Luebbe0f1f95e2012-12-27 00:40:32 +0100233 osmo_timer_schedule(&bsc_gsmnet->subscr_expire_timer, EXPIRE_INTERVAL);
234}
235
Harald Welte30f93fb2011-02-19 16:48:17 +0100236void talloc_ctx_init(void);
Harald Welte59698fb2010-01-10 18:01:52 +0100237
Holger Hans Peter Freyther3538c772010-06-08 16:11:06 +0800238extern enum node_type bsc_vty_go_parent(struct vty *vty);
Harald Welte778c4b92010-05-25 23:31:39 +0200239
240static struct vty_app_info vty_info = {
241 .name = "OpenBSC",
242 .version = PACKAGE_VERSION,
243 .go_parent_cb = bsc_vty_go_parent,
Holger Hans Peter Freyther19ce77c2010-08-26 15:38:42 +0800244 .is_config_node = bsc_vty_is_config_node,
Harald Welte778c4b92010-05-25 23:31:39 +0200245};
246
Harald Welte59b04682009-06-10 05:40:52 +0800247int main(int argc, char **argv)
248{
249 int rc;
250
Harald Welte778c4b92010-05-25 23:31:39 +0200251 vty_info.copyright = openbsc_copyright;
252
Harald Weltea8379772009-06-20 22:36:41 +0200253 tall_bsc_ctx = talloc_named_const(NULL, 1, "openbsc");
Harald Welte (local)8751ee92009-08-15 02:30:58 +0200254 talloc_ctx_init();
Harald Welte (local)bd931f12009-08-13 13:52:14 +0200255 on_dso_load_token();
Harald Welte (local)95713782009-08-16 13:18:51 +0200256 on_dso_load_rrlp();
Harald Welteb90d7bd2009-12-17 00:31:10 +0100257 on_dso_load_ho_dec();
Holger Hans Peter Freyther2d59cc62011-05-12 16:02:07 +0200258
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +0200259 libosmo_abis_init(tall_bsc_ctx);
Holger Hans Peter Freyther2d59cc62011-05-12 16:02:07 +0200260 osmo_init_logging(&log_info);
Pablo Neira Ayuso5bd96a72011-05-14 11:32:48 +0200261 bts_init();
Harald Weltee76bea02011-02-05 13:54:41 +0100262
Harald Welte40152872010-05-16 20:52:23 +0200263 /* This needs to precede handle_options() */
Harald Welte778c4b92010-05-25 23:31:39 +0200264 vty_init(&vty_info);
Pablo Neira Ayuso36ad9a42011-03-09 13:36:32 +0100265 bsc_vty_init(&log_info);
Harald Welte40152872010-05-16 20:52:23 +0200266
Harald Welteb7dd6612012-11-20 22:22:04 +0100267#ifdef BUILD_SMPP
Harald Welte51f65482013-03-13 15:05:26 +0100268 if (smpp_openbsc_init(tall_bsc_ctx, 0) < 0)
Harald Welteb7dd6612012-11-20 22:22:04 +0100269 return -1;
270#endif
271
Holger Hans Peter Freyther4f8b9eb2010-05-31 21:42:53 +0800272 /* parse options */
273 handle_options(argc, argv);
274
Harald Weltee532fb72010-12-23 01:31:07 +0100275 /* internal MNCC handler or MNCC socket? */
276 if (use_mncc_sock) {
277 rc = bsc_bootstrap_network(mncc_sock_from_cc, config_file);
278 if (rc >= 0)
279 mncc_sock_init(bsc_gsmnet);
280 } else
281 rc = bsc_bootstrap_network(int_mncc_recv, config_file);
Harald Welte10c29f62010-05-16 19:20:24 +0200282 if (rc < 0)
283 exit(1);
Harald Welte784be942013-03-13 15:39:56 +0100284#ifdef BUILD_SMPP
Harald Welte51f65482013-03-13 15:05:26 +0100285 smpp_openbsc_set_net(bsc_gsmnet);
Harald Welte784be942013-03-13 15:39:56 +0100286#endif
Holger Hans Peter Freytherc7efbe42010-06-30 14:30:35 +0800287 bsc_api_init(bsc_gsmnet, msc_bsc_api());
Harald Welte10c29f62010-05-16 19:20:24 +0200288
Harald Welte6bcd3032014-08-24 17:54:49 +0200289 bsc_gsmnet->ctrl = bsc_controlif_setup(bsc_gsmnet, OSMO_CTRL_PORT_NITB_BSC);
Daniel Willmann6eb756f2011-08-05 12:22:35 +0200290 if (!bsc_gsmnet->ctrl) {
291 printf("Failed to initialize control interface. Exiting.\n");
292 return -1;
293 }
294
Holger Hans Peter Freyther1ba8fa62013-01-09 17:03:27 +0100295 if (bsc_base_ctrl_cmds_install() != 0) {
Holger Hans Peter Freytherfba03162014-03-23 12:06:36 +0100296 printf("Failed to initialize the BSC control commands.\n");
297 return -1;
298 }
299
300 if (msc_ctrl_cmds_install() != 0) {
301 printf("Failed to initialize the MSC control commands.\n");
Holger Hans Peter Freyther1ba8fa62013-01-09 17:03:27 +0100302 return -1;
303 }
304
Harald Welte59b04682009-06-10 05:40:52 +0800305 /* seed the PRNG */
306 srand(time(NULL));
307
Ciaby38abd7b2014-03-06 17:20:55 +0100308 bsc_gsmnet->bsc_data->rf_ctrl = osmo_bsc_rf_create(rf_ctrl_name, bsc_gsmnet);
309 if (!bsc_gsmnet->bsc_data->rf_ctrl) {
Holger Hans Peter Freytherbcfa0b62014-02-07 20:07:51 +0100310 fprintf(stderr, "Failed to create the RF service.\n");
311 exit(1);
Holger Hans Peter Freyther5faf1d32012-05-11 23:28:19 +0200312 }
313
Holger Hans Peter Freythercad370f2009-08-17 06:55:10 +0200314 if (db_init(database_name)) {
315 printf("DB: Failed to init database. Please check the option settings.\n");
316 return -1;
317 }
318 printf("DB: Database initialized.\n");
319
320 if (db_prepare()) {
321 printf("DB: Failed to prepare database.\n");
322 return -1;
323 }
324 printf("DB: Database prepared.\n");
325
Holger Hans Peter Freyther76037f02009-12-23 05:29:04 +0100326 /* setup the timer */
327 db_sync_timer.cb = db_sync_timer_cb;
328 db_sync_timer.data = NULL;
Harald Weltecfa26852011-11-13 19:02:06 +0100329 if (use_db_counter)
330 osmo_timer_schedule(&db_sync_timer, DB_SYNC_INTERVAL);
Holger Hans Peter Freyther76037f02009-12-23 05:29:04 +0100331
Jan Luebbe0f1f95e2012-12-27 00:40:32 +0100332 bsc_gsmnet->subscr_expire_timer.cb = subscr_expire_cb;
333 bsc_gsmnet->subscr_expire_timer.data = NULL;
334 osmo_timer_schedule(&bsc_gsmnet->subscr_expire_timer, EXPIRE_INTERVAL);
335
Harald Welte3b714502009-08-06 17:43:50 +0200336 signal(SIGINT, &signal_handler);
Harald Welte59b04682009-06-10 05:40:52 +0800337 signal(SIGABRT, &signal_handler);
Harald Weltea8379772009-06-20 22:36:41 +0200338 signal(SIGUSR1, &signal_handler);
Harald Welte0c836602009-12-24 10:51:56 +0100339 signal(SIGUSR2, &signal_handler);
Holger Hans Peter Freyther2d59cc62011-05-12 16:02:07 +0200340 osmo_init_ignore_signals();
Harald Welte59b04682009-06-10 05:40:52 +0800341
Holger Hans Peter Freyther575d2e12010-12-24 13:48:27 +0100342 /* start the SMS queue */
Holger Hans Peter Freyther48710462010-12-25 17:43:03 +0100343 if (sms_queue_start(bsc_gsmnet, 20) != 0)
Holger Hans Peter Freyther575d2e12010-12-24 13:48:27 +0100344 return -1;
Harald Welteb7dd6612012-11-20 22:22:04 +0100345
Harald Weltec4ae1762010-08-25 19:43:54 +0200346 if (daemonize) {
347 rc = osmo_daemonize();
348 if (rc < 0) {
349 perror("Error during daemonize");
350 exit(1);
351 }
352 }
353
Harald Welte59b04682009-06-10 05:40:52 +0800354 while (1) {
Harald Welte51d2a592010-03-26 21:28:59 +0800355 log_reset_context();
Pablo Neira Ayuso04d24cd2011-05-06 12:11:23 +0200356 osmo_select_main(0);
Harald Welte59b04682009-06-10 05:40:52 +0800357 }
358}