added watchdog routines
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Thu, 24 Jun 1982 12:10:04 +0000 (04:10 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Thu, 24 Jun 1982 12:10:04 +0000 (04:10 -0800)
SCCS-vsn: sys/net/if.c 4.18
SCCS-vsn: sys/net/if.h 4.15

usr/src/sys/net/if.c
usr/src/sys/net/if.h

index 0fcf3c8..770b043 100644 (file)
@@ -1,4 +1,4 @@
-/*     if.c    4.17    82/06/20        */
+/*     if.c    4.18    82/06/23        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -146,3 +146,23 @@ if_down(ifp)
        ifp->if_flags &= ~IFF_UP;
        pfctlinput(PRC_IFDOWN, (caddr_t)&ifp->if_addr);
 }
        ifp->if_flags &= ~IFF_UP;
        pfctlinput(PRC_IFDOWN, (caddr_t)&ifp->if_addr);
 }
+
+/*
+ * Handle interface watchdog timer routines.  Called
+ * from softclock, we decrement timers (if set) and
+ * call the appropriate interface routine on expiration.
+ */
+if_slowtimo()
+{
+       register struct ifnet *ifp;
+
+       for (ifp = ifnet; ifp; ifp = ifp->if_next)
+               if (ifp->if_timer && --ifp->if_timer == 0) {
+                       if (ifp->if_watchdog == 0) {
+                               printf("%s%d: no watchdog routine\n", 
+                                       ifp->if_name, ifp->if_unit);
+                               continue;
+                       }
+                       (*ifp->if_watchdog)(ifp->if_unit);
+               }
+}
index f3f43b1..1aa0bfa 100644 (file)
@@ -1,4 +1,4 @@
-/*     if.h    4.14    82/06/13        */
+/*     if.h    4.15    82/06/23        */
 
 /*
  * Structures defining a network interface, providing a packet
 
 /*
  * Structures defining a network interface, providing a packet
@@ -38,6 +38,7 @@ struct ifnet {
        short   if_mtu;                 /* maximum transmission unit */
        int     if_net;                 /* network number of interface */
        short   if_flags;               /* up/down, broadcast, etc. */
        short   if_mtu;                 /* maximum transmission unit */
        int     if_net;                 /* network number of interface */
        short   if_flags;               /* up/down, broadcast, etc. */
+       short   if_timer;               /* time 'til if_watchdog called */
        int     if_host[2];             /* local net host number */
        struct  sockaddr if_addr;       /* address of interface */
        union {
        int     if_host[2];             /* local net host number */
        struct  sockaddr if_addr;       /* address of interface */
        union {
@@ -57,6 +58,7 @@ struct ifnet {
        int     (*if_init)();           /* init routine */
        int     (*if_output)();         /* output routine */
        int     (*if_ubareset)();       /* uba reset routine */
        int     (*if_init)();           /* init routine */
        int     (*if_output)();         /* output routine */
        int     (*if_ubareset)();       /* uba reset routine */
+       int     (*if_watchdog)();       /* timer routine */
 /* generic interface statistics */
        int     if_ipackets;            /* packets received on interface */
        int     if_ierrors;             /* input errors on interface */
 /* generic interface statistics */
        int     if_ipackets;            /* packets received on interface */
        int     if_ierrors;             /* input errors on interface */
@@ -108,6 +110,7 @@ struct ifnet {
 }
 
 #define        IFQ_MAXLEN      50
 }
 
 #define        IFQ_MAXLEN      50
+#define        IFNET_SLOWHZ    1               /* granularity is 1 second */
 
 #ifdef KERNEL
 #ifdef INET
 
 #ifdef KERNEL
 #ifdef INET