#! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # sl # This archive created: Thu Apr 7 19:28:46 1988 export PATH; PATH=/bin:/usr/bin:$PATH if test ! -d 'sl' then echo shar: "creating directory 'sl'" mkdir 'sl' fi echo shar: "entering directory 'sl'" cd 'sl' echo shar: "extracting 'README'" '(4102 characters)' if test -f 'README' then echo shar: "will not over-write existing file 'README'" else cat << \SHAR_EOF > 'README' this is a new serial line ip driver distribution that includes (untested) support for generic 4.2 bsd vax systems and suns running 3.n. if you are running 4.3 bsd, you do not need this package since it is part of standard 4.3. some things to be aware of: 1. if you are a binary only 4.2 site and your vendor has not fixed the kernel routing code to permit routing on one logical network with many physical networks, then you will need to get your vendor to fix this before you can run this driver (it is fixed on sun 3.n and 4.3 bsd). the patch to implement this change is included in this distribution for those 4.2 sites with source code. 2. the use of the the built-in serial ports on the sun 2 and sun 3 is recommended as these ports support modem control and reliable throughput up to 19200 baud. although not suggested, the driver can be used with a systech serial board provided a minor hardware adjustment is made. the problem is that the default hardware interrupt priority for the systech board is set too high (it is higher than splimp). the problem manifests itself as `mget' panics and can be fixed by lowering the hardware interrupt level of the board by one. the following files are included in the distribution: README - this file if_sl.c.diff - patch to if_sl.c for sun 3.n & 4.2 bsd man/man8/slattach.8c - 4.3 bsd slattach(8c) man page man/manl/dstaddr.l - destaddr(l) man page src/local/Makefile - makefile for dstaddr & slattach src/local/dstaddr.c - dstaddr(l) source src/local/slattach.c - 4.3 bsd slattach(8c) source src/sys/net/if_sl.c - 4.3 bsd serial line driver sun.diff - patches to kernel files for sun 3.n vax.diff - patches to kernel files for 4.2 bsd installation instructions: 1. copy src/sys/net/if_sl.c into the `net' subdirectory of your kernel working area and then apply the kernel patches in if_sl.c.diff and either sun.diff or vax.diff using the `patch' program with the `-p' option (for example, `patch -d /mysysdir -p < if_sl.c.diff'). 2. create and install the dstaddr and slattach binaries in src/local. note that the makefile in the src/local directory may need to be changed if the length of the maximum hostname is different than the sun 3.n and 4.2 bsd default length of 32. 4.3 bsd defines the `MAXHOSTNAMELEN' in but it is not defined on systems based on 4.2 bsd so in this distribution it is set in the src/local/Makefile. in addition, if the changes to `h/ioctl.h' are not propagated to the copy of the file in `/usr/incude/sys/ioctl.h', an appropriate `-Ipathname' argument will need to be added to the definition of `CFLAGS'. 3. add a line of the form `pseudo-device sl ' to the configuration file of the system you wish to add the serial line driver to. the value should be the number of serial lines you plan on using for tcp/ip connections. by default, is one. 4. generate a new kernel through the usual steps (see `Building Berkeley Kernels with Config' by Leffler and Karels, or the sun 3.n documentation if you are not familiar with this procedure). due to the simplified method the sun uses to generate dependencies, it will be necessary to manually edit the makefile created by `config' and remove the dependency containing `/usr/include/machine/mtpr.h'. 5. after saving a copy of the currently running kernel and rebooting with the new system installed, the sequence of steps needed to initialize this end of the tcp/ip serial line is roughly: % slattach [] % dstaddr sl % ifconfig sl where starts out at zero, and increments for each slattach process that is running. for example, % /usr/local/etc/slattach ttyb 4800 % /usr/local/etc/dstaddr sl0 192.12.141.14 % /etc/ifconfig sl0 192.33.188.1 similar steps should then be applied on the other machine (4.3 sites normally set the destination address with the `ifconfig' command). once the link is known to be working, the above steps should be added to the machine's respective rc.local files. SHAR_EOF if test 4102 -ne "`wc -c < 'README'`" then echo shar: "error transmitting 'README'" '(should have been 4102 characters)' fi chmod 444 'README' fi if test ! -d 'man' then echo shar: "creating directory 'man'" mkdir 'man' fi echo shar: "entering directory 'man'" cd 'man' if test ! -d 'manl' then echo shar: "creating directory 'manl'" mkdir 'manl' fi echo shar: "entering directory 'manl'" cd 'manl' echo shar: "extracting 'dstaddr.l'" '(890 characters)' if test -f 'dstaddr.l' then echo shar: "will not over-write existing file 'dstaddr.l'" else cat << \SHAR_EOF > 'dstaddr.l' .TH DSTADDR 8C "Sep 15, 1986" .UC 5 .SH NAME dstaddr \- configure network interface destination address .SH SYOPNSIS .B /usr/local/dstaddr interface dest_address .SH DESCRIPTION .I Dstaddr must be used at boot time to specify the address of the correspondent on the other end of a point to point link. The .I interface parameter is a string of the form ``name unit'', e.g. ``en0''. .LP The address is either a host name present in the host name data base, .IR hosts (5), or a DARPA Internet address expressed in the Internet standard ``dot notation''. .PP Only the super-user may modify the configuration of a network interface. .SH DIAGNOSTICS Messages indicating the specified interface does not exit, the requested address is unknown, or the user is not privileged and tried to alter an interface's configuration. .SH "SEE ALSO" netstat(1), intro(4N), rc(8), ifconfig(8c), slattach(8c) SHAR_EOF if test 890 -ne "`wc -c < 'dstaddr.l'`" then echo shar: "error transmitting 'dstaddr.l'" '(should have been 890 characters)' fi chmod 444 'dstaddr.l' fi chmod 755 . echo shar: "done with directory 'manl'" cd .. if test ! -d 'man8' then echo shar: "creating directory 'man8'" mkdir 'man8' fi echo shar: "entering directory 'man8'" cd 'man8' echo shar: "extracting 'slattach.8c'" '(1093 characters)' if test -f 'slattach.8c' then echo shar: "will not over-write existing file 'slattach.8c'" else cat << \SHAR_EOF > 'slattach.8c' .\" @(#)slattach.8c 6.1 (Berkeley) 2/17/86 .TH SLATTACH 8C "February 17, 1986" .UC 6 .SH NAME slattach \- attach serial lines as network interfaces .SH SYOPNSIS .B /etc/slattach ttyname [ .I baudrate ] .SH DESCRIPTION .I Slattach is used to assign a tty line to a network interface, and to define the network source and destination addresses. The .I ttyname parameter is a string of the form ``ttyXX'', or ``/dev/ttyXX''. The optional .I baudrate parameter is used to set the speed of the connection. If not specified, the default of 9600 is used. .PP Only the super-user may attach a network interface. .PP To detach the interface, use `ifconfig .I interface-name down' after killing off the .I slattach process. .I interface-name is the name that is shown by .B netstat(1) .SH EXAMPLES .ta 8 /etc/slattach ttyh8 .br /etc/slattach /dev/tty01 4800 .SH DIAGNOSTICS Messages indicating the specified interface does not exit, the requested address is unknown, the user is not privileged and tried to alter an interface's configuration. .SH "SEE ALSO" rc(8), intro(4N), netstat(1), ifconfig(8C) SHAR_EOF if test 1093 -ne "`wc -c < 'slattach.8c'`" then echo shar: "error transmitting 'slattach.8c'" '(should have been 1093 characters)' fi chmod 444 'slattach.8c' fi chmod 755 . echo shar: "done with directory 'man8'" cd .. chmod 755 . echo shar: "done with directory 'man'" cd .. if test ! -d 'src' then echo shar: "creating directory 'src'" mkdir 'src' fi echo shar: "entering directory 'src'" cd 'src' if test ! -d 'local' then echo shar: "creating directory 'local'" mkdir 'local' fi echo shar: "entering directory 'local'" cd 'local' echo shar: "extracting 'dstaddr.c'" '(1394 characters)' if test -f 'dstaddr.c' then echo shar: "will not over-write existing file 'dstaddr.c'" else cat << \SHAR_EOF > 'dstaddr.c' #include #include #include #include #include #include #include #include struct ifreq ifr; int s; main(argc, argv) int argc; char *argv[]; { char *strncpy(); if (argc < 3) { (void) fprintf(stderr, "usage: %s interface dest_addr\n", argv[0]); exit(1); } (void) strncpy(ifr.ifr_name, argv[1], strlen(argv[1]) + 1); s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) { perror("socket"); exit(1); } if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) { perror("ioctl (SIOCGIFFLAGS)"); exit(1); } in_getaddr(argv[2], &ifr.ifr_addr); if (ioctl(s, SIOCSIFDSTADDR, (caddr_t)&ifr) < 0) perror("ioctl (SIOCSIFDSTADDR)"); } struct in_addr inet_makeaddr(); in_getaddr(s, saddr) char *s; struct sockaddr *saddr; { register struct sockaddr_in *sin = (struct sockaddr_in *)saddr; struct hostent *hp; struct netent *np; int val; sin->sin_family = AF_INET; val = inet_addr(s); if (val != -1) { sin->sin_addr.s_addr = val; return; } hp = gethostbyname(s); if (hp) { sin->sin_family = hp->h_addrtype; bcopy(hp->h_addr, (char *)&sin->sin_addr, hp->h_length); return; } np = getnetbyname(s); if (np) { sin->sin_family = np->n_addrtype; sin->sin_addr = inet_makeaddr(np->n_net, INADDR_ANY); return; } (void) fprintf(stderr, "%s: bad value\n", s); exit(1); } SHAR_EOF if test 1394 -ne "`wc -c < 'dstaddr.c'`" then echo shar: "error transmitting 'dstaddr.c'" '(should have been 1394 characters)' fi chmod 444 'dstaddr.c' fi echo shar: "extracting 'Makefile'" '(1035 characters)' if test -f 'Makefile' then echo shar: "will not over-write existing file 'Makefile'" else cat << \SHAR_EOF > 'Makefile' # DESTDIR= CFLAGS= -DMAXHOSTNAMELEN=32 -O # C programs that live in the current directory and do not need # explicit make lines. # STD= dstaddr slattach all: ${STD} ${STD}: cc ${CFLAGS} -o $@ $@.c install: -for i in ${STD}; do \ (install $$i ${DESTDIR}/usr/local/etc/$$i); done clean: rm -f a.out core *.s *.o for i in ${SUBDIR}; do (cd $$i; make ${MFLAGS} clean); done rm -f ${STD} ${NSTD} depend: cat x.c for i in ${STD} ${NSTD}; do \ (echo $$i: $$i.c >>makedep; \ /bin/grep '^#[ ]*include' x.c $$i.c | sed \ -e 's,<\(.*\)>,"/usr/include/\1",' \ -e 's/:[^"]*"\([^"]*\)".*/: \1/' \ -e 's/\.c//' >>makedep); done echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep echo '$$r makedep' >>eddep echo 'w' >>eddep cp Makefile Makefile.bak ed - Makefile < eddep rm eddep makedep x.c echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile echo '# see make depend above' >> Makefile # DO NOT DELETE THIS LINE -- make depend uses it SHAR_EOF if test 1035 -ne "`wc -c < 'Makefile'`" then echo shar: "error transmitting 'Makefile'" '(should have been 1035 characters)' fi chmod 444 'Makefile' fi echo shar: "extracting 'slattach.c'" '(2203 characters)' if test -f 'slattach.c' then echo shar: "will not over-write existing file 'slattach.c'" else cat << \SHAR_EOF > 'slattach.c' #ifndef lint static char sccsid[] = "@(#)slattach.c 4.1 (Berkeley) 2/17/86"; #endif #include #include #include #include #include #include #include #include #ifndef lint static char rcsid[] = "$Header: slattach.c,v 1.1 84/10/04 12:57:12 rick Exp $"; #endif #define DEFAULT_BAUD 9600 int speed; int slipdisc = SLIPDISC; char devname[32]; char hostname[MAXHOSTNAMELEN]; extern int errno; main(argc, argv) int argc; char *argv[]; { register FILE *fp; register int fd; register char *dev = argv[1]; struct sgttyb sgtty; int n; if (argc < 2 || argc > 3) { fprintf(stderr, "usage: %s ttyname [baudrate]\n", argv[0]); exit(1); } speed = argc == 3 ? findspeed(atoi(argv[2])) : findspeed(DEFAULT_BAUD); if (speed == 0) { fprintf(stderr, "unknown speed %s", argv[2]); exit(1); } if (strncmp("/dev/", dev, 5)) { sprintf(devname, "/dev/%s", dev); dev = devname; } if ((fd = open(dev, O_RDWR | O_NDELAY)) < 0) { perror(dev); exit(1); } sgtty.sg_flags = RAW | ANYP; sgtty.sg_ispeed = sgtty.sg_ospeed = speed; if (ioctl(fd, TIOCSETP, &sgtty) < 0) { perror("ioctl(TIOCSETP)"); exit(1); } if (ioctl(fd, TIOCSETD, &slipdisc) < 0) { perror("ioctl(TIOCSETD)"); exit(1); } if (fork() > 0) exit(0); for (;;) sigpause(0); } struct sg_spds { int sp_val, sp_name; } spds[] = { #ifdef B50 { 50, B50 }, #endif #ifdef B75 { 75, B75 }, #endif #ifdef B110 { 110, B110 }, #endif #ifdef B150 { 150, B150 }, #endif #ifdef B200 { 200, B200 }, #endif #ifdef B300 { 300, B300 }, #endif #ifdef B600 { 600, B600 }, #endif #ifdef B1200 { 1200, B1200 }, #endif #ifdef B1800 { 1800, B1800 }, #endif #ifdef B2000 { 2000, B2000 }, #endif #ifdef B2400 { 2400, B2400 }, #endif #ifdef B3600 { 3600, B3600 }, #endif #ifdef B4800 { 4800, B4800 }, #endif #ifdef B7200 { 7200, B7200 }, #endif #ifdef B9600 { 9600, B9600 }, #endif #ifdef EXTA { 19200, EXTA }, #endif #ifdef EXTB { 38400, EXTB }, #endif { 0, 0 } }; findspeed(speed) register int speed; { register struct sg_spds *sp; sp = spds; while (sp->sp_val && sp->sp_val != speed) sp++; return (sp->sp_name); } SHAR_EOF if test 2203 -ne "`wc -c < 'slattach.c'`" then echo shar: "error transmitting 'slattach.c'" '(should have been 2203 characters)' fi chmod 444 'slattach.c' fi chmod 755 . echo shar: "done with directory 'local'" cd .. if test ! -d 'sys' then echo shar: "creating directory 'sys'" mkdir 'sys' fi echo shar: "entering directory 'sys'" cd 'sys' if test ! -d 'net' then echo shar: "creating directory 'net'" mkdir 'net' fi echo shar: "entering directory 'net'" cd 'net' echo shar: "extracting 'if_sl.c'" '(11512 characters)' if test -f 'if_sl.c' then echo shar: "will not over-write existing file 'if_sl.c'" else cat << \SHAR_EOF > 'if_sl.c' /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and that due credit is given * to the University of California at Berkeley. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. * * @(#)if_sl.c 7.6.1.1 (Berkeley) 3/15/88 */ /* * Serial Line interface * * Rick Adams * Center for Seismic Studies * 1300 N 17th Street, Suite 1450 * Arlington, Virginia 22209 * (703)276-7900 * rick@seismo.ARPA * seismo!rick * * Pounded on heavily by Chris Torek (chris@mimsy.umd.edu, umcp-cs!chris). * N.B.: this belongs in netinet, not net, the way it stands now. * Should have a link-layer type designation, but wouldn't be * backwards-compatible. * * Converted to 4.3BSD Beta by Chris Torek. * Other changes made at Berkeley, based in part on code by Kirk Smith. */ /* $Header: if_sl.c,v 1.12 85/12/20 21:54:55 chris Exp $ */ /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */ #include "sl.h" #if NSL > 0 #include "param.h" #include "mbuf.h" #include "buf.h" #include "dk.h" #include "socket.h" #include "ioctl.h" #include "file.h" #include "tty.h" #include "errno.h" #include "if.h" #include "netisr.h" #include "route.h" #if INET #include "../netinet/in.h" #include "../netinet/in_systm.h" #include "../netinet/in_var.h" #include "../netinet/ip.h" #endif #include "../machine/mtpr.h" /* * N.B.: SLMTU is now a hard limit on input packet size. * SLMTU must be <= CLBYTES - sizeof(struct ifnet *). */ #define SLMTU 1006 #define SLIP_HIWAT 1000 /* don't start a new packet if HIWAT on queue */ #define CLISTRESERVE 1000 /* Can't let clists get too low */ struct sl_softc { struct ifnet sc_if; /* network-visible interface */ short sc_flags; /* see below */ short sc_ilen; /* length of input-packet-so-far */ struct tty *sc_ttyp; /* pointer to tty structure */ char *sc_mp; /* pointer to next available buf char */ char *sc_buf; /* input buffer */ } sl_softc[NSL]; /* flags */ #define SC_ESCAPED 0x0001 /* saw a FRAME_ESCAPE */ #define FRAME_END 0300 /* Frame End */ #define FRAME_ESCAPE 0333 /* Frame Esc */ #define TRANS_FRAME_END 0334 /* transposed frame end */ #define TRANS_FRAME_ESCAPE 0335 /* transposed frame esc */ #define t_sc T_LINEP int sloutput(), slioctl(), ttrstrt(); /* * Called from boot code to establish sl interfaces. */ slattach() { register struct sl_softc *sc; register int i = 0; for (sc = sl_softc; i < NSL; sc++) { sc->sc_if.if_name = "sl"; sc->sc_if.if_unit = i++; sc->sc_if.if_mtu = SLMTU; sc->sc_if.if_flags = IFF_POINTOPOINT; sc->sc_if.if_ioctl = slioctl; sc->sc_if.if_output = sloutput; sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN; if_attach(&sc->sc_if); } } /* * Line specific open routine. * Attach the given tty to the first available sl unit. */ /* ARGSUSED */ slopen(dev, tp) dev_t dev; register struct tty *tp; { register struct sl_softc *sc; register int nsl; if (!suser()) return (EPERM); if (tp->t_line == SLIPDISC) return (EBUSY); for (nsl = 0, sc = sl_softc; nsl < NSL; nsl++, sc++) if (sc->sc_ttyp == NULL) { sc->sc_flags = 0; sc->sc_ilen = 0; if (slinit(sc) == 0) return (ENOBUFS); tp->t_sc = (caddr_t)sc; sc->sc_ttyp = tp; ttyflush(tp, FREAD | FWRITE); return (0); } return (ENXIO); } /* * Line specific close routine. * Detach the tty from the sl unit. * Mimics part of ttyclose(). */ slclose(tp) struct tty *tp; { register struct sl_softc *sc; int s; ttywflush(tp); tp->t_line = 0; s = splimp(); /* paranoid; splnet probably ok */ sc = (struct sl_softc *)tp->t_sc; if (sc != NULL) { if_down(&sc->sc_if); sc->sc_ttyp = NULL; tp->t_sc = NULL; MCLFREE((struct mbuf *)sc->sc_buf); sc->sc_buf = 0; } splx(s); } /* * Line specific (tty) ioctl routine. * Provide a way to get the sl unit number. */ /* ARGSUSED */ sltioctl(tp, cmd, data, flag) struct tty *tp; caddr_t data; { if (cmd == TIOCGETD) { *(int *)data = ((struct sl_softc *)tp->t_sc)->sc_if.if_unit; return (0); } return (-1); } /* * Queue a packet. Start transmission if not active. */ sloutput(ifp, m, dst) register struct ifnet *ifp; register struct mbuf *m; struct sockaddr *dst; { register struct sl_softc *sc; int s; /* * `Cannot happen' (see slioctl). Someday we will extend * the line protocol to support other address families. */ if (dst->sa_family != AF_INET) { printf("sl%d: af%d not supported\n", ifp->if_unit, dst->sa_family); m_freem(m); return (EAFNOSUPPORT); } sc = &sl_softc[ifp->if_unit]; if (sc->sc_ttyp == NULL) { m_freem(m); return (ENETDOWN); /* sort of */ } if ((sc->sc_ttyp->t_state & TS_CARR_ON) == 0) { m_freem(m); return (EHOSTUNREACH); } s = splimp(); if (IF_QFULL(&ifp->if_snd)) { IF_DROP(&ifp->if_snd); splx(s); m_freem(m); sc->sc_if.if_oerrors++; return (ENOBUFS); } IF_ENQUEUE(&ifp->if_snd, m); if (sc->sc_ttyp->t_outq.c_cc == 0) { splx(s); slstart(sc->sc_ttyp); } else splx(s); return (0); } /* * Start output on interface. Get another datagram * to send from the interface queue and map it to * the interface before starting output. */ slstart(tp) register struct tty *tp; { register struct sl_softc *sc = (struct sl_softc *)tp->t_sc; register struct mbuf *m; register int len; register u_char *cp; int nd, np, n, s; struct mbuf *m2; extern int cfreecount; for (;;) { /* * If there is more in the output queue, just send it now. * We are being called in lieu of ttstart and must do what * it would. */ if (tp->t_outq.c_cc > 0) ttstart(tp); if (tp->t_outq.c_cc > SLIP_HIWAT) return; /* * This happens briefly when the line shuts down. */ if (sc == NULL) return; /* * If system is getting low on clists * and we have something running already, stop here. */ if (cfreecount < CLISTRESERVE + SLMTU && tp->t_outq.c_cc == 0) return; /* * Get a packet and send it to the interface. */ s = splimp(); IF_DEQUEUE(&sc->sc_if.if_snd, m); splx(s); if (m == NULL) return; /* * The extra FRAME_END will start up a new packet, and thus * will flush any accumulated garbage. We do this whenever * the line may have been idle for some time. */ if (tp->t_outq.c_cc == 0) (void) putc(FRAME_END, &tp->t_outq); while (m) { cp = mtod(m, u_char *); len = m->m_len; while (len > 0) { /* * Find out how many bytes in the string we can * handle without doing something special. */ nd = locc(FRAME_ESCAPE, len, cp); np = locc(FRAME_END, len, cp); n = len - MAX(nd, np); if (n) { /* * Put n characters at once * into the tty output queue. */ if (b_to_q((char *)cp, n, &tp->t_outq)) break; len -= n; cp += n; } /* * If there are characters left in the mbuf, * the first one must be special.. * Put it out in a different form. */ if (len) { if (putc(FRAME_ESCAPE, &tp->t_outq)) break; if (putc(*cp == FRAME_ESCAPE ? TRANS_FRAME_ESCAPE : TRANS_FRAME_END, &tp->t_outq)) { (void) unputc(&tp->t_outq); break; } cp++; len--; } } MFREE(m, m2); m = m2; } if (putc(FRAME_END, &tp->t_outq)) { /* * Not enough room. Remove a char to make room * and end the packet normally. * If you get many collisions (more than one or two * a day) you probably do not have enough clists * and you should increase "nclist" in param.c. */ (void) unputc(&tp->t_outq); (void) putc(FRAME_END, &tp->t_outq); sc->sc_if.if_collisions++; } else sc->sc_if.if_opackets++; } } slinit(sc) register struct sl_softc *sc; { struct mbuf *p; if (sc->sc_buf == (char *) 0) { MCLALLOC(p, 1); if (p) { sc->sc_buf = (char *)p; sc->sc_mp = sc->sc_buf + sizeof(struct ifnet *); } else { printf("sl%d: can't allocate buffer\n", sc - sl_softc); sc->sc_if.if_flags &= ~IFF_UP; return (0); } } return (1); } /* * Copy data buffer to mbuf chain; add ifnet pointer ifp. */ struct mbuf * sl_btom(sc, len, ifp) struct sl_softc *sc; register int len; struct ifnet *ifp; { register caddr_t cp; register struct mbuf *m, **mp; register unsigned count; struct mbuf *top = NULL; cp = sc->sc_buf + sizeof(struct ifnet *); mp = ⊤ while (len > 0) { MGET(m, M_DONTWAIT, MT_DATA); if ((*mp = m) == NULL) { m_freem(top); return (NULL); } if (ifp) m->m_off += sizeof(ifp); /* * If we have at least NBPG bytes, * allocate a new page. Swap the current buffer page * with the new one. We depend on having a space * left at the beginning of the buffer * for the interface pointer. */ if (len >= NBPG) { MCLGET(m); if (m->m_len == CLBYTES) { cp = mtod(m, char *); m->m_off = (int)sc->sc_buf - (int)m; sc->sc_buf = cp; if (ifp) { m->m_off += sizeof(ifp); count = MIN(len, CLBYTES - sizeof(struct ifnet *)); } else count = MIN(len, CLBYTES); goto nocopy; } } if (ifp) count = MIN(len, MLEN - sizeof(ifp)); else count = MIN(len, MLEN); bcopy(cp, mtod(m, caddr_t), count); nocopy: m->m_len = count; if (ifp) { m->m_off -= sizeof(ifp); m->m_len += sizeof(ifp); *mtod(m, struct ifnet **) = ifp; ifp = NULL; } cp += count; len -= count; mp = &m->m_next; } return (top); } /* * tty interface receiver interrupt. */ slinput(c, tp) register int c; register struct tty *tp; { register struct sl_softc *sc; register struct mbuf *m; int s; tk_nin++; sc = (struct sl_softc *)tp->t_sc; if (sc == NULL) return; c &= 0xff; if (sc->sc_flags & SC_ESCAPED) { sc->sc_flags &= ~SC_ESCAPED; switch (c) { case TRANS_FRAME_ESCAPE: c = FRAME_ESCAPE; break; case TRANS_FRAME_END: c = FRAME_END; break; default: sc->sc_if.if_ierrors++; sc->sc_mp = sc->sc_buf + sizeof(struct ifnet *); sc->sc_ilen = 0; return; } } else { switch (c) { case FRAME_END: if (sc->sc_ilen == 0) /* ignore */ return; m = sl_btom(sc, sc->sc_ilen, &sc->sc_if); if (m == NULL) { sc->sc_if.if_ierrors++; return; } sc->sc_mp = sc->sc_buf + sizeof(struct ifnet *); sc->sc_ilen = 0; sc->sc_if.if_ipackets++; s = splimp(); if (IF_QFULL(&ipintrq)) { IF_DROP(&ipintrq); sc->sc_if.if_ierrors++; m_freem(m); } else { IF_ENQUEUE(&ipintrq, m); schednetisr(NETISR_IP); } splx(s); return; case FRAME_ESCAPE: sc->sc_flags |= SC_ESCAPED; return; } } if (++sc->sc_ilen > SLMTU) { sc->sc_if.if_ierrors++; sc->sc_mp = sc->sc_buf + sizeof(struct ifnet *); sc->sc_ilen = 0; return; } *sc->sc_mp++ = c; } /* * Process an ioctl request. */ slioctl(ifp, cmd, data) register struct ifnet *ifp; int cmd; caddr_t data; { register struct ifaddr *ifa = (struct ifaddr *)data; int s = splimp(), error = 0; switch (cmd) { case SIOCSIFADDR: if (ifa->ifa_addr.sa_family == AF_INET) ifp->if_flags |= IFF_UP; else error = EAFNOSUPPORT; break; case SIOCSIFDSTADDR: if (ifa->ifa_addr.sa_family != AF_INET) error = EAFNOSUPPORT; break; default: error = EINVAL; } splx(s); return (error); } #endif SHAR_EOF if test 11512 -ne "`wc -c < 'if_sl.c'`" then echo shar: "error transmitting 'if_sl.c'" '(should have been 11512 characters)' fi chmod 444 'if_sl.c' fi chmod 755 . echo shar: "done with directory 'net'" cd .. chmod 755 . echo shar: "done with directory 'sys'" cd .. chmod 755 . echo shar: "done with directory 'src'" cd .. echo shar: "extracting 'vax.diff'" '(2609 characters)' if test -f 'vax.diff' then echo shar: "will not over-write existing file 'vax.diff'" else cat << \SHAR_EOF > 'vax.diff' *** conf/files.orig Thu Apr 7 11:05:31 1988 --- conf/files Thu Apr 7 15:17:19 1988 *************** *** 1,5 **** --- 1,6 ---- net/af.c standard net/if.c standard + net/if_sl.c optional sl net/raw_cb.c standard net/raw_usrreq.c standard net/route.c standard *** h/ioctl.h.orig Thu Apr 7 11:06:05 1988 --- h/ioctl.h Thu Apr 7 15:17:14 1988 *************** *** 176,181 **** --- 176,182 ---- #define NTTYDISC 2 /* new tty discipline */ #define TABLDISC 3 /* hitachi tablet discipline */ #define NTABLDISC 4 /* gtco tablet discipline */ + #define SLIPDISC 5 /* serial IP discipline */ #define FIOCLEX _IO(f, 1) /* set exclusive use on fd */ #define FIONCLEX _IO(f, 2) /* remove exclusive use */ *** net/route.c.orig Thu Apr 7 15:15:57 1988 --- net/route.c Thu Apr 7 15:16:51 1988 *************** *** 241,252 **** error = EEXIST; goto bad; } ! ifp = if_ifwithaddr(&entry->rt_gateway); if (ifp == 0) { ! ifp = if_ifwithnet(&entry->rt_gateway); if (ifp == 0) { ! error = ENETUNREACH; ! goto bad; } } m = m_get(M_DONTWAIT, MT_RTABLE); --- 241,263 ---- error = EEXIST; goto bad; } ! for (ifp = ifnet; ifp; ifp = ifp->if_next) { ! if (ifp->if_addr.sa_family != entry->rt_dst.sa_family || ! !(ifp->if_flags&IFF_UP)) ! continue; ! if ((ifp->if_flags & IFF_POINTOPOINT) && ! (bcmp(ifp->if_dstaddr.sa_data, entry->rt_dst.sa_data, 14) == 0) ! || (bcmp(ifp->if_dstaddr.sa_data, entry->rt_gateway.sa_data, 14) == 0)) ! break; ! } if (ifp == 0) { ! ifp = if_ifwithaddr(&entry->rt_gateway); if (ifp == 0) { ! ifp = if_ifwithnet(&entry->rt_gateway); ! if (ifp == 0) { ! error = ENETUNREACH; ! goto bad; ! } } } m = m_get(M_DONTWAIT, MT_RTABLE); *** sys/tty_conf.c.orig Thu Apr 7 15:16:26 1988 --- sys/tty_conf.c Thu Apr 7 15:16:36 1988 *************** *** 21,26 **** --- 21,30 ---- #if NTB > 0 int tbopen(),tbclose(),tbread(),tbinput(),tbioctl(); #endif + #include "sl.h" + #if NSL > 0 + int slopen(),slclose(),slinput(),sltioctl(),slstart(); + #endif struct linesw linesw[] = { *************** *** 45,50 **** --- 49,61 ---- #if NTB > 0 tbopen, tbclose, tbread, nodev, tbioctl, tbinput, nodev, nulldev, ttstart, nulldev, /* 4 */ + #else + nodev, nodev, nodev, nodev, nodev, + nodev, nodev, nodev, nodev, nodev, + #endif + #if NSL > 0 + slopen, slclose, nodev, nodev, sltioctl, + slinput, nodev, nulldev, slstart, nulldev, /* 5 */ #else nodev, nodev, nodev, nodev, nodev, nodev, nodev, nodev, nodev, nodev, SHAR_EOF if test 2609 -ne "`wc -c < 'vax.diff'`" then echo shar: "error transmitting 'vax.diff'" '(should have been 2609 characters)' fi chmod 444 'vax.diff' fi echo shar: "extracting 'sun.diff'" '(1615 characters)' if test -f 'sun.diff' then echo shar: "will not over-write existing file 'sun.diff'" else cat << \SHAR_EOF > 'sun.diff' *** conf/files.orig Tue Jul 8 00:28:35 1986 --- conf/files Mon Apr 4 17:06:44 1988 *************** *** 2,7 **** --- 2,8 ---- krpc/klm_kprot.c standard net/af.c standard net/if.c standard + net/if_sl.c optional sl net/nit.c optional NIT net/raw_cb.c standard net/raw_usrreq.c standard *** h/ioctl.h.orig Mon Oct 13 14:29:40 1986 --- h/ioctl.h Mon Apr 4 15:57:25 1988 *************** *** 263,268 **** --- 263,269 ---- #define NTABLDISC 4 /* gtco tablet discipline */ #define MOUSELDISC 5 /* mouse discipline */ #define KBDLDISC 6 /* up/down keyboard trans (console) */ + #define SLIPDISC 7 /* serial IP discipline */ #define FIOCLEX _IO(f, 1) /* set exclusive use on fd */ #define FIONCLEX _IO(f, 2) /* remove exclusive use */ *** sys/tty_conf.c.orig Tue Jul 8 01:02:02 1986 --- sys/tty_conf.c Mon Apr 4 15:58:05 1988 *************** *** 32,37 **** --- 32,42 ---- int kbdopen(), kbdclose(), kbdread(), kbdioctl(), kbdinput(); #endif + #include "sl.h" + #if NSL > 0 + int slopen(),slclose(),slinput(),sltioctl(),slstart(); + #endif + struct linesw linesw[] = { ttyopen, nodev, ttread, ttwrite, nullioctl, *************** *** 69,74 **** --- 74,86 ---- #if NKB > 0 kbdopen, kbdclose, kbdread, ttwrite, kbdioctl, kbdinput, nodev, nulldev, ttstart, nulldev, /* 6 */ + #else + nodev, nodev, nodev, nodev, nodev, + nodev, nodev, nodev, nodev, nodev, + #endif + #if NSL > 0 + slopen, slclose, nodev, nodev, sltioctl, + slinput, nodev, nulldev, slstart, nulldev, /* 7 */ #else nodev, nodev, nodev, nodev, nodev, nodev, nodev, nodev, nodev, nodev, SHAR_EOF if test 1615 -ne "`wc -c < 'sun.diff'`" then echo shar: "error transmitting 'sun.diff'" '(should have been 1615 characters)' fi chmod 444 'sun.diff' fi echo shar: "extracting 'if_sl.c.diff'" '(6785 characters)' if test -f 'if_sl.c.diff' then echo shar: "will not over-write existing file 'if_sl.c.diff'" else cat << \SHAR_EOF > 'if_sl.c.diff' *** net/if_sl.c.orig Thu Apr 7 16:45:26 1988 --- net/if_sl.c Thu Apr 7 16:48:20 1988 *************** *** 38,64 **** #include "sl.h" #if NSL > 0 ! #include "param.h" ! #include "mbuf.h" ! #include "buf.h" ! #include "dk.h" ! #include "socket.h" ! #include "ioctl.h" ! #include "file.h" ! #include "tty.h" ! #include "errno.h" ! #include "if.h" ! #include "netisr.h" ! #include "route.h" #if INET #include "../netinet/in.h" #include "../netinet/in_systm.h" ! #include "../netinet/in_var.h" #include "../netinet/ip.h" #endif #include "../machine/mtpr.h" /* * N.B.: SLMTU is now a hard limit on input packet size. --- 38,66 ---- #include "sl.h" #if NSL > 0 ! #include "../h/param.h" ! #include "../h/mbuf.h" ! #include "../h/buf.h" ! #include "../h/dk.h" ! #include "../h/socket.h" ! #include "../h/ioctl.h" ! #include "../h/file.h" ! #include "../h/tty.h" ! #include "../h/errno.h" ! #include "../net/if.h" ! #include "../net/netisr.h" ! #include "../net/route.h" #if INET #include "../netinet/in.h" #include "../netinet/in_systm.h" ! /* #include "../netinet/in_var.h" */ #include "../netinet/ip.h" #endif + #ifndef sun #include "../machine/mtpr.h" + #endif /* * N.B.: SLMTU is now a hard limit on input packet size. *************** *** 85,95 **** --- 87,142 ---- #define TRANS_FRAME_END 0334 /* transposed frame end */ #define TRANS_FRAME_ESCAPE 0335 /* transposed frame esc */ + #ifdef sun + #define t_sc t_linep + extern char mclrefcnt[]; + #else #define t_sc T_LINEP + #endif int sloutput(), slioctl(), ttrstrt(); + #ifndef mtocl + /* virtual address to network cluster number */ + #define mtocl(x) (((int)x - (int)mbutl) >> CLSHIFT) + #endif + /* + * Mbuf page cluster macros. + * MCLALLOC allocates mbuf page clusters. + * Note that it works only with a count of 1 at the moment. + * MCLGET adds such clusters to a normal mbuf. + * m->m_len is set to CLBYTES upon success. + * MCLFREE frees clusters allocated by MCLALLOC. + */ + #ifndef MCLALLOC + #define MCLALLOC(m, i) \ + { int ms = splimp(); \ + if (mclfree == 0) \ + (void)m_clalloc(1, MPG_CLUSTERS, M_DONTWAIT); \ + if ((m)=mclfree) \ + {++mclrefcnt[mtocl(m)];mbstat.m_clfree--;mclfree = (m)->m_next;} \ + splx(ms); } + #endif + + #ifndef MCLGET + #define MCLGET(m) \ + { struct mbuf *p; \ + MCLALLOC(p, 1); \ + if (p) { \ + (m)->m_off = (int)p - (int)(m); \ + (m)->m_len = CLBYTES; \ + } \ + } + #endif + #ifndef MCLFREE + #define MCLFREE(m) { \ + if (--mclrefcnt[mtocl(m)] == 0) \ + { (m)->m_next = mclfree;mclfree = (m);mbstat.m_clfree++;} \ + } + #endif + + /* * Called from boot code to establish sl interfaces. */ slattach() *************** *** 121,126 **** --- 168,186 ---- register struct sl_softc *sc; register int nsl; + #ifndef BSD4_3 + if (sl_softc->sc_if.if_name == NULL) { + slattach(); /* XXX */ + if (ifnet != NULL && !bcmp(ifnet->if_name, "lo", sizeof "lo")) { + register struct ifnet *ifp; + + ifp = ifnet->if_next; + ifnet->if_next = NULL; + ifnet = ifp; + loattach(); /* XXX */ + } + } + #endif if (!suser()) return (EPERM); if (tp->t_line == SLIPDISC) *************** *** 388,395 **** --- 448,457 ---- m_freem(top); return (NULL); } + #ifdef BSD4_3 if (ifp) m->m_off += sizeof(ifp); + #endif /* * If we have at least NBPG bytes, * allocate a new page. Swap the current buffer page *************** *** 398,424 **** --- 460,495 ---- * for the interface pointer. */ if (len >= NBPG) { + #if defined(BSD4_3) || defined(sun) MCLGET(m); + #else + MCLGET(m, 0); + #endif if (m->m_len == CLBYTES) { cp = mtod(m, char *); m->m_off = (int)sc->sc_buf - (int)m; sc->sc_buf = cp; + #ifdef BSD4_3 if (ifp) { m->m_off += sizeof(ifp); count = MIN(len, CLBYTES - sizeof(struct ifnet *)); } else + #endif count = MIN(len, CLBYTES); goto nocopy; } } + #ifdef BSD4_3 if (ifp) count = MIN(len, MLEN - sizeof(ifp)); else + #endif count = MIN(len, MLEN); bcopy(cp, mtod(m, caddr_t), count); nocopy: m->m_len = count; + #ifdef BSD4_3 if (ifp) { m->m_off -= sizeof(ifp); m->m_len += sizeof(ifp); *************** *** 425,430 **** --- 496,502 ---- *mtod(m, struct ifnet **) = ifp; ifp = NULL; } + #endif cp += count; len -= count; mp = &m->m_next; *************** *** 515,535 **** --- 587,669 ---- int cmd; caddr_t data; { + #ifdef BSD4_3 register struct ifaddr *ifa = (struct ifaddr *)data; + #else + #ifdef sun + register struct sockaddr *addr = (struct sockaddr *)data; + #else + register struct ifreq *ifr = (struct ifreq *)data; + register struct sockaddr *addr; + #endif + #endif int s = splimp(), error = 0; switch (cmd) { case SIOCSIFADDR: + #ifdef BSD4_3 if (ifa->ifa_addr.sa_family == AF_INET) ifp->if_flags |= IFF_UP; + #else + #ifndef sun + addr = &ifr->ifr_addr; + #endif + if (addr->sa_family == AF_INET) { + struct sockaddr oldaddr; + struct sockaddr_in netaddr; + int s = splimp(); + + oldaddr = ifp->if_addr; + ifp->if_addr = *addr; + + /* + * Delete any previous route for an old address. + */ + bzero((caddr_t)&netaddr, sizeof (netaddr)); + netaddr.sin_family = AF_INET; + if (ifp->if_flags & IFF_ROUTE) { + rtinit(&ifp->if_dstaddr, &oldaddr, RTF_HOST); + ifp->if_flags &= ~IFF_ROUTE; + } + ifp->if_net = in_netof(((struct sockaddr_in *)(addr))->sin_addr); + splx(s); + /* + * Add route for the network. + */ + if (ifp->if_flags & IFF_POINTOPOINT) + rtinit(&ifp->if_dstaddr, &ifp->if_addr, + RTF_HOST|RTF_UP); + ifp->if_flags |= IFF_ROUTE | IFF_UP; + } + #endif else error = EAFNOSUPPORT; break; case SIOCSIFDSTADDR: + #ifdef BSD4_3 if (ifa->ifa_addr.sa_family != AF_INET) + #else + #ifndef sun + addr = &ifr->ifr_addr; + #endif + if (addr->sa_family != AF_INET) + #endif error = EAFNOSUPPORT; + #ifndef BSD4_3 + else { + struct sockaddr oldaddr; + + oldaddr = ifp->if_dstaddr; + ifp->if_dstaddr = *addr; + if (ifp->if_flags & IFF_ROUTE) { + rtinit(&oldaddr, &ifp->if_addr, -1); + rtinit(&ifp->if_dstaddr, &ifp->if_addr, + RTF_HOST|RTF_UP); + } + } + #endif break; default: *************** *** 538,541 **** --- 672,689 ---- splx(s); return (error); } + + #ifndef BSD4_3 + locc(mask, size, cp) + register u_char mask; + u_int size; + register u_char *cp; + { + register u_char *end = &cp[size]; + + while (cp < end && *cp != mask) + cp++; + return (end - cp); + } + #endif #endif SHAR_EOF if test 6785 -ne "`wc -c < 'if_sl.c.diff'`" then echo shar: "error transmitting 'if_sl.c.diff'" '(should have been 6785 characters)' fi chmod 444 'if_sl.c.diff' fi chmod 755 . echo shar: "done with directory 'sl'" cd .. exit 0 # End of shell archive