aboutsummaryrefslogtreecommitdiffstats
path: root/gg_sniff/gg_sniff.c
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2012-12-04 15:44:40 +0100
committerLaurent Ghigonis <laurent@p1sec.com>2012-12-04 15:44:40 +0100
commite8946a36bc72db82e6666d1ab8f7afdee9f41824 (patch)
treec39c086d8f4c5fd7732c786cc81f6404acf7e898 /gg_sniff/gg_sniff.c
parentstop the servers in the main(), not in signal handlers ! (diff)
downloadglouglou-e8946a36bc72db82e6666d1ab8f7afdee9f41824.tar.xz
glouglou-e8946a36bc72db82e6666d1ab8f7afdee9f41824.zip
handle listening on any interface, by passing to interface option to gg_sniff.
therefore, implement LINUX_SLL handling in pcap.c
Diffstat (limited to 'gg_sniff/gg_sniff.c')
-rw-r--r--gg_sniff/gg_sniff.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/gg_sniff/gg_sniff.c b/gg_sniff/gg_sniff.c
index e35238e..91585b7 100644
--- a/gg_sniff/gg_sniff.c
+++ b/gg_sniff/gg_sniff.c
@@ -39,7 +39,7 @@ usage(void)
{
extern char *__progname;
- fprintf(stderr, "usage: %s [-hv] interface [ip [port]]", __progname);
+ fprintf(stderr, "usage: %s [-hv] [-i interface] [ip [port]]", __progname);
exit(1);
}
@@ -59,7 +59,7 @@ main(int argc, char **argv)
struct ggnet *net = NULL;
struct event *ev_sigint, *ev_sigterm, *ev_sigchld, *ev_sighup;
char ggserv_ip[30] = "127.0.0.1";
- char iface[30] = "lo";
+ char *iface = NULL;
int ggserv_port = GLOUGLOU_PROBE_DEFAULT_PORT;
int pcap_init = 0;
int dns_init = 0;
@@ -70,11 +70,14 @@ main(int argc, char **argv)
if (geteuid() != 0)
errx(1, "must be root");
- while ((op = getopt(argc, argv, "hv")) != -1) {
+ while ((op = getopt(argc, argv, "hi:v")) != -1) {
switch (op) {
case 'h':
usage();
/* NOTREACHED */
+ case 'i':
+ iface = strndup(optarg, 30);
+ break;
case 'v':
loglevel++;
break;
@@ -83,10 +86,10 @@ main(int argc, char **argv)
/* NOTREACHED */
}
}
- switch (argc) {
- case 4: ggserv_port = atoi(argv[3]);
- case 3: strncpy(ggserv_ip, argv[2], sizeof(ggserv_ip));
- case 2: strncpy(iface, argv[1], sizeof(iface));
+ switch (argc - optind) {
+ case 2: ggserv_port = atoi(argv[3]);
+ case 1: strncpy(ggserv_ip, argv[2], sizeof(ggserv_ip));
+ case 0:
break;
default:
usage();
@@ -137,7 +140,7 @@ quit:
if (net)
ggnet_free(net);
- gg_log_info("exiting");
+ gg_log_warn("exiting");
gg_log_shutdown();