[BACK]Return to nchan.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Annotation of src/usr.bin/ssh/nchan.h, Revision 1.1

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