ITS
GBCPacket.cpp
Go to the documentation of this file.
1 #include "GBCPacket.h"
2 
4 {
5  m_reserved = 0;
6 }
7 
8 GBCPacket::GBCPacket(quint16 sequenceNumber, LongPositionVector lpv, DestinationArea da)
9 {
11  m_reserved = 0;
12  m_soPv = lpv;
13  m_destinationArea = da;
14 }
15 
17 {
18  this->m_sequenceNumber = other.m_sequenceNumber;
19  this->m_reserved = other.m_reserved;
20  this->m_soPv = other.soPv();
22 }
23 
25 {
26  this->m_sequenceNumber = other.m_sequenceNumber;
27  this->m_reserved = other.m_reserved;
28  this->m_soPv = other.soPv();
30  return *this;
31 }
32 
33 bool GBCPacket::operator==(const GBCPacket &other)
34 {
36 }
37 
38 
40 {
41 }
42 
43 quint64 GBCPacket::extract(uchar* packet)
44 {
45  quint64 offset = 0;
46 
47  offset += get_UINT16(packet + offset, &m_sequenceNumber);
48  offset += get_UINT16(packet + offset, &m_reserved);
49  offset += m_soPv.extract(packet + offset);
50  offset += m_destinationArea.extract(packet + offset);
51 
52  return offset;
53 }
54 
55 QByteArray GBCPacket::toHex()
56 {
57  QByteArray hex;
58  QDataStream ds(&hex, QIODevice::WriteOnly);
59 
61  ds.writeRawData(m_soPv.toHex().data(), LongPositionVector::helper_size);
62  ds.writeRawData(m_destinationArea.toHex().data(), DestinationArea::helper_size);
63 
64  return hex;
65 }
bool operator==(const GBCPacket &other)
operator== GBCPacket equal operator.
Definition: GBCPacket.cpp:33
quint64 extract(uchar *packet)
extract Extract GBC from packet.
Definition: GBCPacket.cpp:43
LongPositionVector soPv() const
soPv SO PV getter.
Definition: GBCPacket.h:95
quint32 timestamp() const
timestamp Timestamp field getter
quint16 sequenceNumber() const
sequenceNumber Sequence number getter.
Definition: GBCPacket.h:90
GBCPacket()
GBCPacket GBCPacket constructor.
Definition: GBCPacket.cpp:3
LongPositionVector m_soPv
Definition: GBCPacket.h:116
bool isDuplicatePacketDetectionTimestampSN(quint32 lastReceivedTimestamp, quint32 nowReceivedTimestamp, quint16 lastReceivedSN, quint16 nowReceivedSN)
isDuplicatePacketDetectionTimestamp Calculate if the packet is a duplicate using the timestamp and th...
Definition: apiNetwork.cpp:104
quint64 extract(uchar *packet)
extract Fill the LongPositionVector with values contained in the packet
quint16 m_reserved
Definition: GBCPacket.h:115
DestinationArea m_destinationArea
Definition: GBCPacket.h:117
GBCPacket operator=(const GBCPacket &other)
operator= GBCPacket affectation operator.
Definition: GBCPacket.cpp:24
GBC packet structure.
quint16 m_sequenceNumber
Definition: GBCPacket.h:114
~GBCPacket()
~GBCPacket The GBCPacket destructor.
Definition: GBCPacket.cpp:39
quint64 get_UINT16(u_char *field, quint16 *uint16)
get_INT64 Extract an integer encoded in 64 bits from a byte array.
Definition: apiNetwork.cpp:69
QByteArray toHex()
toHex Create a QByteArray containing the hexadecimal format of the DestinationArea.
QByteArray toHex()
toHex Create a QByteArray containing the hexadecimal format of the LongPositionVector.
quint64 extract(uchar *packet)
extract Extract DestinationArea from byte array.
QByteArray toHex()
toHex Create a QByteArray containing the hexadecimal format of the GBCPacket.
Definition: GBCPacket.cpp:55