 configure.in            |    3 ++-
 contrib/MacOSX/config.h |    2 ++
 src/ngircd/conn.c       |   11 ++++++-----
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/configure.in b/configure.in
index 3d4c640..10a72d3 100644
--- a/configure.in
+++ b/configure.in
@@ -105,7 +105,8 @@ AC_CHECK_HEADERS([ \
 	strings.h sys/socket.h sys/time.h unistd.h \
 	],,AC_MSG_ERROR([required C header missing!]))
 
-AC_CHECK_HEADERS([arpa/inet.h ctype.h malloc.h stdbool.h stddef.h varargs.h])
+AC_CHECK_HEADERS([ \
+	arpa/inet.h ctype.h malloc.h netinet/ip.h stdbool.h stddef.h varargs.h])
 
 # -- Datatypes --
 
diff --git a/contrib/MacOSX/config.h b/contrib/MacOSX/config.h
index 60b0618..66465e2 100644
--- a/contrib/MacOSX/config.h
+++ b/contrib/MacOSX/config.h
@@ -71,6 +71,8 @@
 #define HAVE_STDBOOL_H 1
 /* Define to 1 if you have the <arpa/inet.h> header file. */
 #define HAVE_ARPA_INET_H 1
+/* Define to 1 if you have the <netinet/ip.h> header file. */
+#define HAVE_NETINET_IP_H 1
 
 /* Define to 1 if you have the `kqueue' function. */
 #define HAVE_KQUEUE 1
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index e82b717..1e4ba0a 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -1877,12 +1877,13 @@ Init_Socket( int Sock )
 	}
 
 	/* Set type of service (TOS) */
-#if defined(IP_TOS) && defined(IPTOS_LOWDELAY)
+#if defined(IPPROTO_IP) && defined(IPTOS_LOWDELAY)
 	value = IPTOS_LOWDELAY;
-	LogDebug("Setting option IP_TOS on socket %d to IPTOS_LOWDELAY (%d).", Sock, value );
-	if( setsockopt( Sock, SOL_IP, IP_TOS, &value, (socklen_t)sizeof( value )) != 0 )
-	{
-		Log( LOG_ERR, "Can't set socket option IP_TOS: %s!", strerror( errno ));
+	LogDebug("Setting IP_TOS on socket %d to IPTOS_LOWDELAY.", Sock);
+	if (setsockopt(Sock, IPPROTO_IP, IP_TOS, &value,
+		       (socklen_t) sizeof(value))) {
+		Log(LOG_ERR, "Can't set socket option IP_TOS: %s!",
+		    strerror(errno));
 		/* ignore this error */
 	}
 #endif
