[PATCH 2/3] add ctrl_interface_setup_dynip() for bind address

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Neels Hofmeyr nhofmeyr at sysmocom.de
Wed Feb 24 17:59:31 UTC 2016


Make the ctrl interface bind address configurable, so that it may be made
available on other addresses than 127.0.0.1. The specific aim is to allow
running multiple osmo-nitbs alongside each other (commits in openbsc follow).
---
 include/osmocom/ctrl/control_if.h |  4 ++++
 src/ctrl/control_if.c             | 10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/osmocom/ctrl/control_if.h b/include/osmocom/ctrl/control_if.h
index 00caacc..181c60a 100644
--- a/include/osmocom/ctrl/control_if.h
+++ b/include/osmocom/ctrl/control_if.h
@@ -22,5 +22,9 @@ struct ctrl_handle {
 int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd);
 struct ctrl_handle *ctrl_interface_setup(void *data, uint16_t port,
 					 ctrl_cmd_lookup lookup);
+struct ctrl_handle *ctrl_interface_setup_dynip(void *data,
+					       const char *bind_addr,
+					       uint16_t port,
+					       ctrl_cmd_lookup lookup);
 
 int ctrl_cmd_handle(struct ctrl_handle *ctrl, struct ctrl_cmd *cmd, void *data);
diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c
index 18e695d..bde245d 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -673,6 +673,14 @@ static int verify_counter(struct ctrl_cmd *cmd, const char *value, void *data)
 struct ctrl_handle *ctrl_interface_setup(void *data, uint16_t port,
 					 ctrl_cmd_lookup lookup)
 {
+	return ctrl_interface_setup_dynip(data, "127.0.0.1", port, lookup);
+}
+
+struct ctrl_handle *ctrl_interface_setup_dynip(void *data,
+					       const char *bind_addr,
+					       uint16_t port,
+					       ctrl_cmd_lookup lookup)
+{
 	int ret;
 	struct ctrl_handle *ctrl;
 
@@ -693,7 +701,7 @@ struct ctrl_handle *ctrl_interface_setup(void *data, uint16_t port,
 	ctrl->listen_fd.cb = listen_fd_cb;
 	ctrl->listen_fd.data = ctrl;
 	ret = osmo_sock_init_ofd(&ctrl->listen_fd, AF_INET, SOCK_STREAM, IPPROTO_TCP,
-				 "127.0.0.1", port, OSMO_SOCK_F_BIND);
+				 bind_addr, port, OSMO_SOCK_F_BIND);
 	if (ret < 0)
 		goto err_vec;
 
-- 
2.1.4




More information about the OpenBSC mailing list