/[monit]/monit/net.c
ViewVC logotype

Diff of /monit/net.c

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

revision 1.38 by martinp, Thu Sep 25 15:22:10 2003 UTC revision 1.39 by martinp, Fri Sep 26 06:27:15 2003 UTC
# Line 607  int icmp_echo(const char *hostname, int Line 607  int icmp_echo(const char *hostname, int
607    int n= 0;    int n= 0;
608    int rv= FALSE;    int rv= FALSE;
609    unsigned ttl= 255;    unsigned ttl= 255;
   unsigned short mypid;  
610    char buf[STRLEN];    char buf[STRLEN];
611        
612    ASSERT(hostname);    ASSERT(hostname);
613    
   mypid= getpid();  
   
614    if( (hp= gethostbyname(hostname)) == NULL )    if( (hp= gethostbyname(hostname)) == NULL )
615      return FALSE;      return FALSE;
616    
# Line 626  int icmp_echo(const char *hostname, int Line 623  int icmp_echo(const char *hostname, int
623    icmphdrout= (struct icmphdr *)xmalloc(sizeof(struct icmphdr));    icmphdrout= (struct icmphdr *)xmalloc(sizeof(struct icmphdr));
624    icmphdrout->type= ICMP_ECHO;    icmphdrout->type= ICMP_ECHO;
625    icmphdrout->code= 0;    icmphdrout->code= 0;
626    icmphdrout->un.echo.id= mypid;    icmphdrout->un.echo.id= getpid();
627    icmphdrout->un.echo.sequence= 0;    icmphdrout->un.echo.sequence= 0;
628    icmphdrout->checksum= checksum_ip((unsigned char *)icmphdrout,    icmphdrout->checksum= checksum_ip((unsigned char *)icmphdrout,
629                                      sizeof(struct icmphdr));                                      sizeof(struct icmphdr));
# Line 661  int icmp_echo(const char *hostname, int Line 658  int icmp_echo(const char *hostname, int
658      iphdrin= (struct iphdr *)buf;      iphdrin= (struct iphdr *)buf;
659      icmphdrin= (struct icmphdr *)(buf + iphdrin->ihl * 4);      icmphdrin= (struct icmphdr *)(buf + iphdrin->ihl * 4);
660    
661      if( (icmphdrin->un.echo.id == mypid) &&      if( (icmphdrin->un.echo.id == icmphdrout->un.echo.id) &&
662          (icmphdrin->type == ICMP_ECHOREPLY) &&          (icmphdrin->type == ICMP_ECHOREPLY) &&
663          (icmphdrin->un.echo.sequence == 0) ) {          (icmphdrin->un.echo.sequence == 0) ) {
664    
# Line 670  int icmp_echo(const char *hostname, int Line 667  int icmp_echo(const char *hostname, int
667    
668      }      }
669    
670    } while(! ( (icmphdrin->un.echo.id == mypid) &&    } while(! ( (icmphdrin->un.echo.id == icmphdrout->un.echo.id) &&
671                (icmphdrin->type == ICMP_ECHOREPLY) &&                (icmphdrin->type == ICMP_ECHOREPLY) &&
672                (icmphdrin->un.echo.sequence == 0) ) );                (icmphdrin->un.echo.sequence == 0) ) );
673    

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.39

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