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

Deleted obsolete files.

Rev: src/abstract_io.c:1.5.2.1(DEAD)
Rev: src/abstract_io.h:1.37.2.2(DEAD)
Rev: src/read_data.c:1.37.2.2(DEAD)
Rev: src/read_data.h:1.16.2.2(DEAD)
Rev: src/read_file.c:1.8.2.1(DEAD)
Rev: src/read_line.c:1.34.2.1(DEAD)
Rev: src/read_line.h:1.18.2.1(DEAD)
Rev: src/read_packet.c:1.60.2.1(DEAD)
Rev: src/read_packet.h:1.11.2.2(DEAD)
Rev: src/write_buffer.c:1.28.2.1(DEAD)
Rev: src/write_buffer.h:1.26.2.2(DEAD)
parent ae39f37d
/* abstract_io.c
*
* This is the layer separating protocol processing from actual io.
*
*/
/* lsh, an implementation of the ssh protocol
*
* Copyright (C) 1998 Niels Möller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include "abstract_io.h"
#define GABA_DEFINE
#include "abstract_io.h.x"
#undef GABA_DEFINE
/* abstract_io.h
*
* This is the layer separating protocol processing from actual io.
*
*/
/* lsh, an implementation of the ssh protocol
*
* Copyright (C) 1998 Niels Möller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LSH_ABSTRACT_IO_H_INCLUDED
#define LSH_ABSTRACT_IO_H_INCLUDED
#error Obsolete file
#include "exception.h"
#define GABA_DECLARE
#include "abstract_io.h.x"
#undef GABA_DECLARE
/* GABA:
(class
(name abstract_write)
(vars
(write method void "struct lsh_string *packet")))
*/
#define A_WRITE(f, packet) ((f)->write((f), (packet) ))
/* A handler that passes packets on to another handler */
/* GABA:
(class
(name abstract_write_pipe)
(super abstract_write)
(vars
(next object abstract_write)))
*/
/* GABA:
(class
(name read_handler)
(vars
(handler indirect-method
; The method returns the amount of data processed.
; On errors, it can set self to NULL, but only for
; debugging purposes; it's the responibility of the the
; exception handler to close the corresponding fd and
; make sure that handler is not called again. '
; Available is 0 iff we have got EOF.
uint32_t "uint32_t available" "const uint8_t *data")))
"struct exception_handler *e")))
*/
/* May store a new handler into *h. */
#define READ_HANDLER(h, l, d) ((h)->handler(&(h), (l), (d)))
struct read_handler *
make_read_file(struct abstract_write *c,
uint32_t max_size);
#endif /*LSH_ABSTRACT_IO_H_INCLUDED */
/* read_data.c
*
*/
/* lsh, an implementation of the ssh protocol
*
* Copyright (C) 1998 Niels Möller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include "read_data.h"
#include "io.h"
#include "werror.h"
#include "xalloc.h"
#include "read_data.c.x"
/* GABA:
(class
(name read_data)
(super io_consuming_read)
(vars
; For flow control.
; FIXME: Perhaps the information that is needed for flow
; control should be abstracted out from the channel struct?
(channel object ssh_channel)))
*/
static uint32_t
do_read_data_query(struct io_consuming_read *s)
{
CAST(read_data, self, s);
assert(self->channel->sources);
if (self->channel->flags &
(CHANNEL_RECEIVED_CLOSE | CHANNEL_SENT_CLOSE | CHANNEL_SENT_EOF))
{
werror("read_data: Receiving data on closed channel. Ignoring.\n");
return 0;
}
/* FIXME: XXX Need some other mechanism ot put channels to sleep. */
#if 0
/* If a keyexchange is in progress, we should stop reading. We rely
* on channels_wakeup to restart reading. */
if (self->connection->send_kex_only)
{
trace
("read_data: Data arrived during key exchange. Won't read it now.\n");
return 0;
}
if (self->connection->hard_limit)
{
trace
("read_data: Data arrived, but connection' write_buffer is full.\n");
return 0;
}
#endif
/* There are three numbers that limit the amount of data we can read:
*
* 1 The current send_window_size.
* 2 The send_max_packet size for the channel.
* 3 (The maximum size for a complete packet SSH_MAX_PACKET)
*
* We don't enforce (3) here, but assume that if the remote end has
* given us a huge send_max_packet, it will also handle huge ssh
* packets.
*
* For channels that are forwarded via a gateway, we do need to care
* about (3), but that is done by the gatewaying code adjusting the
* send_max_packet. */
return MIN(self->channel->send_window_size, self->channel->send_max_packet);
}
struct io_callback *
make_read_data(struct ssh_channel *channel,
struct abstract_write *write)
{
NEW(read_data, self);
init_consuming_read(&self->super, write);
self->super.query = do_read_data_query;
self->super.consumer = write;
self->channel = channel;
channel->sources++;
return &self->super.super;
}
/* read_data.h
*
* A read handler for application data.
*
*/
/* lsh, an implementation of the ssh protocol
*
* Copyright (C) 1998 Niels Möller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#error obsolete file
#ifndef LSH_READ_DATA_H_INCLUDED
#define LSH_READ_DATA_H_INCLUDED
#include "channel.h"
struct io_callback *
make_read_data(struct ssh_channel *channel,
struct abstract_write *write);
#endif /* LSH_READ_DATA_H_INCLUDED */
/* read_file.c
*
* A read handler for reading an entire file as a string.
*
*/
/* lsh, an implementation of the ssh protocol
*
* Copyright (C) 2000 Niels Mller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <string.h>
#include "abstract_io.h"
#include "format.h"
#include "lsh_string.h"
#include "werror.h"
#include "xalloc.h"
#include "read_file.c.x"
/* GABA:
(class
(name read_file)
(super read_handler)
(vars
(c object abstract_write)
(buffer string)
(pos . uint32_t)))
*/
static uint32_t
do_read_file(struct read_handler **h,
uint32_t available,
const uint8_t *data)
{
CAST(read_file, self, *h);
if (!self->buffer)
{
/* Ignore any extra data. */
werror("do_read_file: buffer == NULL, ignoring extra data.\n");
return available;
}
if (!available)
{
/* EOF reached */
lsh_string_trunc(self->buffer, self->pos);
A_WRITE(self->c, self->buffer);
self->buffer = NULL;
*h = NULL;
return 0;
}
else
{
uint32_t left = lsh_string_length(self->buffer) - self->pos;
if (available >= left)
{
lsh_string_write(self->buffer, self->pos, left, data);
A_WRITE(self->c, self->buffer);
self->buffer = NULL;
*h = NULL;
return available;
}
else
{
lsh_string_write(self->buffer, self->pos, available, data);
self->pos += available;
return available;
}
}
}
struct read_handler *
make_read_file(struct abstract_write *c,
uint32_t max_size)
{
NEW(read_file, self);
assert(max_size);
self->super.handler = do_read_file;
self->c = c;
self->buffer = lsh_string_alloc(max_size);
self->pos = 0;
return &self->super;
}
/* read_line.c
*
*/
/* lsh, an implementation of the ssh protocol
*
* Copyright (C) 1998 Niels Mller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <string.h>
#include "read_line.h"
#include "lsh_string.h"
#include "werror.h"
#include "xalloc.h"
#define GABA_DEFINE
#include "read_line.h.x"
#undef GABA_DEFINE
#include "read_line.c.x"
/* GABA:
(class
(name read_line)
(super read_handler)
(vars
(handler object line_handler)
(e object exception_handler)
; Line buffer
(pos . uint32_t)
(buffer string)))
*/
static uint32_t
do_read_line(struct read_handler **h,
uint32_t available,
const uint8_t *data)
{
CAST(read_line, self, *h);
uint8_t *eol;
uint32_t consumed;
uint32_t tail;
uint32_t length;
if (!available)
{
/* FIXME: Should we use some other exception type for this? */
EXCEPTION_RAISE(self->e,
make_protocol_exception(0, "Unexpected EOF"));
*h = NULL;
return 0;
}
eol = memchr(data, 0x0a, available);
if (!eol)
{
/* No newline character yet */
if (available + self->pos >= 255)
{
/* Too long line */
EXCEPTION_RAISE(self->e,
make_protocol_exception(0, "Line too long."));
}
else
{
lsh_string_write(self->buffer, self->pos, available, data);
self->pos += available;
}
return available;
}
tail = eol - data; /* Excludes the newline character */
consumed = tail + 1; /* Includes newline character */
if ( (self->pos + consumed) > MAX_LINE)
{
/* Too long line */
EXCEPTION_RAISE(self->e,
make_protocol_exception(0, "Line too long."));
return available;
}
/* Ok, now we have a line. Copy it into the buffer. */
lsh_string_write(self->buffer, self->pos, tail, data);
length = self->pos + tail;
/* Exclude carriage return character, if any */
if (length && (data[length-1] == 0xd))
length--;
/* NOTE: This call can modify both self->handler and *h. */
PROCESS_LINE(self->handler, h,
length, lsh_string_data(self->buffer), self->e);
/* Reset */
self->pos = 0;
return consumed;
}
struct read_handler *make_read_line(struct line_handler *handler,
struct exception_handler *e)
{
NEW(read_line, closure);
assert(e);
closure->super.handler = do_read_line;
closure->pos = 0;
closure->buffer = lsh_string_alloc(MAX_LINE);
closure->handler = handler;
closure->e = e;
return &closure->super;
}
/* read_line.h
*
* Read-handler processing a line at a time.
*
*/
/* lsh, an implementation of the ssh protocol
*
* Copyright (C) 1998 Niels Möller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LSH_READ_HANDLER_H_INCLUDED
#define LSH_READ_HANDLER_H_INCLUDED
#include "abstract_io.h"
#define GABA_DECLARE
#include "read_line.h.x"
#undef GABA_DECLARE
/* This limit follows the ssh specification */
#define MAX_LINE 255
/* May store a new handler into *h. */
/* GABA:
(class
(name line_handler)
(vars
(handler indirect-method void "struct read_handler **r"
"uint32_t length" "const uint8_t *line"
"struct exception_handler *e")))
*/
#define PROCESS_LINE(h, r, length, line, e) \
((h)->handler(&(h), (r), (length), (line), (e)))
struct read_handler *make_read_line(struct line_handler *handler,
struct exception_handler *e);
#endif /* LSH_READ_HANDLER_H_INCLUDED */
/* read_packet.c
*
*/
/* lsh, an implementation of the ssh protocol
*
* Copyright (C) 1998 Niels Mller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <string.h>
#include "nettle/macros.h"
#include "read_packet.h"
#include "crypto.h"
#include "format.h"
#include "io.h"
#include "lsh_string.h"
#include "ssh.h"
#include "werror.h"
#include "xalloc.h"
#define WAIT_START 0
#define WAIT_HEADER 1
#define WAIT_CONTENTS 2
#define WAIT_MAC 3
#include "read_packet.c.x"
/* GABA:
(class
(name read_packet)
(super read_handler)
(vars
(state . int)
; Attached to read packets
(sequence_number . uint32_t)
; Buffer index, used for all the buffers
(pos . uint32_t)
; Buffer for first received block
(block_buffer string)