All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
packet-defines.h
Go to the documentation of this file.
1 #ifndef PACKET_DEFINES_H_
2 #define PACKET_DEFINES_H_
3 
4 #pragma pack(push,2)
5 
7 struct TIPAddr
8 {
9  union
10  {
11  uint64_t ui64addr[2];
13  uint16_t ui16addr[8];
14  uint8_t ui8addr[16];
15  struct
16  {
19  };
20  };
21 
22 #ifdef __cplusplus
23  // constructors
24  TIPAddr() {} // default constructor
25 
26  TIPAddr(uint32_t ui32Ip) // conversion constructor for casting
27  {
28  if (ui32Ip)
29  {
30  ui64addr[0] = 0;
31  ui32addr[2] = 0xFFFF;
32  ui32addr[3] = ui32Ip;
33  }
34  else
35  ui64addr[0] = ui64addr[1] = 0;
36  }
37 
38  TIPAddr(uint64_t ui64Ip1, uint64_t ui64Ip2)
39  {
40  ui64addr[0] = ui64Ip1;
41  ui64addr[1] = ui64Ip2;
42  }
43 
44  // Operators
45  void operator=(const uint32_t& ulIp)
46  {
47  if (ulIp)
48  {
49  this->ui64addr[0] = 0;
50  this->ui32addr[2] = 0xFFFF;
51  this->ui32addr[3] = ulIp;
52  }
53  else
54  this->ui64addr[0] = this->ui64addr[1] = 0;
55 
56  }
57 
58  void operator=(const TIPAddr &T)
59  {
60  this->ui64addr[0] = T.ui64addr[0];
61  this->ui64addr[1] = T.ui64addr[1];
62  }
63 
64  bool operator==(const TIPAddr &T) const
65  {
66  return ((T.ui64addr[0] == this->ui64addr[0]) && (T.ui64addr[1] == this->ui64addr[1])) ? true : false;
67  }
68 
69  bool operator!=(const TIPAddr &T) const
70  {
71  return ((T.ui64addr[0] != this->ui64addr[0]) || (T.ui64addr[1] != this->ui64addr[1])) ? true : false;
72  }
73 
74  TIPAddr operator& (const TIPAddr &T) const
75  {
76  TIPAddr tIPAddr;
77  tIPAddr.ui64addr[0] = this->ui64addr[0] & T.ui64addr[0];
78  tIPAddr.ui64addr[1] = this->ui64addr[1] & T.ui64addr[1];
79  return tIPAddr;
80  }
81 
82  bool IsZero(void) const
83  {
84  if (IsMappedAddress())
85  {
86  return (ui32IPV4Addr==0) ? true : false;
87  }
88  return (ui64addr[0]==0 && ui64addr[1]==0) ? true : false;
89  }
90 
91  bool IsMappedAddress(void) const
92  {
93  return (ui32addr[0]==0x0 && ui32addr[1]==0x0 && ui32addr[2]==0xFFFF) ? true : false;
94  }
95 
97  {
98  TIPAddr tIPAddr;
99  tIPAddr.ui32addr[0] = 0;
100  tIPAddr.ui32addr[1] = 0;
101  tIPAddr.ui32addr[2] = 0xFFFF;
102  tIPAddr.ui32addr[3] = ui32IPV4Addr;
103  return tIPAddr;
104  }
105 
106 #endif
107 };
108 
109 typedef struct
110 {
111  uint16_t ui16DestMACMSB;
112  uint16_t ui16DestMACNSB;
113  uint16_t ui16DestMACLSB;
114 
115  uint16_t ui16SrcMACMSB;
116  uint16_t ui16SrcMACNSB;
117  uint16_t ui16SrcMACLSB;
118 
119  uint16_t ui16EtherType;
121 
122 typedef struct
123 {
124  uint16_t ui16DestMACMSB;
125  uint16_t ui16DestMACNSB;
126  uint16_t ui16DestMACLSB;
127 
128  uint16_t ui16SrcMACMSB;
129  uint16_t ui16SrcMACNSB;
130  uint16_t ui16SrcMACLSB;
131 
132  uint16_t ui16VLANID8100;
133  uint16_t ui16VLANTag;
134 
135  uint16_t ui16EtherType;
137 
138 typedef struct
139 {
144  uint16_t ui16Opcode;
145  uint16_t ui16SrcMACMSB;
146  uint16_t ui16SrcMACNSB;
147  uint16_t ui16SrcMACLSB;
149  uint16_t ui16DestMACMSB;
150  uint16_t ui16DestMACNSB;
151  uint16_t ui16DestMACLSB;
153 }TARPHeader;
154 
155 typedef struct
156 {
157  uint8_t ui8Version_IHL;
158  uint8_t ui8Services;
159  uint16_t ui16Length;
162  uint8_t ui8TTL;
163  uint8_t ui8Protocol;
164  uint16_t ui16Checksum;
166  uint16_t ui16SourceIPLow;
167  uint16_t ui16DestIPHigh;
168  uint16_t ui16DestIPLow;
169 } TIPHeader;
170 
171 typedef struct
172 {
173  uint16_t ui16SourcePort;
174  uint16_t ui16DestPort;
175  uint16_t ui16Length;
176  uint16_t ui16Checksum;
177 } TUDPHeader;
178 
179 typedef struct
180 {
181  uint8_t ui8VerPXCC; // Version, Padding, Extension, CC
182  uint8_t ui8PayloadType;
185  uint32_t SSRC; // Synchronisation Source
186 }TRTPHeader;
187 
188 typedef struct
189 {
190  uint8_t ui8Type;
191  uint8_t ui8Code;
192  uint16_t ui16Checksum;
193 }TICMPHeader;
194 
195 #pragma pack(pop)
196 #endif /*PACKET_DEFINES_H_*/
TIPAddr(uint64_t ui64Ip1, uint64_t ui64Ip2)
uint16_t ui16SourceIPLow
uint16_t ui16DestMACNSB
uint16_t ui16Checksum
uint8_t ui8VerPXCC
uint8_t ui8ProtocollAddLength
bool IsZero(void) const
TIPAddr(uint32_t ui32Ip)
uint64_t ui64addr[2]
IPV6 address as a 2 x 64 bit value.
uint16_t ui16Checksum
uint16_t ui16SrcMACMSB
bool operator!=(const TIPAddr &T) const
uint16_t ui16Opcode
uint8_t ui8Version_IHL
uint16_t ui16SourcePort
bool IsMappedAddress(void) const
TIPAddr operator&(const TIPAddr &T) const
Struct contains an IPV4 or an IPV6 address.
Definition: packet-defines.h:7
uint16_t ui16ProtocolType
uint16_t ui16Checksum
uint16_t ui16Length
uint8_t ui8Protocol
uint16_t ui16Flags_Offset
uint8_t ui8TTL
uint32_t ui32addr[4]
IPV6 address as a 4 x 32 bit value.
uint16_t ui16DestMACLSB
uint32_t ui32DestinationIPAddress
uint16_t ui16DestIPHigh
uint16_t ui16HardwareType
uint16_t ui16DestPort
uint8_t ui8PayloadType
uint16_t ui16Length
uint8_t ui8Type
uint32_t ui32SourceIPAddress
TIPAddr GetIpv6MappedAddress(void) const
uint32_t ui32IPV4Addr
IPV4 address.
uint8_t ui8addr[16]
IPV6 address as a 16 x 8 bit value.
uint8_t ui8Code
void operator=(const uint32_t &ulIp)
uint16_t ui16Indentification
uint8_t ui8HardwareAddLength
uint16_t ui16DestMACLSB
uint16_t ui16addr[8]
IPV6 address as a 8 x 16 bit value.
uint16_t ui16EtherType
uint8_t ui8Services
uint16_t ui16SrcMACMSB
uint16_t ui16DestMACMSB
uint16_t ui16DestIPLow
uint32_t SSRC
uint16_t ui16SrcMACNSB
uint16_t ui16SrcMACLSB
uint16_t ui16SourceIPHigh
bool operator==(const TIPAddr &T) const
void operator=(const TIPAddr &T)
uint16_t ui16DestMACMSB
uint16_t ui16DestMACNSB
uint16_t ui16SrcMACLSB
uint32_t ui32Dummy[3]
uint32_t ui32TimeStamp
uint16_t ui16SrcMACNSB
uint16_t ui16SequenceNumber