.\" Title: socket_wrapper
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 2014-07-09
+.\" Date: 2015-08-11
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
-.TH "SOCKET_WRAPPER" "1" "2014\-07\-09" "\ \&" "\ \&"
+.TH "SOCKET_WRAPPER" "1" "2015\-08\-11" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
When debugging, it is often interesting to investigate the network traffic between the client and server within your application\&. If you define SOCKET_WRAPPER_PCAP_FILE=/path/to/file\&.pcap, socket_wrapper will dump all your network traffic to the specified file\&. After the test has been finished you\(cqre able to open the file for example with Wireshark\&.
.RE
.PP
+\fBSOCKET_WRAPPER_MTU\fR
+.RS 4
+With this variable you can change the MTU size\&. However we do not recomment to do that as the default size of 1500 byte is best for formatting PCAP files\&.
+.RE
+.sp
+The minimum value you can set is 512 and the maximum 32768\&.
+.PP
\fBSOCKET_WRAPPER_DEBUGLEVEL\fR
.RS 4
If you need to see what is going on in socket_wrapper itself or try to find a bug, you can enable logging support in socket_wrapper if you built it with debug symbols\&.
socket_wrapper(1)
=================
-:revdate: 2014-07-09
+:revdate: 2015-08-11
NAME
----
network traffic to the specified file. After the test has been finished you're
able to open the file for example with Wireshark.
+*SOCKET_WRAPPER_MTU*::
+
+With this variable you can change the MTU size. However we do not recomment to
+do that as the default size of 1500 byte is best for formatting PCAP files.
+
+The minimum value you can set is 512 and the maximum 32768.
+
*SOCKET_WRAPPER_DEBUGLEVEL*::
If you need to see what is going on in socket_wrapper itself or try to find a
#define SOCKET_TYPE_CHAR_UDP_V6 'Y'
/*
- * Cut down to 1500 byte packets for stream sockets,
- * which makes it easier to format PCAP capture files
- * (as the caller will simply continue from here)
+ * Set the packet MTU to 1500 bytes for stream sockets to make it it easier to
+ * format PCAP capture files (as the caller will simply continue from here).
*/
-#define SOCKET_MAX_PACKET 1500
+#define SOCKET_WRAPPER_MTU_DEFAULT 1500
+#define SOCKET_WRAPPER_MTU_MIN 512
+#define SOCKET_WRAPPER_MTU_MAX 32768
#define SOCKET_MAX_SOCKETS 1024
return s;
}
+static unsigned int socket_wrapper_mtu(void)
+{
+ static unsigned int max_mtu = 0;
+ unsigned int tmp;
+ const char *s;
+ char *endp;
+
+ if (max_mtu != 0) {
+ return max_mtu;
+ }
+
+ max_mtu = SOCKET_WRAPPER_MTU_DEFAULT;
+
+ s = getenv("SOCKET_WRAPPER_MTU");
+ if (s == NULL) {
+ goto done;
+ }
+
+ tmp = strtol(s, &endp, 10);
+ if (s == endp) {
+ goto done;
+ }
+
+ if (tmp < SOCKET_WRAPPER_MTU_MIN || tmp > SOCKET_WRAPPER_MTU_MAX) {
+ goto done;
+ }
+ max_mtu = tmp;
+
+done:
+ return max_mtu;
+}
+
bool socket_wrapper_enabled(void)
{
const char *s = socket_wrapper_dir();
}
switch (si->type) {
- case SOCK_STREAM:
+ case SOCK_STREAM: {
+ unsigned long mtu;
+
if (!si->connected) {
errno = ENOTCONN;
return -1;
break;
}
+ mtu = socket_wrapper_mtu();
for (i = 0; i < (size_t)msg->msg_iovlen; i++) {
size_t nlen;
nlen = len + msg->msg_iov[i].iov_len;
- if (nlen > SOCKET_MAX_PACKET) {
+ if (nlen > mtu) {
break;
}
}
msg->msg_iovlen = i;
if (msg->msg_iovlen == 0) {
*tmp_iov = msg->msg_iov[0];
- tmp_iov->iov_len = MIN(tmp_iov->iov_len, SOCKET_MAX_PACKET);
+ tmp_iov->iov_len = MIN(tmp_iov->iov_len, mtu);
msg->msg_iov = tmp_iov;
msg->msg_iovlen = 1;
}
break;
-
+ }
case SOCK_DGRAM:
if (si->connected) {
if (msg->msg_name) {
(void)fd; /* unused */
switch (si->type) {
- case SOCK_STREAM:
+ case SOCK_STREAM: {
+ unsigned int mtu;
if (!si->connected) {
errno = ENOTCONN;
return -1;
break;
}
+ mtu = socket_wrapper_mtu();
for (i = 0; i < (size_t)msg->msg_iovlen; i++) {
size_t nlen;
nlen = len + msg->msg_iov[i].iov_len;
- if (nlen > SOCKET_MAX_PACKET) {
+ if (nlen > mtu) {
break;
}
}
msg->msg_iovlen = i;
if (msg->msg_iovlen == 0) {
*tmp_iov = msg->msg_iov[0];
- tmp_iov->iov_len = MIN(tmp_iov->iov_len, SOCKET_MAX_PACKET);
+ tmp_iov->iov_len = MIN(tmp_iov->iov_len, mtu);
msg->msg_iov = tmp_iov;
msg->msg_iovlen = 1;
}
break;
-
+ }
case SOCK_DGRAM:
if (msg->msg_name == NULL) {
errno = EINVAL;