summaryrefslogtreecommitdiff
path: root/packet.c
diff options
context:
space:
mode:
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c49
1 files changed, 18 insertions, 31 deletions
diff --git a/packet.c b/packet.c
index 0a8baa5b2..d06ac904a 100644
--- a/packet.c
+++ b/packet.c
@@ -37,7 +37,7 @@
37 */ 37 */
38 38
39#include "includes.h" 39#include "includes.h"
40RCSID("$OpenBSD: packet.c,v 1.100 2002/11/21 22:45:31 markus Exp $"); 40RCSID("$OpenBSD: packet.c,v 1.101 2002/12/10 19:26:50 markus Exp $");
41 41
42#include "xmalloc.h" 42#include "xmalloc.h"
43#include "buffer.h" 43#include "buffer.h"
@@ -1314,16 +1314,26 @@ packet_not_very_much_data_to_write(void)
1314 return buffer_len(&output) < 128 * 1024; 1314 return buffer_len(&output) < 128 * 1024;
1315} 1315}
1316 1316
1317void
1318packet_set_tos(int interactive)
1319{
1320 int tos = interactive ? IPTOS_LOWDELAY : IPTOS_THROUGHPUT;
1321
1322 if (!packet_connection_is_on_socket() ||
1323 !packet_connection_is_ipv4())
1324 return;
1325 if (setsockopt(connection_in, IPPROTO_IP, IP_TOS, &tos,
1326 sizeof(tos)) < 0)
1327 error("setsockopt IP_TOS %d: %.100s:",
1328 tos, strerror(errno));
1329}
1330
1317/* Informs that the current session is interactive. Sets IP flags for that. */ 1331/* Informs that the current session is interactive. Sets IP flags for that. */
1318 1332
1319void 1333void
1320packet_set_interactive(int interactive) 1334packet_set_interactive(int interactive)
1321{ 1335{
1322 static int called = 0; 1336 static int called = 0;
1323#if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN)
1324 int lowdelay = IPTOS_LOWDELAY;
1325 int throughput = IPTOS_THROUGHPUT;
1326#endif
1327 1337
1328 if (called) 1338 if (called)
1329 return; 1339 return;
@@ -1334,35 +1344,12 @@ packet_set_interactive(int interactive)
1334 1344
1335 /* Only set socket options if using a socket. */ 1345 /* Only set socket options if using a socket. */
1336 if (!packet_connection_is_on_socket()) 1346 if (!packet_connection_is_on_socket())
1337 return; 1347 if (interactive)
1338 /*
1339 * IPTOS_LOWDELAY and IPTOS_THROUGHPUT are IPv4 only
1340 */
1341 if (interactive) {
1342 /*
1343 * Set IP options for an interactive connection. Use
1344 * IPTOS_LOWDELAY and TCP_NODELAY.
1345 */
1346#if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN)
1347 if (packet_connection_is_ipv4()) {
1348 if (setsockopt(connection_in, IPPROTO_IP, IP_TOS,
1349 &lowdelay, sizeof(lowdelay)) < 0)
1350 error("setsockopt IPTOS_LOWDELAY: %.100s",
1351 strerror(errno));
1352 }
1353#endif
1354 set_nodelay(connection_in); 1348 set_nodelay(connection_in);
1355 } else if (packet_connection_is_ipv4()) {
1356 /*
1357 * Set IP options for a non-interactive connection. Use
1358 * IPTOS_THROUGHPUT.
1359 */
1360#if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN) 1349#if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN)
1361 if (setsockopt(connection_in, IPPROTO_IP, IP_TOS, &throughput, 1350 packet_set_tos(interactive);
1362 sizeof(throughput)) < 0)
1363 error("setsockopt IPTOS_THROUGHPUT: %.100s", strerror(errno));
1364#endif 1351#endif
1365 } 1352
1366} 1353}
1367 1354
1368/* Returns true if the current connection is interactive. */ 1355/* Returns true if the current connection is interactive. */