1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
The following patch from Yury Shevchuk (sizif@botik.ru) may make the -I
option to ping work if it doesn't.
----------------------------
revision 1.1.1.3
date: 1996/06/04 12:54:39; author: sizif; state: Exp; lines: +12 -1
Use bind(2) to set source address for -I. (This used to be done with
multicast-related ioctls, and #if 0'd out probably because Linux
lack[s/ed] support for them).
----------------------------
--- ping.c 1995/08/18 08:24:10 1.1.1.2
+++ ping.c 1996/06/04 12:54:39 1.1.1.3
@@ -377,10 +377,21 @@
}
if (moptions & MULTICAST_IF) {
if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF,
&ifaddr, sizeof(ifaddr)) == -1) {
perror ("can't set multicast source interface");
+ exit(94);
+ }
+ }
+/*#else*/
+ if (moptions & MULTICAST_IF) {
+ struct sockaddr_in sa;
+ sa.sin_family = AF_INET;
+ sa.sin_addr = ifaddr;
+ sa.sin_port = 0;
+ if (bind(s, &sa, sizeof(sa)) == -1) {
+ perror ("can't set source interface");
exit(94);
}
}
#endif
|