ITS
GnAddr.cpp
Go to the documentation of this file.
1 #include "GnAddr.h"
2 
4 {
6  for(int i = 0 ; i < 6 ; i++)
7  m_mid[i] = 0x00;
8 }
9 
10 GnAddr::GnAddr(quint8 manually, quint8 stationType, quint16 stationCountryCode, quint8 *mid)
11 {
15  for(int i = 0 ; i < 6 ; i++)
16  m_mid[i] = mid[i];
17 }
18 
19 GnAddr::GnAddr(quint16 mStationTypeStationCountryCode, quint8 *mid)
20 {
21  m_StationType_StationCountryCode = mStationTypeStationCountryCode;
22  for(int i = 0 ; i < 6 ; i++)
23  m_mid[i] = mid[i];
24 }
25 
27 {
29  for(int i = 0 ; i < 6 ; i++)
30  m_mid[i] = gnAddr.mid[i];
31 }
32 
33 GnAddr::GnAddr(QByteArray gnAddr)
34 {
35  extract((uchar*)gnAddr.data());
36 }
37 
38 GnAddr::GnAddr(const GnAddr &other)
39 {
41  for(int i = 0 ; i < 6 ; i++)
42  this->m_mid[i] = other.m_mid[i];
43 }
44 
45 bool GnAddr::operator==(const GnAddr &g2) const
46 {
47  bool b = true;
48 
49  for(int i=0; i<6; i++)
50  if(this->m_mid[i] != g2.m_mid[i])
51  b = false;
52  return (b && this->MStationTypeCountryCode() == g2.MStationTypeCountryCode());
53 }
54 
55 quint64 GnAddr::extract(uchar* packet)
56 {
57  quint64 offset = 0;
58 
59  offset += get_UINT16(packet, &m_StationType_StationCountryCode);
60  for(int i=0; i<6; i++)
61  {
62  m_mid[i] = *(packet + offset);
63  offset++;
64  }
65  return offset;
66 }
67 
68 #include <QDebug>
69 QByteArray GnAddr::toHex()
70 {
71  QByteArray hex;
72  QDataStream ds(&hex, QIODevice::WriteOnly);
73 
75  for(int i = 0 ; i < 6 ; i++)
76  ds << m_mid[i];
77 
78  return hex;
79 }
GeoNet Address class.
quint8 manually() const
manually Manually field getter (1 bit).
Definition: GnAddr.h:101
quint8 m_mid[6]
Definition: GnAddr.h:138
quint16 m_StationType_StationCountryCode
setMID
Definition: GnAddr.h:137
quint8 * mid()
mid MID field getter.
Definition: GnAddr.h:121
quint16 MStationTypeCountryCode() const
MStationTypeCountryCode Manually StationType CountryCode field getter.
Definition: GnAddr.h:116
quint64 extract(uchar *packet)
extract Fill the GnAddr with values contained in the packet.
Definition: GnAddr.cpp:55
quint16 stationType_StationCountryCode
Definition: GnAddr.h:24
QByteArray toHex()
toHex Create a QByteArray containing the hexadecimal format of the GnAddr.
Definition: GnAddr.cpp:69
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
quint16 stationCountryCode() const
stationCountryCode Station Country Code field getter (10 bits).
Definition: GnAddr.h:111
quint8 stationType() const
stationType Station Type field getter (5 bits).
Definition: GnAddr.h:106
Definition: GnAddr.h:28
GnAddr()
GnAddr Default constructor.
Definition: GnAddr.cpp:3
The sniff_gnAddr_t structure is the C style of the class.
Definition: GnAddr.h:22
bool operator==(const GnAddr &g2) const
operator == Overload of the == operator.
Definition: GnAddr.cpp:45
quint8 mid[6]
Definition: GnAddr.h:25