- Renamed the `proxy'' modifier of the -d flag to `pub'',

to be consistent with the -s flag.  Updated documentation
  on what this modifier does.

- Added the ``only'' keyword to the -s and -S flags, that
  could be used to created "proxy-only" published entries.
  Previously, arp(8) created an entry of this type only
  in the absence of the route to a destination.

PR:		bin/12357
MFC after:	1 week
This commit is contained in:
Ruslan Ermilov 2001-06-07 12:35:53 +00:00
parent d9c185f10a
commit 3f844a2221
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=77870
2 changed files with 53 additions and 27 deletions

View File

@ -47,18 +47,18 @@
.Fl a
.Nm
.Fl d Ar hostname
.Op Cm proxy
.Op Cm pub
.Nm
.Fl d
.Fl a
.Nm
.Fl s Ar hostname ether_addr
.Op Cm temp
.Op Cm pub
.Op Cm pub Op Cm only
.Nm
.Fl S Ar hostname ether_addr
.Op Cm temp
.Op Cm pub
.Op Cm pub Op Cm only
.Nm
.Fl f Ar filename
.Sh DESCRIPTION
@ -86,10 +86,17 @@ A super-user may delete an entry for the host called
with the
.Fl d
flag.
The
.Cm proxy
keyword is sometimes required when deleting published ARP entries.
This flag may be combined with the
It the
.Cm pub
keyword is specified, only
.Dq published
.Tn ARP
entry
for this host will be deleted.
.Pp
Alternatively, the
.Fl d
flag may be combined with the
.Fl a
flag to delete all entries.
.It Fl n
@ -109,7 +116,9 @@ The entry will be permanent unless the word
is given in the command.
If the word
.Cm pub
is given, the entry will be "published"; i.e., this system will
is given, the entry will be
.Dq published ;
i.e., this system will
act as an
.Tn ARP
server,
@ -123,6 +132,16 @@ can be given as
in which case the interfaces on this host will be examined,
and if one of them is found to occupy the same subnet, its
Ethernet address will be used.
If the
.Cm only
keyword is also specified, this will create a
.Dq "published (proxy only)"
entry.
This type of entry is created automatically if
.Nm
detects that the routing table entry for
.Ar hostname
already exists.
.It Fl S Ar hostname ether_addr
Is just like
.Fl s

View File

@ -115,9 +115,7 @@ static int s = -1;
#define SETFUNC(f) { if (func) usage(); func = (f); }
int
main(argc, argv)
int argc;
char **argv;
main(int argc, char *argv[])
{
int ch, func = 0;
int rtn = 0;
@ -166,7 +164,7 @@ main(argc, argv)
break;
case F_SET:
case F_REPLACE:
if (argc < 2 || argc > 5)
if (argc < 2 || argc > 6)
usage();
if (func == F_REPLACE)
(void) delete(argv[0], NULL);
@ -239,7 +237,7 @@ getsocket(void)
struct sockaddr_in so_mask = {8, 0, 0, { 0xffffffff}};
struct sockaddr_inarp blank_sin = {sizeof(blank_sin), AF_INET }, sin_m;
struct sockaddr_dl blank_sdl = {sizeof(blank_sdl), AF_LINK }, sdl_m;
int expire_time, flags, export_only, doing_proxy, found_entry;
int expire_time, flags, doing_proxy, proxy_only, found_entry;
struct {
struct rt_msghdr m_rtm;
char m_space[512];
@ -264,7 +262,7 @@ set(int argc, char **argv)
sdl_m = blank_sdl;
sin_m = blank_sin;
sin->sin_addr.s_addr = inet_addr(host);
if (sin->sin_addr.s_addr == -1) {
if (sin->sin_addr.s_addr == INADDR_NONE) {
if (!(hp = gethostbyname(host))) {
warnx("%s: %s", host, hstrerror(h_errno));
return (1);
@ -272,16 +270,21 @@ set(int argc, char **argv)
bcopy((char *)hp->h_addr, (char *)&sin->sin_addr,
sizeof sin->sin_addr);
}
doing_proxy = flags = export_only = expire_time = 0;
doing_proxy = flags = proxy_only = expire_time = 0;
while (argc-- > 0) {
if (strncmp(argv[0], "temp", 4) == 0) {
struct timeval time;
gettimeofday(&time, 0);
expire_time = time.tv_sec + 20 * 60;
struct timeval tv;
gettimeofday(&tv, 0);
expire_time = tv.tv_sec + 20 * 60;
}
else if (strncmp(argv[0], "pub", 3) == 0) {
flags |= RTF_ANNOUNCE;
doing_proxy = SIN_PROXY;
doing_proxy = 1;
if (argc && strncmp(argv[1], "only", 3) == 0) {
proxy_only = 1;
sin_m.sin_other = SIN_PROXY;
argc--; argv++;
}
} else if (strncmp(argv[0], "trail", 5) == 0) {
printf("%s: Sending trailers is no longer supported\n",
host);
@ -324,7 +327,7 @@ set(int argc, char **argv)
return(1);
}
sin_m.sin_other = SIN_PROXY;
export_only = 1;
proxy_only = 1;
goto tryagain;
}
overwrite:
@ -348,7 +351,7 @@ get(char *host)
sin_m = blank_sin;
sin->sin_addr.s_addr = inet_addr(host);
if (sin->sin_addr.s_addr == -1) {
if (sin->sin_addr.s_addr == INADDR_NONE) {
if (!(hp = gethostbyname(host)))
errx(1, "%s: %s", host, hstrerror(h_errno));
bcopy((char *)hp->h_addr, (char *)&sin->sin_addr,
@ -376,10 +379,14 @@ delete(char *host, char *info)
getsocket();
sin_m = blank_sin;
if (info && strncmp(info, "pro", 3) == 0)
sin_m.sin_other = SIN_PROXY;
if (info) {
if (strncmp(info, "pub", 3) == 0)
sin_m.sin_other = SIN_PROXY;
else
usage();
}
sin->sin_addr.s_addr = inet_addr(host);
if (sin->sin_addr.s_addr == -1) {
if (sin->sin_addr.s_addr == INADDR_NONE) {
if (!(hp = gethostbyname(host))) {
warnx("%s: %s", host, hstrerror(h_errno));
return (1);
@ -470,7 +477,7 @@ void
print_entry(struct sockaddr_dl *sdl,
struct sockaddr_inarp *sin, struct rt_msghdr *rtm)
{
char *host;
const char *host;
struct hostent *hp;
int seg;
@ -567,7 +574,7 @@ usage(void)
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
"usage: arp [-n] hostname",
" arp [-n] -a",
" arp -d hostname [proxy]",
" arp -d hostname [pub]",
" arp -d -a",
" arp -s hostname ether_addr [temp] [pub]",
" arp -S hostname ether_addr [temp] [pub]",
@ -601,7 +608,7 @@ rtmsg(int cmd)
rtm->rtm_flags |= (RTF_HOST | RTF_STATIC);
sin_m.sin_other = 0;
if (doing_proxy) {
if (export_only)
if (proxy_only)
sin_m.sin_other = SIN_PROXY;
else {
rtm->rtm_addrs |= RTA_NETMASK;