From e9219f78cdadfeb3583ac0783159bca4d6e9c5f9 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 17 Mar 2016 14:49:35 +0500 Subject: [PATCH] freebsd fix --- C/inet/libinetsocket.c | 23 ++++++++++++++++++++--- CMakeLists.txt | 6 ++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/C/inet/libinetsocket.c b/C/inet/libinetsocket.c index edd1b11a..cd43fc7b 100644 --- a/C/inet/libinetsocket.c +++ b/C/inet/libinetsocket.c @@ -92,6 +92,13 @@ } +#ifdef __FreeBSD__ +# if !defined(IPV6_ADD_MEMBERSHIP) && defined(IPV6_JOIN_GROUP) +# define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP +# define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP +# endif +#endif + # ifdef __FreeBSD__ # define _TRADITIONAL_RDNS # endif @@ -953,8 +960,13 @@ int create_multicast_socket(const char* group, const char* port, const char* if_ errno = errno_saved; return -1; } - - mreq4.imr_ifindex = interface.ifr_ifindex; + + # ifdef __FreeBSD__ + mreq4.imr_ifindex = interface.ifr_index; + #else + mreq4.imr_ifindex = interface.ifr_ifindex; + # endif + } if ( -1 == check_error(setsockopt(sfd,IPPROTO_IP,IP_ADD_MEMBERSHIP,&mreq4,sizeof(struct ip_mreqn))) ) @@ -993,8 +1005,13 @@ int create_multicast_socket(const char* group, const char* port, const char* if_ errno = errno_saved; return -1; } + + # ifdef __FreeBSD__ + mreq6.ipv6mr_interface = interface.ifr_index; + #else + mreq6.ipv6mr_interface = interface.ifr_ifindex; + # endif - mreq6.ipv6mr_interface = interface.ifr_ifindex; } if ( -1 == check_error(setsockopt(sfd,IPPROTO_IPV6,IPV6_ADD_MEMBERSHIP,&mreq6,sizeof(struct ipv6_mreq))) ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5233618f..fc35bbf2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,8 +27,14 @@ ADD_DEFINITIONS(-Wall -Wextra) #ADD_DEFINITIONS(-DVERBOSE) # Install directories +#For FreeBSD installed files should be stored at /usr/local +IF( CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" ) +SET(HEADER_DIR /usr/local/include/libsocket) +SET(LIB_DIR /usr/local/lib) +ELSE() SET(HEADER_DIR /usr/include/libsocket) SET(LIB_DIR /usr/lib) +ENDIF() ADD_SUBDIRECTORY(C/) ADD_SUBDIRECTORY(headers/)