Message ID | 201602240240.u1O2ePec030429@einhorn.in-berlin.de |
---|---|
State | Superseded |
Headers | show |
Hi Neels, On Wed, Feb 24, 2016 at 03:39:37AM +0100, Neels Hofmeyr wrote: > -struct ctrl_handle *ctrl_interface_setup(void *data, uint16_t port, > - ctrl_cmd_lookup lookup); > +struct ctrl_handle *ctrl_interface_setup(void *data, const char *bind_addr, > + uint16_t port, ctrl_cmd_lookup lookup); we generally don't beak interfaces of our libraries like this. Pleaes add a second/new function like (ctrl_interface_setup2 or ctrl_interface_setup_nonlocal, ctrl_interface_setup_bind, ...) with the new argument. This way old and new code works. See telnet_init_dynif() vs. telnet_init() in libosmovty.
On Wed, Feb 24, 2016 at 10:06:48AM +0100, Harald Welte wrote: > Hi Neels, > > On Wed, Feb 24, 2016 at 03:39:37AM +0100, Neels Hofmeyr wrote: > > -struct ctrl_handle *ctrl_interface_setup(void *data, uint16_t port, > > - ctrl_cmd_lookup lookup); > > +struct ctrl_handle *ctrl_interface_setup(void *data, const char *bind_addr, > > + uint16_t port, ctrl_cmd_lookup lookup); > > we generally don't beak interfaces of our libraries like this. Pleaes I was suspecting so. "Just checking if you're paying attention" ;) > See telnet_init_dynif() vs. telnet_init() in libosmovty. exactly what I had in mind. _dynif is a good suffix to reuse then, I assume. Thanks! ~Neels
diff --git a/include/osmocom/ctrl/control_if.h b/include/osmocom/ctrl/control_if.h index 00caacc..2f327c1 100644 --- a/include/osmocom/ctrl/control_if.h +++ b/include/osmocom/ctrl/control_if.h @@ -20,7 +20,7 @@ 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(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..74c84c9 100644 --- a/src/ctrl/control_if.c +++ b/src/ctrl/control_if.c @@ -670,8 +670,8 @@ static int verify_counter(struct ctrl_cmd *cmd, const char *value, void *data) return 0; } -struct ctrl_handle *ctrl_interface_setup(void *data, uint16_t port, - ctrl_cmd_lookup lookup) +struct ctrl_handle *ctrl_interface_setup(void *data, const char *bind_addr, + uint16_t port, ctrl_cmd_lookup lookup) { int ret; struct ctrl_handle *ctrl; @@ -693,7 +693,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;