diff src/proto.nacltai.c @ 22:38d495566d1c

Re-added some debugging messages to nacltai protocol code, enabled by the DEBUG environment variable
author Ivo Smits <Ivo@UCIS.nl>
date Sun, 27 Feb 2011 23:52:32 +0100
parents 3400045a57b8
children dfac56805c77
line wrap: on
line diff
--- 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;
 }