mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-13 02:34:48 +08:00
rework ping
This commit is contained in:
parent
bf0ab55833
commit
2f1061f95b
8 changed files with 25 additions and 36 deletions
|
@ -1521,11 +1521,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
case CMD_CAPABILITIES:
|
||||
SendCapabilities();
|
||||
case CMD_PING:
|
||||
if (packet->ng) {
|
||||
reply_ng(CMD_PING, PM3_SUCCESS, packet->data.asBytes, packet->length);
|
||||
} else {
|
||||
reply_mix(CMD_ACK, reply_via_fpc, 0, 0, 0, 0);
|
||||
}
|
||||
reply_ng(CMD_PING, PM3_SUCCESS, packet->data.asBytes, packet->length);
|
||||
break;
|
||||
#ifdef WITH_LCD
|
||||
case CMD_LCD_RESET:
|
||||
|
|
|
@ -606,7 +606,7 @@ static int CmdHFiClassELoad(const char *Cmd) {
|
|||
// Disable fast mode and send a dummy command to make it effective
|
||||
conn.block_after_ACK = false;
|
||||
SendCommandNG(CMD_PING, NULL, 0);
|
||||
WaitForResponseTimeout(CMD_ACK, NULL, 1000);
|
||||
WaitForResponseTimeout(CMD_PING, NULL, 1000);
|
||||
|
||||
PrintAndLogEx(SUCCESS, "sent %d bytes of data to device emulator memory", bytes_sent);
|
||||
return 0;
|
||||
|
@ -2038,7 +2038,7 @@ out:
|
|||
// Disable fast mode and send a dummy command to make it effective
|
||||
conn.block_after_ACK = false;
|
||||
SendCommandNG(CMD_PING, NULL, 0);
|
||||
WaitForResponseTimeout(CMD_ACK, NULL, 1000);
|
||||
WaitForResponseTimeout(CMD_PING, NULL, 1000);
|
||||
|
||||
DropField();
|
||||
free(pre);
|
||||
|
|
|
@ -2027,7 +2027,7 @@ out:
|
|||
// Disable fast mode and send a dummy command to make it effective
|
||||
conn.block_after_ACK = false;
|
||||
SendCommandNG(CMD_PING, NULL, 0);
|
||||
WaitForResponseTimeout(CMD_ACK, NULL, 1000);
|
||||
WaitForResponseTimeout(CMD_PING, NULL, 1000);
|
||||
|
||||
|
||||
if (createDumpFile) {
|
||||
|
|
|
@ -465,22 +465,14 @@ static int CmdStatus(const char *Cmd) {
|
|||
}
|
||||
|
||||
static int CmdPing(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
clearCommandBuffer();
|
||||
PacketResponseNG resp;
|
||||
SendCommandNG(CMD_PING, NULL, 0);
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000))
|
||||
PrintAndLogEx(SUCCESS, "Ping " _GREEN_("successful"));
|
||||
else
|
||||
PrintAndLogEx(WARNING, "Ping " _RED_("failed"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdPingNG(const char *Cmd) {
|
||||
uint32_t len = strtol(Cmd, NULL, 0);
|
||||
if (len > PM3_CMD_DATA_SIZE)
|
||||
len = PM3_CMD_DATA_SIZE;
|
||||
PrintAndLogEx(INFO, "PingNG sent with payload len=%d", len);
|
||||
if (len) {
|
||||
PrintAndLogEx(INFO, "Ping sent with payload len=%d", len);
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "Ping sent");
|
||||
}
|
||||
clearCommandBuffer();
|
||||
PacketResponseNG resp;
|
||||
uint8_t data[PM3_CMD_DATA_SIZE] = {0};
|
||||
|
@ -489,11 +481,14 @@ static int CmdPingNG(const char *Cmd) {
|
|||
SendCommandNG(CMD_PING, data, len);
|
||||
if (WaitForResponseTimeout(CMD_PING, &resp, 1000)) {
|
||||
bool error = false;
|
||||
if (len)
|
||||
if (len) {
|
||||
error = memcmp(data, resp.data.asBytes, len) != 0;
|
||||
PrintAndLogEx((error)? ERR:SUCCESS, "PingNG response received, content is %s", error ? _RED_("NOT ok") : _GREEN_("ok"));
|
||||
PrintAndLogEx((error)? ERR:SUCCESS, "Ping response " _GREEN_("received") "and content is %s", error ? _RED_("NOT ok") : _GREEN_("ok"));
|
||||
} else {
|
||||
PrintAndLogEx((error)? ERR:SUCCESS, "Ping response " _GREEN_("received"));
|
||||
}
|
||||
} else
|
||||
PrintAndLogEx(WARNING, "PingNG response " _RED_("timeout"));
|
||||
PrintAndLogEx(WARNING, "Ping response " _RED_("timeout"));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -538,8 +533,7 @@ static command_t CommandTable[] = {
|
|||
{"fpgaoff", CmdFPGAOff, IfPm3Present, "Set FPGA off"},
|
||||
{"lcd", CmdLCD, IfPm3Lcd, "<HEX command> <count> -- Send command/data to LCD"},
|
||||
{"lcdreset", CmdLCDReset, IfPm3Lcd, "Hardware reset LCD"},
|
||||
{"ping", CmdPing, IfPm3Present, "Test if the Proxmark3 is responding"},
|
||||
{"pingng", CmdPingNG, IfPm3Present, "Test if the Proxmark3 is responsive, using new frame format (experimental)"},
|
||||
{"ping", CmdPing, IfPm3Present, "Test if the Proxmark3 is responsive"},
|
||||
{"readmem", CmdReadmem, IfPm3Present, "[address] -- Read memory at decimal address from flash"},
|
||||
{"reset", CmdReset, IfPm3Present, "Reset the Proxmark3"},
|
||||
{"setlfdivisor", CmdSetDivisor, IfPm3Present, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"},
|
||||
|
|
|
@ -87,12 +87,12 @@ static int usage_lf_awid_brute(void) {
|
|||
}
|
||||
|
||||
static bool sendPing(void) {
|
||||
SendCommandMIX(CMD_PING, 1, 2, 3, NULL, 0);
|
||||
SendCommandMIX(CMD_PING, 1, 2, 3, NULL, 0);
|
||||
SendCommandMIX(CMD_PING, 1, 2, 3, NULL, 0);
|
||||
SendCommandNG(CMD_PING, NULL, 0);
|
||||
SendCommandNG(CMD_PING, NULL, 0);
|
||||
SendCommandNG(CMD_PING, NULL, 0);
|
||||
clearCommandBuffer();
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000))
|
||||
if (!WaitForResponseTimeout(CMD_PING, &resp, 1000))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -93,12 +93,12 @@ static int usage_lf_hid_brute(void) {
|
|||
|
||||
// sending three times. Didn't seem to break the previous sim?
|
||||
static bool sendPing(void) {
|
||||
SendCommandMIX(CMD_PING, 1, 2, 3, NULL, 0);
|
||||
SendCommandMIX(CMD_PING, 1, 2, 3, NULL, 0);
|
||||
SendCommandMIX(CMD_PING, 1, 2, 3, NULL, 0);
|
||||
SendCommandNG(CMD_PING, NULL, 0);
|
||||
SendCommandNG(CMD_PING, NULL, 0);
|
||||
SendCommandNG(CMD_PING, NULL, 0);
|
||||
clearCommandBuffer();
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000))
|
||||
if (!WaitForResponseTimeout(CMD_PING, &resp, 1000))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -608,7 +608,6 @@ int TestProxmark(void) {
|
|||
return PM3_EIO;
|
||||
|
||||
SendCommandNG(CMD_CAPABILITIES, NULL, 0);
|
||||
|
||||
if (WaitForResponseTimeoutW(CMD_PING, &resp, 1000, false)) {
|
||||
memcpy(&pm3_capabilities, resp.data.asBytes, resp.length);
|
||||
conn.send_via_fpc_usart = pm3_capabilities.via_fpc;
|
||||
|
|
|
@ -46,7 +46,7 @@ static int l_fast_push_mode(lua_State *L) {
|
|||
// Disable fast mode and send a dummy command to make it effective
|
||||
if (enable == false) {
|
||||
SendCommandNG(CMD_PING, NULL, 0);
|
||||
WaitForResponseTimeout(CMD_ACK, NULL, 1000);
|
||||
WaitForResponseTimeout(CMD_PING, NULL, 1000);
|
||||
}
|
||||
|
||||
//Push the retval on the stack
|
||||
|
|
Loading…
Reference in a new issue