# HG changeset patch # User Ivo Smits # Date 1298847152 -3600 # Node ID 38d495566d1c597573d09c61d0d5adcd39e6ca3e # Parent c1e5af9329f13e129b2bd2da2484a7502f083e66 Re-added some debugging messages to nacltai protocol code, enabled by the DEBUG environment variable diff -r c1e5af9329f1 -r 38d495566d1c src/common.c --- a/src/common.c Sun Feb 27 22:48:51 2011 +0100 +++ b/src/common.c Sun Feb 27 23:52:32 2011 +0100 @@ -77,9 +77,11 @@ extern int errorexitp(const char*); extern void print_header(); extern void hex2bin(unsigned char*, unsigned char*, int); + extern int debug; #else char* (*getconf)(const char*) = getenv; +int debug = 0; int errorexit(const char* text) { fprintf(stderr, "%s\n", text); @@ -92,7 +94,7 @@ void print_header() { fprintf(stderr, "UCIS QuickTun (c) 2010 Ivo Smits \n"); - fprintf(stderr, "More information: http://wiki.qontrol.nl/QuickTun\n"); + fprintf(stderr, "More information: http://wiki.ucis.nl/QuickTun\n"); } int init_udp(struct qtsession* session) { @@ -189,6 +191,7 @@ } int qtrun(struct qtproto* p) { + if (getconf("DEBUG")) debug = 1; struct qtsession session; session.protocol = *p; diff -r c1e5af9329f1 -r 38d495566d1c src/proto.nacltai.c --- a/src/proto.nacltai.c Sun Feb 27 22:48:51 2011 +0100 +++ b/src/proto.nacltai.c Sun Feb 27 23:52:32 2011 +0100 @@ -118,20 +118,20 @@ } static int encode(struct qtsession* sess, char* raw, char* enc, int len) { -// fprintf(stderr, "Encoding packet of %d bytes from %d to %d\n", len, raw, enc); + if (debug) fprintf(stderr, "Encoding packet of %d bytes from %d to %d\n", len, raw, enc); struct qt_proto_data_nacltai* d = (struct qt_proto_data_nacltai*)sess->protocol_data; memset(raw, 0, crypto_box_ZEROBYTES); taia_now(&d->cdtaic); taia_pack(d->cenonce + nonceoffset, &(d->cdtaic)); - if (crypto_box_afternm(enc, raw, len + crypto_box_ZEROBYTES, d->cenonce, d->cbefore)) return errorexit("Crypto failed"); + if (crypto_box_afternm(enc, raw, len + crypto_box_ZEROBYTES, d->cenonce, d->cbefore)) return errorexit("Encryption failed"); memcpy((void*)(enc + crypto_box_BOXZEROBYTES - noncelength), d->cenonce + nonceoffset, noncelength); len += overhead; -// fprintf(stderr, "Encoded packet of %d bytes from %d to %d\n", len, raw, enc); + if (debug) fprintf(stderr, "Encoded packet of %d bytes from %d to %d\n", len, raw, enc); return len; } static int decode(struct qtsession* sess, char* enc, char* raw, int len) { -// fprintf(stderr, "Decoding packet of %d bytes from %d to %d\n", len, enc, raw); + if (debug) fprintf(stderr, "Decoding packet of %d bytes from %d to %d\n", len, enc, raw); struct qt_proto_data_nacltai* d = (struct qt_proto_data_nacltai*)sess->protocol_data; int i; if (len < overhead) { @@ -151,7 +151,7 @@ return 0; } d->cdtaip = d->cdtaic; -// fprintf(stderr, "Decoded packet of %d bytes from %d to %d\n", len, enc, raw); + if (debug) fprintf(stderr, "Decoded packet of %d bytes from %d to %d\n", len, enc, raw); return len; }