Diff between 2a0ae8294b52864db38dee9b94c2c3368a4f79c8 and c0509b127a1a37ceb7a01e73e124766766e9684f

Changed Files

File Additions Deletions Status
mesh/main.c +2 -1 modified
mesh/util.c +11 -0 modified
mesh/util.h +1 -0 modified

Full Patch

diff --git a/mesh/main.c b/mesh/main.c
index c6bf1ff..1a4e6ba 100644
--- a/mesh/main.c
+++ b/mesh/main.c
@@ -37,6 +37,7 @@
 #include "mesh/crypto.h"
 #include "mesh/dbus.h"
 #include "mesh/mesh-io.h"
+#include "mesh/util.h"
 
 static const char *config_dir;
 static const char *mesh_conf_fname;
@@ -210,7 +211,7 @@ int main(int argc, char *argv[])
 			detached = false;
 			break;
 		case 'd':
-			l_debug_enable("*");
+			enable_debug();
 			break;
 		case 'c':
 			config_dir = optarg;
diff --git a/mesh/util.c b/mesh/util.c
index 43340f1..7d28333 100644
--- a/mesh/util.c
+++ b/mesh/util.c
@@ -34,10 +34,15 @@
 
 #include "mesh/util.h"
 
+static bool debug_enabled;
+
 void print_packet(const char *label, const void *data, uint16_t size)
 {
 	struct timeval pkt_time;
 
+	if (!debug_enabled)
+		return;
+
 	gettimeofday(&pkt_time, NULL);
 
 	if (size > 0) {
@@ -154,3 +159,9 @@ void del_path(const char *path)
 {
 	nftw(path, del_fobject, 5, FTW_DEPTH | FTW_PHYS);
 }
+
+void enable_debug(void)
+{
+	debug_enabled = true;
+	l_debug_enable("*");
+}
diff --git a/mesh/util.h b/mesh/util.h
index 092d330..93c2d86 100644
--- a/mesh/util.h
+++ b/mesh/util.h
@@ -24,3 +24,4 @@ size_t hex2str(uint8_t *in, size_t in_len, char *out, size_t out_len);
 void print_packet(const char *label, const void *data, uint16_t size);
 int create_dir(const char *dir_name);
 void del_path(const char *path);
+void enable_debug(void);