ssh1connection.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. bool X11_fwd_enabled;
  23. struct X11Display *x11disp;
  24. struct X11FakeAuth *x11auth;
  25. tree234 *x11authtree;
  26. tree234 *rportfwds;
  27. PortFwdManager *portfwdmgr;
  28. bool portfwdmgr_configured;
  29. bool finished_setup;
  30. /*
  31. * These store the list of requests that we're waiting for
  32. * SSH_SMSG_{SUCCESS,FAILURE} replies to. (Those messages don't
  33. * come with any indication of what they're in response to, so we
  34. * have to keep track of the queue ourselves.)
  35. */
  36. struct outstanding_succfail *succfail_head, *succfail_tail;
  37. bool compressing; /* used in server mode only */
  38. bool sent_exit_status; /* also for server mode */
  39. prompts_t *antispoof_prompt;
  40. int antispoof_ret;
  41. const SshServerConfig *ssc;
  42. ConnectionLayer cl;
  43. PacketProtocolLayer ppl;
  44. };
  45. struct ssh1_channel {
  46. struct ssh1_connection_state *connlayer;
  47. unsigned remoteid, localid;
  48. int type;
  49. /* True if we opened this channel but server hasn't confirmed. */
  50. bool halfopen;
  51. /* Bitmap of whether we've sent/received CHANNEL_CLOSE and
  52. * CHANNEL_CLOSE_CONFIRMATION. */
  53. #define CLOSES_SENT_CLOSE 1
  54. #define CLOSES_SENT_CLOSECONF 2
  55. #define CLOSES_RCVD_CLOSE 4
  56. #define CLOSES_RCVD_CLOSECONF 8
  57. int closes;
  58. /*
  59. * This flag indicates that an EOF is pending on the outgoing side
  60. * of the channel: that is, wherever we're getting the data for
  61. * this channel has sent us some data followed by EOF. We can't
  62. * actually send the EOF until we've finished sending the data, so
  63. * we set this flag instead to remind us to do so once our buffer
  64. * is clear.
  65. */
  66. bool pending_eof;
  67. /*
  68. * True if this channel is causing the underlying connection to be
  69. * throttled.
  70. */
  71. bool throttling_conn;
  72. /*
  73. * True if we currently have backed-up data on the direction of
  74. * this channel pointing out of the SSH connection, and therefore
  75. * would prefer the 'Channel' implementation not to read further
  76. * local input if possible.
  77. */
  78. bool throttled_by_backlog;
  79. Channel *chan; /* handle the client side of this channel, if not */
  80. SshChannel sc; /* entry point for chan to talk back to */
  81. };
  82. SshChannel *ssh1_session_open(ConnectionLayer *cl, Channel *chan);
  83. void ssh1_channel_init(struct ssh1_channel *c);
  84. void ssh1_channel_free(struct ssh1_channel *c);
  85. struct ssh_rportfwd *ssh1_rportfwd_alloc(
  86. ConnectionLayer *cl,
  87. const char *shost, int sport, const char *dhost, int dport,
  88. int addressfamily, const char *log_description, PortFwdRecord *pfr,
  89. ssh_sharing_connstate *share_ctx);
  90. SshChannel *ssh1_serverside_x11_open(
  91. ConnectionLayer *cl, Channel *chan, const SocketPeerInfo *pi);
  92. SshChannel *ssh1_serverside_agent_open(ConnectionLayer *cl, Channel *chan);
  93. void ssh1_connection_direction_specific_setup(
  94. struct ssh1_connection_state *s);
  95. bool ssh1_handle_direction_specific_packet(
  96. struct ssh1_connection_state *s, PktIn *pktin);
  97. bool ssh1_check_termination(struct ssh1_connection_state *s);
  98. bool ssh1_connection_need_antispoof_prompt(struct ssh1_connection_state *s);