summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 755185b)
raw | patch | inline | side by side (parent: 755185b)
author | octo <octo> | |
Sun, 14 May 2006 21:11:09 +0000 (21:11 +0000) | ||
committer | octo <octo> | |
Sun, 14 May 2006 21:11:09 +0000 (21:11 +0000) |
src/liboping.c | patch | blob | history | |
src/mans/ping_setopt.pod | patch | blob | history | |
src/oping.h | patch | blob | history |
diff --git a/src/liboping.c b/src/liboping.c
index de1ff02b56ffe6d15f94234334e4aaf6b1f254eb..3c63521a65b12b7c15ea7e1587d606bc834c7a55 100644 (file)
--- a/src/liboping.c
+++ b/src/liboping.c
#define PING_ERRMSG_LEN 256
-#define PING_DATA "Florian Forster <octo@verplant.org> http://verplant.org/"
-
struct pinghost
{
char *hostname;
double timeout;
int ttl;
int addrfamily;
+ char *data;
char errmsg[PING_ERRMSG_LEN];
icmp4->icmp_id = htons (ph->ident);
icmp4->icmp_seq = htons (ph->sequence);
- strcpy (data, PING_DATA);
+ buflen = 4096 - sizeof (struct icmp);
+ if (obj->data != NULL)
+ strncpy (data, obj->data, buflen);
+ else
+ strncpy (data, PING_DEF_DATA, buflen);
datalen = strlen (data);
buflen = datalen + sizeof (struct icmp);
icmp6->icmp6_id = htons (ph->ident);
icmp6->icmp6_seq = htons (ph->sequence);
- strcpy (data, PING_DATA);
+ buflen = 4096 - sizeof (struct icmp6_hdr);
+ if (obj->data != NULL)
+ strncpy (data, obj->data, buflen);
+ else
+ strncpy (data, PING_DEF_DATA, buflen);
datalen = strlen (data);
buflen = datalen + sizeof (struct icmp6_hdr);
}
break;
+ case PING_OPT_DATA:
+ if (obj->data != NULL)
+ {
+ free (obj->data);
+ obj->data = NULL;
+ }
+ obj->data = strdup ((const char *) value);
+ break;
+
default:
ret = -2;
} /* switch (option) */
index 7f64b04796a458f3f0cad75f558dbc6b590a92b4..9c73929410e485249b52898b9d47e4d045f77b88 100644 (file)
--- a/src/mans/ping_setopt.pod
+++ b/src/mans/ping_setopt.pod
option only effects hosts that are being added B<after> this option has been
set. Default is B<PING_DEF_AF>.
+=item B<PING_OPT_DATA>
+
+Set the data to send. The value passed must be a char-pointer to a
+null-terminated string. By default a 56 byte long string is used so that the
+packet size of an ICMPv4 packet is exactly 64 bytes. That's the behavior of the
+L<ping(1)> command.
+
=back
The I<val> argument is a pointer to the new value. It must not be NULL. It is
diff --git a/src/oping.h b/src/oping.h
index 521494798dd4c8055e4d767d40bcd475fe82ee33..7463672ee4425ac96a1e5deb9a7ca1815ae38a0d 100644 (file)
--- a/src/oping.h
+++ b/src/oping.h
#define PING_OPT_TIMEOUT 0x01
#define PING_OPT_TTL 0x02
#define PING_OPT_AF 0x04
+#define PING_OPT_DATA 0x08
#define PING_DEF_TIMEOUT 1.0
#define PING_DEF_TTL 255
#define PING_DEF_AF AF_UNSPEC
+#define PING_DEF_DATA "Florian Forster <octo@verplant.org> http://verplant.org/"
/*
* Method definitions