[Xorp-cvs] SF.net SVN: xorp:[11552] trunk/xorp/libcomm
bms_fbsd at users.sourceforge.net
bms_fbsd at users.sourceforge.net
Mon Sep 21 15:53:57 PDT 2009
Revision: 11552
http://xorp.svn.sourceforge.net/xorp/?rev=11552&view=rev
Author: bms_fbsd
Date: 2009-09-21 22:53:57 +0000 (Mon, 21 Sep 2009)
Log Message:
-----------
Add libcomm wrapper for TCP_NOPUSH.
Modified Paths:
--------------
trunk/xorp/libcomm/comm_api.h
trunk/xorp/libcomm/comm_sock.c
trunk/xorp/libcomm/comm_user.c
Modified: trunk/xorp/libcomm/comm_api.h
===================================================================
--- trunk/xorp/libcomm/comm_api.h 2009-09-21 22:48:30 UTC (rev 11551)
+++ trunk/xorp/libcomm/comm_api.h 2009-09-21 22:53:57 UTC (rev 11552)
@@ -188,6 +188,13 @@
extern int comm_tos_present(void);
/**
+ * Test whether the underlying system has TCP_NOPUSH support.
+ *
+ * @return XORP_OK on success, otherwise XORP_ERROR.
+ */
+extern int comm_nopush_present(void);
+
+/**
* Test whether the underlying system has IP_TTL support.
*
* @return XORP_OK on success, otherwise XORP_ERROR.
@@ -800,6 +807,15 @@
extern int comm_set_nodelay(xsock_t sock, int val);
/**
+ * Set/reset the TCP_NOPUSH option on a TCP socket.
+ *
+ * @param sock the socket whose option we want to set/reset.
+ * @param val if non-zero, the option will be set, otherwise will be reset.
+ * @return XORP_OK on success, otherwise XORP_ERROR.
+ */
+extern int comm_set_nopush(xsock_t sock, int val);
+
+/**
* Set/reset the SO_LINGER option on a socket.
*
* @param sock the socket whose option we want to set/reset.
Modified: trunk/xorp/libcomm/comm_sock.c
===================================================================
--- trunk/xorp/libcomm/comm_sock.c 2009-09-21 22:48:30 UTC (rev 11551)
+++ trunk/xorp/libcomm/comm_sock.c 2009-09-21 22:53:57 UTC (rev 11552)
@@ -1018,6 +1018,30 @@
}
int
+comm_set_nopush(xsock_t sock, int val)
+{
+#ifdef TCP_NOPUSH /* XXX: Defined in <netinet/tcp.h> across Free/Net/OpenBSD */
+ if (setsockopt(sock, IPPROTO_TCP, TCP_NOPUSH,
+ XORP_SOCKOPT_CAST(&val), sizeof(val)) < 0) {
+ _comm_set_serrno();
+ XLOG_ERROR("Error %s TCP_NOPUSH on socket %d: %s",
+ (val)? "set": "reset", sock,
+ comm_get_error_str(comm_get_last_error()));
+ return (XORP_ERROR);
+ }
+
+ return (XORP_OK);
+
+#else /* ! TCP_NOPUSH */
+ UNUSED(sock);
+ UNUSED(val);
+ XLOG_WARNING("TCP_NOPUSH Undefined!");
+
+ return (XORP_ERROR);
+#endif /* ! TCP_NOPUSH */
+}
+
+int
comm_set_tos(xsock_t sock, int val)
{
#ifdef IP_TOS
Modified: trunk/xorp/libcomm/comm_user.c
===================================================================
--- trunk/xorp/libcomm/comm_user.c 2009-09-21 22:48:30 UTC (rev 11551)
+++ trunk/xorp/libcomm/comm_user.c 2009-09-21 22:53:57 UTC (rev 11552)
@@ -193,6 +193,16 @@
}
int
+comm_nopush_present(void)
+{
+#ifdef TCP_NOPUSH
+ return XORP_OK;
+#else
+ return XORP_ERROR;
+#endif
+}
+
+int
comm_unicast_ttl_present(void)
{
#ifdef IP_TTL
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Xorp-cvs
mailing list