pespin has uploaded this change for review.

View Change

layer23: Introduce l23_app_start() API step

This commit is a preparation towards having shared VTY infrastructure
for layer23 apps. Having 2 steps (first init(), then start()) allows
the apps easily struct allocation & initialization, and then start doing
work after VTY config has been read.

Change-Id: I1d232809764962f82fee86159bc61cdbc3eb3c48
---
M src/host/layer23/include/osmocom/bb/common/l23_app.h
M src/host/layer23/src/common/main.c
2 files changed, 23 insertions(+), 12 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/43/30943/1
diff --git a/src/host/layer23/include/osmocom/bb/common/l23_app.h b/src/host/layer23/include/osmocom/bb/common/l23_app.h
index 0b9994c..fb71164 100644
--- a/src/host/layer23/include/osmocom/bb/common/l23_app.h
+++ b/src/host/layer23/include/osmocom/bb/common/l23_app.h
@@ -13,9 +13,13 @@
L23_OPT_VTYIP = 32,
};

-/* initialization, called once when starting the app, before entering
- * select loop */
+/* initialization, called once when starting the app, before reading VTY config */
extern int l23_app_init(struct osmocom_ms *ms);
+
+/* Start work after reading VTY config and starting layer23 components,
+ *immediatelly before entering main select loop */
+extern int l23_app_start(struct osmocom_ms *ms);
+
extern int (*l23_app_work) (struct osmocom_ms *ms);
extern int (*l23_app_exit) (struct osmocom_ms *ms);

diff --git a/src/host/layer23/src/common/main.c b/src/host/layer23/src/common/main.c
index f714010..48bdfec 100644
--- a/src/host/layer23/src/common/main.c
+++ b/src/host/layer23/src/common/main.c
@@ -249,15 +249,6 @@

ms->name = talloc_strdup(ms, "1");
ms->test_arfcn = 871;
-
- handle_options(argc, argv);
-
- rc = layer2_open(ms, layer2_socket_path);
- if (rc < 0) {
- fprintf(stderr, "Failed during layer2_open()\n");
- exit(1);
- }
-
ms->lapdm_channel.lapdm_dcch.l1_ctx = ms;
ms->lapdm_channel.lapdm_dcch.l3_ctx = ms;
ms->lapdm_channel.lapdm_acch.l1_ctx = ms;
@@ -265,9 +256,19 @@
lapdm_channel_init(&ms->lapdm_channel, LAPDM_MODE_MS);
lapdm_channel_set_l1(&ms->lapdm_channel, l1ctl_ph_prim_cb, ms);

+ handle_options(argc, argv);
+
rc = l23_app_init(ms);
- if (rc < 0)
+ if (rc < 0) {
+ fprintf(stderr, "Failed during l23_app_init()\n");
exit(1);
+ }
+
+ rc = layer2_open(ms, layer2_socket_path);
+ if (rc < 0) {
+ fprintf(stderr, "Failed during layer2_open()\n");
+ exit(1);
+ }

if (gsmtap_ip) {
gsmtap_inst = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 1);
@@ -278,6 +279,12 @@
gsmtap_source_add_sink(gsmtap_inst);
}

+ rc = l23_app_start(ms);
+ if (rc < 0) {
+ fprintf(stderr, "Failed during l23_app_start()\n");
+ exit(1);
+ }
+
signal(SIGINT, sighandler);
signal(SIGHUP, sighandler);
signal(SIGTERM, sighandler);

To view, visit change 30943. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I1d232809764962f82fee86159bc61cdbc3eb3c48
Gerrit-Change-Number: 30943
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-MessageType: newchange