Change in libosmo-netif[master]: stream: Fix log of IPv6 during accept()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Fri Aug 21 13:28:56 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/19762 )


Change subject: stream: Fix log of IPv6 during accept()
......................................................................

stream: Fix log of IPv6 during accept()

Change-Id: Ib13db8d135138059a70d18a8bba14e53c6514fa7
---
M src/stream.c
1 file changed, 9 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/62/19762/1

diff --git a/src/stream.c b/src/stream.c
index e265ee1..8f83113 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -834,7 +834,9 @@
 {
 	int ret;
 	int sock_fd;
-	struct sockaddr_in sa;
+	char addrstr[128];
+	bool is_ipv6;
+	struct sockaddr_storage sa;
 	socklen_t sa_len = sizeof(sa);
 	struct osmo_stream_srv_link *link = ofd->data;
 
@@ -844,8 +846,13 @@
 			"peer, reason=`%s'\n", strerror(errno));
 		return ret;
 	}
+	is_ipv6 = sa_len == sizeof(struct sockaddr_in6);
 	LOGP(DLINP, LOGL_DEBUG, "accept()ed new link from %s to port %u\n",
-		inet_ntoa(sa.sin_addr), link->port);
+		inet_ntop(is_ipv6 ? AF_INET6 : AF_INET,
+			  is_ipv6 ? (void*)&(((struct sockaddr_in6 *)&sa)->sin6_addr) :
+				    (void*)&(((struct sockaddr_in *)&sa)->sin_addr),
+			  addrstr, sizeof(addrstr)),
+		link->port);
 	sock_fd = ret;
 
 	if (link->proto == IPPROTO_SCTP) {

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

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ib13db8d135138059a70d18a8bba14e53c6514fa7
Gerrit-Change-Number: 19762
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200821/dba5e3ff/attachment.htm>


More information about the gerrit-log mailing list