Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
# define HAVE_NETINET_IN_H
#endif

#if !defined(WIN32) && !defined(_AIX)
# define HAVE_BIND_INTERFACE
#endif

#define OPENSSL_LOAD_CONF

/* ============================================================
Expand Down
2 changes: 1 addition & 1 deletion src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
return MOSQ_ERR_INVAL;
}
}else if(!strcmp(token, "bind_interface")){
#ifdef SO_BINDTODEVICE
#ifdef HAVE_BIND_INTERFACE
if(reload){
continue; /* Rebinding listeners not valid during reloading. */
}
Expand Down
14 changes: 7 additions & 7 deletions src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

#ifndef WIN32
# include <arpa/inet.h>
# ifndef _AIX
# include <ifaddrs.h>
# endif
# include <netdb.h>
# include <netinet/tcp.h>
# include <strings.h>
Expand All @@ -45,6 +42,10 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
# include <netinet/in.h>
#endif

#ifdef HAVE_BIND_INTERFACE
# include <ifaddrs.h>
#endif

#if defined(WITH_UNIX_SOCKETS) || defined(WITH_TLS)
# include "sys/stat.h"
#endif
Expand Down Expand Up @@ -718,15 +719,14 @@ int net__tls_load_verify(struct mosquitto__listener *listener)
}


#if !defined(WIN32) && !defined(_AIX)
#ifdef HAVE_BIND_INTERFACE


static int net__bind_interface(struct mosquitto__listener *listener, struct addrinfo *rp)
{
/*
* This binds the listener sock to a network interface.
* The use of SO_BINDTODEVICE requires root access, which we don't have, so instead
* use getifaddrs to find the interface addresses, and use IP of the
* Use getifaddrs to find the interface addresses, then use the IP of the
* matching interface in the later bind().
*/
struct ifaddrs *ifaddr;
Expand Down Expand Up @@ -874,7 +874,7 @@ static int net__socket_listen_tcp(struct mosquitto__listener *listener)
return 1;
}

#if !defined(WIN32) && !defined(_AIX)
#ifdef HAVE_BIND_INTERFACE
if(listener->bind_interface){
/* It might be possible that an interface does not support all relevant sa_families.
* We should successfully find at least one. */
Expand Down