aboutsummaryrefslogtreecommitdiffstats
path: root/src/gtphub/gtphub_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtphub/gtphub_main.c')
-rw-r--r--src/gtphub/gtphub_main.c65
1 files changed, 23 insertions, 42 deletions
diff --git a/src/gtphub/gtphub_main.c b/src/gtphub/gtphub_main.c
index f693f0993..9b0532b24 100644
--- a/src/gtphub/gtphub_main.c
+++ b/src/gtphub/gtphub_main.c
@@ -34,6 +34,7 @@
#include <osmocom/core/logging.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/rate_ctr.h>
+#include <osmocom/core/msgb.h>
#include <osmocom/vty/logging.h>
#include <osmocom/vty/telnet_interface.h>
@@ -41,10 +42,10 @@
#include <osmocom/vty/misc.h>
#include <osmocom/sgsn/debug.h>
-#include <osmocom/sgsn/gtphub.h>
+#include <osmocom/gtphub/gtphub.h>
#include <osmocom/sgsn/vty.h>
-#include "../../bscconfig.h"
+#include "../../config.h"
#if BUILD_IU
#include <osmocom/sigtran/osmo_ss7.h>
@@ -95,11 +96,11 @@ void log_cfg(struct gtphub_cfg *cfg)
}
}
-static void signal_handler(int signal)
+static void signal_handler(int signum)
{
- fprintf(stdout, "signal %d received\n", signal);
+ fprintf(stdout, "signal %d received\n", signum);
- switch (signal) {
+ switch (signum) {
case SIGINT:
case SIGTERM:
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
@@ -107,8 +108,16 @@ static void signal_handler(int signal)
exit(0);
break;
case SIGABRT:
- /* in case of abort, we want to obtain a talloc report
- * and then return to the caller, who will abort the process */
+ /* in case of abort, we want to obtain a talloc report and
+ * then run default SIGABRT handler, who will generate coredump
+ * and abort the process. abort() should do this for us after we
+ * return, but program wouldn't exit if an external SIGABRT is
+ * received.
+ */
+ talloc_report_full(osmo_gtphub_ctx, stderr);
+ signal(SIGABRT, SIG_DFL);
+ raise(SIGABRT);
+ break;
case SIGUSR1:
case SIGUSR2:
talloc_report_full(osmo_gtphub_ctx, stderr);
@@ -118,44 +127,12 @@ static void signal_handler(int signal)
}
}
-#if BUILD_IU
-int gtphub_vty_go_parent(struct vty *vty)
-{
- switch (vty->node) {
- default:
- osmo_ss7_vty_go_parent(vty);
- }
-
- return vty->node;
-}
-#endif
-
-int gtphub_vty_is_config_node(struct vty *vty, int node)
-{
- /* Check if libosmo-sccp declares the node in
- * question as config node */
-#if BUILD_IU
- if (osmo_ss7_is_config_node(vty, node))
- return 1;
-#endif
-
- switch (node) {
- /* add items that are not config */
- case CONFIG_NODE:
- return 0;
-
- default:
- return 1;
- }
-}
-
static struct vty_app_info vty_info = {
.name = "OsmoGTPhub",
.version = PACKAGE_VERSION,
#if BUILD_IU
- .go_parent_cb = gtphub_vty_go_parent,
+ .go_parent_cb = osmo_ss7_vty_go_parent,
#endif
- .is_config_node = gtphub_vty_is_config_node,
};
struct cmdline_cfg {
@@ -322,6 +299,11 @@ static void handle_options(struct cmdline_cfg *ccfg, int argc, char **argv)
break;
}
}
+
+ if (argc > optind) {
+ fprintf(stderr, "Unsupported positional arguments on command line\n");
+ exit(2);
+ }
}
int main(int argc, char **argv)
@@ -372,8 +354,7 @@ int main(int argc, char **argv)
}
/* start telnet after reading config for vty_get_bind_addr() */
- rc = telnet_init_dynif(osmo_gtphub_ctx, 0, vty_get_bind_addr(),
- OSMO_VTY_PORT_GTPHUB);
+ rc = telnet_init_default(osmo_gtphub_ctx, NULL, OSMO_VTY_PORT_GTPHUB);
if (rc < 0)
exit(1);