Skip to content

Commit

Permalink
ESP-IDF: Fix non IPv6 builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdeep1 committed Jul 31, 2023
1 parent 3694156 commit 7146a45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/coap_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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),
Expand All @@ -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 */
Expand Down
2 changes: 2 additions & 0 deletions src/coap_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down

0 comments on commit 7146a45

Please sign in to comment.