Commit b9090ff9 authored by Niels Möller's avatar Niels Möller

*** empty log message ***

Rev: src/.cvsignore:1.3
Rev: src/Makefile.in:1.6
Rev: src/client.c:1.4
Rev: src/client.h:1.3
Rev: src/io.h:1.5
Rev: src/lsh.c:1.4
Rev: src/lsh_types.h:1.5
Rev: src/read_data.h:1.2
Rev: src/version.h:1.2
Rev: src/void.c:1.5
Rev: src/werror.c:1.4
Rev: src/write_buffer.c:1.3
Rev: src/write_buffer.h:1.3
parent 95cbe881
......@@ -10,5 +10,6 @@ config.log
config.status
configure
configure.scan
lsh
stamp-h
stamp-h.in
......@@ -10,5 +10,6 @@
/config.status
/configure
/configure.scan
/lsh
/stamp-h
/stamp-h.in
......@@ -17,7 +17,9 @@ DEFS = @DEFS@
LIBS = @LIBS@
CFLAGS = -g -Wall # -O2 -fomit-frame-pointer
LDFLAGS = -g
LDFLAGS = @LDFLAGS@
LOADLIBES = $(LIBS)
CPPFLAGS =
......@@ -32,10 +34,10 @@ binprefix =
#### End of system configuration section. ####
SRCS = atoms.c atoms_gperf.c atoms_table.c bignum.c client.c debug.c \
encrypt.c format.c io.c lsh.c packet_dispatch.c \
SRCS = atoms.c atoms_gperf.c atoms_table.c bignum.c client.c connection.c \
debug.c encrypt.c format.c io.c lsh.c packet_dispatch.c \
pad.c parse.c read_data.c read_line.c read_packet.c \
server_keyexchange.c session.c transport.c unpad.c void.c \
server_keyexchange.c transport.c unpad.c void.c \
werror.c write_buffer.c xalloc.c
OBJS = $(SRCS:.c=.o)
......@@ -46,7 +48,7 @@ all: lsh
$(CC) -c $(CPPFLAGS) $(DEFS) $(CFLAGS) $<
lsh: lsh.o client.o read_packet.o read_line.o debug.o werror.o \
xalloc.o io.o void.o write_buffer.o
xalloc.o io.o void.o write_buffer.o format.o bignum.o atoms.o connection.o
# $(CC) -o lsh $(CFLAGS) $<
atoms_defines.h: atoms.in process_atoms
......@@ -65,7 +67,7 @@ very_clean: clean
rm *.d
%.d: %.c
$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $(DEFS) $< \
$(SHELL) -ec '$(CC) -MM -MG $(CPPFLAGS) $(DEFS) $< \
| sed '\''s/\($*\)\.o:/\1\.o $@ : /g'\'' > $@'
include $(SRCS:.c=.d)
......
......@@ -6,14 +6,14 @@
#include "client.h"
#include "version.h"
#include "session.h"
#include "connection.h"
#include "abstract_io.h"
#include "read_line.h"
#include "read_packet.h"
#include "debug.h"
#include "format.h"
#include "werror.h"
#include "void.c"
#include "void.h"
#include "xalloc.h"
struct read_handler *make_client_read_line();
......@@ -22,24 +22,26 @@ struct callback *make_client_close_handler();
static int client_initiate(struct client_callback *closure,
int fd)
{
struct ssh_session *session = ssh_session_alloc();
struct ssh_connection *connection = ssh_connection_alloc();
struct abstract_write *write =
io_read_write(closure->backend, fd,
make_client_read_line(),
closure->block_size,
make_client_close_handler());
session->client_version = ssh_format("SSH-" PROTOCOL_VERSION
"-" SOFTWARE_VERSION " %lS\r\n",
closure->id_comment);
connection->client_version
= ssh_format("SSH-%z-%z %z\r\n",
PROTOCOL_VERSION,
SOFTWARE_CLIENT_VERSION,
closure->id_comment);
/* Copies the version string, so that it is isn't freed */
return A_WRITE(write, ssh_format("%lS", session->client_version));
return A_WRITE(write, ssh_format("%lS", connection->client_version));
}
struct client_line_handler
{
struct line_handler super;
struct ssh_session *session;
struct ssh_connection *connection;
};
static struct read_handler *do_line(struct client_line_handler *closure,
......@@ -55,9 +57,9 @@ static struct read_handler *do_line(struct client_line_handler *closure,
struct read_handler *new
= make_read_packet(make_debug_processor(make_packet_void(),
stderr),
closure->session->max_packet);
closure->connection->max_packet);
closure->session->server_version
closure->connection->server_version
= ssh_format("%s", length, line);
/* FIXME: Cleanup properly. */
......@@ -70,8 +72,9 @@ static struct read_handler *do_line(struct client_line_handler *closure,
werror("Unsupported protocol version: ");
werror_safe(length, line);
werror("\n");
fatal("client.c: do_line: Unsupported version.\n");
/* FIXME: What could be returned here? */
fatal("client.c: do_line: Unsupported version.\n");
return 0;
}
}
......@@ -85,25 +88,43 @@ static struct read_handler *do_line(struct client_line_handler *closure,
}
}
struct read_handler *make_client_read_line(struct ssh_session *s)
struct read_handler *make_client_read_line(struct ssh_connection *s)
{
struct client_line_handler *closure
= xalloc(sizeof(struct client_line_handler));
closure->super.handler = (line_handler_f) do_line;
closure->session = s;
closure->connection = s;
return make_read_line( (struct line_handler *) closure);
}
struct fd_callback *make_client_callback(struct io_backend *b,
char *comment,
UINT32 block_size)
{
struct client_callback *connected = xalloc(sizeof(struct client_callback));
connected->c.f = (fd_callback_f) client_initiate;
connected->backend = b;
connected->block_size = block_size;
connected->id_comment = comment;
return (struct fd_callback *) connected;
}
static int client_die(struct callback *closure)
{
werror("Connection died.\n");
exit(1);
}
struct callback *make_client_close_handler()
{
struct callback *c = xalloc(sizeof(struct callback));
c->f = client_die;
return c;
}
......@@ -12,10 +12,11 @@ struct client_callback
struct fd_callback c;
struct io_backend *backend;
UINT32 block_size;
struct lsh_string *id_comment;
char *id_comment;
};
struct fd_callback *make_client_callback(struct io_backend *b,
char *comment,
UINT32 block_size);
#if 0
......
......@@ -29,7 +29,7 @@ struct io_fd
/* A closed function with a file descriptor as argument */
struct fd_callback;
typedef int (*fd_callback_f)(struct callback *closure, int fd);
typedef int (*fd_callback_f)(struct fd_callback *closure, int fd);
struct fd_callback
{
fd_callback_f f;
......
......@@ -60,12 +60,14 @@ int main(int argc, char **argv)
if (!get_inaddr(&remote, host, port, "tcp"))
{
fprintf(stderr, "No such host or service");
fprintf(stderr, "No such host or service\n");
exit(1);
}
io_connect(&backend, &remote, NULL,
make_client_callback(&backend, BLOCK_SIZE));
make_client_callback(&backend,
"lsh - a free ssh",
BLOCK_SIZE));
io_run(&backend);
......
......@@ -16,6 +16,8 @@
#define UINT32 unsigned int
#elif SIZEOF_LONG >= 4
#define UINT32 unsigned long
#else
#error Ledsen error
#endif
#define UINT8 unsigned char
......
......@@ -6,7 +6,7 @@
#ifndef LSH_READ_DATA_H_INCLUDED
#define LSH_READ_DATA_H_INCLUDED
#include "abstract_read.h"
#include "abstract_io.h"
struct read_data
{
......
......@@ -3,4 +3,5 @@
*/
#define PROTOCOL_VERSION "2.0"
#define SOFTWARE_VERSION "lsh_0.0"
#define SOFTWARE_CLIENT_VERSION "lsh_0.0"
#define SOFTWARE_SERVER_VERSION "lshd_0.0"
......@@ -4,6 +4,7 @@
#include "void.h"
#include "xalloc.h"
#include "abstract_io.h"
static int do_ignore(struct abstract_write *closure,
struct lsh_string *packet)
......@@ -12,7 +13,7 @@ static int do_ignore(struct abstract_write *closure,
return 1;
}
struct abstract_write *make_void()
struct abstract_write *make_packet_void()
{
struct abstract_write *closure = xalloc(sizeof(struct abstract_write));
......
......@@ -58,7 +58,7 @@ void werror_washed(UINT32 length, UINT8 *msg)
}
/* Fall through */
case '\n':
putc('\n', stderr);
putc(msg[i], stderr);
break;
}
}
......
......@@ -3,6 +3,7 @@
*/
#include "xalloc.h"
#include "write_buffer.h"
static int do_write(struct write_buffer *closure,
struct lsh_string *packet)
......@@ -37,7 +38,7 @@ static int do_write(struct write_buffer *closure,
}
#endif
buffer->empty = 0;
closure->empty = 0;
return 1;
}
......@@ -58,7 +59,7 @@ int write_buffer_pre_write(struct write_buffer *buffer)
if (buffer->start > buffer->block_size)
{
/* Copy contents to the start of the buffer */
memcpy(buffer->data, buffer->data + buffer->start, length);
memcpy(buffer->buffer, buffer->buffer + buffer->start, length);
buffer->start = 0;
buffer->end = length;
}
......@@ -73,7 +74,7 @@ int write_buffer_pre_write(struct write_buffer *buffer)
if (partial_left <= buffer_left)
{
/* The rest of the partial packet fits in the buffer */
memcpy(buffer->data + length,
memcpy(buffer->buffer + length,
buffer->partial->data + buffer->pos,
partial_left);
......@@ -85,7 +86,7 @@ int write_buffer_pre_write(struct write_buffer *buffer)
}
else
{
memcpy(buffer->data + length,
memcpy(buffer->buffer + length,
buffer->partial->data + buffer->pos,
buffer_left);
......@@ -104,9 +105,10 @@ int write_buffer_pre_write(struct write_buffer *buffer)
buffer->pos = 0;
buffer->head = n->next;
if (buffer->head)
buffer->head->->next = 0;
buffer->head->prev = 0;
else
buffer->tail = 0;
free(n);
}
else
break;
......@@ -116,9 +118,9 @@ int write_buffer_pre_write(struct write_buffer *buffer)
return !buffer->empty;
}
struct abstract_write *write_buffer_alloc(UINT32 size)
struct write_buffer *write_buffer_alloc(UINT32 size)
{
struct write_buffer *res = xalloc(sizeof(write_callback) - 1 + size*2);
struct write_buffer *res = xalloc(sizeof(struct write_buffer) - 1 + size*2);
res->a.write = (abstract_write_f) do_write;
......@@ -133,7 +135,7 @@ struct abstract_write *write_buffer_alloc(UINT32 size)
res->head = res->tail = 0;
res->pos = 0;
res->packet = NULL;
res->partial = NULL;
res->start = res->end = 0;
......
......@@ -38,13 +38,15 @@ struct write_buffer
UINT8 buffer[1]; /* Real size is twice the blocksize */
};
#if 0
struct write_callback
{
struct callback c;
struct write_buffer buffer;
};
#endif
struct write_callback *write_buffer_alloc(UINT32 size);
struct write_buffer *write_buffer_alloc(UINT32 size);
int write_buffer_pre_write(struct write_buffer *buffer);
#endif /* LSH_WRITE_BUFFER_H_INCLUDED */
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