-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
41 lines (33 loc) · 868 Bytes
/
main.cpp
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
#include "NAT.h"
const string NAT_FILE = "NAT";
const string FLOW_FILE = "FLOW";
const string OUTPUT_FILE = "OUTPUT";
void translate_flow(const string& fname_flow, const string& fname_out, NAT& nat)
{
ifstream flow(fname_flow);
if (!flow)
cerr << "Error: failed to open flow file for reading" << endl;
ofstream out(fname_out);
if (!out)
cerr << "Error: failed to open output file for writing" << endl;
string addr, new_addr;
while (getline(flow, addr))
{
new_addr = nat.lookup(addr);
// If lookup returns empty string, there was no match
if (new_addr == "") {
out << "No nat match for " << addr << endl;
} else {
out << addr << " -> " << new_addr << endl;
}
}
flow.close();
out.close();
}
int main()
{
NAT nat;
nat.init(NAT_FILE);
translate_flow(FLOW_FILE, OUTPUT_FILE, nat);
return 0;
}