pespin has uploaded this change for review. ( 
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 osmo_stream_srv_link_get_sockname()
Depends: libosmocore.git Change-Id I48950754ed6f61ee5ffa04a447fab8903f10acc0
Related: SYS#6636
Change-Id: I331b6e2fe11cd97e286b7ba684d4a17b8055f9d4
---
M TODO-RELEASE
M src/osmo_ss7_vty.c
2 files changed, 44 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/42/35242/1

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..6ab2401 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_MAX_ADDRS * INET6_ADDRSTRLEN + OSMO_SOCK_MAX_ADDRS + 
2 + 6 + 1];
        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,

--
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35242?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I331b6e2fe11cd97e286b7ba684d4a17b8055f9d4
Gerrit-Change-Number: 35242
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to