lint-style cleanup
[unix-history] / usr / src / usr.sbin / arp / arp.c
index ab860b9..9461958 100644 (file)
@@ -15,18 +15,17 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)arp.c      5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)arp.c      5.17 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
  * arp - display, set, and delete arp table entries
  */
 
 #endif /* not lint */
 
 /*
  * arp - display, set, and delete arp table entries
  */
 
-
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/socket.h>
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/socket.h>
-#include <sys/kinfo.h>
+#include <sys/sysctl.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
@@ -36,15 +35,17 @@ static char sccsid[] = "@(#)arp.c   5.12 (Berkeley) %G%";
 #include <netinet/in.h>
 #include <netinet/if_ether.h>
 
 #include <netinet/in.h>
 #include <netinet/if_ether.h>
 
+#include <arpa/inet.h>
+
 #include <netdb.h>
 #include <errno.h>
 #include <nlist.h>
 #include <netdb.h>
 #include <errno.h>
 #include <nlist.h>
+#include <kvm.h>
 #include <stdio.h>
 #include <paths.h>
 
 extern int errno;
 static int pid;
 #include <stdio.h>
 #include <paths.h>
 
 extern int errno;
 static int pid;
-static int kflag;
 static int nflag;
 static int s = -1;
 
 static int nflag;
 static int s = -1;
 
@@ -175,10 +176,13 @@ set(argc, argv)
                        gettimeofday(&time, 0);
                        expire_time = time.tv_sec + 20 * 60;
                }
                        gettimeofday(&time, 0);
                        expire_time = time.tv_sec + 20 * 60;
                }
-               else if (strncmp(argv[0], "pub", 3) == 0)
+               else if (strncmp(argv[0], "pub", 3) == 0) {
+                       flags |= RTF_ANNOUNCE;
                        doing_proxy = SIN_PROXY;
                        doing_proxy = SIN_PROXY;
-               else if (strncmp(argv[0], "trail", 5) == 0)
-                       flags = RTF_PROTO1;
+               } else if (strncmp(argv[0], "trail", 5) == 0) {
+                       printf("%s: Sending trailers is no longer supported\n",
+                               host);
+               }
                argv++;
        }
 tryagain:
                argv++;
        }
 tryagain:
@@ -227,7 +231,6 @@ get(host)
        struct hostent *hp;
        struct sockaddr_inarp *sin = &sin_m;
        u_char *ea;
        struct hostent *hp;
        struct sockaddr_inarp *sin = &sin_m;
        u_char *ea;
-       char *inet_ntoa();
 
        sin_m = blank_sin;
        sin->sin_addr.s_addr = inet_addr(host);
 
        sin_m = blank_sin;
        sin->sin_addr.s_addr = inet_addr(host);
@@ -314,8 +317,8 @@ delete:
 dump(addr)
 u_long addr;
 {
 dump(addr)
 u_long addr;
 {
-       int sz, needed, rlen;
-       long op = KINFO_RT_FLAGS | (((long)AF_INET) << 16);
+       int mib[6];
+       size_t needed;
        char *host, *malloc(), *lim, *buf, *next;
        struct rt_msghdr *rtm;
        struct sockaddr_inarp *sin;
        char *host, *malloc(), *lim, *buf, *next;
        struct rt_msghdr *rtm;
        struct sockaddr_inarp *sin;
@@ -323,22 +326,6 @@ u_long addr;
        extern int h_errno;
        struct hostent *hp;
 
        extern int h_errno;
        struct hostent *hp;
 
-       if ((needed = getkerninfo(op, 0, 0, RTF_LLINFO)) < 0)
-               quit("route-getkerninfo-estimate");
-       if ((buf = malloc(needed)) == NULL)
-               quit("malloc");
-       if ((rlen = getkerninfo(op, buf, &needed, RTF_LLINFO)) < 0)
-               quit("actual retrieval of routing table");
-       lim = buf + rlen;
-       for (next = buf; next < lim; next += rtm->rtm_msglen) {
-               rtm = (struct rt_msghdr *)next;
-               sin = (struct sockaddr_inarp *)(rtm + 1);
-               sdl = (struct sockaddr_dl *)(sin + 1);
-               if (addr) {
-                       if (addr != sin->sin_addr.s_addr)
-                               continue;
-                       found_entry = 1;
-               }
                if (nflag == 0)
                        hp = gethostbyaddr((caddr_t)&(sin->sin_addr),
                            sizeof sin->sin_addr, AF_INET);
                if (nflag == 0)
                        hp = gethostbyaddr((caddr_t)&(sin->sin_addr),
                            sizeof sin->sin_addr, AF_INET);
@@ -360,8 +347,6 @@ u_long addr;
                        printf(" permanent");
                if (sin->sin_other & SIN_PROXY)
                        printf(" published (proxy only)");
                        printf(" permanent");
                if (sin->sin_other & SIN_PROXY)
                        printf(" published (proxy only)");
-               if (rtm->rtm_flags & RTF_PROTO1)
-                       printf(" trailers");
                if (rtm->rtm_addrs & RTA_NETMASK) {
                        sin = (struct sockaddr_inarp *)
                                (sdl->sdl_len + (char *)sdl);
                if (rtm->rtm_addrs & RTA_NETMASK) {
                        sin = (struct sockaddr_inarp *)
                                (sdl->sdl_len + (char *)sdl);
@@ -372,8 +357,6 @@ u_long addr;
                }
                printf("\n");
        }
                }
                printf("\n");
        }
-}
-
 ether_print(cp)
        u_char *cp;
 {
 ether_print(cp)
        u_char *cp;
 {
@@ -402,7 +385,7 @@ usage()
        printf("usage: arp hostname\n");
        printf("       arp -a [kernel] [kernel_memory]\n");
        printf("       arp -d hostname\n");
        printf("usage: arp hostname\n");
        printf("       arp -a [kernel] [kernel_memory]\n");
        printf("       arp -d hostname\n");
-       printf("       arp -s hostname ether_addr [temp] [pub] [trail]\n");
+       printf("       arp -s hostname ether_addr [temp] [pub]\n");
        printf("       arp -f filename\n");
        exit(1);
 }
        printf("       arp -f filename\n");
        exit(1);
 }
@@ -430,7 +413,7 @@ rtmsg(cmd)
                rtm->rtm_addrs |= RTA_GATEWAY;
                rtm->rtm_rmx.rmx_expire = expire_time;
                rtm->rtm_inits = RTV_EXPIRE;
                rtm->rtm_addrs |= RTA_GATEWAY;
                rtm->rtm_rmx.rmx_expire = expire_time;
                rtm->rtm_inits = RTV_EXPIRE;
-               rtm->rtm_flags |= RTF_HOST;
+               rtm->rtm_flags |= (RTF_HOST | RTF_STATIC);
                sin_m.sin_other = 0;
                if (doing_proxy) {
                        if (export_only)
                sin_m.sin_other = 0;
                if (doing_proxy) {
                        if (export_only)