diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-12-06 18:25:34 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-12-12 15:54:13 +0100 |
commit | 6ad714de985a8c0ab60bbc5a56bce520e43538b1 (patch) | |
tree | 8ddbc37c1f39764c2e0420f2be2c5156a3fc7e52 | |
parent | 65741dca056e3a16973ad156dd4c09760a6a945b (diff) |
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
-rw-r--r-- | TODO-RELEASE | 1 | ||||
-rw-r--r-- | src/osmo_ss7_vty.c | 30 |
2 files changed, 27 insertions, 4 deletions
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 write_one_xua(struct vty *vty, struct osmo_xua_server *xs) 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, |