forked from osmocom/wireshark
androiddump: Set socket connect() timeout to 500ms
This should avoid neverending or long time to obtain timeout in some cases like firewall's drop rules, etc. Bump version to 1.0.4 Bug: 13104 Ping-Bug: 13114 Change-Id: I9bef714b6d92b3516a2a95ebdbe1ba594fa60e34 Reviewed-on: https://code.wireshark.org/review/18728 Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com> Reviewed-by: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
parent
51bdba4c1f
commit
720927a10e
|
@ -98,13 +98,15 @@
|
|||
|
||||
#define ANDROIDDUMP_VERSION_MAJOR "1"
|
||||
#define ANDROIDDUMP_VERSION_MINOR "0"
|
||||
#define ANDROIDDUMP_VERSION_RELEASE "3"
|
||||
#define ANDROIDDUMP_VERSION_RELEASE "4"
|
||||
|
||||
#define SERIAL_NUMBER_LENGTH_MAX 512
|
||||
#define MODEL_NAME_LENGTH_MAX 64
|
||||
|
||||
#define PACKET_LENGTH 65535
|
||||
|
||||
#define SOCKET_SEND_TIMEOUT_MS 500
|
||||
|
||||
enum exit_code {
|
||||
EXIT_CODE_SUCCESS = 0,
|
||||
EXIT_CODE_CANNOT_GET_INTERFACES_LIST = 1,
|
||||
|
@ -247,6 +249,21 @@ static inline int is_specified_interface(char *interface, const char *interface_
|
|||
return !strncmp(interface, interface_prefix, strlen(interface_prefix));
|
||||
}
|
||||
|
||||
static void useSndTimeout(socket_handle_t sock) {
|
||||
#ifdef _WIN32
|
||||
const DWORD socket_timeout = SOCKET_SEND_TIMEOUT_MS;
|
||||
|
||||
setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (const char *) &socket_timeout, sizeof(socket_timeout));
|
||||
#else
|
||||
const struct timeval socket_timeout = {
|
||||
.tv_sec = SOCKET_SEND_TIMEOUT_MS / 1000,
|
||||
.tv_usec = (SOCKET_SEND_TIMEOUT_MS % 1000) * 1000
|
||||
};
|
||||
|
||||
setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &socket_timeout, sizeof(socket_timeout));
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct extcap_dumper extcap_dumper_open(char *fifo, int encap) {
|
||||
struct extcap_dumper extcap_dumper;
|
||||
int encap_ext;
|
||||
|
@ -386,6 +403,8 @@ static socket_handle_t adb_connect(const char *server_ip, unsigned short *server
|
|||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
useSndTimeout(sock);
|
||||
|
||||
if (connect(sock, (struct sockaddr *) &server, sizeof(server)) == SOCKET_ERROR) {
|
||||
#if 0
|
||||
/* NOTE: This does not work well - make significant delay while initializing Wireshark.
|
||||
|
@ -1537,6 +1556,8 @@ static int capture_android_bluetooth_external_parser(char *interface,
|
|||
server.sin_port = GINT16_TO_BE(*bt_local_tcp_port);
|
||||
server.sin_addr.s_addr = inet_addr(bt_local_ip);
|
||||
|
||||
useSndTimeout(sock);
|
||||
|
||||
if (connect(sock, (struct sockaddr *) &server, sizeof(server)) == SOCKET_ERROR) {
|
||||
g_warning("<%s> Please check that adb daemon is running.", strerror(errno));
|
||||
closesocket(sock);
|
||||
|
@ -1633,6 +1654,8 @@ static int capture_android_bluetooth_external_parser(char *interface,
|
|||
server.sin_port = GINT16_TO_BE(*bt_local_tcp_port);
|
||||
server.sin_addr.s_addr = inet_addr(bt_local_ip);
|
||||
|
||||
useSndTimeout(sock);
|
||||
|
||||
if (connect(sock, (struct sockaddr *) &server, sizeof(server)) == SOCKET_ERROR) {
|
||||
g_warning("ERROR reconnect: <%s> Please check that adb daemon is running.", strerror(errno));
|
||||
closesocket(sock);
|
||||
|
|
Loading…
Reference in New Issue