Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 1 | /* NS-over-IP proxy */ |
| 2 | |
| 3 | /* (C) 2010 by Harald Welte <laforge@gnumonks.org> |
Holger Hans Peter Freyther | 5180844 | 2010-10-06 20:37:09 +0800 | [diff] [blame] | 4 | * (C) 2010 by On-Waves |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 8 | * 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 Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 10 | * (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 Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 15 | * GNU Affero General Public License for more details. |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 16 | * |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 17 | * 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 Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include <unistd.h> |
| 23 | #include <stdio.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <string.h> |
| 26 | #include <getopt.h> |
| 27 | #include <errno.h> |
Harald Welte | 32c806e | 2010-05-12 18:40:01 +0000 | [diff] [blame] | 28 | #include <signal.h> |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 29 | #include <sys/fcntl.h> |
| 30 | #include <sys/stat.h> |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 31 | #include <sys/socket.h> |
| 32 | #include <netinet/in.h> |
| 33 | #include <arpa/inet.h> |
| 34 | |
Holger Hans Peter Freyther | 2d59cc6 | 2011-05-12 16:02:07 +0200 | [diff] [blame] | 35 | #include <osmocom/core/application.h> |
Pablo Neira Ayuso | dd5fff4 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 36 | #include <osmocom/core/talloc.h> |
| 37 | #include <osmocom/core/select.h> |
| 38 | #include <osmocom/core/rate_ctr.h> |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 39 | |
Harald Welte | cfb6b28 | 2012-06-16 14:59:56 +0800 | [diff] [blame] | 40 | #include <osmocom/gprs/gprs_ns.h> |
| 41 | #include <osmocom/gprs/gprs_bssgp.h> |
| 42 | |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 43 | #include <openbsc/signal.h> |
| 44 | #include <openbsc/debug.h> |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 45 | #include <openbsc/vty.h> |
Harald Welte | 323e4f6 | 2010-05-01 11:28:43 +0200 | [diff] [blame] | 46 | #include <openbsc/gb_proxy.h> |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 47 | |
Harald Welte | bd9591f | 2010-05-19 19:45:32 +0200 | [diff] [blame] | 48 | #include <osmocom/vty/command.h> |
| 49 | #include <osmocom/vty/telnet_interface.h> |
Pablo Neira Ayuso | f304678 | 2011-03-23 08:49:00 +0100 | [diff] [blame] | 50 | #include <osmocom/vty/logging.h> |
Harald Welte | 6bcd303 | 2014-08-24 17:54:49 +0200 | [diff] [blame] | 51 | #include <osmocom/vty/ports.h> |
Harald Welte | 10c29f6 | 2010-05-16 19:20:24 +0200 | [diff] [blame] | 52 | |
Harald Welte | 48030cf | 2010-05-04 07:41:59 +0200 | [diff] [blame] | 53 | #include "../../bscconfig.h" |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 54 | |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 55 | #define _GNU_SOURCE |
| 56 | #include <getopt.h> |
| 57 | |
| 58 | void *tall_bsc_ctx; |
| 59 | |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 60 | const char *openbsc_copyright = |
Holger Hans Peter Freyther | 260646d | 2010-09-11 13:32:30 +0800 | [diff] [blame] | 61 | "Copyright (C) 2010 Harald Welte and On-Waves\r\n" |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 62 | "License AGPLv3+: GNU AGPL version 3 or later <http://gnu.org/licenses/agpl-3.0.html>\r\n" |
Holger Hans Peter Freyther | 260646d | 2010-09-11 13:32:30 +0800 | [diff] [blame] | 63 | "This is free software: you are free to change and redistribute it.\r\n" |
| 64 | "There is NO WARRANTY, to the extent permitted by law.\r\n"; |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 65 | |
Harald Welte | 55fe055 | 2010-05-01 16:48:27 +0200 | [diff] [blame] | 66 | static char *config_file = "osmo_gbproxy.cfg"; |
Jacob Erlbeck | 2504bc4 | 2014-05-19 10:14:58 +0200 | [diff] [blame] | 67 | struct gbproxy_config gbcfg = {0}; |
Harald Welte | c4ae176 | 2010-08-25 19:43:54 +0200 | [diff] [blame] | 68 | static int daemonize = 0; |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 69 | |
| 70 | /* Pointer to the SGSN peer */ |
| 71 | extern struct gbprox_peer *gbprox_peer_sgsn; |
| 72 | |
| 73 | /* call-back function for the NS protocol */ |
| 74 | static int proxy_ns_cb(enum gprs_ns_evt event, struct gprs_nsvc *nsvc, |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 75 | struct msgb *msg, uint16_t bvci) |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 76 | { |
| 77 | int rc = 0; |
| 78 | |
| 79 | switch (event) { |
| 80 | case GPRS_NS_EVT_UNIT_DATA: |
Holger Hans Peter Freyther | 7d9c1df | 2014-08-04 15:42:36 +0200 | [diff] [blame] | 81 | rc = gbprox_rcvmsg(&gbcfg, msg, nsvc->nsei, bvci, nsvc->nsvci); |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 82 | break; |
| 83 | default: |
| 84 | LOGP(DGPRS, LOGL_ERROR, "SGSN: Unknown event %u from NS\n", event); |
| 85 | if (msg) |
Holger Hans Peter Freyther | 1bcd637 | 2012-03-01 20:30:32 +0100 | [diff] [blame] | 86 | msgb_free(msg); |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 87 | rc = -EIO; |
| 88 | break; |
| 89 | } |
| 90 | return rc; |
| 91 | } |
| 92 | |
Harald Welte | 32c806e | 2010-05-12 18:40:01 +0000 | [diff] [blame] | 93 | static void signal_handler(int signal) |
| 94 | { |
| 95 | fprintf(stdout, "signal %u received\n", signal); |
| 96 | |
| 97 | switch (signal) { |
| 98 | case SIGINT: |
Pablo Neira Ayuso | 42e41df | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 99 | osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL); |
Harald Welte | 32c806e | 2010-05-12 18:40:01 +0000 | [diff] [blame] | 100 | sleep(1); |
| 101 | exit(0); |
| 102 | break; |
| 103 | case SIGABRT: |
| 104 | /* in case of abort, we want to obtain a talloc report |
| 105 | * and then return to the caller, who will abort the process */ |
| 106 | case SIGUSR1: |
| 107 | talloc_report(tall_vty_ctx, stderr); |
| 108 | talloc_report_full(tall_bsc_ctx, stderr); |
| 109 | break; |
| 110 | case SIGUSR2: |
| 111 | talloc_report_full(tall_vty_ctx, stderr); |
| 112 | break; |
| 113 | default: |
| 114 | break; |
| 115 | } |
| 116 | } |
| 117 | |
Harald Welte | 17f83c5 | 2010-05-14 11:22:33 +0000 | [diff] [blame] | 118 | static void print_usage() |
| 119 | { |
| 120 | printf("Usage: bsc_hack\n"); |
| 121 | } |
| 122 | |
| 123 | static void print_help() |
| 124 | { |
| 125 | printf(" Some useful help...\n"); |
| 126 | printf(" -h --help this text\n"); |
| 127 | printf(" -d option --debug=DNS:DGPRS,0:0 enable debugging\n"); |
Harald Welte | c4ae176 | 2010-08-25 19:43:54 +0200 | [diff] [blame] | 128 | printf(" -D --daemonize Fork the process into a background daemon\n"); |
Harald Welte | 17f83c5 | 2010-05-14 11:22:33 +0000 | [diff] [blame] | 129 | printf(" -c --config-file filename The config file to use.\n"); |
| 130 | printf(" -s --disable-color\n"); |
| 131 | printf(" -T --timestamp Prefix every log line with a timestamp\n"); |
| 132 | printf(" -V --version. Print the version of OpenBSC.\n"); |
| 133 | printf(" -e --log-level number. Set a global loglevel.\n"); |
| 134 | } |
| 135 | |
| 136 | static void handle_options(int argc, char **argv) |
| 137 | { |
| 138 | while (1) { |
| 139 | int option_index = 0, c; |
| 140 | static struct option long_options[] = { |
| 141 | { "help", 0, 0, 'h' }, |
| 142 | { "debug", 1, 0, 'd' }, |
Harald Welte | c4ae176 | 2010-08-25 19:43:54 +0200 | [diff] [blame] | 143 | { "daemonize", 0, 0, 'D' }, |
Harald Welte | 17f83c5 | 2010-05-14 11:22:33 +0000 | [diff] [blame] | 144 | { "config-file", 1, 0, 'c' }, |
| 145 | { "disable-color", 0, 0, 's' }, |
| 146 | { "timestamp", 0, 0, 'T' }, |
| 147 | { "version", 0, 0, 'V' }, |
| 148 | { "log-level", 1, 0, 'e' }, |
| 149 | { 0, 0, 0, 0 } |
| 150 | }; |
| 151 | |
Harald Welte | c4ae176 | 2010-08-25 19:43:54 +0200 | [diff] [blame] | 152 | c = getopt_long(argc, argv, "hd:Dc:sTVe:", |
Harald Welte | 17f83c5 | 2010-05-14 11:22:33 +0000 | [diff] [blame] | 153 | long_options, &option_index); |
| 154 | if (c == -1) |
| 155 | break; |
| 156 | |
| 157 | switch (c) { |
| 158 | case 'h': |
| 159 | print_usage(); |
| 160 | print_help(); |
| 161 | exit(0); |
| 162 | case 's': |
Holger Hans Peter Freyther | 2d59cc6 | 2011-05-12 16:02:07 +0200 | [diff] [blame] | 163 | log_set_use_color(osmo_stderr_target, 0); |
Harald Welte | 17f83c5 | 2010-05-14 11:22:33 +0000 | [diff] [blame] | 164 | break; |
| 165 | case 'd': |
Holger Hans Peter Freyther | 2d59cc6 | 2011-05-12 16:02:07 +0200 | [diff] [blame] | 166 | log_parse_category_mask(osmo_stderr_target, optarg); |
Harald Welte | 17f83c5 | 2010-05-14 11:22:33 +0000 | [diff] [blame] | 167 | break; |
Harald Welte | c4ae176 | 2010-08-25 19:43:54 +0200 | [diff] [blame] | 168 | case 'D': |
| 169 | daemonize = 1; |
| 170 | break; |
Harald Welte | 17f83c5 | 2010-05-14 11:22:33 +0000 | [diff] [blame] | 171 | case 'c': |
Holger Hans Peter Freyther | 196cb62 | 2015-01-26 10:26:36 +0100 | [diff] [blame] | 172 | config_file = optarg; |
Harald Welte | 17f83c5 | 2010-05-14 11:22:33 +0000 | [diff] [blame] | 173 | break; |
| 174 | case 'T': |
Holger Hans Peter Freyther | 2d59cc6 | 2011-05-12 16:02:07 +0200 | [diff] [blame] | 175 | log_set_print_timestamp(osmo_stderr_target, 1); |
Harald Welte | 17f83c5 | 2010-05-14 11:22:33 +0000 | [diff] [blame] | 176 | break; |
| 177 | case 'e': |
Holger Hans Peter Freyther | 2d59cc6 | 2011-05-12 16:02:07 +0200 | [diff] [blame] | 178 | log_set_log_level(osmo_stderr_target, atoi(optarg)); |
Harald Welte | 17f83c5 | 2010-05-14 11:22:33 +0000 | [diff] [blame] | 179 | break; |
| 180 | case 'V': |
Harald Welte | 10c29f6 | 2010-05-16 19:20:24 +0200 | [diff] [blame] | 181 | print_version(1); |
Harald Welte | 17f83c5 | 2010-05-14 11:22:33 +0000 | [diff] [blame] | 182 | exit(0); |
| 183 | break; |
| 184 | default: |
| 185 | break; |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
Harald Welte | 32c806e | 2010-05-12 18:40:01 +0000 | [diff] [blame] | 190 | extern void *tall_msgb_ctx; |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 191 | |
Holger Hans Peter Freyther | 3538c77 | 2010-06-08 16:11:06 +0800 | [diff] [blame] | 192 | extern enum node_type bsc_vty_go_parent(struct vty *vty); |
Harald Welte | 778c4b9 | 2010-05-25 23:31:39 +0200 | [diff] [blame] | 193 | |
| 194 | static struct vty_app_info vty_info = { |
Harald Welte | 9af42c3 | 2011-02-24 23:57:06 +0100 | [diff] [blame] | 195 | .name = "OsmoGbProxy", |
Harald Welte | 778c4b9 | 2010-05-25 23:31:39 +0200 | [diff] [blame] | 196 | .version = PACKAGE_VERSION, |
| 197 | .go_parent_cb = bsc_vty_go_parent, |
Holger Hans Peter Freyther | ba289d0 | 2010-09-04 11:00:01 +0800 | [diff] [blame] | 198 | .is_config_node = bsc_vty_is_config_node, |
Harald Welte | 778c4b9 | 2010-05-25 23:31:39 +0200 | [diff] [blame] | 199 | }; |
| 200 | |
Harald Welte | 40b2575 | 2012-06-17 12:58:46 +0800 | [diff] [blame] | 201 | /* default categories */ |
| 202 | static struct log_info_cat gprs_categories[] = { |
| 203 | [DGPRS] = { |
| 204 | .name = "DGPRS", |
| 205 | .description = "GPRS Packet Service", |
| 206 | .enabled = 1, .loglevel = LOGL_DEBUG, |
| 207 | }, |
| 208 | [DNS] = { |
| 209 | .name = "DNS", |
| 210 | .description = "GPRS Network Service (NS)", |
| 211 | .enabled = 1, .loglevel = LOGL_INFO, |
| 212 | }, |
| 213 | [DBSSGP] = { |
| 214 | .name = "DBSSGP", |
| 215 | .description = "GPRS BSS Gateway Protocol (BSSGP)", |
| 216 | .enabled = 1, .loglevel = LOGL_DEBUG, |
| 217 | }, |
| 218 | }; |
| 219 | |
| 220 | static const struct log_info gprs_log_info = { |
| 221 | .filter_fn = gprs_log_filter_fn, |
| 222 | .cat = gprs_categories, |
| 223 | .num_cat = ARRAY_SIZE(gprs_categories), |
| 224 | }; |
| 225 | |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 226 | int main(int argc, char **argv) |
| 227 | { |
| 228 | struct gsm_network dummy_network; |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 229 | int rc; |
| 230 | |
| 231 | tall_bsc_ctx = talloc_named_const(NULL, 0, "nsip_proxy"); |
Harald Welte | 32c806e | 2010-05-12 18:40:01 +0000 | [diff] [blame] | 232 | tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 0, "msgb"); |
| 233 | |
| 234 | signal(SIGINT, &signal_handler); |
| 235 | signal(SIGABRT, &signal_handler); |
| 236 | signal(SIGUSR1, &signal_handler); |
| 237 | signal(SIGUSR2, &signal_handler); |
Holger Hans Peter Freyther | 2d59cc6 | 2011-05-12 16:02:07 +0200 | [diff] [blame] | 238 | osmo_init_ignore_signals(); |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 239 | |
Harald Welte | 40b2575 | 2012-06-17 12:58:46 +0800 | [diff] [blame] | 240 | osmo_init_logging(&gprs_log_info); |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 241 | |
Harald Welte | 778c4b9 | 2010-05-25 23:31:39 +0200 | [diff] [blame] | 242 | vty_info.copyright = openbsc_copyright; |
| 243 | vty_init(&vty_info); |
Harald Welte | 40b2575 | 2012-06-17 12:58:46 +0800 | [diff] [blame] | 244 | logging_vty_add_cmds(&gprs_log_info); |
Harald Welte | 2ef79c5 | 2010-05-19 14:04:23 +0200 | [diff] [blame] | 245 | gbproxy_vty_init(); |
Harald Welte | 10c29f6 | 2010-05-16 19:20:24 +0200 | [diff] [blame] | 246 | |
Harald Welte | 17f83c5 | 2010-05-14 11:22:33 +0000 | [diff] [blame] | 247 | handle_options(argc, argv); |
| 248 | |
Harald Welte | c80bb28 | 2010-05-13 11:45:07 +0200 | [diff] [blame] | 249 | rate_ctr_init(tall_bsc_ctx); |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 250 | |
Harald Welte | 6bcd303 | 2014-08-24 17:54:49 +0200 | [diff] [blame] | 251 | rc = telnet_init(tall_bsc_ctx, &dummy_network, OSMO_VTY_PORT_GBPROXY); |
Harald Welte | 4015287 | 2010-05-16 20:52:23 +0200 | [diff] [blame] | 252 | if (rc < 0) |
| 253 | exit(1); |
| 254 | |
Harald Welte | 1d12338 | 2012-06-16 16:54:06 +0800 | [diff] [blame] | 255 | bssgp_nsi = gprs_ns_instantiate(&proxy_ns_cb, tall_bsc_ctx); |
Harald Welte | 874acec | 2010-05-11 10:01:17 +0200 | [diff] [blame] | 256 | if (!bssgp_nsi) { |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 257 | LOGP(DGPRS, LOGL_ERROR, "Unable to instantiate NS\n"); |
| 258 | exit(1); |
| 259 | } |
Holger Hans Peter Freyther | 5eaf1a2 | 2014-08-04 11:10:09 +0200 | [diff] [blame] | 260 | gbproxy_init_config(&gbcfg); |
Harald Welte | 874acec | 2010-05-11 10:01:17 +0200 | [diff] [blame] | 261 | gbcfg.nsi = bssgp_nsi; |
Harald Welte | 51cce2a | 2010-05-12 15:55:23 +0000 | [diff] [blame] | 262 | gprs_ns_vty_init(bssgp_nsi); |
Harald Welte | deb9017 | 2012-06-16 17:45:59 +0800 | [diff] [blame] | 263 | gprs_ns_set_log_ss(DNS); |
Harald Welte | a084f12 | 2012-06-17 13:04:02 +0800 | [diff] [blame] | 264 | bssgp_set_log_ss(DBSSGP); |
Holger Hans Peter Freyther | 7d9c1df | 2014-08-04 15:42:36 +0200 | [diff] [blame] | 265 | osmo_signal_register_handler(SS_L_NS, &gbprox_signal, &gbcfg); |
Harald Welte | 51cce2a | 2010-05-12 15:55:23 +0000 | [diff] [blame] | 266 | |
| 267 | rc = gbproxy_parse_config(config_file, &gbcfg); |
| 268 | if (rc < 0) { |
| 269 | LOGP(DGPRS, LOGL_FATAL, "Cannot parse config file\n"); |
| 270 | exit(2); |
| 271 | } |
| 272 | |
Harald Welte | a529c07 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 273 | if (!gprs_nsvc_by_nsei(gbcfg.nsi, gbcfg.nsip_sgsn_nsei)) { |
Harald Welte | 2ef79c5 | 2010-05-19 14:04:23 +0200 | [diff] [blame] | 274 | LOGP(DGPRS, LOGL_FATAL, "You cannot proxy to NSEI %u " |
| 275 | "without creating that NSEI before\n", |
| 276 | gbcfg.nsip_sgsn_nsei); |
| 277 | exit(2); |
| 278 | } |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 279 | |
Harald Welte | 31f0a23 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 280 | rc = gprs_ns_nsip_listen(bssgp_nsi); |
Harald Welte | 2ef79c5 | 2010-05-19 14:04:23 +0200 | [diff] [blame] | 281 | if (rc < 0) { |
| 282 | LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen on NSIP socket\n"); |
| 283 | exit(2); |
| 284 | } |
Harald Welte | 9ee404a | 2010-05-14 11:53:08 +0000 | [diff] [blame] | 285 | |
Harald Welte | 31f0a23 | 2010-05-19 15:09:09 +0200 | [diff] [blame] | 286 | rc = gprs_ns_frgre_listen(bssgp_nsi); |
| 287 | if (rc < 0) { |
| 288 | LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen GRE " |
| 289 | "socket. Do you have CAP_NET_RAW?\n"); |
| 290 | exit(2); |
Harald Welte | ba1f931 | 2010-05-19 14:38:50 +0200 | [diff] [blame] | 291 | } |
| 292 | |
Harald Welte | c4ae176 | 2010-08-25 19:43:54 +0200 | [diff] [blame] | 293 | if (daemonize) { |
| 294 | rc = osmo_daemonize(); |
| 295 | if (rc < 0) { |
| 296 | perror("Error during daemonize"); |
| 297 | exit(1); |
| 298 | } |
| 299 | } |
| 300 | |
Harald Welte | 9ee404a | 2010-05-14 11:53:08 +0000 | [diff] [blame] | 301 | /* Reset all the persistent NS-VCs that we've read from the config */ |
| 302 | gbprox_reset_persistent_nsvcs(bssgp_nsi); |
| 303 | |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 304 | while (1) { |
Pablo Neira Ayuso | 04d24cd | 2011-05-06 12:11:23 +0200 | [diff] [blame] | 305 | rc = osmo_select_main(0); |
Harald Welte | d1991e7 | 2010-04-30 20:26:32 +0200 | [diff] [blame] | 306 | if (rc < 0) |
| 307 | exit(3); |
| 308 | } |
| 309 | |
| 310 | exit(0); |
| 311 | } |