MULTICAST is now standard
[unix-history] / usr / src / sys / net / if_sl.c
index 3f058dd..dae3c25 100644 (file)
@@ -1,10 +1,10 @@
 /*
 /*
- * Copyright (c) 1987, 1989 Regents of the University of California.
+ * Copyright (c) 1987, 1989, 1992 Regents of the University of California.
  * All rights reserved.
  *
  * %sccs.include.redist.c%
  *
  * All rights reserved.
  *
  * %sccs.include.redist.c%
  *
- *     @(#)if_sl.c     7.24 (Berkeley) %G%
+ *     @(#)if_sl.c     7.31 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
 #include "sl.h"
 #if NSL > 0
 
 #include "sl.h"
 #if NSL > 0
 
-#include "param.h"
-#include "proc.h"
-#include "mbuf.h"
-#include "buf.h"
-#include "dk.h"
-#include "socket.h"
-#include "ioctl.h"
-#include "file.h"
-#include "tty.h"
-#include "kernel.h"
-#include "conf.h"
-
-#include "if.h"
-#include "if_types.h"
-#include "netisr.h"
-#include "route.h"
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/mbuf.h>
+#include <sys/buf.h>
+#include <sys/dkstat.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/file.h>
+#include <sys/tty.h>
+#include <sys/kernel.h>
+#include <sys/conf.h>
+
+#include <machine/cpu.h>
+
+#include <net/if.h>
+#include <net/if_types.h>
+#include <net/netisr.h>
+#include <net/route.h>
+
 #if INET
 #if INET
-#include "netinet/in.h"
-#include "netinet/in_systm.h"
-#include "netinet/in_var.h"
-#include "netinet/ip.h"
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
 #else
 Huh? Slip without inet?
 #endif
 
 #else
 Huh? Slip without inet?
 #endif
 
-#include "machine/mtpr.h"
-
-#include "slcompress.h"
-#include "if_slvar.h"
+#include <net/slcompress.h>
+#include <net/if_slvar.h>
 
 /*
  * SLMAX is a hard limit on input packet size.  To simplify the code
 
 /*
  * SLMAX is a hard limit on input packet size.  To simplify the code
@@ -123,28 +124,13 @@ Huh? Slip without inet?
  *     (inspired by HAYES modem escape arrangement)
  *     1sec escape 1sec escape 1sec escape { 1sec escape 1sec escape }
  *     within window time signals a "soft" exit from slip mode by remote end
  *     (inspired by HAYES modem escape arrangement)
  *     1sec escape 1sec escape 1sec escape { 1sec escape 1sec escape }
  *     within window time signals a "soft" exit from slip mode by remote end
+ *     if the IFF_DEBUG flag is on.
  */
  */
-
 #define        ABT_ESC         '\033'  /* can't be t_intr - distant host must know it*/
 #define ABT_IDLE       1       /* in seconds - idle before an escape */
 #define ABT_COUNT      3       /* count of escapes for abort */
 #define ABT_WINDOW     (ABT_COUNT*2+2) /* in seconds - time to count */
 
 #define        ABT_ESC         '\033'  /* can't be t_intr - distant host must know it*/
 #define ABT_IDLE       1       /* in seconds - idle before an escape */
 #define ABT_COUNT      3       /* count of escapes for abort */
 #define ABT_WINDOW     (ABT_COUNT*2+2) /* in seconds - time to count */
 
-
-#ifdef nomore
-/*
- * The following disgusting hack gets around the problem that IP TOS
- * can't be set yet.  We want to put "interactive" traffic on a high
- * priority queue.  To decide if traffic is interactive, we check that
- * a) it is TCP and b) one of its ports is telnet, rlogin or ftp control.
- */
-static u_short interactive_ports[8] = {
-       0,      513,    0,      0,
-       0,      21,     0,      23,
-};
-#define INTERACTIVE(p) (interactive_ports[(p) & 7] == (p))
-#endif
-
 struct sl_softc sl_softc[NSL];
 
 #define FRAME_END              0xc0            /* Frame End */
 struct sl_softc sl_softc[NSL];
 
 #define FRAME_END              0xc0            /* Frame End */
@@ -167,9 +153,11 @@ slattach()
 
        for (sc = sl_softc; i < NSL; sc++) {
                sc->sc_if.if_name = "sl";
 
        for (sc = sl_softc; i < NSL; sc++) {
                sc->sc_if.if_name = "sl";
+               sc->sc_if.if_next = NULL;
                sc->sc_if.if_unit = i++;
                sc->sc_if.if_mtu = SLMTU;
                sc->sc_if.if_unit = i++;
                sc->sc_if.if_mtu = SLMTU;
-               sc->sc_if.if_flags = IFF_POINTOPOINT;
+               sc->sc_if.if_flags =
+                   IFF_POINTOPOINT | SC_AUTOCOMP | IFF_MULTICAST;
                sc->sc_if.if_type = IFT_SLIP;
                sc->sc_if.if_ioctl = slioctl;
                sc->sc_if.if_output = sloutput;
                sc->sc_if.if_type = IFT_SLIP;
                sc->sc_if.if_ioctl = slioctl;
                sc->sc_if.if_output = sloutput;
@@ -268,7 +256,9 @@ slclose(tp)
 /* ARGSUSED */
 sltioctl(tp, cmd, data, flag)
        struct tty *tp;
 /* ARGSUSED */
 sltioctl(tp, cmd, data, flag)
        struct tty *tp;
+       int cmd;
        caddr_t data;
        caddr_t data;
+       int flag;
 {
        struct sl_softc *sc = (struct sl_softc *)tp->t_sc;
        int s;
 {
        struct sl_softc *sc = (struct sl_softc *)tp->t_sc;
        int s;
@@ -278,25 +268,6 @@ sltioctl(tp, cmd, data, flag)
                *(int *)data = sc->sc_if.if_unit;
                break;
 
                *(int *)data = sc->sc_if.if_unit;
                break;
 
-#ifdef notdef
-       case SLIOCGFLAGS:
-               *(int *)data = sc->sc_if.if_flags;
-               break;
-#endif
-
-       case SLIOCSFLAGS:
-               s = splimp();
-               /* temp compat */
-               sc->sc_if.if_flags &= ~(SC_COMPRESS | SC_NOICMP | SC_AUTOCOMP);
-               if (*(int *)data & 0x2)
-                       sc->sc_if.if_flags |= SC_COMPRESS;
-               if (*(int *)data & 0x4)
-                       sc->sc_if.if_flags |= SC_NOICMP;
-               if (*(int *)data & 0x8)
-                       sc->sc_if.if_flags |= SC_AUTOCOMP;
-               splx(s);
-               break;
-
        default:
                return (-1);
        }
        default:
                return (-1);
        }
@@ -314,6 +285,7 @@ sloutput(ifp, m, dst)
        register struct sl_softc *sc = &sl_softc[ifp->if_unit];
        register struct ip *ip;
        register struct ifqueue *ifq;
        register struct sl_softc *sc = &sl_softc[ifp->if_unit];
        register struct ip *ip;
        register struct ifqueue *ifq;
+       register int p;
        int s;
 
        /*
        int s;
 
        /*
@@ -337,25 +309,13 @@ sloutput(ifp, m, dst)
                return (EHOSTUNREACH);
        }
        ifq = &sc->sc_if.if_snd;
                return (EHOSTUNREACH);
        }
        ifq = &sc->sc_if.if_snd;
-       if ((ip = mtod(m, struct ip *))->ip_p == IPPROTO_TCP) {
-#ifdef nomore
-               register int p = ((int *)ip)[ip->ip_hl];
-
-               if (INTERACTIVE(p & 0xffff) || INTERACTIVE(p >> 16)) {
-                       ifq = &sc->sc_fastq;
-                       p = 1;
-               } else
-                       p = 0;
-#else
-               register int p;
-
-               if (ip->ip_tos & IPTOS_LOWDELAY) {
-                       ifq = &sc->sc_fastq;
-                       p = 1;
-               } else
-                       p = 0;
-#endif
-
+       ip = mtod(m, struct ip *);
+       if (ip->ip_tos & IPTOS_LOWDELAY) {
+               ifq = &sc->sc_fastq;
+               p = 1;
+       } else
+               p = 0;
+       if (ip->ip_p == IPPROTO_TCP) {
                if (sc->sc_if.if_flags & SC_COMPRESS) {
                        /*
                         * The last parameter turns off connection id
                if (sc->sc_if.if_flags & SC_COMPRESS) {
                        /*
                         * The last parameter turns off connection id
@@ -703,7 +663,8 @@ slioctl(ifp, cmd, data)
        caddr_t data;
 {
        register struct ifaddr *ifa = (struct ifaddr *)data;
        caddr_t data;
 {
        register struct ifaddr *ifa = (struct ifaddr *)data;
-       int s = splimp(), error = 0;
+       register struct ifreq *ifr;
+       register int s = splimp(), error = 0;
 
        switch (cmd) {
 
 
        switch (cmd) {
 
@@ -719,10 +680,30 @@ slioctl(ifp, cmd, data)
                        error = EAFNOSUPPORT;
                break;
 
                        error = EAFNOSUPPORT;
                break;
 
+       case SIOCADDMULTI:
+       case SIOCDELMULTI:
+               ifr = (struct ifreq *)data;
+               if (ifr == 0) {
+                       error = EAFNOSUPPORT;           /* XXX */
+                       break;
+               }
+               switch (ifr->ifr_addr.sa_family) {
+
+#ifdef INET
+               case AF_INET:
+                       break;
+#endif
+
+               default:
+                       error = EAFNOSUPPORT;
+                       break;
+               }
+               break;
+#endif
+
        default:
                error = EINVAL;
        }
        splx(s);
        return (error);
 }
        default:
                error = EINVAL;
        }
        splx(s);
        return (error);
 }
-#endif