-
Notifications
You must be signed in to change notification settings - Fork 0
/
iprouter.h
63 lines (47 loc) · 1.23 KB
/
iprouter.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
51
52
53
54
55
56
57
58
59
60
61
#include "datagram.h"
#include <vector>
#include <string>
#include <fstream>
#pragma once
class IpRouter {
private:
// Properties
std::vector<Datagram*> datagrams;
const char* packetsFile;
const char* outFile;
const char* routingFile;
std::ifstream packetsFS;
public:
// Methods
/**
* Takes the names of the files used and stores them in the
* object opening filestreams when appropriate.
*/
IpRouter(const char* packetsFile, const char* routingFile, const char* outFile);
/**
* Destructor, deallocate packets
*/
~IpRouter();
/**
* Reads the next packet from the packets file and returns a Datagram
* struct with the data fields assigned.
*/
Datagram* readPacket();
/**
* Gets all packets, checks for if they are valid, and stores the
* valid ones in the datagrams vector.
*/
void getPackets();
/**
* Output error message that packet has been dropped for reason given.
*/
void outputError(Datagram packet, std::string error);
/**
* Output the results of the ip routing to the terminal.
*/
void getResults();
/**
* Writes packets to file
*/
void writePackets();
};