diff options
author | lns <matzeton@googlemail.com> | 2022-08-21 19:04:16 +0200 |
---|---|---|
committer | lns <matzeton@googlemail.com> | 2022-08-21 19:05:42 +0200 |
commit | f0415cabfa69fa0122a299a10d06c05de4efe2b9 (patch) | |
tree | 0432be4e320913e2c4cc7e50cbb6afc04aac4ecb /nDPId.c | |
parent | 98645285c855243e40c91af3b64b587921580955 (diff) |
nDPId: improved error messages if UNIX/UDP endpoint refuses connections/datagramsadd/nDPId-UDP-endpoint
Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'nDPId.c')
-rw-r--r-- | nDPId.c | 33 |
1 files changed, 25 insertions, 8 deletions
@@ -1985,9 +1985,10 @@ static void send_to_collector(struct nDPId_reader_thread * const reader_thread, if (connect_to_collector(reader_thread) == 0) { logger(1, - "[%8llu, %zu] Reconnected to nDPIsrvd Collector", + "[%8llu, %zu] Reconnected to nDPIsrvd Collector at %s", workflow->packets_captured, - reader_thread->array_index); + reader_thread->array_index, + nDPId_options.collector_address); jsonize_daemon(reader_thread, DAEMON_EVENT_RECONNECT); } } @@ -2007,7 +2008,19 @@ static void send_to_collector(struct nDPId_reader_thread * const reader_thread, } if (saved_errno != EAGAIN) { - reader_thread->collector_sock_reconnect = 1; + if (saved_errno == ECONNREFUSED) + { + logger(1, + "[%8llu, %zu] %s to %s refused by endpoint", + workflow->packets_captured, + reader_thread->array_index, + (collector_address.raw.sa_family == AF_UNIX ? "Connection" : "Datagram"), + nDPId_options.collector_address); + } + if (collector_address.raw.sa_family == AF_UNIX) + { + reader_thread->collector_sock_reconnect = 1; + } } else { @@ -2021,11 +2034,15 @@ static void send_to_collector(struct nDPId_reader_thread * const reader_thread, if (written < 0) { logger(1, - "[%8llu, %zu] Send data (blocking I/O) to nDPIsrvd Collector failed: %s", + "[%8llu, %zu] Send data (blocking I/O) to nDPIsrvd Collector at %s failed: %s", workflow->packets_captured, reader_thread->array_index, + nDPId_options.collector_address, strerror(saved_errno)); - reader_thread->collector_sock_reconnect = 1; + if (collector_address.raw.sa_family == AF_UNIX) + { + reader_thread->collector_sock_reconnect = 1; + } break; } else @@ -2716,7 +2733,7 @@ static int process_datalink_layer(struct nDPId_reader_thread * const reader_thre return 1; } - struct ndpi_chdlc const * const chdlc = (struct ndpi_chdlc const * const) & packet[eth_offset]; + struct ndpi_chdlc const * const chdlc = (struct ndpi_chdlc const * const)&packet[eth_offset]; *ip_offset = sizeof(struct ndpi_chdlc); *layer3_type = ntohs(chdlc->proto_code); break; @@ -2738,7 +2755,7 @@ static int process_datalink_layer(struct nDPId_reader_thread * const reader_thre if (packet[0] == 0x0f || packet[0] == 0x8f) { - struct ndpi_chdlc const * const chdlc = (struct ndpi_chdlc const * const) & packet[eth_offset]; + struct ndpi_chdlc const * const chdlc = (struct ndpi_chdlc const * const)&packet[eth_offset]; *ip_offset = sizeof(struct ndpi_chdlc); /* CHDLC_OFF = 4 */ *layer3_type = ntohs(chdlc->proto_code); } @@ -2776,7 +2793,7 @@ static int process_datalink_layer(struct nDPId_reader_thread * const reader_thre } struct ndpi_radiotap_header const * const radiotap = - (struct ndpi_radiotap_header const * const) & packet[eth_offset]; + (struct ndpi_radiotap_header const * const)&packet[eth_offset]; uint16_t radio_len = radiotap->len; /* Check Bad FCS presence */ |