You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
From 1658479fe1f113a02a7af48f53da6baeea5df482 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= <olivier.crete@collabora.com>
|
|
Date: Mon, 9 Jul 2018 17:51:27 -0400
|
|
Subject: [PATCH 1/3] api: Don't use inet_ntop
|
|
|
|
It's not defined on Windows. Instead use getnameinfo with
|
|
the numeric request.
|
|
---
|
|
srtcore/api.h | 15 ++++++---------
|
|
1 file changed, 6 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/srtcore/api.h b/srtcore/api.h
|
|
index e6e9d3f..de3b4f0 100644
|
|
--- a/srtcore/api.h
|
|
+++ b/srtcore/api.h
|
|
@@ -270,19 +270,16 @@ inline std::string SockaddrToString(const sockaddr* sadr)
|
|
|
|
std::ostringstream output;
|
|
char hostbuf[1024];
|
|
+ int flags;
|
|
|
|
#if ENABLE_GETNAMEINFO
|
|
- if (!getnameinfo(sadr, sizeof(*sadr), hostbuf, 1024, NULL, 0, NI_NAMEREQD))
|
|
- {
|
|
- output << hostbuf;
|
|
- }
|
|
- else
|
|
+ flags = NI_NAMEREQD;
|
|
+#else
|
|
+ flags = NI_NUMERICHOST | NI_NUMERICSERV;
|
|
#endif
|
|
+
|
|
+ if (!getnameinfo(sadr, sizeof(*sadr), hostbuf, 1024, NULL, 0, flags))
|
|
{
|
|
- if (inet_ntop(sadr->sa_family, addr, hostbuf, 1024) == NULL)
|
|
- {
|
|
- strcpy(hostbuf, "unknown");
|
|
- }
|
|
output << hostbuf;
|
|
}
|
|
|
|
--
|
|
2.17.1
|
|
|
|
|