From: Klaas Freitag Date: Mon, 6 Dec 1999 16:57:27 +0000 (+0000) Subject: Allow exchange of hostname and mac address in the file read by arp -f. X-Git-Tag: v1.60~74 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09c0d84427d385c52a49c3e180addbb70a75a7d7;p=platform%2Fupstream%2Fnet-tools.git Allow exchange of hostname and mac address in the file read by arp -f. This is for consistency with rarp /etc/ethers. Default to /etc/ethers when no file name is supplied. This hack does not work with IPv6, but arp does not work with IPv6 anyways so it does not matter. Patch from Thorsten Kukuk Fixed man pages (only German and English one). Add blurb about automagic subnet arp. --- diff --git a/arp.c b/arp.c index 71641a2..4e3cec3 100644 --- a/arp.c +++ b/arp.c @@ -8,7 +8,7 @@ * NET-3 Networking Distribution for the LINUX operating * system. * - * Version: $Id: arp.c,v 1.15 1999/11/21 00:40:27 ecki Exp $ + * Version: $Id: arp.c,v 1.16 1999/12/06 16:57:27 freitag Exp $ * * Maintainer: Bernd 'eckes' Eckenfels, * @@ -404,6 +404,14 @@ static int arp_file(char *name) linenr, name); continue; } + if (strchr (args[0], ':') != NULL) { + /* We have a correct ethers file, switch hw adress and hostname + for arp */ + char *cp; + cp = args[1]; + args[1] = args[0]; + args[0] = cp; + } if (arp_set(args) != 0) fprintf(stderr, _("arp: cannot set entry on line %u of etherfile %s !\n"), linenr, name); @@ -604,7 +612,7 @@ static void usage(void) { fprintf(stderr, _("Usage:\n arp [-vn] [] [-i ] [-a] [] <-Display ARP cache\n")); fprintf(stderr, _(" arp [-v] [-i ] -d [pub][nopub] <-Delete ARP entry\n")); - fprintf(stderr, _(" arp [-vnD] [] [-i ] -f <-Add entry from file\n")); + fprintf(stderr, _(" arp [-vnD] [] [-i ] -f [] <-Add entry from file\n")); fprintf(stderr, _(" arp [-v] [] [-i ] -s [temp][nopub] <-Add entry\n")); fprintf(stderr, _(" arp [-v] [] [-i ] -s [netmask ] pub <-''-\n")); fprintf(stderr, _(" arp [-v] [] [-i ] -Ds [netmask ] pub <-''-\n\n")); @@ -617,7 +625,7 @@ static void usage(void) fprintf(stderr, _(" -i, --device specify network interface (e.g. eth0)\n")); fprintf(stderr, _(" -D, --use-device read from given device\n")); fprintf(stderr, _(" -A, -p, --protocol specify protocol family\n")); - fprintf(stderr, _(" -f, --file read new entries from file\n\n")); + fprintf(stderr, _(" -f, --file read new entries from file or from /etc/ethers\n\n")); fprintf(stderr, _(" =Use '-H ' to specify hardware address type. Default: %s\n"), DFLT_HW); fprintf(stderr, _(" List of possible hardware types (which support ARP):\n")); @@ -755,7 +763,7 @@ int main(int argc, char **argv) break; case 2: /* process an EtherFile */ - what = arp_file(argv[optind]); + what = arp_file(argv[optind] ? argv[optind] : "/etc/ethers"); break; case 3: /* delete an ARP entry from the cache */ diff --git a/man/de_DE/arp.8 b/man/de_DE/arp.8 index c948f10..f3632ad 100644 --- a/man/de_DE/arp.8 +++ b/man/de_DE/arp.8 @@ -42,7 +42,7 @@ arp \- Manipulation des ARP-Caches .RB [ \-vnD ] .RB [ "\-H Typ" ] .RB [ "-i Schnittstelle" ] -.B -f Dateiname +.B -f [Dateiname] .SH BESCHREIBUNG .B Arp @@ -128,7 +128,12 @@ in den ARP-Cache eingetragen. .br .B ANMERKUNG: Ab der Kernelversion 2.2.0 ist es nicht mehr m\(:oglich ARP-Eintr\(:age f\(:ur -ganze Teilnetze zu erzeugen. +ganze Teilnetze zu erzeugen. Statt dessen wird automatisches Proxy ARP +durchgef\(:uhrt, d.h. wenn eine Route existiert und Forwarding eingeschaltet +ist wird automatisch ein tempor\(:arer Proxyarpeintrag erzeugt. +Siehe auch +.BR arp (7) +f\(:ur mehr Details. .TP .B "\-f Dateiname, \-\-file Dateiname" \(:Ahnlich der @@ -138,7 +143,8 @@ Option, au\(sser, da\(ss diesmal die Adressinformation aus der Datei verwendet wird. Dies kann verwendet werden, wenn ARP-Eintr\(:age f\(:ur etliche Rechner erzeugt werden m\(:ussen. Der Name dieser Datei ist oft .IR /etc/ethers , -aber dies ist nicht offiziel standardisiert. +aber dies ist nicht offizieil standardisiert. Wenn kein Dateinamen +angeben ist wird /etc/ethers benutzt. .sp 1 Das Format der Datei ist einfach; es enth\(:alt nur ASCII-Textzeilen, die aus einem Rechnernamen und einer Hardwareadresse getrennt von einem @@ -151,6 +157,9 @@ angegeben werden. erwartet wird, kann auch eine .B "IP-Adresse" in Form eines durch Punkte getrennten Dezimalquadrupels angegeben werden. +.P +Aus Kompatiblit\(:atsgr\(:unden k\(:onnen Rechnername und die +Hardwareadresse auch vertauscht werden. .LP Jeder vollst\(:andige Eintrag wird im ARP-Cache mit der .B C diff --git a/man/en_US/arp.8 b/man/en_US/arp.8 index ef1abba..a28a87a 100644 --- a/man/en_US/arp.8 +++ b/man/en_US/arp.8 @@ -42,7 +42,7 @@ arp \- manipulate the system ARP cache .RB [ \-vnD ] .RB [ "\-H type" ] .RB [ "-i if" ] -.B -f filename +.B -f [filename] .SH DESCRIPTION .B Arp @@ -129,7 +129,10 @@ cache. .br .B NOTE: As of kernel 2.2.0 it is no longer possible to set an ARP entry for an -entire subnet. +entire subnet. Linux instead does automagic proxy arp when a route +exists and it is forwarding. See +.BR arp (7) +for details. .TP .B "\-f filename, \-\-file filename" Similar to the @@ -139,7 +142,8 @@ option, only this time the address info is taken from file . This can be used if ARP entries for a lot of hosts have to be set up. The name of the data file is very often .IR /etc/ethers , -but this is not official. +but this is not official. If no filename is specified /etc/ethers +is used as default. .sp 1 The format of the file is simple; it only contains ASCII text lines with a hostname, and a hardware @@ -152,6 +156,9 @@ In all places where a is expected, one can also enter an .B "IP address" in dotted-decimal notation. +.P +As a special case for compatibility the order of the hostname and +the hardware address can be exchanged. .LP Each complete entry in the ARP cache will be marked with the .B C