bug fixes to extended_file output
This commit is contained in:
parent
a5eb3d0a8d
commit
672143e9ba
@ -168,6 +168,7 @@ int recv_run(pthread_mutex_t *recv_ready_mutex)
|
|||||||
log_fatal("recv", "could not allocate address bitmap");
|
log_fatal("recv", "could not allocate address bitmap");
|
||||||
}
|
}
|
||||||
log_debug("recv", "using dev %s", zconf.iface);
|
log_debug("recv", "using dev %s", zconf.iface);
|
||||||
|
if (!zconf.dryrun) {
|
||||||
char errbuf[PCAP_ERRBUF_SIZE];
|
char errbuf[PCAP_ERRBUF_SIZE];
|
||||||
pc = pcap_open_live(zconf.iface, zconf.probe_module->pcap_snaplen,
|
pc = pcap_open_live(zconf.iface, zconf.probe_module->pcap_snaplen,
|
||||||
PCAP_PROMISC, PCAP_TIMEOUT, errbuf);
|
PCAP_PROMISC, PCAP_TIMEOUT, errbuf);
|
||||||
@ -182,6 +183,7 @@ int recv_run(pthread_mutex_t *recv_ready_mutex)
|
|||||||
if (pcap_setfilter(pc, &bpf) < 0) {
|
if (pcap_setfilter(pc, &bpf) < 0) {
|
||||||
log_fatal("recv", "couldn't install filter");
|
log_fatal("recv", "couldn't install filter");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
log_debug("recv", "receiver ready");
|
log_debug("recv", "receiver ready");
|
||||||
if (zconf.filter_duplicates) {
|
if (zconf.filter_duplicates) {
|
||||||
log_debug("recv", "duplicate responses will be excluded from output");
|
log_debug("recv", "duplicate responses will be excluded from output");
|
||||||
@ -202,6 +204,9 @@ int recv_run(pthread_mutex_t *recv_ready_mutex)
|
|||||||
zconf.max_results = -1;
|
zconf.max_results = -1;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
|
if (zconf.dryrun) {
|
||||||
|
sleep(1);
|
||||||
|
} else {
|
||||||
if (pcap_dispatch(pc, 0, packet_cb, NULL) == -1) {
|
if (pcap_dispatch(pc, 0, packet_cb, NULL) == -1) {
|
||||||
log_fatal("recv", "pcap_dispatch error");
|
log_fatal("recv", "pcap_dispatch error");
|
||||||
}
|
}
|
||||||
@ -209,6 +214,7 @@ int recv_run(pthread_mutex_t *recv_ready_mutex)
|
|||||||
zsend.complete = 1;
|
zsend.complete = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} while (!(zsend.complete && (now()-zsend.finish > zconf.cooldown_secs)));
|
} while (!(zsend.complete && (now()-zsend.finish > zconf.cooldown_secs)));
|
||||||
zrecv.finish = now();
|
zrecv.finish = now();
|
||||||
// get final pcap statistics before closing
|
// get final pcap statistics before closing
|
||||||
|
12
src/send.c
12
src/send.c
@ -144,7 +144,17 @@ static int get_socket(void)
|
|||||||
|
|
||||||
static int get_dryrun_socket(void)
|
static int get_dryrun_socket(void)
|
||||||
{
|
{
|
||||||
return socket(AF_INET, SOCK_STREAM, 0);
|
// we need a socket in order to gather details about the system
|
||||||
|
// such as source MAC address and IP address. However, because
|
||||||
|
// we don't want to require root access in order to run dryrun,
|
||||||
|
// we just create a TCP socket.
|
||||||
|
int sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
if (sock <= 0) {
|
||||||
|
log_fatal("send", "couldn't create socket. "
|
||||||
|
"Error: %s\n", strerror(errno));
|
||||||
|
}
|
||||||
|
return sock;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ipaddr_n_t get_src_ip(ipaddr_n_t dst, int local_offset)
|
static inline ipaddr_n_t get_src_ip(ipaddr_n_t dst, int local_offset)
|
||||||
|
@ -222,7 +222,6 @@ static void start_zmap(void)
|
|||||||
}
|
}
|
||||||
// start threads
|
// start threads
|
||||||
pthread_t *tsend, trecv, tmon;
|
pthread_t *tsend, trecv, tmon;
|
||||||
if (!zconf.dryrun) {
|
|
||||||
int r = pthread_create(&trecv, NULL, start_recv, NULL);
|
int r = pthread_create(&trecv, NULL, start_recv, NULL);
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
log_fatal("zmap", "unable to create recv thread");
|
log_fatal("zmap", "unable to create recv thread");
|
||||||
@ -235,7 +234,6 @@ static void start_zmap(void)
|
|||||||
}
|
}
|
||||||
pthread_mutex_unlock(&recv_ready_mutex);
|
pthread_mutex_unlock(&recv_ready_mutex);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
tsend = malloc(zconf.senders * sizeof(pthread_t));
|
tsend = malloc(zconf.senders * sizeof(pthread_t));
|
||||||
assert(tsend);
|
assert(tsend);
|
||||||
log_debug("zmap", "using %d sender threads", zconf.senders);
|
log_debug("zmap", "using %d sender threads", zconf.senders);
|
||||||
@ -263,7 +261,7 @@ static void start_zmap(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
log_debug("zmap", "senders finished");
|
log_debug("zmap", "senders finished");
|
||||||
int r = pthread_join(trecv, NULL);
|
r = pthread_join(trecv, NULL);
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
log_fatal("zmap", "unable to join recv thread");
|
log_fatal("zmap", "unable to join recv thread");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -402,7 +400,7 @@ int main(int argc, char *argv[])
|
|||||||
zconf.raw_output_fields = (char*) "classification, saddr, "
|
zconf.raw_output_fields = (char*) "classification, saddr, "
|
||||||
"daddr, sport, dport, "
|
"daddr, sport, dport, "
|
||||||
"seqnum, acknum, cooldown, "
|
"seqnum, acknum, cooldown, "
|
||||||
"repeat, timstamp-str";
|
"repeat, timestamp-str";
|
||||||
zconf.filter_duplicates = 0;
|
zconf.filter_duplicates = 0;
|
||||||
} else {
|
} else {
|
||||||
zconf.output_module = get_output_module_by_name(args.output_module_arg);
|
zconf.output_module = get_output_module_by_name(args.output_module_arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user