| 76 |
// channel data structure |
// channel data structure |
| 77 |
#define CHANNEL_MAX 100 |
#define CHANNEL_MAX 100 |
| 78 |
|
|
|
enum scp_state { |
|
|
SCP_INIT, SCP_TIMESTAMP, SCP_FILEINFO, SCP_DATA, SCP_CLOSING, |
|
|
}; |
|
|
|
|
|
typedef struct bufchain { |
|
|
buffer_t *msg; |
|
|
struct bufchain *next; |
|
|
} bufchain_t; |
|
|
|
|
|
typedef struct scp { |
|
|
enum scp_dir dir; // transfer direction |
|
|
enum scp_state state; // SCP state |
|
|
char localfile[MAX_PATH]; // local filename |
|
|
char localfilefull[MAX_PATH]; // local filename fullpath |
|
|
char remotefile[MAX_PATH]; // remote filename |
|
|
FILE *localfp; // file pointer for local file |
|
|
struct __stat64 filestat; // file status information |
|
|
HWND progress_window; |
|
|
HANDLE thread; |
|
|
unsigned int thread_id; |
|
|
PTInstVar pvar; |
|
|
// for receiving file |
|
|
long long filetotalsize; |
|
|
long long filercvsize; |
|
|
} scp_t; |
|
|
|
|
|
typedef struct channel { |
|
|
int used; |
|
|
int self_id; |
|
|
int remote_id; |
|
|
unsigned int local_window; |
|
|
unsigned int local_window_max; |
|
|
unsigned int local_consumed; |
|
|
unsigned int local_maxpacket; |
|
|
unsigned int remote_window; |
|
|
unsigned int remote_maxpacket; |
|
|
enum channel_type type; |
|
|
int local_num; |
|
|
bufchain_t *bufchain; |
|
|
scp_t scp; |
|
|
buffer_t *agent_msg; |
|
|
int agent_request_len; |
|
|
} Channel_t; |
|
| 79 |
|
|
| 80 |
static Channel_t channels[CHANNEL_MAX]; |
static Channel_t channels[CHANNEL_MAX]; |
| 81 |
|
|
| 116 |
void SSH2_dispatch_add_range_message(unsigned char begin, unsigned char end); |
void SSH2_dispatch_add_range_message(unsigned char begin, unsigned char end); |
| 117 |
int dh_pub_is_valid(DH *dh, BIGNUM *dh_pub); |
int dh_pub_is_valid(DH *dh, BIGNUM *dh_pub); |
| 118 |
static void start_ssh_heartbeat_thread(PTInstVar pvar); |
static void start_ssh_heartbeat_thread(PTInstVar pvar); |
|
static void SSH2_send_channel_data(PTInstVar pvar, Channel_t *c, unsigned char FAR * buf, unsigned int buflen); |
|
| 119 |
void ssh2_channel_send_close(PTInstVar pvar, Channel_t *c); |
void ssh2_channel_send_close(PTInstVar pvar, Channel_t *c); |
| 120 |
static BOOL SSH_agent_response(PTInstVar pvar, Channel_t *c, int local_channel_num, unsigned char *data, unsigned int buflen); |
static BOOL SSH_agent_response(PTInstVar pvar, Channel_t *c, int local_channel_num, unsigned char *data, unsigned int buflen); |
| 121 |
|
|
| 665 |
} |
} |
| 666 |
} |
} |
| 667 |
|
|
|
#define get_payload_uint32(pvar, offset) get_uint32_MSBfirst((pvar)->ssh_state.payload + (offset)) |
|
|
#define get_uint32(buf) get_uint32_MSBfirst((buf)) |
|
|
#define set_uint32(buf, v) set_uint32_MSBfirst((buf), (v)) |
|
|
#define get_mpint_len(pvar, offset) ((get_ushort16_MSBfirst((pvar)->ssh_state.payload + (offset)) + 7) >> 3) |
|
|
#define get_ushort16(buf) get_ushort16_MSBfirst((buf)) |
|
|
|
|
| 668 |
#define do_crc(buf, len) (~(uint32)crc32(0xFFFFFFFF, (buf), (len))) |
#define do_crc(buf, len) (~(uint32)crc32(0xFFFFFFFF, (buf), (len))) |
| 669 |
|
|
| 670 |
/* Decrypt the payload, checksum it, eat the padding, get the packet type |
/* Decrypt the payload, checksum it, eat the padding, get the packet type |
| 796 |
or for the packet type byte). |
or for the packet type byte). |
| 797 |
Returns a pointer to the payload data area, a region of length 'len', |
Returns a pointer to the payload data area, a region of length 'len', |
| 798 |
to be filled by the caller. */ |
to be filled by the caller. */ |
| 799 |
static unsigned char FAR *begin_send_packet(PTInstVar pvar, int type, int len) |
unsigned char FAR *begin_send_packet(PTInstVar pvar, int type, int len) |
| 800 |
{ |
{ |
| 801 |
unsigned char FAR *buf; |
unsigned char FAR *buf; |
| 802 |
|
|
| 822 |
return buf + 1; |
return buf + 1; |
| 823 |
} |
} |
| 824 |
|
|
|
#define finish_send_packet(pvar) finish_send_packet_special((pvar), 0) |
|
| 825 |
|
|
| 826 |
// 送信リトライ関数の追加 |
// 送信リトライ関数の追加 |
| 827 |
// |
// |
| 922 |
|
|
| 923 |
/* if skip_compress is true, then the data has already been compressed |
/* if skip_compress is true, then the data has already been compressed |
| 924 |
into outbuf + 12 */ |
into outbuf + 12 */ |
| 925 |
static void finish_send_packet_special(PTInstVar pvar, int skip_compress) |
void finish_send_packet_special(PTInstVar pvar, int skip_compress) |
| 926 |
{ |
{ |
| 927 |
unsigned int len = pvar->ssh_state.outgoing_packet_len; |
unsigned int len = pvar->ssh_state.outgoing_packet_len; |
| 928 |
unsigned char FAR *data; |
unsigned char FAR *data; |
| 3218 |
|
|
| 3219 |
} |
} |
| 3220 |
|
|
| 3221 |
static void SSH2_send_channel_data(PTInstVar pvar, Channel_t *c, unsigned char FAR * buf, unsigned int buflen) |
void SSH2_send_channel_data(PTInstVar pvar, Channel_t *c, unsigned char FAR * buf, unsigned int buflen) |
| 3222 |
{ |
{ |
| 3223 |
buffer_t *msg; |
buffer_t *msg; |
| 3224 |
unsigned char *outmsg; |
unsigned char *outmsg; |
| 7252 |
char ch = '\0'; |
char ch = '\0'; |
| 7253 |
SSH2_send_channel_data(pvar, c, &ch, 1); |
SSH2_send_channel_data(pvar, c, &ch, 1); |
| 7254 |
} |
} |
| 7255 |
|
|
| 7256 |
|
} else if (c->type == TYPE_SFTP) { |
| 7257 |
|
// SFTPセッションを開始するためのネゴシエーションを行う。 |
| 7258 |
|
// (2012.5.3 yutaka) |
| 7259 |
|
sftp_do_init(pvar, c); |
| 7260 |
|
|
| 7261 |
} |
} |
| 7262 |
|
|
| 7263 |
return TRUE; |
return TRUE; |
| 8081 |
SSH2_scp_response(pvar, c, data, str_len); |
SSH2_scp_response(pvar, c, data, str_len); |
| 8082 |
|
|
| 8083 |
} else if (c->type == TYPE_SFTP) { // SFTP |
} else if (c->type == TYPE_SFTP) { // SFTP |
| 8084 |
|
sftp_response(pvar, c, data, str_len); |
| 8085 |
|
|
| 8086 |
} else if (c->type == TYPE_AGENT) { // agent forward |
} else if (c->type == TYPE_AGENT) { // agent forward |
| 8087 |
if (!SSH_agent_response(pvar, c, 0, data, str_len)) { |
if (!SSH_agent_response(pvar, c, 0, data, str_len)) { |