summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/ssh/channels.h2
-rw-r--r--usr.bin/ssh/compat.c2
-rw-r--r--usr.bin/ssh/compat.h2
-rw-r--r--usr.bin/ssh/nchan.c11
-rw-r--r--usr.bin/ssh/nchan.h109
5 files changed, 71 insertions, 55 deletions
diff --git a/usr.bin/ssh/channels.h b/usr.bin/ssh/channels.h
index d56892825ff..a046889d5d3 100644
--- a/usr.bin/ssh/channels.h
+++ b/usr.bin/ssh/channels.h
@@ -1,3 +1,5 @@
+/* RCSID("$Id: channels.h,v 1.2 1999/10/16 22:29:00 markus Exp $"); */
+
#ifndef CHANNELS_H
#define CHANNELS_H
diff --git a/usr.bin/ssh/compat.c b/usr.bin/ssh/compat.c
index a003fc6e8c8..fa0579c3107 100644
--- a/usr.bin/ssh/compat.c
+++ b/usr.bin/ssh/compat.c
@@ -1,4 +1,6 @@
#include "includes.h"
+RCSID("$Id: compat.c,v 1.2 1999/10/16 22:29:01 markus Exp $");
+
#include "ssh.h"
int compat13=0;
diff --git a/usr.bin/ssh/compat.h b/usr.bin/ssh/compat.h
index ee77fbae923..03289c27ab1 100644
--- a/usr.bin/ssh/compat.h
+++ b/usr.bin/ssh/compat.h
@@ -1,3 +1,5 @@
+/* RCSID("$Id: compat.h,v 1.2 1999/10/16 22:29:01 markus Exp $"); */
+
#ifndef COMPAT_H
#define COMPAT_H
void enable_compat13(void);
diff --git a/usr.bin/ssh/nchan.c b/usr.bin/ssh/nchan.c
index 1ee66e111bb..1916894ab06 100644
--- a/usr.bin/ssh/nchan.c
+++ b/usr.bin/ssh/nchan.c
@@ -1,4 +1,6 @@
#include "includes.h"
+RCSID("$Id: nchan.c,v 1.2 1999/10/16 22:29:01 markus Exp $");
+
#include "ssh.h"
#include "buffer.h"
@@ -6,7 +8,6 @@
#include "packet.h"
#include "nchan.h"
-
void
dump_chan(Channel *c){
debug("chan %d type %d flags 0x%x", c->self, c->type, c->flags);
@@ -41,7 +42,8 @@ chan_rcvd_oclose(Channel *c){
void
chan_send_ieof(Channel *c){
if(c->flags & CHAN_IEOF_SENT){
- debug("send_chan_ieof twice %d", c->self);
+ /* this is ok: it takes some time before we get OCLOSE */
+ /* debug("send_chan_ieof twice %d", c->self); */
return;
}
debug("send_CHAN_IEOF %d", c->self);
@@ -76,12 +78,13 @@ chan_shutdown_write(Channel *c){
c->flags |= CHAN_SHUT_WR;
/* clear output buffer, since there is noone going to read the data
we just closed the output-socket */
- // buffer_consume(&c->output, buffer_len(&c->output));
+ /* buffer_consume(&c->output, buffer_len(&c->output)); */
}
void
chan_shutdown_read(Channel *c){
if(c->flags & CHAN_SHUT_RD){
- debug("chan_shutdown_read twice %d",c->self);
+ /* chan_shutdown_read is called for read-errors and OCLOSE */
+ /* debug("chan_shutdown_read twice %d",c->self); */
return;
}
debug("chan_shutdown_read %d", c->self);
diff --git a/usr.bin/ssh/nchan.h b/usr.bin/ssh/nchan.h
index b83cf2de035..f312b0ec64b 100644
--- a/usr.bin/ssh/nchan.h
+++ b/usr.bin/ssh/nchan.h
@@ -1,66 +1,73 @@
+/* RCSID("$Id: nchan.h,v 1.2 1999/10/16 22:29:01 markus Exp $"); */
+
#ifndef NCHAN_H
#define NCHAN_H
-
/*
- SSH Protocol 1.5 aka New Channel Protocol
- Thanks to Martina, Axel and everyone who left Erlangen, leaving me bored.
- Written by Markus Friedl in October 1999
-
- Protocol versions 1.3 and 1.5 differ in the handshake protocol used for the
- tear down of channels:
-
- 1.3: strict request-ack-protocol:
- CLOSE ->
- <- CLOSE_CONFIRM
-
- 1.5: uses variations of:
- IEOF ->
- <- OCLOSE
- <- IEOF
- OCLOSE ->
-
- See the debugging output from 'ssh -v' and 'sshd -d' in ssh-1.2.27, for example.
-
- Details: (for Channel data structure see channels.h)
-
- the output_buffer gets data received from the remote peer and is written to the socket,
- the input_buffer gets data from the socket and is sent to remote peer.
- the socket represents the local object communicating with an object reachable via the peer
-
- PEER A PEER B
-
- read(sock, input_buffer) < 0;
- shutdown_read();
- flush(input_buffer) =: DATA
- send(DATA) -> rcvd(DATA)
- write(sock, output_buffer:=DATA);
- send(IEOF) -> rcvd(IEOF)
- shutdown_write() if:
- a) write fails
- b) rcvd_IEOF==true && output_buffer==empty
- <- send(OCLOSE)
- rcvd(OCLOSE) destroy channel
- shutdown_read() if not already
- destroy channel
-
- Note that each side can close the channel only if 2 messages
- have been sent and received and the associated socket has been shutdown, see below:
-*/
-
+ * SSH Protocol 1.5 aka New Channel Protocol
+ * Thanks to Martina, Axel and everyone who left Erlangen, leaving me bored.
+ * Written by Markus Friedl in October 1999
+ *
+ * Protocol versions 1.3 and 1.5 differ in the handshake protocol used for the
+ * tear down of channels:
+ *
+ * 1.3: strict request-ack-protocol:
+ * CLOSE ->
+ * <- CLOSE_CONFIRM
+ *
+ * 1.5: uses variations of:
+ * IEOF ->
+ * <- OCLOSE
+ * <- IEOF
+ * OCLOSE ->
+ * i.e. both sides have to close the channel
+ *
+ * See the debugging output from 'ssh -v' and 'sshd -d' of
+ * ssh-1.2.27 as an example.
+ *
+ * Details: (for Channel data structure see channels.h)
+ *
+ * - the output_buffer gets data received from the remote peer and
+ * is written to the socket,
+ * - the input_buffer gets data from the socket and is sent to remote peer.
+ * - the socket represents the local object communicating with an object
+ * reachable via the peer
+ *
+ * PEER A PEER B
+ *
+ * read(sock, input_buffer) < 0;
+ * shutdown_read();
+ * flush(input_buffer) =: DATA
+ * send(DATA) -> rcvd(DATA)
+ * write(sock, output_buffer:=DATA);
+ * send(IEOF) -> rcvd(IEOF)
+ * shutdown_write() if:
+ * a) write fails
+ * b) rcvd_IEOF==true &&
+ * output_buffer==empty
+ * rcvd(OCLOSE) <- send(OCLOSE)
+ *
+ * The channel is now half closed. No data will flow from A to B.
+ *
+ * Note that each side can remove the channel only if 2 messages
+ * have been sent and received and the associated socket has been
+ * shutdown, see below:
+ */
enum {
/* ssh-proto-1.5 overloads message-types */
- CHAN_IEOF = SSH_MSG_CHANNEL_CLOSE, /* no more data from sender */
- CHAN_OCLOSE = SSH_MSG_CHANNEL_CLOSE_CONFIRMATION, /* all received data has been output */
+ CHAN_IEOF = SSH_MSG_CHANNEL_CLOSE,
+ /* there will be no more data from sender */
+ CHAN_OCLOSE = SSH_MSG_CHANNEL_CLOSE_CONFIRMATION,
+ /* all received data has been written to the socket */
/* channel close flags */
- CHAN_IEOF_SENT = 0x01,
- CHAN_IEOF_RCVD = 0x02,
+ CHAN_IEOF_SENT = 0x01,
+ CHAN_IEOF_RCVD = 0x02,
CHAN_OCLOSE_SENT = 0x04,
CHAN_OCLOSE_RCVD = 0x08,
CHAN_SHUT_RD = 0x10,
- CHAN_SHUT_WR = 0x20,
+ CHAN_SHUT_WR = 0x20,
/* a channel can be removed if ALL the following flags are set: */
CHAN_CLOSED = CHAN_IEOF_SENT | CHAN_IEOF_RCVD |