Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/arp Kill __P(), use ANSI function declarations, con...



details:   https://anonhg.NetBSD.org/src/rev/0eea305b4e59
branches:  trunk
changeset: 574880:0eea305b4e59
user:      xtraeme <xtraeme%NetBSD.org@localhost>
date:      Wed Mar 16 02:04:51 2005 +0000

description:
Kill __P(), use ANSI function declarations, constify; WARNS=3

diffstat:

 usr.sbin/arp/Makefile |    3 +-
 usr.sbin/arp/arp.c    |  156 ++++++++++++++++++++++---------------------------
 2 files changed, 71 insertions(+), 88 deletions(-)

diffs (truncated from 394 to 300 lines):

diff -r 637662bc80e8 -r 0eea305b4e59 usr.sbin/arp/Makefile
--- a/usr.sbin/arp/Makefile     Wed Mar 16 01:44:46 2005 +0000
+++ b/usr.sbin/arp/Makefile     Wed Mar 16 02:04:51 2005 +0000
@@ -1,7 +1,8 @@
-#      $NetBSD: Makefile,v 1.8 1995/03/01 11:50:52 chopps Exp $
+#      $NetBSD: Makefile,v 1.9 2005/03/16 02:04:51 xtraeme Exp $
 #      from: @(#)Makefile      8.2 (Berkeley) 4/18/94
 
 PROG=  arp
 MAN=   arp.4 arp.8
+WARNS=  3
 
 .include <bsd.prog.mk>
diff -r 637662bc80e8 -r 0eea305b4e59 usr.sbin/arp/arp.c
--- a/usr.sbin/arp/arp.c        Wed Mar 16 01:44:46 2005 +0000
+++ b/usr.sbin/arp/arp.c        Wed Mar 16 02:04:51 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arp.c,v 1.40 2004/08/14 02:16:13 jrf Exp $ */
+/*     $NetBSD: arp.c,v 1.41 2005/03/16 02:04:51 xtraeme Exp $ */
 
 /*
  * Copyright (c) 1984, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)arp.c      8.3 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: arp.c,v 1.40 2004/08/14 02:16:13 jrf Exp $");
+__RCSID("$NetBSD: arp.c,v 1.41 2005/03/16 02:04:51 xtraeme Exp $");
 #endif
 #endif /* not lint */
 
@@ -80,20 +80,19 @@
 #include <unistd.h>
 #include <ifaddrs.h>
 
-int    delete __P((const char *, const char *));
-void   dump __P((u_long));
-void   delete_all __P((void));
-void   sdl_print __P((const struct sockaddr_dl *));
-int    getifname __P((u_int16_t, char *, size_t));
-int    atosdl __P((const char *s, struct sockaddr_dl *sdl));
-int    file __P((char *));
-void   get __P((const char *));
-int    getinetaddr __P((const char *, struct in_addr *));
-void   getsocket __P((void));
-int    main __P((int, char **));
-int    rtmsg __P((int));
-int    set __P((int, char **));
-void   usage __P((void));
+int    delete(const char *, const char *);
+void   dump(u_long);
+void   delete_all(void);
+void   sdl_print(const struct sockaddr_dl *);
+int    getifname(u_int16_t, char *, size_t);
+int    atosdl(const char *s, struct sockaddr_dl *sdl);
+int    file(char *);
+void   get(const char *);
+int    getinetaddr(const char *, struct in_addr *);
+void   getsocket(void);
+int    rtmsg(int);
+int    set(int, char **);
+void   usage(void);
 
 static int pid;
 static int aflag, nflag, vflag;
@@ -101,9 +100,7 @@
 static struct ifaddrs* ifaddrs = NULL;
 
 int
-main(argc, argv)
-       int argc;
-       char **argv;
+main(int argc, char **argv)
 {
        int ch;
        int op = 0;
@@ -173,8 +170,7 @@
  * Process a file to set standard arp entries
  */
 int
-file(name)
-       char *name;
+file(char *name)
 {
        char line[100], arg[5][50], *args[5];
        int i, retval;
@@ -204,7 +200,7 @@
 }
 
 void
-getsocket()
+getsocket(void)
 {
        if (s >= 0)
                return;
@@ -226,17 +222,15 @@
  * Set an individual arp entry 
  */
 int
-set(argc, argv)
-       int argc;
-       char **argv;
+set(int argc, char **argv)
 {
-       struct sockaddr_inarp *sin;
+       struct sockaddr_inarp *sina;
        struct sockaddr_dl *sdl;
        struct rt_msghdr *rtm;
        char *host = argv[0], *eaddr;
        int rval;
 
-       sin = &sin_m;
+       sina = &sin_m;
        rtm = &(m_rtmsg.m_rtm);
        eaddr = argv[1];
 
@@ -245,16 +239,16 @@
        argv += 2;
        sdl_m = blank_sdl;              /* struct copy */
        sin_m = blank_sin;              /* struct copy */
-       if (getinetaddr(host, &sin->sin_addr) == -1)
+       if (getinetaddr(host, &sina->sin_addr) == -1)
                return (1);
        if (atosdl(eaddr, &sdl_m))
                warnx("invalid link-level address '%s'", eaddr);
        doing_proxy = flags = export_only = expire_time = 0;
        while (argc-- > 0) {
                if (strncmp(argv[0], "temp", 4) == 0) {
-                       struct timeval time;
-                       (void)gettimeofday(&time, 0);
-                       expire_time = time.tv_sec + 20 * 60;
+                       struct timeval timev;
+                       (void)gettimeofday(&timev, 0);
+                       expire_time = timev.tv_sec + 20 * 60;
                }
                else if (strncmp(argv[0], "pub", 3) == 0) {
                        flags |= RTF_ANNOUNCE;
@@ -271,9 +265,9 @@
                warn("%s", host);
                return (1);
        }
-       sin = (struct sockaddr_inarp *)(rtm + 1);
-       sdl = (struct sockaddr_dl *)(ROUNDUP(sin->sin_len) + (char *)sin);
-       if (sin->sin_addr.s_addr == sin_m.sin_addr.s_addr) {
+       sina = (struct sockaddr_inarp *)(rtm + 1);
+       sdl = (struct sockaddr_dl *)(ROUNDUP(sina->sin_len) + (char *)sina);
+       if (sina->sin_addr.s_addr == sin_m.sin_addr.s_addr) {
                if (sdl->sdl_family == AF_LINK &&
                    (rtm->rtm_flags & RTF_LLINFO) &&
                    !(rtm->rtm_flags & RTF_GATEWAY)) switch (sdl->sdl_type) {
@@ -312,19 +306,18 @@
  * Display an individual arp entry
  */
 void
-get(host)
-       const char *host;
+get(const char *host)
 {
-       struct sockaddr_inarp *sin;
+       struct sockaddr_inarp *sina;
 
-       sin = &sin_m;
+       sina = &sin_m;
        sin_m = blank_sin;              /* struct copy */
-       if (getinetaddr(host, &sin->sin_addr) == -1)
+       if (getinetaddr(host, &sina->sin_addr) == -1)
                exit(1);
-       dump(sin->sin_addr.s_addr);
+       dump(sina->sin_addr.s_addr);
        if (found_entry == 0) {
                (void)printf("%s (%s) -- no entry\n", host,
-                   inet_ntoa(sin->sin_addr));
+                   inet_ntoa(sina->sin_addr));
                exit(1);
        }
 }
@@ -333,31 +326,29 @@
  * Delete an arp entry 
  */
 int
-delete(host, info)
-       const char *host;
-       const char *info;
+delete(const char *host, const char *info)
 {
-       struct sockaddr_inarp *sin;
+       struct sockaddr_inarp *sina;
        struct rt_msghdr *rtm;
        struct sockaddr_dl *sdl;
 
-       sin = &sin_m;
+       sina = &sin_m;
        rtm = &m_rtmsg.m_rtm;
 
        if (info && strncmp(info, "pro", 3) )
                export_only = 1;
        getsocket();
        sin_m = blank_sin;              /* struct copy */
-       if (getinetaddr(host, &sin->sin_addr) == -1)
+       if (getinetaddr(host, &sina->sin_addr) == -1)
                return (1);
 tryagain:
        if (rtmsg(RTM_GET) < 0) {
                warn("%s", host);
                return (1);
        }
-       sin = (struct sockaddr_inarp *)(rtm + 1);
-       sdl = (struct sockaddr_dl *)(ROUNDUP(sin->sin_len) + (char *)sin);
-       if (sin->sin_addr.s_addr == sin_m.sin_addr.s_addr) {
+       sina = (struct sockaddr_inarp *)(rtm + 1);
+       sdl = (struct sockaddr_dl *)(ROUNDUP(sina->sin_len) + (char *)sina);
+       if (sina->sin_addr.s_addr == sin_m.sin_addr.s_addr) {
                if (sdl->sdl_family == AF_LINK &&
                    (rtm->rtm_flags & RTF_LLINFO) &&
                    !(rtm->rtm_flags & RTF_GATEWAY)) switch (sdl->sdl_type) {
@@ -382,7 +373,7 @@
                return (1);
        if (vflag)
                (void)printf("%s (%s) deleted\n", host,
-                   inet_ntoa(sin->sin_addr));
+                   inet_ntoa(sina->sin_addr));
        return (0);
 }
 
@@ -390,15 +381,15 @@
  * Dump the entire arp table
  */
 void
-dump(addr)
-       u_long addr;
+dump(u_long addr)
 {
        int mib[6];
        size_t needed;
        char ifname[IFNAMSIZ];
-       char *host, *lim, *buf, *next;
+       char *lim, *buf, *next;
+        const char *host;
        struct rt_msghdr *rtm;
-       struct sockaddr_inarp *sin;
+       struct sockaddr_inarp *sina;
        struct sockaddr_dl *sdl;
        struct hostent *hp;
 
@@ -419,23 +410,23 @@
        lim = buf + needed;
        for (next = buf; next < lim; next += rtm->rtm_msglen) {
                rtm = (struct rt_msghdr *)next;
-               sin = (struct sockaddr_inarp *)(rtm + 1);
+               sina = (struct sockaddr_inarp *)(rtm + 1);
                sdl = (struct sockaddr_dl *)
-                   (ROUNDUP(sin->sin_len) + (char *)sin);
+                   (ROUNDUP(sina->sin_len) + (char *)sina);
                if (addr) {
-                       if (addr != sin->sin_addr.s_addr)
+                       if (addr != sina->sin_addr.s_addr)
                                continue;
                        found_entry = 1;
                }
                if (nflag == 0)
-                       hp = gethostbyaddr((caddr_t)&(sin->sin_addr),
-                           sizeof sin->sin_addr, AF_INET);
+                       hp = gethostbyaddr((caddr_t)&(sina->sin_addr),
+                           sizeof sina->sin_addr, AF_INET);
                else
                        hp = NULL;
 
                host = hp ? hp->h_name : "?";
 
-               (void)printf("%s (%s) at ", host, inet_ntoa(sin->sin_addr));
+               (void)printf("%s (%s) at ", host, inet_ntoa(sina->sin_addr));
                if (sdl->sdl_alen)
                        sdl_print(sdl);
                else
@@ -448,14 +439,14 @@
 
                if (rtm->rtm_rmx.rmx_expire == 0)
                        (void)printf(" permanent");
-               if (sin->sin_other & SIN_PROXY)
+               if (sina->sin_other & SIN_PROXY)
                        (void)printf(" published (proxy only)");
                if (rtm->rtm_addrs & RTA_NETMASK) {
-                       sin = (struct sockaddr_inarp *)
+                       sina = (struct sockaddr_inarp *)
                                (ROUNDUP(sdl->sdl_len) + (char *)sdl);
-                       if (sin->sin_addr.s_addr == 0xffffffff)
+                       if (sina->sin_addr.s_addr == 0xffffffff)
                                (void)printf(" published");
-                       if (sin->sin_len != 8)
+                       if (sina->sin_len != 8)
                                (void)printf("(weird)");
                }
                (void)printf("\n");
@@ -474,7 +465,7 @@
        char addr[sizeof("000.000.000.000\0")];
        char *lim, *buf, *next;
        struct rt_msghdr *rtm;
-       struct sockaddr_inarp *sin;
+       struct sockaddr_inarp *sina;
        struct sockaddr_dl *sdl;



Home | Main Index | Thread Index | Old Index