Annotation of src/usr.bin/ssh/nchan.h, Revision 1.2
1.2 ! markus 1: /* RCSID("$Id: servconf.h,v 1.9 1999/10/12 18:11:54 markus Exp $"); */
! 2:
1.1 markus 3: #ifndef NCHAN_H
4: #define NCHAN_H
5:
6: /*
1.2 ! markus 7: * SSH Protocol 1.5 aka New Channel Protocol
! 8: * Thanks to Martina, Axel and everyone who left Erlangen, leaving me bored.
! 9: * Written by Markus Friedl in October 1999
! 10: *
! 11: * Protocol versions 1.3 and 1.5 differ in the handshake protocol used for the
! 12: * tear down of channels:
! 13: *
! 14: * 1.3: strict request-ack-protocol:
! 15: * CLOSE ->
! 16: * <- CLOSE_CONFIRM
! 17: *
! 18: * 1.5: uses variations of:
! 19: * IEOF ->
! 20: * <- OCLOSE
! 21: * <- IEOF
! 22: * OCLOSE ->
! 23: * i.e. both sides have to close the channel
! 24: *
! 25: * See the debugging output from 'ssh -v' and 'sshd -d' of
! 26: * ssh-1.2.27 as an example.
! 27: *
! 28: * Details: (for Channel data structure see channels.h)
! 29: *
! 30: * - the output_buffer gets data received from the remote peer and
! 31: * is written to the socket,
! 32: * - the input_buffer gets data from the socket and is sent to remote peer.
! 33: * - the socket represents the local object communicating with an object
! 34: * reachable via the peer
! 35: *
! 36: * PEER A PEER B
! 37: *
! 38: * read(sock, input_buffer) < 0;
! 39: * shutdown_read();
! 40: * flush(input_buffer) =: DATA
! 41: * send(DATA) -> rcvd(DATA)
! 42: * write(sock, output_buffer:=DATA);
! 43: * send(IEOF) -> rcvd(IEOF)
! 44: * shutdown_write() if:
! 45: * a) write fails
! 46: * b) rcvd_IEOF==true &&
! 47: * output_buffer==empty
! 48: * rcvd(OCLOSE) <- send(OCLOSE)
! 49: *
! 50: * The channel is now half closed. No data will flow from A to B.
! 51: *
! 52: * Note that each side can remove the channel only if 2 messages
! 53: * have been sent and received and the associated socket has been
! 54: * shutdown, see below:
! 55: */
1.1 markus 56:
57: enum {
58: /* ssh-proto-1.5 overloads message-types */
1.2 ! markus 59: CHAN_IEOF = SSH_MSG_CHANNEL_CLOSE,
! 60: /* there will be no more data from sender */
! 61: CHAN_OCLOSE = SSH_MSG_CHANNEL_CLOSE_CONFIRMATION,
! 62: /* all received data has been written to the socket */
1.1 markus 63:
64: /* channel close flags */
1.2 ! markus 65: CHAN_IEOF_SENT = 0x01,
! 66: CHAN_IEOF_RCVD = 0x02,
1.1 markus 67: CHAN_OCLOSE_SENT = 0x04,
68: CHAN_OCLOSE_RCVD = 0x08,
69: CHAN_SHUT_RD = 0x10,
1.2 ! markus 70: CHAN_SHUT_WR = 0x20,
1.1 markus 71:
72: /* a channel can be removed if ALL the following flags are set: */
73: CHAN_CLOSED = CHAN_IEOF_SENT | CHAN_IEOF_RCVD |
74: CHAN_OCLOSE_SENT | CHAN_OCLOSE_RCVD |
75: CHAN_SHUT_RD | CHAN_SHUT_WR
76: };
77:
78: void chan_del_if_dead(Channel *c);
79: void chan_rcvd_ieof(Channel *c);
80: void chan_rcvd_oclose(Channel *c);
81: void chan_send_ieof(Channel *c);
82: void chan_send_oclose(Channel *c);
83: void chan_shutdown_read(Channel *c);
84: void chan_shutdown_write(Channel *c);
85: #endif