Change in libosmo-sccp[master]: ss7_vty: Print actual connected port number in case of IPA server

laforge gerrit-no-reply at lists.osmocom.org
Fri Apr 30 10:19:27 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/23991 )


Change subject: ss7_vty: Print actual connected port number in case of IPA server
......................................................................

ss7_vty: Print actual connected port number in case of IPA server

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
---
M src/osmo_ss7_vty.c
1 file changed, 11 insertions(+), 1 deletion(-)



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

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 @@
 	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",

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

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I1327a46d0b74c572d2ad828a958090af53b9fa37
Gerrit-Change-Number: 23991
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210430/6a671e38/attachment.htm>


More information about the gerrit-log mailing list