pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35242?usp=email )
Change subject: vty: Retrieve IP addr set from sk when dumping xUA server ......................................................................
vty: Retrieve IP addr set from sk when dumping xUA server
Until now we simply printed back the configured set of IP addresses, not the one retrieved from the socket at the time, because we didn't have any easy means to retrieve multiple addresses from a socket. This is possible since recently using libosmocore APIs. Use them.
Depends: libosmo-netif.git Change-Id I1bd3f790d93af74c150938a59108b882ad2820f3 Depends: libosmocore.git Change-Id I18a0e1a652a3e8ef3e97154355eb1d07a14ef0bd Related: SYS#6636 Change-Id: I331b6e2fe11cd97e286b7ba684d4a17b8055f9d4 --- M TODO-RELEASE M src/osmo_ss7_vty.c 2 files changed, 44 insertions(+), 4 deletions(-)
Approvals: osmith: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified
diff --git a/TODO-RELEASE b/TODO-RELEASE index 1e4c41a..2b15a91 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -9,3 +9,4 @@ #library what description / commit summary line libosmocore >1.9.0 osmo_sock_multiaddr_{add,del}_local_addr() libosmo-netif >1.4.0 osmo_stream_{srv,cli}_get_fd() +libosmocore >1.9,0 osmo_sock_multiaddr_get_ip_and_port(), osmo_multiaddr_ip_and_port_snprintf() \ No newline at end of file diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 5a637b4..6c36768 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -610,11 +610,33 @@
static void vty_dump_xua_server(struct vty *vty, struct osmo_xua_server *xs) { - char buf[512]; + char buf[OSMO_SOCK_MULTIADDR_PEER_STR_MAXLEN]; const char *proto = get_value_string(osmo_ss7_asp_protocol_vals, xs->cfg.proto); - if (osmo_ss7_asp_peer_snprintf(buf, sizeof(buf), &xs->cfg.local) < 0) - snprintf(buf, sizeof(buf), "<error>"); - vty_out(vty, "xUA server for %s on %s%s", proto, buf, VTY_NEWLINE); + int fd = xs->server ? osmo_stream_srv_link_get_fd(xs->server) : -1; + + if (fd < 0) { + if (osmo_ss7_asp_peer_snprintf(buf, sizeof(buf), &xs->cfg.local) < 0) + snprintf(buf, sizeof(buf), "<error>"); + } else { + char hostbuf[OSMO_SOCK_MAX_ADDRS][INET6_ADDRSTRLEN]; + size_t num_hostbuf = ARRAY_SIZE(hostbuf); + char portbuf[6]; + int rc; + rc = osmo_sock_multiaddr_get_ip_and_port(fd, ss7_asp_proto_to_ip_proto(xs->cfg.proto), + &hostbuf[0][0], &num_hostbuf, sizeof(hostbuf[0]), + portbuf, sizeof(portbuf), true); + if (rc < 0) { + snprintf(buf, sizeof(buf), "<error>"); + } else { + if (num_hostbuf > ARRAY_SIZE(hostbuf)) + num_hostbuf = ARRAY_SIZE(hostbuf); + osmo_multiaddr_ip_and_port_snprintf(buf, sizeof(buf), + &hostbuf[0][0], num_hostbuf, sizeof(hostbuf[0]), + portbuf); + } + } + vty_out(vty, "xUA server for %s on %s is %s%s", + proto, buf, fd >= 0 ? "listening" : "inactive", VTY_NEWLINE); }
DEFUN(show_cs7_xua, show_cs7_xua_cmd,