Small fixes to make LZO compression work.
This commit is contained in:
parent
c70f52087b
commit
6ba4e2da55
2 changed files with 17 additions and 12 deletions
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: net_packet.c,v 1.1.2.28 2003/05/06 21:13:17 guus Exp $
|
||||
$Id: net_packet.c,v 1.1.2.29 2003/05/06 23:14:45 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -82,7 +82,7 @@
|
|||
int keylifetime = 0;
|
||||
int keyexpires = 0;
|
||||
EVP_CIPHER_CTX packet_ctx;
|
||||
char lzo_wrkmem[MAXSIZE];
|
||||
char lzo_wrkmem[LZO1X_999_MEM_COMPRESS > LZO1X_1_MEM_COMPRESS ? LZO1X_999_MEM_COMPRESS : LZO1X_1_MEM_COMPRESS];
|
||||
|
||||
|
||||
#define MAX_SEQNO 1073741824
|
||||
|
@ -94,7 +94,7 @@ length_t compress_packet(uint8_t *dest, const uint8_t *source, length_t len, int
|
|||
lzo1x_1_compress(source, len, dest, &lzolen, lzo_wrkmem);
|
||||
return lzolen;
|
||||
} else if(level < 10) {
|
||||
unsigned long destlen;
|
||||
unsigned long destlen = MAXSIZE;
|
||||
if(compress2(dest, &destlen, source, len, level) == Z_OK)
|
||||
return destlen;
|
||||
else
|
||||
|
@ -117,7 +117,7 @@ length_t uncompress_packet(uint8_t *dest, const uint8_t *source, length_t len, i
|
|||
else
|
||||
return -1;
|
||||
} else {
|
||||
unsigned long destlen;
|
||||
unsigned long destlen = MAXSIZE;
|
||||
if(uncompress(dest, &destlen, source, len) == Z_OK)
|
||||
return destlen;
|
||||
else
|
||||
|
@ -136,7 +136,6 @@ void receive_udppacket(node_t *n, vpn_packet_t *inpkt)
|
|||
int nextpkt = 0;
|
||||
vpn_packet_t *outpkt = pkt[0];
|
||||
int outlen, outpad;
|
||||
long int complen = MTU + 12;
|
||||
char hmac[EVP_MAX_MD_SIZE];
|
||||
int i;
|
||||
|
||||
|
@ -188,7 +187,7 @@ void receive_udppacket(node_t *n, vpn_packet_t *inpkt)
|
|||
} else if (inpkt->seqno <= n->received_seqno) {
|
||||
if(inpkt->seqno <= n->received_seqno - sizeof(n->late) * 8 || !(n->late[(inpkt->seqno / 8) % sizeof(n->late)] & (1 << inpkt->seqno % 8))) {
|
||||
syslog(LOG_WARNING, _("Got late or replayed packet from %s (%s), seqno %d, last received %d"),
|
||||
n->name, n->hostname, inpkt->seqno, n->received_seqno, n->late[(inpkt->seqno / 8) % sizeof(n->late)]);
|
||||
n->name, n->hostname, inpkt->seqno, n->received_seqno);
|
||||
} else
|
||||
for(i = n->received_seqno + 1; i < inpkt->seqno; i++)
|
||||
n->late[(inpkt->seqno / 8) % sizeof(n->late)] |= 1 << i % 8;
|
||||
|
@ -249,7 +248,6 @@ void send_udppacket(node_t *n, vpn_packet_t *inpkt)
|
|||
vpn_packet_t *outpkt;
|
||||
int origlen;
|
||||
int outlen, outpad;
|
||||
long int complen = MTU + 12;
|
||||
vpn_packet_t *copy;
|
||||
static int priority = 0;
|
||||
int origpriority;
|
||||
|
|
17
src/tincd.c
17
src/tincd.c
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: tincd.c,v 1.10.4.66 2003/01/17 00:43:58 guus Exp $
|
||||
$Id: tincd.c,v 1.10.4.67 2003/05/06 23:14:45 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -50,6 +50,8 @@
|
|||
#include <openssl/pem.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
#include <lzo1x.h>
|
||||
|
||||
#include <utils.h>
|
||||
#include <xalloc.h>
|
||||
|
||||
|
@ -361,6 +363,9 @@ int main(int argc, char **argv, char **envp)
|
|||
if(show_help)
|
||||
usage(0);
|
||||
|
||||
if(kill_tincd)
|
||||
exit(kill_other(kill_tincd));
|
||||
|
||||
#ifndef LOG_PERROR
|
||||
openlog("tinc", LOG_CONS, LOG_DAEMON); /* Catch all syslog() calls issued before detaching */
|
||||
#else
|
||||
|
@ -409,15 +414,17 @@ int main(int argc, char **argv, char **envp)
|
|||
exit(keygen(generate_keys));
|
||||
}
|
||||
|
||||
if(kill_tincd)
|
||||
exit(kill_other(kill_tincd));
|
||||
|
||||
if(read_server_config())
|
||||
exit(1);
|
||||
|
||||
if(lzo_init() != LZO_E_OK) {
|
||||
syslog(LOG_ERR, _("Error initializing LZO compressor!"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(detach())
|
||||
exit(0);
|
||||
|
||||
|
||||
for(;;) {
|
||||
if(!setup_network_connections()) {
|
||||
main_loop();
|
||||
|
|
Loading…
Reference in a new issue