[LARTC] Patch for arping

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a multi-part message in MIME format.
--------------020501090002070402040804
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

This is probably the wrong forum for this, a small patch for arping. 
However:

- the guy who wrote arping, part of iputils, also wrote iproute2
- that guy is pretty much unreachable -- or I have to presume so, 
because his ftp site, the main site for his work, has been broken for 
months now
- I don't know where else to send it
- it might be useful to someone else

It's just a fix for an annoyance -- you should be able to arping from a 
source address you don't actually have. Don't ask me why one would want 
to do this; it solves a detailed problem I have, and I can't be the only 
one.

Btw, if you're interested enough to have read this far, this patches 
cleanly over the RedHat 8.0-patched version of arping. It adds one 
option, -B, which means, "don't bother trying to bind, just do your 
business."

-Steve


--- arping.c	2003-02-13 00:45:26.000000000 -0800
+++ arping.c.new	2003-02-13 00:44:45.000000000 -0800
@@ -38,6 +38,7 @@
 char *device="eth0";
 int ifindex;
 char *source;
+int nobind=0;
 struct in_addr src, dst;
 char *target;
 int dad, unsolicited, advert;
@@ -62,7 +63,7 @@
 void usage(void)
 {
 	fprintf(stderr,
- 		"Usage: arping [-fqbDUAV] [-c count] [-w timeout] [-I device] [-s source] destination\n"
+ 		"Usage: arping [-fqbDUAVB] [-c count] [-w timeout] [-I device] [-s source] destination\n"
  		"  -f : quit on first reply\n"
 		"  -q : be quiet\n"
  		"  -b : keep broadcasting, don't go unicast\n"
@@ -70,6 +71,7 @@
 		"  -U : Unsolicited ARP mode, update your neighbours\n"
 		"  -A : ARP answer mode, update your neighbours\n"
 		"  -V : print version and exit\n"
+		"  -B : do not try to bind to source address\n"
 		"  -c count : how many packets to send\n"
 		"  -w timeout : how long to wait for a reply\n"
 		"  -I device : which ethernet device to use (eth0)\n"
@@ -306,7 +308,7 @@
 
 	setuid(uid);
 
-	while ((ch = getopt(argc, argv, "h?bfDUAqc:w:s:I:V")) != EOF) {
+	while ((ch = getopt(argc, argv, "h?bfDUAqc:w:s:I:VB")) != EOF) {
 		switch(ch) {
 		case 'b':
 			broadcast_only=1;
@@ -340,6 +342,9 @@
 		case 's':
 			source = optarg;
 			break;
+		case 'B':
+			nobind = 1;
+			break;
 		case 'V':
 			printf("arping utility, iputils-ss%s\n", SNAPSHOT);
 			exit(0);
@@ -428,7 +433,7 @@
 		saddr.sin_family = AF_INET;
 		if (src.s_addr) {
 			saddr.sin_addr = src;
-			if (bind(probe_fd, (struct sockaddr*)&saddr, sizeof(saddr)) == -1) {
+			if (!nobind && bind(probe_fd, (struct sockaddr*)&saddr, sizeof(saddr)) == -1) {
 				perror("bind");
 				exit(2);
 			}



--------------020501090002070402040804
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title></title>
</head>
<body>
This is probably the wrong forum for this, a small patch for arping.
However:<br>
<br>
- the guy who wrote arping, part of iputils, also wrote iproute2<br>
- that guy is pretty much unreachable -- or I have to presume so,
because his ftp site, the main site for his work, has been broken for
months now<br>
- I don't know where else to send it<br>
- it might be useful to someone else<br>
<br>
It's just a fix for an annoyance -- you should be able to arping from a
source address you don't actually have. Don't ask me why one would want
to do this; it solves a detailed problem I have, and I can't be the
only one.<br>
<br>
Btw, if you're interested enough to have read this far, this patches
cleanly over the RedHat 8.0-patched version of arping. It adds one
option, -B, which means, "don't bother trying to bind, just do your
business."<br>
<br>
-Steve<br>
<br>
<br>
<div class="moz-text-plain" wrap="true" graphical-quote="true"
 style="font-family: -moz-fixed; font-size: 14px;" lang="x-western">
<pre wrap="">--- arping.c	2003-02-13 00:45:26.000000000 -0800
+++ arping.c.new	2003-02-13 00:44:45.000000000 -0800
@@ -38,6 +38,7 @@
 char *device="eth0";
 int ifindex;
 char *source;
+int nobind=0;
 struct in_addr src, dst;
 char *target;
 int dad, unsolicited, advert;
@@ -62,7 +63,7 @@
 void usage(void)
 {
 	fprintf(stderr,
- 		"Usage: arping [-fqbDUAV] [-c count] [-w timeout] [-I device] [-s source] destination\n"
+ 		"Usage: arping [-fqbDUAVB] [-c count] [-w timeout] [-I device] [-s source] destination\n"
  		"  -f : quit on first reply\n"
 		"  -q : be quiet\n"
  		"  -b : keep broadcasting, don't go unicast\n"
@@ -70,6 +71,7 @@
 		"  -U : Unsolicited ARP mode, update your neighbours\n"
 		"  -A : ARP answer mode, update your neighbours\n"
 		"  -V : print version and exit\n"
+		"  -B : do not try to bind to source address\n"
 		"  -c count : how many packets to send\n"
 		"  -w timeout : how long to wait for a reply\n"
 		"  -I device : which ethernet device to use (eth0)\n"
@@ -306,7 +308,7 @@
 
 	setuid(uid);
 
-	while ((ch = getopt(argc, argv, "h?<a class="moz-txt-link-freetext"
 href="bfDUAqc:w:s:I:V">bfDUAqc:w:s:I:V</a>")) != EOF) {
+	while ((ch = getopt(argc, argv, "h?<a class="moz-txt-link-freetext"
 href="bfDUAqc:w:s:I:VB">bfDUAqc:w:s:I:VB</a>")) != EOF) {
 		switch(ch) {
 		case 'b':
 			broadcast_only=1;
@@ -340,6 +342,9 @@
 		case 's':
 			source = optarg;
 			break;
+		case 'B':
+			nobind = 1;
+			break;
 		case 'V':
 			printf("arping utility, iputils-ss%s\n", SNAPSHOT);
 			exit(0);
@@ -428,7 +433,7 @@
 		saddr.sin_family = AF_INET;
 		if (src.s_addr) {
 			saddr.sin_addr = src;
-			if (bind(probe_fd, (struct sockaddr*)&amp;saddr, sizeof(saddr)) == -1) {
+			if (!nobind &amp;&amp; bind(probe_fd, (struct sockaddr*)&amp;saddr, sizeof(saddr)) == -1) {
 				perror("bind");
 				exit(2);
 			}
</pre>
</div>
<br>
</body>
</html>

--------------020501090002070402040804--



[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux