aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r--src/microhttpd/daemon.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 644e134f..6aaeaae4 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -7450,6 +7450,9 @@ process_interim_params (struct MHD_Daemon *d,
7450 d->listen_is_unix = _MHD_UNKNOWN; 7450 d->listen_is_unix = _MHD_UNKNOWN;
7451#endif /* ! SO_DOMAIN || ! AF_UNIX */ 7451#endif /* ! SO_DOMAIN || ! AF_UNIX */
7452 d->listen_fd = params->listen_fd; 7452 d->listen_fd = params->listen_fd;
7453#ifdef MHD_USE_GETSOCKNAME
7454 d->port = 0; /* Force use of autodetection */
7455#endif /* MHD_USE_GETSOCKNAME */
7453 } 7456 }
7454 } 7457 }
7455 return true; 7458 return true;
@@ -8032,6 +8035,43 @@ MHD_start_daemon_va (unsigned int flags,
8032 servaddr = (struct sockaddr *) &servaddr4; 8035 servaddr = (struct sockaddr *) &servaddr4;
8033 } 8036 }
8034 } 8037 }
8038 else
8039 {
8040#ifdef MHD_USE_GETSOCKNAME
8041 daemon->port = 0; /* Force use of autodetection */
8042#else /* ! MHD_USE_GETSOCKNAME */
8043 switch (servaddr->sa_family)
8044 {
8045 case AF_INET:
8046 {
8047 struct sockaddr_in sa4;
8048 memcpy (&sa4, servaddr, sizeof(sa4)); /* Required due to stronger alignment */
8049 daemon->port = ntohs (sa4.sin_port);
8050 break;
8051 }
8052#ifdef HAVE_INET6
8053 case AF_INET6:
8054 {
8055 struct sockaddr_in6 sa6;
8056 memcpy (&sa6, servaddr, sizeof(sa6)); /* Required due to stronger alignment */
8057 daemon->port = ntohs (sa6.sin6_port);
8058 mhd_assert (0 != (*pflags & MHD_USE_IPv6));
8059 break;
8060 }
8061#endif /* HAVE_INET6 */
8062#ifdef AF_UNIX
8063 case AF_UNIX:
8064 daemon->port = 0; /* special value for UNIX domain sockets */
8065 daemon->listen_is_unix = _MHD_YES;
8066 break;
8067#endif
8068 default:
8069 daemon->port = 0; /* ugh */
8070 daemon->listen_is_unix = _MHD_UNKNOWN;
8071 break;
8072 }
8073#endif /* ! MHD_USE_GETSOCKNAME */
8074 }
8035 daemon->listen_fd = listen_fd; 8075 daemon->listen_fd = listen_fd;
8036 if (0 != (*pflags & MHD_USE_IPv6)) 8076 if (0 != (*pflags & MHD_USE_IPv6))
8037 { 8077 {