The following commit has been merged in the next branch: commit 5f3776affad426fc2c00be3fb04c1bc1158829c5 Author: Sven Eckelmann sven@narfation.org Date: Sun Nov 20 16:35:16 2011 +0100
batctl: Return failure code when ping was not successful
The standard iputils-ping returns an error code when it could not receive a single reply to a echo request. batctl ping behaved differently and made it only possible to detect that the target is not reachable by parsing the text output of batctl.
A new return code EXIT_NOSUCCESS (2) is introduced to distinguish a general failure from the inability to reach another node.
Reported-by: Filippo Sallemi tonyputi@gmail.com Signed-off-by: Sven Eckelmann sven@narfation.org
diff --git a/main.h b/main.h index e5a3e01..fb7ca38 100644 --- a/main.h +++ b/main.h @@ -25,4 +25,6 @@
#define SOCKET_PATH_FMT "%s/batman_adv/%s/socket"
+#define EXIT_NOSUCCESS 2 + #define __packed __attribute((packed)) /* linux kernel compat */ diff --git a/ping.c b/ping.c index d880290..b7c2932 100644 --- a/ping.c +++ b/ping.c @@ -322,7 +322,10 @@ sleep: printf("rtt min/avg/max/mdev = %.3f/%.3f/%.3f/%.3f ms\n", min, avg, max, mdev);
- ret = EXIT_SUCCESS; + if (packets_in) + ret = EXIT_SUCCESS; + else + ret = EXIT_NOSUCCESS;
out: bat_hosts_free();