]> git.ipfire.org Git - people/pmueller/ipfire-3.x.git/blob - pkgs/iputils/patches/iputils-s20071127-arping_timeout.patch
Change file layout of the makefiles.
[people/pmueller/ipfire-3.x.git] / pkgs / iputils / patches / iputils-s20071127-arping_timeout.patch
1 diff -up iputils-s20070202/arping.c.arping_timeout iputils-s20070202/arping.c
2 --- iputils-s20070202/arping.c.arping_timeout 2008-02-18 16:51:36.000000000 +0100
3 +++ iputils-s20070202/arping.c 2008-02-18 16:54:03.000000000 +0100
4 @@ -45,7 +45,8 @@ struct in_addr src, dst;
5 char *target;
6 int dad, unsolicited, advert;
7 int quiet;
8 -int count=-1;
9 +int count;
10 +int forever = 1;
11 int timeout;
12 int unicasting;
13 int s;
14 @@ -59,7 +60,7 @@ int broadcast_only;
15 struct sockaddr_ll me[2];
16 struct sockaddr_ll he[2];
17
18 -struct timeval start, last;
19 +struct timeval last;
20
21 int sent, brd_sent;
22 int received, brd_recv, req_recv;
23 @@ -172,13 +173,15 @@ void catcher(void)
24
25 gettimeofday(&tv, NULL);
26
27 - if (start.tv_sec==0)
28 - start = tv;
29 -
30 - if (count-- == 0 || (timeout && MS_TDIFF(tv,start) > timeout*1000 + 500))
31 - finish();
32 + if (!forever && count == 0) {
33 + if (timeout && MS_TDIFF(tv, last) > timeout * 1000 + 500)
34 + finish();
35 + else if (!timeout)
36 + finish();
37 + }
38
39 - if (last.tv_sec==0 || MS_TDIFF(tv,last) > 500) {
40 + if ((count > 0 || forever) && (last.tv_sec == 0 || MS_TDIFF(tv, last) > 500)) {
41 + count--;
42 send_pack(s, src, dst, &me[0], &he[0]);
43 if (count == 0 && unsolicited)
44 finish();
45 @@ -339,6 +342,10 @@ main(int argc, char **argv)
46 break;
47 case 'c':
48 count = atoi(optarg);
49 + if (count > 0)
50 + forever = 0;
51 + else
52 + forever = 1;
53 break;
54 case 'w':
55 timeout = atoi(optarg);
56 @@ -544,7 +551,8 @@ main(int argc, char **argv)
57 sigaddset(&sset, SIGALRM);
58 sigaddset(&sset, SIGINT);
59 sigprocmask(SIG_BLOCK, &sset, &osset);
60 - recv_pack(packet, cc, &from[0]);
61 + if (recv_pack(packet, cc, from) && count == 0 && !forever)
62 + finish();
63 sigprocmask(SIG_SETMASK, &osset, NULL);
64 }
65 }