diff options
author | Colin Watson <cjwatson@debian.org> | 2011-09-06 09:45:52 +0100 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2011-09-06 09:45:52 +0100 |
commit | f38224d546cdde55f45c13d3d8225d273a3f920e (patch) | |
tree | a91a26b88ac90dc72d0ea3767feabb341eaa50a8 /packet.c | |
parent | 338146a3fc257e216fe5c10fe40e6896b40d7739 (diff) | |
parent | e90790abaf031e037f444a6658e136e48577ea49 (diff) |
merge 5.9p1
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 44 |
1 files changed, 28 insertions, 16 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: packet.c,v 1.172 2010/11/13 23:27:50 djm Exp $ */ | 1 | /* $OpenBSD: packet.c,v 1.173 2011/05/06 21:14:05 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -422,10 +422,8 @@ packet_set_state(int mode, u_int32_t seqnr, u_int64_t blocks, u_int32_t packets, | |||
422 | state->bytes = bytes; | 422 | state->bytes = bytes; |
423 | } | 423 | } |
424 | 424 | ||
425 | /* returns 1 if connection is via ipv4 */ | 425 | static int |
426 | 426 | packet_connection_af(void) | |
427 | int | ||
428 | packet_connection_is_ipv4(void) | ||
429 | { | 427 | { |
430 | struct sockaddr_storage to; | 428 | struct sockaddr_storage to; |
431 | socklen_t tolen = sizeof(to); | 429 | socklen_t tolen = sizeof(to); |
@@ -439,9 +437,9 @@ packet_connection_is_ipv4(void) | |||
439 | #ifdef IPV4_IN_IPV6 | 437 | #ifdef IPV4_IN_IPV6 |
440 | if (to.ss_family == AF_INET6 && | 438 | if (to.ss_family == AF_INET6 && |
441 | IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&to)->sin6_addr)) | 439 | IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&to)->sin6_addr)) |
442 | return 1; | 440 | return AF_INET; |
443 | #endif | 441 | #endif |
444 | return 0; | 442 | return to.ss_family; |
445 | } | 443 | } |
446 | 444 | ||
447 | /* Sets the connection into non-blocking mode. */ | 445 | /* Sets the connection into non-blocking mode. */ |
@@ -1752,16 +1750,30 @@ packet_not_very_much_data_to_write(void) | |||
1752 | static void | 1750 | static void |
1753 | packet_set_tos(int tos) | 1751 | packet_set_tos(int tos) |
1754 | { | 1752 | { |
1755 | #if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN) | 1753 | #ifndef IP_TOS_IS_BROKEN |
1756 | if (!packet_connection_is_on_socket() || | 1754 | if (!packet_connection_is_on_socket()) |
1757 | !packet_connection_is_ipv4()) | ||
1758 | return; | 1755 | return; |
1759 | debug3("%s: set IP_TOS 0x%02x", __func__, tos); | 1756 | switch (packet_connection_af()) { |
1760 | if (setsockopt(active_state->connection_in, IPPROTO_IP, IP_TOS, &tos, | 1757 | # ifdef IP_TOS |
1761 | sizeof(tos)) < 0) | 1758 | case AF_INET: |
1762 | error("setsockopt IP_TOS %d: %.100s:", | 1759 | debug3("%s: set IP_TOS 0x%02x", __func__, tos); |
1763 | tos, strerror(errno)); | 1760 | if (setsockopt(active_state->connection_in, |
1764 | #endif | 1761 | IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) < 0) |
1762 | error("setsockopt IP_TOS %d: %.100s:", | ||
1763 | tos, strerror(errno)); | ||
1764 | break; | ||
1765 | # endif /* IP_TOS */ | ||
1766 | # ifdef IPV6_TCLASS | ||
1767 | case AF_INET6: | ||
1768 | debug3("%s: set IPV6_TCLASS 0x%02x", __func__, tos); | ||
1769 | if (setsockopt(active_state->connection_in, | ||
1770 | IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)) < 0) | ||
1771 | error("setsockopt IPV6_TCLASS %d: %.100s:", | ||
1772 | tos, strerror(errno)); | ||
1773 | break; | ||
1774 | # endif /* IPV6_TCLASS */ | ||
1775 | } | ||
1776 | #endif /* IP_TOS_IS_BROKEN */ | ||
1765 | } | 1777 | } |
1766 | 1778 | ||
1767 | /* Informs that the current session is interactive. Sets IP flags for that. */ | 1779 | /* Informs that the current session is interactive. Sets IP flags for that. */ |