]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
other includes for dpa comp
authorJelte Jansen <jeltejan@NLnetLabs.nl>
Thu, 15 Dec 2005 10:59:53 +0000 (10:59 +0000)
committerJelte Jansen <jeltejan@NLnetLabs.nl>
Thu, 15 Dec 2005 10:59:53 +0000 (10:59 +0000)
examples/Makefile.in
examples/configure.ac
examples/ldns-dpa.c

index cc1e9b508f9b9f5a711ef045ed2cdd0104d471b6..6e9f5029d916d0e454924c08cda96014b79ae6fd 100644 (file)
@@ -33,7 +33,8 @@ SOURCES       = ldns-read-zone.c \
                  ldns-walk.c \
                  ldns-threshold-update.c  \
                  ldns-zsplit.c \
-                 ldns-zcat.c
+                 ldns-zcat.c \
+                 ldns-dpa.c
 
 
 PROGRAMS=$(SOURCES:.c=)
index 8397671b10cc9a3a00605716c7a9e0c15db80c74..9c0280a6ed83082f05b8e8bb18c054c5427223df 100644 (file)
@@ -10,7 +10,7 @@ AC_AIX
 AC_PROG_CC
 AC_PROG_MAKE_SET
 
-AC_CHECK_HEADERS([sys/types.h getopt.h stdlib.h stdio.h assert.h netinet/in.hctype.h netinet/udp.h time.h pcap.h net/bpf.h arpa/inet.h sys/time.h sys/socket.h],,, [AC_INCLUDES_DEFAULT])
+AC_CHECK_HEADERS([sys/types.h getopt.h stdlib.h stdio.h assert.h netinet/in.hctype.h netinet/udp.h time.h pcap.h arpa/inet.h sys/time.h sys/socket.h],,, [AC_INCLUDES_DEFAULT])
 AC_CHECK_HEADERS([netinet/in.h netinet/ip.h netinet/if_ether.h])
 
 AC_CHECK_HEADERS([sys/param.h sys/mount.h],,,
@@ -44,10 +44,10 @@ AC_CHECK_HEADER(ldns/dns.h,,  [
        ], [AC_INCLUDES_DEFAULT]
 )
 
-#AC_CHECK_LIB(pcap, pcap_open_offline,, [
-#      AC_MSG_ERROR([Can't find pcap library (needed for dpa)])
-#      ]
-#)
+AC_CHECK_LIB(pcap, pcap_open_offline,, [
+       AC_MSG_ERROR([Can't find pcap library (needed for dpa)])
+       ]
+)
 
 AC_CHECK_FUNCS(isblank)
 
@@ -91,9 +91,6 @@ AH_BOTTOM([
 #include <pcap.h>
 #endif
 
-#ifdef HAVE_NET_BPF_H
-#include <net/bpf.h>
-#endif
 #include <netinet/in_systm.h>  
 
 #ifdef HAVE_NETINET_IP_H
index 778848e09a0f7a239689c444c3190de96b9c036b..e76389db855186c794bfccf1e2b5421008e81f70 100644 (file)
@@ -23,6 +23,7 @@ int verbosity = 1;
 /* global options */
 bool show_filter_matches = false;
 size_t total_nr_of_dns_packets = 0;
+size_t total_nr_of_filtered_packets = 0;
 size_t not_ip_packets = 0;
 size_t bad_dns_packets = 0;
 size_t arp_packets = 0;
@@ -561,7 +562,7 @@ print_counter_averages(FILE *output, match_counters *counters, match_operation *
                mt = get_match_by_id(cur->id);
                total_value = calculate_total_value(counters, cur);
                total_count = calculate_total_count(counters, cur);
-               printf("Average for %s: (%u / %u) %.02f\n", mt->name, total_value, total_count, (float) total_value / (float) total_count);
+               printf("Average for %s: (%u / %u) %.02f\n", mt->name, (unsigned int) total_value, (unsigned int) total_count, (float) total_value / (float) total_count);
                if (counters->left) {
                        print_counter_averages(output, counters->left, cur);
                }
@@ -600,7 +601,7 @@ print_counter_average_count(FILE *output, match_counters *counters, match_operat
                mt = get_match_by_id(cur->id);
                total_matches = calculate_total_count_matches(counters, cur);
                total_count = calculate_total_count(counters, cur);
-               printf("Average count for %s: (%u / %u) %.02f\n", mt->name, total_count, total_matches, (float) total_count / (float) total_matches);
+               printf("Average count for %s: (%u / %u) %.02f\n", mt->name, (unsigned int) total_count, (unsigned int) total_matches, (float) total_count / (float) total_matches);
                if (counters->left) {
                        print_counter_averages(output, counters->left, cur);
                }
@@ -2103,6 +2104,8 @@ printf("timeval: %u ; %u\n", cur_hdr.ts.tv_sec, cur_hdr.ts.tv_usec);
                                                printf("\n\n");
                                        }
 
+                                       total_nr_of_dns_packets++;
+
                                        if (match_expr) {
                                                if (match_dns_packet_to_expr(pkt, src_addr, dst_addr, match_expr)) {
                                                        /* if outputfile write */
@@ -2139,7 +2142,7 @@ printf("timeval: %u ; %u\n", cur_hdr.ts.tv_sec, cur_hdr.ts.tv_usec);
                                        }
 
                                        /* General counters here */
-                                       total_nr_of_dns_packets++;
+                                       total_nr_of_filtered_packets++;
 
                                        match_pkt_counters(pkt, src_addr, dst_addr, count);
                                        match_pkt_uniques(pkt, src_addr, dst_addr, uniques, unique_ids, unique_id_count);
@@ -2220,6 +2223,8 @@ printf("timeval: %u ; %u\n", cur_hdr.ts.tv_sec, cur_hdr.ts.tv_usec);
                                        printf("\n\n");
                                }
 
+                               total_nr_of_dns_packets++;
+
                                if (match_expr) {
                                        if (match_dns_packet_to_expr(pkt, src_addr, dst_addr, match_expr)) {
                                                /* if outputfile write */
@@ -2256,7 +2261,7 @@ printf("timeval: %u ; %u\n", cur_hdr.ts.tv_sec, cur_hdr.ts.tv_usec);
                                }
 
                                /* General counters here */
-                               total_nr_of_dns_packets++;
+                               total_nr_of_filtered_packets++;
 
                                match_pkt_counters(pkt, src_addr, dst_addr, count);
                                match_pkt_uniques(pkt, src_addr, dst_addr, uniques, unique_ids, unique_id_count);
@@ -2610,20 +2615,21 @@ int main(int argc, char *argv[]) {
        pcap_close(pc);
        
        if (show_percentages) {
-               fprintf(stdout, "Packets that are not IP: %u\n", not_ip_packets);
-               fprintf(stdout, "bad dns packets: %u\n", bad_dns_packets);
-               fprintf(stdout, "arp packets: %u\n", arp_packets);
-               fprintf(stdout, "udp packets: %u\n", udp_packets);
-               fprintf(stdout, "tcp packets (skipped): %u\n", tcp_packets);
-               fprintf(stdout, "reassembled fragmented packets: %u\n", fragmented_packets);
-               fprintf(stdout, "packet fragments lost: %u\n", lost_packet_fragments);
-               fprintf(stdout, "Total number of DNS packets evaluated: %u\n", (unsigned int) total_nr_of_dns_packets);
+               fprintf(stdout, "Packets that are not IP: %u\n", (unsigned int) not_ip_packets);
+               fprintf(stdout, "bad dns packets: %u\n", (unsigned int) bad_dns_packets);
+               fprintf(stdout, "arp packets: %u\n", (unsigned int) arp_packets);
+               fprintf(stdout, "udp packets: %u\n", (unsigned int) udp_packets);
+               fprintf(stdout, "tcp packets (skipped): %u\n", (unsigned int) tcp_packets);
+               fprintf(stdout, "reassembled fragmented packets: %u\n", (unsigned int) fragmented_packets);
+               fprintf(stdout, "packet fragments lost: %u\n", (unsigned int) lost_packet_fragments);
+               fprintf(stdout, "Total number of DNS packets: %u\n", (unsigned int) total_nr_of_dns_packets);
+               fprintf(stdout, "Total number of DNS packets after filter: %u\n", (unsigned int) total_nr_of_filtered_packets);
        }
        if (count->match) {
-               print_counters(stdout, count, show_percentages, total_nr_of_dns_packets, 0);
+               print_counters(stdout, count, show_percentages, total_nr_of_filtered_packets, 0);
        }
        if (uniques->match) {
-               print_counters(stdout, uniques, show_percentages, total_nr_of_dns_packets, unique_minimum);
+               print_counters(stdout, uniques, show_percentages, total_nr_of_filtered_packets, unique_minimum);
                if (show_averages) {
                        print_counter_averages(stdout, uniques, NULL);
                }