Skip to content

Commit

Permalink
Fix compilation on FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
Juergen authored and Juergen committed Nov 11, 2023
1 parent f9bfc01 commit 6f6e91c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

include_directories(.)
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
endif()

if(APPLE)
include_directories(
/opt/local/include
Expand Down
2 changes: 2 additions & 0 deletions web/httpserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <cstdint>

#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>

class HttpServer
{
Expand Down
10 changes: 7 additions & 3 deletions zeroconf/networkhotplugnotifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <netinet/in.h>
#if __FreeBSD__
#include <netlink/netlink.h>
#include <netlink/rtnetlink.h>
#include <netlink/netlink_route.h>
#else
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#endif
#include <net/if.h>
#endif // !__APPLE__

#include <string.h>

struct NetworkHotplugNotifier::Private
{
std::thread mThread;
Expand All @@ -48,7 +50,8 @@ struct NetworkHotplugNotifier::Private
#if !__APPLE__
int fds[2];
if (::pipe(fds) < 0) {
std::cerr << "Could not create socket pair " << errno << std::endl;
std::cerr << "Could not create socket pair "
<< ::strerror(errno) << std::endl;
return;
}
mPipeReadFd = fds[0];
Expand All @@ -73,7 +76,8 @@ struct NetworkHotplugNotifier::Private
#if !__APPLE__
int sock = ::socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (sock < 0) {
std::cerr << "Could not create netlink socket: " << errno << std::endl;
std::cerr << "Could not create netlink socket: "
<< ::strerror(errno) << std::endl;
return;
}

Expand Down

0 comments on commit 6f6e91c

Please sign in to comment.