| 543 | } |
| 544 | |
| 545 | static 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 | |
| 558 | static void releasePacketCopy(wifi_promiscuous_pkt_t *packet) { |
| 559 | if (!packet) return; |