patch-2.1.53 linux/drivers/net/slip.c

Next file: linux/drivers/net/soundmodem/Makefile
Previous file: linux/drivers/net/myri_sbus.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.52/linux/drivers/net/slip.c linux/drivers/net/slip.c
@@ -106,6 +106,7 @@
 #ifdef CONFIG_SLIP_SMART
 static void sl_keepalive(unsigned long sls);
 static void sl_outfill(unsigned long sls);
+static int sl_ioctl(struct device *dev,struct ifreq *rq,int cmd);
 #endif
 
 /* Find a free SLIP channel, and link in this `tty' line. */
@@ -1015,8 +1016,6 @@
 #ifdef CONFIG_SLIP_SMART
 	/* VSV changes start here */
         case SIOCSKEEPALIVE:
-                if (sl->keepalive)
-                        (void)del_timer (&sl->keepalive_timer);
 		err = verify_area(VERIFY_READ, arg, sizeof(int));
 		if (err)  {
 			return -err;
@@ -1024,6 +1023,8 @@
 		get_user(tmp,(int *)arg);
                 if (tmp > 255) /* max for unchar */
 			return -EINVAL;
+                if (sl->keepalive)
+                        (void)del_timer (&sl->keepalive_timer);
 		if ((sl->keepalive = (unchar) tmp) != 0) {
 			sl->keepalive_timer.expires=jiffies+sl->keepalive*HZ;
 			add_timer(&sl->keepalive_timer);
@@ -1040,8 +1041,6 @@
 		return 0;
 
         case SIOCSOUTFILL:
-                if (sl->outfill)
-                         (void)del_timer (&sl->outfill_timer);
 		err = verify_area(VERIFY_READ, arg, sizeof(int));
 		if (err)  {
 			return -err;
@@ -1049,6 +1048,8 @@
 		get_user(tmp,(int *)arg);
                 if (tmp > 255) /* max for unchar */
 			return -EINVAL;
+                if (sl->outfill)
+                         (void)del_timer (&sl->outfill_timer);
                 if ((sl->outfill = (unchar) tmp) != 0){
 			sl->outfill_timer.expires=jiffies+sl->outfill*HZ;
 			add_timer(&sl->outfill_timer);
@@ -1076,6 +1077,58 @@
 	}
 }
 
+/* VSV changes start here */
+#ifdef CONFIG_SLIP_SMART
+/* function do_ioctl called from net/core/dev.c
+   to allow get/set outfill/keepalive parameter
+   by ifconfig                                 */
+
+static int sl_ioctl(struct device *dev,struct ifreq *rq,int cmd)
+{
+	struct slip *sl = (struct slip*)(dev->priv);
+
+	if (sl == NULL)		/* Allocation failed ?? */
+		return -ENODEV;
+
+	switch(cmd){
+        case SIOCSKEEPALIVE:
+		/* max for unchar */
+                if (((unsigned int)((unsigned long)rq->ifr_data)) > 255)
+			return -EINVAL;
+                if (sl->keepalive)
+                        (void)del_timer (&sl->keepalive_timer);
+		sl->keepalive = (unchar) ((unsigned long)rq->ifr_data);
+		if (sl->keepalive != 0) {
+			sl->keepalive_timer.expires=jiffies+sl->keepalive*HZ;
+			add_timer(&sl->keepalive_timer);
+			set_bit(SLF_KEEPTEST, &sl->flags);
+                }
+		break;
+
+        case SIOCGKEEPALIVE:
+		rq->ifr_data=(caddr_t)((unsigned long)sl->keepalive);
+		break;
+
+        case SIOCSOUTFILL:
+                if (((unsigned)((unsigned long)rq->ifr_data)) > 255) /* max for unchar */
+			return -EINVAL;
+                if (sl->outfill)
+			del_timer (&sl->outfill_timer);
+                if ((sl->outfill = (unchar)((unsigned long) rq->ifr_data)) != 0){
+			sl->outfill_timer.expires=jiffies+sl->outfill*HZ;
+			add_timer(&sl->outfill_timer);
+			set_bit(SLF_OUTWAIT, &sl->flags);
+		}
+                break;
+
+        case SIOCGOUTFILL:
+		rq->ifr_data=(caddr_t)((unsigned long)sl->outfill);
+	};
+	return 0;
+}
+#endif
+/* VSV changes end */
+
 static int sl_open_dev(struct device *dev)
 {
 	struct slip *sl = (struct slip*)(dev->priv);
@@ -1173,6 +1226,9 @@
 	dev->open		= sl_open_dev;
 	dev->stop		= sl_close;
 	dev->get_stats	        = sl_get_stats;
+#ifdef CONFIG_SLIP_SMART
+	dev->do_ioctl		= sl_ioctl;
+#endif
 	dev->hard_header_len	= 0;
 	dev->addr_len		= 0;
 	dev->type		= ARPHRD_SLIP + SL_MODE_DEFAULT;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov