From fe076d92eca402b27979bacf4062563e759e7279 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Sat, 29 Nov 2014 15:30:09 +0000 Subject: -Fixed a bug in Ping and other small things reported in #837 git-svn-id: http://svn.miranda-ng.org/main/trunk@11151 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Ping/src/rawping.cpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'plugins/Ping/src') diff --git a/plugins/Ping/src/rawping.cpp b/plugins/Ping/src/rawping.cpp index 007200fa23..f31868db5a 100644 --- a/plugins/Ping/src/rawping.cpp +++ b/plugins/Ping/src/rawping.cpp @@ -149,38 +149,48 @@ extern int raw_ping(char *host, int timeout) if (bread == SOCKET_ERROR) { if(WSAGetLastError() != WSAETIMEDOUT) { - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: socket error...cycling"), 0); + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: socket error...cycling"), 0); } continue; } - if(reply_header->proto != ICMP_PROTO) - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: packet not ICMP...cycling"), 0); + if(reply_header->proto != ICMP_PROTO) { + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: packet not ICMP...cycling"), 0); continue; + } - if(reply_header->tos != 0) - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: TOS not 0...cycling"), 0); + if(reply_header->tos != 0) { + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: TOS not 0...cycling"), 0); continue; + } reply = (ICMPHeader *)(recv_buff + reply_header->h_len * 4); if((unsigned)bread < reply_header->h_len * 4 + sizeof(ICMPHeader)) { - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: short header"), 0); + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: short header"), 0); continue; } - if(reply->id != (USHORT)GetCurrentProcessId()) - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong ID...cycling"), 0); + if(reply->id != (USHORT)GetCurrentProcessId()) { + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong ID...cycling"), 0); continue; + } if(reply->type != PT_ICMP_ECHO_REPLY && reply->type != PT_ICMP_SOURCE_QUENCH) { - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong type...cycling"), 0); + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong type...cycling"), 0); continue; } //if(reply->seq < seq_no) continue; //if(reply->seq > seq_no) return -1; if(reply->seq != seq_no) { - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong sequence number...cycling"), 0); + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong sequence number...cycling"), 0); continue; } @@ -197,7 +207,8 @@ extern int raw_ping(char *host, int timeout) } else return current_time - send_time; } - if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: timeout"), 0); + if(options.logging) + CallService(PLUG "/Log", (WPARAM)_T("rawping error: timeout"), 0); return -1; } -- cgit v1.2.3