version 1.172, 2010/11/13 23:27:50 |
version 1.173, 2011/05/06 21:14:05 |
|
|
state->bytes = bytes; |
state->bytes = bytes; |
} |
} |
|
|
/* returns 1 if connection is via ipv4 */ |
static int |
|
packet_connection_af(void) |
int |
|
packet_connection_is_ipv4(void) |
|
{ |
{ |
struct sockaddr_storage to; |
struct sockaddr_storage to; |
socklen_t tolen = sizeof(to); |
socklen_t tolen = sizeof(to); |
|
|
if (getsockname(active_state->connection_out, (struct sockaddr *)&to, |
if (getsockname(active_state->connection_out, (struct sockaddr *)&to, |
&tolen) < 0) |
&tolen) < 0) |
return 0; |
return 0; |
if (to.ss_family != AF_INET) |
return to.ss_family; |
return 0; |
|
return 1; |
|
} |
} |
|
|
/* Sets the connection into non-blocking mode. */ |
/* Sets the connection into non-blocking mode. */ |
|
|
static void |
static void |
packet_set_tos(int tos) |
packet_set_tos(int tos) |
{ |
{ |
if (!packet_connection_is_on_socket() || |
if (!packet_connection_is_on_socket()) |
!packet_connection_is_ipv4()) |
|
return; |
return; |
debug3("%s: set IP_TOS 0x%02x", __func__, tos); |
switch (packet_connection_af()) { |
if (setsockopt(active_state->connection_in, IPPROTO_IP, IP_TOS, &tos, |
case AF_INET: |
sizeof(tos)) < 0) |
debug3("%s: set IP_TOS 0x%02x", __func__, tos); |
error("setsockopt IP_TOS %d: %.100s:", |
if (setsockopt(active_state->connection_in, |
tos, strerror(errno)); |
IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) < 0) |
|
error("setsockopt IP_TOS %d: %.100s:", |
|
tos, strerror(errno)); |
|
break; |
|
case AF_INET6: |
|
debug3("%s: set IPV6_TCLASS 0x%02x", __func__, tos); |
|
if (setsockopt(active_state->connection_in, |
|
IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)) < 0) |
|
error("setsockopt IPV6_TCLASS %d: %.100s:", |
|
tos, strerror(errno)); |
|
break; |
|
} |
} |
} |
|
|
/* Informs that the current session is interactive. Sets IP flags for that. */ |
/* Informs that the current session is interactive. Sets IP flags for that. */ |