From: Guus Sliepen Date: Sat, 16 Dec 2017 21:54:31 +0000 (+0100) Subject: Assume all IPPROTO_* macros exist. X-Git-Tag: release-1.1pre16~49 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=0b2361a9399944cd57def87226f2be7f92646aa5;p=tinc Assume all IPPROTO_* macros exist. --- diff --git a/src/net_packet.c b/src/net_packet.c index 1aa881ce..ce2361cb 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -773,7 +773,7 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { listen_socket[sock].priority = origpriority; switch(sa->sa.sa_family) { -#if defined(IPPROTO_IP) && defined(IP_TOS) +#if defined(IP_TOS) case AF_INET: logger(DEBUG_TRAFFIC, LOG_DEBUG, "Setting IPv4 outgoing packet priority to %d", origpriority); @@ -784,7 +784,7 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { break; #endif -#if defined(IPPROTO_IPV6) & defined(IPV6_TCLASS) +#if defined(IPV6_TCLASS) case AF_INET6: logger(DEBUG_TRAFFIC, LOG_DEBUG, "Setting IPv6 outgoing packet priority to %d", origpriority); diff --git a/src/net_setup.c b/src/net_setup.c index ad9398db..4f9d738f 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -637,7 +637,7 @@ bool setup_myself_reloadable(void) { subnet_add(NULL, s); } -#if !defined(IPPROTO_IP) || !defined(IP_TOS) +#if !defined(IP_TOS) if(priorityinheritance) { logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform for IPv4 connections", "PriorityInheritance"); @@ -645,7 +645,7 @@ bool setup_myself_reloadable(void) { #endif -#if !defined(IPPROTO_IPV6) || !defined(IPV6_TCLASS) +#if !defined(IPV6_TCLASS) if(priorityinheritance) { logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform for IPv6 connections", "PriorityInheritance"); diff --git a/src/net_socket.c b/src/net_socket.c index 43ea4f8d..979e84b9 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -70,17 +70,17 @@ static void configure_tcp(connection_t *c) { #endif -#if defined(IPPROTO_TCP) && defined(TCP_NODELAY) +#if defined(TCP_NODELAY) option = 1; setsockopt(c->socket, IPPROTO_TCP, TCP_NODELAY, (void *)&option, sizeof(option)); #endif -#if defined(IPPROTO_IP) && defined(IP_TOS) && defined(IPTOS_LOWDELAY) +#if defined(IP_TOS) && defined(IPTOS_LOWDELAY) option = IPTOS_LOWDELAY; setsockopt(c->socket, IPPROTO_IP, IP_TOS, (void *)&option, sizeof(option)); #endif -#if defined(IPPROTO_IPV6) && defined(IPV6_TCLASS) && defined(IPTOS_LOWDELAY) +#if defined(IPV6_TCLASS) && defined(IPTOS_LOWDELAY) option = IPTOS_LOWDELAY; setsockopt(c->socket, IPPROTO_IPV6, IPV6_TCLASS, (void *)&option, sizeof(option)); #endif @@ -175,12 +175,14 @@ int setup_listen_socket(const sockaddr_t *sa) { option = 1; setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, (void *)&option, sizeof(option)); -#if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY) +#if defined(IPV6_V6ONLY) if(sa->sa.sa_family == AF_INET6) { setsockopt(nfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option)); } +#else +#warning IPV6_V6ONLY not defined #endif if(get_config_string @@ -271,7 +273,7 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { logger(DEBUG_ALWAYS, LOG_WARNING, "Can't set UDP SO_SNDBUF to %i: %s", udp_sndbuf, sockstrerror(sockerrno)); } -#if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY) +#if defined(IPV6_V6ONLY) if(sa->sa.sa_family == AF_INET6) { setsockopt(nfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option)); @@ -283,14 +285,14 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { #define IP_DONTFRAGMENT IP_DONTFRAG #endif -#if defined(IPPROTO_IP) && defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO) +#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO) if(myself->options & OPTION_PMTU_DISCOVERY) { option = IP_PMTUDISC_DO; setsockopt(nfd, IPPROTO_IP, IP_MTU_DISCOVER, (void *)&option, sizeof(option)); } -#elif defined(IPPROTO_IP) && defined(IP_DONTFRAGMENT) +#elif defined(IP_DONTFRAGMENT) if(myself->options & OPTION_PMTU_DISCOVERY) { option = 1; @@ -299,14 +301,14 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { #endif -#if defined(IPPROTO_IPV6) && defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DO) +#if defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DO) if(myself->options & OPTION_PMTU_DISCOVERY) { option = IPV6_PMTUDISC_DO; setsockopt(nfd, IPPROTO_IPV6, IPV6_MTU_DISCOVER, (void *)&option, sizeof(option)); } -#elif defined(IPPROTO_IPV6) && defined(IPV6_DONTFRAG) +#elif defined(IPV6_DONTFRAG) if(myself->options & OPTION_PMTU_DISCOVERY) { option = 1; @@ -586,7 +588,7 @@ begin: #endif if(proxytype != PROXY_EXEC) { -#if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY) +#if defined(IPV6_V6ONLY) int option = 1; if(c->address.sa.sa_family == AF_INET6) {