summaryrefslogtreecommitdiff
path: root/staging
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2015-02-20 16:49:27 +0100
committerTobias Klauser <tklauser@distanz.ch>2015-02-20 16:49:27 +0100
commitce75021f844084bf1c3105bd2478a13dc96a12a1 (patch)
treed4cb357240f64d35b3aeba15d32137333bb96bed /staging
parentdb20fa00ca9880e6e661befee92e19194fa5e69a (diff)
mz: Dont bind to dev if help was specified
Fixed warnings: Warning: [lookupdev.c get_dev_params()] Cannot open socket! when specify help for packet type: # mz -t tcp help Also fixes delayed output of the same command if user is root. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'staging')
-rw-r--r--staging/mausezahn.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/staging/mausezahn.c b/staging/mausezahn.c
index f5b470f..83ce424 100644
--- a/staging/mausezahn.c
+++ b/staging/mausezahn.c
@@ -357,6 +357,7 @@ int getopts (int argc, char *argv[])
char *packet_type=NULL, *mops_type=NULL;
char *dum;
unsigned char *dum1, *dum2;
+ bool do_help = false;
libnet_t *l;
char err_buf[LIBNET_ERRBUF_SIZE];
@@ -575,12 +576,17 @@ int getopts (int argc, char *argv[])
}
else { /// arg_string given => no device has been specified -- let's find one!
strncpy (tx.arg_string, argv[optind], MAX_PAYLOAD_SIZE);
- if (lookupdev()) { // no device found
- if (verbose) fprintf(stderr, " mz: no active interfaces found!\n");
- strcpy(tx.device, "lo");
+ do_help = !!getarg(tx.arg_string,"help", NULL);
+ if (!do_help) {
+ if (lookupdev()) {
+ /* no device found */
+ if (verbose)
+ fprintf(stderr, " mz: no active interfaces found!\n");
+ strcpy(tx.device, "lo");
+ }
+ if (verbose)
+ fprintf(stderr," mz: device not given, will use %s\n",tx.device);
}
- if (verbose)
- fprintf(stderr," mz: device not given, will use %s\n",tx.device);
}
break;
case 2: // both device and arg_string given
@@ -610,7 +616,7 @@ int getopts (int argc, char *argv[])
// Get own device MAC address:
// Don't open context if only a help text is requested
- if (getarg(tx.arg_string,"help", NULL)!=1) {
+ if (!do_help && getarg(tx.arg_string,"help", NULL) !=1) {
l = libnet_init (LIBNET_LINK_ADV, tx.device, err_buf );
if (l == NULL) {
fprintf(stderr, " mz/getopts: libnet_init() failed (%s)", err_buf);