summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fa42fc0)
raw | patch | inline | side by side (parent: fa42fc0)
author | Florian Forster <octo@verplant.org> | |
Mon, 12 Jun 2006 20:48:54 +0000 (22:48 +0200) | ||
committer | Florian Forster <octo@verplant.org> | |
Mon, 12 Jun 2006 20:48:54 +0000 (22:48 +0200) |
src/oping.c | patch | blob | history |
diff --git a/src/oping.c b/src/oping.c
index 48f6db51886a5fe323f30756011f418959a51ce2..8bc119ebc3c7e33c3276a86bdedc203f9a41484f 100644 (file)
--- a/src/oping.c
+++ b/src/oping.c
double latency_total_square;
} ping_context_t;
-static double opt_interval = 1.0;
-static int opt_addrfamily = PING_DEF_AF;
-static int opt_count = -1;
+static double opt_interval = 1.0;
+static int opt_addrfamily = PING_DEF_AF;
+static char *opt_srcaddr = NULL;
+static int opt_count = -1;
void sigint_handler (int signal)
{
while (1)
{
- optchar = getopt (argc, argv, "46c:hi:");
+ optchar = getopt (argc, argv, "46c:hi:I:");
if (optchar == -1)
break;
opt_interval = new_interval;
}
break;
+ case 'I':
+ {
+ if (opt_srcaddr != NULL)
+ free (opt_srcaddr);
+ opt_srcaddr = strdup (optarg);
+ }
+ break;
case 'h':
default:
if (opt_addrfamily != PING_DEF_AF)
ping_setopt (ping, PING_OPT_AF, (void *) &opt_addrfamily);
+ if (opt_srcaddr != NULL)
+ {
+ if (ping_setopt (ping, PING_OPT_SOURCE, (void *) opt_srcaddr) != 0)
+ {
+ fprintf (stderr, "Setting source address failed: %s\n",
+ ping_get_error (ping));
+ }
+ }
+
for (i = optind; i < argc; i++)
{
if (ping_host_add (ping, argv[i]) < 0)