comparison cli-service.c @ 33:f789045062e6

Progressing client support
author Matt Johnston <matt@ucc.asn.au>
date Tue, 27 Jul 2004 16:30:46 +0000
parents
children e2a1eaa19f22
comparison
equal deleted inserted replaced
32:8fd0cdbb5b1b 33:f789045062e6
1 #include "includes.h"
2 #include "service.h"
3 #include "dbutil.h"
4 #include "packet.h"
5 #include "buffer.h"
6 #include "session.h"
7 #include "ssh.h"
8
9 void send_msg_service_request(char* servicename) {
10
11 TRACE(("enter send_msg_service_request: servicename='%s'", servicename));
12
13 CHECKCLEARTOWRITE();
14
15 buf_putbyte(ses.payload, SSH_MSG_SERVICE_REQUEST);
16 buf_putstring(ses.payload, servicename, strlen(servicename));
17
18 encrypt_packet();
19 TRACE(("leave send_msg_service_request"));
20 }
21
22 /* This just sets up the state variables right for the main client session loop
23 * to deal with */
24 void recv_msg_service_accept() {
25
26 unsigned char* servicename;
27 unsigned int len;
28
29 TRACE(("enter recv_msg_service_accept"));
30
31 servicename = buf_getstring(ses.payload, &len);
32
33 /* ssh-userauth */
34 if (cli_ses.state = SERVICE_AUTH_REQ_SENT
35 && len == SSH_SERVICE_USERAUTH_LEN
36 && strncmp(SSH_SERVICE_USERAUTH, servicename, len) == 0) {
37
38 cli_ses.state = SERVICE_AUTH_ACCEPT_RCVD;
39 m_free(servicename);
40 TRACE(("leave recv_msg_service_accept: done ssh-userauth"));
41 return;
42 }
43
44 /* ssh-connection */
45 if (cli_ses.state = SERVICE_CONN_REQ_SENT
46 && len == SSH_SERVICE_CONNECTION_LEN
47 && strncmp(SSH_SERVICE_CONNECTION, servicename, len) == 0) {
48
49 if (ses.authstate.authdone != 1) {
50 dropbear_exit("request for connection before auth");
51 }
52
53 cli_ses.state = SERVICE_CONN_ACCEPT_RCVD;
54 m_free(servicename);
55 TRACE(("leave recv_msg_service_accept: done ssh-connection"));
56 return;
57 }
58
59 dropbear_exit("unrecognised service accept");
60 /* m_free(servicename); not reached */
61
62 }