aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-03-23 00:09:32 +0800
committerHarald Welte <laforge@gnumonks.org>2010-03-23 00:09:32 +0800
commit5a29c7fa895a14112a1ac65e541f4b87ae9dba04 (patch)
treeebe00528c9d0b992406de8c30ab2a3e99eccdd0a /openbsc/src
parent351ec2a1784fbdb2ce688f50a9134532f3bf0723 (diff)
automatically include program version and print it from vty and --version
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/bsc_hack.c30
-rw-r--r--openbsc/src/mgcp/mgcp_main.c23
-rw-r--r--openbsc/src/telnet_interface.c15
-rw-r--r--openbsc/src/vty/cardshell.h5
4 files changed, 58 insertions, 15 deletions
diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c
index 49c9d36ef..2405ceebd 100644
--- a/openbsc/src/bsc_hack.c
+++ b/openbsc/src/bsc_hack.c
@@ -37,12 +37,21 @@
#include <osmocore/talloc.h>
#include <openbsc/signal.h>
+#include "../bscconfig.h"
+
/* MCC and MNC for the Location Area Identifier */
static struct debug_target *stderr_target;
struct gsm_network *bsc_gsmnet = 0;
static const char *database_name = "hlr.sqlite3";
static const char *config_file = "openbsc.cfg";
-
+const char *openbsc_version = "OpenBSC " PACKAGE_VERSION;
+const char *openbsc_copyright =
+ "Copyright (C) 2008-2010 Harald Welte, Holger Freyther\n"
+ "Contributions by Daniel Willmann, Jan Lübbe,Stefan Schmidt\n"
+ "Dieter Spaar, Andreas Eversberg\n\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";
/* timer to store statistics */
#define DB_SYNC_INTERVAL 60, 0
@@ -83,6 +92,16 @@ static void print_help()
printf(" -P --rtp-proxy Enable the RTP Proxy code inside OpenBSC\n");
}
+static void print_version()
+{
+ printf("%s\n", openbsc_version);
+}
+
+static void print_copyright()
+{
+ printf(openbsc_copyright);
+}
+
static void handle_options(int argc, char** argv)
{
while (1) {
@@ -96,11 +115,12 @@ static void handle_options(int argc, char** argv)
{"authorize-everyone", 0, 0, 'a'},
{"pcap", 1, 0, 'p'},
{"timestamp", 0, 0, 'T'},
+ {"version", 0, 0, 'V' },
{"rtp-proxy", 0, 0, 'P'},
{0, 0, 0, 0}
};
- c = getopt_long(argc, argv, "hd:sl:ar:p:TPc:",
+ c = getopt_long(argc, argv, "hd:sl:ar:p:TPVc:",
long_options, &option_index);
if (c == -1)
break;
@@ -131,6 +151,12 @@ static void handle_options(int argc, char** argv)
case 'P':
ipacc_rtp_direct = 0;
break;
+ case 'V':
+ print_version();
+ printf("\n");
+ print_copyright();
+ exit(0);
+ break;
default:
/* ignore */
break;
diff --git a/openbsc/src/mgcp/mgcp_main.c b/openbsc/src/mgcp/mgcp_main.c
index cea0ba427..e45a1e981 100644
--- a/openbsc/src/mgcp/mgcp_main.c
+++ b/openbsc/src/mgcp/mgcp_main.c
@@ -40,6 +40,8 @@
#include <openbsc/mgcp.h>
#include <openbsc/telnet_interface.h>
+#include "../../bscconfig.h"
+
/* this is here for the vty... it will never be called */
void subscr_put() { abort(); }
@@ -51,6 +53,14 @@ void subscr_put() { abort(); }
static struct bsc_fd bfd;
static int first_request = 1;
static struct mgcp_config *cfg;
+const char *openbsc_version = "OpenBSC MGCP " PACKAGE_VERSION;
+const char *openbsc_copyright =
+ "Copyright (C) 2009-2010 Holger Freyther and On-Waves\n"
+ "Contributions by Daniel Willmann, Jan Lübbe,Stefan Schmidt\n"
+ "Dieter Spaar, Andreas Eversberg, Harald Welte\n\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";
static char *config_file = "mgcp.cfg";
@@ -64,6 +74,12 @@ static void print_help()
printf(" -c --config-file filename The config file to use.\n");
}
+static void print_version()
+{
+ printf("%s\n\n", openbsc_version);
+ printf(openbsc_copyright);
+}
+
static void handle_options(int argc, char** argv)
{
while (1) {
@@ -71,10 +87,11 @@ static void handle_options(int argc, char** argv)
static struct option long_options[] = {
{"help", 0, 0, 'h'},
{"config-file", 1, 0, 'c'},
+ {"version", 0, 0, 'V'},
{0, 0, 0, 0},
};
- c = getopt_long(argc, argv, "hc:", long_options, &option_index);
+ c = getopt_long(argc, argv, "hc:V", long_options, &option_index);
if (c == -1)
break;
@@ -87,6 +104,10 @@ static void handle_options(int argc, char** argv)
case 'c':
config_file = talloc_strdup(tall_bsc_ctx, optarg);
break;
+ case 'V':
+ print_version();
+ exit(0);
+ break;
default:
/* ignore */
break;
diff --git a/openbsc/src/telnet_interface.c b/openbsc/src/telnet_interface.c
index 805dd127d..aa119b464 100644
--- a/openbsc/src/telnet_interface.c
+++ b/openbsc/src/telnet_interface.c
@@ -98,21 +98,16 @@ void telnet_init(struct gsm_network *network, int port) {
bsc_register_fd(&server_socket);
}
+extern const char *openbsc_copyright;
+extern const char *openbsc_version;
+
static void print_welcome(int fd) {
int ret;
static char *msg =
- "Welcome to the OpenBSC Control interface\n"
- "Copyright (C) 2008-2010 Harald Welte\n"
- "Contributions by Daniel Willmann, Jan Lübbe, "
- "Stefan Schmidt, Holger Freyther, Andreas Eversberg\n\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.\nType \"help\" to get a short introduction.\n";
+ "Welcome to the OpenBSC Control interface\n";
ret = write(fd, msg, strlen(msg));
+ ret = write(fd, openbsc_copyright, strlen(openbsc_copyright));
}
int telnet_close_client(struct bsc_fd *fd) {
diff --git a/openbsc/src/vty/cardshell.h b/openbsc/src/vty/cardshell.h
index d963a3810..85164d2bd 100644
--- a/openbsc/src/vty/cardshell.h
+++ b/openbsc/src/vty/cardshell.h
@@ -1,5 +1,6 @@
-#define QUAGGA_PROGNAME "OpenBSC"
-#define QUAGGA_VERSION "0.01"
+#include "../../bscconfig.h"
+#define QUAGGA_PROGNAME PACKAGE_NAME
+#define QUAGGA_VERSION PACKAGE_VERSION
#define QUAGGA_COPYRIGHT "Harald Welte <laforge@gnumonks.org>"
#define CONFIGFILE_MASK 022
#define SYSCONFDIR "/usr/local/etc"