summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--packet.c51
-rw-r--r--packet.h5
3 files changed, 60 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 0f39fa215..93f6b8a20 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
1 - (dtucker) OpenBSD CVS Sync
2 - andreas@cvs.openbsd.org 2009/06/27 09:29:06
3 [packet.h packet.c]
4 packet_bacup_state() and packet_restore_state() will be used to
5 temporarily save the current state ren resuming a suspended connection.
6 ok markus@
7
120090622 820090622
2 - (dtucker) OpenBSD CVS Sync 9 - (dtucker) OpenBSD CVS Sync
3 - dtucker@cvs.openbsd.org 2009/06/22 05:39:28 10 - dtucker@cvs.openbsd.org 2009/06/22 05:39:28
diff --git a/packet.c b/packet.c
index 0e9993b5a..600e015fb 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.c,v 1.165 2009/06/12 20:58:32 andreas Exp $ */ 1/* $OpenBSD: packet.c,v 1.166 2009/06/27 09:29:06 andreas 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
@@ -194,7 +194,7 @@ struct session_state {
194 TAILQ_HEAD(, packet) outgoing; 194 TAILQ_HEAD(, packet) outgoing;
195}; 195};
196 196
197static struct session_state *active_state; 197static struct session_state *active_state, *backup_state;
198 198
199static struct session_state * 199static struct session_state *
200alloc_session_state(void) 200alloc_session_state(void)
@@ -1887,3 +1887,50 @@ packet_get_newkeys(int mode)
1887{ 1887{
1888 return (void *)active_state->newkeys[mode]; 1888 return (void *)active_state->newkeys[mode];
1889} 1889}
1890
1891/*
1892 * Save the state for the real connection, and use a separate state when
1893 * resuming a suspended connection.
1894 */
1895void
1896packet_backup_state(void)
1897{
1898 struct session_state *tmp;
1899
1900 close(active_state->connection_in);
1901 active_state->connection_in = -1;
1902 close(active_state->connection_out);
1903 active_state->connection_out = -1;
1904 if (backup_state)
1905 tmp = backup_state;
1906 else
1907 tmp = alloc_session_state();
1908 backup_state = active_state;
1909 active_state = tmp;
1910}
1911
1912/*
1913 * Swap in the old state when resuming a connecion.
1914 */
1915void
1916packet_restore_state(void)
1917{
1918 struct session_state *tmp;
1919 void *buf;
1920 u_int len;
1921
1922 tmp = backup_state;
1923 backup_state = active_state;
1924 active_state = tmp;
1925 active_state->connection_in = backup_state->connection_in;
1926 backup_state->connection_in = -1;
1927 active_state->connection_out = backup_state->connection_out;
1928 backup_state->connection_out = -1;
1929 len = buffer_len(&backup_state->input);
1930 if (len > 0) {
1931 buf = buffer_ptr(&backup_state->input);
1932 buffer_append(&active_state->input, buf, len);
1933 buffer_clear(&backup_state->input);
1934 add_recv_bytes(len);
1935 }
1936}
diff --git a/packet.h b/packet.h
index 265fcf236..33523d750 100644
--- a/packet.h
+++ b/packet.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.h,v 1.51 2009/05/27 06:36:07 andreas Exp $ */ 1/* $OpenBSD: packet.h,v 1.52 2009/06/27 09:29:06 andreas Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -109,6 +109,9 @@ do { \
109int packet_need_rekeying(void); 109int packet_need_rekeying(void);
110void packet_set_rekey_limit(u_int32_t); 110void packet_set_rekey_limit(u_int32_t);
111 111
112void packet_backup_state(void);
113void packet_restore_state(void);
114
112void *packet_get_input(void); 115void *packet_get_input(void);
113void *packet_get_output(void); 116void *packet_get_output(void);
114 117