diff options
author | Luca <deri@ntop.org> | 2024-10-02 15:55:35 +0200 |
---|---|---|
committer | Luca <deri@ntop.org> | 2024-10-02 15:55:35 +0200 |
commit | 45323e3bf8a0fc56fd5f74c12f78e2f27429e701 (patch) | |
tree | 7c49dc82092a43b645ac8cfd54344fcfa1017604 /example/reader_util.c | |
parent | 4df60a888b374e4b41298d0d63f98fcaff05786d (diff) |
Exports DNS A/AAAA responses (up to 4 addresses)
Changed the default to IPv4 (used to be IPv6) in case of DNS error response
Diffstat (limited to 'example/reader_util.c')
-rw-r--r-- | example/reader_util.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/example/reader_util.c b/example/reader_util.c index c0c723da0..11d6a24a3 100644 --- a/example/reader_util.c +++ b/example/reader_util.c @@ -1221,19 +1221,36 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl } /* DNS */ else if(is_ndpi_proto(flow, NDPI_PROTOCOL_DNS)) { - if(flow->ndpi_flow->protos.dns.rsp_type == 0x1) + if(flow->ndpi_flow->protos.dns.is_rsp_addr_ipv6[0] == 0) { flow->info_type = INFO_GENERIC; - inet_ntop(AF_INET, &flow->ndpi_flow->protos.dns.rsp_addr.ipv4, flow->info, sizeof(flow->info)); + inet_ntop(AF_INET, &flow->ndpi_flow->protos.dns.rsp_addr[0].ipv4, flow->info, sizeof(flow->info)); } else { flow->info_type = INFO_GENERIC; - inet_ntop(AF_INET6, &flow->ndpi_flow->protos.dns.rsp_addr.ipv6, flow->info, sizeof(flow->info)); + inet_ntop(AF_INET6, &flow->ndpi_flow->protos.dns.rsp_addr[0].ipv6, flow->info, sizeof(flow->info)); /* For consistency across platforms replace :0: with :: */ ndpi_patchIPv6Address(flow->info); } + if(flow->ndpi_flow->protos.dns.geolocation_iata_code[0] != '\0') strcpy(flow->dns.geolocation_iata_code, flow->ndpi_flow->protos.dns.geolocation_iata_code); + + if(0) { + u_int8_t i; + + for(i=0; i<flow->ndpi_flow->protos.dns.num_rsp_addr; i++) { + char buf[64]; + + if(flow->ndpi_flow->protos.dns.is_rsp_addr_ipv6[i] == 0) { + inet_ntop(AF_INET, &flow->ndpi_flow->protos.dns.rsp_addr[i].ipv4, buf, sizeof(buf)); + } else { + inet_ntop(AF_INET6, &flow->ndpi_flow->protos.dns.rsp_addr[i].ipv6, buf, sizeof(buf)); + } + + printf("(%s) %s [ttl: %u]\n", flow->host_server_name, buf, flow->ndpi_flow->protos.dns.rsp_addr_ttl[i]); + } + } } /* MDNS */ else if(is_ndpi_proto(flow, NDPI_PROTOCOL_MDNS)) { |