/[inetutils]/inetutils/ping/ping_echo.c
ViewVC logotype

Diff of /inetutils/ping/ping_echo.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by gray, Mon Nov 10 14:29:40 2003 UTC revision 1.11 by ams, Mon Jun 20 08:21:48 2005 UTC
# Line 1  Line 1 
1  /* Copyright (C) 2001, 2002 Free Software Foundation, Inc.  /* Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
2    
3     This file is part of GNU Inetutils.     This file is part of GNU Inetutils.
4    
# Line 45  Line 45 
45  #include <errno.h>  #include <errno.h>
46  #include <limits.h>  #include <limits.h>
47    
 #include "getopt.h"  
48  #include <icmp.h>  #include <icmp.h>
49  #include <ping.h>  #include <ping.h>
50  #include <ping_impl.h>  #include "ping_common.h"
51    #include "ping_impl.h"
52    
53  #define NROUTES         9               /* number of record route slots */  #define NROUTES         9               /* number of record route slots */
54  #ifndef MAX_IPOPTLEN  #ifndef MAX_IPOPTLEN
55  # define MAX_IPOPTLEN 40  # define MAX_IPOPTLEN 40
56  #endif  #endif
57    
58  extern char *xstrdup (const char *);  #include <xalloc.h>
 extern char *xmalloc (size_t);  
59    
60  static int handler (int code, void *closure,  static int handler (int code, void *closure,
61                     struct sockaddr_in *dest, struct sockaddr_in *from,                     struct sockaddr_in *dest, struct sockaddr_in *from,
# Line 70  void print_icmp_header (struct sockaddr_ Line 69  void print_icmp_header (struct sockaddr_
69                                struct ip *ip, icmphdr_t *icmp, int len);                                struct ip *ip, icmphdr_t *icmp, int len);
70  static void print_ip_opt (struct ip *ip, int hlen);  static void print_ip_opt (struct ip *ip, int hlen);
71    
 static void tvsub (struct timeval *out, struct timeval *in);  
   
72  int  int
73  ping_echo (int argc, char **argv)  ping_echo (int argc, char **argv)
74  {  {
# Line 526  print_ip_opt (struct ip *ip, int hlen) Line 523  print_ip_opt (struct ip *ip, int hlen)
523        }        }
524  }  }
525    
 /*  
  * tvsub --  
  *      Subtract 2 timeval structs:  out = out - in.  Out is assumed to  
  * be >= in.  
  */  
 static void  
 tvsub (struct timeval *out, struct timeval *in)  
 {  
   if ((out->tv_usec -= in->tv_usec) < 0)  
     {  
       --out->tv_sec;  
       out->tv_usec += 1000000;  
     }  
   out->tv_sec -= in->tv_sec;  
 }  
   
 double  
 nabs (double a)  
 {  
   return (a < 0) ? -a : a;  
 }  
   
 double  
 nsqrt (double a, double prec)  
 {  
   double x0, x1;  
     
   if (a < 0)  
     return 0;  
   if (a < prec)  
     return 0;  
   x1 = a/2;  
   do  
     {  
       x0 = x1;  
       x1 = (x0 + a/x0) / 2;  
     }  
   while (nabs (x1 - x0) > prec);  
   
   return x1;  
 }  
   
526  int  int
527  echo_finish ()  echo_finish ()
528  {  {

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26