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 |
|
|
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 |
|
|
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); |
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); |