From f4c118d7a32370516b0871920b36002895f14f1d Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 27 Mar 2002 14:36:07 +0000 Subject: 2002-03-27 Ilya Alexeev * PR162 * net/if_ppp.c ppp_txdaemon(), net/if_pppvar.h pppstart(): Local variables must not be used in a device write routines. Now ppp_softc structure have own character for writing to device (sc_outchar). I think that converting local variables to static is not a right solution, because problems will occur in the case of two or more ppp instances. * net/ppp_tty.c pppstart(): Type of the ioffset variable must be u_long, otherwise in the case of the big output packet endless loop may occur. --- c/src/exec/libnetworking/ChangeLog | 13 +++++++++++++ c/src/exec/libnetworking/net/if_ppp.c | 4 ++-- c/src/exec/libnetworking/net/if_pppvar.h | 1 + c/src/exec/libnetworking/net/ppp_tty.c | 21 ++++++++++----------- 4 files changed, 26 insertions(+), 13 deletions(-) (limited to 'c/src/exec/libnetworking') diff --git a/c/src/exec/libnetworking/ChangeLog b/c/src/exec/libnetworking/ChangeLog index 8305cf2bc0..34f30b49c3 100644 --- a/c/src/exec/libnetworking/ChangeLog +++ b/c/src/exec/libnetworking/ChangeLog @@ -1,3 +1,16 @@ +2002-03-27 Ilya Alexeev + + * PR162 + * net/if_ppp.c ppp_txdaemon(), net/if_pppvar.h pppstart(): Local + variables must not be used in a device write routines. Now + ppp_softc structure have own character for writing to device + (sc_outchar). I think that converting local variables to static + is not a right solution, because problems will occur in the case + of two or more ppp instances. + * net/ppp_tty.c pppstart(): Type of the ioffset variable must be + u_long, otherwise in the case of the big output packet endless + loop may occur. + 2002-03-21 Ilya Alexeev * net/if_ppp.c, net/ppp_tty.c: Initial preparations for multiple diff --git a/c/src/exec/libnetworking/net/if_ppp.c b/c/src/exec/libnetworking/net/if_ppp.c index bb90eac78a..d4e0847655 100644 --- a/c/src/exec/libnetworking/net/if_ppp.c +++ b/c/src/exec/libnetworking/net/if_ppp.c @@ -243,7 +243,6 @@ static rtems_task ppp_rxdaemon(rtems_task_argument arg) static rtems_task ppp_txdaemon(rtems_task_argument arg) { rtems_event_set events; - char cFrame = (char )PPP_FLAG; int iprocess = (int )0; struct ppp_softc *sc = (struct ppp_softc *)arg; struct mbuf *mp; @@ -351,7 +350,8 @@ static rtems_task ppp_txdaemon(rtems_task_argument arg) microtime(&sc->sc_if.if_lastchange); /* write out frame byte to start the transmission */ - (*tp->device.write)(tp->minor, &cFrame, 1); + sc->sc_outchar = (u_char)PPP_FLAG; + (*tp->device.write)(tp->minor, &sc->sc_outchar, 1); } /* check to see if we need to free some empty mbufs */ diff --git a/c/src/exec/libnetworking/net/if_pppvar.h b/c/src/exec/libnetworking/net/if_pppvar.h index 374fac3b11..2b4cd7d9de 100644 --- a/c/src/exec/libnetworking/net/if_pppvar.h +++ b/c/src/exec/libnetworking/net/if_pppvar.h @@ -105,6 +105,7 @@ struct ppp_softc { short sc_outfcslen; /* length of output fcs data */ u_char sc_outfcsbuf[8]; /* output packet fcs buffer */ u_char *sc_outbuf; /* pointer to output data */ + u_char sc_outchar; rtems_id sc_rxtask; rtems_id sc_txtask; diff --git a/c/src/exec/libnetworking/net/ppp_tty.c b/c/src/exec/libnetworking/net/ppp_tty.c index b655fd4f04..060bd3976c 100644 --- a/c/src/exec/libnetworking/net/ppp_tty.c +++ b/c/src/exec/libnetworking/net/ppp_tty.c @@ -562,10 +562,8 @@ pppasyncctlp(sc) int pppstart(struct rtems_termios_tty *tp) { - char c; char *sendBegin; - char cFrame = (char )PPP_FLAG; - u_char ioffset = (u_char )0; + u_long ioffset = (u_long )0; struct mbuf *m = (struct mbuf *)0; struct ppp_softc *sc = tp->t_sc; @@ -596,7 +594,8 @@ pppstart(struct rtems_termios_tty *tp) else { /* done with this packet */ sc->sc_outflag &= ~SC_TX_BUSY; - (*tp->device.write)(tp->minor, &cFrame, 1); + sc->sc_outchar = (u_char)PPP_FLAG; + (*tp->device.write)(tp->minor, &sc->sc_outchar, 1); rtems_event_send(sc->sc_txtask, TX_TRANSMIT); } } @@ -604,11 +603,11 @@ pppstart(struct rtems_termios_tty *tp) /* check to see if there is some data to write out */ if ( sc->sc_outoff < sc->sc_outlen ) { /* check to see if character needs to be escaped */ - c = sc->sc_outbuf[sc->sc_outoff]; - if ( ESCAPE_P(c) ) { + sc->sc_outchar = sc->sc_outbuf[sc->sc_outoff]; + if ( ESCAPE_P(sc->sc_outchar) ) { if ( sc->sc_outflag & SC_TX_ESCAPE ) { /* last sent character was the escape character */ - c = c ^ PPP_TRANS; + sc->sc_outchar = sc->sc_outchar ^ PPP_TRANS; /* clear the escape flag and increment the offset */ sc->sc_outflag &= ~SC_TX_ESCAPE; @@ -616,18 +615,18 @@ pppstart(struct rtems_termios_tty *tp) } else { /* need to send the escape character */ - c = PPP_ESCAPE; + sc->sc_outchar = PPP_ESCAPE; /* set the escape flag */ sc->sc_outflag |= SC_TX_ESCAPE; } - sendBegin = &c; + sendBegin = &sc->sc_outchar; } else { /* escape not needed - increment the offset as much as possible */ - while ((!ESCAPE_P(c)) && ((sc->sc_outoff + ioffset) < sc->sc_outlen)) { + while ((!ESCAPE_P(sc->sc_outchar)) && ((sc->sc_outoff + ioffset) < sc->sc_outlen)) { ioffset++; - c = sc->sc_outbuf[sc->sc_outoff + ioffset]; + sc->sc_outchar = sc->sc_outbuf[sc->sc_outoff + ioffset]; } sendBegin = &sc->sc_outbuf[sc->sc_outoff]; } -- cgit v1.2.3