Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freebsd fix #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
23 changes: 20 additions & 3 deletions C/inet/libinetsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))) )
Expand Down Expand Up @@ -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))) )
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down