#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) */
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
#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