7 /* TCP window scaling control
9 /* #include <iostuff.h>
11 /* int inet_windowsize;
13 /* void set_inet_windowsize(sock, windowsize)
17 /* set_inet_windowsize() overrides the default TCP window size
18 /* with the specified value. When called before listen() or
19 /* accept(), this works around broken infrastructure that
20 /* mis-handles TCP window scaling options.
22 /* The global inet_windowsize variable is available for other
23 /* routines to remember that they wish to override the default
24 /* TCP window size. The variable is not accessed by the
25 /* set_inet_windowsize() function itself.
29 /* TCP communication endpoint, before the connect(2) or listen(2) call.
31 /* The preferred TCP window size. This must be > 0.
33 /* Panic: interface violation.
34 /* Warnings: some error return from setsockopt().
38 /* The Secure Mailer license must be distributed with this software.
41 /* IBM T.J. Watson Research
43 /* Yorktown Heights, NY 10598, USA
46 /* System libraries. */
49 #include <sys/socket.h>
51 /* Utility library. */
56 /* Application storage. */
59 * Tunable to work around broken routers.
61 int inet_windowsize
= 0;
63 /* set_inet_windowsize - set TCP send/receive window size */
65 void set_inet_windowsize(int sock
, int windowsize
)
72 msg_panic("inet_windowsize: bad window size %d", windowsize
);
75 * Generic implementation: set the send and receive buffer size before
76 * listen() or connect().
78 if (setsockopt(sock
, SOL_SOCKET
, SO_SNDBUF
, (char *) &windowsize
,
79 sizeof(windowsize
)) < 0)
80 msg_warn("setsockopt SO_SNDBUF %d: %m", windowsize
);
81 if (setsockopt(sock
, SOL_SOCKET
, SO_RCVBUF
, (char *) &windowsize
,
82 sizeof(windowsize
)) < 0)
83 msg_warn("setsockopt SO_RCVBUF %d: %m", windowsize
);