ssh1connection.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. prompts_t *antispoof_prompt;
  42. int antispoof_ret;
  43. const SshServerConfig *ssc;
  44. ConnectionLayer cl;
  45. PacketProtocolLayer ppl;
  46. };
  47. struct ssh1_channel {
  48. struct ssh1_connection_state *connlayer;
  49. unsigned remoteid, localid;
  50. int type;
  51. /* True if we opened this channel but server hasn't confirmed. */
  52. bool halfopen;
  53. /* Bitmap of whether we've sent/received CHANNEL_CLOSE and
  54. * CHANNEL_CLOSE_CONFIRMATION. */
  55. #define CLOSES_SENT_CLOSE 1
  56. #define CLOSES_SENT_CLOSECONF 2
  57. #define CLOSES_RCVD_CLOSE 4
  58. #define CLOSES_RCVD_CLOSECONF 8
  59. int closes;
  60. /*
  61. * This flag indicates that an EOF is pending on the outgoing side
  62. * of the channel: that is, wherever we're getting the data for
  63. * this channel has sent us some data followed by EOF. We can't
  64. * actually send the EOF until we've finished sending the data, so
  65. * we set this flag instead to remind us to do so once our buffer
  66. * is clear.
  67. */
  68. bool pending_eof;
  69. /*
  70. * True if this channel is causing the underlying connection to be
  71. * throttled.
  72. */
  73. bool throttling_conn;
  74. /*
  75. * True if we currently have backed-up data on the direction of
  76. * this channel pointing out of the SSH connection, and therefore
  77. * would prefer the 'Channel' implementation not to read further
  78. * local input if possible.
  79. */
  80. bool throttled_by_backlog;
  81. Channel *chan; /* handle the client side of this channel, if not */
  82. SshChannel sc; /* entry point for chan to talk back to */
  83. };
  84. SshChannel *ssh1_session_open(ConnectionLayer *cl, Channel *chan);
  85. void ssh1_channel_init(struct ssh1_channel *c);
  86. void ssh1_channel_free(struct ssh1_channel *c);
  87. struct ssh_rportfwd *ssh1_rportfwd_alloc(
  88. ConnectionLayer *cl,
  89. const char *shost, int sport, const char *dhost, int dport,
  90. int addressfamily, const char *log_description, PortFwdRecord *pfr,
  91. ssh_sharing_connstate *share_ctx);
  92. SshChannel *ssh1_serverside_x11_open(
  93. ConnectionLayer *cl, Channel *chan, const SocketPeerInfo *pi);
  94. SshChannel *ssh1_serverside_agent_open(ConnectionLayer *cl, Channel *chan);
  95. void ssh1_connection_direction_specific_setup(
  96. struct ssh1_connection_state *s);
  97. bool ssh1_handle_direction_specific_packet(
  98. struct ssh1_connection_state *s, PktIn *pktin);
  99. bool ssh1_check_termination(struct ssh1_connection_state *s);
  100. bool ssh1_connection_need_antispoof_prompt(struct ssh1_connection_state *s);