[PATCH 13/15] tgt: BSD builds, some setsockopt are not supported

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some setsockopt() options are not defined or supported
in BSD. overide setsockopt() to an internal routine and
define these Linux options to be -1, Then if the option is -1
just return with no error, else call the original function.

Signed-off-by: Boaz Harrosh <bharrosh@xxxxxxxxxxx>
---
 usr/bsd/os.c         |   11 +++++++++++
 usr/bsd/sys/socket.h |   23 +++++++++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
 create mode 100644 usr/bsd/sys/socket.h

diff --git a/usr/bsd/os.c b/usr/bsd/os.c
index 12d2ec4..6c98d15 100644
--- a/usr/bsd/os.c
+++ b/usr/bsd/os.c
@@ -62,3 +62,14 @@ int os_getnameinfo_ss(struct sockaddr_storage *ss, char *host, size_t hostlen,
 	return getnameinfo((struct sockaddr *)ss, slen, host, hostlen,
 			   serv, servlen, flags);
 }
+
+int bsd_setsockopt(int s, int level, int optname, const void *optval,
+		   socklen_t optlen)
+{
+	if (optname == BSD_NOT_SUPPORTED)
+		return 0;
+
+#undef setsockop
+	return setsockopt(s, level, optname, optval, optlen);
+}
+
diff --git a/usr/bsd/sys/socket.h b/usr/bsd/sys/socket.h
new file mode 100644
index 0000000..c7d7b13
--- /dev/null
+++ b/usr/bsd/sys/socket.h
@@ -0,0 +1,23 @@
+#ifndef __TGTBSD_SYS_SOCKET_H__
+#define __TGTBSD_SYS_SOCKET_H__
+
+/* Overide socket.h on BSD to define Linux specific options, in which case
+ * just return success.
+ */
+
+#include <../include/sys/socket.h>
+
+#define setsockopt bsd_setsockopt
+
+#define BSD_NOT_SUPPORTED -1
+#define TCP_KEEPIDLE	BSD_NOT_SUPPORTED
+#define TCP_KEEPCNT	BSD_NOT_SUPPORTED
+#define TCP_KEEPINTVL	BSD_NOT_SUPPORTED
+#define TCP_CORK	BSD_NOT_SUPPORTED
+#define SOL_TCP		BSD_NOT_SUPPORTED
+
+/* is in bsd/os.c */
+int bsd_setsockopt(int s, int level, int optname, const void *optval,
+		   socklen_t optlen);
+
+#endif /* __TGTBSD_SYS_SOCKET_H__ */
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux