Jan Wasserbauer <[EMAIL PROTECTED]> wrote:

> Due to mails here I send a copy of original mail about ax25_info_struct
> diff is just 3kB so it is included too.

Okay, thank you. I've slightly changed the patch to make it better
maintainable. It is against 2.3.42, but should work with 2.2.14 as
well. It doesn't seem to break anything -- I'll try to get this into
2.3.x if nobody objects. The compatibility code could go away at the 
end of 2.5.x. Comments?

73,
J�rg
diff -ur linux-2.3.42/include/linux/ax25.h linux-2.3.42-bke/include/linux/ax25.h
--- linux-2.3.42/include/linux/ax25.h	Wed Feb  2 17:46:07 2000
+++ linux-2.3.42-bke/include/linux/ax25.h	Wed Feb  2 18:58:55 2000
@@ -29,9 +29,11 @@
 #define SIOCAX25NOUID		(SIOCPROTOPRIVATE+3)
 #define SIOCAX25OPTRT		(SIOCPROTOPRIVATE+7)
 #define SIOCAX25CTLCON		(SIOCPROTOPRIVATE+8)
-#define SIOCAX25GETINFO		(SIOCPROTOPRIVATE+9)
+#define SIOCAX25GETINFOOLD	(SIOCPROTOPRIVATE+9)
 #define SIOCAX25ADDFWD		(SIOCPROTOPRIVATE+10)
 #define SIOCAX25DELFWD		(SIOCPROTOPRIVATE+11)
+#define SIOCAX25DEVCTL          (SIOCPROTOPRIVATE+12)
+#define SIOCAX25GETINFO         (SIOCPROTOPRIVATE+13)
 
 #define AX25_SET_RT_IPMODE	2
 
@@ -80,6 +82,17 @@
         ax25_address            digi_addr[AX25_MAX_DIGIS];
 };
 
+/* this will go away. Please do not export to user land */
+struct ax25_info_struct_depreciated {
+	unsigned int	n2, n2count;
+	unsigned int	t1, t1timer;
+	unsigned int	t2, t2timer;
+	unsigned int	t3, t3timer;
+	unsigned int	idle, idletimer;
+	unsigned int	state;
+	unsigned int	rcv_q, snd_q;
+};
+
 struct ax25_info_struct {
 	unsigned int	n2, n2count;
 	unsigned int	t1, t1timer;
@@ -88,6 +101,9 @@
 	unsigned int	idle, idletimer;
 	unsigned int	state;
 	unsigned int	rcv_q, snd_q;
+	unsigned int	vs, vr, va, vs_max;
+	unsigned int	paclen;
+	unsigned int	window;
 };
 
 struct ax25_fwd_struct {
Only in linux-2.3.42-bke/include/linux: ax25.h.old
diff -ur linux-2.3.42/net/ax25/af_ax25.c linux-2.3.42-bke/net/ax25/af_ax25.c
--- linux-2.3.42/net/ax25/af_ax25.c	Wed Feb  2 17:40:47 2000
+++ linux-2.3.42-bke/net/ax25/af_ax25.c	Wed Feb  2 19:09:25 2000
@@ -1574,8 +1574,10 @@
 				return -EPERM;
 			return ax25_ctl_ioctl(cmd, (void *)arg);
 
-		case SIOCAX25GETINFO: {
+		case SIOCAX25GETINFO: 
+		case SIOCAX25GETINFOOLD: {
 			struct ax25_info_struct ax25_info;
+
 			ax25_info.t1        = sk->protinfo.ax25->t1   / HZ;
 			ax25_info.t2        = sk->protinfo.ax25->t2   / HZ;
 			ax25_info.t3        = sk->protinfo.ax25->t3   / HZ;
@@ -1589,8 +1591,28 @@
 			ax25_info.state     = sk->protinfo.ax25->state;
 			ax25_info.rcv_q     = atomic_read(&sk->rmem_alloc);
 			ax25_info.snd_q     = atomic_read(&sk->wmem_alloc);
-			if (copy_to_user((void *)arg, &ax25_info, sizeof(ax25_info)))
-				return -EFAULT;
+			ax25_info.vs        = sk->protinfo.ax25->vs;
+			ax25_info.vr        = sk->protinfo.ax25->vr;
+			ax25_info.va        = sk->protinfo.ax25->va;
+			ax25_info.vs_max    = sk->protinfo.ax25->vs; /* reserved */
+			ax25_info.paclen    = sk->protinfo.ax25->paclen;
+			ax25_info.window    = sk->protinfo.ax25->window;
+
+			/* old structure? */
+			if (cmd == SIOCAX25GETINFOOLD) {
+				static int warned = 0;
+				if (!warned) {
+					printk(KERN_INFO "%s uses old SIOCAX25GETINFO\n",
+						current->comm);
+					warned=1;
+				}
+
+				if (copy_to_user((void *)arg, &ax25_info, sizeof(struct ax25_info_struct_depreciated)))
+					return -EFAULT;
+			} else {
+				if (copy_to_user((void *)arg, &ax25_info, sizeof(struct ax25_info_struct)))
+					return -EINVAL;
+			} 
 			return 0;
 		}
 
Joerg Reuter                                 http://poboxes.com/jreuter/
And I make my way to where the warm scent of soil fills the evening air. 
Everything is waiting quietly out there....                 (Anne Clark)

Reply via email to