arpd: allow configuring polling interval
A new option -p is added to the arpd command that accepts
a time indicating the number of seconds
to wait between kernel arp table polling attempts.
The minimum value is .1 (100ms).
If not specified, polling defaults to 30 seconds.
Patch by Erik Hugne <erik.hugne@ericsson.com> with
modifications
diff --git a/misc/arpd.c b/misc/arpd.c
index 4f0021b..dd1de80 100644
--- a/misc/arpd.c
+++ b/misc/arpd.c
@@ -90,11 +90,13 @@
int no_kernel_broadcasts;
int broadcast_rate = 1000;
int broadcast_burst = 3000;
+int poll_timeout = 30000;
void usage(void)
{
fprintf(stderr,
-"Usage: arpd [ -lkh? ] [ -a N ] [ -b dbase ] [ -B number ] [ -f file ] [ -n time ] [ -R rate ] [ interfaces ]\n");
+ "Usage: arpd [ -lkh? ] [ -a N ] [ -b dbase ] [ -B number ]"
+ " [ -f file ] [ -n time ] [-p interval ] [ -R rate ] [ interfaces ]\n");
exit(1);
}
@@ -591,7 +593,7 @@
int do_list = 0;
char *do_load = NULL;
- while ((opt = getopt(argc, argv, "h?b:lf:a:n:kR:B:")) != EOF) {
+ while ((opt = getopt(argc, argv, "h?b:lf:a:n:p:kR:B:")) != EOF) {
switch (opt) {
case 'b':
dbname = optarg;
@@ -615,6 +617,12 @@
case 'k':
no_kernel_broadcasts = 1;
break;
+ case 'p':
+ if ((poll_timeout = 1000 * strtod(optarg, NULL)) < 100) {
+ fprintf(stderr,"Invalid poll timeout\n");
+ exit(-1);
+ }
+ break;
case 'R':
if ((broadcast_rate = atoi(optarg)) <= 0 ||
(broadcast_rate = 1000/broadcast_rate) <= 0) {
@@ -807,7 +815,7 @@
}
if (do_stats)
send_stats();
- if (poll(pset, 2, 30000) > 0) {
+ if (poll(pset, 2, poll_timeout) > 0) {
in_poll = 0;
if (pset[0].revents&EVENTS)
get_arp_pkt();