add LOOPBACK flag, interface metric
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Fri, 7 Feb 1986 06:18:27 +0000 (22:18 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Fri, 7 Feb 1986 06:18:27 +0000 (22:18 -0800)
SCCS-vsn: sys/net/if_loop.c 6.9
SCCS-vsn: sys/net/if.c 6.12
SCCS-vsn: sys/net/if.h 6.11

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

index a410678..579d0fb 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)if.c        6.11 (Berkeley) %G%
+ *     @(#)if.c        6.12 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -256,6 +256,10 @@ ifioctl(so, cmd, data)
                ifr->ifr_flags = ifp->if_flags;
                break;
 
                ifr->ifr_flags = ifp->if_flags;
                break;
 
+       case SIOCGIFMETRIC:
+               ifr->ifr_metric = ifp->if_metric;
+               break;
+
        case SIOCSIFFLAGS:
                if (!suser())
                        return (u.u_error);
        case SIOCSIFFLAGS:
                if (!suser())
                        return (u.u_error);
@@ -270,6 +274,12 @@ ifioctl(so, cmd, data)
                        (void) (*ifp->if_ioctl)(ifp, cmd, data);
                break;
 
                        (void) (*ifp->if_ioctl)(ifp, cmd, data);
                break;
 
+       case SIOCSIFMETRIC:
+               if (!suser())
+                       return (u.u_error);
+               ifp->if_metric = ifr->ifr_metric;
+               break;
+
        default:
                if (so->so_proto == 0)
                        return (EOPNOTSUPP);
        default:
                if (so->so_proto == 0)
                        return (EOPNOTSUPP);
index f2d4e94..bec5e5e 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)if.h        6.10 (Berkeley) %G%
+ *     @(#)if.h        6.11 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -42,6 +42,7 @@ struct ifnet {
        short   if_mtu;                 /* maximum transmission unit */
        short   if_flags;               /* up/down, broadcast, etc. */
        short   if_timer;               /* time 'til if_watchdog called */
        short   if_mtu;                 /* maximum transmission unit */
        short   if_flags;               /* up/down, broadcast, etc. */
        short   if_timer;               /* time 'til if_watchdog called */
+       int     if_metric;              /* routing metric (external only) */
        struct  ifaddr *if_addrlist;    /* linked list of addresses per if */
        struct  ifqueue {
                struct  mbuf *ifq_head;
        struct  ifaddr *if_addrlist;    /* linked list of addresses per if */
        struct  ifqueue {
                struct  mbuf *ifq_head;
@@ -69,12 +70,12 @@ struct ifnet {
 #define        IFF_UP          0x1             /* interface is up */
 #define        IFF_BROADCAST   0x2             /* broadcast address valid */
 #define        IFF_DEBUG       0x4             /* turn on debugging */
 #define        IFF_UP          0x1             /* interface is up */
 #define        IFF_BROADCAST   0x2             /* broadcast address valid */
 #define        IFF_DEBUG       0x4             /* turn on debugging */
-/* was IFF_ROUTE       0x8             /* routing entry installed */
+#define        IFF_LOOPBACK    0x8             /* is a loopback net */
 #define        IFF_POINTOPOINT 0x10            /* interface is point-to-point link */
 #define        IFF_NOTRAILERS  0x20            /* avoid use of trailers */
 #define        IFF_RUNNING     0x40            /* resources allocated */
 #define        IFF_NOARP       0x80            /* no address resolution protocol */
 #define        IFF_POINTOPOINT 0x10            /* interface is point-to-point link */
 #define        IFF_NOTRAILERS  0x20            /* avoid use of trailers */
 #define        IFF_RUNNING     0x40            /* resources allocated */
 #define        IFF_NOARP       0x80            /* no address resolution protocol */
-                                       /* flags set internally only: */
+/* flags set internally only: */
 #define        IFF_CANTCHANGE  (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING)
 
 /*
 #define        IFF_CANTCHANGE  (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING)
 
 /*
@@ -172,12 +173,14 @@ struct    ifreq {
                struct  sockaddr ifru_dstaddr;
                struct  sockaddr ifru_broadaddr;
                short   ifru_flags;
                struct  sockaddr ifru_dstaddr;
                struct  sockaddr ifru_broadaddr;
                short   ifru_flags;
+               int     ifru_metric;
                caddr_t ifru_data;
        } ifr_ifru;
 #define        ifr_addr        ifr_ifru.ifru_addr      /* address */
 #define        ifr_dstaddr     ifr_ifru.ifru_dstaddr   /* other end of p-to-p link */
 #define        ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address */
 #define        ifr_flags       ifr_ifru.ifru_flags     /* flags */
                caddr_t ifru_data;
        } ifr_ifru;
 #define        ifr_addr        ifr_ifru.ifru_addr      /* address */
 #define        ifr_dstaddr     ifr_ifru.ifru_dstaddr   /* other end of p-to-p link */
 #define        ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address */
 #define        ifr_flags       ifr_ifru.ifru_flags     /* flags */
+#define        ifr_metric      ifr_ifru.ifru_metric    /* metric */
 #define        ifr_data        ifr_ifru.ifru_data      /* for use by interface */
 };
 
 #define        ifr_data        ifr_ifru.ifru_data      /* for use by interface */
 };
 
index 544dc87..4434d8a 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)if_loop.c   6.8 (Berkeley) %G%
+ *     @(#)if_loop.c   6.9 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -48,6 +48,7 @@ loattach()
 
        ifp->if_name = "lo";
        ifp->if_mtu = LOMTU;
 
        ifp->if_name = "lo";
        ifp->if_mtu = LOMTU;
+       ifp->if_flags = IFF_LOOPBACK;
        ifp->if_ioctl = loioctl;
        ifp->if_output = looutput;
        if_attach(ifp);
        ifp->if_ioctl = loioctl;
        ifp->if_output = looutput;
        if_attach(ifp);