cnping

Minimal Graphical Ping Tool
git clone https://git.sinitax.com/cnlohr/cnping
Log | Files | Refs | Submodules | README | LICENSE | sfeed.txt

commit 593d80f8aded3f6f289bfab20eaa2d61b0493f76
parent fc4fc15e12112385495add6d82684839bbabe725
Author: CNLohr <charles@cnlohr.com>
Date:   Wed, 21 Jun 2017 10:32:48 -0400

Merge branch 'master' into dev
Diffstat:
Mcnping.c | 6+++---
Acnping.exe | 0
Mos_generic.c | 2+-
Mos_generic.h | 4++--
Mping.c | 26+++++++++++++-------------
Mping.h | 4++--
Msearchnet.c | 2+-
7 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/cnping.c b/cnping.c @@ -377,12 +377,12 @@ int main( int argc, const char ** argv ) if( argc > 2 ) { - pingperiod = atof( argv[2] ); - printf( "Extra ping period: %f\n", pingperiod ); + pingperiodseconds = atof( argv[2] ); + printf( "Extra ping period: %f\n", pingperiodseconds ); } else { - pingperiod = 0.02; + pingperiodseconds = 0.02; } if( argc > 3 ) diff --git a/cnping.exe b/cnping.exe Binary files differ. diff --git a/os_generic.c b/os_generic.c @@ -1,6 +1,5 @@ #include "os_generic.h" - #ifdef USE_WINDOWS #include <windows.h> @@ -56,6 +55,7 @@ void * OGJoinThread( og_thread_t ot ) { WaitForSingleObject( ot, INFINITE ); CloseHandle( ot ); + return 0; } void OGCancelThread( og_thread_t ot ) diff --git a/os_generic.h b/os_generic.h @@ -1,7 +1,7 @@ #ifndef _OS_GENERIC_H #define _OS_GENERIC_H -#ifdef WIN32 +#if defined( WIN32 ) || defined (WINDOWS) || defined( _WIN32) #define USE_WINDOWS #endif @@ -25,7 +25,7 @@ og_thread_t OGCreateThread( void * (routine)( void * ), void * parameter ); void * OGJoinThread( og_thread_t ot ); void OGCancelThread( og_thread_t ot ); -//Always a recrusive mutex. +//Always a recursive mutex. og_mutex_t OGCreateMutex(); void OGLockMutex( og_mutex_t om ); void OGUnlockMutex( og_mutex_t om ); diff --git a/ping.c b/ping.c @@ -18,7 +18,6 @@ #define ICMP_ECHO 8 #define IP_TTL 2 #define O_NONBLOCK 04000 - void usleep(int x) { Sleep(x / 1000); } #include <windows.h> #include <winsock2.h> #include <ws2tcpip.h> @@ -36,7 +35,6 @@ #include <netinet/ip.h> #include <netinet/ip_icmp.h> #endif - #if defined WIN32 || defined __APPLE__ struct icmphdr { @@ -60,7 +58,7 @@ struct icmphdr }; #endif -float pingperiod; +float pingperiodseconds; int precise_ping; #define PACKETSIZE 1500 @@ -99,8 +97,8 @@ void listener() if ( setsockopt(sd, SOL_IP, IP_TTL, &val, sizeof(val)) != 0) { - ERRM("Erro: could not set TTL option - did you forget to run as root or sticky bit cnping?\n"); - exit( -1 ); + ERRM("Error: could not set TTL option - did you forget to run as root or sticky bit cnping?\n"); + exit( -1 ); } #endif @@ -132,7 +130,9 @@ void listener() if ( bytes > 0 ) display(buf + 28, bytes - 28 ); else - ERRM( "recfrom failed." ); + { + ERRM("Error: recvfrom failed"); + } goto keep_retry_quick; } @@ -187,19 +187,19 @@ void ping(struct sockaddr_in *addr ) do { ctime = OGGetAbsoluteTime(); - if( pingperiod >= 1000 ) stime = ctime; - } while( ctime < stime + pingperiod ); - stime += pingperiod; + if( pingperiodseconds >= 1000 ) stime = ctime; + } while( ctime < stime + pingperiodseconds ); + stime += pingperiodseconds; } else { - if( pingperiod > 0 ) + if( pingperiodseconds > 0 ) { - uint32_t dlw = 1000000.0*pingperiod; - usleep( dlw ); + uint32_t dlw = 1000000.0*pingperiodseconds; + OGUSleep( dlw ); } } - } while( pingperiod >= 0 ); + } while( pingperiodseconds >= 0 ); //close( sd ); //Hacky, we don't close here because SD doesn't come from here, rather from ping_setup. We may want to run this multiple times. } diff --git a/ping.h b/ping.h @@ -18,8 +18,8 @@ void listener(); void ping(struct sockaddr_in *addr ); void do_pinger( const char * strhost ); -//If pingperiod = -1, run ping/do_pinger once and exit. -extern float pingperiod; +//If pingperiodseconds = -1, run ping/do_pinger once and exit. +extern float pingperiodseconds; extern int precise_ping; //if 0, use minimal CPU, but ping send-outs are only approximate, if 1, spinlock until precise time for ping is hit. void ping_setup(); diff --git a/searchnet.c b/searchnet.c @@ -85,7 +85,7 @@ int main( int argc, char ** argv ) send_id[2] = (cur>>8)&0xff; send_id[3] = (cur)&0xff; // printf( "Pinging: %s\n", dispip ); - pingperiod = -1; + pingperiodseconds = -1; do_pinger( dispip ); OGUSleep( (int)(speed * 1000000) );