Commit c3e73100 authored by Mans Rullgard's avatar Mans Rullgard

network: use getservbyport() only if available

The absence of this function will only give a less informative
string back from our fallback implementation of getnameinfo().
Signed-off-by: 's avatarMans Rullgard <mans@mansr.com>
parent da0d0ae9
...@@ -1190,6 +1190,7 @@ HAVE_LIST=" ...@@ -1190,6 +1190,7 @@ HAVE_LIST="
GetProcessTimes GetProcessTimes
GetSystemTimeAsFileTime GetSystemTimeAsFileTime
getrusage getrusage
getservbyport
gettimeofday gettimeofday
gnu_as gnu_as
ibm_asm ibm_asm
...@@ -3158,6 +3159,7 @@ if enabled network; then ...@@ -3158,6 +3159,7 @@ if enabled network; then
check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
check_type netinet/sctp.h "struct sctp_event_subscribe" check_type netinet/sctp.h "struct sctp_event_subscribe"
check_func getaddrinfo $network_extralibs check_func getaddrinfo $network_extralibs
check_func getservbyport $network_extralibs
# Prefer arpa/inet.h over winsock2 # Prefer arpa/inet.h over winsock2
if check_header arpa/inet.h ; then if check_header arpa/inet.h ; then
check_func closesocket check_func closesocket
......
...@@ -235,8 +235,10 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen, ...@@ -235,8 +235,10 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen,
if (serv && servlen > 0) { if (serv && servlen > 0) {
struct servent *ent = NULL; struct servent *ent = NULL;
#if HAVE_GETSERVBYPORT
if (!(flags & NI_NUMERICSERV)) if (!(flags & NI_NUMERICSERV))
ent = getservbyport(sin->sin_port, flags & NI_DGRAM ? "udp" : "tcp"); ent = getservbyport(sin->sin_port, flags & NI_DGRAM ? "udp" : "tcp");
#endif
if (ent) if (ent)
snprintf(serv, servlen, "%s", ent->s_name); snprintf(serv, servlen, "%s", ent->s_name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment