// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: MIT-0 #ifndef GWAPPLIANCE_UDPPACKETRECEIVER_H #define GWAPPLIANCE_UDPPACKETRECEIVER_H #include #include #include #include "utils.h" typedef std::function udpCallback; class UDPPacketReceiverThread { public: UDPPacketReceiverThread(); ~UDPPacketReceiverThread(); void setup(int threadNumberParam, int coreNumberParam, uint16_t portNumberParam, udpCallback recvDispatcherParam); bool healthCheck(); std::string status(); void shutdown(); bool setupCalled; private: int sock; uint16_t portNumber; int threadNumber; int coreNumber; bool shutdownRequested; pid_t threadId; std::future thread; udpCallback recvDispatcher; int threadFunction(); std::atomic lastPacket; std::atomic pktsIn, bytesIn; }; class UDPPacketReceiver { public: UDPPacketReceiver(); ~UDPPacketReceiver(); void setup(ThreadConfig threadConfig, uint16_t portNumberParam, udpCallback recvDispatcherParam); bool healthCheck(); std::string status(); void shutdown(); private: uint16_t portNumber; std::array threads; }; #endif //GWAPPLIANCE_UDPPACKETRECEIVER_H