]> git.meshlink.io Git - meshlink/commitdiff
Small fixes to make LZO compression work.
authorGuus Sliepen <guus@tinc-vpn.org>
Tue, 6 May 2003 23:14:45 +0000 (23:14 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Tue, 6 May 2003 23:14:45 +0000 (23:14 +0000)
src/net_packet.c
src/tincd.c

index e4c4c10a00e25c8c6473586b0adcd4ba9192be03..f9fdf92603b90f56182e5b858e8d919a43c9ac05 100644 (file)
@@ -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;
index 4335d7b613040c2b488624f5f396c3431300de16..f3ffc195e32f746512067ca214a0b9698a37c0e8 100644 (file)
@@ -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();