comparison session.h @ 4:fe6bca95afa7

Makefile.in contains updated files required
author Matt Johnston <matt@ucc.asn.au>
date Tue, 01 Jun 2004 02:46:09 +0000
parents
children bc6477a6c393
comparison
equal deleted inserted replaced
-1:000000000000 4:fe6bca95afa7
1 /*
2 * Dropbear - a SSH2 server
3 *
4 * Copyright (c) 2002,2003 Matt Johnston
5 * All rights reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE. */
24
25 #ifndef _SESSION_H_
26 #define _SESSION_H_
27
28 #include "includes.h"
29 #include "buffer.h"
30 #include "signkey.h"
31 #include "kex.h"
32 #include "auth.h"
33 #include "channel.h"
34 #include "queue.h"
35 #include "runopts.h"
36 #include "remotetcpfwd.h"
37
38 extern int sessinitdone; /* Is set to 0 somewhere */
39 extern int exitflag;
40
41 void common_session_init(int sock, runopts *opts);
42 void common_session_cleanup();
43 void checktimeouts();
44 void session_identification();
45
46 extern void(*session_remoteclosed)();
47
48 /* Server */
49 void svr_session(int sock, runopts *opts, int childpipe,
50 struct sockaddr *remoteaddr);
51
52 struct key_context {
53
54 const struct dropbear_cipher *recv_algo_crypt; /* NULL for none */
55 const struct dropbear_cipher *trans_algo_crypt; /* NULL for none */
56 const struct dropbear_hash *recv_algo_mac; /* NULL for none */
57 const struct dropbear_hash *trans_algo_mac; /* NULL for none */
58 char algo_kex;
59 char algo_hostkey;
60
61 char recv_algo_comp; /* compression */
62 char trans_algo_comp;
63 #ifndef DISABLE_ZLIB
64 z_streamp recv_zstream;
65 z_streamp trans_zstream;
66 #endif
67
68 /* actual keys */
69 symmetric_CBC recv_symmetric_struct;
70 symmetric_CBC trans_symmetric_struct;
71 unsigned char recvmackey[MAX_MAC_KEY];
72 unsigned char transmackey[MAX_MAC_KEY];
73
74 };
75
76 struct sshsession {
77
78 /* Is it a client or server? */
79 unsigned char isserver;
80
81 runopts * opts; /* runtime options, incl hostkey, banner etc */
82
83 long connecttimeout; /* time to disconnect if we have a timeout (for
84 userauth etc), or 0 for no timeout */
85
86 int sock;
87
88 struct sockaddr *remoteaddr;
89 unsigned char *remotehost; /* the peer hostname */
90 unsigned char *remoteident;
91
92 int maxfd; /* the maximum file descriptor to check with select() */
93
94
95 /* Packet buffers/values etc */
96 buffer *writepayload; /* Unencrypted payload to write - this is used
97 throughout the code, as handlers fill out this
98 buffer with the packet to send. */
99 struct Queue writequeue; /* A queue of encrypted packets to send */
100 buffer *readbuf; /* Encrypted */
101 buffer *decryptreadbuf; /* Post-decryption */
102 buffer *payload; /* Post-decompression, the actual SSH packet */
103 unsigned int transseq, recvseq; /* Sequence IDs */
104
105 /* Packet-handling flags */
106 unsigned dataallowed : 1; /* whether we can send data packets or we are in
107 the middle of a KEX or something */
108
109 unsigned char expecting; /* byte indicating what packet we expect next,
110 or 0x00 for any */
111
112 unsigned char ignorenext; /* whether to ignore the next packet,
113 used for kex_follows stuff */
114
115
116
117 /* KEX/encryption related */
118 struct KEXState kexstate;
119 struct key_context *keys;
120 struct key_context *newkeys;
121 unsigned char *session_id; /* this is the hash from the first kex */
122 /* The below are used temorarily during kex, are freed after use */
123 mp_int * dh_K; /* SSH_MSG_KEXDH_REPLY and sending SSH_MSH_NEWKEYS */
124 unsigned char hash[SHA1_HASH_SIZE]; /* the hash*/
125 buffer* kexhashbuf; /* session hash buffer calculated from various packets*/
126 buffer* transkexinit; /* the kexinit packet we send should be kept so we
127 can add it to the hash when generating keys */
128
129
130
131 /* Channel related */
132 struct Channel ** channels; /* these pointers may be null */
133 unsigned int chansize; /* the number of Channel*s allocated for channels */
134 struct ChanType **chantypes; /* The valid channel types */
135
136
137 /* TCP forwarding - where manage listeners */
138 #ifndef DISABLE_REMOTETCPFWD
139 struct TCPListener ** tcplisteners;
140 unsigned int tcplistensize;
141 #endif
142
143 };
144
145 struct serversession {
146
147 /* Server specific options */
148 int childpipe; /* kept open until we successfully authenticate */
149 /* userauth */
150 struct AuthState authstate;
151
152 struct ChildPid * childpids; /* array of mappings childpid<->channel */
153 unsigned int childpidsize;
154
155 };
156
157
158
159 struct clientsession {
160
161 int something; /* XXX */
162
163 };
164
165 /* Global structs storing the state */
166 extern struct sshsession ses;
167
168 #ifdef DROPBEAR_SERVER
169 extern struct serversession svr_ses;
170 #endif /* DROPBEAR_SERVER */
171
172 #ifdef DROPBEAR_CLIENT
173 extern struct serversession cli_ses;
174 #endif /* DROPBEAR_CLIENT */
175
176 #endif /* _SESSION_H_ */