summaryrefslogtreecommitdiff
path: root/staging
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2016-09-20 21:37:35 +0300
committerTobias Klauser <tklauser@distanz.ch>2016-09-21 09:36:46 +0200
commit6197f02044e2fe6689b52dad0a0c75bdc0eb185b (patch)
tree73f525c5743b5e7e906b9e0b9a852bdeb161168b /staging
parent4829ae377acc30222c3866eb67082d7cf15c73f1 (diff)
mz: Check device argument by ifindex instead of name prefix
Check device argument by valid ifindex instead of guessing it by different device name prefixes like "eth", "ath", "ens", "enp". Use __device_ifindex(...) function for this, which needs to add few more dependencies like sock.o, link.o to the Makefile for mausezahn. Closes #159 Suggested-by: Tobias Klauser <tklauser@distanz.ch> 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.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/staging/mausezahn.c b/staging/mausezahn.c
index 70f1e72..32bcdc5 100644
--- a/staging/mausezahn.c
+++ b/staging/mausezahn.c
@@ -30,6 +30,7 @@
#include "config.h"
#include "llist.h"
#include "die.h"
+#include "dev.h"
int verbose_level = 0;
@@ -597,13 +598,8 @@ int getopts (int argc, char *argv[])
}
break;
case 1: // arg_string OR device given => find out!
- if ( (strncmp(argv[optind],"eth",3)==0)
- || (strncmp(argv[optind],"ath",3)==0)
- || ((strncmp(argv[optind],"lo",2)==0)&&(strncmp(argv[optind],"log",3)!=0))
- || (strncmp(argv[optind],"vmnet",5)==0)
- || (strncmp(argv[optind],"wifi",4)==0) ) {
- // device has been specified!
- strncpy (tx.device, argv[optind], 16);
+ if (__device_ifindex(argv[optind]) > 0) {
+ strncpy(tx.device, argv[optind], 16);
}
else { /// arg_string given => no device has been specified -- let's find one!
strncpy (tx.arg_string, argv[optind], MAX_PAYLOAD_SIZE);