mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Stop using ssh->protocol_initial_phase_done in SSH-1.
This flag was used to indicate that ssh1_protocol (or, as of the previous commit, ssh1_coro_wrapper) should stop passing packets to do_ssh1_login and start passing them to do_ssh1_connection. Now, instead of using a flag, we simply have two separate versions of ssh1_coro_wrapper for the two phases, and indicate the change by rewriting all the entries in the dispatch table. So now we _just_ have a function-pointer dereference per packet, rather than one of those and then a flag check.
This commit is contained in:
parent
5d9adc5c93
commit
bf62c85051
23
ssh.c
23
ssh.c
@ -973,7 +973,7 @@ struct ssh_tag {
|
||||
struct rdpkt2_state_tag rdpkt2_state;
|
||||
struct rdpkt2_bare_state_tag rdpkt2_bare_state;
|
||||
|
||||
/* SSH-1 and SSH-2 use this for different things, but both use it */
|
||||
/* Only used by SSH-2 */
|
||||
int protocol_initial_phase_done;
|
||||
|
||||
void (*protocol) (Ssh ssh, const void *vin, int inlen);
|
||||
@ -6268,16 +6268,23 @@ static void ssh_msg_ignore(Ssh ssh, struct Packet *pktin)
|
||||
/* Do nothing, because we're ignoring it! Duhh. */
|
||||
}
|
||||
|
||||
static void ssh1_coro_wrapper(Ssh ssh, struct Packet *pktin)
|
||||
static void ssh1_coro_wrapper_session(Ssh ssh, struct Packet *pktin);
|
||||
|
||||
static void ssh1_coro_wrapper_initial(Ssh ssh, struct Packet *pktin)
|
||||
{
|
||||
if (!ssh->protocol_initial_phase_done) {
|
||||
if (do_ssh1_login(ssh, NULL, 0, pktin))
|
||||
ssh->protocol_initial_phase_done = TRUE;
|
||||
} else {
|
||||
do_ssh1_connection(ssh, NULL, 0, pktin);
|
||||
if (do_ssh1_login(ssh, NULL, 0, pktin)) {
|
||||
int i;
|
||||
for (i = 0; i < 256; i++)
|
||||
if (ssh->packet_dispatch[i] == ssh1_coro_wrapper_initial)
|
||||
ssh->packet_dispatch[i] = ssh1_coro_wrapper_session;
|
||||
}
|
||||
}
|
||||
|
||||
static void ssh1_coro_wrapper_session(Ssh ssh, struct Packet *pktin)
|
||||
{
|
||||
do_ssh1_connection(ssh, NULL, 0, pktin);
|
||||
}
|
||||
|
||||
static void ssh1_protocol_setup(Ssh ssh)
|
||||
{
|
||||
int i;
|
||||
@ -6286,7 +6293,7 @@ static void ssh1_protocol_setup(Ssh ssh)
|
||||
* Most messages are handled by the main protocol routine.
|
||||
*/
|
||||
for (i = 0; i < 256; i++)
|
||||
ssh->packet_dispatch[i] = ssh1_coro_wrapper;
|
||||
ssh->packet_dispatch[i] = ssh1_coro_wrapper_initial;
|
||||
|
||||
/*
|
||||
* These special message types we install handlers for.
|
||||
|
Loading…
Reference in New Issue
Block a user