version 1.59, 2001/04/04 23:09:18 |
version 1.60, 2001/04/05 10:39:03 |
|
|
|
|
/* Scratch buffer for packet compression/decompression. */ |
/* Scratch buffer for packet compression/decompression. */ |
static Buffer compression_buffer; |
static Buffer compression_buffer; |
|
static int compression_buffer_ready = 0; |
|
|
/* Flag indicating whether packet compression/decompression is enabled. */ |
/* Flag indicating whether packet compression/decompression is enabled. */ |
static int packet_compression = 0; |
static int packet_compression = 0; |
|
|
buffer_free(&output); |
buffer_free(&output); |
buffer_free(&outgoing_packet); |
buffer_free(&outgoing_packet); |
buffer_free(&incoming_packet); |
buffer_free(&incoming_packet); |
if (packet_compression) { |
if (compression_buffer_ready) { |
buffer_free(&compression_buffer); |
buffer_free(&compression_buffer); |
buffer_compress_uninit(); |
buffer_compress_uninit(); |
} |
} |
|
|
* Level is compression level 1 (fastest) - 9 (slow, best) as in gzip. |
* Level is compression level 1 (fastest) - 9 (slow, best) as in gzip. |
*/ |
*/ |
|
|
/*** XXXXX todo: kex means re-init */ |
|
void |
void |
|
packet_init_compression() |
|
{ |
|
if (compression_buffer_ready == 1) |
|
return; |
|
compression_buffer_ready = 1; |
|
buffer_init(&compression_buffer); |
|
} |
|
|
|
void |
packet_start_compression(int level) |
packet_start_compression(int level) |
{ |
{ |
if (packet_compression) |
if (packet_compression && !use_ssh2_packet_format) |
fatal("Compression already enabled."); |
fatal("Compression already enabled."); |
packet_compression = 1; |
packet_compression = 1; |
buffer_init(&compression_buffer); |
packet_init_compression(); |
buffer_compress_init(level); |
buffer_compress_init_send(level); |
|
buffer_compress_init_recv(); |
} |
} |
|
|
/* |
/* |
|
|
memset(enc->iv, 0, enc->cipher->block_size); |
memset(enc->iv, 0, enc->cipher->block_size); |
memset(enc->key, 0, enc->cipher->key_len); |
memset(enc->key, 0, enc->cipher->key_len); |
if (comp->type != 0 && comp->enabled == 0) { |
if (comp->type != 0 && comp->enabled == 0) { |
|
packet_init_compression(); |
|
if (mode == MODE_OUT) |
|
buffer_compress_init_send(6); |
|
else |
|
buffer_compress_init_recv(); |
comp->enabled = 1; |
comp->enabled = 1; |
if (! packet_compression) |
|
packet_start_compression(6); |
|
} |
} |
} |
} |
|
|