aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-02-07 20:07:51 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-02-08 12:47:32 +0100
commit362d10f20adfa0a956c43965f409cc62bb776342 (patch)
tree40e87ef272c5d113848f1a0b3b5d74fea4fbab94 /openbsc/src
parent8cedb1135076abaead01589662a45218356110c9 (diff)
libbsc: Create the RF interface all the time
The interface can be accessed through CTRL and a socket. But currently it is only available when the socket interface has been configured. Create the interface all the time but only listen on the socket when a path has been specified.
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/libbsc/bsc_rf_ctrl.c38
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_main.c11
-rw-r--r--openbsc/src/osmo-nitb/bsc_hack.c10
3 files changed, 31 insertions, 28 deletions
diff --git a/openbsc/src/libbsc/bsc_rf_ctrl.c b/openbsc/src/libbsc/bsc_rf_ctrl.c
index 9eb85e5f7..59f31c99a 100644
--- a/openbsc/src/libbsc/bsc_rf_ctrl.c
+++ b/openbsc/src/libbsc/bsc_rf_ctrl.c
@@ -1,8 +1,8 @@
/* RF Ctl handling socket */
/* (C) 2010 by Harald Welte <laforge@gnumonks.org>
- * (C) 2010-2012 by Holger Hans Peter Freyther <zecke@selfish.org>
- * (C) 2010-2012 by On-Waves
+ * (C) 2010-2014 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2010-2014 by On-Waves
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
@@ -435,26 +435,19 @@ static int msc_signal_handler(unsigned int subsys, unsigned int signal,
return 0;
}
-struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net)
+static int rf_create_socket(struct osmo_bsc_rf *rf, const char *path)
{
unsigned int namelen;
struct sockaddr_un local;
struct osmo_fd *bfd;
- struct osmo_bsc_rf *rf;
int rc;
- rf = talloc_zero(NULL, struct osmo_bsc_rf);
- if (!rf) {
- LOGP(DLINP, LOGL_ERROR, "Failed to create osmo_bsc_rf.\n");
- return NULL;
- }
-
bfd = &rf->listen;
bfd->fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (bfd->fd < 0) {
LOGP(DLINP, LOGL_ERROR, "Can not create socket. %d/%s\n",
errno, strerror(errno));
- return NULL;
+ return -1;
}
local.sun_family = AF_UNIX;
@@ -479,15 +472,13 @@ struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net
LOGP(DLINP, LOGL_ERROR, "Failed to bind '%s' errno: %d/%s\n",
local.sun_path, errno, strerror(errno));
close(bfd->fd);
- talloc_free(rf);
- return NULL;
+ return -1;
}
if (listen(bfd->fd, 0) != 0) {
LOGP(DLINP, LOGL_ERROR, "Failed to listen: %d/%s\n", errno, strerror(errno));
close(bfd->fd);
- talloc_free(rf);
- return NULL;
+ return -1;
}
bfd->when = BSC_FD_READ;
@@ -497,6 +488,23 @@ struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net
if (osmo_fd_register(bfd) != 0) {
LOGP(DLINP, LOGL_ERROR, "Failed to register bfd.\n");
close(bfd->fd);
+ return -1;
+ }
+
+ return 0;
+}
+
+struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net)
+{
+ struct osmo_bsc_rf *rf;
+
+ rf = talloc_zero(NULL, struct osmo_bsc_rf);
+ if (!rf) {
+ LOGP(DLINP, LOGL_ERROR, "Failed to create osmo_bsc_rf.\n");
+ return NULL;
+ }
+
+ if (path && rf_create_socket(rf, path) != 0) {
talloc_free(rf);
return NULL;
}
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c
index 864d62970..84186a6a5 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_main.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c
@@ -228,13 +228,10 @@ int main(int argc, char **argv)
if (rf_ctrl)
bsc_replace_string(data, &data->rf_ctrl_name, rf_ctrl);
- if (data->rf_ctrl_name) {
- data->rf_ctrl = osmo_bsc_rf_create(data->rf_ctrl_name,
- bsc_gsmnet);
- if (!data->rf_ctrl) {
- fprintf(stderr, "Failed to create the RF service.\n");
- exit(1);
- }
+ data->rf_ctrl = osmo_bsc_rf_create(data->rf_ctrl_name, bsc_gsmnet);
+ if (!data->rf_ctrl) {
+ fprintf(stderr, "Failed to create the RF service.\n");
+ exit(1);
}
llist_for_each_entry(msc, &bsc_gsmnet->bsc_data->mscs, entry) {
diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c
index 018393494..96ae0b833 100644
--- a/openbsc/src/osmo-nitb/bsc_hack.c
+++ b/openbsc/src/osmo-nitb/bsc_hack.c
@@ -293,12 +293,10 @@ int main(int argc, char **argv)
/* seed the PRNG */
srand(time(NULL));
- if (rf_ctrl_name) {
- rf_ctrl = osmo_bsc_rf_create(rf_ctrl_name, bsc_gsmnet);
- if (!rf_ctrl) {
- fprintf(stderr, "Failed to create the RF service.\n");
- exit(1);
- }
+ rf_ctrl = osmo_bsc_rf_create(rf_ctrl_name, bsc_gsmnet);
+ if (!rf_ctrl) {
+ fprintf(stderr, "Failed to create the RF service.\n");
+ exit(1);
}
if (db_init(database_name)) {