xref: /titanic_44/usr/src/cmd/ssh/doc/nchan2.ms (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate.TL
2*7c478bd9Sstevel@tonic-gateOpenSSH Channel Close Protocol 2.0 Implementation
3*7c478bd9Sstevel@tonic-gate.SH
4*7c478bd9Sstevel@tonic-gateChannel Input State Diagram
5*7c478bd9Sstevel@tonic-gate.PS
6*7c478bd9Sstevel@tonic-gatereset
7*7c478bd9Sstevel@tonic-gatel=1
8*7c478bd9Sstevel@tonic-gates=1.2
9*7c478bd9Sstevel@tonic-gateellipsewid=s*ellipsewid
10*7c478bd9Sstevel@tonic-gateboxwid=s*boxwid
11*7c478bd9Sstevel@tonic-gateellipseht=s*ellipseht
12*7c478bd9Sstevel@tonic-gateS1: ellipse "INPUT" "OPEN"
13*7c478bd9Sstevel@tonic-gatemove right 2*l from last ellipse.e
14*7c478bd9Sstevel@tonic-gateS3: ellipse invis
15*7c478bd9Sstevel@tonic-gatemove down l from last ellipse.s
16*7c478bd9Sstevel@tonic-gateS4: ellipse "INPUT" "CLOSED"
17*7c478bd9Sstevel@tonic-gatemove down l from 1st ellipse.s
18*7c478bd9Sstevel@tonic-gateS2: ellipse "INPUT" "WAIT" "DRAIN"
19*7c478bd9Sstevel@tonic-gatearrow from S1.e to S4.n
20*7c478bd9Sstevel@tonic-gatebox invis "rcvd CLOSE/" "shutdown_read" with .sw at last arrow.c
21*7c478bd9Sstevel@tonic-gatearrow "ibuf_empty ||" "rcvd CLOSE/" "send EOF" "" from S2.e to S4.w
22*7c478bd9Sstevel@tonic-gatearrow from S1.s to S2.n
23*7c478bd9Sstevel@tonic-gatebox invis "read_failed/" "shutdown_read" with .e at last arrow.c
24*7c478bd9Sstevel@tonic-gateellipse wid .9*ellipsewid ht .9*ellipseht at S4
25*7c478bd9Sstevel@tonic-gatearrow "start" "" from S1.w+(-0.5,0) to S1.w
26*7c478bd9Sstevel@tonic-gate.PE
27*7c478bd9Sstevel@tonic-gate.SH
28*7c478bd9Sstevel@tonic-gateChannel Output State Diagram
29*7c478bd9Sstevel@tonic-gate.PS
30*7c478bd9Sstevel@tonic-gateS1: ellipse "OUTPUT" "OPEN"
31*7c478bd9Sstevel@tonic-gatemove right 2*l from last ellipse.e
32*7c478bd9Sstevel@tonic-gateS3: ellipse invis
33*7c478bd9Sstevel@tonic-gatemove down l from last ellipse.s
34*7c478bd9Sstevel@tonic-gateS4: ellipse "OUTPUT" "CLOSED"
35*7c478bd9Sstevel@tonic-gatemove down l from 1st ellipse.s
36*7c478bd9Sstevel@tonic-gateS2: ellipse "OUTPUT" "WAIT" "DRAIN"
37*7c478bd9Sstevel@tonic-gatearrow from S1.e to S4.n
38*7c478bd9Sstevel@tonic-gatebox invis "write_failed/" "shutdown_write" with .sw at last arrow.c
39*7c478bd9Sstevel@tonic-gatearrow "obuf_empty ||" "write_failed/" "shutdown_write" "" from S2.e to S4.w
40*7c478bd9Sstevel@tonic-gatearrow from S1.s to S2.n
41*7c478bd9Sstevel@tonic-gatebox invis "rcvd EOF ||" "rcvd CLOSE/" "-" with .e at last arrow.c
42*7c478bd9Sstevel@tonic-gateellipse wid .9*ellipsewid ht .9*ellipseht at S4
43*7c478bd9Sstevel@tonic-gatearrow "start" "" from S1.w+(-0.5,0) to S1.w
44*7c478bd9Sstevel@tonic-gate.PE
45*7c478bd9Sstevel@tonic-gate.SH
46*7c478bd9Sstevel@tonic-gateNotes
47*7c478bd9Sstevel@tonic-gate.PP
48*7c478bd9Sstevel@tonic-gateThe input buffer is filled with data from the socket
49*7c478bd9Sstevel@tonic-gate(the socket represents the local consumer/producer of the
50*7c478bd9Sstevel@tonic-gateforwarded channel).
51*7c478bd9Sstevel@tonic-gateThe data is then sent over the INPUT-end (transmit-end) of the channel to the
52*7c478bd9Sstevel@tonic-gateremote peer.
53*7c478bd9Sstevel@tonic-gateData sent by the peer is received on the OUTPUT-end (receive-end),
54*7c478bd9Sstevel@tonic-gatesaved in the output buffer and written to the socket.
55*7c478bd9Sstevel@tonic-gate.PP
56*7c478bd9Sstevel@tonic-gateIf the local protocol instance has forwarded all data on the
57*7c478bd9Sstevel@tonic-gateINPUT-end of the channel, it sends an EOF message to the peer.
58*7c478bd9Sstevel@tonic-gate.PP
59*7c478bd9Sstevel@tonic-gateA CLOSE message is sent to the peer if
60*7c478bd9Sstevel@tonic-gateboth the INPUT- and the OUTOUT-half of the local
61*7c478bd9Sstevel@tonic-gateend of the channel are closed.
62*7c478bd9Sstevel@tonic-gate.PP
63*7c478bd9Sstevel@tonic-gateThe channel can be deallocated by a protocol instance
64*7c478bd9Sstevel@tonic-gateif a CLOSE message he been both sent and received.
65