version 1.1.1.1, 2013/07/21 23:43:42
|
version 1.1.1.2, 2016/11/01 09:33:48
|
Line 16
|
Line 16
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
*/ |
*/ |
|
|
#include <config.h> | #include "config.h" |
|
|
#if defined(HAVE_SYS_XTI_H) |
#if defined(HAVE_SYS_XTI_H) |
#include <sys/xti.h> |
#include <sys/xti.h> |
Line 210 extern int af; /* address family of remote target */
|
Line 210 extern int af; /* address family of remote target */
|
extern int mtrtype; /* type of query packet used */ |
extern int mtrtype; /* type of query packet used */ |
extern int remoteport; /* target port for TCP tracing */ |
extern int remoteport; /* target port for TCP tracing */ |
extern int timeout; /* timeout for TCP connections */ |
extern int timeout; /* timeout for TCP connections */ |
|
#ifdef SO_MARK |
|
extern int mark; /* SO_MARK to set for ping packet*/ |
|
#endif |
|
|
/* return the number of microseconds to wait before sending the next |
/* return the number of microseconds to wait before sending the next |
ping */ |
ping */ |
Line 327 void net_send_tcp(int index)
|
Line 330 void net_send_tcp(int index)
|
addrcpy((void *) &local4->sin_addr, (void *) &ssa4->sin_addr, af); |
addrcpy((void *) &local4->sin_addr, (void *) &ssa4->sin_addr, af); |
addrcpy((void *) &remote4->sin_addr, (void *) remoteaddress, af); |
addrcpy((void *) &remote4->sin_addr, (void *) remoteaddress, af); |
remote4->sin_port = htons(remoteport); |
remote4->sin_port = htons(remoteport); |
|
len = sizeof (struct sockaddr_in); |
break; |
break; |
#ifdef ENABLE_IPV6 |
#ifdef ENABLE_IPV6 |
case AF_INET6: |
case AF_INET6: |
addrcpy((void *) &local6->sin6_addr, (void *) &ssa6->sin6_addr, af); |
addrcpy((void *) &local6->sin6_addr, (void *) &ssa6->sin6_addr, af); |
addrcpy((void *) &remote6->sin6_addr, (void *) remoteaddress, af); |
addrcpy((void *) &remote6->sin6_addr, (void *) remoteaddress, af); |
remote6->sin6_port = htons(remoteport); |
remote6->sin6_port = htons(remoteport); |
|
len = sizeof (struct sockaddr_in6); |
break; |
break; |
#endif |
#endif |
} |
} |
|
|
if (bind(s, (struct sockaddr *) &local, sizeof (local))) { | if (bind(s, (struct sockaddr *) &local, len)) { |
display_clear(); |
display_clear(); |
perror("bind()"); |
perror("bind()"); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
|
len = sizeof (local); |
|
if (getsockname(s, (struct sockaddr *) &local, &len)) { |
if (getsockname(s, (struct sockaddr *) &local, &len)) { |
display_clear(); |
display_clear(); |
perror("getsockname()"); |
perror("getsockname()"); |
Line 381 void net_send_tcp(int index)
|
Line 385 void net_send_tcp(int index)
|
#endif |
#endif |
} |
} |
|
|
|
#ifdef SO_MARK |
|
if (mark >= 0 && setsockopt( s, SOL_SOCKET, SO_MARK, &mark, sizeof mark ) ) { |
|
perror( "setsockopt SO_MARK" ); |
|
exit( EXIT_FAILURE ); |
|
} |
|
#endif |
|
|
switch (local.ss_family) { |
switch (local.ss_family) { |
case AF_INET: |
case AF_INET: |
port = ntohs(local4->sin_port); |
port = ntohs(local4->sin_port); |
Line 400 void net_send_tcp(int index)
|
Line 411 void net_send_tcp(int index)
|
gettimeofday(&sequence[port].time, NULL); |
gettimeofday(&sequence[port].time, NULL); |
sequence[port].socket = s; |
sequence[port].socket = s; |
|
|
connect(s, (struct sockaddr *) &remote, sizeof (remote)); | connect(s, (struct sockaddr *) &remote, len); |
} |
} |
|
|
/* Attempt to find the host at a particular number of hops away */ |
/* Attempt to find the host at a particular number of hops away */ |
Line 481 void net_send_query(int index)
|
Line 492 void net_send_query(int index)
|
#endif |
#endif |
} |
} |
|
|
|
#ifdef SO_MARK |
|
if (mark >= 0 && setsockopt( sendsock, SOL_SOCKET, SO_MARK, &mark, sizeof mark ) ) { |
|
perror( "setsockopt SO_MARK" ); |
|
exit( EXIT_FAILURE ); |
|
} |
|
#endif |
|
|
switch ( mtrtype ) { |
switch ( mtrtype ) { |
case IPPROTO_ICMP: |
case IPPROTO_ICMP: |
icmp = (struct ICMPHeader *)(packet + iphsize); |
icmp = (struct ICMPHeader *)(packet + iphsize); |
Line 1393 void net_save_return(int at, int seq, int ms)
|
Line 1411 void net_save_return(int at, int seq, int ms)
|
{ |
{ |
int idx; |
int idx; |
idx = seq - host[at].saved_seq_offset; |
idx = seq - host[at].saved_seq_offset; |
if (idx < 0 || idx > SAVED_PINGS) { | if (idx < 0 || idx >= SAVED_PINGS) { |
return; |
return; |
} |
} |
host[at].saved[idx] = ms; |
host[at].saved[idx] = ms; |
Line 1562 void net_harvest_fds(void)
|
Line 1580 void net_harvest_fds(void)
|
net_add_fds(&writefd, &maxfd); |
net_add_fds(&writefd, &maxfd); |
select(maxfd, NULL, &writefd, NULL, &tv); |
select(maxfd, NULL, &writefd, NULL, &tv); |
net_process_fds(&writefd); |
net_process_fds(&writefd); |
} |
|
|
|
|
} |