aboutsummaryrefslogtreecommitdiffstats
path: root/src/stream.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-08-21 14:43:10 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2020-08-24 12:05:30 +0200
commit97a293e46ab051bb7da811ba4763cb50d3557d42 (patch)
tree35a94d3b7ef3003f1a698f71ac0f4ba9fb015c67 /src/stream.c
parentef6ae62c6e6babc6cbd5b1b72fda59c4c857e08b (diff)
stream: Fix log of IPv6 during accept()pespin/ipv6
Diffstat (limited to 'src/stream.c')
-rw-r--r--src/stream.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/stream.c b/src/stream.c
index e265ee1..5f171ea 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -834,7 +834,9 @@ static int osmo_stream_srv_fd_cb(struct osmo_fd *ofd, unsigned int what)
{
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 @@ static int osmo_stream_srv_fd_cb(struct osmo_fd *ofd, unsigned int what)
"peer, reason=`%s'\n", strerror(errno));
return ret;
}
+ is_ipv6 = ((struct sockaddr *)&sa)->sa_family == AF_INET6;
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) {