version 1.100, 2002/11/21 22:45:31 |
version 1.101, 2002/12/10 19:26:50 |
|
|
return buffer_len(&output) < 128 * 1024; |
return buffer_len(&output) < 128 * 1024; |
} |
} |
|
|
|
void |
|
packet_set_tos(int interactive) |
|
{ |
|
int tos = interactive ? IPTOS_LOWDELAY : IPTOS_THROUGHPUT; |
|
|
|
if (!packet_connection_is_on_socket() || |
|
!packet_connection_is_ipv4()) |
|
return; |
|
if (setsockopt(connection_in, IPPROTO_IP, IP_TOS, &tos, |
|
sizeof(tos)) < 0) |
|
error("setsockopt IP_TOS %d: %.100s:", |
|
tos, strerror(errno)); |
|
} |
|
|
/* Informs that the current session is interactive. Sets IP flags for that. */ |
/* Informs that the current session is interactive. Sets IP flags for that. */ |
|
|
void |
void |
packet_set_interactive(int interactive) |
packet_set_interactive(int interactive) |
{ |
{ |
static int called = 0; |
static int called = 0; |
int lowdelay = IPTOS_LOWDELAY; |
|
int throughput = IPTOS_THROUGHPUT; |
|
|
|
if (called) |
if (called) |
return; |
return; |
|
|
/* Only set socket options if using a socket. */ |
/* Only set socket options if using a socket. */ |
if (!packet_connection_is_on_socket()) |
if (!packet_connection_is_on_socket()) |
return; |
return; |
/* |
if (interactive) |
* IPTOS_LOWDELAY and IPTOS_THROUGHPUT are IPv4 only |
|
*/ |
|
if (interactive) { |
|
/* |
|
* Set IP options for an interactive connection. Use |
|
* IPTOS_LOWDELAY and TCP_NODELAY. |
|
*/ |
|
if (packet_connection_is_ipv4()) { |
|
if (setsockopt(connection_in, IPPROTO_IP, IP_TOS, |
|
&lowdelay, sizeof(lowdelay)) < 0) |
|
error("setsockopt IPTOS_LOWDELAY: %.100s", |
|
strerror(errno)); |
|
} |
|
set_nodelay(connection_in); |
set_nodelay(connection_in); |
} else if (packet_connection_is_ipv4()) { |
packet_set_tos(interactive); |
/* |
|
* Set IP options for a non-interactive connection. Use |
|
* IPTOS_THROUGHPUT. |
|
*/ |
|
if (setsockopt(connection_in, IPPROTO_IP, IP_TOS, &throughput, |
|
sizeof(throughput)) < 0) |
|
error("setsockopt IPTOS_THROUGHPUT: %.100s", strerror(errno)); |
|
} |
|
} |
} |
|
|
/* Returns true if the current connection is interactive. */ |
/* Returns true if the current connection is interactive. */ |