comparison cli-session.c @ 743:09c5eb71ec96 kexguess

merge from head roundtrip changes
author Matt Johnston <matt@ucc.asn.au>
date Mon, 01 Apr 2013 00:13:41 +0800
parents cd201dc2da9a 9a5438271556
children 15999b098cc9
comparison
equal deleted inserted replaced
742:cd201dc2da9a 743:09c5eb71ec96
39 39
40 static void cli_remoteclosed(); 40 static void cli_remoteclosed();
41 static void cli_sessionloop(); 41 static void cli_sessionloop();
42 static void cli_session_init(); 42 static void cli_session_init();
43 static void cli_finished(); 43 static void cli_finished();
44 static void recv_msg_service_accept(void);
44 45
45 struct clientsession cli_ses; /* GLOBAL */ 46 struct clientsession cli_ses; /* GLOBAL */
46 47
47 /* Sorted in decreasing frequency will be more efficient - data and window 48 /* Sorted in decreasing frequency will be more efficient - data and window
48 * should be first */ 49 * should be first */
156 157
157 ses.send_kex_first_guess = cli_send_kex_first_guess; 158 ses.send_kex_first_guess = cli_send_kex_first_guess;
158 159
159 } 160 }
160 161
162 static void send_msg_service_request(char* servicename) {
163
164 TRACE(("enter send_msg_service_request: servicename='%s'", servicename))
165
166 CHECKCLEARTOWRITE();
167
168 buf_putbyte(ses.writepayload, SSH_MSG_SERVICE_REQUEST);
169 buf_putstring(ses.writepayload, servicename, strlen(servicename));
170
171 encrypt_packet();
172 TRACE(("leave send_msg_service_request"))
173 }
174
175 static void recv_msg_service_accept(void) {
176 // do nothing, if it failed then the server MUST have disconnected
177 }
178
161 /* This function drives the progress of the session - it initiates KEX, 179 /* This function drives the progress of the session - it initiates KEX,
162 * service, userauth and channel requests */ 180 * service, userauth and channel requests */
163 static void cli_sessionloop() { 181 static void cli_sessionloop() {
164 182
165 TRACE(("enter cli_sessionloop")) 183 TRACE2(("enter cli_sessionloop"))
166 184
167 if (ses.lastpacket == SSH_MSG_KEXINIT && cli_ses.kex_state == KEX_NOTHING) { 185 if (ses.lastpacket == SSH_MSG_KEXINIT && cli_ses.kex_state == KEX_NOTHING) {
168 /* We initiate the KEXDH. If DH wasn't the correct type, the KEXINIT 186 /* We initiate the KEXDH. If DH wasn't the correct type, the KEXINIT
169 * negotiation would have failed. */ 187 * negotiation would have failed. */
170 if (!ses.kexstate.our_first_follows_matches) { 188 if (!ses.kexstate.our_first_follows_matches) {
199 217
200 case STATE_NOTHING: 218 case STATE_NOTHING:
201 /* We've got the transport layer sorted, we now need to request 219 /* We've got the transport layer sorted, we now need to request
202 * userauth */ 220 * userauth */
203 send_msg_service_request(SSH_SERVICE_USERAUTH); 221 send_msg_service_request(SSH_SERVICE_USERAUTH);
204 cli_ses.state = SERVICE_AUTH_REQ_SENT;
205 TRACE(("leave cli_sessionloop: sent userauth service req"))
206 return;
207
208 /* userauth code */
209 case SERVICE_AUTH_ACCEPT_RCVD:
210 cli_auth_getmethods(); 222 cli_auth_getmethods();
211 cli_ses.state = USERAUTH_REQ_SENT; 223 cli_ses.state = USERAUTH_REQ_SENT;
212 TRACE(("leave cli_sessionloop: sent userauth methods req")) 224 TRACE(("leave cli_sessionloop: sent userauth methods req"))
213 return; 225 return;
214 226
278 290
279 default: 291 default:
280 break; 292 break;
281 } 293 }
282 294
283 TRACE(("leave cli_sessionloop: fell out")) 295 TRACE2(("leave cli_sessionloop: fell out"))
284 296
285 } 297 }
286 298
287 void cli_session_cleanup() { 299 void cli_session_cleanup() {
288 300