aboutsummaryrefslogtreecommitdiff
path: root/example/ndpiReader.c
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2021-03-23 11:47:29 +0100
committerGitHub <noreply@github.com>2021-03-23 11:47:29 +0100
commita6029d250d9c5dd0d7346fe47de838c243c20cac (patch)
tree0ed238d0235cb2e8db36e4fb65b15064b659b6c9 /example/ndpiReader.c
parentb04040768323a7666bcf588f2323054082883d75 (diff)
ndpiReader: print an error msg if we found an unsupported datalink type (#1157)
Diffstat (limited to 'example/ndpiReader.c')
1 files changed, 7 insertions, 1 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index a626eb527..8854a7d23 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -3321,9 +3321,15 @@ static void ndpi_process_packet(u_char *args,
* @brief Call pcap_loop() to process packets from a live capture or savefile
*/
static void runPcapLoop(u_int16_t thread_id) {
- if((!shutdown_app) && (ndpi_thread_info[thread_id].workflow->pcap_handle != NULL))
+ if((!shutdown_app) && (ndpi_thread_info[thread_id].workflow->pcap_handle != NULL)) {
+ int datalink_type = pcap_datalink(ndpi_thread_info[thread_id].workflow->pcap_handle);
+ if(!ndpi_is_datalink_supported(datalink_type)) {
+ printf("Unsupported datalink %d. Skip pcap\n", datalink_type);
+ return;
+ }
if(pcap_loop(ndpi_thread_info[thread_id].workflow->pcap_handle, -1, &ndpi_process_packet, (u_char*)&thread_id) < 0)
printf("Error while reading pcap file: '%s'\n", pcap_geterr(ndpi_thread_info[thread_id].workflow->pcap_handle));
+ }
}
/**