Skip to content

Commit

Permalink
Merge pull request #2219 from wh201906/hw_connect
Browse files Browse the repository at this point in the history
Update connection type in CLI prompt
  • Loading branch information
iceman1001 authored Dec 27, 2023
2 parents abdaf57 + e5dd995 commit 78dfd84
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions client/src/proxmark3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions client/src/proxmark3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 9 additions & 4 deletions client/src/uart/uart_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
13 changes: 9 additions & 4 deletions client/src/uart/uart_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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;
Expand Down

0 comments on commit 78dfd84

Please sign in to comment.