1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

cpu/native: add -w <tap> command line parameter to simulate wireless tap

This commit is contained in:
Benjamin Valentin 2022-02-26 15:28:08 +01:00
parent f61c12e008
commit 2520aaf1e8

View File

@ -115,6 +115,9 @@ static const char short_opts[] = ":hi:s:deEoc:"
#endif
#ifdef MODULE_PERIPH_SPIDEV_LINUX
"p:"
#endif
#ifdef MODULE_NETDEV_TAP
"w:"
#endif
"";
@ -367,6 +370,11 @@ void usage_exit(int status)
" -M <eeprom> , --eeprom=<eeprom>\n"
" Specify the file path where the EEPROM content is stored\n"
" Example: --eeprom=/tmp/riot_native.eeprom\n");
#endif
#ifdef MODULE_NETDEV_TAP
real_printf(
" -w <tap>\n"
" Add a tap interface as a wireless interface\n");
#endif
real_exit(status);
}
@ -468,6 +476,9 @@ __attribute__((constructor)) static void startup(int argc, char **argv, char **e
_native_id = _native_pid;
int c, opt_idx = 0, uart = 0;
#ifdef MODULE_NETDEV_TAP
unsigned taps = 0;
#endif
#ifdef MODULE_SOCKET_ZEP
unsigned zeps = 0;
#endif
@ -575,6 +586,13 @@ __attribute__((constructor)) static void startup(int argc, char **argv, char **e
strncpy(eeprom_file, optarg, EEPROM_FILEPATH_MAX_LEN);
break;
}
#endif
#ifdef MODULE_NETDEV_TAP
case 'w':
netdev_tap_params[taps].tap_name = &argv[optind - 1];
netdev_tap_params[taps].wired = false;
++taps;
break;
#endif
default:
usage_exit(EXIT_FAILURE);
@ -582,7 +600,7 @@ __attribute__((constructor)) static void startup(int argc, char **argv, char **e
}
}
#ifdef MODULE_NETDEV_TAP
for (int i = 0; i < NETDEV_TAP_MAX; i++) {
for (unsigned i = 0; i < NETDEV_TAP_MAX - taps; i++) {
if (argv[optind + i] == NULL) {
/* no tap parameter left */
usage_exit(EXIT_FAILURE);
@ -653,9 +671,9 @@ __attribute__((constructor)) static void startup(int argc, char **argv, char **e
native_cpu_init();
native_interrupt_init();
#ifdef MODULE_NETDEV_TAP
for (int i = 0; i < NETDEV_TAP_MAX; i++) {
netdev_tap_params[i].tap_name = &argv[optind + i];
netdev_tap_params[i].wired = true;
for (unsigned i = 0; taps < NETDEV_TAP_MAX; ++taps, ++i) {
netdev_tap_params[taps].tap_name = &argv[optind + i];
netdev_tap_params[taps].wired = true;
}
#endif