mirror of
https://gerrit.osmocom.org/osmo-gbproxy
synced 2024-08-21 18:36:25 +00:00
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.
This commit is contained in:
parent
ae3ec99f37
commit
bcfa0b6a92
3 changed files with 31 additions and 28 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in a new issue