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