-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.cpp
More file actions
71 lines (58 loc) · 1.78 KB
/
Copy pathApp.cpp
File metadata and controls
71 lines (58 loc) · 1.78 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "App.h"
#include <stdlib.h>
namespace libnetin
{
App::App(int& argc, char **argv)
{
for(int i=1; i < argc; i++) {
m_args.push_back(argv[i]);
}
}
void App::test_offline()
{
Pcap::showAll();
m_pcap.offline("/home/ilian/gitprojects/libnetin/Data/mqtt4.pcap");
m_pcap.loop();
}
void App::test_online()
{
}
int App::exec()
{
bool res=false;
if (m_args.size() == 0) {
std::cout << "(libnetin --help) to see usage\r\n";
return -1;
} else {
for(size_t i=0; i < m_args.size(); i++) {
if (m_args[i] == "-l") {
Pcap::showAll();
return 0;
} else if (m_args[i] == "-p"){
for(size_t j=i+1; j < m_args.size(); j++) {
res = m_pcap.offline(m_args[j].c_str());
}
} else if (m_args[i] == "-i") {
res = m_pcap.live(m_args[i+1].c_str());
} else if (m_args[i] == "--no-stun") {
} else if (m_args[i] == "--no-rtp") {
} else if (m_args[i] == "--help"){
std::cout << "Use libnetin -<option> for the following:\r\n"
<< "libnetin -l (List all devices)\r\n"
<<"\t while in live mode press 'q' or 'Q' to stop\r\n"
<< "libnetin -p pcapfile.pcal (Read and analyse pcap contents)\r\n"
<< "libnetin -i <NIC DEVICE> (Open live mode on network card)\r\n"
<<"=============================================================\r\n";
return 0;
} else {
}
}
}
if (res) {
m_pcap.loop();
} else {
std::cerr << "Failed to open pcap\r\n";
}
return res ? 0 : -1;
}
}//ns libnetin