-
Notifications
You must be signed in to change notification settings - Fork 0
/
Packet.h
56 lines (45 loc) · 1.66 KB
/
Packet.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
#ifndef PACKET_H_
# define PACKET_H_
#include "Payload.hpp"
#include "EthHeader.h"
#include "IPHeader.h"
#include "ITLHeader.h"
namespace Yellow
{
class Packet
{
public:
Packet(void *buff, int len);
~Packet();
const EthHeader &getEthHeader() const;
const IPHeader &getIPHeader() const;
const std::shared_ptr<Yellow::ITLHeader> getTLHeader() const;
template <typename T>
const Payload<T> getPayload() const;
template <typename T>
void setPayload(const Payload<T> &);
std::chrono::high_resolution_clock::time_point &getTimePoint();
void setTimePoint(std::chrono::high_resolution_clock::time_point &tp);
const unsigned char *operator[](int) const;
const int getLenght() const;
private:
unsigned char *buff;
int len;
EthHeader eth;
IPHeader ip;
std::shared_ptr<ITLHeader> tl;
std::chrono::high_resolution_clock::time_point tp;
};
template<typename T>
inline const Payload<T> Packet::getPayload() const
{
int headerlen;
headerlen = eth.getLenght() + ip.getHeaderLenght() + tl->getLenght();
return Payload<T>(buff + headerlen, len - headerlen);
}
template<typename T>
inline void Packet::setPayload(const Payload<T>&)
{
}
}
#endif /* !PACKET_H_ */