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 .\" 
  13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  14 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  15 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  16 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  17 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  18 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  19 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  20 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23 .\"
  24 .TL
  25 OpenSSH Channel Close Protocol 1.5 Implementation
  26 .SH
  27 Channel Input State Diagram
  28 .PS
  29 reset
  30 l=1
  31 s=1.2
  32 ellipsewid=s*ellipsewid
  33 boxwid=s*boxwid
  34 ellipseht=s*ellipseht
  35 S1: ellipse "INPUT" "OPEN"
  36 move right 2*l from last ellipse.e
  37 S4: ellipse "INPUT" "CLOSED"
  38 move down l from last ellipse.s
  39 S3: ellipse "INPUT" "WAIT" "OCLOSED"
  40 move down l from 1st ellipse.s
  41 S2: ellipse "INPUT" "WAIT" "DRAIN"
  42 arrow "" "rcvd OCLOSE/" "shutdown_read" "send IEOF" from S1.e to S4.w
  43 arrow "ibuf_empty/" "send IEOF" from S2.e to S3.w
  44 arrow from S1.s to S2.n
  45 box invis "read_failed/" "shutdown_read" with .e at last arrow.c
  46 arrow  from S3.n to S4.s
  47 box invis "rcvd OCLOSE/" "-" with .w at last arrow.c
  48 ellipse wid .9*ellipsewid ht .9*ellipseht at S4
  49 arrow "start" "" from S1.w+(-0.5,0) to S1.w
  50 arrow from S2.ne to S4.sw
  51 box invis "rcvd OCLOSE/     " with .e at last arrow.c
  52 box invis " send IEOF" with .w at last arrow.c
  53 .PE
  54 .SH
  55 Channel Output State Diagram
  56 .PS
  57 S1: ellipse "OUTPUT" "OPEN"
  58 move right 2*l from last ellipse.e
  59 S3: ellipse "OUTPUT" "WAIT" "IEOF"
  60 move down l from last ellipse.s
  61 S4: ellipse "OUTPUT" "CLOSED"
  62 move down l from 1st ellipse.s
  63 S2: ellipse "OUTPUT" "WAIT" "DRAIN"
  64 arrow "" "write_failed/" "shutdown_write" "send OCLOSE" from S1.e to S3.w
  65 arrow "obuf_empty ||" "write_failed/" "shutdown_write" "send OCLOSE" from S2.e to S4.w
  66 arrow from S1.s to S2.n
  67 box invis "rcvd IEOF/" "-" with .e at last arrow.c
  68 arrow from S3.s to S4.n
  69 box invis "rcvd IEOF/" "-" with .w at last arrow.c
  70 ellipse wid .9*ellipsewid ht .9*ellipseht at S4
  71 arrow "start" "" from S1.w+(-0.5,0) to S1.w
  72 .PE
  73 .SH
  74 Notes
  75 .PP
  76 The input buffer is filled with data from the socket
  77 (the socket represents the local consumer/producer of the
  78 forwarded channel).
  79 The data is then sent over the INPUT-end (transmit-end) of the channel to the
  80 remote peer.
  81 Data sent by the peer is received on the OUTPUT-end (receive-end),
  82 saved in the output buffer and written to the socket.
  83 .PP
  84 If the local protocol instance has forwarded all data on the
  85 INPUT-end of the channel, it sends an IEOF message to the peer.
  86 If the peer receives the IEOF and has consumed all
  87 data he replies with an OCLOSE.
  88 When the local instance receives the OCLOSE
  89 he considers the INPUT-half of the channel closed.
  90 The peer has his OUTOUT-half closed.
  91 .PP
  92 A channel can be deallocated by a protocol instance
  93 if both the INPUT- and the OUTOUT-half on his
  94 side of the channel are closed.
  95 Note that when an instance is unable to consume the
  96 received data, he is permitted to send an OCLOSE
  97 before the matching IEOF is received.