connection1.h 4.1 KB

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