X-Git-Url: https://git.tokkee.org/?p=liboping.git;a=blobdiff_plain;f=src%2Foping.c;fp=src%2Foping.c;h=6263a4def36459c7d94c8dbbb362cc89b56a9f6e;hp=3ae226c6f5e64d25e31d3ab3d960e0e673a8289f;hb=0a2a9fe209b27e37d15096fa730bac9520dfeced;hpb=a336f1ecc9665dc1d2f20fd8dfe6d9a93bb41b25 diff --git a/src/oping.c b/src/oping.c index 3ae226c..6263a4d 100644 --- a/src/oping.c +++ b/src/oping.c @@ -196,6 +196,7 @@ static double opt_timeout = PING_DEF_TIMEOUT; static int opt_addrfamily = PING_DEF_AF; static char *opt_srcaddr = NULL; static char *opt_device = NULL; +static char *opt_mark = NULL; static char *opt_filename = NULL; static int opt_count = -1; static int opt_send_ttl = 64; @@ -437,6 +438,7 @@ static void usage_exit (const char *name, int status) /* {{{ */ " Use \"-Q help\" for a list of valid options.\n" " -I srcaddr source address\n" " -D device outgoing interface name\n" + " -m mark mark to set on outgoing packets\n" " -f filename filename to read hosts from\n" #if USE_NCURSES " -u / -U force / disable UTF-8 output\n" @@ -647,7 +649,7 @@ static int read_options (int argc, char **argv) /* {{{ */ while (1) { - optchar = getopt (argc, argv, "46c:hi:I:t:Q:f:D:Z:P:w:" + optchar = getopt (argc, argv, "46c:hi:I:t:Q:f:D:Z:P:m:w:" #if USE_NCURSES "uUg:" #endif @@ -724,6 +726,10 @@ static int read_options (int argc, char **argv) /* {{{ */ opt_device = optarg; break; + case 'm': + opt_mark = optarg; + break; + case 't': { int new_send_ttl; @@ -1756,6 +1762,23 @@ int main (int argc, char **argv) /* {{{ */ } } + if(opt_mark != NULL) + { + char *endp; + int mark = strtoul(opt_mark, &endp, 0); + if(opt_mark[0] != '\0' && *endp == '\0') + { + if(ping_setopt(ping, PING_OPT_MARK, (void*)(&mark)) != 0) + { + fprintf (stderr, "Setting mark failed: %s\n", + ping_get_error (ping)); + } + } + else{ + fprintf(stderr, "Ignoring invalid mark: %s\n", optarg); + } + } + if (opt_filename != NULL) { FILE *infile;