Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/ttssh2/ttxssh/ttxssh.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10960 - (hide annotations) (download) (as text)
Sat Oct 7 17:40:35 2023 UTC (6 months ago) by zmatsuo
File MIME type: text/x-chdr
File size: 12146 byte(s)
SCP受信時、受信したデータが随時書き込まれない場合があるので修正

- SCP 受信したデータが随時書き込まれない (GitHub #15)

Ticket #34056
1 maya 3227 /*
2 doda 6841 * Copyright (c) 1998-2001, Robert O'Callahan
3 nmaya 9048 * (C) 2004- TeraTerm Project
4 doda 6841 * All rights reserved.
5     *
6     * Redistribution and use in source and binary forms, with or without
7     * modification, are permitted provided that the following conditions
8     * are met:
9     *
10     * 1. Redistributions of source code must retain the above copyright
11     * notice, this list of conditions and the following disclaimer.
12     * 2. Redistributions in binary form must reproduce the above copyright
13     * notice, this list of conditions and the following disclaimer in the
14     * documentation and/or other materials provided with the distribution.
15     * 3. The name of the author may not be used to endorse or promote products
16     * derived from this software without specific prior written permission.
17     *
18     * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
19     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21     * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23     * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28     */
29 maya 3227
30     /*
31     This code is copyright (C) 1998-1999 Robert O'Callahan.
32     See LICENSE.TXT for the license.
33     */
34    
35     #ifndef __TTXSSH_H
36     #define __TTXSSH_H
37    
38     #pragma warning(3 : 4035)
39    
40 yutakapon 6286 /* VS2015(VC14.0)�����AWSASocketA(), inet_ntoa() ������API��deprecated��������
41     * �x�������������A�x�����}�~�����B�����������u���������AVS2005(VC8.0)���r���h
42     * �����������������A�x�����}�~���������������B
43     */
44     #if _MSC_VER >= 1800 // VSC2013(VC12.0) or later
45     #ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
46     #define _WINSOCK_DEPRECATED_NO_WARNINGS
47     #endif
48     #endif
49    
50 maya 3227 #include <winsock2.h>
51     #include <ws2tcpip.h>
52 zmatsuo 7479 #include <wspiapi.h>
53 maya 3227 /* actual body of in6addr_any and in6addr_loopback is disappeared?? */
54     #undef IN6_IS_ADDR_LOOPBACK
55     #define IN6_IS_ADDR_LOOPBACK(a) \
56     ((*(unsigned int *)(&(a)->s6_addr[0]) == 0) && \
57     (*(unsigned int *)(&(a)->s6_addr[4]) == 0) && \
58     (*(unsigned int *)(&(a)->s6_addr[8]) == 0) && \
59     (*(unsigned int *)(&(a)->s6_addr[12]) == ntohl(1)))
60     /* work around for MS Platform SDK Oct 2000 */
61     #include <malloc.h> /* prevent of conflict stdlib.h */
62     #include <stdlib.h>
63 doda 6051 #include <stdarg.h>
64 maya 3227 #include <crtdbg.h>
65    
66     #include "i18n.h"
67 maya 3295 #include "ttlib.h"
68 maya 3227
69 doda 6801 typedef struct _TInstVar *PTInstVar;
70 maya 3227
71 doda 6834 #include "ttxssh-version.h"
72 maya 3227 #include "util.h"
73     #include "pkt.h"
74     #include "ssh.h"
75     #include "auth.h"
76     #include "crypt.h"
77 nmaya 9255 #include "cipher.h"
78     #include "comp.h"
79     #include "kex.h"
80     #include "hostkey.h"
81     #include "key.h"
82 maya 3227 #include "hosts.h"
83     #include "fwd.h"
84    
85     #include <openssl/dh.h>
86 maya 4314 #include <openssl/ec.h>
87 maya 3227 #include <openssl/evp.h>
88     #include "buffer.h"
89    
90     /* tttypes.h �����`���������� EM �}�N���� openssl/rsa.h (OpenSSL 0.9.8)�������v���g�^�C�v������
91     * �������������d�����������������A�r���h�G���[�������B���L3�w�b�_��include���u�����L�����������B
92     * (2005.7.9 yutaka)
93     */
94     #include "teraterm.h"
95     #include "tttypes.h"
96     #include "ttplugin.h"
97    
98 maya 7773 #if defined(_MSC_VER) && !defined(_Printf_format_string_)
99     // ���`�������������������������������������`��������
100 zmatsuo 7648 #define _Printf_format_string_
101     #endif
102    
103 zmatsuo 8837 extern HANDLE hInst; /* Instance handle of TTXSSH.DLL */
104 maya 3227
105     #define ID_SSHSCPMENU 52110
106     #define ID_SSHSETUPMENU 52310
107     #define ID_SSHAUTHSETUPMENU 52320
108     #define ID_SSHFWDSETUPMENU 52330
109     #define ID_SSHKEYGENMENU 52340
110     #define ID_ABOUTMENU 52910
111    
112     #define ID_SSHAUTH 62501
113     #define ID_SSHUNKNOWNHOST 62502
114 maya 4330 #define ID_SSHDIFFERENTKEY 62503
115 maya 3227 #define ID_SSHASYNCMESSAGEBOX 62504
116 yutakapon 8093 #define ID_SSHDIFFERENT_TYPE_KEY 62505
117 maya 3227
118     #define OPTION_NONE 0
119     #define OPTION_CLEAR 1
120     #define OPTION_REPLACE 2
121    
122     /*
123 yutakapon 5620 * DisablePopupMessage �p���r�b�g���`
124     */
125     #define POPUP_MSG_default 0
126     #define POPUP_MSG_FWD_received_data (1 << 0)
127 nmaya 10576 #define POPUP_MSG_FWD_channel_open (1 << 1)
128 yutakapon 5620
129 yutakapon 5849
130 yutakapon 5620 /*
131 zmatsuo 9429 * Host key rotation
132 yutakapon 5849 */
133 doda 5887 #define SSH_UPDATE_HOSTKEYS_NO 0
134     #define SSH_UPDATE_HOSTKEYS_YES 1
135     #define SSH_UPDATE_HOSTKEYS_ASK 2
136 yutakapon 5901 #define SSH_UPDATE_HOSTKEYS_MAX 3
137 yutakapon 5849
138 doda 5928 /*
139     * Server compatibility flag
140     */
141     #define SSH_BUG_DHGEX_LARGE 0x00000001
142 yutakapon 5849
143 doda 5928
144 yutakapon 5849 /*
145 maya 3227 These are the fields that WOULD go in Tera Term's 'ts' structure, if
146     we could put them there.
147     */
148     typedef struct _TS_SSH {
149     BOOL Enabled;
150     int CompressionLevel; /* 0 = NONE, else 1-9 */
151 zmatsuo 7632
152     int DefaultUserType; /* 0/1/2 = no input/DefaultUserName/Windows logon user */
153 maya 3227 char DefaultUserName[256];
154    
155     /* this next option is a string of digits. Each digit represents a
156     cipher. The first digit is the most preferred cipher, and so on.
157     The digit SSH_CIPHER_NONE signifies that any ciphers after it are
158     disabled. */
159 doda 7455 char CipherOrder[SSH_CIPHER_MAX+2];
160 maya 3227
161     char KnownHostsFiles[2048];
162     int DefaultAuthMethod;
163     char DefaultRhostsLocalUserName[256];
164     char DefaultRhostsHostPrivateKeyFile[1024];
165     char DefaultRSAPrivateKeyFile[1024];
166    
167 doda 6831 char DefaultForwarding[4096];
168 maya 3227 BOOL TryDefaultAuth;
169    
170     int LogLevel; /* 0 = NONE, 100 = Verbose */
171     int WriteBufferSize;
172    
173     int ssh_protocol_version; // SSH version (2004.10.11 yutaka)
174     int ssh_heartbeat_overtime; // SSH heartbeat(keepalive) (2004.12.11 yutaka)
175     // whether password will permanently store on heap memory (2006.8.5 yutaka)
176     int remember_password;
177    
178     // try auth with "none" method for disable unsupported on dialog (2007.9.24 maya)
179     BOOL CheckAuthListFirst;
180    
181     // Enable connection to the server that has RSA key length less than 768 bit (2008.9.11 maya)
182     BOOL EnableRsaShortKeyServer;
183    
184     // Enable Agent forwarding
185     BOOL ForwardAgent;
186 maya 4229
187     // Confirm Agent forwarding
188     BOOL ForwardAgentConfirm;
189 yutakapon 4367
190 doda 6663 // Confirm Agent forwarding
191     BOOL ForwardAgentNotify;
192    
193 yutakapon 4367 // KEX order(derived from teraterm.ini)
194     char KexOrder[KEX_DH_MAX+1];
195 doda 10064 char HostKeyOrder[KEY_ALGO_MAX+1];
196 yutakapon 4367 char MacOrder[HMAC_MAX+1];
197     char CompOrder[COMP_MAX+1];
198 doda 4531
199     BOOL VerifyHostKeyDNS;
200 doda 5261
201     int IconID;
202 yutakapon 5620
203     int DisablePopupMessage;
204 doda 5793
205     char X11Display[128];
206 yutakapon 5839
207 yutakapon 5901 int UpdateHostkeys;
208 doda 5900
209     int GexMinimalGroupSize;
210 doda 7048
211     int AuthBanner;
212 doda 10247
213     BOOL KexKeyLogging;
214 doda 10254 wchar_t KexKeyLogFile[1024];
215 nmaya 10509
216     // Sign algorithm order
217     // for publickey authentication (not for server hostkey)
218     // for RSA key only
219     char RSAPubkeySignAlgorithmOrder[RSA_PUBKEY_SIGN_ALGO_MAX+1];
220 maya 3227 } TS_SSH;
221    
222     typedef struct _TInstVar {
223     PTTSet ts;
224     PComVar cv;
225    
226     /* shared memory for settings across instances. Basically it's
227     a cache for the INI file.*/
228 doda 6801 TS_SSH *ts_SSH;
229 maya 3227
230     int fatal_error;
231     int showing_err;
232 doda 6801 char *err_msg;
233 maya 3227
234     Tconnect Pconnect;
235     Trecv Precv;
236     Tsend Psend;
237     TWSAAsyncSelect PWSAAsyncSelect;
238     TWSAGetLastError PWSAGetLastError;
239    
240     PReadIniFile ReadIniFile;
241     PWriteIniFile WriteIniFile;
242     PParseParam ParseParam;
243    
244 doda 4463 HMENU FileMenu;
245    
246 maya 3227 SOCKET socket;
247     HWND NotificationWindow;
248     unsigned int notification_msg;
249     long notification_events;
250 nmaya 10009 HICON OldSmallIcon; // �g�p������
251     HICON OldLargeIcon; // �g�p������
252 maya 3227
253     BOOL hostdlg_activated;
254     BOOL hostdlg_Enabled;
255    
256     int protocol_major;
257     int protocol_minor;
258    
259     PKTState pkt_state;
260     SSHState ssh_state;
261     AUTHState auth_state;
262     CRYPTState crypt_state;
263     HOSTSState hosts_state;
264     FWDState fwd_state;
265    
266     /* The settings applied to the current session. The user may change
267     the settings but usually we don't want that to affect the session
268     in progress (race conditions). So user setup changes usually
269     modify the 'settings' field below. */
270     TS_SSH session_settings;
271    
272     /* our copy of the global settings. This is synced up with the shared
273     memory only when we do a ReadIniFile or WriteIniFile
274     (i.e. the user loads or saves setup) */
275     TS_SSH settings;
276    
277     // SSH2
278     DH *kexdh;
279     char server_version_string[128];
280     char client_version_string[128];
281     buffer_t *my_kex;
282     buffer_t *peer_kex;
283 maya 4378 kex_algorithm kex_type; // KEX algorithm
284 doda 10064 ssh_keyalgo hostkey_type;
285 nmaya 9255 const struct ssh2cipher *ciphers[MODE_MAX];
286     const struct SSH2Mac *macs[MODE_MAX];
287 maya 4378 compression_type ctos_compression;
288     compression_type stoc_compression;
289 maya 3227 int we_need;
290 doda 10073 int kex_status;
291 maya 3227 char *session_id;
292     int session_id_len;
293 doda 7001 SSHKeys ssh2_keys[MODE_MAX];
294 nmaya 9255 struct sshcipher_ctx *cc[MODE_MAX];
295 maya 3227 int userauth_success;
296     int shell_id;
297     int session_nego_status;
298     /*
299     unsigned int local_window;
300     unsigned int local_window_max;
301     unsigned int local_consumed;
302     unsigned int local_maxpacket;
303     unsigned int remote_window;
304     unsigned int remote_maxpacket;
305     */
306     int client_key_bits;
307     int server_key_bits;
308     int kexgex_min;
309     int kexgex_bits;
310     int kexgex_max;
311     int ssh2_autologin;
312     int ask4passwd;
313     SSHAuthMethod ssh2_authmethod;
314     char ssh2_username[MAX_PATH];
315     char ssh2_password[MAX_PATH];
316     char ssh2_keyfile[MAX_PATH];
317     time_t ssh_heartbeat_tick;
318     HANDLE ssh_heartbeat_thread;
319     int keyboard_interactive_password_input;
320     int userauth_retry_count;
321     buffer_t *decomp_buffer;
322 doda 7049 buffer_t *authbanner_buffer;
323 maya 3227 char *ssh2_authlist;
324     BOOL tryed_ssh2_authlist;
325     HWND ssh_hearbeat_dialog;
326    
327     /* Pageant �������M�p */
328     unsigned char *pageant_key;
329     unsigned char *pageant_curkey;
330     int pageant_keylistlen;
331     int pageant_keycount;
332     int pageant_keycurrent;
333     BOOL pageant_keyfinal;// SSH2 PK_OK ������������ TRUE ������
334    
335     // agent forward
336     BOOL agentfwd_enable;
337 doda 3579
338     BOOL origDisableTCPEchoCR;
339 yutakapon 3631
340     BOOL nocheck_known_hosts;
341 maya 4314
342     EC_KEY *ecdh_client_key;
343 doda 4559
344     int dns_key_check;
345 doda 5928
346     unsigned int server_compat_flag;
347 yutakapon 5931
348     void *hostkey_ctx;
349 doda 6717
350     BOOL use_subsystem;
351     char subsystem_name[256];
352 doda 7363
353     BOOL nosession;
354 zmatsuo 7714
355     // dialog resource
356     HFONT hFontFixed; // hosts.c�����_�C�A���O�p
357    
358 zmatsuo 10960 struct {
359     BOOL suspended; // SCP���M���t���[�����p,TRUE������������������������
360     //BOOL timer_triggerd;
361     UINT_PTR timer_id;
362     BOOL data_finished; // TRUE������,�f�[�^�����M����������
363     BOOL close_request;
364     } recv;
365    
366 doda 10066 char *server_sig_algs;
367    
368 zmatsuo 10618 char UIMsg[MAX_UIMSG];
369 maya 3227 } TInstVar;
370    
371 doda 6834 // �o�[�W���������������������X�������B ��: TTSSH_2-81_TS_data
372     #define TTSSH_FILEMAPNAME "TTSSH_" TTSSH_VERSION_STR("-") "_TS_data"
373 doda 6830
374 maya 3227 #define LOG_LEVEL_FATAL 5
375     #define LOG_LEVEL_ERROR 10
376     #define LOG_LEVEL_WARNING 30
377 doda 6655 #define LOG_LEVEL_NOTICE 50
378 doda 5927 #define LOG_LEVEL_INFO 80
379 maya 3227 #define LOG_LEVEL_VERBOSE 100
380     #define LOG_LEVEL_SSHDUMP 200
381    
382     #define SSHv1(pvar) ((pvar)->protocol_major == 1)
383     #define SSHv2(pvar) ((pvar)->protocol_major == 2)
384    
385 doda 6823 #define LogLevel(pvar, level) ((pvar)->settings.LogLevel >= (level))
386 doda 6813
387 maya 3227 void notify_established_secure_connection(PTInstVar pvar);
388 doda 6801 void notify_closed_connection(PTInstVar pvar, char *send_msg);
389     void notify_nonfatal_error(PTInstVar pvar, char *msg);
390     void notify_fatal_error(PTInstVar pvar, char *msg, BOOL send_disconnect);
391 doda 6809 void logputs(int level, char *msg);
392 zmatsuo 7648 #if defined(_MSC_VER)
393     void logprintf(int level, _Printf_format_string_ const char *fmt, ...);
394     void logprintf_hexdump(int level, const char *data, int len, _Printf_format_string_ const char *fmt, ...);
395     #elif defined(__GNUC__)
396     void logprintf(int level, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
397     void logprintf_hexdump(int level, const char *data, int len, const char *fmt, ...) __attribute__ ((format (printf, 4, 5)));
398     #else
399     void logprintf(int level, const char *fmt, ...);
400     void logprintf_hexdump(int level, const char *data, int len, const char *fmt, ...);
401     #endif
402 maya 3227
403 doda 6801 void get_teraterm_dir_relative_name(char *buf, int bufsize, char *basename);
404 zmatsuo 9429 wchar_t *get_teraterm_dir_relative_nameW(const wchar_t *basename);
405 doda 6801 int copy_teraterm_dir_relative_path(char *dest, int destsize, char *basename);
406 zmatsuo 9505 wchar_t *get_home_dir_relative_nameW(const wchar_t *basename);
407 nmaya 9707 wchar_t *get_log_dir_relative_nameW(const wchar_t *basename);
408 maya 3227 int uuencode(unsigned char *src, int srclen, unsigned char *target, int targsize);
409    
410     #endif

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