Skip to contentSkip to conversation

IrDA: IrLAP raw mode

PATCH Applied Samuel Ortiz 2 participants 3 messages Mar 17, 2007 – Apr 6, 2007 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 IrDA: IrLAP raw mode

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).

---
 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
include/net/irda/irlap.h +5 -0
index e77eb88..1b24cfc 100644
@@ -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 {
 	int    xbofs_delay;   /* Nr of XBOF's used to MTT */
 	int    bofs_count;    /* Negotiated extra BOFs */
 	int    next_bofs;     /* Negotiated extra BOFs after next frame */
+#ifdef CONFIG_IRDA_RAW
+	int    raw_mode;
+	struct irlap_raw * irlap_raw;
+#endif
 };
 
 /* 
include/net/irda/irlap_raw.h new file +57 -0

57 lines not on this page · raw message

net/irda/Kconfig +10 -0
index 9efb17b..310a036 100644
@@ -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"
 
net/irda/Makefile +1 -0
index d1366c2..11d5ffb 100644
@@ -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
net/irda/irlap.c +5 -0
index d93ebd1..656c949 100644
@@ -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);
net/irda/irlap_event.c +3 -0
index 7b6433f..3a11c3e 100644
@@ -241,6 +241,9 @@ void irlap_do_event(struct irlap_cb *self, IRLAP_EVENT event,
 	if (!self || self->magic != LAP_MAGIC)
 		return;
 
+	if (irlap_raw_mode(self))
+		return;
+
 	IRDA_DEBUG(3, "%s(), event = %s, state = %s\n", __FUNCTION__,
 		   irlap_event[event], irlap_state[self->state]);
 
net/irda/irlap_frame.c +4 -0
index 803ac41..5a3a868 100644
@@ -1325,6 +1325,10 @@ int irlap_driver_rcv(struct sk_buff *skb, struct net_device *dev,
 		return -1;
 	}
 
+       if (irlap_raw_mode(self)) {
+               return irlap_raw_recv_frame(skb, dev);
+       }
+
 	/* We are no longer an "old" protocol, so we need to handle
 	 * share and non linear skbs. This should never happen, so
 	 * we don't need to be clever about it. Jean II */
net/irda/irlap_raw.c new file +358 -0

358 lines not on this page · raw message

net/irda/irsysctl.c +15 -1
index 2e968e7..a7e967d 100644
@@ -35,7 +35,7 @@
 enum { DISCOVERY=1, DEVNAME, DEBUG, FAST_POLL, DISCOVERY_SLOTS,
        DISCOVERY_TIMEOUT, SLOT_TIMEOUT, MAX_BAUD_RATE, MIN_TX_TURN_TIME,
        MAX_TX_DATA_SIZE, MAX_TX_WINDOW, MAX_NOREPLY_TIME, WARN_NOREPLY_TIME,
-       LAP_KEEPALIVE_TIME };
+       LAP_KEEPALIVE_TIME, RAW_RING_LENGTH };
 
 extern int  sysctl_discovery;
 extern int  sysctl_discovery_slots;
@@ -50,6 +50,9 @@ extern int  sysctl_max_tx_window;
 extern int  sysctl_max_noreply_time;
 extern int  sysctl_warn_noreply_time;
 extern int  sysctl_lap_keepalive_time;
+#ifdef CONFIG_IRDA_RAW
+extern unsigned int  sysctl_raw_ring_length;
+#endif
 
 /* this is needed for the proc_dointvec_minmax - Jean II */
 static int max_discovery_slots = 16;		/* ??? */
@@ -237,6 +240,17 @@ static ctl_table irda_table[] = {
 		.extra1		= &min_lap_keepalive_time,
 		.extra2		= &max_lap_keepalive_time
 	},
+#ifdef CONFIG_IRDA_RAW
+	{
+		.ctl_name	= RAW_RING_LENGTH,
+		.procname	= "raw_ring_length",
+		.data		= &sysctl_raw_ring_length,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec
+	},
+#endif
+
 	{ .ctl_name = 0 }
 };
 
Signature · 8 lines
1.5.0.2


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
maintainer
#1 lore raw

From: Samuel Ortiz <[email protected]>
Date: Sat, 17 Mar 2007 03:57:29 +0200

Quoted 6 lines

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).

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 :)

A message that is not in the archive (sent off-list or not yet received): 20070316.203451.102575913.davem-fT/PcQaiUtIeIZ0/[email protected]

#3 lore raw
Quoted 13 lines · David Miller

From: Samuel Ortiz <[email protected]>
Date: Sat, 17 Mar 2007 03:57:29 +0200

Quoted 6 lines

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).

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

Quoted 6 lines

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.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV