diff options
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 53 |
1 files changed, 37 insertions, 16 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: packet.c,v 1.168 2010/07/13 23:13:16 djm Exp $ */ | 1 | /* $OpenBSD: packet.c,v 1.172 2010/11/13 23:27:50 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 |
@@ -199,13 +199,13 @@ static struct session_state *active_state, *backup_state; | |||
199 | static struct session_state * | 199 | static struct session_state * |
200 | alloc_session_state(void) | 200 | alloc_session_state(void) |
201 | { | 201 | { |
202 | struct session_state *s = xcalloc(1, sizeof(*s)); | 202 | struct session_state *s = xcalloc(1, sizeof(*s)); |
203 | 203 | ||
204 | s->connection_in = -1; | 204 | s->connection_in = -1; |
205 | s->connection_out = -1; | 205 | s->connection_out = -1; |
206 | s->max_packet_size = 32768; | 206 | s->max_packet_size = 32768; |
207 | s->packet_timeout_ms = -1; | 207 | s->packet_timeout_ms = -1; |
208 | return s; | 208 | return s; |
209 | } | 209 | } |
210 | 210 | ||
211 | /* | 211 | /* |
@@ -391,8 +391,8 @@ packet_get_ssh1_cipher(void) | |||
391 | } | 391 | } |
392 | 392 | ||
393 | void | 393 | void |
394 | packet_get_state(int mode, u_int32_t *seqnr, u_int64_t *blocks, u_int32_t *packets, | 394 | packet_get_state(int mode, u_int32_t *seqnr, u_int64_t *blocks, |
395 | u_int64_t *bytes) | 395 | u_int32_t *packets, u_int64_t *bytes) |
396 | { | 396 | { |
397 | struct packet_state *state; | 397 | struct packet_state *state; |
398 | 398 | ||
@@ -547,8 +547,7 @@ packet_start_compression(int level) | |||
547 | */ | 547 | */ |
548 | 548 | ||
549 | void | 549 | void |
550 | packet_set_encryption_key(const u_char *key, u_int keylen, | 550 | packet_set_encryption_key(const u_char *key, u_int keylen, int number) |
551 | int number) | ||
552 | { | 551 | { |
553 | Cipher *cipher = cipher_by_number(number); | 552 | Cipher *cipher = cipher_by_number(number); |
554 | 553 | ||
@@ -641,6 +640,14 @@ packet_put_bignum2(BIGNUM * value) | |||
641 | buffer_put_bignum2(&active_state->outgoing_packet, value); | 640 | buffer_put_bignum2(&active_state->outgoing_packet, value); |
642 | } | 641 | } |
643 | 642 | ||
643 | #ifdef OPENSSL_HAS_ECC | ||
644 | void | ||
645 | packet_put_ecpoint(const EC_GROUP *curve, const EC_POINT *point) | ||
646 | { | ||
647 | buffer_put_ecpoint(&active_state->outgoing_packet, curve, point); | ||
648 | } | ||
649 | #endif | ||
650 | |||
644 | /* | 651 | /* |
645 | * Finalizes and sends the packet. If the encryption key has been set, | 652 | * Finalizes and sends the packet. If the encryption key has been set, |
646 | * encrypts the packet before sending. | 653 | * encrypts the packet before sending. |
@@ -1511,6 +1518,14 @@ packet_get_bignum2(BIGNUM * value) | |||
1511 | buffer_get_bignum2(&active_state->incoming_packet, value); | 1518 | buffer_get_bignum2(&active_state->incoming_packet, value); |
1512 | } | 1519 | } |
1513 | 1520 | ||
1521 | #ifdef OPENSSL_HAS_ECC | ||
1522 | void | ||
1523 | packet_get_ecpoint(const EC_GROUP *curve, EC_POINT *point) | ||
1524 | { | ||
1525 | buffer_get_ecpoint(&active_state->incoming_packet, curve, point); | ||
1526 | } | ||
1527 | #endif | ||
1528 | |||
1514 | void * | 1529 | void * |
1515 | packet_get_raw(u_int *length_ptr) | 1530 | packet_get_raw(u_int *length_ptr) |
1516 | { | 1531 | { |
@@ -1546,6 +1561,13 @@ packet_get_string_ptr(u_int *length_ptr) | |||
1546 | return buffer_get_string_ptr(&active_state->incoming_packet, length_ptr); | 1561 | return buffer_get_string_ptr(&active_state->incoming_packet, length_ptr); |
1547 | } | 1562 | } |
1548 | 1563 | ||
1564 | /* Ensures the returned string has no embedded \0 characters in it. */ | ||
1565 | char * | ||
1566 | packet_get_cstring(u_int *length_ptr) | ||
1567 | { | ||
1568 | return buffer_get_cstring(&active_state->incoming_packet, length_ptr); | ||
1569 | } | ||
1570 | |||
1549 | /* | 1571 | /* |
1550 | * Sends a diagnostic message from the server to the client. This message | 1572 | * Sends a diagnostic message from the server to the client. This message |
1551 | * can be sent at any time (but not while constructing another message). The | 1573 | * can be sent at any time (but not while constructing another message). The |
@@ -1728,14 +1750,13 @@ packet_not_very_much_data_to_write(void) | |||
1728 | } | 1750 | } |
1729 | 1751 | ||
1730 | static void | 1752 | static void |
1731 | packet_set_tos(int interactive) | 1753 | packet_set_tos(int tos) |
1732 | { | 1754 | { |
1733 | #if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN) | 1755 | #if defined(IP_TOS) && !defined(IP_TOS_IS_BROKEN) |
1734 | int tos = interactive ? IPTOS_LOWDELAY : IPTOS_THROUGHPUT; | ||
1735 | |||
1736 | if (!packet_connection_is_on_socket() || | 1756 | if (!packet_connection_is_on_socket() || |
1737 | !packet_connection_is_ipv4()) | 1757 | !packet_connection_is_ipv4()) |
1738 | return; | 1758 | return; |
1759 | debug3("%s: set IP_TOS 0x%02x", __func__, tos); | ||
1739 | if (setsockopt(active_state->connection_in, IPPROTO_IP, IP_TOS, &tos, | 1760 | if (setsockopt(active_state->connection_in, IPPROTO_IP, IP_TOS, &tos, |
1740 | sizeof(tos)) < 0) | 1761 | sizeof(tos)) < 0) |
1741 | error("setsockopt IP_TOS %d: %.100s:", | 1762 | error("setsockopt IP_TOS %d: %.100s:", |
@@ -1746,7 +1767,7 @@ packet_set_tos(int interactive) | |||
1746 | /* Informs that the current session is interactive. Sets IP flags for that. */ | 1767 | /* Informs that the current session is interactive. Sets IP flags for that. */ |
1747 | 1768 | ||
1748 | void | 1769 | void |
1749 | packet_set_interactive(int interactive) | 1770 | packet_set_interactive(int interactive, int qos_interactive, int qos_bulk) |
1750 | { | 1771 | { |
1751 | if (active_state->set_interactive_called) | 1772 | if (active_state->set_interactive_called) |
1752 | return; | 1773 | return; |
@@ -1759,7 +1780,7 @@ packet_set_interactive(int interactive) | |||
1759 | if (!packet_connection_is_on_socket()) | 1780 | if (!packet_connection_is_on_socket()) |
1760 | return; | 1781 | return; |
1761 | set_nodelay(active_state->connection_in); | 1782 | set_nodelay(active_state->connection_in); |
1762 | packet_set_tos(interactive); | 1783 | packet_set_tos(interactive ? qos_interactive : qos_bulk); |
1763 | } | 1784 | } |
1764 | 1785 | ||
1765 | /* Returns true if the current connection is interactive. */ | 1786 | /* Returns true if the current connection is interactive. */ |