*** isdn_ppp.c.orig	Mon Oct 15 22:58:31 2001
--- isdn_ppp.c	Mon Oct 15 23:00:05 2001
***************
*** 982,990 ****
  	if (is->debug & 0x10) {
  		printk(KERN_DEBUG "push, skb %d %04x\n", (int) skb->len, proto);
  		isdn_ppp_frame_log("rpush", skb->data, skb->len, 32,is->unit,lp->ppp_slot);
  	}
! 	if (is->compflags & SC_DECOMP_ON) {
  		skb = isdn_ppp_decompress(skb, is, mis, &proto);
  		if (!skb) // decompression error
    			return;
    	}
--- 982,990 ----
  	if (is->debug & 0x10) {
  		printk(KERN_DEBUG "push, skb %d %04x\n", (int) skb->len, proto);
  		isdn_ppp_frame_log("rpush", skb->data, skb->len, 32,is->unit,lp->ppp_slot);
  	}
! 	if (mis->compflags & SC_DECOMP_ON) {
  		skb = isdn_ppp_decompress(skb, is, mis, &proto);
  		if (!skb) // decompression error
    			return;
    	}
***************
*** 998,1005 ****
--- 998,1010 ----
  			if (is->debug & 0x20)
  				printk(KERN_DEBUG "isdn_ppp: IP\n");
  			skb->protocol = htons(ETH_P_IP);
  			break;
+ 		case PPP_COMP:
+ 		case PPP_COMPFRAG:
+ 			printk(KERN_WARNING "isdn_ppp: unexpected compressed frame dropped\n");
+ 			goto drop_packet;
+ 			break;
  #ifdef CONFIG_ISDN_PPP_VJ
  		case PPP_VJC_UNCOMP:
  			if (is->debug & 0x20)
  				printk(KERN_DEBUG "isdn_ppp: VJC_UNCOMP\n");
***************
*** 1221,1230 ****
  
  	/*
  	 * normal (single link) or bundle compression
  	 */
! 	if(ipts->compflags & SC_COMP_ON)
! 		skb = isdn_ppp_compress(skb,&proto,ipt,ipts,0);
  
  	if (ipt->debug & 0x24)
  		printk(KERN_DEBUG "xmit2 skb, len %d, proto %04x\n", (int) skb->len, proto);
  
--- 1226,1242 ----
  
  	/*
  	 * normal (single link) or bundle compression
  	 */
! 	if(ipts->compflags & SC_COMP_ON) {
! 		/* We send compressed only if both down- und upstream
! 		   compression is negotiated, that means, CCP is up */
! 		if(ipts->compflags & SC_DECOMP_ON) {
! 			skb = isdn_ppp_compress(skb,&proto,ipt,ipts,0);
! 		} else {
! 			printk(KERN_DEBUG "isdn_ppp: CCP not yet up - sending as-is\n");
! 		}
! 	}
  
  	if (ipt->debug & 0x24)
  		printk(KERN_DEBUG "xmit2 skb, len %d, proto %04x\n", (int) skb->len, proto);
  
***************
*** 2079,2096 ****
  		return;
  	}
  	if(rs->ta && rs->state == CCPResetSentReq) {
  		/* We are correct here */
- 		printk(KERN_DEBUG "ippp_ccp: CCP Reset timed out for id %d\n",
- 		       rs->id);
  		if(!rs->expra) {
  			/* Hmm, there is no Ack really expected. We can clean
  			   up the state now, it will be reallocated if the
  			   decompressor insists on another reset */
  			rs->ta = 0;
  			isdn_ppp_ccp_reset_free_state(rs->is, rs->id);
  			return;
  		}
  		/* Push it again */
  		isdn_ppp_ccp_xmit_reset(rs->is, PPP_CCP, CCP_RESETREQ, rs->id,
  					rs->data, rs->dlen);
  		/* Restart timer */
--- 2091,2108 ----
  		return;
  	}
  	if(rs->ta && rs->state == CCPResetSentReq) {
  		/* We are correct here */
  		if(!rs->expra) {
  			/* Hmm, there is no Ack really expected. We can clean
  			   up the state now, it will be reallocated if the
  			   decompressor insists on another reset */
  			rs->ta = 0;
  			isdn_ppp_ccp_reset_free_state(rs->is, rs->id);
  			return;
  		}
+ 		printk(KERN_DEBUG "ippp_ccp: CCP Reset timed out for id %d\n",
+ 		       rs->id);
  		/* Push it again */
  		isdn_ppp_ccp_xmit_reset(rs->is, PPP_CCP, CCP_RESETREQ, rs->id,
  					rs->data, rs->dlen);
  		/* Restart timer */
***************
*** 2315,2323 ****
  		kfree_skb(skb);
  		if (len <= 0) {
  			switch(len) {
  			case DECOMP_ERROR:
- 				ri->pppcfg |= SC_DC_ERROR;
  				printk(KERN_INFO "ippp: decomp wants reset %s params\n",
  				       rsparm.valid ? "with" : "without");
  				
  				isdn_ppp_ccp_reset_trans(ri, &rsparm);
--- 2327,2334 ----
***************
*** 2430,2437 ****
--- 2441,2455 ----
  		mis = is;
  
  	switch(skb->data[0]) {
  	case CCP_CONFREQ:
+ 		if(is->debug & 0x10)
+ 			printk(KERN_DEBUG "Disable compression here!\n");
+ 		if(proto == PPP_CCP)
+ 			mis->compflags &= ~SC_COMP_ON;		
+ 		else
+ 			is->compflags &= ~SC_LINK_COMP_ON;		
+ 		break;
  	case CCP_TERMREQ:
  	case CCP_TERMACK:
  		if(is->debug & 0x10)
  			printk(KERN_DEBUG "Disable (de)compression here!\n");
***************
*** 2467,2475 ****
  					      len ? &skb->data[4] : NULL,
  					      len, NULL);
  			/* TODO: This is not easy to decide here */
  			mis->compflags &= ~SC_DECOMP_DISCARD;
- 			mis->pppcfg &= ~SC_DC_ERROR;
  		}
  		else {
  			isdn_ppp_ccp_reset_ack_rcvd(is, skb->data[1]);
  			if(is->link_decompressor && is->link_decomp_stat)
--- 2485,2492 ----
***************
*** 2480,2488 ****
  					      len ? &skb->data[4] : NULL,
  					      len, NULL);
  			/* TODO: neither here */
  			is->compflags &= ~SC_LINK_DECOMP_DISCARD;
- 			is->pppcfg &= ~SC_DC_ERROR;
  		}
  		break;
  
  	case CCP_RESETREQ:
--- 2497,2504 ----
***************
*** 2545,2552 ****
--- 2561,2588 ----
   */
  
  /* TODO: Clean this up with new Reset semantics */
  
+ /* I believe the CCP handling as-is is done wrong. Compressed frames
+  * should only be sent/received after CCP reaches UP state, which means
+  * both sides have sent CONF_ACK. Currently, we handle both directions
+  * independently, which means we may accept compressed frames too early
+  * (supposedly not a problem), but may also mean we send compressed frames
+  * too early, which may turn out to be a problem.
+  * This part of state machine should actually be handled by (i)pppd, but
+  * that's too big of a change now. --kai
+  */
+ 
+ /* Actually, we might turn this into an advantage: deal with the RFC in
+  * the old tradition of beeing generous on what we accept, but beeing
+  * strict on what we send. Thus we should just
+  * - accept compressed frames as soon as decompression is negotiated
+  * - send compressed frames only when decomp *and* comp are negotiated
+  * - drop rx compressed frames if we cannot decomp (instead of pushing them
+  *   up to ipppd)
+  * and I tried to modify this file according to that. --abp
+  */
+ 
  static void isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp, struct sk_buff *skb)
  {
  	struct ippp_struct *mis,*is = ippp_table[lp->ppp_slot];
  	int proto;
***************
*** 2579,2586 ****
--- 2615,2629 ----
  		printk(KERN_DEBUG "isdn_ppp: Ouch! Master CCP sends on slave slot!\n");
  	
          switch(data[2]) {
  	case CCP_CONFREQ:
+ 		if(is->debug & 0x10)
+ 			printk(KERN_DEBUG "Disable decompression here!\n");
+ 		if(proto == PPP_CCP)
+ 			is->compflags &= ~SC_DECOMP_ON;
+ 		else
+ 			is->compflags &= ~SC_LINK_DECOMP_ON;
+ 		break;
  	case CCP_TERMREQ:
  	case CCP_TERMACK:
  		if(is->debug & 0x10)
  			printk(KERN_DEBUG "Disable (de)compression here!\n");

