Skip to content

Commit

Permalink
Merge 580b814 into 296de3d
Browse files Browse the repository at this point in the history
  • Loading branch information
tomangert committed Sep 7, 2020
2 parents 296de3d + 580b814 commit 2097ef0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/fping.c
Expand Up @@ -315,6 +315,9 @@ int64_t perhost_interval = (int64_t) DEFAULT_PERHOST_INTERVAL * 1000000;
float backoff = DEFAULT_BACKOFF_FACTOR;
unsigned int ping_data_size = DEFAULT_PING_DATA_SIZE;
unsigned int count = 1, min_reachable = 0;
#ifdef SO_MARK
unsigned int fwmark = 0;
#endif
unsigned int trials;
int64_t report_interval = 0;
unsigned int ttl = 0;
Expand Down Expand Up @@ -480,6 +483,9 @@ int main(int argc, char** argv)
{ "ttl", 'H', OPTPARSE_REQUIRED },
{ "interval", 'i', OPTPARSE_REQUIRED },
{ "iface", 'I', OPTPARSE_REQUIRED },
#ifdef SO_MARK
{ "fwmark", 'k', OPTPARSE_REQUIRED },
#endif
{ "loop", 'l', OPTPARSE_NONE },
{ "all", 'm', OPTPARSE_NONE },
{ "dontfrag", 'M', OPTPARSE_NONE },
Expand Down Expand Up @@ -600,6 +606,23 @@ int main(int argc, char** argv)
report_all_rtts_flag = 1;
break;

#ifdef SO_MARK
case 'k':
if (!(fwmark = (unsigned int)strtol(optparse_state.optarg, NULL, 0)))
usage(1);

if (socket4 >= 0)
if(-1 == setsockopt(socket4, SOL_SOCKET, SO_MARK, &fwmark, sizeof fwmark))
perror("fwmark ipv4");

#ifdef IPV6
if (socket6 >= 0)
if(-1 == setsockopt(socket6, SOL_SOCKET, SO_MARK, &fwmark, sizeof fwmark))
perror("fwmark ipv6");
#endif
break;
#endif

case 'b':
if (!sscanf(optparse_state.optarg, "%u", &ping_data_size))
usage(1);
Expand Down Expand Up @@ -2880,6 +2903,9 @@ void usage(int is_error)
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");
#ifdef SO_MARK
fprintf(out, " -k, --fwmark=FWMARK set the routing mark\n");
#endif
fprintf(out, "\n");
fprintf(out, "Output options:\n");
fprintf(out, " -a, --alive show targets that are alive\n");
Expand Down

0 comments on commit 2097ef0

Please sign in to comment.