diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-07-13 20:57:12 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-07-13 20:57:12 +0200 |
commit | 42409f7f228083dad788efd4ed3cc96d26712c6f (patch) | |
tree | 45e11b7c4bdb2a7df98fc1322f4ed977ad850d07 /pingu_ping.c | |
parent | 0a0ed0b5472cd19043799a9953ac06fd11ae7585 (diff) | |
download | pingu-42409f7f228083dad788efd4ed3cc96d26712c6f.tar.bz2 pingu-42409f7f228083dad788efd4ed3cc96d26712c6f.tar.xz |
pingu: try bind socket to interface every burst
It might be an interface that disappeared and came back, e.g ppp0.
We also don't even try unless we have a successful binding.
Diffstat (limited to 'pingu_ping.c')
-rw-r--r-- | pingu_ping.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/pingu_ping.c b/pingu_ping.c index 4f15c32..037fb44 100644 --- a/pingu_ping.c +++ b/pingu_ping.c @@ -99,17 +99,22 @@ static void pingu_ping_handle_reply(struct ev_loop *loop, free(ping); } -int pingu_ping_send(struct ev_loop *loop, struct pingu_host *host) +int pingu_ping_send(struct ev_loop *loop, struct pingu_host *host, + int set_status_on_failure) { int packetlen = sizeof(struct iphdr) + sizeof(struct icmphdr); struct pingu_ping *ping; int seq, r; + if ((host->iface->name[0] != '\0') && !host->iface->has_binding) + return pingu_host_set_status(host, 0) - 1; + seq = pingu_ping_get_seq(); r = icmp_send_ping(host->iface->fd, &host->burst.saddr, sizeof(host->burst.saddr), seq, packetlen); if (r < 0) { - pingu_host_set_status(host, 0); + if (set_status_on_failure) + pingu_host_set_status(host, 0); return -1; } |