diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h index 036c594ec..5cebf278f 100644 --- a/include/osmocom/gprs/gprs_ns2.h +++ b/include/osmocom/gprs/gprs_ns2.h @@ -9,6 +9,7 @@ #include struct osmo_sockaddr; +struct osmo_sockaddr_str; struct gprs_ns2_inst; struct gprs_ns2_nse; @@ -157,7 +158,7 @@ char *gprs_ns2_ll_str_buf(char *buf, size_t buf_len, struct gprs_ns2_vc *nsvc); char *gprs_ns2_ll_str_c(const void *ctx, struct gprs_ns2_vc *nsvc); /* vty */ -int gprs_ns2_vty_init(struct gprs_ns2_inst *nsi); +int gprs_ns2_vty_init(struct gprs_ns2_inst *nsi, struct osmo_sockaddr_str *default_bind); int gprs_ns2_vty_create(); void gprs_ns2_vty_force_vc_mode(bool force, enum gprs_ns2_vc_mode mode, const char *reason); diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c index 321b23f25..824466ba5 100644 --- a/src/gb/gprs_ns2_vty.c +++ b/src/gb/gprs_ns2_vty.c @@ -690,7 +690,13 @@ DEFUN(logging_fltr_nsvc, return CMD_SUCCESS; } -int gprs_ns2_vty_init(struct gprs_ns2_inst *nsi) +/** + * gprs_ns2_vty_init initialize the vty + * \param[inout] nsi + * \param[in] default_bind set the default address to bind to. Can be NULL. + * \return 0 on success + */ +int gprs_ns2_vty_init(struct gprs_ns2_inst *nsi, struct osmo_sockaddr_str *default_bind) { static bool vty_elements_installed = false; @@ -698,6 +704,8 @@ int gprs_ns2_vty_init(struct gprs_ns2_inst *nsi) memset(&priv, 0, sizeof(struct ns2_vty_priv)); INIT_LLIST_HEAD(&priv.vtyvc); priv.vc_mode = NS2_VC_MODE_BLOCKRESET; + if (default_bind) + memcpy(&priv.udp, default_bind, sizeof(*default_bind)); /* Regression test code may call this function repeatedly, so make sure * that VTY elements are not duplicated, which would assert. */