-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRouteTable.h
More file actions
51 lines (47 loc) · 1.15 KB
/
Copy pathRouteTable.h
File metadata and controls
51 lines (47 loc) · 1.15 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
/*
* @Author: HZW ZJM CSS
* @Date: 2021-05-11 20:53:32
* @LastEditTime: 2021-05-13 11:14:19
* @Description:
*/
#ifndef _ROUTETABLE_H_
#define _ROUTETABLE_H_
#include <iostream>
#include <vector>
using namespace std;
class RouteTable
{
public:
typedef struct RouteTableEntry
{
long dest_ip_addr;
long next_hop_ip_addr;
int cost;
RouteTableEntry(long _dest_ip_addr, long _next_hop_ip_addr, int _cost)
{
dest_ip_addr = _dest_ip_addr;
next_hop_ip_addr = _next_hop_ip_addr;
cost = _cost;
}
} RouteTableEntry;
void push(long dest_ip_addr, long next_hop_ip_addr, int cost)
{
RouteTableEntry entry(dest_ip_addr, next_hop_ip_addr, cost);
route_table_.push_back(entry);
}
int size()
{
return route_table_.size();
}
RouteTableEntry &operator[](int index)
{
if (index >= 0 && index < route_table_.size())
return route_table_[index];
cerr << "RouteTable: out of range" << endl;
return *(RouteTableEntry *)NULL;
}
void print();
private:
vector<RouteTableEntry> route_table_;
};
#endif