further unification work

pull/82/head
David Schweikert 10 years ago
parent 22e4ad996f
commit 2f4781214b

@ -29,7 +29,7 @@ if test x$ipv4 = xfalse && test x$ipv6 = xfalse; then
fi
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([foreign])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AM_MAINTAINER_MODE
AC_CONFIG_HEADERS([config.h])

@ -365,7 +365,7 @@ int main( int argc, char **argv )
int tos = 0;
HOST_ENTRY *cursor;
s = open_ping_socket();
s = open_ping_socket(ping_data_size);
if((uid = getuid())) {
/* drop privileges */
@ -1405,7 +1405,7 @@ int send_ping( int s, HOST_ENTRY *h )
printf( "sending [%d] to %s\n", h->num_sent, h->host );
#endif /* DEBUG || _DEBUG */
n = socket_sendto_ping(s, (struct sockaddr *) &h->saddr, h->saddr_len, ping_pkt_size, myseq, ident);
n = socket_sendto_ping(s, (struct sockaddr *) &h->saddr, h->saddr_len, myseq, ident);
if(
(n < 0 || n != ping_pkt_size)

@ -21,8 +21,8 @@ void errno_crash_and_burn( char *message );
int in_cksum( unsigned short *p, int n );
/* socket.c */
int open_ping_socket();
int open_ping_socket(size_t ping_data_size);
void socket_set_src_addr(int s, FPING_INADDR src_addr);
int socket_sendto_ping(int s, struct sockaddr *saddr, socklen_t saddr_len, size_t ping_pkg_size, uint16_t icmp_seq, uint16_t icmp_id);
int socket_sendto_ping(int s, struct sockaddr *saddr, socklen_t saddr_len, uint16_t icmp_seq, uint16_t icmp_id);
#endif

@ -37,15 +37,15 @@ int open_ping_socket_ipv4();
int open_ping_socket_ipv6();
void socket_set_src_addr_ipv4(int s, FPING_INADDR src_addr);
void socket_set_src_addr_ipv6(int s, FPING_INADDR src_addr);
int socket_sendto_ping_ipv4(int s, struct sockaddr *saddr, socklen_t saddr_len, size_t ping_pkg_size, uint16_t icmp_seq_nr, uint16_t icmp_id_nr);
int socket_sendto_ping_ipv6(int s, struct sockaddr *saddr, socklen_t saddr_len, size_t ping_pkg_size, uint16_t icmp_seq_nr, uint16_t icmp_id_nr);
int socket_sendto_ping_ipv4(int s, struct sockaddr *saddr, socklen_t saddr_len, uint16_t icmp_seq_nr, uint16_t icmp_id_nr);
int socket_sendto_ping_ipv6(int s, struct sockaddr *saddr, socklen_t saddr_len, uint16_t icmp_seq_nr, uint16_t icmp_id_nr);
int open_ping_socket()
int open_ping_socket(size_t ping_data_size)
{
#ifndef IPV6
return open_ping_socket_ipv4();
return open_ping_socket_ipv4(ping_data_size);
#else
return open_ping_socket_ipv6();
return open_ping_socket_ipv6(ping_data_size);
#endif
}
@ -58,11 +58,11 @@ void socket_set_src_addr(int s, FPING_INADDR src_addr)
#endif
}
int socket_sendto_ping(int s, struct sockaddr *saddr, socklen_t saddr_len, size_t ping_pkt_size, uint16_t icmp_seq_nr, uint16_t icmp_id_nr)
int socket_sendto_ping(int s, struct sockaddr *saddr, socklen_t saddr_len, uint16_t icmp_seq_nr, uint16_t icmp_id_nr)
{
#ifndef IPV6
return socket_sendto_ping_ipv4(s, saddr, saddr_len, ping_pkt_size, icmp_seq_nr, icmp_id_nr);
return socket_sendto_ping_ipv4(s, saddr, saddr_len, icmp_seq_nr, icmp_id_nr);
#else
return socket_sendto_ping_ipv6(s, saddr, saddr_len, ping_pkt_size, icmp_seq_nr, icmp_id_nr);
return socket_sendto_ping_ipv6(s, saddr, saddr_len, icmp_seq_nr, icmp_id_nr);
#endif
}

@ -84,7 +84,7 @@ void socket_set_src_addr_ipv4(int s, FPING_INADDR src_addr)
errno_crash_and_burn( "cannot bind source address" );
}
int socket_sendto_ping_ipv4(int s, struct sockaddr *saddr, socklen_t saddr_len, size_t ping_pkt_size, uint16_t icmp_seq_nr, uint16_t icmp_id_nr)
int socket_sendto_ping_ipv4(int s, struct sockaddr *saddr, socklen_t saddr_len, uint16_t icmp_seq_nr, uint16_t icmp_id_nr)
{
struct icmp *icp;
int n;

@ -92,10 +92,6 @@ int socket_sendto_ping_ipv6(int s, struct sockaddr *saddr, socklen_t saddr_len,
// FIXME: randomization
icp = (struct icmp6_hdr *) ping_buffer;
if(!icp) {
crash_and_burn("can't malloc ping packet");
}
icp->icmp6_type = ICMP6_ECHO_REQUEST;
icp->icmp6_code = 0;
icp->icmp6_seq = htons(icmp_seq_nr);

Loading…
Cancel
Save