# fping -c n
{
-my $cmd = Test::Command->new(cmd => "fping -c 2 -p 100 localhost 127.0.0.1");
+my $cmd = Test::Command->new(cmd => "fping -4 -c 2 -p 100 localhost 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_like(qr{localhost : \[0\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
# fping -C n
{
-my $cmd = Test::Command->new(cmd => "fping -C 2 -p 100 localhost 127.0.0.1");
+my $cmd = Test::Command->new(cmd => "fping -4 -C 2 -p 100 localhost 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_like(qr{localhost : \[0\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
char *prog;
int ident; /* our pid */
int socket4 = 0;
-#ifndef IPV6
-int hints_ai_family = AF_INET;
-#else
-int hints_ai_family = AF_UNSPEC;
-#endif
-
#ifndef IPV6
int *allsocket[2] = { &socket4, NULL };
+int hints_ai_family = AF_INET;
#else
int socket6 = 0;
int *allsocket[3] = { &socket4, &socket6, NULL };
+int hints_ai_family = AF_UNSPEC;
#endif
+
unsigned int debugging = 0;
/* times get *100 because all times are calculated in 10 usec units, not ms */
/* get command line options */
- while( ( c = getopt( argc, argv, "ADMNRadeghlmnoqsuvzB:C:H:I:O:Q:S:T:b:c:f:i:p:r:t:" ) ) != EOF )
+ while( ( c = getopt( argc, argv, "46ADMNRadeghlmnoqsuvzB:C:H:I:O:Q:S:T:b:c:f:i:p:r:t:" ) ) != EOF )
{
switch( c )
{
+ case '4':
+ hints_ai_family = AF_INET;
+ // FIXME: check that -4 and -6 not used together
+ break;
+ case '6':
+ hints_ai_family = AF_INET6;
+ // FIXME: check that -4 and -6 not used together
+ break;
case 'M':
#ifdef IP_MTU_DISCOVER
{
int val = IP_PMTUDISC_DO;
- int *sp;
- for(sp=allsocket[0]; *sp; sp++) {
- if (setsockopt(*sp, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val))) {
+ int **sp;
+ for(sp=&allsocket[0]; *sp; sp++) {
+ if (setsockopt(**sp, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val))) {
perror("setsockopt IP_MTU_DISCOVER");
}
}
case 'I':
#ifdef SO_BINDTODEVICE
{
- int *sp;
- for(sp=allsocket[0]; *sp; sp++) {
- if (setsockopt(*sp, SOL_SOCKET, SO_BINDTODEVICE, optarg, strlen(optarg))) {
+ int **sp;
+ for(sp=&allsocket[0]; *sp; sp++) {
+ if (setsockopt(**sp, SOL_SOCKET, SO_BINDTODEVICE, optarg, strlen(optarg))) {
perror("binding to specific interface (SO_BINTODEVICE)");
}
}
case 'O':
if (sscanf(optarg,"%i",&tos)){
- int *sp;
- for(sp=allsocket[0]; *sp; sp++) {
- if ( setsockopt(*sp, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))) {
+ int **sp;
+ for(sp=&allsocket[0]; *sp; sp++) {
+ if ( setsockopt(**sp, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))) {
perror("setting type of service octet IP_TOS");
}
}
/* set the TTL, if the -H option was set (otherwise ttl will be = 0) */
if(ttl > 0) {
- int *sp;
- for(sp=allsocket[0]; *sp; sp++) {
- if (setsockopt(*sp, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl))) {
+ int **sp;
+ for(sp=&allsocket[0]; *sp; sp++) {
+ if (setsockopt(**sp, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl))) {
perror("setting time to live");
}
}
#if HAVE_SO_TIMESTAMP
{
int opt = 1;
- int *sp;
- for(sp=allsocket[0]; *sp; sp++) {
- if (setsockopt(*sp, SOL_SOCKET, SO_TIMESTAMP, &opt, sizeof(opt))) {
+ int **sp;
+ for(sp=&allsocket[0]; *sp; sp++) {
+ if (setsockopt(**sp, SOL_SOCKET, SO_TIMESTAMP, &opt, sizeof(opt))) {
perror("setting SO_TIMESTAMP option");
}
}