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

Function duplicatePacket

src/modules/wifi/sniffer.cpp:545–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

543}
544
545static wifi_promiscuous_pkt_t *duplicatePacket(const wifi_promiscuous_pkt_t *pkt, uint16_t length) {
546 size_t total = sizeof(wifi_pkt_rx_ctrl_t) + length;
547 uint8_t *buffer = (uint8_t *)heap_caps_malloc(total, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
548 if (!buffer) { buffer = (uint8_t *)heap_caps_malloc(total, MALLOC_CAP_8BIT); }
549 if (!buffer) { buffer = (uint8_t *)malloc(total); }
550 if (!buffer) { return nullptr; }
551 auto *copy = reinterpret_cast<wifi_promiscuous_pkt_t *>(buffer);
552 memcpy(copy, pkt, sizeof(wifi_pkt_rx_ctrl_t));
553 memcpy(buffer + sizeof(wifi_pkt_rx_ctrl_t), pkt->payload, length);
554 copy->rx_ctrl.sig_len = length;
555 return copy;
556}
557
558static void releasePacketCopy(wifi_promiscuous_pkt_t *packet) {
559 if (!packet) return;

Callers 1

snifferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected