ssh1connection.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. struct ssh1_channel;
  2. struct outstanding_succfail;
  3. struct ssh1_connection_state {
  4. int crState;
  5. Ssh *ssh;
  6. Conf *conf;
  7. int local_protoflags, remote_protoflags;
  8. tree234 *channels; /* indexed by local id */
  9. /* In SSH-1, the main session doesn't take the form of a 'channel'
  10. * according to the wire protocol. But we want to use the same API
  11. * for it, so we define an SshChannel here - but one that uses a
  12. * separate vtable from the usual one, so it doesn't map to a
  13. * struct ssh1_channel as all the others do. */
  14. SshChannel mainchan_sc;
  15. Channel *mainchan_chan; /* the other end of mainchan_sc */
  16. mainchan *mainchan; /* and its subtype */
  17. bool got_pty;
  18. bool ldisc_opts[LD_N_OPTIONS];
  19. bool stdout_throttling;
  20. bool want_user_input;
  21. bool session_terminated;
  22. int term_width, term_height, term_width_orig, term_height_orig;
  23. bool X11_fwd_enabled;
  24. struct X11Display *x11disp;
  25. struct X11FakeAuth *x11auth;
  26. tree234 *x11authtree;
  27. bool agent_fwd_enabled;
  28. tree234 *rportfwds;
  29. PortFwdManager *portfwdmgr;
  30. bool portfwdmgr_configured;
  31. bool finished_setup;
  32. /*
  33. * These store the list of requests that we're waiting for
  34. * SSH_SMSG_{SUCCESS,FAILURE} replies to. (Those messages don't
  35. * come with any indication of what they're in response to, so we
  36. * have to keep track of the queue ourselves.)
  37. */
  38. struct outstanding_succfail *succfail_head, *succfail_tail;
  39. bool compressing; /* used in server mode only */
  40. bool sent_exit_status; /* also for server mode */
  41. ConnectionLayer cl;
  42. PacketProtocolLayer ppl;
  43. };
  44. struct ssh1_channel {
  45. struct ssh1_connection_state *connlayer;
  46. unsigned remoteid, localid;
  47. int type;
  48. /* True if we opened this channel but server hasn't confirmed. */
  49. bool halfopen;
  50. /* Bitmap of whether we've sent/received CHANNEL_CLOSE and
  51. * CHANNEL_CLOSE_CONFIRMATION. */
  52. #define CLOSES_SENT_CLOSE 1
  53. #define CLOSES_SENT_CLOSECONF 2
  54. #define CLOSES_RCVD_CLOSE 4
  55. #define CLOSES_RCVD_CLOSECONF 8
  56. int closes;
  57. /*
  58. * This flag indicates that an EOF is pending on the outgoing side
  59. * of the channel: that is, wherever we're getting the data for
  60. * this channel has sent us some data followed by EOF. We can't
  61. * actually send the EOF until we've finished sending the data, so
  62. * we set this flag instead to remind us to do so once our buffer
  63. * is clear.
  64. */
  65. bool pending_eof;
  66. /*
  67. * True if this channel is causing the underlying connection to be
  68. * throttled.
  69. */
  70. bool throttling_conn;
  71. /*
  72. * True if we currently have backed-up data on the direction of
  73. * this channel pointing out of the SSH connection, and therefore
  74. * would prefer the 'Channel' implementation not to read further
  75. * local input if possible.
  76. */
  77. bool throttled_by_backlog;
  78. Channel *chan; /* handle the client side of this channel, if not */
  79. SshChannel sc; /* entry point for chan to talk back to */
  80. };
  81. SshChannel *ssh1_session_open(ConnectionLayer *cl, Channel *chan);
  82. void ssh1_channel_init(struct ssh1_channel *c);
  83. void ssh1_channel_free(struct ssh1_channel *c);
  84. struct ssh_rportfwd *ssh1_rportfwd_alloc(
  85. ConnectionLayer *cl,
  86. const char *shost, int sport, const char *dhost, int dport,
  87. int addressfamily, const char *log_description, PortFwdRecord *pfr,
  88. ssh_sharing_connstate *share_ctx);
  89. SshChannel *ssh1_serverside_x11_open(
  90. ConnectionLayer *cl, Channel *chan, const SocketPeerInfo *pi);
  91. SshChannel *ssh1_serverside_agent_open(ConnectionLayer *cl, Channel *chan);
  92. void ssh1_connection_direction_specific_setup(
  93. struct ssh1_connection_state *s);
  94. bool ssh1_handle_direction_specific_packet(
  95. struct ssh1_connection_state *s, PktIn *pktin);
  96. bool ssh1_check_termination(struct ssh1_connection_state *s);