summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-12-26 19:15:48 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-12-27 19:01:37 +0100
commit2934d0a4f4391b45e4bdb9adcbc1931b1323b986 (patch)
treec501997243ac52400a1f977c9faafff879aa00ad
parent000066110ade5227822532989b36f11c004b193f (diff)
layer23: Create an l23_app_info for various information and cb's
Make it possible that each l23 app can inject the copyright string, also prepare to have callbacks for the config handling and other places. This will be useful to add app specific config options.
-rw-r--r--src/host/layer23/include/osmocom/bb/common/l23_app.h8
-rw-r--r--src/host/layer23/src/common/main.c20
-rw-r--r--src/host/layer23/src/misc/app_bcch_scan.c11
-rw-r--r--src/host/layer23/src/misc/app_cbch_sniff.c11
-rw-r--r--src/host/layer23/src/misc/app_cell_log.c7
-rw-r--r--src/host/layer23/src/misc/app_echo_test.c11
-rw-r--r--src/host/layer23/src/misc/app_phone.c11
7 files changed, 74 insertions, 5 deletions
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 1a228567..8a248843 100644
--- a/src/host/layer23/include/osmocom/bb/common/l23_app.h
+++ b/src/host/layer23/include/osmocom/bb/common/l23_app.h
@@ -7,4 +7,12 @@ extern int l23_app_init(struct osmocom_ms *ms);
extern int (*l23_app_work) (struct osmocom_ms *ms);
extern int (*l23_app_exit) (struct osmocom_ms *ms);
+/* configuration options */
+struct l23_app_info {
+ const char *copyright;
+ const char *contribution;
+};
+
+extern struct l23_app_info *l23_app_info();
+
#endif /* _L23_APP_H */
diff --git a/src/host/layer23/src/common/main.c b/src/host/layer23/src/common/main.c
index ba16a321..2bcb2f43 100644
--- a/src/host/layer23/src/common/main.c
+++ b/src/host/layer23/src/common/main.c
@@ -60,12 +60,12 @@ int (*l23_app_exit) (struct osmocom_ms *ms) = NULL;
int quit = 0;
const char *openbsc_copyright =
- "Copyright (C) 2008-2010 ...\n"
- "Contributions by ...\n\n"
+ "%s"
+ "%s\n"
"License GPLv2+: GNU GPL version 2 or later "
"<http://gnu.org/licenses/gpl.html>\n"
"This is free software: you are free to change and redistribute it.\n"
- "There is NO WARRANTY, to the extent permitted by law.\n";
+ "There is NO WARRANTY, to the extent permitted by law.\n\n";
static void print_usage(const char *app)
{
@@ -157,12 +157,19 @@ void sighandler(int sigset)
exit (0);
}
+static void print_copyright()
+{
+ struct l23_app_info *app;
+ app = l23_app_info();
+ printf(openbsc_copyright,
+ app && app->copyright ? app->copyright : "",
+ app && app->contribution ? app->contribution : "");
+}
+
int main(int argc, char **argv)
{
int rc;
- printf("%s\n", openbsc_copyright);
-
INIT_LLIST_HEAD(&ms_list);
log_init(&log_info);
stderr_target = log_target_create_stderr();
@@ -176,6 +183,9 @@ int main(int argc, char **argv)
fprintf(stderr, "Failed to allocate MS\n");
exit(1);
}
+
+ print_copyright();
+
llist_add_tail(&ms->entity, &ms_list);
sprintf(ms->name, "1");
diff --git a/src/host/layer23/src/misc/app_bcch_scan.c b/src/host/layer23/src/misc/app_bcch_scan.c
index 326623f4..cce22b3b 100644
--- a/src/host/layer23/src/misc/app_bcch_scan.c
+++ b/src/host/layer23/src/misc/app_bcch_scan.c
@@ -25,6 +25,7 @@
#include <osmocom/bb/common/l1ctl.h>
#include <osmocom/bb/common/lapdm.h>
#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/l23_app.h>
#include <osmocom/bb/misc/layer3.h>
#include <osmocore/msgb.h>
@@ -55,3 +56,13 @@ int l23_app_init(struct osmocom_ms *ms)
l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
return register_signal_handler(SS_L1CTL, &signal_cb, NULL);
}
+
+static struct l23_app_info info = {
+ .copyright = "Copyright (C) 2010 Harald Welte <laforge@gnumonks.org>\n",
+ .contribution = "Contributions by Holger Hans Peter Freyther\n",
+};
+
+struct l23_app_info *l23_app_info()
+{
+ return &info;
+}
diff --git a/src/host/layer23/src/misc/app_cbch_sniff.c b/src/host/layer23/src/misc/app_cbch_sniff.c
index 19a9aced..9e2d1a99 100644
--- a/src/host/layer23/src/misc/app_cbch_sniff.c
+++ b/src/host/layer23/src/misc/app_cbch_sniff.c
@@ -26,6 +26,7 @@
#include <osmocom/bb/common/l1ctl.h>
#include <osmocom/bb/common/lapdm.h>
#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/l23_app.h>
#include <osmocom/bb/misc/layer3.h>
#include <osmocore/msgb.h>
@@ -186,3 +187,13 @@ int l23_app_init(struct osmocom_ms *ms)
l1ctl_tx_dm_rel_req(ms);
return register_signal_handler(SS_L1CTL, &signal_cb, NULL);
}
+
+static struct l23_app_info info = {
+ .copyright = "Copyright (C) 2010 Harald Welte <laforge@gnumonks.org>\n",
+ .contribution = "Contributions by Holger Hans Peter Freyther\n",
+};
+
+struct l23_app_info *l23_app_info()
+{
+ return &info;
+}
diff --git a/src/host/layer23/src/misc/app_cell_log.c b/src/host/layer23/src/misc/app_cell_log.c
index fcc2b1fd..1ab64f51 100644
--- a/src/host/layer23/src/misc/app_cell_log.c
+++ b/src/host/layer23/src/misc/app_cell_log.c
@@ -72,4 +72,11 @@ int l23_app_init(struct osmocom_ms *ms)
return 0;
}
+static struct l23_app_info info = {
+ .copyright = "Copyright (C) 2010 Andreas Eversberg\n",
+};
+struct l23_app_info *l23_app_info()
+{
+ return &info;
+}
diff --git a/src/host/layer23/src/misc/app_echo_test.c b/src/host/layer23/src/misc/app_echo_test.c
index 56ab6740..c9b18958 100644
--- a/src/host/layer23/src/misc/app_echo_test.c
+++ b/src/host/layer23/src/misc/app_echo_test.c
@@ -25,6 +25,7 @@
#include <osmocom/bb/common/l1ctl.h>
#include <osmocom/bb/common/lapdm.h>
#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/l23_app.h>
#include <osmocom/bb/misc/layer3.h>
#include <osmocore/msgb.h>
@@ -53,3 +54,13 @@ int l23_app_init(struct osmocom_ms *ms)
return 0;
}
+
+static struct l23_app_info info = {
+ .copyright = "Copyright (C) 2010 Harald Welte <laforge@gnumonks.org>\n",
+ .contribution = "Contributions by Holger Hans Peter Freyther\n",
+};
+
+struct l23_app_info *l23_app_info()
+{
+ return &info;
+}
diff --git a/src/host/layer23/src/misc/app_phone.c b/src/host/layer23/src/misc/app_phone.c
index 6b2c9281..85d0da9d 100644
--- a/src/host/layer23/src/misc/app_phone.c
+++ b/src/host/layer23/src/misc/app_phone.c
@@ -25,6 +25,7 @@
#include <osmocom/bb/common/l1ctl.h>
#include <osmocom/bb/common/lapdm.h>
#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/l23_app.h>
#include <osmocom/bb/misc/layer3.h>
#include <osmocore/msgb.h>
@@ -59,3 +60,13 @@ int l23_app_init(struct osmocom_ms *ms)
l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
return layer3_init(ms);
}
+
+static struct l23_app_info info = {
+ .copyright = "Copyright (C) 2010 Harald Welte <laforge@gnumonks.org>\n",
+ .contribution = "Contributions by Holger Hans Peter Freyther\n",
+};
+
+struct l23_app_info *l23_app_info()
+{
+ return &info;
+}