-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrip.h
50 lines (35 loc) · 1.36 KB
/
rip.h
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
#ifndef _RIP_H_
#define _RIP_H_
#include <vector>
#include <string>
#include <map>
using namespace std;
#define NOT_FOUND 0
#define FILE_ERR 1
#define DATA_ERR 2
#define DATA_UNMATCH 3
#define MAX 10000
struct RouterTab{
string dst;
string hop;
int seqNum;
double cost;
};
struct Host{
string name;
int seqNum;
int vectorNum;
};
/*read the data from disk file and get the name of router*/
void ripInit(string filename, map<string, struct RouterTab> &table, map<int, string> &adjTab, struct Host &host);
/*convert the router table to string*/
void ripSend(string &content, map<string, struct RouterTab> &table, struct Host &host);
/*receive the router table from src router and update own table*/
void ripUpdate(struct Host from, map<string, struct RouterTab> &srcTab, map<string, struct RouterTab> &adjTable, map<string, struct RouterTab> &routeTable, struct Host &host);
/*refresh the route table*/
void ripRefresh(map<string, struct RouterTab> &bufferdAdj, map<string, struct RouterTab> &newAdj, map<string, struct RouterTab> &table, struct Host &host);
/*receive the socket content and turn it to map*/
void ripReceive(string content, map<string, struct RouterTab> &srcTab, struct Host &from);
/*print router table*/
void ripPrintTable(map<string, struct RouterTab> &table, int &printNum, struct Host &host);
#endif