From b3cfa2ea0861aaee34b00eb0ad97b68060c263ad Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Thu, 23 Jun 2011 17:00:00 +0200 Subject: [PATCH] [lib-client] Disable use_iface() if glibc not used setsockopt(... SO_BINDTODEVICE ...) does not work on OpenBSD. The only way to force an interface seems to specify its IP address and to use setsockopt(... IPPROTO_IP, IP_MULTICAST_IF ...). See the code of ping (-I option). libowlps-client now builds on OpenBSD! --- libowlps-client/libowlps-client.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libowlps-client/libowlps-client.c b/libowlps-client/libowlps-client.c index dd043f4..b9e9e53 100644 --- a/libowlps-client/libowlps-client.c +++ b/libowlps-client/libowlps-client.c @@ -5,6 +5,8 @@ #include #include +#include + #define DEBUG @@ -44,6 +46,7 @@ int owlclient_create_trx_socket(const char *const dest_ip, /* Selects 'iface' as sending interface for the socket 'sockfd'. */ void owlclient_use_iface(const int sockfd, const char *const iface) { +#ifdef __GLIBC__ if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, iface, strlen(iface) + 1) == -1) { @@ -52,6 +55,11 @@ void owlclient_use_iface(const int sockfd, const char *const iface) perror("") ; fprintf(stderr, "Sending through the default interface.\n") ; } +#else // __GLIBC__ + fprintf(stderr, "Cannot select interface %s to send the packet:" + " this option is currently GNU libc-specific.\n" + "Sending through the default interface.\n", iface) ; +#endif // __GLIBC__ }