diff --git a/monitor/monitor.m b/monitor/monitor.m index 6678f82..f684ea9 100644 --- a/monitor/monitor.m +++ b/monitor/monitor.m @@ -39,7 +39,7 @@ }; int nctl_monitor(int argc, char** argv) { - if (argc < 2) { + if (argc < 1) { errno = EINVAL; errx(1, "not enough args"); } @@ -47,13 +47,13 @@ int nctl_monitor(int argc, char** argv) { BOOL monitorTCP = NO; BOOL monitorUDP = NO; - if (!strcmp(argv[1], "tcp")) { + if (!strcmp(argv[0], "tcp")) { monitorTCP = YES; } - if (!strcmp(argv[1], "udp")) { + if (!strcmp(argv[0], "udp")) { monitorUDP = YES; } - if (!strcmp(argv[1], "all")) { + if (!strcmp(argv[0], "all")) { monitorTCP = YES; monitorUDP = YES; } diff --git a/netctl.c b/netctl.c index e39793f..dc832aa 100644 --- a/netctl.c +++ b/netctl.c @@ -17,18 +17,15 @@ int main(int argc, char *argv[]) { } #if NO_WIFI == 0 - if (!strcmp(argv[1], "wifi")) - return wifi(argc, argv); + if (!strcmp(argv[1], "wifi")) return wifi(argc, argv); #endif #if NO_CELLULAR == 0 - if (!strcmp(argv[1], "cellular")) - return cellular(argc, argv); + if (!strcmp(argv[1], "cellular")) return cellular(argc, argv); #endif #if NO_AIRDROP == 0 - if (!strcmp(argv[1], "airdrop")) - return airdrop(argc, argv); + if (!strcmp(argv[1], "airdrop")) return airdrop(argc, argv); #endif #if NO_AIRPLANE == 0 @@ -37,8 +34,7 @@ int main(int argc, char *argv[]) { #endif #if NO_MONITOR == 0 - if (!strcmp(argv[1], "monitor")) - return nctl_monitor(argc-1, argv+1); + if (!strcmp(argv[1], "monitor")) return nctl_monitor(argc - 2, argv + 2); #endif usage(); @@ -46,5 +42,7 @@ int main(int argc, char *argv[]) { } void usage() { - fprintf(stderr, "Usage: netctl [airdrop | cellular | wifi | monitor] [arguments]\n"); + fprintf( + stderr, + "Usage: netctl [airdrop | cellular | wifi | monitor] [arguments]\n"); }