Compare commits

..

No commits in common. '062d6419d64fe5f320b289bba101c07f74b597e5' and '00d641710499248319622c25d4fc79e1465f2714' have entirely different histories.

@ -358,7 +358,7 @@ int multif_flag, timeout_flag, fast_reachable;
int outage_flag = 0;
int timestamp_flag = 0;
int timestamp_format_flag = 0;
int nonzero_payload_flag = 0;
int random_data_flag = 0;
int cumulative_stats_flag = 0;
#if defined(DEBUG) || defined(_DEBUG)
int randomly_lose_flag, trace_flag, print_per_system_flag;
@ -547,7 +547,7 @@ int main(int argc, char **argv)
{ "quiet", 'q', OPTPARSE_NONE },
{ "squiet", 'Q', OPTPARSE_REQUIRED },
{ "retry", 'r', OPTPARSE_REQUIRED },
{ "nonzero", 'Z', OPTPARSE_NONE },
{ "random", 'R', OPTPARSE_NONE },
{ "stats", 's', OPTPARSE_NONE },
{ "src", 'S', OPTPARSE_REQUIRED },
{ "timeout", 't', OPTPARSE_REQUIRED },
@ -751,8 +751,8 @@ int main(int argc, char **argv)
timestamp_flag = 1;
break;
case 'Z':
nonzero_payload_flag = 1;
case 'R':
random_data_flag = 1;
break;
case 'l':
@ -3033,7 +3033,7 @@ void usage(int is_error)
fprintf(out, " -p, --period=MSEC interval between ping packets to one target (in ms)\n");
fprintf(out, " (in loop and count modes, default: %.0f ms)\n", perhost_interval / 1e6);
fprintf(out, " -r, --retry=N number of retries (default: %d)\n", DEFAULT_RETRY);
fprintf(out, " -Z, --nonzero non-zero packet data (same payload as ping 0xA ...)\n");
fprintf(out, " -R, --random random packet data (to foil link data compression)\n");
fprintf(out, " -S, --src=IP set source address\n");
fprintf(out, " -t, --timeout=MSEC individual target initial timeout (default: %.0f ms,\n", timeout / 1e6);
fprintf(out, " except with -l/-c/-C, where it's the -p period up to 2000 ms)\n");

@ -22,7 +22,7 @@ extern int trace_flag;
void crash_and_burn( char *message );
void errno_crash_and_burn( char *message );
int in_cksum( unsigned short *p, int n );
extern int nonzero_payload_flag;
extern int random_data_flag;
/* socket.c */
int open_ping_socket_ipv4(int *socktype);

@ -133,7 +133,6 @@ int socket_sendto_ping_ipv4(int s, struct sockaddr* saddr, socklen_t saddr_len,
{
struct icmp* icp;
int n;
size_t i;
icp = (struct icmp*)ping_buffer_ipv4;
@ -143,12 +142,9 @@ int socket_sendto_ping_ipv4(int s, struct sockaddr* saddr, socklen_t saddr_len,
icp->icmp_seq = htons(icmp_seq_nr);
icp->icmp_id = icmp_id_nr;
if (nonzero_payload_flag) {
// for (n = ((char*)&icp->icmp_data - (char*)icp); n < ping_pkt_size_ipv4; ++n) {
// ping_buffer_ipv4[n] = random() & 0xFF;
// }
for(n = (char*) &icp->icmp_data - (char*)icp, i = 0xA; n < ping_pkt_size_ipv4; ++n, i += 1) {
ping_buffer_ipv4[n] = i & 0xFF;
if (random_data_flag) {
for (n = ((char*)&icp->icmp_data - (char*)icp); n < ping_pkt_size_ipv4; ++n) {
ping_buffer_ipv4[n] = random() & 0xFF;
}
}

@ -115,7 +115,6 @@ int socket_sendto_ping_ipv6(int s, struct sockaddr* saddr, socklen_t saddr_len,
{
struct icmp6_hdr* icp;
int n;
size_t i;
icp = (struct icmp6_hdr*)ping_buffer_ipv6;
icp->icmp6_type = ICMP6_ECHO_REQUEST;
@ -123,9 +122,9 @@ int socket_sendto_ping_ipv6(int s, struct sockaddr* saddr, socklen_t saddr_len,
icp->icmp6_seq = htons(icmp_seq_nr);
icp->icmp6_id = icmp_id_nr;
if (nonzero_payload_flag) {
for (n = sizeof(struct icmp6_hdr), i = 0xA; n < ping_pkt_size_ipv6; ++n, i+=1) {
ping_buffer_ipv6[n] = i & 0xFF;
if (random_data_flag) {
for (n = sizeof(struct icmp6_hdr); n < ping_pkt_size_ipv6; ++n) {
ping_buffer_ipv6[n] = random() & 0xFF;
}
}

Loading…
Cancel
Save