diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | packet.c | 51 | ||||
-rw-r--r-- | packet.h | 5 |
3 files changed, 60 insertions, 3 deletions
@@ -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 | |||
1 | 20090622 | 8 | 20090622 |
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 |
@@ -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 | ||
197 | static struct session_state *active_state; | 197 | static struct session_state *active_state, *backup_state; |
198 | 198 | ||
199 | static struct session_state * | 199 | static struct session_state * |
200 | alloc_session_state(void) | 200 | alloc_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 | */ | ||
1895 | void | ||
1896 | packet_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 | */ | ||
1915 | void | ||
1916 | packet_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 | } | ||
@@ -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 { \ | |||
109 | int packet_need_rekeying(void); | 109 | int packet_need_rekeying(void); |
110 | void packet_set_rekey_limit(u_int32_t); | 110 | void packet_set_rekey_limit(u_int32_t); |
111 | 111 | ||
112 | void packet_backup_state(void); | ||
113 | void packet_restore_state(void); | ||
114 | |||
112 | void *packet_get_input(void); | 115 | void *packet_get_input(void); |
113 | void *packet_get_output(void); | 116 | void *packet_get_output(void); |
114 | 117 | ||