Patch dp-3.1.2 => dp-3.1.2a

This patch fixes some problems with VJ compression and adds support
for MAGMA serial ports.  See the updated README file for details.

To apply this patch, cd to the parent directory of your dp-3.1.2
distribution and execute 'patch <"this file"'

---------------------------------- cut here -----------------------
diff -rc dp-3.1.2/Makefile.hw dp-3.1.2a/Makefile.hw
*** dp-3.1.2/Makefile.hw	Wed Apr 27 22:48:19 1994
--- dp-3.1.2a/Makefile.hw	Thu Nov  3 18:56:38 1994
***************
*** 5,8 ****
  #		at 57.6 Kb, 115.2 Kb, or 230.4 Kb
  # -DFASTZS	Allows Sun ZS internal ports to be operated at 76,800 baud
  #
! HWSUPPORT=-DFASTZS
--- 5,11 ----
  #		at 57.6 Kb, 115.2 Kb, or 230.4 Kb
  # -DFASTZS	Allows Sun ZS internal ports to be operated at 76,800 baud
  #
! # -DMAGMA	Allows MAGMA S-BUS cards to be operated at 56Kb, 57.6Kb,
! #		64Kb, 76.8Kb and 115.2Kb.
! HWSUPPORT=-DMAGMA
! 
diff -rc dp-3.1.2/README dp-3.1.2a/README
*** dp-3.1.2/README	Tue Mar 15 18:51:13 1994
--- dp-3.1.2a/README	Fri Nov  4 11:01:52 1994
***************
*** 1,3 ****
--- 1,29 ----
+ 03 November 1994
+ 
+ This is dp-3.1.2a
+ 
+ Things fixed since dp-3.1.2:
+ 
+ Van Jacobson compression should now be negotiated as per rfc1332.
+ Previous versions did not correctly pass the negotiated number of
+ slots or the slot-id compression flag to the vjc streams module.  The
+ default IPCP VJ-compression option is now rfc1332 style (protocol
+ 002d, length 6 bytes, slots & compression flag negotiable).  Older
+ styles are available as options to the ppp process:
+ vjmode rfc1172    - protocol 0037, 16 slots non-negotiable
+ vjmode pre1332    - protocol 002d, 16 slots non-negotiable
+ 
+ Fixed some bugs in the vjc module which could cause a panic
+ (tcp_close_detached - no mblk) when VJ was in use.
+ 
+ Added support for MAGMA Sbus serial cards.
+ 
+ 
+ 				Frank Cringle
+ 				fdc@cliwe.ping.de
+ 
+ 
+ 
  15 March 1994
  
  This is dp-3.1.1
diff -rc dp-3.1.2/doc/DialupPPP dp-3.1.2a/doc/DialupPPP
*** dp-3.1.2/doc/DialupPPP	Wed Jan 12 21:40:30 1994
--- dp-3.1.2a/doc/DialupPPP	Thu Nov  3 19:14:51 1994
***************
*** 836,842 ****
  patch level of PPP. So, in the 2.3 configuration file, you can put
  the line:
  
! 	PPP_ARGS=vjmode,old
  
  This will talk to a patchlevel 4 PPP correctly and the option negotiation
  will function properly.
--- 836,842 ----
  patch level of PPP. So, in the 2.3 configuration file, you can put
  the line:
  
! 	PPP_ARGS=vjmode,rfc1172
  
  This will talk to a patchlevel 4 PPP correctly and the option negotiation
  will function properly.
diff -rc dp-3.1.2/dpd/makecall.c dp-3.1.2a/dpd/makecall.c
*** dp-3.1.2/dpd/makecall.c	Wed Jan 19 17:03:30 1994
--- dp-3.1.2a/dpd/makecall.c	Thu Nov  3 18:57:37 1994
***************
*** 611,616 ****
--- 611,623 ----
  #ifdef	FASTZS
       case 76800:    		return B50;
  #endif	FASTZS
+ #ifdef	MAGMA
+      case 56000:		return B50;
+      case 57600:		return B75;
+      case 64000:		return B134;
+      case 76800:		return B200;
+      case 115200:		return B1800;
+ #endif	MAGMA
       default:		return -1;
      }
  }
diff -rc dp-3.1.2/dpd/readconfig.c dp-3.1.2a/dpd/readconfig.c
*** dp-3.1.2/dpd/readconfig.c	Fri Feb 25 15:49:29 1994
--- dp-3.1.2a/dpd/readconfig.c	Thu Nov  3 18:58:45 1994
***************
*** 550,555 ****
--- 550,562 ----
  #ifdef	FASTZS
  	 case 76800:
  #endif	FASTZS
+ #ifdef	MAGMA
+ 	 case 56000:
+ 	 case 57600:
+ 	 case 64000:
+ 	 case 76800:
+ 	 case 115200:
+ #endif	MAGMA
  	    break;
  	 default:
  	    yyerror(path, "Bad MODEM speed \"%s\"\n", val);
diff -rc dp-3.1.2/h/vjc.h dp-3.1.2a/h/vjc.h
*** dp-3.1.2/h/vjc.h	Tue Jul 13 15:27:05 1993
--- dp-3.1.2a/h/vjc.h	Thu Nov  3 18:31:15 1994
***************
*** 169,174 ****
--- 169,175 ----
  /* flag values */
  #define VJCF_TOSS	1	/* tossing rcvd frames because of input err */
  #define	VJCF_COMPTCP	2	/* Compressing TCP Headers */
+ #define	VJCF_COMPSLT	4	/* Compressing slot ids */
  
  /*
   * Return values from vjc_pullup_tcp()
diff -rc dp-3.1.2/ppp/ipcp.c dp-3.1.2a/ppp/ipcp.c
*** dp-3.1.2/ppp/ipcp.c	Thu Jun 17 22:01:27 1993
--- dp-3.1.2a/ppp/ipcp.c	Fri Nov  4 08:59:06 1994
***************
*** 40,45 ****
--- 40,46 ----
  #include "ppp.h"
  #include "fsm.h"
  #include "ipcp.h"
+ #include "vjc.h"
  
  /* global vars */
  ipcp_options ipcp_wantoptions[NPPP]; /* Options that we want to request */
***************
*** 56,64 ****
   * VJ compression protocol mode for negotiation. See ipcp.h for a 
   * description of each mode.
   */
! static int vj_mode = IPCP_VJMODE_CURRENT;
  
! static int vj_opt_len = 4;	/* holds length in octets for valid vj */
  				/* compression frame depending on mode */
  
  static int vj_opt_val = IPCP_VJ_COMP;
--- 57,65 ----
   * VJ compression protocol mode for negotiation. See ipcp.h for a 
   * description of each mode.
   */
! static int vj_mode = IPCP_VJMODE_DRAFT;
  
! static int vj_opt_len = 6;	/* holds length in octets for valid vj */
  				/* compression frame depending on mode */
  
  static int vj_opt_val = IPCP_VJ_COMP;
***************
*** 802,808 ****
  	      GETCHAR(maxslotindex, p);
  	      IPCPDEBUG((LOG_INFO, "(maxslot his=%d, ours=%d)", maxslotindex,
  			wo->maxslotindex))
! 	      if (maxslotindex > wo->maxslotindex) { 
  		DECPTR(1, p);
  		orc = CONFNAK;
  	        IPCPDEBUG((LOG_INFO, "ipcp_reqci: naking SLOTINDEX"))
--- 803,810 ----
  	      GETCHAR(maxslotindex, p);
  	      IPCPDEBUG((LOG_INFO, "(maxslot his=%d, ours=%d)", maxslotindex,
  			wo->maxslotindex))
! 	      if (maxslotindex > wo->maxslotindex ||
! 		  maxslotindex < VJC_MIN_STATES) { 
  		DECPTR(1, p);
  		orc = CONFNAK;
  	        IPCPDEBUG((LOG_INFO, "ipcp_reqci: naking SLOTINDEX"))
***************
*** 814,826 ****
  	      GETCHAR(cflag, p);
  	      IPCPDEBUG((LOG_INFO, "(cflag his=%d, ours=%d)", cflag,
  			wo->cflag))
- 	      if (cflag != wo->cflag) {
- 		DECPTR(1, p);
- 		orc = CONFNAK;
- 	        IPCPDEBUG((LOG_INFO, "ipcp_reqci: naking CFLAG"))
- 		PUTCHAR(wo->cflag, p);
- 		break;
- 	      }
  	      ho->cflag = wo->cflag;
  	    }
  	    break;
--- 816,821 ----
***************
*** 888,894 ****
    mask = GetMask(ipcp_gotoptions[f->unit].ouraddr);
    if (mask) 
      SIFMASK(f->unit, mask);
!   SIFVJCOMP(f->unit, ipcp_hisoptions[f->unit].neg_vj);
    SIFSAPENABLE(PPP_IP);
  }
  
--- 883,891 ----
    mask = GetMask(ipcp_gotoptions[f->unit].ouraddr);
    if (mask) 
      SIFMASK(f->unit, mask);
!   SIFVJCOMP(f->unit, ipcp_hisoptions[f->unit].neg_vj ?
! 	    ipcp_hisoptions[f->unit].maxslotindex : 0,
! 	    ipcp_hisoptions[f->unit].cflag);
    SIFSAPENABLE(PPP_IP);
  }
  
diff -rc dp-3.1.2/ppp/main.c dp-3.1.2a/ppp/main.c
*** dp-3.1.2/ppp/main.c	Tue Apr 19 18:01:01 1994
--- dp-3.1.2a/ppp/main.c	Fri Nov  4 12:01:20 1994
***************
*** 270,276 ****
  };
  
  
! char *usage = "PPP patch level %d\n\
  Usage: %s [ arguments ], where arguments are:\n\
  	-all		Don't request/allow any options\n\
  	-ac		Disable Address/Control compression\n\
--- 270,276 ----
  };
  
  
! char *usage = "PPP %s patch level %d\n\
  Usage: %s [ arguments ], where arguments are:\n\
  	-all		Don't request/allow any options\n\
  	-ac		Disable Address/Control compression\n\
***************
*** 291,297 ****
  	-ua		Don't allow UPAP authentication\n\
  	+chap		Require CHAP authentication\n\
  	-chap		Don't allow CHAP authentication\n\
! 	vjmode <m>      VJ compression mode {old, current (default), draft}\n\
          -vj             disable VJ compression\n\
          connect <p>     Invoke shell command <p> to set up the serial line\n\
          domain <d>      Append domain name <d> to hostname for authentication\n\
--- 291,297 ----
  	-ua		Don't allow UPAP authentication\n\
  	+chap		Require CHAP authentication\n\
  	-chap		Don't allow CHAP authentication\n\
! 	vjmode <m>      VJ compression mode {rfc1172, pre1332, rfc1332}\n\
          -vj             disable VJ compression\n\
          connect <p>     Invoke shell command <p> to set up the serial line\n\
          domain <d>      Append domain name <d> to hostname for authentication\n\
***************
*** 1154,1160 ****
  	*/
  	if (protocol != LCP && lcp_fsm[0].state != OPEN) {
  	    MAINDEBUG((LOG_INFO,
! 		"io(): Received non-LCP packet and LCP is not in open state."))
  	    free(pstart);
  	    return;
  	}
--- 1154,1160 ----
  	*/
  	if (protocol != LCP && lcp_fsm[0].state != OPEN) {
  	    MAINDEBUG((LOG_INFO,
! 		"io(): Received non-LCP packet(%04x) and LCP is not in open state.", protocol))
  	    free(pstart);
  	    return;
  	}
***************
*** 1628,1647 ****
    
    --*argcp, ++*argvp;
    
!   if (!strcmp(**argvp, "old")) {	/* "old" mode */
      ipcp_vj_setmode(IPCP_VJMODE_OLD);
    }
    
!   else if (!strcmp(**argvp, "current")) {	/* "current" mode (default)*/
      ipcp_vj_setmode(IPCP_VJMODE_CURRENT);
    }
    
!   else if (!strcmp(**argvp, "draft")) {	/* "draft" mode */
      ipcp_vj_setmode(IPCP_VJMODE_DRAFT);
    }
    else {
!     MAINDEBUG((LOG_WARNING, "Unknown vj compression mode %s. Defaulting to current.", **argvp))
!     ipcp_vj_setmode(IPCP_VJMODE_CURRENT);
    }
    --*argcp, ++*argvp;
    
--- 1628,1650 ----
    
    --*argcp, ++*argvp;
    
!   if (!strcmp(**argvp, "rfc1172") ||
!       !strcmp(**argvp, "old")) {		/* "old" mode */
      ipcp_vj_setmode(IPCP_VJMODE_OLD);
    }
    
!   else if (!strcmp(**argvp, "pre1332") ||
! 	   !strcmp(**argvp, "current")) {	/* "current" mode */
      ipcp_vj_setmode(IPCP_VJMODE_CURRENT);
    }
    
!   else if (!strcmp(**argvp, "rfc1332") ||
! 	   !strcmp(**argvp, "draft")) {		/* "draft" mode (default) */
      ipcp_vj_setmode(IPCP_VJMODE_DRAFT);
    }
    else {
!     MAINDEBUG((LOG_WARNING, "Unknown vj compression mode %s. Defaulting to rfc1332.", **argvp))
!     ipcp_vj_setmode(IPCP_VJMODE_DRAFT);
    }
    --*argcp, ++*argvp;
    
***************
*** 1648,1654 ****
    return (1);
  }
  /*
!  *	setnovj - diable vj compression
   */
  
  static int
--- 1651,1657 ----
    return (1);
  }
  /*
!  *	setnovj - disable vj compression
   */
  
  static int
diff -rc dp-3.1.2/ppp/patchlevel.h dp-3.1.2a/ppp/patchlevel.h
*** dp-3.1.2/ppp/patchlevel.h	Tue Apr 26 18:14:46 1994
--- dp-3.1.2a/ppp/patchlevel.h	Thu Nov  3 19:02:47 1994
***************
*** 1,4 ****
  #define	PATCHLEVEL	0
  
! #define VERSION		"dp-3.1.2"
! #define DATE		"26 March 1994"
--- 1,4 ----
  #define	PATCHLEVEL	0
  
! #define VERSION		"dp-3.1.2a"
! #define DATE		"03 November 1994"
diff -rc dp-3.1.2/ppp/ppp.h dp-3.1.2a/ppp/ppp.h
*** dp-3.1.2/ppp/ppp.h	Mon Sep 20 15:52:11 1993
--- dp-3.1.2a/ppp/ppp.h	Fri Nov  4 12:06:05 1994
***************
*** 230,244 ****
      } }
  
  /*
!  * SIFVJCOMP - Config the interface for Van Jacobsen TCP header compression
   */
! #define	SIFVJCOMP(u, a) 	{ \
!     char x = a;			\
! 	if (debug) syslog(LOG_DEBUG, "SIFVJCOMP unit %d to value %d\n",u,x); \
  	if(strioctl(dpfd, DPIOCSVJCOMP, -1, sizeof(x), (caddr_t) &x) < 0) { \
! 		syslog(LOG_ERR, "ioctl(DPIOCSVJCOMP): %m"); \
! 		quit(); \
! 	} \
  }
  #define	SIFASYNCMAP(u, a, err)	{ \
       u_long x = a; \
--- 230,246 ----
      } }
  
  /*
!  * SIFVJCOMP - Config the interface for Van Jacobson TCP header compression
   */
! #define	SIFVJCOMP(u, ms, cs) 	{					\
! 	u_char x[2];							\
! 	x[0] = ms;							\
! 	x[1] = cs;							\
! 	if (debug) syslog(LOG_DEBUG, "SIFVJCOMP unit %d to value %d.%d\n",u,ms,cs); \
  	if(strioctl(dpfd, DPIOCSVJCOMP, -1, sizeof(x), (caddr_t) &x) < 0) { \
! 		syslog(LOG_ERR, "ioctl(DPIOCSVJCOMP): %m");		\
! 		quit();							\
! 	}								\
  }
  #define	SIFASYNCMAP(u, a, err)	{ \
       u_long x = a; \
diff -rc dp-3.1.2/script/zyxel-dial dp-3.1.2a/script/zyxel-dial
*** dp-3.1.2/script/zyxel-dial	Wed Jan 12 14:48:26 1994
--- dp-3.1.2a/script/zyxel-dial	Thu Nov  3 19:10:54 1994
***************
*** 24,30 ****
  mark
  {
      alternate
! 	recv "CONNECT 2400" "CONNECT 1200" "CONNECT" "BUSY" "NO CARRIER" "NO DIALTONE" "ERROR" 55
      alternate
  	log "Modem Timeout"
  	abort
--- 24,30 ----
  mark
  {
      alternate
! 	recv "CONNECT" "BUSY" "NO CARRIER" "NO DIALTONE" "NO ANSWER" "ERROR" 55
      alternate
  	log "Modem Timeout"
  	abort
***************
*** 32,45 ****
  {
      alternate
  	replay
- 	recv "CONNECT 1200" 0
- 	go
-     alternate
- 	replay
- 	recv "CONNECT 2400" 0
- 	go
-     alternate
- 	replay
  	recv "CONNECT" 0
  	go
      alternate
--- 32,37 ----
***************
*** 55,60 ****
--- 47,56 ----
  	replay
  	recv "NO DIALTONE" 0
  	log "No dialtone"
+     alternate
+ 	replay
+ 	recv "NO ANSWER" 0
+ 	log "No answer"
      alternate
  	replay
  	recv "ERROR" 0
diff -rc dp-3.1.2/sys/dp.c dp-3.1.2a/sys/dp.c
*** dp-3.1.2/sys/dp.c	Wed Apr 27 20:39:54 1994
--- dp-3.1.2a/sys/dp.c	Thu Nov  3 16:59:34 1994
***************
*** 61,79 ****
  int dp_debug_dump_msg = 0;	/* Print out messages */
  int dp_debug_lists = 0;		/* Debug linked lists */
  #ifdef	SOLARIS1
! #define	DLOG(s)		   if (dp_debug) log(LOG_INFO, (s))
! #define	DLOG1(s,a)	   if (dp_debug) log(LOG_INFO, (s),(a))
! #define	DLOG2(s,a,b)	   if (dp_debug) log(LOG_INFO, (s),(a),(b))
! #define	DLOG3(s,a,b,c)	   if (dp_debug) log(LOG_INFO, (s),(a),(b),(c))
! #define	DLOG4(s,a,b,c,d)   if (dp_debug) log(LOG_INFO, (s),(a),(b),(c),(d))
! #define	DLOG5(s,a,b,c,d,e) if (dp_debug) log(LOG_INFO, (s),(a),(b),(c),(d),(e))
  #else
! #define	DLOG(s)		   if (dp_debug) cmn_err(CE_CONT, (s))
! #define	DLOG1(s,a)	   if (dp_debug) cmn_err(CE_CONT, (s),(a))
! #define	DLOG2(s,a,b)	   if (dp_debug) cmn_err(CE_CONT, (s),(a),(b))
! #define	DLOG3(s,a,b,c)	   if (dp_debug) cmn_err(CE_CONT, (s),(a),(b),(c))
! #define	DLOG4(s,a,b,c,d)   if (dp_debug) cmn_err(CE_CONT, (s),(a),(b),(c),(d))
! #define	DLOG5(s,a,b,c,d,e) if (dp_debug) cmn_err(CE_CONT, (s),(a),(b),(c),(d),(e))
  #endif
  static char *dps_str[] = {
      "ACTIVE",
--- 61,79 ----
  int dp_debug_dump_msg = 0;	/* Print out messages */
  int dp_debug_lists = 0;		/* Debug linked lists */
  #ifdef	SOLARIS1
! #define	DLOG(s)		   do { if (dp_debug) log(LOG_INFO, (s)); } while (0)
! #define	DLOG1(s,a)	   do { if (dp_debug) log(LOG_INFO, (s),(a)); } while (0)
! #define	DLOG2(s,a,b)	   do { if (dp_debug) log(LOG_INFO, (s),(a),(b)); } while (0)
! #define	DLOG3(s,a,b,c)	   do { if (dp_debug) log(LOG_INFO, (s),(a),(b),(c)); } while (0)
! #define	DLOG4(s,a,b,c,d)   do { if (dp_debug) log(LOG_INFO, (s),(a),(b),(c),(d)); } while (0)
! #define	DLOG5(s,a,b,c,d,e) do { if (dp_debug) log(LOG_INFO, (s),(a),(b),(c),(d),(e)); } while (0)
  #else
! #define	DLOG(s)		   do { if (dp_debug) cmn_err(CE_CONT, (s)); } while (0)
! #define	DLOG1(s,a)	   do { if (dp_debug) cmn_err(CE_CONT, (s),(a)); } while (0)
! #define	DLOG2(s,a,b)	   do { if (dp_debug) cmn_err(CE_CONT, (s),(a),(b)); } while (0)
! #define	DLOG3(s,a,b,c)	   do { if (dp_debug) cmn_err(CE_CONT, (s),(a),(b),(c)); } while (0)
! #define	DLOG4(s,a,b,c,d)   do { if (dp_debug) cmn_err(CE_CONT, (s),(a),(b),(c),(d)); } while (0)
! #define	DLOG5(s,a,b,c,d,e) do { if (dp_debug) cmn_err(CE_CONT, (s),(a),(b),(c),(d),(e)); } while (0)
  #endif
  static char *dps_str[] = {
      "ACTIVE",
***************
*** 247,253 ****
  
  static struct modldrv dpldrv = {
      &mod_driverops,
!     "Dialup PPP DLPI Driver v3.1.2",
      &dp_ops
  };
  
--- 247,253 ----
  
  static struct modldrv dpldrv = {
      &mod_driverops,
!     "Dialup PPP DLPI Driver v3.1.2a",
      &dp_ops
  };
  
diff -rc dp-3.1.2/sys/pppasync.c dp-3.1.2a/sys/pppasync.c
*** dp-3.1.2/sys/pppasync.c	Wed Apr 27 20:40:15 1994
--- dp-3.1.2a/sys/pppasync.c	Thu Nov  3 16:58:22 1994
***************
*** 50,62 ****
  #include <sys/syslog.h>
  #define	static	
  #ifdef	SOLARIS1
! #define	DLOG(s)		if (ppp_async_debug) log(LOG_INFO, (s))
! #define	DLOG1(s, a)	if (ppp_async_debug) log(LOG_INFO, (s), (a))
! #define	DLOG2(s, a, b)	if (ppp_async_debug) log(LOG_INFO, (s), (a), (b))
  #else
! #define	DLOG(s)		if (ppp_async_debug) cmn_err(CE_CONT, (s))
! #define	DLOG1(s, a)	if (ppp_async_debug) cmn_err(CE_CONT, (s), (a))
! #define	DLOG2(s, a, b)	if (ppp_async_debug) cmn_err(CE_CONT, (s), (a), (b))
  #endif
  
  int	ppp_async_debug=0;
--- 50,62 ----
  #include <sys/syslog.h>
  #define	static	
  #ifdef	SOLARIS1
! #define	DLOG(s)		do { if (ppp_async_debug) log(LOG_INFO, (s)); } while (0)
! #define	DLOG1(s, a)	do { if (ppp_async_debug) log(LOG_INFO, (s), (a)); } while (0)
! #define	DLOG2(s, a, b)	do { if (ppp_async_debug) log(LOG_INFO, (s), (a), (b)); } while (0)
  #else
! #define	DLOG(s)		do { if (ppp_async_debug) cmn_err(CE_CONT, (s)); } while (0)
! #define	DLOG1(s, a)	do { if (ppp_async_debug) cmn_err(CE_CONT, (s), (a)); } while (0)
! #define	DLOG2(s, a, b)	do { if (ppp_async_debug) cmn_err(CE_CONT, (s), (a), (b)); } while (0)
  #endif
  
  int	ppp_async_debug=0;
***************
*** 63,71 ****
  int	ppp_async_input_debug=0;
  #define MAX_DUMP_BYTES 1504
  #else
! #define	DLOG(s)		{}
! #define	DLOG1(s, a)	{}
! #define	DLOG2(s, a, b)	{}
  #endif
  
  #ifdef	SOLARIS1
--- 63,71 ----
  int	ppp_async_input_debug=0;
  #define MAX_DUMP_BYTES 1504
  #else
! #define	DLOG(s)
! #define	DLOG1(s, a)
! #define	DLOG2(s, a, b)
  #endif
  
  #ifdef	SOLARIS1
***************
*** 197,203 ****
  #endif
  {
      register pai_t	*p;
-     register int x;
      int	s;
  
      DLOG("ppp_async_open\n");
--- 197,202 ----
***************
*** 476,481 ****
--- 475,481 ----
      register mblk_t	*mp;
      u_char		*start, *stop,c;
      mblk_t		*m1, *m0, *outgoing;
+     u_long		lval;
  
      while ((mp = getq(q)) != NULL) {
  	/*
***************
*** 596,603 ****
  	 * that we don't need a leading PPP_FLAG because these packets
  	 * will be sent back to back
  	 */
! 	if (!qsize(q->q_next)) {
  	    /* no entries in next queue, have to add a leading PPP_FLAG */
  	    m1 = allocb(sizeof(u_char), BPRI_LO);
  	    if (!m1)
  		goto nobuffs;
--- 596,607 ----
  	 * that we don't need a leading PPP_FLAG because these packets
  	 * will be sent back to back
  	 */
! 	freezestr(q);
! 	if (strqget(q->q_next, QCOUNT, 0, &lval) == 0 && lval > 0)
! 	    unfreezestr(q);
! 	else {
  	    /* no entries in next queue, have to add a leading PPP_FLAG */
+ 	    unfreezestr(q);
  	    m1 = allocb(sizeof(u_char), BPRI_LO);
  	    if (!m1)
  		goto nobuffs;
***************
*** 836,841 ****
--- 840,846 ----
  			    p->pai_buffcount > PPP_HDR_SIZE + sizeof(u_short)) {
  			    adjmsg(p->pai_buffer, -sizeof(u_short));
  			    putnext(q, p->pai_buffer);
+ 			    /* should really test canputnext() here */
  			}
  			else {
  			    INPUT_ERROR(q);
***************
*** 846,855 ****
  			    goto hdr_alloc;
  			p->pai_buffer = NULL;
  			p->pai_buffcount = 0;
  			break;
  		    }
  	    }
! 	    if (!mleft)
  		goto data_alloc;
  	    /*
  	     * Done with this message block. Go on to the next one.
--- 851,861 ----
  			    goto hdr_alloc;
  			p->pai_buffer = NULL;
  			p->pai_buffcount = 0;
+ 			mleft = 0;
  			break;
  		    }
  	    }
! 	    if (cp < mp->b_wptr)
  		goto data_alloc;
  	    /*
  	     * Done with this message block. Go on to the next one.
***************
*** 925,939 ****
      cmn_err(CE_CONT,"ppp_async: %s\n", buf); 
  #endif
  }
- 
- nmsgb(mp)
- mblk_t	*mp;
- {
-     int n;
-     for (n = 0 ; mp ; mp = mp->b_cont)
- 	n++;
-     return n;
- }
  #endif /*DEBUGS*/
  
  #ifdef	SOLARIS1
--- 931,936 ----
***************
*** 1004,1010 ****
  
  static struct modlstrmod pppasynclstrmod = {
      &mod_strmodops,
!     "PPP Async Module v3.1.2",
      &pppasyncfsw
  };
  
--- 1001,1007 ----
  
  static struct modlstrmod pppasynclstrmod = {
      &mod_strmodops,
!     "PPP Async Module v3.1.2a",
      &pppasyncfsw
  };
  
diff -rc dp-3.1.2/sys/vjc.c dp-3.1.2a/sys/vjc.c
*** dp-3.1.2/sys/vjc.c	Wed Apr 27 20:40:03 1994
--- dp-3.1.2a/sys/vjc.c	Fri Nov  4 09:04:10 1994
***************
*** 74,93 ****
  #include <sys/syslog.h>
  #define	static	
  #ifdef	SOLARIS1
! #define	DLOG(s)		if(vjc_debug) log(LOG_INFO, (s))
! #define	DLOG1(s, a)	if(vjc_debug) log(LOG_INFO, (s), (a))
! #define	DLOG2(s, a, b)	if(vjc_debug) log(LOG_INFO, (s), (a), (b))
  #else
! #define	DLOG(s)		if(vjc_debug) cmn_err(CE_CONT, (s))
! #define	DLOG1(s, a)	if(vjc_debug) cmn_err(CE_CONT, (s), (a))
! #define	DLOG2(s, a, b)	if(vjc_debug) cmn_err(CE_CONT, (s), (a), (b))
  #endif
  
  int	vjc_debug = 0;
  #else
! #define	DLOG(s)		{}
! #define	DLOG1(s, a)	{}
! #define	DLOG2(s, a, b)	{}
  #endif
  
  #ifndef VJC_NO_STATS
--- 74,93 ----
  #include <sys/syslog.h>
  #define	static	
  #ifdef	SOLARIS1
! #define	DLOG(s)		do { if(vjc_debug) log(LOG_INFO, (s)); } while (0)
! #define	DLOG1(s, a)	do { if(vjc_debug) log(LOG_INFO, (s), (a)); } while (0)
! #define	DLOG2(s, a, b)	do { if(vjc_debug) log(LOG_INFO, (s), (a), (b)); } while (0)
  #else
! #define	DLOG(s)		do { if(vjc_debug) cmn_err(CE_CONT, (s)); } while (0)
! #define	DLOG1(s, a)	do { if(vjc_debug) cmn_err(CE_CONT, (s), (a)); } while (0)
! #define	DLOG2(s, a, b)	do { if(vjc_debug) cmn_err(CE_CONT, (s), (a), (b)); } while (0)
  #endif
  
  int	vjc_debug = 0;
  #else
! #define	DLOG(s)
! #define	DLOG1(s, a)
! #define	DLOG2(s, a, b)
  #endif
  
  #ifndef VJC_NO_STATS
***************
*** 210,217 ****
      rq->q_ptr = WR(rq)->q_ptr = (caddr_t)vjc;
      mutex_init(&vjc->tlock, "vjc module transmit lock",
  	       MUTEX_DRIVER, (void *)0);
!     mutex_init(&vjc->rlock, "vjc module recieve lock",
  	       MUTEX_DRIVER, (void *)0);
      qprocson(rq);
  #ifdef	SOLARIS1
      splx(s);
--- 210,218 ----
      rq->q_ptr = WR(rq)->q_ptr = (caddr_t)vjc;
      mutex_init(&vjc->tlock, "vjc module transmit lock",
  	       MUTEX_DRIVER, (void *)0);
!     mutex_init(&vjc->rlock, "vjc module receive lock",
  	       MUTEX_DRIVER, (void *)0);
+     vjc->flags = VJCF_COMPSLT;
      qprocson(rq);
  #ifdef	SOLARIS1
      splx(s);
***************
*** 248,254 ****
      /*
       * Free associated memory
       */
!     (void)vjc_tcpenable(vjc, 0);
      mutex_destroy(&vjc->rlock);
      mutex_destroy(&vjc->tlock);
      kmem_free((caddr_t)vjc, sizeof(vjc_t));
--- 249,255 ----
      /*
       * Free associated memory
       */
!     (void)vjc_tcpenable(vjc, 0, 0);
      mutex_destroy(&vjc->rlock);
      mutex_destroy(&vjc->tlock);
      kmem_free((caddr_t)vjc, sizeof(vjc_t));
***************
*** 350,357 ****
  	     case VPT_NO_MEM:
  		goto out_of_mem;
  	     case VPT_SUCCESS:
! 		if (proto != PPP_IP &&
! 		    !(pmp = uncompress_tcp(pmp, vjc, mlen))) {
  		    putctl1(q, M_CTL, DP_IF_IERROR);
  		    continue;
  		}
--- 351,357 ----
  	     case VPT_NO_MEM:
  		goto out_of_mem;
  	     case VPT_SUCCESS:
! 		if (!(pmp = uncompress_tcp(pmp, vjc, mlen))) {
  		    putctl1(q, M_CTL, DP_IF_IERROR);
  		    continue;
  		}
***************
*** 433,439 ****
  	 case VPT_SUCCESS:
  	    DLOG1("vjcwsrv: before proto %x\n",
  		 ntohs(((struct ppp_header *)pmp->b_rptr)->ph_protocol));
! 	    pmp = compress_tcp(pmp, vjc, 1);
  	    DLOG1("vjcwsrv: after proto %x\n",
  		 ntohs(((struct ppp_header *)pmp->b_rptr)->ph_protocol));
  	    break;
--- 433,439 ----
  	 case VPT_SUCCESS:
  	    DLOG1("vjcwsrv: before proto %x\n",
  		 ntohs(((struct ppp_header *)pmp->b_rptr)->ph_protocol));
! 	    pmp = compress_tcp(pmp, vjc, (vjc->flags & VJCF_COMPSLT) != 0);
  	    DLOG1("vjcwsrv: after proto %x\n",
  		 ntohs(((struct ppp_header *)pmp->b_rptr)->ph_protocol));
  	    break;
***************
*** 460,468 ****
--- 460,470 ----
      register struct iocblk *ioc;
      register vjc_t *vjc;
      int err = 0;
+     int compslot;
  
      ioc = (struct iocblk *)mp->b_rptr;
      vjc = (vjc_t *)q->q_ptr;
+     compslot = (vjc->flags & VJCF_COMPSLT) != 0;
  
      if (ioc->ioc_count == TRANSPARENT) {
  	/*
***************
*** 480,490 ****
        * enable or disable VJ compression
        */
       case DPIOCSVJCOMP:
! 	if (ioc->ioc_count != sizeof(u_char)) {
  	    err = EINVAL;
! 	    break;
  	}
- 	err = vjc_tcpenable(vjc, *(u_char *)mp->b_cont->b_rptr);
  	break;
  
       default:
--- 482,502 ----
        * enable or disable VJ compression
        */
       case DPIOCSVJCOMP:
! 	switch (ioc->ioc_count) {
! 	case 2:
! 	    if (mp->b_cont->b_rptr[1] > 1) {
! 		err = EINVAL;
! 		goto vjc_ioc_ret;
! 	    }
! 	    compslot = mp->b_cont->b_rptr[1];
! 	    /* fall thru */
! 	case 1:
! 	    err = vjc_tcpenable(vjc, *mp->b_cont->b_rptr, compslot);
! 	    goto vjc_ioc_ret;
! 	default:
  	    err = EINVAL;
! 	    goto vjc_ioc_ret;
  	}
  	break;
  
       default:
***************
*** 497,503 ****
  	mp->b_cont = NULL;
      }
      ioc->ioc_count = 0;
- vjc_ioc_data_ret:
      if (err) {
  	ioc->ioc_error = err;
  	mp->b_datap->db_type = M_IOCNAK;
--- 509,514 ----
***************
*** 509,522 ****
  
  #define	STATE_SIZE(n)	((size_t)((n) * sizeof(cstate_t)))
  
! vjc_tcpenable(vjc, nstates)
  vjc_t *vjc;
  unsigned nstates;
  {
      int ostates;
  #ifdef	SOLARIS1
      int s = splstr();
  #endif
      mutex_enter(&vjc->tlock);
      mutex_enter(&vjc->rlock);
      if  (nstates == 1)
--- 520,536 ----
  
  #define	STATE_SIZE(n)	((size_t)((n) * sizeof(cstate_t)))
  
! vjc_tcpenable(vjc, nstates, compslot)
  vjc_t *vjc;
  unsigned nstates;
+ int compslot;
  {
      int ostates;
  #ifdef	SOLARIS1
      int s = splstr();
  #endif
+     if (nstates < VJC_MIN_STATES || nstates > VJC_MAX_STATES)
+ 	return EINVAL;
      mutex_enter(&vjc->tlock);
      mutex_enter(&vjc->rlock);
      if  (nstates == 1)
***************
*** 539,544 ****
--- 553,560 ----
  		kmem_free((caddr_t)vjc->tstate, STATE_SIZE(nstates));
  	    if (vjc->rstate)
  		kmem_free((caddr_t)vjc->rstate, STATE_SIZE(nstates));
+ 	    mutex_exit(&vjc->rlock);
+ 	    mutex_exit(&vjc->tlock);
  	    return ENOMEM;
  	}
  	vjc->nstates = nstates;
***************
*** 547,553 ****
  	vjc->flags |= VJCF_COMPTCP;
      }
   vjc_tcpenable_done:
!     DLOG1("vjc: %d states\n", vjc->nstates);
      mutex_exit(&vjc->rlock);
      mutex_exit(&vjc->tlock);
  #ifdef	SOLARIS1
--- 563,572 ----
  	vjc->flags |= VJCF_COMPTCP;
      }
   vjc_tcpenable_done:
!     vjc->flags &= ~VJCF_COMPSLT;
!     if (compslot)
! 	vjc->flags |= VJCF_COMPSLT;
!     DLOG2("vjc: %d.%d states\n", vjc->nstates, compslot);
      mutex_exit(&vjc->rlock);
      mutex_exit(&vjc->tlock);
  #ifdef	SOLARIS1
***************
*** 604,610 ****
      struct ppp_header *ph;
      struct ip *ip;
      struct tcphdr *th;
!     mblk_t *imp, *rmp;
      u_short proto;
  
      if (mlen < PPP_HDR_SIZE)
--- 623,629 ----
      struct ppp_header *ph;
      struct ip *ip;
      struct tcphdr *th;
!     mblk_t *imp;
      u_short proto;
  
      if (mlen < PPP_HDR_SIZE)
***************
*** 629,636 ****
       * take a little time to split it up to make further processing simpler.
       */
      if (pmp->b_wptr - pmp->b_rptr > PPP_HDR_SIZE) {
! 	imp = pmp;
! 	pmp = dupb(imp);
  	pmp->b_wptr = pmp->b_rptr + PPP_HDR_SIZE;
  	imp->b_rptr += PPP_HDR_SIZE;
  	pmp->b_cont = imp;
--- 648,655 ----
       * take a little time to split it up to make further processing simpler.
       */
      if (pmp->b_wptr - pmp->b_rptr > PPP_HDR_SIZE) {
! 	imp = dupb(pmp);
! 	imp->b_cont = pmp->b_cont;
  	pmp->b_wptr = pmp->b_rptr + PPP_HDR_SIZE;
  	imp->b_rptr += PPP_HDR_SIZE;
  	pmp->b_cont = imp;
***************
*** 818,823 ****
--- 837,846 ----
  	vjc->last_cs = lcs;
  	hlen += th->th_off;
  	hlen <<= 2;
+ 	if (hlen > (imp->b_wptr - imp->b_rptr)) {
+ 	    mutex_exit(&vjc->tlock);
+ 	    return pmp;
+ 	}
  	goto uncompressed;
  
  found:
***************
*** 848,853 ****
--- 871,880 ----
      deltaS = hlen;
      hlen += th->th_off;
      hlen <<= 2;
+     if (hlen > (imp->b_wptr - imp->b_rptr)) {
+ 	mutex_exit(&vjc->tlock);
+ 	return pmp;
+     }
  
      if (((u_short *)ip)[0] != ((u_short *)&cs->cs_ip)[0] ||
  	((u_short *)ip)[3] != ((u_short *)&cs->cs_ip)[3] ||
***************
*** 960,967 ****
       * some other purpose.
       */
      deltaS = cp - new_seq;
!     if (!(nimp = allocb(deltaS + 4, BPRI_MED)))
! 	return pmp;
  
      /*
       * Remove old IP/TCP header from packet, keeping track of the rest.
--- 987,996 ----
       * some other purpose.
       */
      deltaS = cp - new_seq;
!     if (!(nimp = allocb(deltaS + 4, BPRI_MED))) {
! 	mutex_exit(&vjc->tlock);
!  	return pmp;
!     }
  
      /*
       * Remove old IP/TCP header from packet, keeping track of the rest.
***************
*** 1010,1017 ****
       */
  uncompressed:
      
!     if (!(nimp = allocb(hlen, BPRI_MED)))
! 	return pmp;
  
      /*
       * Copy packet into our state table.
--- 1039,1048 ----
       */
  uncompressed:
      
!     if (!(nimp = allocb(hlen, BPRI_MED))) {
! 	mutex_exit(&vjc->tlock);
!  	return pmp;
!     }
  
      /*
       * Copy packet into our state table.
***************
*** 1056,1062 ****
   * uncompress_tcp() implements the Van Jacobson TCP Uncompression.
   *
   *  pmp		A message block containing the PPP header.  The
!  *		second message block is guaranteed to conatain at
   *		least the IP & TCP headers.
   *  len		the total length of the packet, including IP & TCP headers.
   *  type	either PPP_COMPRESSED_TCP or PPP_UNCOMPTRESSED_TCP
--- 1087,1093 ----
   * uncompress_tcp() implements the Van Jacobson TCP Uncompression.
   *
   *  pmp		A message block containing the PPP header.  The
!  *		second message block is guaranteed to contain at
   *		least the IP & TCP headers.
   *  len		the total length of the packet, including IP & TCP headers.
   *  type	either PPP_COMPRESSED_TCP or PPP_UNCOMPTRESSED_TCP
***************
*** 1306,1312 ****
  
  static struct modlstrmod vjclstrmod = {
      &mod_strmodops,
!     "Van Jacobson Compression Module v3.1.2",
      &vjcfsw
  };
  
--- 1337,1343 ----
  
  static struct modlstrmod vjclstrmod = {
      &mod_strmodops,
!     "VJ Compression Module v3.1.2a",
      &vjcfsw
  };
  
