diff --git a/src/coap_io.c b/src/coap_io.c index ae65e3ca..022014b3 100644 --- a/src/coap_io.c +++ b/src/coap_io.c @@ -93,7 +93,10 @@ coap_socket_bind_udp(coap_socket_t *sock, const coap_address_t *listen_addr, coap_address_t *bound_addr) { #ifndef RIOT_VERSION - int on = 1, off = 0; + int on = 1; +#if COAP_IPV6_SUPPORT + int off = 0; +#endif /* COAP_IPV6_SUPPORT */ #else /* ! RIOT_VERSION */ struct timeval timeout = {0, 0}; #endif /* ! RIOT_VERSION */ @@ -129,6 +132,7 @@ coap_socket_bind_udp(coap_socket_t *sock, coap_socket_strerror()); break; #endif /* COAP_IPV4_SUPPORT */ +#if COAP_IPV6_SUPPORT case AF_INET6: /* Configure the socket as dual-stacked */ if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_V6ONLY, OPTVAL_T(&off), @@ -141,6 +145,7 @@ coap_socket_bind_udp(coap_socket_t *sock, coap_log_alert("coap_socket_bind_udp: setsockopt IPV6_PKTINFO: %s\n", coap_socket_strerror()); #endif /* !defined(ESPIDF_VERSION) */ +#endif /* COAP_IPV6_SUPPORT */ setsockopt(sock->fd, IPPROTO_IP, GEN_IP_PKTINFO, OPTVAL_T(&on), sizeof(on)); /* ignore error, because likely cause is that IPv4 is disabled at the os level */ diff --git a/src/coap_net.c b/src/coap_net.c index 1c9b8413..24e5599e 100644 --- a/src/coap_net.c +++ b/src/coap_net.c @@ -4346,6 +4346,7 @@ coap_mcast_set_hops(coap_session_t *session, size_t hops) { } return 1; #endif /* COAP_IPV4_SUPPORT */ +#if COAP_IPV6_SUPPORT case AF_INET6: if (setsockopt(session->sock.fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (const char *)&hops, sizeof(hops)) < 0) { @@ -4354,6 +4355,7 @@ coap_mcast_set_hops(coap_session_t *session, size_t hops) { return 0; } return 1; +#endif /* COAP_IPV6_SUPPORT */ default: break; }