|
Lines 444-449
packet_connection_is_ipv4(void)
Link Here
|
| 444 |
return 0; |
444 |
return 0; |
| 445 |
} |
445 |
} |
| 446 |
|
446 |
|
|
|
447 |
/* returns 1 if connection is via ipv6 */ |
| 448 |
|
| 449 |
int |
| 450 |
packet_connection_is_ipv6(void) |
| 451 |
{ |
| 452 |
struct sockaddr_storage to; |
| 453 |
socklen_t tolen = sizeof(to); |
| 454 |
|
| 455 |
memset(&to, 0, sizeof(to)); |
| 456 |
if (getsockname(active_state->connection_out, (struct sockaddr *)&to, |
| 457 |
&tolen) < 0) |
| 458 |
return 0; |
| 459 |
#ifdef IPV4_IN_IPV6 |
| 460 |
if (to.ss_family == AF_INET6 && |
| 461 |
IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&to)->sin6_addr)) |
| 462 |
return 0; |
| 463 |
#endif |
| 464 |
if (to.ss_family == AF_INET6) |
| 465 |
return 1; |
| 466 |
return 0; |
| 467 |
} |
| 468 |
|
| 447 |
/* Sets the connection into non-blocking mode. */ |
469 |
/* Sets the connection into non-blocking mode. */ |
| 448 |
|
470 |
|
| 449 |
void |
471 |
void |
|
Lines 1753-1766
static void
Link Here
|
| 1753 |
packet_set_tos(int tos) |
1775 |
packet_set_tos(int tos) |
| 1754 |
{ |
1776 |
{ |
| 1755 |
#if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN) |
1777 |
#if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN) |
| 1756 |
if (!packet_connection_is_on_socket() || |
1778 |
if (!packet_connection_is_on_socket()) |
| 1757 |
!packet_connection_is_ipv4()) |
|
|
| 1758 |
return; |
1779 |
return; |
| 1759 |
debug3("%s: set IP_TOS 0x%02x", __func__, tos); |
1780 |
if (packet_connection_is_ipv4()) { |
| 1760 |
if (setsockopt(active_state->connection_in, IPPROTO_IP, IP_TOS, &tos, |
1781 |
debug3("%s: set IP_TOS 0x%02x", __func__, tos); |
| 1761 |
sizeof(tos)) < 0) |
1782 |
if (setsockopt(active_state->connection_in, IPPROTO_IP, |
| 1762 |
error("setsockopt IP_TOS %d: %.100s:", |
1783 |
IP_TOS, &tos, sizeof(tos)) < 0) |
| 1763 |
tos, strerror(errno)); |
1784 |
error("setsockopt IP_TOS %d: %.100s:", |
|
|
1785 |
tos, strerror(errno)); |
| 1786 |
} |
| 1787 |
# ifdef IPV6_TCLASS |
| 1788 |
else if (packet_connection_is_ipv6()) { |
| 1789 |
debug3("%s: set IPV6_TCLASS 0x%02x", __func__, tos); |
| 1790 |
if (setsockopt(active_state->connection_in, IPPROTO_IPV6, |
| 1791 |
IPV6_TCLASS, &tos, sizeof(tos)) < 0) |
| 1792 |
error("setsockopt IPV6_TCLASS %d: %.100s:", |
| 1793 |
tos, strerror(errno)); |
| 1794 |
} |
| 1795 |
# endif |
| 1764 |
#endif |
1796 |
#endif |
| 1765 |
} |
1797 |
} |
| 1766 |
|
1798 |
|