-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
45 lines (40 loc) · 1.39 KB
/
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
42
43
44
45
// "ndvp" stands for "New Distance Vector Protocol"
#include <iostream>
#include <string>
#include "ndvp/ndvp.h"
#include "nap/nap.h"
#include "ndvp/util.h"
#define AS_NUMBER 33
#define MASK "255.255.0.0"
// NetworkSystem 0 [0-2] router-id [local_ip] [0-1]
// NetworkSystem 1 server_ip
// NetworkSystem 2 egress_ip
int main(int argc,char *argv[]) {
if (atoi(argv[1]) == 0)
{
int proto_type = atoi(argv[2]);
int router_id = atoi(argv[3]);
std::cout << "This is router[" << router_id << "]" << std::endl;
std::vector<std::pair<const char*, const char*>> local_ip;
for (int i = 4;i < argc-1;i++) {
const char* ip = argv[i];
const char* mask = MASK;
std::cout << "ip:[" << ip << "], mask:[" << mask << "]" << std::endl;
local_ip.emplace_back(ip, mask);
}
auto r = std::make_shared<Router>(router_id,AS_NUMBER,local_ip,proto_type);
auto s = std::make_shared<Server>(r);
if (atoi(argv[argc-1]) == 1) {
r->Shell();
}
}
else if (atoi(argv[1]) == 1) {
std::string server_addr = std::string(argv[2]);
auto c = std::make_shared<Client>(server_addr);
}
else if (atoi(argv[1]) == 2) {
std::string egress_addr = std::string(argv[2]);
int server_id = atoi(argv[3]);
auto c = std::make_shared<Router>(egress_addr, server_id);
}
}