ITS
CommonHeader.cpp
Go to the documentation of this file.
1 #include "CommonHeader.h"
2 
4 {
9  m_flags = 0;
10  m_payloadLength = 0;
12  m_reserved = 0;
13 }
14 
15 CommonHeader::CommonHeader(quint8 nextHeader, enum e_headerType headerType, quint8 headerSubType, TrafficClass trafficClass, quint8 flags, quint16 payloadLength, quint8 maximumHopLimit)
16 {
17  m_nextHeader = (nextHeader & 0xF) << 4;
21  m_flags = (flags & 1) << 7;
24  m_reserved = 0;
25 }
26 
27 CommonHeader::CommonHeader(quint8 nextHeader, quint8 headerType_HeaderSubType, TrafficClass trafficClass, quint8 flags, quint16 payloadLength, quint8 maximumHopLimit)
28 {
29  m_nextHeader = (nextHeader & 0xF) << 4;
32  m_flags = (flags & 1) << 7;
35  m_reserved = 0;
36 }
37 
39 {
40  this->m_nextHeader = other.nextHeader();
42  this->m_trafficClass = other.trafficClass();
43  this->m_flags = other.flags();
44  this->m_payloadLength = other.payloadLength();
45  this->m_maximumHopLimit = other.maximumHopLimit();
46  m_reserved = 0;
47 }
48 
50 {
54  m_flags = ch.flags;
57 }
58 
59 QByteArray CommonHeader::toHex()
60 {
61  QByteArray hex;
62  QDataStream ds(&hex, QIODevice::WriteOnly);
63 
64  ds << m_nextHeader;
66  ds.writeRawData(m_trafficClass.toHex().data(), TrafficClass::helper_size);
67  ds << m_flags;
68  ds << m_payloadLength;
69  ds << m_maximumHopLimit;
70  ds << m_reserved;
71 
72  return hex;
73 }
QByteArray toHex()
toHex Create a QByteArray containing the hexadecimal format of the CommonHeader.
Common Header structure.
TrafficClass m_trafficClass
Definition: CommonHeader.h:228
quint8 m_nextHeader
Definition: CommonHeader.h:226
quint8 m_flags
Definition: CommonHeader.h:229
quint8 m_headerType_HeaderSubType
Definition: CommonHeader.h:227
quint8 m_maximumHopLimit
Definition: CommonHeader.h:231
quint16 payloadLength() const
payloadLength Payload length field getter.
Definition: CommonHeader.h:218
#define SWAP16(nb)
Definition: api.h:41
quint8 SCF_ChannelOffload_TCID
Definition: TrafficClass.h:25
quint8 headerType_HeaderSubType
Definition: CommonHeader.h:32
e_headerType
The e_headerType enum defines the Header type values.
Definition: CommonHeader.h:65
quint8 headerType() const
headerType Header field getter.
Definition: CommonHeader.h:193
quint8 m_reserved
Definition: CommonHeader.h:232
TrafficClass trafficClass() const
trafficClass Traffic class field getter.
Definition: CommonHeader.h:203
quint8 flags() const
flags Flags field getter.
Definition: CommonHeader.h:208
quint16 m_payloadLength
Definition: CommonHeader.h:230
sniff_trafficClass_t trafficClass
Definition: CommonHeader.h:33
CommonHeader()
CommonHeader Default constructor.
Definition: CommonHeader.cpp:3
quint8 headerSubType() const
headerSubType Header sub-type field getter.
Definition: CommonHeader.h:198
quint8 nextHeader() const
nextHeader Next header field getter.
Definition: CommonHeader.h:182
QByteArray toHex()
toHex Encode the TrafficClass in binary.
The sniff_commonHeader_t is a C version of the class.
Definition: CommonHeader.h:29
quint8 maximumHopLimit() const
maximumHopLimit Maximum hop limit field getter.
Definition: CommonHeader.h:223
quint8 headerType_HeaderSubType() const
headerType_HeaderSubType Header type + header sub-type fields getter.
Definition: CommonHeader.h:187