aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-04-30 12:17:17 +0200
committerlaforge <laforge@osmocom.org>2021-05-03 19:31:56 +0000
commita7c4f97348d415491c64565dfb8defec4c68b3ef (patch)
treeadbc687cc879a143338bfb4521efe18da2f881b5
parentc288852320dd09b3511396729c4f5d05c5c04cee (diff)
ss7_vty: Print actual connected port number in case of IPA serverHEADmaster
In IPA, unlike M3UA/SUA, we often have clients connecting from random/unknown ports. In such cases, the configured remote port is '0'. Let's use getsockname to determine the actual source ip/port of the connected client (if any) during "show ... asp" Change-Id: I1327a46d0b74c572d2ad828a958090af53b9fa37 Closes: SYS#5429
-rw-r--r--src/osmo_ss7_vty.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index b3aa9ef..4db3c53 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -37,6 +37,8 @@
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/misc.h>
+#include <osmocom/netif/stream.h>
+
#include <osmocom/sigtran/osmo_ss7.h>
#include <osmocom/sigtran/protocol/mtp.h>
@@ -765,7 +767,15 @@ DEFUN(show_cs7_asp, show_cs7_asp_cmd,
vty_out(vty, "------------ ------------ ------------- ---- ----------------------- ----------%s", VTY_NEWLINE);
llist_for_each_entry(asp, &inst->asp_list, list) {
- osmo_ss7_asp_peer_snprintf(buf, sizeof(buf), &asp->cfg.remote);
+ if (asp->cfg.proto == OSMO_SS7_ASP_PROT_IPA && asp->cfg.remote.port == 0 && asp->server) {
+ struct osmo_fd *ofd = osmo_stream_srv_get_ofd(asp->server);
+ char hostbuf[64];
+ char portbuf[16];
+ osmo_sock_get_ip_and_port(ofd->fd, hostbuf, sizeof(hostbuf),
+ portbuf, sizeof(portbuf), false);
+ snprintf(buf, sizeof(buf), "%s:%s", hostbuf, portbuf);
+ } else
+ osmo_ss7_asp_peer_snprintf(buf, sizeof(buf), &asp->cfg.remote);
vty_out(vty, "%-12s %-12s %-13s %-4s %-14s %-10s%s",
asp->cfg.name, "?",
asp->fi? osmo_fsm_inst_state_name(asp->fi) : "uninitialized",