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

Work in progress

Rev: src/abstract_io.h:1.8
Rev: src/client.c:1.8
Rev: src/connection.h:1.4
Rev: src/keyexchange.h:1.3
Rev: src/packet_dispatch.c:1.6
Rev: src/parse.c:1.7
Rev: src/parse.h:1.6
parent 4e52ead0
......@@ -35,8 +35,7 @@ struct read_handler
#define READ_HANDLER(h, read) ((h)->handler(&(h), (read)))
/* FIXME: What should writers return? Perhaps a new writer,
* analogous to read-handlers? */
/* FIXME: What should writers return? */
/* May store a new handler into *w. */
struct abstract_write
......
......@@ -18,6 +18,7 @@
#include "encrypt.h"
#include "pad.h"
#include "crypto.h"
#include "unpad.h"
struct read_handler *make_client_read_line();
struct callback *make_client_close_handler();
......@@ -73,9 +74,11 @@ static struct read_handler *do_line(struct line_handler **h,
|| ((length >= 9) && !memcmp(line + 4, "1.99-", 5)))
{
struct read_handler *new
= make_read_packet(make_packet_debug(make_packet_void(),
stderr),
closure->connection->max_packet);
= make_read_packet
(make_packet_debug
(make_packet_unpad(make_client_dispatch(connection)),
stderr),
closure->connection->max_packet);
closure->connection->server_version
= ssh_format("%ls", length, line);
......@@ -157,3 +160,26 @@ struct callback *make_client_close_handler()
return c;
}
#if 0
/* FIXME: HERE */
struct abstract_write *make_client_dispatch(struct ssh_connection *c)
{
struct abstract_write *ignore = make_packet_void();
struct abstract_write *fail = make_disconnect(connection);
struct abstract_write *kex = make_client_key_exchange(connection);
struct dispatch_assoc table[] = {
{ SSH_MSG_DISCONNECT, make_handle_disconnect(connection) },
{ SSH_MSG_IGNORE, ignore },
{ SSH_MSG_UNIMPLEMENTED, ignore },
{ SSH_MSG_DEBUG, make_handle_debug(connection) },
{ SSH_MSG_SERVICE_REQUEST, fail },
{ SSH_MSG_SERVICE_ACCEPT, fail },
{ SSH_MSG_KEXINIT, kex },
{ SSH_MSG_NEWKEYS, fail },
{ SSH_MSG
#endif
......@@ -19,6 +19,9 @@ struct ssh_connection
struct abstract_write *write; /* Where to send packets throw the
* pipeline */
/* Table of all known message types */
struct abstract_write *dispatch[0x100];
UINT32 max_packet;
......
......@@ -5,10 +5,32 @@
#ifndef LSH_KEYEXCHANGE_H_INCLUDED
#define LSH_KEYEXCHANGE_H_INCLUDED
struct kexinit
{
UINT8 cookie[16];
/* Zero terminated list of atoms */
int *kex_algorithms;
int *server_host_key_algorithms;
int *encryption_algorithms_client_to_server;
int *encryption_algorithms_server_to_client;
int *mac_algorithms_client_to_server;
int *mac_algorithms_server_to_client;
int *compression_algorithms_client_to_server;
int *compression_algorithms_server_to_client;
int *languages_client_to_server;
int *languages_server_to_client;
int first_kex_packet_follows;
}
struct handle_kexinit
{
struct abstract_write super;
};
struct server_keyexchange
{
struct abstract_write p;
};
#endif /* LSH_KEYEXCHANGE_H_INCLUDED */
......@@ -73,6 +73,3 @@ make_dispatch_processor(unsigned size,
return &closure->super;
}
......@@ -3,6 +3,7 @@
*/
#include "parse.h"
#include "xalloc.h"
void simple_buffer_init(struct simple_buffer *buffer,
UINT32 capacity, UINT8 *data)
......@@ -109,6 +110,36 @@ int parse_next_atom(struct simple_buffer *buffer, int *result)
return 1;
}
int *parse_atom_list(struct simple_buffer *buffer)
{
int count;
int i;
int *res;
/* Count commas (no commas means one atom) */
for (i = buffer->pos, count = 1; i < buffer->capacity; i++)
if (buffer->data[i] == ',')
count++;
res = xalloc(sizeof(int) * (count+1));
for (i = 0; i < count; i++)
{
switch(parse_next_atom(buffer, res+i))
{
case 1:
continue;
case 0:
lsh_free(res);
return NULL;
default:
fatal("Internal error\n");
}
}
res[i] = -1;
return res;
}
/* Returns success (i.e. 1) iff there is no data left */
int parse_eod(struct simple_buffer *buffer)
{
......
......@@ -36,6 +36,11 @@ int parse_bignum(struct simple_buffer *buffer, bignum *result);
* Unknown atoms sets result to zero. */
int parse_next_atom(struct simple_buffer *buffer, int *result);
/* Allocates an array of integers. The 0 atom means an unknown atom
* was read. The list is terminated with -1. Returns a NULL pointer on
* error. */
int *parse_atom_list(struct simple_buffer *buffer);
/* Returns success (i.e. 1) iff there is no data left */
int parse_eod(struct simple_buffer *buffer);
......
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