X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=freebsd-2.0%2Fppp_tty.c;h=81ffe925b97f4a1e7c3252bf7aaacb66e930507d;hp=1f22821dc26f58b4b1398b3508fefd6b130748cc;hb=f496bf27c6f959825eb6b6d60e31801ff6137462;hpb=29aef83eca8130891aafe73bf32c4e5463393d0f diff --git a/freebsd-2.0/ppp_tty.c b/freebsd-2.0/ppp_tty.c index 1f22821..81ffe92 100644 --- a/freebsd-2.0/ppp_tty.c +++ b/freebsd-2.0/ppp_tty.c @@ -70,7 +70,7 @@ * Paul Mackerras (paulus@cs.anu.edu.au). */ -/* $Id: ppp_tty.c,v 1.2 1995/05/02 01:00:44 paulus Exp $ */ +/* $Id: ppp_tty.c,v 1.4 1995/10/27 03:34:44 paulus Exp $ */ /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */ #include "ppp.h" @@ -111,7 +111,7 @@ int pppopen __P((dev_t dev, struct tty *tp)); int pppclose __P((struct tty *tp, int flag)); int pppread __P((struct tty *tp, struct uio *uio, int flag)); int pppwrite __P((struct tty *tp, struct uio *uio, int flag)); -int ppptioctl __P((struct tty *tp, int cmd, caddr_t data, int flag, +int ppptioctl __P((struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *)); int pppinput __P((int c, struct tty *tp)); int pppstart __P((struct tty *tp)); @@ -157,7 +157,7 @@ static void ppplogchar __P((struct ppp_softc *, int)); static struct linesw pppdisc = { pppopen, pppclose, pppread, pppwrite, ppptioctl, - pppinput, pppstart, nullmodem + pppinput, pppstart, ttymodem }; void @@ -171,6 +171,7 @@ TEXT_SET(pseudo_set, pppasyncattach); /* * Line specific open routine for async tty devices. * Attach the given tty to the first available ppp unit. + * Called from device open routine or ttioctl. */ /* ARGSUSED */ int @@ -185,19 +186,24 @@ pppopen(dev, tp) if (error = suser(p->p_ucred, &p->p_acflag)) return (error); + s = spltty(); + if (tp->t_line == PPPDISC) { sc = (struct ppp_softc *) tp->t_sc; - if (sc != NULL && sc->sc_devp == (void *) tp) + if (sc != NULL && sc->sc_devp == (void *) tp) { + splx(s); return (0); + } } - if ((sc = pppalloc(p->p_pid)) == NULL) + if ((sc = pppalloc(p->p_pid)) == NULL) { + splx(s); return ENXIO; + } if (sc->sc_relinq) (*sc->sc_relinq)(sc); /* get previous owner to relinquish the unit */ - s = splimp(); sc->sc_ilen = 0; sc->sc_m = NULL; bzero(sc->sc_asyncmap, sizeof(sc->sc_asyncmap)); @@ -214,13 +220,14 @@ pppopen(dev, tp) tp->t_sc = (caddr_t) sc; ttyflush(tp, FREAD | FWRITE); - splx(s); + splx(s); return (0); } /* - * Line specific close routine. + * Line specific close routine, called from device close routine + * and from ttioctl. * Detach the tty from the ppp unit. * Mimics part of ttyclose(). */ @@ -233,8 +240,8 @@ pppclose(tp, flag) struct mbuf *m; int s; - ttywflush(tp); - s = splimp(); /* paranoid; splnet probably ok */ + s = spltty(); + ttyflush(tp, FREAD|FWRITE); tp->t_line = 0; sc = (struct ppp_softc *) tp->t_sc; if (sc != NULL) { @@ -257,7 +264,7 @@ pppasyncrelinq(sc) { int s; - s = splimp(); + s = spltty(); if (sc->sc_outm) { m_freem(sc->sc_outm); sc->sc_outm = NULL; @@ -293,7 +300,7 @@ pppread(tp, uio, flag) * Loop waiting for input, checking that nothing disasterous * happens in the meantime. */ - s = splimp(); + s = spltty(); for (;;) { if (tp != (struct tty *) sc->sc_devp || tp->t_line != PPPDISC) { splx(s); @@ -310,7 +317,7 @@ pppread(tp, uio, flag) splx(s); return (EWOULDBLOCK); } - error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI|PCATCH, ttyin, 0); + error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH, "ttyin", 0); if (error) { splx(s); return error; @@ -388,8 +395,9 @@ pppwrite(tp, uio, flag) int ppptioctl(tp, cmd, data, flag, p) struct tty *tp; + u_long cmd; caddr_t data; - int cmd, flag; + int flag; struct proc *p; { struct ppp_softc *sc = (struct ppp_softc *) tp->t_sc; @@ -498,7 +506,7 @@ pppfcs(fcs, cp, len) /* * This gets called from pppoutput when a new packet is - * put on a queue. + * put on a queue, at splnet. */ static void pppasyncstart(sc) @@ -507,30 +515,34 @@ pppasyncstart(sc) register struct tty *tp = (struct tty *) sc->sc_devp; int s; - s = splimp(); + s = spltty(); pppstart(tp); splx(s); } /* * This gets called when a received packet is placed on - * the inq. + * the inq, at splnet. */ static void pppasyncctlp(sc) struct ppp_softc *sc; { struct tty *tp; + int s; /* Put a placeholder byte in canq for ttselect()/ttnread(). */ + s = spltty(); tp = (struct tty *) sc->sc_devp; putc(0, &tp->t_canq); ttwakeup(tp); + splx(s); } /* * Start output on async tty interface. Get another datagram * to send from the interface queue and start sending it. + * Called at spltty or higher. */ int pppstart(tp) @@ -695,7 +707,7 @@ pppstart(tp) } /* - * If there is stuff in the output queue, send it now. + * Send anything that may be in the output queue. * We are being called in lieu of ttstart and must do what it would. */ if (tp->t_oproc != NULL) @@ -725,7 +737,7 @@ ppp_timeout(x) struct tty *tp = (struct tty *) sc->sc_devp; int s; - s = splimp(); + s = spltty(); sc->sc_flags &= ~SC_TIMEOUT; pppstart(tp); splx(s); @@ -742,7 +754,7 @@ pppgetm(sc) int len; int s; - s = splimp(); + s = spltty(); mp = &sc->sc_m; for (len = sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN; len > 0; ){ if ((m = *mp) == NULL) { @@ -779,7 +791,7 @@ pppinput(c, tp) if (sc == NULL || tp != (struct tty *) sc->sc_devp) return 0; - s = spltty(); + s = spltty(); /* should be unnecessary */ ++tk_nin; ++sc->sc_bytesrcvd; @@ -792,6 +804,22 @@ pppinput(c, tp) c &= 0xff; + if (sc->sc_flags & SC_XONXOFF) { + if (c == XOFF) { + if ((tp->t_state & TS_TTSTOP) == 0) { + tp->t_state |= TS_TTSTOP; + (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0); + } + return 0; + } + if (c == XON) { + tp->t_state &= ~TS_TTSTOP; + if (tp->t_oproc != NULL) + (*tp->t_oproc)(tp); + return 0; + } + } + if (c & 0x80) sc->sc_flags |= SC_RCV_B7_1; else