Browse Source

Debug: Enable crypto packet dumps conditionally based on debug level

nodeinfo-routing-update
Evgeny 2 months ago
parent
commit
603768052d
  1. 52
      Makefile
  2. 10
      src/etcp_connections.c

52
Makefile

@ -89,8 +89,8 @@ POST_INSTALL = :
NORMAL_UNINSTALL = : NORMAL_UNINSTALL = :
PRE_UNINSTALL = : PRE_UNINSTALL = :
POST_UNINSTALL = : POST_UNINSTALL = :
build_triplet = x86_64-w64-mingw32 build_triplet = x86_64-pc-linux-gnu
host_triplet = x86_64-w64-mingw32 host_triplet = x86_64-pc-linux-gnu
subdir = . subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__aclocal_m4_deps = $(top_srcdir)/configure.ac
@ -210,28 +210,28 @@ distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print
ACLOCAL = ${SHELL} '/c/ARM/_uTun/utun2/build-aux/missing' aclocal-1.16 ACLOCAL = ${SHELL} '/home/vnc1/proj/utun3/build-aux/missing' aclocal-1.16
AMTAR = $${TAR-tar} AMTAR = $${TAR-tar}
AM_DEFAULT_VERBOSITY = 1 AM_DEFAULT_VERBOSITY = 1
AR = ar AR = ar
AUTOCONF = ${SHELL} '/c/ARM/_uTun/utun2/build-aux/missing' autoconf AUTOCONF = ${SHELL} '/home/vnc1/proj/utun3/build-aux/missing' autoconf
AUTOHEADER = ${SHELL} '/c/ARM/_uTun/utun2/build-aux/missing' autoheader AUTOHEADER = ${SHELL} '/home/vnc1/proj/utun3/build-aux/missing' autoheader
AUTOMAKE = ${SHELL} '/c/ARM/_uTun/utun2/build-aux/missing' automake-1.16 AUTOMAKE = ${SHELL} '/home/vnc1/proj/utun3/build-aux/missing' automake-1.16
AWK = gawk AWK = mawk
CC = x86_64-w64-mingw32-gcc CC = gcc
CCDEPMODE = depmode=gcc3 CCDEPMODE = depmode=gcc3
CFLAGS = -g -O2 CFLAGS = -g -O2
CPPFLAGS = CPPFLAGS =
CSCOPE = cscope CSCOPE = cscope
CTAGS = ctags CTAGS = ctags
CYGPATH_W = cygpath -w CYGPATH_W = echo
DEFS = -DHAVE_CONFIG_H DEFS = -DHAVE_CONFIG_H
DEPDIR = .deps DEPDIR = .deps
ECHO_C = ECHO_C =
ECHO_N = -n ECHO_N = -n
ECHO_T = ECHO_T =
ETAGS = etags ETAGS = etags
EXEEXT = .exe EXEEXT =
INSTALL = /usr/bin/install -c INSTALL = /usr/bin/install -c
INSTALL_DATA = ${INSTALL} -m 644 INSTALL_DATA = ${INSTALL} -m 644
INSTALL_PROGRAM = ${INSTALL} INSTALL_PROGRAM = ${INSTALL}
@ -241,7 +241,7 @@ LDFLAGS =
LIBOBJS = LIBOBJS =
LIBS = -lcrypto LIBS = -lcrypto
LTLIBOBJS = LTLIBOBJS =
MAKEINFO = ${SHELL} '/c/ARM/_uTun/utun2/build-aux/missing' makeinfo MAKEINFO = ${SHELL} '/home/vnc1/proj/utun3/build-aux/missing' makeinfo
MKDIR_P = /usr/bin/mkdir -p MKDIR_P = /usr/bin/mkdir -p
OBJEXT = o OBJEXT = o
PACKAGE = utun PACKAGE = utun
@ -254,41 +254,41 @@ PACKAGE_VERSION = 2.0.0
PATH_SEPARATOR = : PATH_SEPARATOR = :
RANLIB = ranlib RANLIB = ranlib
SET_MAKE = SET_MAKE =
SHELL = /bin/sh SHELL = /bin/bash
STRIP = STRIP =
VERSION = 2.0.0 VERSION = 2.0.0
abs_builddir = /c/ARM/_uTun/utun2 abs_builddir = /home/vnc1/proj/utun3
abs_srcdir = /c/ARM/_uTun/utun2 abs_srcdir = /home/vnc1/proj/utun3
abs_top_builddir = /c/ARM/_uTun/utun2 abs_top_builddir = /home/vnc1/proj/utun3
abs_top_srcdir = /c/ARM/_uTun/utun2 abs_top_srcdir = /home/vnc1/proj/utun3
ac_ct_AR = ar ac_ct_AR = ar
ac_ct_CC = ac_ct_CC = gcc
am__include = include am__include = include
am__leading_dot = . am__leading_dot = .
am__quote = am__quote =
am__tar = $${TAR-tar} chof - "$$tardir" am__tar = $${TAR-tar} chof - "$$tardir"
am__untar = $${TAR-tar} xf - am__untar = $${TAR-tar} xf -
bindir = ${exec_prefix}/bin bindir = ${exec_prefix}/bin
build = x86_64-w64-mingw32 build = x86_64-pc-linux-gnu
build_alias = x86_64-w64-mingw32 build_alias =
build_cpu = x86_64 build_cpu = x86_64
build_os = mingw32 build_os = linux-gnu
build_vendor = w64 build_vendor = pc
builddir = . builddir = .
datadir = ${datarootdir} datadir = ${datarootdir}
datarootdir = ${prefix}/share datarootdir = ${prefix}/share
docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
dvidir = ${docdir} dvidir = ${docdir}
exec_prefix = ${prefix} exec_prefix = ${prefix}
host = x86_64-w64-mingw32 host = x86_64-pc-linux-gnu
host_alias = x86_64-w64-mingw32 host_alias =
host_cpu = x86_64 host_cpu = x86_64
host_os = mingw32 host_os = linux-gnu
host_vendor = w64 host_vendor = pc
htmldir = ${docdir} htmldir = ${docdir}
includedir = ${prefix}/include includedir = ${prefix}/include
infodir = ${datarootdir}/info infodir = ${datarootdir}/info
install_sh = ${SHELL} /c/ARM/_uTun/utun2/build-aux/install-sh install_sh = ${SHELL} /home/vnc1/proj/utun3/build-aux/install-sh
libdir = ${exec_prefix}/lib libdir = ${exec_prefix}/lib
libexecdir = ${exec_prefix}/libexec libexecdir = ${exec_prefix}/libexec
localedir = ${datarootdir}/locale localedir = ${datarootdir}/locale

10
src/etcp_connections.c

@ -485,10 +485,10 @@ int etcp_encrypt_send(struct ETCP_DGRAM* dgram) {
dgram->timestamp=get_current_timestamp(); dgram->timestamp=get_current_timestamp();
// DUMP: Show packet before encryption // DUMP: Show packet before encryption
// log_dump("ECTP_ENCRYPT_SEND", dgram->data, dgram->data_len); if (debug_should_output(DEBUG_LEVEL_DEBUG, DEBUG_CATEGORY_CRYPTO)) log_dump("ECTP_ENCRYPT_SEND", dgram->data, dgram->data_len);
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Encrypt start"); // DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Encrypt start");
sc_encrypt(sc, (uint8_t*)&dgram->timestamp/*не править это, тут верно!*/, sizeof(uint16_t) + len, enc_buf, &enc_buf_len); sc_encrypt(sc, (uint8_t*)&dgram->timestamp/*не править это, тут верно!*/, sizeof(uint16_t) + len, enc_buf, &enc_buf_len);
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Encrypt end"); // DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Encrypt end");
if (enc_buf_len == 0) { if (enc_buf_len == 0) {
DEBUG_ERROR(DEBUG_CATEGORY_CRYPTO, "etcp_encrypt_send: encryption failed for node %llu", (unsigned long long)dgram->link->etcp->instance->node_id); DEBUG_ERROR(DEBUG_CATEGORY_CRYPTO, "etcp_encrypt_send: encryption failed for node %llu", (unsigned long long)dgram->link->etcp->instance->node_id);
dgram->link->send_errors++; dgram->link->send_errors++;
@ -499,7 +499,7 @@ int etcp_encrypt_send(struct ETCP_DGRAM* dgram) {
memcpy(enc_buf+enc_buf_len, dgram->data+len, dgram->noencrypt_len); memcpy(enc_buf+enc_buf_len, dgram->data+len, dgram->noencrypt_len);
// DUMP: Show complete packet before sending // DUMP: Show complete packet before sending
// log_dump("ENCRYPTED, READY TO SEND", enc_buf, enc_buf_len + dgram->noencrypt_len); if (debug_should_output(DEBUG_LEVEL_DEBUG, DEBUG_CATEGORY_CRYPTO)) log_dump("ENCRYPTED, READY TO SEND", enc_buf, enc_buf_len + dgram->noencrypt_len);
struct sockaddr_storage* addr=&dgram->link->remote_addr; struct sockaddr_storage* addr=&dgram->link->remote_addr;
socklen_t addr_len = (addr->ss_family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6); socklen_t addr_len = (addr->ss_family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6);
@ -563,7 +563,7 @@ static void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
// printf("[ETCP] Received packet: %zd bytes from address\n", recv_len); // printf("[ETCP] Received packet: %zd bytes from address\n", recv_len);
// DUMP: Show received packet content // DUMP: Show received packet content
// log_dump("RECV in:", data, recv_len); // link unknown at this point if (debug_should_output(DEBUG_LEVEL_DEBUG, DEBUG_CATEGORY_CRYPTO)) log_dump("RECV in:", data, recv_len); // link unknown at this point
struct ETCP_DGRAM* pkt = memory_pool_alloc(e_sock->instance->pkt_pool); struct ETCP_DGRAM* pkt = memory_pool_alloc(e_sock->instance->pkt_pool);
if (!pkt) return; if (!pkt) return;

Loading…
Cancel
Save