api-messages.texi 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. @c -*-texinfo-*-
  2. @c This file is part of Guile-SSH Reference Manual.
  3. @c Copyright (C) 2014 Artyom V. Poptsov
  4. @c See the file guile-ssh.texi for copying conditions.
  5. @node Messages
  6. @section Messages
  7. @cindex talking to a SSH client
  8. @tindex message
  9. The @code{(ssh message)} module provides procedures for handling of
  10. Guile-SSH messages.
  11. @menu
  12. * Message Handling::
  13. * Parsing of Requests::
  14. @end menu
  15. @node Message Handling
  16. @subsection Messages Handling
  17. A message is an object that represents a single request to a Guile-SSH
  18. server. Basically the server handles requests in some loop in which
  19. it accepts messages with @code{server-message-get} procedure
  20. (@pxref{Servers}), handles the received request and replies to the
  21. message.
  22. @deffn {Scheme Procedure} message? x
  23. Return @code{#t} if @var{x} a Guile-SSH message, @code{#f} otherwise.
  24. @end deffn
  25. @deffn {Scheme Procedure} message-reply-default message
  26. Reply with @var{SSH_MSG_UNIMPLEMENTED}. Throw @code{guile-ssh-error}
  27. on error. Return value is undefined.
  28. @end deffn
  29. @deffn {Scheme Procedure} message-reply-success message [args]
  30. Reply ``success'' to the @var{message}. This procedure is a
  31. convenient wrapper for other @code{*-reply-success} procedures (see
  32. below). The right procedure to use will be selected depending on a
  33. type of the @code{message}. The procedure may take additional
  34. argument @code{'partial} for that changes reply to authentication
  35. request, and a @code{bound-port} for a global request.
  36. Throw an exception on error. Return value is undefined.
  37. @end deffn
  38. @deffn {Scheme Procedure} message-service-reply-success message
  39. Reply with ``success'' status on the service-request @var{message}.
  40. Throw @code{guile-ssh-error} on error. Return value is undefined.
  41. @end deffn
  42. @deffn {Scheme Procedure} message-auth-reply-success message partial?
  43. Reply with ``success'' on the auth-request @var{message}. Throw
  44. @code{guile-ssh-error} on error. Return value is undefined.
  45. @end deffn
  46. @deffn {Scheme Procedure} message-channel-request-reply-success message
  47. Reply ``success'' on a channel-request @var{message}.
  48. Throw @code{guile-ssh-error} on error. Return value is undefined.
  49. @end deffn
  50. @deffn {Scheme Procedure} message-global-request-reply-success message bound-port
  51. Reply ``success'' on a global request @var{message}. Throw
  52. @code{guile-ssh-error} on error. Return value is undefined.
  53. @end deffn
  54. @deffn {Scheme Procedure} message-auth-reply-public-key-ok message
  55. Reply ``OK'' on the public key auth-request @var{message}. Throw
  56. @code{guile-ssh-error} on error. Return value is undefined.
  57. @end deffn
  58. @deffn {Scheme Procedure} message-channel-request-open-reply-accept message
  59. Accept open-channel request. Return a new Guile-SSH channel, or
  60. @code{#f} on error.
  61. @end deffn
  62. @deffn {Scheme Procedure} message-get-type message
  63. Get type of the @var{message} in the following format:
  64. @example
  65. <msg-type> = "'(" <type> [<WSP> <subtype>] ")"
  66. @end example
  67. The procedure returns @code{#f} on error.
  68. Example:
  69. @lisp
  70. (message-get-type msg)
  71. @result{} '(request-auth auth-method-none)
  72. @end lisp
  73. Possible types:
  74. @table @samp
  75. @item request-auth
  76. Subtypes:
  77. @table @samp
  78. @item auth-method-unknown
  79. @item auth-method-none
  80. @item auth-method-password
  81. @item auth-method-publickey
  82. @item auth-method-hostbased
  83. @item auth-method-interactive
  84. @end table
  85. @item request-channel-open
  86. Subtypes:
  87. @table @samp
  88. @item channel-unknown
  89. @item channel-session
  90. @item channel-direct-tcpip
  91. @item channel-forwarded-tcpip
  92. @item channel-x11
  93. @end table
  94. @item request-channel
  95. Subtypes:
  96. @table @samp
  97. @item channel-request-unknown
  98. @item channel-request-pty
  99. @item channel-request-exec
  100. @item channel-request-shell
  101. @item channel-request-env
  102. @item channel-request-subsystem
  103. @item channel-request-window-change
  104. @end table
  105. @item request-service
  106. @item request-global
  107. Subtypes:
  108. @table @samp
  109. @item global-request-unknown
  110. @item global-request-tcpip-forward
  111. @item global-request-cancel-tcpip-forward
  112. @end table
  113. @end table
  114. @end deffn
  115. @deffn {Scheme Procedure} message-get-req message
  116. Get a request object from the @var{message}. Returns a new request
  117. object (@pxref{Parsing of Requests}). Throw @code{guile-ssh-error} on
  118. error.
  119. @end deffn
  120. @deffn {Scheme Procedure} message-auth-set-methods! message methods-list
  121. Set authentication methods to @var{methods-list}. Possible methods
  122. are: @code{password}, @code{public-key}, @code{interactive},
  123. @code{host-based}. Throw @code{guile-ssh-error} on error. Return
  124. value is undefined.
  125. @end deffn
  126. @deffn {Scheme Procedure} message-get-session message
  127. Get the session from which the @var{message} was received. Return the
  128. session.
  129. @end deffn
  130. @node Parsing of Requests
  131. @subsection Parsing of Requests
  132. @cindex handling of requests
  133. @tindex request
  134. @deffn {Scheme Procedure} service-req:service request
  135. Get service name from a service @var{request}.
  136. @end deffn
  137. @deffn {Scheme Procedure} channel-open-req:orig request
  138. @deffnx {Scheme Procedure} channel-open-req:orig-port request
  139. @deffnx {Scheme Procedure} channel-open-req:dest request
  140. @deffnx {Scheme Procedure} channel-open-req:dest-port request
  141. Get originator, originator-port, destination and destination-port from
  142. the channel-open @var{request}.
  143. @end deffn
  144. @deffn {Scheme Procedure} auth-req:user request
  145. @deffnx {Scheme Procedure} auth-req:password request
  146. @deffnx {Scheme Procedure} auth-req:pubkey request
  147. @deffnx {Scheme Procedure} auth-req:pubkey-state request
  148. Get user, password, public key and public key state from the auth
  149. @var{request}.
  150. @end deffn
  151. @deffn {Scheme Procedure} pty-req:term request
  152. @deffnx {Scheme Procedure} pty-req:width request
  153. @deffnx {Scheme Procedure} pty-req:height request
  154. @deffnx {Scheme Procedure} pty-req:pxwidth request
  155. @deffnx {Scheme Procedure} pty-req:pxheight request
  156. Get terminal, terminal width, terminal height, terminal pxwidth and
  157. terminal pxheight from the @acronym{PTY} @var{request}.
  158. @end deffn
  159. @deffn {Scheme Procedure} env-req:name request
  160. @deffnx {Scheme Procedure} env-req:value request
  161. Get environment variable name and its value from the environment
  162. @var{request}.
  163. @end deffn
  164. @deffn {Scheme Procedure} exec-req:cmd request
  165. Get a command from the exec @var{request}.
  166. @end deffn
  167. @deffn {Scheme Procedure} global-req:addr request
  168. @deffnx {Scheme Procedure} global-req:port request
  169. Get address and port from the global @var{request}.
  170. @end deffn
  171. @c Local Variables:
  172. @c TeX-master: "guile-ssh.texi"
  173. @c End: