Annotation of src/usr.bin/ssh/nchan.ms, Revision 1.4
1.4 ! markus 1: .\"
! 2: .\" Copyright (c) 1999 Markus Friedl. All rights reserved.
! 3: .\"
! 4: .\" Redistribution and use in source and binary forms, with or without
! 5: .\" modification, are permitted provided that the following conditions
! 6: .\" are met:
! 7: .\" 1. Redistributions of source code must retain the above copyright
! 8: .\" notice, this list of conditions and the following disclaimer.
! 9: .\" 2. Redistributions in binary form must reproduce the above copyright
! 10: .\" notice, this list of conditions and the following disclaimer in the
! 11: .\" documentation and/or other materials provided with the distribution.
! 12: .\" 3. All advertising materials mentioning features or use of this software
! 13: .\" must display the following acknowledgement:
! 14: .\" This product includes software developed by Markus Friedl.
! 15: .\" 4. The name of the author may not be used to endorse or promote products
! 16: .\" derived from this software without specific prior written permission.
! 17: .\"
! 18: .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 19: .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 20: .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 21: .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 22: .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 23: .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 24: .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 25: .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 26: .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 27: .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 28: .\"
1.1 markus 29: .TL
30: OpenSSH Channel Close Protocol 1.5 Implementation
31: .SH
32: Channel Input State Diagram
33: .PS
34: reset
35: l=1
36: s=1.2
37: ellipsewid=s*ellipsewid
38: boxwid=s*boxwid
39: ellipseht=s*ellipseht
40: S1: ellipse "INPUT" "OPEN"
41: move right 2*l from last ellipse.e
42: S4: ellipse "INPUT" "CLOSED"
43: move down l from last ellipse.s
44: S3: ellipse "INPUT" "WAIT" "OCLOSED"
45: move down l from 1st ellipse.s
46: S2: ellipse "INPUT" "WAIT" "DRAIN"
47: arrow "" "rcvd OCLOSE/" "shutdown_read" "send IEOF" from S1.e to S4.w
48: arrow "ibuf_empty/" "send IEOF" from S2.e to S3.w
49: arrow from S1.s to S2.n
50: box invis "read_failed/" "shutdown_read" with .e at last arrow.c
51: arrow from S3.n to S4.s
52: box invis "rcvd OCLOSE/" "-" with .w at last arrow.c
53: ellipse wid .9*ellipsewid ht .9*ellipseht at S4
54: arrow "start" "" from S1.w+(-0.5,0) to S1.w
55: .PE
56: .SH
57: Channel Output State Diagram
58: .PS
59: S1: ellipse "OUTPUT" "OPEN"
60: move right 2*l from last ellipse.e
61: S3: ellipse "OUTPUT" "WAIT" "IEOF"
62: move down l from last ellipse.s
63: S4: ellipse "OUTPUT" "CLOSED"
64: move down l from 1st ellipse.s
65: S2: ellipse "OUTPUT" "WAIT" "DRAIN"
66: arrow "" "write_failed/" "shutdown_write" "send OCLOSE" from S1.e to S3.w
67: arrow "obuf_empty ||" "write_failed/" "shutdown_write" "send OCLOSE" from S2.e to S4.w
68: arrow from S1.s to S2.n
69: box invis "rcvd IEOF/" "-" with .e at last arrow.c
70: arrow from S3.s to S4.n
71: box invis "rcvd IEOF/" "-" with .w at last arrow.c
72: ellipse wid .9*ellipsewid ht .9*ellipseht at S4
73: arrow "start" "" from S1.w+(-0.5,0) to S1.w
74: .PE
1.2 markus 75: .SH
76: Notes
77: .PP
78: The input buffer is filled with data from the socket
79: (the socket represents the local comsumer/producer of the
80: forwarded channel).
1.3 markus 81: The data is then sent over the INPUT-end (transmit-end) of the channel to the
1.2 markus 82: remote peer.
1.3 markus 83: Data sent by the peer is received on the OUTPUT-end (receive-end),
1.2 markus 84: saved in the output buffer and written to the socket.
85: .PP
86: If the local protocol instance has forwarded all data on the
87: INPUT-end of the channel, it sends an IEOF message to the peer.
88: If the peer receives the IEOF and has comsumed all
89: data he replies with an OCLOSE.
90: When the local instance receives the OCLOSE
91: he considers the INPUT-half of the channel closed.
92: The peer has his OUTOUT-half closed.
93: .PP
94: A channel can be deallocated by a protocol instance
95: if both the INPUT- and the OUTOUT-half on his
96: side of the channel are closed.
97: Note that when an instance is unable to comsume the
98: received data, he is permitted to send an OCLOSE
99: before the matching IEOF is received.