summaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorDaniel Willmann <daniel@totalueberwachung.de>2011-07-22 17:55:42 +0200
committerHarald Welte <laforge@gnumonks.org>2014-08-21 15:34:14 +0200
commit782974b6c9f562be223023b25547bb0d5e258864 (patch)
tree1acbf5e58632c3d2ba5f8d5ee21fa1c8af1b3f90 /openbsc
parent0e0cf37c44d70feb23123d7bff0ab89f97fc1c28 (diff)
libctrl: Change controlif_setup so it returns the ctrl handle
nat: Catch up with controlif_setup API change We now save a control handle reference in the nat osmo-bsc: Catch up with controlif_setup API change We now save a control handle reference in the gsm network
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/control_cmd.h1
-rw-r--r--openbsc/include/openbsc/control_if.h10
-rw-r--r--openbsc/src/libctrl/control_if.c25
3 files changed, 20 insertions, 16 deletions
diff --git a/openbsc/include/openbsc/control_cmd.h b/openbsc/include/openbsc/control_cmd.h
index 2a5391f5..a3f74b48 100644
--- a/openbsc/include/openbsc/control_cmd.h
+++ b/openbsc/include/openbsc/control_cmd.h
@@ -150,6 +150,5 @@ struct ctrl_cmd_element cmd_##cmdname = { \
}
struct gsm_network;
-int controlif_setup(struct gsm_network *gsmnet, uint16_t port);
#endif /* _CONTROL_CMD_H */
diff --git a/openbsc/include/openbsc/control_if.h b/openbsc/include/openbsc/control_if.h
index 96fbf6bf..6afc86d7 100644
--- a/openbsc/include/openbsc/control_if.h
+++ b/openbsc/include/openbsc/control_if.h
@@ -5,9 +5,17 @@
#include <openbsc/control_cmd.h>
#include <openbsc/gsm_data.h>
+struct ctrl_handle {
+ struct osmo_fd listen_fd;
+ struct gsm_network *gsmnet;
+
+ /* List of control connections */
+ struct llist_head ccon_list;
+};
+
int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd);
int ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data);
-int controlif_setup(struct gsm_network *gsmnet, uint16_t port);
+struct ctrl_handle *controlif_setup(struct gsm_network *gsmnet, uint16_t port);
#endif /* _CONTROL_IF_H */
diff --git a/openbsc/src/libctrl/control_if.c b/openbsc/src/libctrl/control_if.c
index 36fdc280..e871a519 100644
--- a/openbsc/src/libctrl/control_if.c
+++ b/openbsc/src/libctrl/control_if.c
@@ -39,6 +39,7 @@
#include <sys/types.h>
#include <openbsc/control_cmd.h>
+#include <openbsc/control_if.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/ipaccess.h>
@@ -62,14 +63,6 @@
#include <osmocom/abis/e1_input.h>
#include <osmocom/abis/ipa.h>
-struct ctrl_handle {
- struct osmo_fd listen_fd;
- struct gsm_network *gsmnet;
-
- /* List of control connections */
- struct llist_head ccon_list;
-};
-
vector ctrl_node_vec;
int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd)
@@ -607,33 +600,37 @@ static int verify_counter(struct ctrl_cmd *cmd, const char *value, void *data)
return 0;
}
-int controlif_setup(struct gsm_network *gsmnet, uint16_t port)
+struct ctrl_handle *controlif_setup(struct gsm_network *gsmnet, uint16_t port)
{
int ret;
struct ctrl_handle *ctrl;
ctrl = talloc_zero(tall_bsc_ctx, struct ctrl_handle);
if (!ctrl)
- return -ENOMEM;
+ return NULL;
INIT_LLIST_HEAD(&ctrl->ccon_list);
ctrl->gsmnet = gsmnet;
ctrl_node_vec = vector_init(5);
- if (!ctrl_node_vec)
- return -ENOMEM;
+ if (!ctrl_node_vec) {
+ talloc_free(ctrl);
+ return NULL;
+ }
/* Listen for control connections */
ret = make_sock(&ctrl->listen_fd, IPPROTO_TCP, INADDR_LOOPBACK, port,
0, listen_fd_cb, ctrl);
if (ret < 0) {
talloc_free(ctrl);
- return ret;
+ vector_free(ctrl_node_vec);
+ ctrl_node_vec = NULL;
+ return NULL;
}
ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_rate_ctr);
ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_counter);
- return ret;
+ return ctrl;
}