diff -uN ppp-2.4.1b2.WORKING/pppd/framepipe.c /usr/src/ppp-2.4.1b2/pppd/framepipe.c --- ppp-2.4.1b2.WORKING/pppd/framepipe.c 1970-01-01 01:00:00.000000000 +0100 +++ /usr/src/ppp-2.4.1b2/pppd/framepipe.c 2007-04-22 13:22:11.000000000 +0200 @@ -0,0 +1,66 @@ +#include "framepipe.h" + +#include +#include +#include +#include + +int framepipe_read(const int fd, void **buff) { + int n; + int len; + int pos; + char *p = *buff; + + pos = 0; + do { + n = read(fd, &((char *)&len)[pos], sizeof(len)-pos); + + if (n < 0) + return n; + + + pos += n; + } while (pos 0) + while ((n = read_packet(inpacket_buf)) > 0) { if (loop_frame(inpacket_buf, n)) rv = 1; + } return rv; } - while ((n = read(master_fd, inbuf, sizeof(inbuf))) > 0) + while ((n = read(master_fd, inbuf, sizeof(inbuf))) > 0) { if (loop_chars(inbuf, n)) rv = 1; + } if (n == 0) fatal("eof on loopback"); diff -uN ppp-2.4.1b2.WORKING/pppd/tty.c /usr/src/ppp-2.4.1b2/pppd/tty.c --- ppp-2.4.1b2.WORKING/pppd/tty.c 2004-07-28 22:52:49.000000000 +0200 +++ /usr/src/ppp-2.4.1b2/pppd/tty.c 2007-04-23 12:54:48.000000000 +0200 @@ -49,6 +49,9 @@ #include "fsm.h" #include "lcp.h" + +#include "framepipe.h" + void tty_process_extra_options __P((void)); void tty_check_options __P((void)); int connect_tty __P((void)); @@ -877,6 +880,11 @@ * This runs as the user (not as root). * (We assume ofd >= ifd which is true the way this gets called. :-). */ + +#ifdef FRAMEPIPEDEBUG +static unsigned long glob_rd_cnt=0, glob_wr_cnt=0, glob_pty_rd_cnt=0; +#endif + static void charshunt(ifd, ofd, record_file) int ifd, ofd; @@ -886,7 +894,6 @@ fd_set ready, writey; u_char *ibufp, *obufp; int nibuf, nobuf; - int flags; int pty_readable, stdin_readable; struct timeval lasttime; FILE *recordf = NULL; @@ -894,6 +901,8 @@ struct timeval levelt, tout, *top; extern u_char inpacket_buf[]; + char *readp=NULL; + /* * Reset signal handlers. */ @@ -947,6 +956,7 @@ error("Couldn't create record file %s: %m", record_file); } +#if 0 /* set all the fds to non-blocking mode */ flags = fcntl(pty_master, F_GETFL); if (flags == -1 @@ -962,6 +972,7 @@ || fcntl(ofd, F_SETFL, flags | O_NONBLOCK) == -1) warn("couldn't set stdout to nonblock: %m"); } +#endif nibuf = nobuf = 0; ibufp = obufp = NULL; @@ -1028,7 +1039,24 @@ ilevel = olevel = 0; if (FD_ISSET(ifd, &ready)) { ibufp = inpacket_buf; - nibuf = read(ifd, ibufp, PPP_MRU + PPP_HDRLEN); + //nibuf = read(ifd, ibufp, PPP_MRU + PPP_HDRLEN); + nibuf=framepipe_read(ifd, (void**)&readp); + + if (nibuf>0) + memcpy(ibufp,readp, nibuf); + +#ifdef DEBUGFRAMPIPE + int i; + FILE *fp=fopen("/tmp/ppp.log","a+"); + fprintf(fp, "read (%d) l(%x):",glob_rd_cnt, nibuf); + for (i=0; i max_level) n = max_level - olevel; - n = write(ofd, obufp, n); + //n = write(ofd, obufp, n); + n=framepipe_write(ofd, obufp, n); + +#ifdef DEBUGFRAMPIPE + if (n>0) { + int i; + FILE *fp=fopen("/tmp/ppp.log","a+"); + fprintf(fp, "write (%d) l(%x):",glob_wr_cnt, n); + for (i=0; i