Index: c/src/exec/libnetworking/ChangeLog
===================================================================
--- c/src/exec/libnetworking/ChangeLog	(revision 90f30c8c145117851c10bda31235fac1b4fdd8a7)
+++ c/src/exec/libnetworking/ChangeLog	(revision f4c118d7a32370516b0871920b36002895f14f1d)
@@ -1,2 +1,15 @@
+2002-03-27      Ilya Alexeev <ilya@continuum.ru>
+
+	* 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 <ilya@continuum.ru>
 
Index: c/src/exec/libnetworking/net/if_ppp.c
===================================================================
--- c/src/exec/libnetworking/net/if_ppp.c	(revision 90f30c8c145117851c10bda31235fac1b4fdd8a7)
+++ c/src/exec/libnetworking/net/if_ppp.c	(revision f4c118d7a32370516b0871920b36002895f14f1d)
@@ -244,5 +244,4 @@
 {
   rtems_event_set             events;
-  char                        cFrame   = (char              )PPP_FLAG;
   int                         iprocess = (int               )0;
   struct ppp_softc           *sc       = (struct ppp_softc *)arg;
@@ -352,5 +351,6 @@
   
         /* 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);
       }
 
Index: c/src/exec/libnetworking/net/if_pppvar.h
===================================================================
--- c/src/exec/libnetworking/net/if_pppvar.h	(revision 90f30c8c145117851c10bda31235fac1b4fdd8a7)
+++ c/src/exec/libnetworking/net/if_pppvar.h	(revision f4c118d7a32370516b0871920b36002895f14f1d)
@@ -106,4 +106,5 @@
 	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;
Index: c/src/exec/libnetworking/net/ppp_tty.c
===================================================================
--- c/src/exec/libnetworking/net/ppp_tty.c	(revision 90f30c8c145117851c10bda31235fac1b4fdd8a7)
+++ c/src/exec/libnetworking/net/ppp_tty.c	(revision f4c118d7a32370516b0871920b36002895f14f1d)
@@ -563,8 +563,6 @@
 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;
@@ -597,5 +595,6 @@
         /* 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);
       }
@@ -605,9 +604,9 @@
     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 */
@@ -617,16 +616,16 @@
         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];
Index: c/src/libnetworking/ChangeLog
===================================================================
--- c/src/libnetworking/ChangeLog	(revision 90f30c8c145117851c10bda31235fac1b4fdd8a7)
+++ c/src/libnetworking/ChangeLog	(revision f4c118d7a32370516b0871920b36002895f14f1d)
@@ -1,2 +1,15 @@
+2002-03-27      Ilya Alexeev <ilya@continuum.ru>
+
+	* 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 <ilya@continuum.ru>
 
Index: c/src/libnetworking/net/if_ppp.c
===================================================================
--- c/src/libnetworking/net/if_ppp.c	(revision 90f30c8c145117851c10bda31235fac1b4fdd8a7)
+++ c/src/libnetworking/net/if_ppp.c	(revision f4c118d7a32370516b0871920b36002895f14f1d)
@@ -244,5 +244,4 @@
 {
   rtems_event_set             events;
-  char                        cFrame   = (char              )PPP_FLAG;
   int                         iprocess = (int               )0;
   struct ppp_softc           *sc       = (struct ppp_softc *)arg;
@@ -352,5 +351,6 @@
   
         /* 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);
       }
 
Index: c/src/libnetworking/net/if_pppvar.h
===================================================================
--- c/src/libnetworking/net/if_pppvar.h	(revision 90f30c8c145117851c10bda31235fac1b4fdd8a7)
+++ c/src/libnetworking/net/if_pppvar.h	(revision f4c118d7a32370516b0871920b36002895f14f1d)
@@ -106,4 +106,5 @@
 	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;
Index: c/src/libnetworking/net/ppp_tty.c
===================================================================
--- c/src/libnetworking/net/ppp_tty.c	(revision 90f30c8c145117851c10bda31235fac1b4fdd8a7)
+++ c/src/libnetworking/net/ppp_tty.c	(revision f4c118d7a32370516b0871920b36002895f14f1d)
@@ -563,8 +563,6 @@
 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;
@@ -597,5 +595,6 @@
         /* 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);
       }
@@ -605,9 +604,9 @@
     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 */
@@ -617,16 +616,16 @@
         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];
Index: cpukit/libnetworking/ChangeLog
===================================================================
--- cpukit/libnetworking/ChangeLog	(revision 90f30c8c145117851c10bda31235fac1b4fdd8a7)
+++ cpukit/libnetworking/ChangeLog	(revision f4c118d7a32370516b0871920b36002895f14f1d)
@@ -1,2 +1,15 @@
+2002-03-27      Ilya Alexeev <ilya@continuum.ru>
+
+	* 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 <ilya@continuum.ru>
 
Index: cpukit/libnetworking/net/if_ppp.c
===================================================================
--- cpukit/libnetworking/net/if_ppp.c	(revision 90f30c8c145117851c10bda31235fac1b4fdd8a7)
+++ cpukit/libnetworking/net/if_ppp.c	(revision f4c118d7a32370516b0871920b36002895f14f1d)
@@ -244,5 +244,4 @@
 {
   rtems_event_set             events;
-  char                        cFrame   = (char              )PPP_FLAG;
   int                         iprocess = (int               )0;
   struct ppp_softc           *sc       = (struct ppp_softc *)arg;
@@ -352,5 +351,6 @@
   
         /* 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);
       }
 
Index: cpukit/libnetworking/net/if_pppvar.h
===================================================================
--- cpukit/libnetworking/net/if_pppvar.h	(revision 90f30c8c145117851c10bda31235fac1b4fdd8a7)
+++ cpukit/libnetworking/net/if_pppvar.h	(revision f4c118d7a32370516b0871920b36002895f14f1d)
@@ -106,4 +106,5 @@
 	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;
Index: cpukit/libnetworking/net/ppp_tty.c
===================================================================
--- cpukit/libnetworking/net/ppp_tty.c	(revision 90f30c8c145117851c10bda31235fac1b4fdd8a7)
+++ cpukit/libnetworking/net/ppp_tty.c	(revision f4c118d7a32370516b0871920b36002895f14f1d)
@@ -563,8 +563,6 @@
 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;
@@ -597,5 +595,6 @@
         /* 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);
       }
@@ -605,9 +604,9 @@
     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 */
@@ -617,16 +616,16 @@
         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];
