|
6 | 6 |
|
7 | 7 | /// @file |
8 | 8 |
|
9 | | -/** |
10 | | - * \namespace pcpp |
11 | | - * \brief The main namespace for the PcapPlusPlus lib |
12 | | - */ |
| 9 | +/// @namespace pcpp |
| 10 | +/// @brief The main namespace for the PcapPlusPlus lib |
13 | 11 | namespace pcpp |
14 | 12 | { |
15 | | - |
16 | | - /** |
17 | | - * @struct arphdr |
18 | | - * Represents an ARP protocol header |
19 | | - */ |
| 13 | + /// @struct arphdr |
| 14 | + /// Represents an ARP protocol header |
20 | 15 | #pragma pack(push, 1) |
21 | 16 | struct arphdr |
22 | 17 | { |
23 | | - /** Hardware type (HTYPE) */ |
| 18 | + /// Hardware type (HTYPE) |
24 | 19 | uint16_t hardwareType; |
25 | | - /** Protocol type (PTYPE). The permitted PTYPE values share a numbering space with those for EtherType */ |
| 20 | + /// Protocol type (PTYPE). The permitted PTYPE values share a numbering space with those for EtherType |
26 | 21 | uint16_t protocolType; |
27 | | - /** Hardware address length (HLEN). For IPv4, this has the value 0x0800 */ |
| 22 | + /// Hardware address length (HLEN). For IPv4, this has the value 0x0800 |
28 | 23 | uint8_t hardwareSize; |
29 | | - /** Protocol length (PLEN). Length (in octets) of addresses used in the upper layer protocol. (The upper layer |
30 | | - * protocol specified in PTYPE.) IPv4 address size is 4 */ |
| 24 | + /// Protocol length (PLEN). Length (in octets) of addresses used in the upper layer protocol. (The upper layer |
| 25 | + /// protocol specified in PTYPE.) IPv4 address size is 4 |
31 | 26 | uint8_t protocolSize; |
32 | | - /** Specifies the operation that the sender is performing: 1 (::ARP_REQUEST) for request, 2 (::ARP_REPLY) for |
33 | | - * reply */ |
| 27 | + /// Specifies the operation that the sender is performing: 1 (::ARP_REQUEST) for request, 2 (::ARP_REPLY) for |
| 28 | + /// reply |
34 | 29 | uint16_t opcode; |
35 | | - /** Sender hardware address (SHA) */ |
| 30 | + /// Sender hardware address (SHA) |
36 | 31 | uint8_t senderMacAddr[6]; |
37 | | - /** Sender protocol address (SPA) */ |
| 32 | + /// Sender protocol address (SPA) |
38 | 33 | uint32_t senderIpAddr; |
39 | | - /** Target hardware address (THA) */ |
| 34 | + /// Target hardware address (THA) |
40 | 35 | uint8_t targetMacAddr[6]; |
41 | | - /** Target protocol address (TPA) */ |
| 36 | + /// Target protocol address (TPA) |
42 | 37 | uint32_t targetIpAddr; |
43 | 38 | }; |
44 | 39 | #pragma pack(pop) |
45 | 40 |
|
46 | | - /** |
47 | | - * An enum for ARP message type |
48 | | - */ |
| 41 | + /// An enum for ARP message type |
49 | 42 | enum ArpOpcode |
50 | 43 | { |
51 | 44 | ARP_REQUEST = 0x0001, ///< ARP request |
52 | 45 | ARP_REPLY = 0x0002 ///< ARP reply (response) |
53 | 46 | }; |
54 | 47 |
|
55 | | - /** |
56 | | - * @class ArpLayer |
57 | | - * Represents an ARP protocol layer. Currently only IPv4 ARP messages are supported |
58 | | - */ |
| 48 | + /// @class ArpLayer |
| 49 | + /// Represents an ARP protocol layer. Currently only IPv4 ARP messages are supported |
59 | 50 | class ArpLayer : public Layer |
60 | 51 | { |
61 | 52 | public: |
62 | | - /** |
63 | | - * A constructor that creates the layer from an existing packet raw data |
64 | | - * @param[in] data A pointer to the raw data (will be casted to @ref arphdr) |
65 | | - * @param[in] dataLen Size of the data in bytes |
66 | | - * @param[in] prevLayer A pointer to the previous layer |
67 | | - * @param[in] packet A pointer to the Packet instance where layer will be stored in |
68 | | - */ |
| 53 | + /// A constructor that creates the layer from an existing packet raw data |
| 54 | + /// @param[in] data A pointer to the raw data (will be casted to @ref arphdr) |
| 55 | + /// @param[in] dataLen Size of the data in bytes |
| 56 | + /// @param[in] prevLayer A pointer to the previous layer |
| 57 | + /// @param[in] packet A pointer to the Packet instance where layer will be stored in |
69 | 58 | ArpLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet) |
70 | 59 | : Layer(data, dataLen, prevLayer, packet, ARP) |
71 | 60 | { |
72 | 61 | m_DataLen = sizeof(arphdr); |
73 | 62 | } |
74 | 63 |
|
75 | | - /** |
76 | | - * A constructor that allocates a new ARP header |
77 | | - * @param[in] opCode ARP message type (ARP request or ARP reply) |
78 | | - * @param[in] senderMacAddr The sender MAC address (will be put in arphdr#senderMacAddr) |
79 | | - * @param[in] targetMacAddr The target MAC address (will be put in arphdr#targetMacAddr) |
80 | | - * @param[in] senderIpAddr The sender IP address (will be put in arphdr#senderIpAddr) |
81 | | - * @param[in] targetIpAddr The target IP address (will be put in arphdr#targetIpAddr) |
82 | | - */ |
| 64 | + /// A constructor that allocates a new ARP header |
| 65 | + /// @param[in] opCode ARP message type (ARP request or ARP reply) |
| 66 | + /// @param[in] senderMacAddr The sender MAC address (will be put in arphdr#senderMacAddr) |
| 67 | + /// @param[in] targetMacAddr The target MAC address (will be put in arphdr#targetMacAddr) |
| 68 | + /// @param[in] senderIpAddr The sender IP address (will be put in arphdr#senderIpAddr) |
| 69 | + /// @param[in] targetIpAddr The target IP address (will be put in arphdr#targetIpAddr) |
83 | 70 | ArpLayer(ArpOpcode opCode, const MacAddress& senderMacAddr, const MacAddress& targetMacAddr, |
84 | 71 | const IPv4Address& senderIpAddr, const IPv4Address& targetIpAddr); |
85 | 72 |
|
86 | 73 | ~ArpLayer() override = default; |
87 | 74 |
|
88 | | - /** |
89 | | - * Get a pointer to the ARP header. Notice this points directly to the data, so every change will change the |
90 | | - * actual packet data |
91 | | - * @return A pointer to the @ref arphdr |
92 | | - */ |
| 75 | + /// Get a pointer to the ARP header. Notice this points directly to the data, so every change will change the |
| 76 | + /// actual packet data |
| 77 | + /// @return A pointer to the @ref arphdr |
93 | 78 | inline arphdr* getArpHeader() const |
94 | 79 | { |
95 | 80 | return reinterpret_cast<arphdr*>(m_Data); |
96 | 81 | } |
97 | 82 |
|
98 | | - /** |
99 | | - * Get the sender hardware address (SHA) in the form of MacAddress |
100 | | - * @return A MacAddress containing the sender hardware address (SHA) |
101 | | - */ |
| 83 | + /// Get the sender hardware address (SHA) in the form of MacAddress |
| 84 | + /// @return A MacAddress containing the sender hardware address (SHA) |
102 | 85 | inline MacAddress getSenderMacAddress() const |
103 | 86 | { |
104 | 87 | return MacAddress(getArpHeader()->senderMacAddr); |
105 | 88 | } |
106 | 89 |
|
107 | | - /** |
108 | | - * Get the target hardware address (THA) in the form of MacAddress |
109 | | - * @return A MacAddress containing the target hardware address (THA) |
110 | | - */ |
| 90 | + /// Get the target hardware address (THA) in the form of MacAddress |
| 91 | + /// @return A MacAddress containing the target hardware address (THA) |
111 | 92 | inline MacAddress getTargetMacAddress() const |
112 | 93 | { |
113 | 94 | return MacAddress(getArpHeader()->targetMacAddr); |
114 | 95 | } |
115 | 96 |
|
116 | | - /** |
117 | | - * Get the sender protocol address (SPA) in the form of IPv4Address |
118 | | - * @return An IPv4Address containing the sender protocol address (SPA) |
119 | | - */ |
| 97 | + /// Get the sender protocol address (SPA) in the form of IPv4Address |
| 98 | + /// @return An IPv4Address containing the sender protocol address (SPA) |
120 | 99 | inline IPv4Address getSenderIpAddr() const |
121 | 100 | { |
122 | 101 | return getArpHeader()->senderIpAddr; |
123 | 102 | } |
124 | 103 |
|
125 | | - /** |
126 | | - * Get the target protocol address (TPA) in the form of IPv4Address |
127 | | - * @return An IPv4Address containing the target protocol address (TPA) |
128 | | - */ |
| 104 | + /// Get the target protocol address (TPA) in the form of IPv4Address |
| 105 | + /// @return An IPv4Address containing the target protocol address (TPA) |
129 | 106 | inline IPv4Address getTargetIpAddr() const |
130 | 107 | { |
131 | 108 | return getArpHeader()->targetIpAddr; |
132 | 109 | } |
133 | 110 |
|
134 | 111 | // implement abstract methods |
135 | 112 |
|
136 | | - /** |
137 | | - * Does nothing for this layer (ArpLayer is always last) |
138 | | - */ |
| 113 | + /// Does nothing for this layer (ArpLayer is always last) |
139 | 114 | void parseNextLayer() override |
140 | 115 | {} |
141 | 116 |
|
142 | | - /** |
143 | | - * @return The size of @ref arphdr |
144 | | - */ |
| 117 | + /// @return The size of @ref arphdr |
145 | 118 | size_t getHeaderLen() const override |
146 | 119 | { |
147 | 120 | return sizeof(arphdr); |
148 | 121 | } |
149 | 122 |
|
150 | | - /** |
151 | | - * Calculate the following fields: |
152 | | - * - @ref arphdr#hardwareType = Ethernet (1) |
153 | | - * - @ref arphdr#hardwareSize = 6 |
154 | | - * - @ref arphdr#protocolType = ETHERTYPE_IP (assume IPv4 over ARP) |
155 | | - * - @ref arphdr#protocolSize = 4 (assume IPv4 over ARP) |
156 | | - * - if it's an ARP request: @ref arphdr#targetMacAddr = MacAddress("00:00:00:00:00:00") |
157 | | - */ |
| 123 | + /// Calculate the following fields: |
| 124 | + /// - @ref arphdr#hardwareType = Ethernet (1) |
| 125 | + /// - @ref arphdr#hardwareSize = 6 |
| 126 | + /// - @ref arphdr#protocolType = ETHERTYPE_IP (assume IPv4 over ARP) |
| 127 | + /// - @ref arphdr#protocolSize = 4 (assume IPv4 over ARP) |
| 128 | + /// - if it's an ARP request: @ref arphdr#targetMacAddr = MacAddress("00:00:00:00:00:00") |
158 | 129 | void computeCalculateFields() override; |
159 | 130 |
|
160 | | - /** |
161 | | - * Is this packet an ARP request? |
162 | | - */ |
| 131 | + /// Is this packet an ARP request? |
163 | 132 | bool isRequest() const; |
164 | 133 |
|
165 | | - /** |
166 | | - * Is this packet an ARP reply? |
167 | | - */ |
| 134 | + /// Is this packet an ARP reply? |
168 | 135 | bool isReply() const; |
169 | 136 |
|
170 | 137 | std::string toString() const override; |
|
0 commit comments