Mercurial > dropbear
comparison svr-session.c @ 22:c1e5d9195402
merge of abac2150ee4f4031a98016241fbd136d24fed127
and ffa047425729e478a5b49b1ab0f8ec71c08a1421
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 23 Jun 2004 07:14:16 +0000 |
parents | 5ae28f6101c1 |
children | 469950e86d0f |
comparison
equal
deleted
inserted
replaced
14:5ae28f6101c1 | 22:c1e5d9195402 |
---|---|
34 #include "kex.h" | 34 #include "kex.h" |
35 #include "channel.h" | 35 #include "channel.h" |
36 #include "chansession.h" | 36 #include "chansession.h" |
37 #include "atomicio.h" | 37 #include "atomicio.h" |
38 #include "tcpfwd-direct.h" | 38 #include "tcpfwd-direct.h" |
39 #include "service.h" | |
40 #include "auth.h" | |
41 #include "tcpfwd-remote.h" | |
39 | 42 |
40 static void svr_remoteclosed(); | 43 static void svr_remoteclosed(); |
41 | 44 |
42 struct serversession svr_ses; | 45 struct serversession svr_ses; |
43 | 46 |
44 const struct ChanType *chantypes[] = { | 47 static const packettype svr_packettypes[] = { |
48 /* TYPE, AUTHREQUIRED, FUNCTION */ | |
49 {SSH_MSG_SERVICE_REQUEST, recv_msg_service_request}, // server | |
50 {SSH_MSG_USERAUTH_REQUEST, recv_msg_userauth_request}, //server | |
51 {SSH_MSG_KEXINIT, recv_msg_kexinit}, | |
52 {SSH_MSG_KEXDH_INIT, recv_msg_kexdh_init}, | |
53 {SSH_MSG_NEWKEYS, recv_msg_newkeys}, | |
54 {SSH_MSG_CHANNEL_DATA, recv_msg_channel_data}, | |
55 {SSH_MSG_CHANNEL_WINDOW_ADJUST, recv_msg_channel_window_adjust}, | |
56 {SSH_MSG_GLOBAL_REQUEST, recv_msg_global_request_remotetcp}, | |
57 {SSH_MSG_CHANNEL_REQUEST, recv_msg_channel_request}, | |
58 {SSH_MSG_CHANNEL_OPEN, recv_msg_channel_open}, | |
59 {SSH_MSG_CHANNEL_EOF, recv_msg_channel_eof}, | |
60 {SSH_MSG_CHANNEL_CLOSE, recv_msg_channel_close}, | |
61 {SSH_MSG_CHANNEL_OPEN_CONFIRMATION, recv_msg_channel_open_confirmation}, | |
62 {SSH_MSG_CHANNEL_OPEN_FAILURE, recv_msg_channel_open_failure}, | |
63 {0, 0} /* End */ | |
64 }; | |
65 | |
66 static const struct ChanType *svr_chantypes[] = { | |
45 &svrchansess, | 67 &svrchansess, |
46 &chan_tcpdirect, | 68 &chan_tcpdirect, |
47 NULL /* Null termination is mandatory. */ | 69 NULL /* Null termination is mandatory. */ |
48 }; | 70 }; |
49 | |
50 | 71 |
51 void svr_session(int sock, runopts *opts, int childpipe, | 72 void svr_session(int sock, runopts *opts, int childpipe, |
52 struct sockaddr* remoteaddr) { | 73 struct sockaddr* remoteaddr) { |
53 | 74 |
54 fd_set readfd, writefd; | 75 fd_set readfd, writefd; |
62 ses.remotehost = getaddrhostname(remoteaddr); | 83 ses.remotehost = getaddrhostname(remoteaddr); |
63 | 84 |
64 /* Initialise server specific parts of the session */ | 85 /* Initialise server specific parts of the session */ |
65 svr_ses.childpipe = childpipe; | 86 svr_ses.childpipe = childpipe; |
66 authinitialise(); | 87 authinitialise(); |
67 chaninitialise(chantypes); | 88 chaninitialise(svr_chantypes); |
68 svr_chansessinitialise(); | 89 svr_chansessinitialise(); |
69 | 90 |
70 if (gettimeofday(&timeout, 0) < 0) { | 91 if (gettimeofday(&timeout, 0) < 0) { |
71 dropbear_exit("Error getting time"); | 92 dropbear_exit("Error getting time"); |
72 } | 93 } |
73 | 94 |
74 ses.connecttimeout = timeout.tv_sec + AUTH_TIMEOUT; | 95 ses.connecttimeout = timeout.tv_sec + AUTH_TIMEOUT; |
75 | 96 |
76 /* set up messages etc */ | 97 /* set up messages etc */ |
77 session_remoteclosed = svr_remoteclosed; | 98 session_remoteclosed = svr_remoteclosed; |
99 | |
100 /* packet handlers */ | |
101 ses.packettypes = svr_packettypes; | |
78 | 102 |
79 /* We're ready to go now */ | 103 /* We're ready to go now */ |
80 sessinitdone = 1; | 104 sessinitdone = 1; |
81 | 105 |
82 /* exchange identification, version etc */ | 106 /* exchange identification, version etc */ |
143 } | 167 } |
144 | 168 |
145 /* Process the decrypted packet. After this, the read buffer | 169 /* Process the decrypted packet. After this, the read buffer |
146 * will be ready for a new packet */ | 170 * will be ready for a new packet */ |
147 if (ses.payload != NULL) { | 171 if (ses.payload != NULL) { |
148 svr_process_packet(); | 172 process_packet(); |
149 } | 173 } |
150 } | 174 } |
151 | 175 |
152 /* process pipes etc for the channels, ses.dataallowed == 0 | 176 /* process pipes etc for the channels, ses.dataallowed == 0 |
153 * during rekeying ) */ | 177 * during rekeying ) */ |