Re: [PATCH 1/4] [net-2.6.22] IrDA: IrLAP raw mode

2007-04-06 Thread Samuel Ortiz
On Fri, Mar 16, 2007 at 08:34:51PM -0700, David Miller wrote:
 From: Samuel Ortiz [EMAIL PROTECTED]
 Date: Sat, 17 Mar 2007 03:57:29 +0200
 
  This patch allows us to bypass the IrDA stack down to the IrLAP level.
  Sending and receiving frames is done through a character device.
  This is useful for e.g. doing real IrDA sniffing, testing external IrDA
  stacks and for Lirc (once I will add the framing disabling switch).
  
  Signed-off-by: Samuel Ortiz [EMAIL PROTECTED]
 
 I understand the idea, but I fail to see any reason this should not be
 done with sockets.
 
 Everywhere else we provide this kind of functionality it is either
 with netlink (nf_queue etc.) or raw sockets of some kind
 (AF_INET/SOCK_RAW, AF_PACKET, etc.)
 
 Therefore IRDA should really provide this facility in some similar
 manner.
I definitely agree here. Actually, you can already sniff IrDA packets through
an AF_PACKET socket, that's what irdadump does. My patch was useless, forget
about it...

I have a question though: On top of the regular IrDA sniffing done with a
simple AF_PACKET socket, I also would like to be able to disable TX at the
IrLAP level (typically, this would allow an IrDA device to listen to all
the packets from an IrDA link without being noticed by the other devices).

I was thinking of adding a protocol private ioctl (as in SIOCPROTOPRIVATE) to
let userspace toggle an IrLAP flag (one per IrLAP instance) that would
disable a specific IrDA device TX path.
Would that be an acceptable solution, or would you rather see a netlink socket
for that purpose ?

Cheers,
Samuel.

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] [net-2.6.22] IrDA: IrLAP raw mode

2007-03-16 Thread Samuel Ortiz
This patch allows us to bypass the IrDA stack down to the IrLAP level.
Sending and receiving frames is done through a character device.
This is useful for e.g. doing real IrDA sniffing, testing external IrDA
stacks and for Lirc (once I will add the framing disabling switch).

Signed-off-by: Samuel Ortiz [EMAIL PROTECTED]
---
 include/net/irda/irlap.h |5 +
 include/net/irda/irlap_raw.h |   57 +++
 net/irda/Kconfig |   10 ++
 net/irda/Makefile|1 +
 net/irda/irlap.c |5 +
 net/irda/irlap_event.c   |3 +
 net/irda/irlap_frame.c   |4 +
 net/irda/irlap_raw.c |  358 ++
 net/irda/irsysctl.c  |   16 ++-
 9 files changed, 458 insertions(+), 1 deletions(-)
 create mode 100644 include/net/irda/irlap_raw.h
 create mode 100644 net/irda/irlap_raw.c

diff --git a/include/net/irda/irlap.h b/include/net/irda/irlap.h
index e77eb88..1b24cfc 100644
--- a/include/net/irda/irlap.h
+++ b/include/net/irda/irlap.h
@@ -36,6 +36,7 @@
 #include net/irda/qos.h  /* struct qos_info */
 #include net/irda/discovery.h/* discovery_t */
 #include net/irda/irlap_event.h  /* IRLAP_STATE, ... */
+#include net/irda/irlap_raw.h/* IRLAP raw definitions */
 #include net/irda/irmod.h/* struct notify_t */
 
 #define CONFIG_IRDA_DYNAMIC_WINDOW 1
@@ -208,6 +209,10 @@ struct irlap_cb {
intxbofs_delay;   /* Nr of XBOF's used to MTT */
intbofs_count;/* Negotiated extra BOFs */
intnext_bofs; /* Negotiated extra BOFs after next frame */
+#ifdef CONFIG_IRDA_RAW
+   intraw_mode;
+   struct irlap_raw * irlap_raw;
+#endif
 };
 
 /* 
diff --git a/include/net/irda/irlap_raw.h b/include/net/irda/irlap_raw.h
new file mode 100644
index 000..ce90563
--- /dev/null
+++ b/include/net/irda/irlap_raw.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2007 Samuel Ortiz ([EMAIL PROTECTED])
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2.
+ *
+ */
+
+#ifndef _IRLAP_RAW_H
+#define _IRLAP_RAW_H
+
+struct irlap_cb;
+
+#ifdef CONFIG_IRDA_RAW
+
+extern int irlap_raw_recv_frame(struct sk_buff *skb, struct net_device *dev);
+extern int irlap_raw_register_device(struct net_device * dev);
+extern int irlap_raw_unregister_device(struct net_device * dev);
+extern int irlap_raw_mode(struct irlap_cb *self);
+
+#else
+
+static inline int irlap_raw_recv_frame(struct sk_buff *skb,
+  struct net_device *dev)
+{
+if (skb == NULL)
+return -EINVAL;
+
+if (dev-atalk_ptr == NULL)
+return -ENODEV;
+
+return 0;
+}
+
+static inline int irlap_raw_register_device(struct net_device * dev)
+{
+if (dev == NULL)
+return -ENODEV;
+return 0;
+}
+
+static inline int irlap_raw_unregister_device(struct net_device * dev)
+{
+if (dev == NULL)
+return -ENODEV;
+return 0;
+}
+
+static inline int irlap_raw_mode(struct irlap_cb *self)
+{
+return 0;
+}
+
+#endif
+
+#endif
diff --git a/net/irda/Kconfig b/net/irda/Kconfig
index 9efb17b..310a036 100644
--- a/net/irda/Kconfig
+++ b/net/irda/Kconfig
@@ -92,5 +92,15 @@ config IRDA_DEBUG
 
  If unsure, say Y (since it makes it easier to find the bugs).
 
+config IRDA_RAW
+   bool IrLAP raw
+   depends on IRDA
+   help
+ Say Y if you want to bypass the IrDA stack, down to the IrLAP level.
+ This option allows you to send and receive IrLAP frames from
+ userspace, by writing and reading to a character device
+ (/dev/irdaX_raw). Note that the IrDA stack will be mostly disabled.
+ If unsure, say N.
+
 source drivers/net/irda/Kconfig
 
diff --git a/net/irda/Makefile b/net/irda/Makefile
index d1366c2..11d5ffb 100644
--- a/net/irda/Makefile
+++ b/net/irda/Makefile
@@ -13,3 +13,4 @@ irda-y := iriap.o iriap_event.o irlmp.o irlmp_event.o 
irlmp_frame.o \
  discovery.o parameters.o irmod.o
 irda-$(CONFIG_PROC_FS) += irproc.o
 irda-$(CONFIG_SYSCTL) += irsysctl.o
+irda-$(CONFIG_IRDA_RAW) += irlap_raw.o
diff --git a/net/irda/irlap.c b/net/irda/irlap.c
index d93ebd1..656c949 100644
--- a/net/irda/irlap.c
+++ b/net/irda/irlap.c
@@ -173,6 +173,8 @@ struct irlap_cb *irlap_open(struct net_device *dev, struct 
qos_info *qos,
 
irlmp_register_link(self, self-saddr, self-notify);
 
+   irlap_raw_register_device(dev);
+
return self;
 }
 EXPORT_SYMBOL(irlap_open);
@@ -234,6 +236,9 @@ void irlap_close(struct irlap_cb *self)
IRDA_DEBUG(1, %s(), Didn't find myself!\n, __FUNCTION__);
return;
}
+
+   irlap_raw_unregister_device(self-netdev);
+
__irlap_close(lap);
 }
 EXPORT_SYMBOL(irlap_close);
diff --git a/net/irda/irlap_event.c 

Re: [PATCH 1/4] [net-2.6.22] IrDA: IrLAP raw mode

2007-03-16 Thread David Miller
From: Samuel Ortiz [EMAIL PROTECTED]
Date: Sat, 17 Mar 2007 03:57:29 +0200

 This patch allows us to bypass the IrDA stack down to the IrLAP level.
 Sending and receiving frames is done through a character device.
 This is useful for e.g. doing real IrDA sniffing, testing external IrDA
 stacks and for Lirc (once I will add the framing disabling switch).
 
 Signed-off-by: Samuel Ortiz [EMAIL PROTECTED]

I understand the idea, but I fail to see any reason this should not be
done with sockets.

Everywhere else we provide this kind of functionality it is either
with netlink (nf_queue etc.) or raw sockets of some kind
(AF_INET/SOCK_RAW, AF_PACKET, etc.)

Therefore IRDA should really provide this facility in some similar
manner.  Besides, character device backdoors for networking are
just ugly :)

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html