comparison session.h @ 478:d4f32c3443ac dbclient-netcat-alike

propagate from branch 'au.asn.ucc.matt.dropbear' (head f21045c791002d81fc6b8dde6537ea481e513eb2) to branch 'au.asn.ucc.matt.dropbear.dbclient-netcat-alike' (head d1f69334581dc4c35f9ca16aa5355074c9dd315d)
author Matt Johnston <matt@ucc.asn.au>
date Sun, 14 Sep 2008 06:47:51 +0000
parents 7e43f5e473b9
children e3db1f7a2e43
comparison
equal deleted inserted replaced
296:6b41e2cbf071 478:d4f32c3443ac
43 43
44 void common_session_init(int sock, char* remotehost); 44 void common_session_init(int sock, char* remotehost);
45 void session_loop(void(*loophandler)()); 45 void session_loop(void(*loophandler)());
46 void common_session_cleanup(); 46 void common_session_cleanup();
47 void session_identification(); 47 void session_identification();
48 void send_msg_ignore();
48 49
49 50
50 /* Server */ 51 /* Server */
51 void svr_session(int sock, int childpipe, char *remotehost, char *addrstring); 52 void svr_session(int sock, int childpipe, char *remotehost, char *addrstring);
52 void svr_dropbear_exit(int exitcode, const char* format, va_list param); 53 void svr_dropbear_exit(int exitcode, const char* format, va_list param);
79 unsigned char recvmackey[MAX_MAC_KEY]; 80 unsigned char recvmackey[MAX_MAC_KEY];
80 unsigned char transmackey[MAX_MAC_KEY]; 81 unsigned char transmackey[MAX_MAC_KEY];
81 82
82 }; 83 };
83 84
85 struct packetlist;
86 struct packetlist {
87 struct packetlist *next;
88 buffer * payload;
89 };
90
84 struct sshsession { 91 struct sshsession {
85 92
86 /* Is it a client or server? */ 93 /* Is it a client or server? */
87 unsigned char isserver; 94 unsigned char isserver;
88 95
89 long connecttimeout; /* time to disconnect if we have a timeout (for 96 time_t connect_time; /* time the connection was established
90 userauth etc), or 0 for no timeout */ 97 (cleared after auth once we're not
98 respecting AUTH_TIMEOUT any more) */
91 99
92 int sock; 100 int sock;
93 101
94 unsigned char *remotehost; /* the peer hostname */ 102 unsigned char *remotehost; /* the peer hostname */
95 103
121 unsigned char ignorenext; /* whether to ignore the next packet, 129 unsigned char ignorenext; /* whether to ignore the next packet,
122 used for kex_follows stuff */ 130 used for kex_follows stuff */
123 131
124 unsigned char lastpacket; /* What the last received packet type was */ 132 unsigned char lastpacket; /* What the last received packet type was */
125 133
126 134 int signal_pipe[2]; /* stores endpoints of a self-pipe used for
135 race-free signal handling */
136
137 time_t last_packet_time; /* time of the last packet transmission, for
138 keepalive purposes */
127 139
128 /* KEX/encryption related */ 140 /* KEX/encryption related */
129 struct KEXState kexstate; 141 struct KEXState kexstate;
130 struct key_context *keys; 142 struct key_context *keys;
131 struct key_context *newkeys; 143 struct key_context *newkeys;
134 mp_int * dh_K; /* SSH_MSG_KEXDH_REPLY and sending SSH_MSH_NEWKEYS */ 146 mp_int * dh_K; /* SSH_MSG_KEXDH_REPLY and sending SSH_MSH_NEWKEYS */
135 unsigned char hash[SHA1_HASH_SIZE]; /* the hash*/ 147 unsigned char hash[SHA1_HASH_SIZE]; /* the hash*/
136 buffer* kexhashbuf; /* session hash buffer calculated from various packets*/ 148 buffer* kexhashbuf; /* session hash buffer calculated from various packets*/
137 buffer* transkexinit; /* the kexinit packet we send should be kept so we 149 buffer* transkexinit; /* the kexinit packet we send should be kept so we
138 can add it to the hash when generating keys */ 150 can add it to the hash when generating keys */
151
152 /* a list of queued replies that should be sent after a KEX has
153 concluded (ie, while dataallowed was unset)*/
154 struct packetlist *reply_queue_head, *reply_queue_tail;
139 155
140 algo_type*(*buf_match_algo)(buffer*buf, algo_type localalgos[], 156 algo_type*(*buf_match_algo)(buffer*buf, algo_type localalgos[],
141 int *goodguess); /* The function to use to choose which algorithm 157 int *goodguess); /* The function to use to choose which algorithm
142 to use from the ones presented by the remote 158 to use from the ones presented by the remote
143 side. Is specific to the client/server mode, 159 side. Is specific to the client/server mode,
187 203
188 typedef enum { 204 typedef enum {
189 KEX_NOTHING, 205 KEX_NOTHING,
190 KEXINIT_RCVD, 206 KEXINIT_RCVD,
191 KEXDH_INIT_SENT, 207 KEXDH_INIT_SENT,
192 KEXDONE, 208 KEXDONE
193
194 } cli_kex_state; 209 } cli_kex_state;
195 210
196 typedef enum { 211 typedef enum {
197 STATE_NOTHING, 212 STATE_NOTHING,
198 SERVICE_AUTH_REQ_SENT, 213 SERVICE_AUTH_REQ_SENT,
200 SERVICE_CONN_REQ_SENT, 215 SERVICE_CONN_REQ_SENT,
201 SERVICE_CONN_ACCEPT_RCVD, 216 SERVICE_CONN_ACCEPT_RCVD,
202 USERAUTH_REQ_SENT, 217 USERAUTH_REQ_SENT,
203 USERAUTH_FAIL_RCVD, 218 USERAUTH_FAIL_RCVD,
204 USERAUTH_SUCCESS_RCVD, 219 USERAUTH_SUCCESS_RCVD,
205 SESSION_RUNNING, 220 SESSION_RUNNING
206
207 } cli_state; 221 } cli_state;
208 222
209 struct clientsession { 223 struct clientsession {
210 224
211 mp_int *dh_e, *dh_x; /* Used during KEX */ 225 mp_int *dh_e, *dh_x; /* Used during KEX */