summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c08528d)
raw | patch | inline | side by side (parent: c08528d)
author | Florian Forster <octo@verplant.org> | |
Mon, 12 Jun 2006 20:48:23 +0000 (22:48 +0200) | ||
committer | Florian Forster <octo@verplant.org> | |
Mon, 12 Jun 2006 20:48:23 +0000 (22:48 +0200) |
D'oh!
src/liboping.c | patch | blob | history |
diff --git a/src/liboping.c b/src/liboping.c
index 9fad0c2dc09dbabf353a1fa9f28772c72ce28d6f..21855e1fc04f077dcd6ba149c89e78a475b85aa4 100644 (file)
--- a/src/liboping.c
+++ b/src/liboping.c
continue;
}
-/*
- * The majority vote of operating systems has decided that you don't need to
- * bind here. This code should be reactivated to bind to a specific address,
- * though. See the `-I' option of `ping(1)' (GNU). -octo
- */
-#if 0
- if (bind (ph->fd, (struct sockaddr *) &sockaddr, sockaddr_len) == -1)
+ if (obj->srcaddr != NULL)
{
- dprintf ("bind: %s\n", strerror (errno));
- ping_set_error (obj, "bind", strerror (errno));
- close (ph->fd);
- ph->fd = -1;
- continue;
+ assert (obj->srcaddrlen > 0);
+ assert (obj->srcaddrlen <= sizeof (struct sockaddr_storage));
+
+ if (bind (ph->fd, (struct sockaddr *) obj->srcaddr, obj->srcaddrlen) == -1)
+ {
+ dprintf ("bind: %s\n", strerror (errno));
+ ping_set_error (obj, "bind", strerror (errno));
+ close (ph->fd);
+ ph->fd = -1;
+ continue;
+ }
}
-#endif
assert (sizeof (struct sockaddr_storage) >= ai_ptr->ai_addrlen);
memset (ph->addr, '\0', sizeof (struct sockaddr_storage));