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
/**
* @file protoPketETH.cpp
*
* @brief This is a class that provides access to and control of ETHernet header fields for the associated buffer space. The ProtoPkt "buffer" is presumed to contain a valid ETHernet frame
*/
#include "protoPktETH.h"
ProtoPktETH::ProtoPktETH(void* bufferPtr,
unsigned int numBytes,
bool freeOnDestruct)
: ProtoPkt(bufferPtr, numBytes, freeOnDestruct)
{
}
ProtoPktETH::~ProtoPktETH()
{
}
bool ProtoPktETH::InitIntoBuffer(void* bufferPtr,
unsigned int bufferBytes,
bool freeOnDestruct)
{
if (NULL != bufferPtr)
{
if (bufferBytes < 14)
return false;
else
AttachBuffer(bufferPtr, bufferBytes, freeOnDestruct);
}
else if (GetBufferLength() < 14)
{
return false;
}
memset(AccessBuffer(), 0, 14);
SetLength(14);
return true;
} // end ProtoPktETH::InitIntoBuffer()