summaryrefslogtreecommitdiff
path: root/packet.c
diff options
context:
space:
mode:
authormarkus@openbsd.org <markus@openbsd.org>2016-01-14 16:17:39 +0000
committerDamien Miller <djm@mindrot.org>2016-01-27 16:54:10 +1100
commita306863831c57ec5fad918687cc5d289ee8e2635 (patch)
tree0321a74bc4a9be03ad303d35306555ca0908ee25 /packet.c
parent6ef49e83e30688504552ac10875feabd5521565f (diff)
upstream commit
remove roaming support; ok djm@ Upstream-ID: 2cab8f4b197bc95776fb1c8dc2859dad0c64dc56
Diffstat (limited to 'packet.c')
-rw-r--r--packet.c84
1 files changed, 7 insertions, 77 deletions
diff --git a/packet.c b/packet.c
index 27e85e3a1..9cf200cc3 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.c,v 1.221 2015/12/11 04:21:12 mmcc Exp $ */ 1/* $OpenBSD: packet.c,v 1.222 2016/01/14 16:17:40 markus 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
@@ -83,7 +83,6 @@
83#include "channels.h" 83#include "channels.h"
84#include "ssh.h" 84#include "ssh.h"
85#include "packet.h" 85#include "packet.h"
86#include "roaming.h"
87#include "ssherr.h" 86#include "ssherr.h"
88#include "sshbuf.h" 87#include "sshbuf.h"
89 88
@@ -1279,7 +1278,7 @@ int
1279ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p) 1278ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
1280{ 1279{
1281 struct session_state *state = ssh->state; 1280 struct session_state *state = ssh->state;
1282 int len, r, ms_remain, cont; 1281 int len, r, ms_remain;
1283 fd_set *setp; 1282 fd_set *setp;
1284 char buf[8192]; 1283 char buf[8192];
1285 struct timeval timeout, start, *timeoutp = NULL; 1284 struct timeval timeout, start, *timeoutp = NULL;
@@ -1349,11 +1348,7 @@ ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
1349 if (r == 0) 1348 if (r == 0)
1350 return SSH_ERR_CONN_TIMEOUT; 1349 return SSH_ERR_CONN_TIMEOUT;
1351 /* Read data from the socket. */ 1350 /* Read data from the socket. */
1352 do { 1351 len = read(state->connection_in, buf, sizeof(buf));
1353 cont = 0;
1354 len = roaming_read(state->connection_in, buf,
1355 sizeof(buf), &cont);
1356 } while (len == 0 && cont);
1357 if (len == 0) { 1352 if (len == 0) {
1358 r = SSH_ERR_CONN_CLOSED; 1353 r = SSH_ERR_CONN_CLOSED;
1359 goto out; 1354 goto out;
@@ -2025,19 +2020,18 @@ ssh_packet_write_poll(struct ssh *ssh)
2025{ 2020{
2026 struct session_state *state = ssh->state; 2021 struct session_state *state = ssh->state;
2027 int len = sshbuf_len(state->output); 2022 int len = sshbuf_len(state->output);
2028 int cont, r; 2023 int r;
2029 2024
2030 if (len > 0) { 2025 if (len > 0) {
2031 cont = 0; 2026 len = write(state->connection_out,
2032 len = roaming_write(state->connection_out, 2027 sshbuf_ptr(state->output), len);
2033 sshbuf_ptr(state->output), len, &cont);
2034 if (len == -1) { 2028 if (len == -1) {
2035 if (errno == EINTR || errno == EAGAIN || 2029 if (errno == EINTR || errno == EAGAIN ||
2036 errno == EWOULDBLOCK) 2030 errno == EWOULDBLOCK)
2037 return 0; 2031 return 0;
2038 return SSH_ERR_SYSTEM_ERROR; 2032 return SSH_ERR_SYSTEM_ERROR;
2039 } 2033 }
2040 if (len == 0 && !cont) 2034 if (len == 0)
2041 return SSH_ERR_CONN_CLOSED; 2035 return SSH_ERR_CONN_CLOSED;
2042 if ((r = sshbuf_consume(state->output, len)) != 0) 2036 if ((r = sshbuf_consume(state->output, len)) != 0)
2043 return r; 2037 return r;
@@ -2314,58 +2308,6 @@ ssh_packet_get_output(struct ssh *ssh)
2314 return (void *)ssh->state->output; 2308 return (void *)ssh->state->output;
2315} 2309}
2316 2310
2317/* XXX TODO update roaming to new API (does not work anyway) */
2318/*
2319 * Save the state for the real connection, and use a separate state when
2320 * resuming a suspended connection.
2321 */
2322void
2323ssh_packet_backup_state(struct ssh *ssh,
2324 struct ssh *backup_state)
2325{
2326 struct ssh *tmp;
2327
2328 close(ssh->state->connection_in);
2329 ssh->state->connection_in = -1;
2330 close(ssh->state->connection_out);
2331 ssh->state->connection_out = -1;
2332 if (backup_state)
2333 tmp = backup_state;
2334 else
2335 tmp = ssh_alloc_session_state();
2336 backup_state = ssh;
2337 ssh = tmp;
2338}
2339
2340/* XXX FIXME FIXME FIXME */
2341/*
2342 * Swap in the old state when resuming a connecion.
2343 */
2344void
2345ssh_packet_restore_state(struct ssh *ssh,
2346 struct ssh *backup_state)
2347{
2348 struct ssh *tmp;
2349 u_int len;
2350 int r;
2351
2352 tmp = backup_state;
2353 backup_state = ssh;
2354 ssh = tmp;
2355 ssh->state->connection_in = backup_state->state->connection_in;
2356 backup_state->state->connection_in = -1;
2357 ssh->state->connection_out = backup_state->state->connection_out;
2358 backup_state->state->connection_out = -1;
2359 len = sshbuf_len(backup_state->state->input);
2360 if (len > 0) {
2361 if ((r = sshbuf_putb(ssh->state->input,
2362 backup_state->state->input)) != 0)
2363 fatal("%s: %s", __func__, ssh_err(r));
2364 sshbuf_reset(backup_state->state->input);
2365 add_recv_bytes(len);
2366 }
2367}
2368
2369/* Reset after_authentication and reset compression in post-auth privsep */ 2311/* Reset after_authentication and reset compression in post-auth privsep */
2370static int 2312static int
2371ssh_packet_set_postauth(struct ssh *ssh) 2313ssh_packet_set_postauth(struct ssh *ssh)
@@ -2515,11 +2457,6 @@ ssh_packet_get_state(struct ssh *ssh, struct sshbuf *m)
2515 (r = sshbuf_put_stringb(m, state->output)) != 0) 2457 (r = sshbuf_put_stringb(m, state->output)) != 0)
2516 return r; 2458 return r;
2517 2459
2518 if (compat20) {
2519 if ((r = sshbuf_put_u64(m, get_sent_bytes())) != 0 ||
2520 (r = sshbuf_put_u64(m, get_recv_bytes())) != 0)
2521 return r;
2522 }
2523 return 0; 2460 return 0;
2524} 2461}
2525 2462
@@ -2646,7 +2583,6 @@ ssh_packet_set_state(struct ssh *ssh, struct sshbuf *m)
2646 size_t ssh1keylen, rlen, slen, ilen, olen; 2583 size_t ssh1keylen, rlen, slen, ilen, olen;
2647 int r; 2584 int r;
2648 u_int ssh1cipher = 0; 2585 u_int ssh1cipher = 0;
2649 u_int64_t sent_bytes = 0, recv_bytes = 0;
2650 2586
2651 if (!compat20) { 2587 if (!compat20) {
2652 if ((r = sshbuf_get_u32(m, &state->remote_protocol_flags)) != 0 || 2588 if ((r = sshbuf_get_u32(m, &state->remote_protocol_flags)) != 0 ||
@@ -2711,12 +2647,6 @@ ssh_packet_set_state(struct ssh *ssh, struct sshbuf *m)
2711 (r = sshbuf_put(state->output, output, olen)) != 0) 2647 (r = sshbuf_put(state->output, output, olen)) != 0)
2712 return r; 2648 return r;
2713 2649
2714 if (compat20) {
2715 if ((r = sshbuf_get_u64(m, &sent_bytes)) != 0 ||
2716 (r = sshbuf_get_u64(m, &recv_bytes)) != 0)
2717 return r;
2718 roam_set_bytes(sent_bytes, recv_bytes);
2719 }
2720 if (sshbuf_len(m)) 2650 if (sshbuf_len(m))
2721 return SSH_ERR_INVALID_FORMAT; 2651 return SSH_ERR_INVALID_FORMAT;
2722 debug3("%s: done", __func__); 2652 debug3("%s: done", __func__);