ongrep

A cleaned up fork of ngrep for OpenBSD
git clone git://git.sgregoratto.me/ongrep
Log | Files | Refs | README | LICENSE

commit 04d71c10b929f92c65e6bfde76352d556720116f
parent 4676690c3a0d453f358920fa25f45869cdee5518
Author: Jordan Ritter <jpr5@darkridge.com>
Date:   Sun, 20 Feb 2005 02:12:53 +0000

previous fix for lack of default_filter didn't work; this one does

Diffstat:
Mngrep.c | 17++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/ngrep.c b/ngrep.c @@ -368,27 +368,26 @@ int main(int argc, char **argv) { } } - if (filter) { - if (!quiet) printf("filter: %s\n", filter); + if (filter && !quiet) + printf("filter: %s\n", filter); - if (pcap_setfilter(pd, &pcapfilter)) { - pcap_perror(pd, "pcap set"); - clean_exit(-1); - } + if (pcap_setfilter(pd, &pcapfilter)) { + pcap_perror(pd, "pcap set"); + clean_exit(-1); } if (match_data) { if (bin_match) { int i = 0, n; char *s, *d; - int len; + unsigned len; if (re_match_word || re_ignore_case) { fprintf(stderr, "fatal: regex switches are incompatible with binary matching\n"); clean_exit(-1); } - len = (int)strlen(match_data); + len = (unsigned)strlen(match_data); if (len % 2 != 0 || !strishex(match_data)) { fprintf(stderr, "fatal: invalid hex string specified\n"); clean_exit(-1); @@ -399,7 +398,7 @@ int main(int argc, char **argv) { d = bin_data; if ((s = strchr(match_data, 'x'))) - len -= (int)(++s - match_data - 1); + len -= (unsigned)(++s - match_data - 1); else s = match_data; while (i <= len) {