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/gerrit-log@lists.osmocom.org/.
Max gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/1629
Add ctrl_interface_connect() function
This is similar to existing ctrl_interface_setup() but it creates
client-side connection for CTRL protocol instead of server-side.
Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32
---
M include/osmocom/ctrl/control_if.h
M src/ctrl/control_if.c
2 files changed, 33 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/29/1629/1
diff --git a/include/osmocom/ctrl/control_if.h b/include/osmocom/ctrl/control_if.h
index 512ae10..08175a8 100644
--- a/include/osmocom/ctrl/control_if.h
+++ b/include/osmocom/ctrl/control_if.h
@@ -27,5 +27,7 @@
const char *bind_addr,
uint16_t port,
ctrl_cmd_lookup lookup);
-
+struct ctrl_handle *ctrl_interface_connect(void *data, const char *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 df39486..22dbb81 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -654,6 +654,36 @@
return ctrl_interface_setup_dynip(data, "127.0.0.1", port, lookup);
}
+struct ctrl_handle *ctrl_interface_connect(void *data, const char *addr,
+ uint16_t port,
+ ctrl_cmd_lookup lookup)
+{
+ int ret;
+ struct ctrl_handle *ctrl;
+
+ ctrl = talloc_zero(data, struct ctrl_handle);
+ if (!ctrl)
+ return NULL;
+
+ INIT_LLIST_HEAD(&ctrl->ccon_list);
+
+ ctrl->data = data;
+ ctrl->lookup = lookup;
+
+ ctrl->listen_fd.cb = NULL;
+ ctrl->listen_fd.data = ctrl;
+ ret = osmo_sock_init_ifd(&ctrl->listen_fd, AF_INET, SOCK_STREAM,
+ IPPROTO_TCP, addr, port, OSMO_SOCK_F_CONNECT);
+ if (ret < 0) {
+ LOGP(DLCTRL, LOGL_ERROR, "Cannot connect to CTRL at %s:%u\n",
+ addr, port);
+ talloc_free(ctrl);
+ return NULL;
+ }
+ LOGP(DLCTRL, LOGL_NOTICE, "CTRL connected to %s:%u\n", addr, port);
+ return ctrl;
+}
+
struct ctrl_handle *ctrl_interface_setup_dynip(void *data,
const char *bind_addr,
uint16_t port,
--
To view, visit https://gerrit.osmocom.org/1629
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>