MCPcopy Create free account
hub / github.com/BruceDevices/firmware / classifyEapolMessage

Function classifyEapolMessage

src/modules/wifi/sniffer.cpp:220–244  ·  view source on GitHub ↗

Analyze the EAPOL Message Number

Source from the content-addressed store, hash-verified

218
219// Analyze the EAPOL Message Number
220int classifyEapolMessage(const wifi_promiscuous_pkt_t *pkt) {
221 const uint8_t *payload = pkt->payload;
222 // QoS frames add 2 bytes to MAC header
223 int qosOffset = ((payload[0] & 0x0F) == 0x08) ? 2 : 0;
224
225 // Offset to Key Information field:
226 // MAC header (24 + qosOffset) + LLC/SNAP (8) + EAPOL header (4) + Descriptor Type (1)
227 int keyInfoOffset = 24 + qosOffset + 8 + 4 + 1;
228
229 if (pkt->rx_ctrl.sig_len < keyInfoOffset + 2) return -1; // safety check
230
231 uint16_t keyInfo = (payload[keyInfoOffset] << 8) | payload[keyInfoOffset + 1];
232
233 bool install = keyInfo & (1 << 6);
234 bool ack = keyInfo & (1 << 7);
235 bool mic = keyInfo & (1 << 8);
236 bool secure = keyInfo & (1 << 9);
237
238 if (ack && !mic && !install) return 1; // Message 1
239 if (!ack && mic && !install && !secure) return 2; // Message 2
240 if (ack && mic && install) return 3; // Message 3
241 if (!ack && mic && !install && secure) return 4; // Message 4
242
243 return -1; // Unknown
244}
245
246bool matchesTargetAP(const wifi_promiscuous_pkt_t *pkt, const uint8_t targetBssid[6]) {
247 const uint8_t *payload = pkt->payload;

Callers 1

analyzeFrameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected