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

Diff of /monit/net.c

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

revision 1.44 by hauk, Mon Oct 20 02:14:28 2003 UTC revision 1.45 by rory, Tue Oct 21 21:06:28 2003 UTC
# Line 40  Line 40 
40  #endif  #endif
41    
42  #ifdef HAVE_NETINET_IN_H  #ifdef HAVE_NETINET_IN_H
43    #include <netinet/in_systm.h>
44  #include <netinet/in.h>  #include <netinet/in.h>
45  #endif  #endif
46    
# Line 606  int icmp_echo(const char *hostname, int Line 607  int icmp_echo(const char *hostname, int
607    int s;    int s;
608    int n= 0;    int n= 0;
609    int rv= FALSE;    int rv= FALSE;
610      int sol_ip;
611    unsigned ttl= 255;    unsigned ttl= 255;
612    char buf[STRLEN];    char buf[STRLEN];
613        
# Line 617  int icmp_echo(const char *hostname, int Line 619  int icmp_echo(const char *hostname, int
619    if((s= socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)    if((s= socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
620      return FALSE;      return FALSE;
621    
622    if(setsockopt(s, SOL_IP, IP_TTL, (char *)&ttl, sizeof(ttl)) < 0)  #ifdef HAVE_SOL_IP
623      sol_ip = SOL_IP;
624    #else
625      {
626        struct protoent *pent;
627        pent = getprotobyname( "ip" );
628        sol_ip = ( pent != NULL ) ? pent->p_proto : 0;
629      }
630    #endif
631    
632      if(setsockopt(s, sol_ip, IP_TTL, (char *)&ttl, sizeof(ttl)) < 0)
633      goto error;      goto error;
634    
635    NEW(icmphdrout);    NEW(icmphdrout);
# Line 627  int icmp_echo(const char *hostname, int Line 639  int icmp_echo(const char *hostname, int
639    icmphdrout->un.echo.sequence= 0;    icmphdrout->un.echo.sequence= 0;
640    icmphdrout->checksum= checksum_ip((unsigned char *)icmphdrout,    icmphdrout->checksum= checksum_ip((unsigned char *)icmphdrout,
641                                      sizeof(struct icmphdr));                                      sizeof(struct icmphdr));
   
642    sout.sin_family= AF_INET;    sout.sin_family= AF_INET;
643    sout.sin_port= 0;    sout.sin_port= 0;
644    memcpy(&sout.sin_addr, hp->h_addr, hp->h_length);    memcpy(&sout.sin_addr, hp->h_addr, hp->h_length);

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45

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