Commit 20ec391f authored by Niels Möller's avatar Niels Möller
Browse files

*** empty log message ***

Rev: src/connection.h:1.5
Rev: src/keyexchange.c:1.2
Rev: src/keyexchange.h:1.5
Rev: src/parse.c:1.9
Rev: src/parse.h:1.8
parent 3f8cfb28
......@@ -17,7 +17,7 @@ struct ssh_connection
struct lsh_string *session_id;
struct abstract_write *raw; /* Socket connected to the other end */
struct abstract_write *write; /* Where to send packets throw the
struct abstract_write *write; /* Where to send packets through the
* pipeline */
/* Table of all known message types */
......
......@@ -5,26 +5,10 @@
#include "keyexchange.h"
#include "parse.h"
static int do_handle_kexinit(struct abstract_write **w,
struct lsh_string *packet)
{
struct kexinit *msg = parse_kexinit(packet);
if (!msg)
return 0;
lsh_free(packet);
{
}
}
#define NLISTS 10
struct kexinit * parse_kexinit(struct lsh_string *packet)
struct kexinit *parse_kexinit(struct lsh_string *packet)
{
struct kexinit *res;
struct simple_buffer buffer;
......@@ -82,3 +66,29 @@ struct kexinit * parse_kexinit(struct lsh_string *packet)
return res;
}
static int do_handle_kexinit(struct abstract_write **w,
struct lsh_string *packet)
{
struct handle_kexinit_packet *closure = (struct handle_kexinit_packet *) *w;
struct kexinit *msg = parse_kexinit(packet);
if (!msg)
return 0;
lsh_free(packet);
return HANDLE_KEXINIT(closure->handler, msg);
}
struct abstract_write *make_packet_kexinit(struct handle_kexinit *handler)
{
struct handle_kexinit_packet *closure
= xalloc(sizeof(struct handle_kexinit_packet));
closure->super.write = do_handle_kexinit;
closure->handler = handler;
return &closure->super;
}
......@@ -30,16 +30,18 @@ struct handle_kexinit
struct kexinit *msg);
}
#define HANDLE_KEXINIT(handler, msg) ((handler)->f((handler), (msg)))
struct handle_kexinit_packet
{
struct abstract_write super;
struct handle_kexinit *handler;
};
struct server_keyexchange
{
struct abstract_write p;
};
struct abstract_write *make_packet_kexinit(struct handle_kexinit *handler);
#if 0
struct lsh_string *make_keyexinit_packet(struct keyexinit *msg);
#endif
#endif /* LSH_KEYEXCHANGE_H_INCLUDED */
......@@ -77,7 +77,7 @@ int parse_boolean(struct simple_buffer *buffer, int *result)
return 1;
}
int parse_bignum(struct simple_buffer *buffer, bignum *result)
int parse_bignum(struct simple_buffer *buffer, bignum result)
{
UINT32 length;
UINT8 *digits;
......@@ -90,6 +90,20 @@ int parse_bignum(struct simple_buffer *buffer, bignum *result)
return 1;
}
int parse_atom(struct simple_buffer *buffer, int *result)
{
UINT32 length;
UINT8 *start;
if ( (!parse_string(buffer, &length, &start))
|| length > 64)
return 0;
*result = lookup_atom(data, start);
return 1;
}
/* Returns 1 on success, 0 on failure, and -1 at end of buffer.
* Unknown atoms sets result to zero. */
......
......@@ -30,7 +30,9 @@ int parse_sub_buffer(struct simple_buffer *buffer,
int parse_uint8(struct simple_buffer *buffer, UINT8 *result);
int parse_boolean(struct simple_buffer *buffer, int *result);
int parse_bignum(struct simple_buffer *buffer, bignum *result);
int parse_bignum(struct simple_buffer *buffer, bignum result);
int parse_atom(struct simple_buffer *buffer, int *result);
/* Returns 1 on success, 0 on failure, and -1 at end of buffer.
* Unknown atoms sets result to zero. */
......
Markdown is supported
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