Develop and Download Open Source Software

Browse Subversion Repository

Contents of /branches/ssh_chacha20poly1305/ttssh2/ttxssh/ttxssh.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2748 - (show annotations) (download) (as text)
Sat Dec 11 07:31:00 2004 UTC (19 years, 4 months ago) by yutakakn
Original Path: ttssh2/trunk/ttxssh/ttxssh.h
File MIME type: text/x-chdr
File size: 6980 byte(s)
SSH heartbeatスレッドの追加した。これにより、IPマスカレード環境において、ルータの
NATテーブルクリアにより、SSHコネクションが切断される現象が回避される。
それに合わせて、teraterm.iniのTTSSHセクションに、HeartBeat エントリを追加。

1 /*
2 Copyright (c) 1998-2001, Robert O'Callahan
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7
8 Redistributions of source code must retain the above copyright notice, this list of
9 conditions and the following disclaimer.
10
11 Redistributions in binary form must reproduce the above copyright notice, this list
12 of conditions and the following disclaimer in the documentation and/or other materials
13 provided with the distribution.
14
15 The name of Robert O'Callahan may not be used to endorse or promote products derived from
16 this software without specific prior written permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 /*
30 This code is copyright (C) 1998-1999 Robert O'Callahan.
31 See LICENSE.TXT for the license.
32 */
33
34 #ifndef __TTXSSH_H
35 #define __TTXSSH_H
36
37 #pragma warning(3 : 4035)
38
39 #ifdef INET6
40 #include <winsock2.h>
41 #include <ws2tcpip.h>
42 /* actual body of in6addr_any and in6addr_loopback is disappeared?? */
43 #undef IN6_IS_ADDR_LOOPBACK
44 #define IN6_IS_ADDR_LOOPBACK(a) \
45 ((*(unsigned int *)(&(a)->s6_addr[0]) == 0) && \
46 (*(unsigned int *)(&(a)->s6_addr[4]) == 0) && \
47 (*(unsigned int *)(&(a)->s6_addr[8]) == 0) && \
48 (*(unsigned int *)(&(a)->s6_addr[12]) == ntohl(1)))
49 /* work around for MS Platform SDK Oct 2000 */
50 #include <malloc.h> /* prevent of conflict stdlib.h */
51 #endif /* INET6 */
52 #include <stdlib.h>
53 #include <crtdbg.h>
54
55 #include "teraterm.h"
56 #include "tttypes.h"
57 #include "ttplugin.h"
58
59 typedef struct _TInstVar FAR * PTInstVar;
60
61 #include "util.h"
62 #include "pkt.h"
63 #include "ssh.h"
64 #include "auth.h"
65 #include "crypt.h"
66 #include "hosts.h"
67 #include "fwd.h"
68
69 #include <openssl/dh.h>
70 #include <openssl/evp.h>
71 #include "buffer.h"
72
73 HANDLE hInst; /* Instance handle of TTXSSH.DLL */
74
75 #define ID_ABOUTMENU 62501
76 #define ID_SSHAUTH 62502
77 #define ID_SSHSETUPMENU 62503
78 #define ID_SSHUNKNOWNHOST 62504
79 #define ID_SSHDIFFERENTHOST 62505
80 #define ID_SSHAUTHSETUPMENU 62506
81 #define ID_SSHASYNCMESSAGEBOX 62507
82 #define ID_SSHFWDSETUPMENU 62508
83
84 /*
85 These are the fields that WOULD go in Teraterm's 'ts' structure, if
86 we could put them there.
87 */
88 typedef struct _TS_SSH {
89 BOOL Enabled;
90 int CompressionLevel; /* 0 = NONE, else 1-9 */
91 char DefaultUserName[256];
92
93 /* this next option is a string of digits. Each digit represents a
94 cipher. The first digit is the most preferred cipher, and so on.
95 The digit SSH_CIPHER_NONE signifies that any ciphers after it are
96 disabled. */
97 char CipherOrder[16];
98
99 char KnownHostsFiles[2048];
100 int DefaultAuthMethod;
101 char DefaultRhostsLocalUserName[256];
102 char DefaultRhostsHostPrivateKeyFile[1024];
103 char DefaultRSAPrivateKeyFile[1024];
104
105 char DefaultForwarding[2048];
106 BOOL TryDefaultAuth;
107
108 int LogLevel; /* 0 = NONE, 100 = Verbose */
109 int WriteBufferSize;
110 int LocalForwardingIdentityCheck;
111
112 int ssh_protocol_version; // SSH version (2004.10.11 yutaka)
113 int ssh_heartbeat_overtime; // SSH heartbeat(keepalive) (2004.12.11 yutaka)
114 } TS_SSH;
115
116 typedef struct _TInstVar {
117 PTTSet ts;
118 PComVar cv;
119
120 /* shared memory for settings across instances. Basically it's
121 a cache for the INI file.*/
122 TS_SSH FAR * ts_SSH;
123
124 int fatal_error;
125 int showing_err;
126 char FAR * err_msg;
127
128 Tconnect Pconnect;
129 Trecv Precv;
130 Tsend Psend;
131 TWSAAsyncSelect PWSAAsyncSelect;
132 TWSAGetLastError PWSAGetLastError;
133
134 PReadIniFile ReadIniFile;
135 PWriteIniFile WriteIniFile;
136 PParseParam ParseParam;
137
138 SOCKET socket;
139 HWND NotificationWindow;
140 unsigned int notification_msg;
141 long notification_events;
142 HICON OldSmallIcon;
143 HICON OldLargeIcon;
144
145 BOOL hostdlg_activated;
146 BOOL hostdlg_Enabled;
147
148 int protocol_major;
149 int protocol_minor;
150
151 PKTState pkt_state;
152 SSHState ssh_state;
153 AUTHState auth_state;
154 CRYPTState crypt_state;
155 HOSTSState hosts_state;
156 FWDState fwd_state;
157
158 /* The settings applied to the current session. The user may change
159 the settings but usually we don't want that to affect the session
160 in progress (race conditions). So user setup changes usually
161 modify the 'settings' field below. */
162 TS_SSH session_settings;
163
164 /* our copy of the global settings. This is synced up with the shared
165 memory only when we do a ReadIniFile or WriteIniFile
166 (i.e. the user loads or saves setup) */
167 TS_SSH settings;
168
169 // SSH2
170 DH *kexdh;
171 char server_version_string[128];
172 char client_version_string[128];
173 buffer_t *my_kex;
174 buffer_t *peer_kex;
175 enum kex_exchange kex_type; // KEX algorithm
176 enum hostkey_type hostkey_type;
177 SSHCipher ctos_cipher;
178 SSHCipher stoc_cipher;
179 int we_need;
180 int key_done;
181 int rekeying;
182 char *session_id;
183 int session_id_len;
184 Newkeys ssh2_keys[MODE_MAX];
185 EVP_CIPHER_CTX evpcip[MODE_MAX];
186 int userauth_success;
187 int remote_id;
188 int session_nego_status;
189 unsigned int local_window;
190 unsigned int local_window_max;
191 unsigned int local_consumed;
192 unsigned int local_maxpacket;
193 unsigned int remote_window;
194 unsigned int remote_maxpacket;
195 int client_key_bits;
196 int server_key_bits;
197 int kexgex_min;
198 int kexgex_bits;
199 int kexgex_max;
200 int ssh2_autologin;
201 char ssh2_username[MAX_PATH];
202 char ssh2_password[MAX_PATH];
203 time_t ssh_heartbeat_tick;
204
205 } TInstVar;
206
207 #define LOG_LEVEL_FATAL 5
208 #define LOG_LEVEL_ERROR 10
209 #define LOG_LEVEL_URGENT 20
210 #define LOG_LEVEL_WARNING 30
211 #define LOG_LEVEL_VERBOSE 100
212
213 #define SSHv1(pvar) ((pvar)->protocol_major == 1)
214 #define SSHv2(pvar) ((pvar)->protocol_major == 2)
215
216 void notify_established_secure_connection(PTInstVar pvar);
217 void notify_closed_connection(PTInstVar pvar);
218 void notify_nonfatal_error(PTInstVar pvar, char FAR * msg);
219 void notify_fatal_error(PTInstVar pvar, char FAR * msg);
220 void notify_verbose_message(PTInstVar pvar, char FAR * msg, int level);
221
222 void get_teraterm_dir_relative_name(char FAR * buf, int bufsize, char FAR * basename);
223 int copy_teraterm_dir_relative_path(char FAR * dest, int destsize, char FAR * basename);
224
225 #endif
226
227 /*
228 * $Log: not supported by cvs2svn $
229 * Revision 1.2 2004/12/01 15:37:49 yutakakn
230 * SSH2�������O�C���@�\�������B
231 * �����A�p�X���[�h�F�������������B
232 * �E�R�}���h���C��
233 * /ssh /auth=�F�����\�b�h /user=���[�U�� /passwd=�p�X���[�h
234 *
235 */

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26