Debian Codegraph @

protolib/src/common/protoPktETH.cpp

raw
1 /**
2 * @file protoPketETH.cpp
3 *
4 * @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
5 */
6 #include "protoPktETH.h"
7
8 ProtoPktETH::ProtoPktETH(void* bufferPtr,
9 unsigned int numBytes,
10 bool freeOnDestruct)
11 : ProtoPkt(bufferPtr, numBytes, freeOnDestruct)
12 {
13 }
14
15 ProtoPktETH::~ProtoPktETH()
16 {
17 }
18
19 bool ProtoPktETH::InitIntoBuffer(void* bufferPtr,
20 unsigned int bufferBytes,
21 bool freeOnDestruct)
22 {
23 if (NULL != bufferPtr)
24 {
25 if (bufferBytes < 14)
26 return false;
27 else
28 AttachBuffer(bufferPtr, bufferBytes, freeOnDestruct);
29 }
30 else if (GetBufferLength() < 14)
31 {
32 return false;
33 }
34 memset(AccessBuffer(), 0, 14);
35 SetLength(14);
36 return true;
37 } // end ProtoPktETH::InitIntoBuffer()