From 949d4e94ce3b9023c165ec9ea2651b56fb0b4847 Mon Sep 17 00:00:00 2001
From: Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Date: Wed, 16 Oct 2002 01:18:31 -0500
Subject: [PATCH] ISDN/PPP: CCP flags handling

Let isdn_ppp_ccp.c take care of keeping state / flags by itself.
---
 drivers/isdn/i4l/isdn_ppp.c     | 14 ++++++++------
 drivers/isdn/i4l/isdn_ppp_ccp.c | 11 +++++++++--
 drivers/isdn/i4l/isdn_ppp_ccp.h | 20 ++++++++++++++++++--
 include/linux/isdn_ppp.h        |  9 ---------
 4 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index 8595e4e13e70..1de1ca9ef90d 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -49,7 +49,7 @@ isdn_ppp_send_ccp(isdn_net_dev *net_dev, isdn_net_local *lp,
 
 /* New CCP stuff */
 static void
-isdn_ppp_ccp_kick_up(void *priv, unsigned int flags);
+isdn_ppp_ccp_kick_up(void *priv);
 
 static void
 isdn_ppp_ccp_xmit_reset(void *priv, int proto, unsigned char code,
@@ -438,6 +438,7 @@ ipppd_ioctl(struct inode *ino, struct file *file, unsigned int cmd, unsigned lon
 	int r;
 	struct ipppd *is;
 	struct isdn_ppp_comp_data data;
+	unsigned int cfg;
 
 	is = (struct ipppd *) file->private_data;
 	idev = is->idev;
@@ -488,7 +489,8 @@ ipppd_ioctl(struct inode *ino, struct file *file, unsigned int cmd, unsigned lon
 		case PPPIOCGFLAGS:	/* get configuration flags */
 			if (!idev)
 				return -ENODEV;
-			if ((r = set_arg((void *) arg, &idev->pppcfg, sizeof(idev->pppcfg) )))
+			cfg = idev->pppcfg | ippp_ccp_get_flags(idev->ccp);
+			if ((r = set_arg((void *) arg, &cfg, sizeof(cfg) )))
 				return r;
 			break;
 		case PPPIOCSFLAGS:	/* set configuration flags */
@@ -498,8 +500,10 @@ ipppd_ioctl(struct inode *ino, struct file *file, unsigned int cmd, unsigned lon
 				return r;
 			}
 			if ((val & SC_ENABLE_IP) && !(idev->pppcfg & SC_ENABLE_IP)) {
+				idev->pppcfg = val;
 				/* OK .. we are ready to send buffers */
 				isdn_net_online(idev);
+				break;
 			}
 			idev->pppcfg = val;
 			break;
@@ -1926,15 +1930,14 @@ isdn_ppp_hangup_slave(char *name)
 /* Push an empty CCP Data Frame up to the daemon to wake it up and let it
    generate a CCP Reset-Request or tear down CCP altogether */
 
-static void isdn_ppp_ccp_kick_up(void *priv, unsigned int flags)
+static void isdn_ppp_ccp_kick_up(void *priv)
 {
 	isdn_net_dev *idev = priv;
 
-	idev->pppcfg |= flags;
 	isdn_ppp_fill_rq(NULL, 0, PPP_COMP, idev->ppp_slot);
 }
 
-static void isdn_ppp_ccp_lp_kick_up(void *priv, unsigned int flags)
+static void isdn_ppp_ccp_lp_kick_up(void *priv)
 {
 	isdn_net_local *lp = priv;
 	isdn_net_dev *idev;
@@ -1944,7 +1947,6 @@ static void isdn_ppp_ccp_lp_kick_up(void *priv, unsigned int flags)
 		return;
 	}
 	idev = list_entry(lp->online.next, isdn_net_dev, online);
-	idev->pppcfg |= flags;
 	isdn_ppp_fill_rq(NULL, 0, PPP_COMP, idev->ppp_slot);
 }
 
diff --git a/drivers/isdn/i4l/isdn_ppp_ccp.c b/drivers/isdn/i4l/isdn_ppp_ccp.c
index c9fb94cd88cb..6e150532958a 100644
--- a/drivers/isdn/i4l/isdn_ppp_ccp.c
+++ b/drivers/isdn/i4l/isdn_ppp_ccp.c
@@ -185,7 +185,7 @@ ippp_ccp_alloc(int proto, void *priv,
 	       void (*xmit_reset)(void *priv, int proto, unsigned char code,
 				  unsigned char id, unsigned char *data, 
 				  int len),
-	       void (*kick_up)(void *priv, unsigned int flags))
+	       void (*kick_up)(void *priv))
 {
 	struct ippp_ccp *ccp;
 
@@ -230,6 +230,12 @@ ippp_ccp_set_mru(struct ippp_ccp *ccp, unsigned int mru)
 	return 0;
 }
 
+unsigned int
+ippp_ccp_get_flags(struct ippp_ccp *ccp);
+{
+	return idev->ccp->compflags & (SC_DC_ERROR|SC_DC_FERROR);
+}
+
 /*
  * compress a frame 
  * returns original skb if we did not compress the frame
@@ -322,8 +328,9 @@ ippp_ccp_decompress(struct ippp_ccp *ccp, struct sk_buff *skb_in, int *proto)
 			ippp_ccp_reset_xmit(ccp, &rsparm);
 			break;
 		case DECOMP_FATALERROR:
+			ccp->compflags |= SC_DC_FERROR;
 			/* Kick ipppd to recognize the error */
-			ccp->kick_up(ccp->priv, SC_DC_FERROR);
+			ccp->kick_up(ccp->priv);
 			break;
 		}
 		kfree_skb(skb);
diff --git a/drivers/isdn/i4l/isdn_ppp_ccp.h b/drivers/isdn/i4l/isdn_ppp_ccp.h
index 71d0cfc3bbb3..ddee87c34375 100644
--- a/drivers/isdn/i4l/isdn_ppp_ccp.h
+++ b/drivers/isdn/i4l/isdn_ppp_ccp.h
@@ -2,6 +2,19 @@
 #include <linux/kernel.h>
 #include <linux/isdn_ppp.h>
 
+/* for ippp_ccp::flags */
+
+#define SC_DECOMP_ON		0x01
+#define SC_COMP_ON		0x02
+#define SC_DECOMP_DISCARD	0x04
+#define SC_COMP_DISCARD		0x08
+
+/* SC_DC_ERROR/FERROR go in here as well, but are defined elsewhere
+
+   #define SC_DC_FERROR	0x00800000
+   #define SC_DC_ERROR	0x00400000
+*/
+
 struct ippp_ccp {
 	int proto;
 	struct isdn_ppp_compressor *compressor;
@@ -15,7 +28,7 @@ struct ippp_ccp {
 	void                       *priv;
 	void (*xmit_reset)(void *priv, int proto, unsigned char code,
 			   unsigned char id, unsigned char *data, int len);
-	void (*kick_up)(void *priv, unsigned int flags);
+	void (*kick_up)(void *priv);
 };
 
 struct ippp_ccp *
@@ -23,7 +36,7 @@ ippp_ccp_alloc(int proto, void *priv,
 	       void (*xmit_reset)(void *priv, int proto, unsigned char code,
 				  unsigned char id, unsigned char *data, 
 				  int len),
-	       void (*kick_up)(void *priv, unsigned int flags));
+	       void (*kick_up)(void *priv));
 
 void
 ippp_ccp_free(struct ippp_ccp *ccp);
@@ -31,6 +44,9 @@ ippp_ccp_free(struct ippp_ccp *ccp);
 int
 ippp_ccp_set_mru(struct ippp_ccp *ccp, unsigned int mru);
 
+unsigned int
+ippp_ccp_get_flags(struct ippp_ccp *ccp);
+
 struct sk_buff *
 ippp_ccp_compress(struct ippp_ccp *ccp, struct sk_buff *skb, int *proto);
 
diff --git a/include/linux/isdn_ppp.h b/include/linux/isdn_ppp.h
index 2c1fc99849f2..ec6016c37421 100644
--- a/include/linux/isdn_ppp.h
+++ b/include/linux/isdn_ppp.h
@@ -38,15 +38,6 @@ struct pppcallinfo
 #define SC_OUT_SHORT_SEQ 0x00000800
 #define SC_IN_SHORT_SEQ  0x00004000
 
-#define SC_DECOMP_ON		0x01
-#define SC_COMP_ON		0x02
-#define SC_DECOMP_DISCARD	0x04
-#define SC_COMP_DISCARD		0x08
-#define SC_LINK_DECOMP_ON	0x10
-#define SC_LINK_COMP_ON		0x20
-#define SC_LINK_DECOMP_DISCARD	0x40
-#define SC_LINK_COMP_DISCARD	0x80
-
 #define ISDN_PPP_COMP_MAX_OPTIONS 16
 
 #define IPPP_COMP_FLAG_XMIT 0x1
-- 
2.30.9