From 3aab9a4d043c7c6ba027eae1c267a8b4a2671e7b Mon Sep 17 00:00:00 2001 From: wh201906 Date: Wed, 27 Dec 2023 22:12:45 +0800 Subject: [PATCH 1/2] Update CLI prompt after switching connection type --- CHANGELOG.md | 1 + client/src/proxmark3.c | 2 ++ client/src/proxmark3.h | 1 + 3 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3877e21f70..ab62c38b7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] + - Fixed CLI prompt - Update connection type prompt after running `hw connect` (@wh201906) - Changed `uart_receive()` - Check if TCP connection is lost (@wh201906) - Change `data detectclock` - now tries all clocks if called w/o any params (@iceman1001) - Changed `lf search -1u` - improved the autocorrelation detection for unknown signals (@iceman1001) diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index 0df264d5f3..c308360c2f 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -281,6 +281,8 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) { prompt_net = PROXPROMPT_NET_UDPV6; break; case PM3_NONE: + prompt_net = PROXPROMPT_NET_NONE; + break; default: break; } diff --git a/client/src/proxmark3.h b/client/src/proxmark3.h index f58c7950e0..bc6dcb3e7f 100644 --- a/client/src/proxmark3.h +++ b/client/src/proxmark3.h @@ -39,6 +39,7 @@ #define PROXPROMPT_NET_UDPV4 "|" _RL_BOLD_GREEN_("udp") #define PROXPROMPT_NET_TCPV6 "|" _RL_BOLD_GREEN_("tcp v6") #define PROXPROMPT_NET_UDPV6 "|" _RL_BOLD_GREEN_("udp v6") +#define PROXPROMPT_NET_NONE "" #define PROXHISTORY "history.txt" From e5dd9952d78e6b9a7a6e18cb4da8dd71352a1ba1 Mon Sep 17 00:00:00 2001 From: wh201906 Date: Wed, 27 Dec 2023 22:13:26 +0800 Subject: [PATCH 2/2] Misc Change style of if block with single statement Reset rx_empty_counter in uart_open() --- client/src/uart/uart_posix.c | 13 +++++++++---- client/src/uart/uart_win32.c | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/client/src/uart/uart_posix.c b/client/src/uart/uart_posix.c index c29c728262..325d26abd3 100644 --- a/client/src/uart/uart_posix.c +++ b/client/src/uart/uart_posix.c @@ -90,6 +90,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) { } sp->udpBuffer = NULL; + rx_empty_counter = 0; // init timeouts timeout.tv_usec = UART_FPC_CLIENT_RX_TIMEOUT_MS * 1000; g_conn.send_via_local_ip = false; @@ -157,10 +158,12 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) { } // for bind option, it's possible to only specify address or port - if (strlen(bindAddrStr) == 0) + if (strlen(bindAddrStr) == 0) { bindAddrStr = NULL; - if (bindPortStr != NULL && strlen(bindPortStr) == 0) + } + if (bindPortStr != NULL && strlen(bindPortStr) == 0) { bindPortStr = NULL; + } } const char *addrStr = NULL; @@ -208,8 +211,9 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) { for (rp = addr; rp != NULL; rp = rp->ai_next) { sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); - if (sfd == -1) + if (sfd == -1) { continue; + } if (!uart_bind(&sfd, bindAddrStr, bindPortStr, isBindingIPv6)) { PrintAndLogEx(ERR, "error: Could not bind. errno: %d", errno); @@ -220,8 +224,9 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) { return INVALID_SERIAL_PORT; } - if (connect(sfd, rp->ai_addr, rp->ai_addrlen) != -1) + if (connect(sfd, rp->ai_addr, rp->ai_addrlen) != -1) { break; + } close(sfd); } diff --git a/client/src/uart/uart_win32.c b/client/src/uart/uart_win32.c index 97ecd41bdd..a343936d29 100644 --- a/client/src/uart/uart_win32.c +++ b/client/src/uart/uart_win32.c @@ -93,6 +93,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) { } sp->udpBuffer = NULL; + rx_empty_counter = 0; g_conn.send_via_local_ip = false; g_conn.send_via_ip = PM3_NONE; @@ -149,10 +150,12 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) { } // for bind option, it's possible to only specify address or port - if (strlen(bindAddrStr) == 0) + if (strlen(bindAddrStr) == 0) { bindAddrStr = NULL; - if (bindPortStr != NULL && strlen(bindPortStr) == 0) + } + if (bindPortStr != NULL && strlen(bindPortStr) == 0) { bindPortStr = NULL; + } } const char *addrStr = NULL; @@ -211,8 +214,9 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) { for (rp = addr; rp != NULL; rp = rp->ai_next) { hSocket = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); - if (hSocket == INVALID_SOCKET) + if (hSocket == INVALID_SOCKET) { continue; + } if (!uart_bind(&hSocket, bindAddrStr, bindPortStr, isBindingIPv6)) { PrintAndLogEx(ERR, "error: Could not bind. error: %u", WSAGetLastError()); @@ -225,8 +229,9 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) { return INVALID_SERIAL_PORT; } - if (connect(hSocket, rp->ai_addr, (int)rp->ai_addrlen) != INVALID_SOCKET) + if (connect(hSocket, rp->ai_addr, (int)rp->ai_addrlen) != INVALID_SOCKET) { break; + } closesocket(hSocket); hSocket = INVALID_SOCKET;