BSD 4_4_Lite2 release
[unix-history] / usr / src / sys / net / if.h
index 10232e1..ec86b68 100644 (file)
@@ -1,10 +1,36 @@
 /*
 /*
- * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)if.h        7.17 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)if.h        8.3 (Berkeley) 2/9/95
  */
 
 /*
  */
 
 /*
  * interfaces.  These routines live in the files if.c and route.c
  */
 #ifndef _TIME_ /*  XXX fast fix for SNMP, going away soon */
  * interfaces.  These routines live in the files if.c and route.c
  */
 #ifndef _TIME_ /*  XXX fast fix for SNMP, going away soon */
-#ifdef KERNEL
-#include "../sys/time.h"
-#else
 #include <sys/time.h>
 #endif
 #include <sys/time.h>
 #endif
-#endif
 
 #ifdef __STDC__
 /*
  * Forward structure declarations for function prototypes [sic].
  */
 
 #ifdef __STDC__
 /*
  * Forward structure declarations for function prototypes [sic].
  */
-struct rtentry;        
 struct mbuf;
 struct mbuf;
+struct proc;
+struct rtentry;        
+struct socket;
+struct ether_header;
 #endif
 /*
  * Structure describing information about an interface
 #endif
 /*
  * Structure describing information about an interface
@@ -61,30 +86,31 @@ struct ifnet {
        struct  ifnet *if_next;         /* all struct ifnets are chained */
        struct  ifaddr *if_addrlist;    /* linked list of addresses per if */
         int    if_pcount;              /* number of promiscuous listeners */
        struct  ifnet *if_next;         /* all struct ifnets are chained */
        struct  ifaddr *if_addrlist;    /* linked list of addresses per if */
         int    if_pcount;              /* number of promiscuous listeners */
+       caddr_t if_bpf;                 /* packet filter structure */
        u_short if_index;               /* numeric abbreviation for this if  */
        short   if_unit;                /* sub-unit for lower level driver */
        short   if_timer;               /* time 'til if_watchdog called */
        short   if_flags;               /* up/down, broadcast, etc. */
        struct  if_data {
 /* generic interface information */
        u_short if_index;               /* numeric abbreviation for this if  */
        short   if_unit;                /* sub-unit for lower level driver */
        short   if_timer;               /* time 'til if_watchdog called */
        short   if_flags;               /* up/down, broadcast, etc. */
        struct  if_data {
 /* generic interface information */
-               short   ifi_mtu;        /* maximum transmission unit */
                u_char  ifi_type;       /* ethernet, tokenring, etc */
                u_char  ifi_addrlen;    /* media address length */
                u_char  ifi_hdrlen;     /* media header length */
                u_char  ifi_type;       /* ethernet, tokenring, etc */
                u_char  ifi_addrlen;    /* media address length */
                u_char  ifi_hdrlen;     /* media header length */
-               int     ifi_metric;     /* routing metric (external only) */
-               int     ifi_baudrate;   /* linespeed */
+               u_long  ifi_mtu;        /* maximum transmission unit */
+               u_long  ifi_metric;     /* routing metric (external only) */
+               u_long  ifi_baudrate;   /* linespeed */
 /* volatile statistics */
 /* volatile statistics */
-               int     ifi_ipackets;   /* packets received on interface */
-               int     ifi_ierrors;    /* input errors on interface */
-               int     ifi_opackets;   /* packets sent on interface */
-               int     ifi_oerrors;    /* output errors on interface */
-               int     ifi_collisions; /* collisions on csma interfaces */
-               int     ifi_ibytes;     /* total number of octets received */
-               int     ifi_obytes;     /* total number of octets sent */
-               int     ifi_imcasts;    /* packets received via multicast */
-               int     ifi_omcasts;    /* packets sent via multicast */
-               int     ifi_iqdrops;    /* dropped on input, this interface */
-               int     ifi_noproto;    /* destined for unsupported protocol */
+               u_long  ifi_ipackets;   /* packets received on interface */
+               u_long  ifi_ierrors;    /* input errors on interface */
+               u_long  ifi_opackets;   /* packets sent on interface */
+               u_long  ifi_oerrors;    /* output errors on interface */
+               u_long  ifi_collisions; /* collisions on csma interfaces */
+               u_long  ifi_ibytes;     /* total number of octets received */
+               u_long  ifi_obytes;     /* total number of octets sent */
+               u_long  ifi_imcasts;    /* packets received via multicast */
+               u_long  ifi_omcasts;    /* packets sent via multicast */
+               u_long  ifi_iqdrops;    /* dropped on input, this interface */
+               u_long  ifi_noproto;    /* destined for unsupported protocol */
                struct  timeval ifi_lastchange;/* last updated */
        }       if_data;
 /* procedure handles */
                struct  timeval ifi_lastchange;/* last updated */
        }       if_data;
 /* procedure handles */
@@ -98,9 +124,9 @@ struct ifnet {
        int     (*if_done)              /* output complete routine */
                __P((struct ifnet *));  /* (XXX not used; fake prototype) */
        int     (*if_ioctl)             /* ioctl routine */
        int     (*if_done)              /* output complete routine */
                __P((struct ifnet *));  /* (XXX not used; fake prototype) */
        int     (*if_ioctl)             /* ioctl routine */
-               __P((struct ifnet *, int, caddr_t));
-       int     (*if_reset)             /* XXX; Unibus reset routine for vax */
-               __P((int, int));        /* new autoconfig will permit removal */
+               __P((struct ifnet *, u_long, caddr_t));
+       int     (*if_reset)     
+               __P((int));             /* new autoconfig will permit removal */
        int     (*if_watchdog)          /* timer routine */
                __P((int));
        struct  ifqueue {
        int     (*if_watchdog)          /* timer routine */
                __P((int));
        struct  ifqueue {
@@ -138,7 +164,6 @@ struct ifnet {
 #define        IFF_NOTRAILERS  0x20            /* avoid use of trailers */
 #define        IFF_RUNNING     0x40            /* resources allocated */
 #define        IFF_NOARP       0x80            /* no address resolution protocol */
 #define        IFF_NOTRAILERS  0x20            /* avoid use of trailers */
 #define        IFF_RUNNING     0x40            /* resources allocated */
 #define        IFF_NOARP       0x80            /* no address resolution protocol */
-/* next two not supported now, but reserved: */
 #define        IFF_PROMISC     0x100           /* receive all packets */
 #define        IFF_ALLMULTI    0x200           /* receive all multicast packets */
 #define        IFF_OACTIVE     0x400           /* transmission in progress */
 #define        IFF_PROMISC     0x100           /* receive all packets */
 #define        IFF_ALLMULTI    0x200           /* receive all multicast packets */
 #define        IFF_OACTIVE     0x400           /* transmission in progress */
@@ -146,10 +171,12 @@ struct ifnet {
 #define        IFF_LINK0       0x1000          /* per link layer defined bit */
 #define        IFF_LINK1       0x2000          /* per link layer defined bit */
 #define        IFF_LINK2       0x4000          /* per link layer defined bit */
 #define        IFF_LINK0       0x1000          /* per link layer defined bit */
 #define        IFF_LINK1       0x2000          /* per link layer defined bit */
 #define        IFF_LINK2       0x4000          /* per link layer defined bit */
+#define        IFF_MULTICAST   0x8000          /* supports multicast */
 
 /* flags set internally only: */
 #define        IFF_CANTCHANGE \
 
 /* flags set internally only: */
 #define        IFF_CANTCHANGE \
-       (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|IFF_SIMPLEX)
+       (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
+           IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
 
 /*
  * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
 
 /*
  * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
@@ -201,13 +228,15 @@ struct ifaddr {
        struct  sockaddr *ifa_netmask;  /* used to determine subnet */
        struct  ifnet *ifa_ifp;         /* back-pointer to interface */
        struct  ifaddr *ifa_next;       /* next address for interface */
        struct  sockaddr *ifa_netmask;  /* used to determine subnet */
        struct  ifnet *ifa_ifp;         /* back-pointer to interface */
        struct  ifaddr *ifa_next;       /* next address for interface */
-       int     (*ifa_rtrequest)();     /* check or clean routes (+ or -)'d */
+       void    (*ifa_rtrequest)();     /* check or clean routes (+ or -)'d */
        u_short ifa_flags;              /* mostly rt_flags for cloning */
        short   ifa_refcnt;             /* extra to malloc for link info */
        int     ifa_metric;             /* cost of going out this interface */
        u_short ifa_flags;              /* mostly rt_flags for cloning */
        short   ifa_refcnt;             /* extra to malloc for link info */
        int     ifa_metric;             /* cost of going out this interface */
-/*     struct  rtentry *ifa_rt;        /* XXXX for ROUTETOIF ????? */
+#ifdef notdef
+       struct  rtentry *ifa_rt;        /* XXXX for ROUTETOIF ????? */
+#endif
 };
 };
-#define IFA_ROUTE      RTF_UP          /* route installed */
+#define        IFA_ROUTE       RTF_UP          /* route installed */
 
 /*
  * Message format for use in obtaining information about interfaces
 
 /*
  * Message format for use in obtaining information about interfaces
@@ -285,6 +314,8 @@ struct      ifconf {
 #define        ifc_req ifc_ifcu.ifcu_req       /* array of structures returned */
 };
 
 #define        ifc_req ifc_ifcu.ifcu_req       /* array of structures returned */
 };
 
+#include <net/if_arp.h>
+
 #ifdef KERNEL
 #define        IFAFREE(ifa) \
        if ((ifa)->ifa_refcnt <= 0) \
 #ifdef KERNEL
 #define        IFAFREE(ifa) \
        if ((ifa)->ifa_refcnt <= 0) \
@@ -292,14 +323,41 @@ struct    ifconf {
        else \
                (ifa)->ifa_refcnt--;
 
        else \
                (ifa)->ifa_refcnt--;
 
-#include "../net/if_arp.h"
-struct ifqueue rawintrq;               /* raw packet input queue */
 struct ifnet   *ifnet;
 struct ifnet   *ifnet;
-struct ifaddr  *ifa_ifwithaddr __P((struct sockaddr *)),
-               *ifa_ifwithnet __P((struct sockaddr *)),
-               *ifa_ifwithdstaddr __P((struct sockaddr *));
-void   ifafree __P((struct ifaddr *));
+
+void   ether_ifattach __P((struct ifnet *));
+void   ether_input __P((struct ifnet *, struct ether_header *, struct mbuf *));
+int    ether_output __P((struct ifnet *,
+          struct mbuf *, struct sockaddr *, struct rtentry *));
+char   *ether_sprintf __P((u_char *));
+
 void   if_attach __P((struct ifnet *));
 void   if_attach __P((struct ifnet *));
-#else KERNEL
-#include <net/if_arp.h>
-#endif KERNEL
+void   if_down __P((struct ifnet *));
+void   if_qflush __P((struct ifqueue *));
+void   if_slowtimo __P((void *));
+void   if_up __P((struct ifnet *));
+#ifdef vax
+void   ifubareset __P((int));
+#endif
+int    ifconf __P((int, caddr_t));
+void   ifinit __P((void));
+int    ifioctl __P((struct socket *, u_long, caddr_t, struct proc *));
+int    ifpromisc __P((struct ifnet *, int));
+struct ifnet *ifunit __P((char *));
+
+struct ifaddr *ifa_ifwithaddr __P((struct sockaddr *));
+struct ifaddr *ifa_ifwithaf __P((int));
+struct ifaddr *ifa_ifwithdstaddr __P((struct sockaddr *));
+struct ifaddr *ifa_ifwithnet __P((struct sockaddr *));
+struct ifaddr *ifa_ifwithroute __P((int, struct sockaddr *,
+                                       struct sockaddr *));
+struct ifaddr *ifaof_ifpforaddr __P((struct sockaddr *, struct ifnet *));
+void   ifafree __P((struct ifaddr *));
+void   link_rtrequest __P((int, struct rtentry *, struct sockaddr *));
+
+int    loioctl __P((struct ifnet *, u_long, caddr_t));
+void   loopattach __P((int));
+int    looutput __P((struct ifnet *,
+          struct mbuf *, struct sockaddr *, struct rtentry *));
+void   lortrequest __P((int, struct rtentry *, struct sockaddr *));
+#endif