A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol
C arduinobluetoothcan-busdebuggingeepromesp32flipperzerogpiohardware-hackingi2cjtagopenocdprotocolspwmradiorfidspisubghzuartwifi
Added ping help
Andrei Vladescub4b08db591a3
diff --git a/src/Abstracts/ANetworkController.cpp b/src/Abstracts/ANetworkController.cppindex fd16b791..2d548266 100644--- a/src/Abstracts/ANetworkController.cpp+++ b/src/Abstracts/ANetworkController.cpp@@ -42,13 +42,46 @@ void ANetworkController::handlePing(const TerminalCommand &cmd)}const std::string host = cmd.getSubcommand();- if (host.empty()) {- terminalView.println("Usage: ping <host|ip>");+ if (host.empty() || host == "-h" || host == "--help") {+ terminalView.println(icmpService.getPingHelp());return;+ }++ auto args = argTransformer.splitArgs(cmd.getArgs());+ int pingCount = 5, pingTimeout = 1000, pingInterval = 200;++ for (int i=0;i<args.size();i++) {+ if (args[i].empty()) continue; // Skip empty args+ auto argument = args[i];+ if (argument == "-h" || argument == "--help") {+ terminalView.println(icmpService.getPingHelp());+ return;+ } else if (argument == "-c") {+ if (++i < args.size()) {+ if (!argTransformer.parseInt(args[i], pingCount) || args[i].empty()) {+ terminalView.println("Invalid count value.");+ return;+ }+ }+ } else if (argument == "-t") {+ if (++i < args.size()) {+ if (!argTransformer.parseInt(args[i], pingTimeout) || args[i].empty()) {+ terminalView.println("Invalid timeout value.");+ return;+ }+ }+ } else if (argument == "-i") {+ if (++i < args.size()) {+ if (!argTransformer.parseInt(args[i], pingInterval) || args[i].empty()) {+ terminalView.println("Invalid interval value.");+ return;+ }+ }+ }}- icmpService.startPingTask(host, 5, 1000, 200);- while (!icmpService.isReady())+ icmpService.startPingTask(host, pingCount, pingTimeout, pingInterval);+ while (!icmpService.isReady())vTaskDelay(pdMS_TO_TICKS(50));terminalView.print(icmpService.getReport());diff --git a/src/Services/ICMPService.cpp b/src/Services/ICMPService.cppindex fb3fda0a..13abb264 100644--- a/src/Services/ICMPService.cpp+++ b/src/Services/ICMPService.cpp@@ -41,6 +41,14 @@ void ICMPService::cleanupICMPService()report.clear();}+std::string ICMPService::getPingHelp() const{+ std::string helpMenu = std::string("Usage: ping <host> [-c <count>] [-t <timeout>] [-i <interval>]\r\nOptions:\r\n ") ++ "\t-c <count> Number of pings (default: 5)\r\n " ++ "\t-t <timeout> Timeout in milliseconds (default: 1000)\r\n" ++ "\t-i <interval> Interval between pings in milliseconds (default: 200)";+ return helpMenu;+}+static bool resolve_ipv4_to_ip_addr(const std::string &targetIP, ip_addr_t &out){// literal first@@ -150,7 +158,7 @@ void ICMPService::startPingTask(const std::string &targetIP, int count, int timethis->report = "--- " + targetIP + " ping statistics ---\r\n";this->report += std::to_string(this->pingTX) + " packets transmitted, ";this->report += std::to_string(this->pingRX) + " received, ";- this->report += std::to_string(this->pingRX * 100 / this->pingTX) + "\% packet loss,";+ this->report += std::to_string(100 - this->pingRX * 100 / this->pingTX) + "\% packet loss,";this->report += " time " + std::to_string(this->pingMedianMs) + " ms\r\n";} else if (this->pingRC == ping_rc_t::ping_resolve_fail) {this->report = "Failed to resolve \"" + targetIP + "\"\r\n";diff --git a/src/Services/ICMPService.h b/src/Services/ICMPService.hindex 72505c6f..6332a14b 100644--- a/src/Services/ICMPService.h+++ b/src/Services/ICMPService.h@@ -33,7 +33,8 @@ public:int lastSent() const { return pingTX; }int lastRecv() const { return pingRX; }const std::string& getReport() const { return report; }-+ std::string getPingHelp() const;+// Task entrystatic void pingAPI(void *pvParams);