aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-04-12 04:07:24 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-12 04:07:24 +0000
commit86d6ba077b8d183914eec1f970ddaf077b574f4b (patch)
treeb5a50e018f06200a5357e12d86df8cdec92a7e47 /src
parentd4f319deafc41d000c7e249e1acfe9626dec52a8 (diff)
downloadmpd-86d6ba077b8d183914eec1f970ddaf077b574f4b.tar.gz
mpd-86d6ba077b8d183914eec1f970ddaf077b574f4b.tar.xz
mpd-86d6ba077b8d183914eec1f970ddaf077b574f4b.zip
provide switches for TCP and unix sockets
autoconf flags for enabling and disabling TCP and unix domain socket support. Embedded machines without a TCP stack may be better off without TCP support. git-svn-id: https://svn.musicpd.org/mpd/trunk@7236 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/interface.c4
-rw-r--r--src/listen.c16
-rw-r--r--src/os_compat.h5
3 files changed, 24 insertions, 1 deletions
diff --git a/src/interface.c b/src/interface.c
index 43c8b3654..df9eb63f7 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -245,6 +245,7 @@ void openAInterface(int fd, struct sockaddr *addr)
} else {
const char *hostname;
switch (addr->sa_family) {
+#ifdef HAVE_TCP
case AF_INET:
hostname = (const char *)inet_ntoa(((struct sockaddr_in *)
addr)->sin_addr);
@@ -267,9 +268,12 @@ void openAInterface(int fd, struct sockaddr *addr)
}
break;
#endif
+#endif /* HAVE_TCP */
+#ifdef HAVE_UN
case AF_UNIX:
hostname = "local connection";
break;
+#endif /* HAVE_UN */
default:
hostname = "unknown";
}
diff --git a/src/listen.c b/src/listen.c
index 423b54e9a..6b2ed994e 100644
--- a/src/listen.c
+++ b/src/listen.c
@@ -74,6 +74,7 @@ static int establishListen(const struct sockaddr *addrp, socklen_t addrlen)
int allowReuse = ALLOW_REUSE;
switch (addrp->sa_family) {
+#ifdef HAVE_TCP
case AF_INET:
pf = PF_INET;
break;
@@ -82,9 +83,12 @@ static int establishListen(const struct sockaddr *addrp, socklen_t addrlen)
pf = PF_INET6;
break;
#endif
+#endif /* HAVE_TCP */
+#ifdef HAVE_UN
case AF_UNIX:
pf = PF_UNIX;
break;
+#endif /* HAVE_UN */
default:
FATAL("unknown address family: %i\n", addrp->sa_family);
}
@@ -123,6 +127,7 @@ static void parseListenConfigParam(unsigned int port, ConfigParam * param)
{
const struct sockaddr *addrp;
socklen_t addrlen;
+#ifdef HAVE_TCP
struct sockaddr_in sin4;
#ifdef HAVE_IPV6
struct sockaddr_in6 sin6;
@@ -135,8 +140,10 @@ static void parseListenConfigParam(unsigned int port, ConfigParam * param)
memset(&sin4, 0, sizeof(struct sockaddr_in));
sin4.sin_port = htons(port);
sin4.sin_family = AF_INET;
+#endif /* HAVE_TCP */
if (!param || 0 == strcmp(param->value, "any")) {
+#ifdef HAVE_TCP
DEBUG("binding to any address\n");
#ifdef HAVE_IPV6
if (useIpv6) {
@@ -157,6 +164,10 @@ static void parseListenConfigParam(unsigned int port, ConfigParam * param)
#endif
BINDERROR();
}
+#else /* HAVE_TCP */
+ FATAL("TCP support is disabled\n");
+#endif /* HAVE_TCP */
+#ifdef HAVE_UN
} else if (param->value[0] == '/') {
size_t path_length;
struct sockaddr_un sun;
@@ -173,7 +184,9 @@ static void parseListenConfigParam(unsigned int port, ConfigParam * param)
if (establishListen(addrp, addrlen) < 0)
BINDERROR();
+#endif /* HAVE_UN */
} else {
+#ifdef HAVE_TCP
struct hostent *he;
DEBUG("binding to address for %s\n", param->value);
if (!(he = gethostbyname(param->value))) {
@@ -207,6 +220,9 @@ static void parseListenConfigParam(unsigned int port, ConfigParam * param)
if (establishListen(addrp, addrlen) < 0)
BINDERROR();
+#else /* HAVE_TCP */
+ FATAL("TCP support is disabled\n");
+#endif /* HAVE_TCP */
}
}
diff --git a/src/os_compat.h b/src/os_compat.h
index 6409053c7..97ab02a2a 100644
--- a/src/os_compat.h
+++ b/src/os_compat.h
@@ -64,7 +64,6 @@
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <sys/un.h>
#include <pwd.h>
#include <grp.h>
#include <limits.h>
@@ -75,4 +74,8 @@
#include <sys/ipc.h>
#include <sys/shm.h>
+#ifdef HAVE_UN
+#include <sys/un.h>
+#endif
+
#endif /* OS_COMPAT_H */