From 88782c4066a4db8cffb0590ca832e4c634a2976d Mon Sep 17 00:00:00 2001
From: Jeremie <jk@jk.fr.eu.org>
Date: Wed, 24 Mar 2010 03:42:34 +0100
Subject: [PATCH 8/9] libbb: setsockopt_bindtodevice() portability stub

A stub which prints a warning and fails is provided for systems which don't
define SO_BINDTODEVICE.
---
 libbb/xconnect.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index 97751eb..d8c8d02 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -21,6 +21,8 @@ int FAST_FUNC setsockopt_broadcast(int fd)
 {
 	return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &const_int_1, sizeof(const_int_1));
 }
+
+#ifdef SO_BINDTODEVICE
 int FAST_FUNC setsockopt_bindtodevice(int fd, const char *iface)
 {
 	int r;
@@ -36,6 +38,14 @@ int FAST_FUNC setsockopt_bindtodevice(int fd, const char *iface)
 		bb_perror_msg("can't bind to interface %s", iface);
 	return r;
 }
+#else
+int FAST_FUNC setsockopt_bindtodevice(int fd UNUSED_PARAM,
+		const char *iface UNUSED_PARAM)
+{
+	bb_error_msg("SO_BINDTODEVICE is not supported on this system");
+	return -1;
+}
+#endif
 
 len_and_sockaddr* FAST_FUNC get_sock_lsa(int fd)
 {
-- 
1.7.0.2

