Commit 9ce82d12 authored by Niels Möller's avatar Niels Möller
Browse files

(connection_send_kex): New function, replacing

macro C_WRITE_NOW. Updated all callers.

Rev: src/client_keyexchange.c:1.65
Rev: src/connection.c:1.79
Rev: src/debug.c:1.39
Rev: src/gateway_commands.c:1.21
Rev: src/handshake.c:1.20
Rev: src/keyexchange.c:1.91
Rev: src/lsh-decode-key.c:1.21
Rev: src/lshg.c:1.23
Rev: src/read_file.c:1.7
Rev: src/server.c:1.76
Rev: src/server_keyexchange.c:1.56
Rev: src/unix_user.c:1.64
parent f0435753
......@@ -31,7 +31,6 @@
#include "atoms.h"
#include "command.h"
#include "debug.h"
#include "format.h"
#include "lookup_verifier.h"
......@@ -157,7 +156,7 @@ do_init_client_dh(struct keyexchange_algorithm *c,
dh->algorithms = algorithms;
/* Send client's message */
C_WRITE_NOW(connection, dh_make_client_msg(&dh->dh));
connection_send_kex(connection, dh_make_client_msg(&dh->dh));
/* Install handler */
connection->dispatch[SSH_MSG_KEXDH_REPLY] = &dh->super;
......@@ -291,7 +290,7 @@ do_handle_srp_reply(struct packet_handler *s,
"SRP failure: Invalid public value from server.");
return;
}
C_WRITE_NOW(connection, response);
connection_send_kex(connection, response);
connection->dispatch[SSH_MSG_KEXSRP_PROOF]
= make_srp_client_proof_handler(self->srp);
......@@ -337,7 +336,7 @@ do_init_client_srp(struct keyexchange_algorithm *s,
srp->m2 = NULL;
/* Send client's message */
C_WRITE_NOW(connection, srp_make_init_msg(&srp->dh, self->name));
connection_send_kex(connection, srp_make_init_msg(&srp->dh, self->name));
/* Install handler */
connection->dispatch[SSH_MSG_KEXSRP_REPLY] = make_srp_reply_handler(srp);
......
......@@ -31,7 +31,6 @@
#include "command.h"
#include "compress.h"
#include "debug.h"
#include "exception.h"
#include "format.h"
#include "io.h"
......@@ -206,7 +205,7 @@ DEFINE_PACKET_HANDLER(, connection_forward_handler, connection, packet)
{
assert(connection->chain);
/* FIXME: Packets of certain types (IGNORE, DEBUG, DISCONNECT)
* could be sent with C_WRITE_NOW. */
* could be sent with connection_send_kex. */
connection_send(connection->chain, packet);
}
......@@ -277,8 +276,8 @@ do_exc_connection_handler(struct exception_handler *s,
werror("Protocol error: %z\n", e->msg);
if (exc->reason)
C_WRITE_NOW(self->connection,
format_disconnect(exc->reason, exc->super.msg, ""));
connection_send_kex(self->connection,
format_disconnect(exc->reason, exc->super.msg, ""));
EXCEPTION_RAISE(self->super.parent, &finish_read_exception);
}
......@@ -467,6 +466,14 @@ make_connection_close_handler(struct ssh_connection *c)
return &closure->super;
}
/* Processes the packet at once, passing it on to the write buffer. */
void
connection_send_kex(struct ssh_connection *self,
struct lsh_string *message)
{
A_WRITE(self->write_packet, message);
}
/* Sends one ordinary (non keyexchange) packet */
void
connection_send(struct ssh_connection *self,
......@@ -479,7 +486,7 @@ connection_send(struct ssh_connection *self,
else
{
assert(string_queue_is_empty(&self->send_queue));
C_WRITE_NOW(self, message);
connection_send_kex(self, message);
}
}
......@@ -497,7 +504,7 @@ connection_send_kex_end(struct ssh_connection *self)
assert(self->send_kex_only);
while (!string_queue_is_empty(&self->send_queue))
C_WRITE_NOW(self, string_queue_remove_head(&self->send_queue));
connection_send_kex(self, string_queue_remove_head(&self->send_queue));
self->send_kex_only = 0;
......
......@@ -25,8 +25,6 @@
#include "config.h"
#endif
#include "debug.h"
#include "connection.h"
#include "format.h"
#include "parse.h"
......@@ -97,7 +95,7 @@ send_debug_message(struct ssh_connection *connection,
const char *msg, int always_display)
{
/* Can be sent even during key exchange. */
C_WRITE_NOW(connection, make_debug_packet(msg, always_display));
connection_send_kex(connection, make_debug_packet(msg, always_display));
}
DEFINE_PACKET_HANDLER(, connection_debug_handler, connection UNUSED, packet)
......
......@@ -34,7 +34,6 @@
#include "channel.h"
#include "connection_commands.h"
#include "debug.h"
#include "format.h"
#include "gateway_channel.h"
#include "io_commands.h"
......
......@@ -33,7 +33,6 @@
#include "command.h"
#include "compress.h"
#include "connection.h"
#include "debug.h"
#include "format.h"
#include "io.h"
#include "keyexchange.h"
......
......@@ -36,7 +36,6 @@
#include "alist.h"
#include "command.h"
#include "connection.h"
#include "debug.h"
#include "format.h"
#include "io.h"
#include "parse.h"
......@@ -192,7 +191,7 @@ send_kexinit(struct ssh_connection *connection)
connection->literal_kexinits[mode] = s;
connection_send_kex_start(connection);
C_WRITE_NOW(connection, lsh_string_dup(s));
connection_send_kex(connection, lsh_string_dup(s));
/* NOTE: This feature isn't fully implemented, as we won't tell
* the selected key exchange method if the guess was "right". */
......@@ -201,7 +200,7 @@ send_kexinit(struct ssh_connection *connection)
s = kex->first_kex_packet;
kex->first_kex_packet = NULL;
C_WRITE_NOW(connection, s);
connection_send_kex(connection, s);
}
}
......@@ -868,7 +867,7 @@ keyexchange_finish(struct ssh_connection *connection,
* newkeys message. */
assert(connection->send_kex_only);
C_WRITE_NOW(connection, ssh_format("%c", SSH_MSG_NEWKEYS));
connection_send_kex(connection, ssh_format("%c", SSH_MSG_NEWKEYS));
/* A hash instance initialized with the key, to be used for key
* generation */
......
......@@ -18,7 +18,6 @@
#include "io.h"
#include "lsh_argp.h"
#include "publickey_crypto.h"
#include "read_file.h"
#include "spki.h"
#include "version.h"
#include "werror.h"
......
......@@ -32,7 +32,6 @@
#include "charset.h"
#include "client.h"
#include "connection.h"
#include "debug.h"
#include "format.h"
#include "gateway.h"
#include "gateway_commands.h"
......@@ -143,7 +142,7 @@ do_lshg_send_ignore(struct command *s,
CAST(ssh_connection, connection, x);
/* Can be sent even during key exchange. */
C_WRITE_NOW(connection, ssh_format("%c%z", SSH_MSG_IGNORE, self->msg));
connection_send_kex(connection, ssh_format("%c%z", SSH_MSG_IGNORE, self->msg));
}
static struct command *
......
......@@ -30,7 +30,7 @@
#include <assert.h>
#include <string.h>
#include "read_file.h"
#include "abstract_io.h"
#include "format.h"
#include "werror.h"
......
......@@ -37,7 +37,6 @@
#include "channel.h"
#include "compress.h"
#include "connection.h"
#include "debug.h"
#include "format.h"
#include "keyexchange.h"
#include "read_line.h"
......
......@@ -31,7 +31,6 @@
#include "atoms.h"
#include "command.h"
#include "debug.h"
#include "format.h"
#include "sexp.h"
#include "srp.h"
......@@ -81,11 +80,11 @@ do_handle_dh_init(struct packet_handler *c,
}
/* Send server's message, to complete key exchange */
C_WRITE_NOW(connection,
dh_make_server_msg(&closure->dh,
closure->server_key,
closure->hostkey_algorithm,
closure->signer));
connection_send_kex(connection,
dh_make_server_msg(&closure->dh,
closure->server_key,
closure->hostkey_algorithm,
closure->signer));
connection->dispatch[SSH_MSG_KEXDH_INIT] = &connection_fail_handler;
......@@ -198,7 +197,7 @@ do_srp_server_proof_handler(struct packet_handler *s,
if (response)
{
C_WRITE_NOW(connection, response);
connection_send_kex(connection, response);
/* Remember that a user was authenticated. */
connection->user = self->srp->user;
......@@ -272,7 +271,7 @@ do_server_srp_read_verifier(struct abstract_write *s,
{
/* Success */
C_WRITE_NOW(self->connection,
connection_send_kex(self->connection,
srp_make_reply_msg(&self->srp->dh,
self->srp->entry));
self->connection->dispatch[SSH_MSG_KEXSRP_PROOF]
......
......@@ -75,7 +75,6 @@
#include "environ.h"
#include "format.h"
#include "io.h"
#include "read_file.h"
#include "reaper.h"
#include "server_pty.h"
#include "werror.h"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment