-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEthHeader.cpp
More file actions
62 lines (50 loc) · 1.14 KB
/
EthHeader.cpp
File metadata and controls
62 lines (50 loc) · 1.14 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
52
53
54
55
56
57
58
59
60
61
62
#include "stdafx.h"
#include "EthHeader.h"
Yellow::EthHeader::EthHeader(void * begin)
: buff(static_cast<unsigned char *>(begin)), eth(static_cast<struct ethhdr *>(begin))
{
}
Yellow::EthHeader::EthHeader(const EthHeader &e)
{
buff = e.buff;
eth = e.eth;
}
Yellow::EthHeader & Yellow::EthHeader::operator=(const EthHeader &e)
{
buff = e.buff;
eth = e.eth;
return (*this);
}
Yellow::EthHeader::~EthHeader()
{
}
void Yellow::EthHeader::setSource(const MACAddress addr)
{
memcpy(eth->h_source, addr, 6);
}
const Yellow::EthHeader::MACAddress Yellow::EthHeader::getSource() const
{
return eth->h_source;
}
void Yellow::EthHeader::setDest(const MACAddress addr)
{
memcpy(eth->h_dest, addr, 6);
}
const Yellow::EthHeader::MACAddress Yellow::EthHeader::getDest() const
{
return eth->h_dest;
}
const unsigned short int Yellow::EthHeader::getProto() const
{
return eth->h_proto;
}
const unsigned char *Yellow::EthHeader::operator[](const int idx) const
{
if (idx >= getLenght())
return NULL;
return &static_cast<const unsigned char *>(buff)[idx];
}
const int Yellow::EthHeader::getLenght() const
{
return sizeof(struct ethhdr);
}