4 * Copyright (C) 2001,2002 Jeffrey Fulmer <jdfulmer@armstrong.com>
5 * This file is part of LIBPING
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #endif/*HAVE_CONFIG_H*/
40 send_data( CONN *C, int bytes )
47 bytes = (bytes>MAXLINE-3)?MAXLINE-3:bytes;
49 memset( buf, 0, bytes+3 );
50 memset( rec, 0, bytes+3 );
52 for( x = 0; x < bytes; x++ )
55 (void)strcat( buf, "\015\012" );
57 if( JOEsocket_write( C, buf, sizeof( buf )) < 0 ){
61 if(( n = JOEreadline( C, rec, sizeof( rec ))) < 0 ){
65 if(( ret = strlen( rec )) > 0 ){
75 CONN *C; /* threadsafe connection */
76 int ret; /* return conditional */
77 struct timeval mytime;
79 C = (CONN*)xmalloc( sizeof( CONN ));
81 C->timeout = ( E->timeout == 0 )?60:E->timeout;
83 (void) gettimeofday( &mytime, (struct timezone *)NULL);
85 if(( C->sock = JOEsocket( C, E->hostname )) < 0 ){
89 ret = send_data( C, E->bytes );
91 E->rtt = elapsed_time( &mytime );
96 echohost( const char *hostname, int b )
100 E = (ECHODATA*)xmalloc( sizeof( ECHODATA ));
101 E->hostname = (char*)strdup( hostname );
104 return ( myecho( E ));
108 echothost( const char *hostname, int b, int t )
112 E = (ECHODATA*)xmalloc( sizeof( ECHODATA ));
113 E->hostname = (char*)strdup( hostname );
117 return ( myecho( E ));
121 techohost( const char *hostname, int b )
126 E = (ECHODATA*)xmalloc( sizeof( ECHODATA ));
127 E->hostname = (char*)strdup( hostname );
133 if( ret > 0 ){ return E->rtt; }
138 techothost( const char *hostname, int b, int t )
143 E = (ECHODATA*)xmalloc( sizeof( ECHODATA ));
144 E->hostname = (char*)strdup( hostname );
149 if( ret > 0 ){ return E->rtt; }