Source-Changes-HG archive

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

[src/trunk]: src KNF, from openbsd via kame



details:   https://anonhg.NetBSD.org/src/rev/ac7236081ca0
branches:  trunk
changeset: 532078:ac7236081ca0
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri May 31 10:22:11 2002 +0000

description:
KNF, from openbsd via kame

diffstat:

 sbin/rtsol/Makefile      |    7 +-
 usr.sbin/rtsold/Makefile |    7 +-
 usr.sbin/rtsold/dump.c   |   26 +--
 usr.sbin/rtsold/if.c     |  114 ++++++++-----------
 usr.sbin/rtsold/probe.c  |   76 +++++-------
 usr.sbin/rtsold/rtsock.c |    4 +-
 usr.sbin/rtsold/rtsol.c  |  174 ++++++++++++++---------------
 usr.sbin/rtsold/rtsold.c |  267 ++++++++++++++++++++++++----------------------
 usr.sbin/rtsold/rtsold.h |   32 +++--
 9 files changed, 349 insertions(+), 358 deletions(-)

diffs (truncated from 1475 to 300 lines):

diff -r b3a8d7f0573d -r ac7236081ca0 sbin/rtsol/Makefile
--- a/sbin/rtsol/Makefile       Fri May 31 09:56:12 2002 +0000
+++ b/sbin/rtsol/Makefile       Fri May 31 10:22:11 2002 +0000
@@ -1,13 +1,16 @@
-# $NetBSD: Makefile,v 1.7 2001/12/12 01:48:43 tv Exp $
+# $NetBSD: Makefile,v 1.8 2002/05/31 10:22:11 itojun Exp $
 
 PROG=  rtsol
 SRCS=  rtsold.c rtsol.c if.c probe.c dump.c rtsock.c
 
-CPPFLAGS+=-DINET6 -DHAVE_GETIFADDRS
+CPPFLAGS+=-DINET6 -DHAVE_GETIFADDRS -DHAVE_ARC4RANDOM
 
 #MAN=  rtsold.8
 NOMAN= # defined
 
 .PATH: ${.CURDIR}/../../usr.sbin/rtsold
 
+LDADD+=        -lutil
+DPADD+=        ${LIBUTIL}
+
 .include <bsd.prog.mk>
diff -r b3a8d7f0573d -r ac7236081ca0 usr.sbin/rtsold/Makefile
--- a/usr.sbin/rtsold/Makefile  Fri May 31 09:56:12 2002 +0000
+++ b/usr.sbin/rtsold/Makefile  Fri May 31 10:22:11 2002 +0000
@@ -1,11 +1,14 @@
-# $NetBSD: Makefile,v 1.6 2001/07/09 06:04:28 itojun Exp $
+# $NetBSD: Makefile,v 1.7 2002/05/31 10:22:13 itojun Exp $
 
 PROG=  rtsold
 SRCS=  rtsold.c rtsol.c if.c probe.c dump.c rtsock.c
 
-CPPFLAGS+=-DINET6 -DHAVE_GETIFADDRS
+CPPFLAGS+=-DINET6 -DHAVE_GETIFADDRS -DHAVE_ARC4RANDOM
 
 MAN=   rtsold.8
 MLINKS=        rtsold.8 rtsol.8
 
+LDADD+=        -lutil
+DPADD+=        ${LIBUTIL}
+
 .include <bsd.prog.mk>
diff -r b3a8d7f0573d -r ac7236081ca0 usr.sbin/rtsold/dump.c
--- a/usr.sbin/rtsold/dump.c    Fri May 31 09:56:12 2002 +0000
+++ b/usr.sbin/rtsold/dump.c    Fri May 31 10:22:11 2002 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: dump.c,v 1.5 2001/08/22 05:24:37 itojun Exp $  */
-/*     $KAME: dump.c,v 1.9 2001/08/20 06:55:54 itojun Exp $    */
+/*     $NetBSD: dump.c,v 1.6 2002/05/31 10:22:13 itojun Exp $  */
+/*     $KAME: dump.c,v 1.10 2002/05/31 10:10:03 itojun Exp $   */
 
 /*
  * Copyright (C) 1999 WIDE Project.
@@ -68,27 +68,26 @@
                if (ifinfo->probeinterval) {
                        fprintf(fp, "%d\n", ifinfo->probeinterval);
                        fprintf(fp, "  probe timer: %d\n", ifinfo->probetimer);
-               }
-               else {
+               } else {
                        fprintf(fp, "infinity\n");
                        fprintf(fp, "  no probe timer\n");
                }
                fprintf(fp, "  interface status: %s\n",
-                       ifinfo->active > 0 ? "active" : "inactive");
+                   ifinfo->active > 0 ? "active" : "inactive");
                fprintf(fp, "  rtsold status: %s\n", ifstatstr[ifinfo->state]);
                fprintf(fp, "  carrier detection: %s\n",
-                       ifinfo->mediareqok ? "available" : "unavailable");
+                   ifinfo->mediareqok ? "available" : "unavailable");
                fprintf(fp, "  probes: %d, dadcount = %d\n",
-                       ifinfo->probes, ifinfo->dadcount);
+                   ifinfo->probes, ifinfo->dadcount);
                if (ifinfo->timer.tv_sec == tm_max.tv_sec &&
                    ifinfo->timer.tv_usec == tm_max.tv_usec)
                        fprintf(fp, "  no timer\n");
                else {
                        fprintf(fp, "  timer: interval=%d:%d, expire=%s\n",
-                               (int)ifinfo->timer.tv_sec,
-                               (int)ifinfo->timer.tv_usec,
-                               (ifinfo->expire.tv_sec < now.tv_sec) ? "expired"
-                               : sec2str(ifinfo->expire.tv_sec - now.tv_sec));
+                           (int)ifinfo->timer.tv_sec,
+                           (int)ifinfo->timer.tv_usec,
+                           (ifinfo->expire.tv_sec < now.tv_sec) ? "expired"
+                           : sec2str(ifinfo->expire.tv_sec - now.tv_sec));
                }
                fprintf(fp, "  number of valid RAs: %d\n", ifinfo->racnt);
        }
@@ -100,12 +99,10 @@
 {
        if ((fp = fopen(dumpfile, "w")) == NULL) {
                warnmsg(LOG_WARNING, __FUNCTION__, "open a dump file(%s): %s",
-                       dumpfile, strerror(errno));
+                   dumpfile, strerror(errno));
                return;
        }
-
        dump_interface_status();
-
        fclose(fp);
 }
 
@@ -147,6 +144,5 @@
                p += n;
        }
        snprintf(p, ep - p, "%ds", secs);
-
        return(result);
 }
diff -r b3a8d7f0573d -r ac7236081ca0 usr.sbin/rtsold/if.c
--- a/usr.sbin/rtsold/if.c      Fri May 31 09:56:12 2002 +0000
+++ b/usr.sbin/rtsold/if.c      Fri May 31 10:22:11 2002 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: if.c,v 1.8 2001/11/14 01:55:38 itojun Exp $    */
-/*     $KAME: if.c,v 1.15 2001/05/22 06:04:17 jinmei Exp $     */
+/*     $NetBSD: if.c,v 1.9 2002/05/31 10:22:14 itojun Exp $    */
+/*     $KAME: if.c,v 1.18 2002/05/31 10:10:03 itojun Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -37,23 +37,11 @@
 #include <sys/queue.h>
 
 #include <net/if.h>
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
-#include <net/if_var.h>
-#endif /* __FreeBSD__ >= 3 */
 #include <net/if_types.h>
 #include <net/route.h>
 #include <net/if_dl.h>
 #include <net/if_media.h>
-#ifdef __FreeBSD__
-# include <net/ethernet.h>
-#endif
-#ifdef __NetBSD__
 #include <net/if_ether.h>
-#endif
-#if defined(__bsdi__) || defined(__OpenBSD__)
-# include <netinet/in.h>
-# include <netinet/if_ether.h>
-#endif
 #include <netinet/in.h>
 #include <netinet/icmp6.h>
 
@@ -76,12 +64,11 @@
 extern int rssock;
 static int ifsock;
 
-static int get_llflag __P((const char *name));
+static int get_llflag __P((const char *));
 #ifndef HAVE_GETIFADDRS
 static unsigned int if_maxindex __P((void));
 #endif
-static void get_rtaddrs __P((int addrs, struct sockaddr *sa,
-                            struct sockaddr **rti_info));
+static void get_rtaddrs __P((int, struct sockaddr *, struct sockaddr **));
 
 int
 ifinit()
@@ -101,15 +88,14 @@
 
        if (ioctl(ifsock, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) {
                warnmsg(LOG_WARNING, __FUNCTION__, "ioctl(SIOCGIFFLAGS): %s",
-                      strerror(errno));
+                   strerror(errno));
                return(-1);
        }
        if (!(ifr.ifr_flags & IFF_UP)) {
                ifr.ifr_flags |= IFF_UP;
-               if (ioctl(ifsock, SIOCSIFFLAGS, (caddr_t)&ifr) < 0) {
+               if (ioctl(ifsock, SIOCSIFFLAGS, (caddr_t)&ifr) < 0)
                        warnmsg(LOG_ERR, __FUNCTION__,
-                               "ioctl(SIOCSIFFLAGS): %s", strerror(errno));
-               }
+                           "ioctl(SIOCSIFFLAGS): %s", strerror(errno));
                return(-1);
        }
 
@@ -118,23 +104,22 @@
        llflag = get_llflag(name);
        if (llflag < 0) {
                warnmsg(LOG_WARNING, __FUNCTION__,
-                       "get_llflag() failed, anyway I'll try");
+                   "get_llflag() failed, anyway I'll try");
                return 0;
        }
 
        if (!(llflag & IN6_IFF_NOTREADY)) {
-               warnmsg(LOG_DEBUG, __FUNCTION__,
-                       "%s is ready", name);
+               warnmsg(LOG_DEBUG, __FUNCTION__, "%s is ready", name);
                return(0);
        } else {
                if (llflag & IN6_IFF_TENTATIVE) {
                        warnmsg(LOG_DEBUG, __FUNCTION__, "%s is tentative",
-                              name);
+                           name);
                        return IFS_TENTATIVE;
                }
                if (llflag & IN6_IFF_DUPLICATED)
                        warnmsg(LOG_DEBUG, __FUNCTION__, "%s is duplicated",
-                              name);
+                           name);
                return -1;
        }
 }
@@ -145,13 +130,13 @@
        char *ifname = ifinfo->ifname;
        struct ifreq ifr;
        struct ifmediareq ifmr;
-       
+
        /* get interface flags */
        memset(&ifr, 0, sizeof(ifr));
        strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
        if (ioctl(ifsock, SIOCGIFFLAGS, &ifr) < 0) {
                warnmsg(LOG_ERR, __FUNCTION__, "ioctl(SIOCGIFFLAGS) on %s: %s",
-                      ifname, strerror(errno));
+                   ifname, strerror(errno));
                return(-1);
        }
        /*
@@ -171,8 +156,8 @@
        if (ioctl(ifsock, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
                if (errno != EINVAL) {
                        warnmsg(LOG_DEBUG, __FUNCTION__,
-                               "ioctl(SIOCGIFMEDIA) on %s: %s",
-                              ifname, strerror(errno));
+                           "ioctl(SIOCGIFMEDIA) on %s: %s",
+                           ifname, strerror(errno));
                        return(-1);
                }
                /*
@@ -184,15 +169,15 @@
        }
 
        if (ifmr.ifm_status & IFM_AVALID) {
-               switch(ifmr.ifm_active & IFM_NMASK) {
-                case IFM_ETHER:
-                        if (ifmr.ifm_status & IFM_ACTIVE)
-                                goto active;
-                        else
-                                goto inactive;
-                        break;
-                default:
-                        goto inactive;
+               switch (ifmr.ifm_active & IFM_NMASK) {
+               case IFM_ETHER:
+                       if (ifmr.ifm_status & IFM_ACTIVE)
+                               goto active;
+                       else
+                               goto inactive;
+                       break;
+               default:
+                       goto inactive;
                }
        }
 
@@ -208,21 +193,20 @@
 
 #define NEXT_SA(ap) (ap) = (struct sockaddr *) \
        ((caddr_t)(ap) + ((ap)->sa_len ? ROUNDUP((ap)->sa_len,\
-                                                sizeof(u_long)) :\
-                                                sizeof(u_long)))
+       sizeof(u_long)) : sizeof(u_long)))
 #define ROUNDUP8(a) (1 + (((a) - 1) | 7))
 
 int
 lladdropt_length(struct sockaddr_dl *sdl)
 {
-       switch(sdl->sdl_type) {
-        case IFT_ETHER:
+       switch (sdl->sdl_type) {
+       case IFT_ETHER:
 #ifdef IFT_IEEE80211
        case IFT_IEEE80211:
 #endif
-                return(ROUNDUP8(ETHER_ADDR_LEN + 2));
-        default:
-                return(0);
+               return(ROUNDUP8(ETHER_ADDR_LEN + 2));
+       default:
+               return(0);
        }
 }
 
@@ -233,19 +217,19 @@
 
        ndopt->nd_opt_type = ND_OPT_SOURCE_LINKADDR; /* fixed */
 
-       switch(sdl->sdl_type) {
-        case IFT_ETHER:
+       switch (sdl->sdl_type) {
+       case IFT_ETHER:
 #ifdef IFT_IEEE80211
        case IFT_IEEE80211:
 #endif
-                ndopt->nd_opt_len = (ROUNDUP8(ETHER_ADDR_LEN + 2)) >> 3;
-                addr = (char *)(ndopt + 1);



Home | Main Index | Thread Index | Old Index