* [PATCHv2 bluetooth-next 0/8] ieee802154: pending/new fixes and cleanup/features
@ 2016-06-27 22:00 Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 1/8] ieee802154: add ieee802154_skb_dst_pan helper Alexander Aring
` (7 more replies)
0 siblings, 8 replies; 10+ messages in thread
From: Alexander Aring @ 2016-06-27 22:00 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
Hi,
I currently work on running the RIOT-OS stack in userspace stuff. At first
for a testing use-case. While working on that I detected the intra-pan
addressing behaviour and non-monitors on fakelb.
I recently posted the first 4 patches and the atusb one. I simple put
them now into one patch-series and added Stefan's suggestion, but still
not use if these pointer helpers on mac headers are okay for lowlevel
functionality.
- Alex
changes since v2:
- Add new patch [5/8] 6lowpan: ndisc: set invalid unicast short addr to unspec
- Add new patch [8/8] fakelb: allow to run as monitor.
- split WARN_ON cleanup from "ieee802154: fix skb get fc on big endian" into
new separate [7/8] ieee802154: cleanup WARN_ON for fc fetch.
- add missing pan_id check in case of non intra-pan and dadder available for
ieee802154_skb_src_pan function.
- add fix for atusb csma setting which isn't mainline yet.
Alexander Aring (8):
ieee802154: add ieee802154_skb_dst_pan helper
ieee802154: add ieee802154_skb_src_pan helper
ieee802154: 6lowpan: fix intra pan id check
ieee802154: fix skb get fc on big endian
6lowpan: ndisc: set invalid unicast short addr to unspec
atusb: don't change csma settings while set channel
ieee802154: cleanup WARN_ON for fc fetch
fakelb: allow to run as monitor
drivers/net/ieee802154/atusb.c | 6 +--
drivers/net/ieee802154/fakelb.c | 8 +++
include/linux/ieee802154.h | 29 +++++++++++
include/net/mac802154.h | 108 ++++++++++++++++++++++++++++++++++++++--
net/6lowpan/ndisc.c | 7 ++-
net/ieee802154/6lowpan/rx.c | 2 +-
6 files changed, 148 insertions(+), 12 deletions(-)
--
2.9.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCHv2 bluetooth-next 1/8] ieee802154: add ieee802154_skb_dst_pan helper
2016-06-27 22:00 [PATCHv2 bluetooth-next 0/8] ieee802154: pending/new fixes and cleanup/features Alexander Aring
@ 2016-06-27 22:00 ` Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 2/8] ieee802154: add ieee802154_skb_src_pan helper Alexander Aring
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Alexander Aring @ 2016-06-27 22:00 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch adds ieee802154_skb_dst_pan function to get the pointer
address of the destination pan id at skb mac pointer.
Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
include/linux/ieee802154.h | 16 ++++++++++++++++
include/net/mac802154.h | 29 +++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
index acedbb6..91f4665 100644
--- a/include/linux/ieee802154.h
+++ b/include/linux/ieee802154.h
@@ -31,6 +31,8 @@
#define IEEE802154_MIN_PSDU_LEN 9
#define IEEE802154_FCS_LEN 2
#define IEEE802154_MAX_AUTH_TAG_LEN 16
+#define IEEE802154_FC_LEN 2
+#define IEEE802154_SEQ_LEN 1
/* General MAC frame format:
* 2 bytes: Frame Control
@@ -221,9 +223,14 @@ enum {
#define IEEE802154_FCTL_ACKREQ 0x0020
#define IEEE802154_FCTL_SECEN 0x0004
#define IEEE802154_FCTL_INTRA_PAN 0x0040
+#define IEEE802154_FCTL_DADDR 0x0c00
#define IEEE802154_FTYPE_DATA 0x0001
+#define IEEE802154_FCTL_ADDR_NONE 0x0000
+#define IEEE802154_FCTL_DADDR_SHORT 0x0800
+#define IEEE802154_FCTL_DADDR_EXTENDED 0x0c00
+
/*
* ieee802154_is_data - check if type is IEEE802154_FTYPE_DATA
* @fc: frame control bytes in little-endian byteorder
@@ -261,6 +268,15 @@ static inline bool ieee802154_is_intra_pan(__le16 fc)
return fc & cpu_to_le16(IEEE802154_FCTL_INTRA_PAN);
}
+/*
+ * ieee802154_daddr_mode - get daddr mode from fc
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline __le16 ieee802154_daddr_mode(__le16 fc)
+{
+ return fc & cpu_to_le16(IEEE802154_FCTL_DADDR);
+}
+
/**
* ieee802154_is_valid_psdu_len - check if psdu len is valid
* available lengths:
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index e465c85..b3f7cd8 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -258,6 +258,35 @@ static inline __le16 ieee802154_get_fc_from_skb(const struct sk_buff *skb)
}
/**
+ * ieee802154_skb_dst_pan - get the pointer to destination pan field
+ * @fc: mac header frame control field
+ * @skb: skb where the destination pan pointer will be get from
+ */
+static inline unsigned char *ieee802154_skb_dst_pan(__le16 fc,
+ const struct sk_buff *skb)
+{
+ unsigned char *dst_pan;
+
+ switch (ieee802154_daddr_mode(fc)) {
+ case cpu_to_le16(IEEE802154_FCTL_ADDR_NONE):
+ dst_pan = NULL;
+ break;
+ case cpu_to_le16(IEEE802154_FCTL_DADDR_SHORT):
+ case cpu_to_le16(IEEE802154_FCTL_DADDR_EXTENDED):
+ dst_pan = skb_mac_header(skb) +
+ IEEE802154_FC_LEN +
+ IEEE802154_SEQ_LEN;
+ break;
+ default:
+ WARN_ONCE(1, "invalid addr mode detected");
+ dst_pan = NULL;
+ break;
+ }
+
+ return dst_pan;
+}
+
+/**
* ieee802154_be64_to_le64 - copies and convert be64 to le64
* @le64_dst: le64 destination pointer
* @be64_src: be64 source pointer
--
2.9.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCHv2 bluetooth-next 2/8] ieee802154: add ieee802154_skb_src_pan helper
2016-06-27 22:00 [PATCHv2 bluetooth-next 0/8] ieee802154: pending/new fixes and cleanup/features Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 1/8] ieee802154: add ieee802154_skb_dst_pan helper Alexander Aring
@ 2016-06-27 22:00 ` Alexander Aring
2016-06-28 10:28 ` Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 3/8] ieee802154: 6lowpan: fix intra pan id check Alexander Aring
` (5 subsequent siblings)
7 siblings, 1 reply; 10+ messages in thread
From: Alexander Aring @ 2016-06-27 22:00 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch adds ieee802154_skb_src_pan function to get the pointer
address of the source pan id at skb mac pointer.
Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
include/linux/ieee802154.h | 13 ++++++++++++
include/net/mac802154.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
index 91f4665..ddb8901 100644
--- a/include/linux/ieee802154.h
+++ b/include/linux/ieee802154.h
@@ -50,6 +50,7 @@
#define IEEE802154_EXTENDED_ADDR_LEN 8
#define IEEE802154_SHORT_ADDR_LEN 2
+#define IEEE802154_PAN_ID_LEN 2
#define IEEE802154_LIFS_PERIOD 40
#define IEEE802154_SIFS_PERIOD 12
@@ -224,12 +225,15 @@ enum {
#define IEEE802154_FCTL_SECEN 0x0004
#define IEEE802154_FCTL_INTRA_PAN 0x0040
#define IEEE802154_FCTL_DADDR 0x0c00
+#define IEEE802154_FCTL_SADDR 0xc000
#define IEEE802154_FTYPE_DATA 0x0001
#define IEEE802154_FCTL_ADDR_NONE 0x0000
#define IEEE802154_FCTL_DADDR_SHORT 0x0800
#define IEEE802154_FCTL_DADDR_EXTENDED 0x0c00
+#define IEEE802154_FCTL_SADDR_SHORT 0x8000
+#define IEEE802154_FCTL_SADDR_EXTENDED 0xc000
/*
* ieee802154_is_data - check if type is IEEE802154_FTYPE_DATA
@@ -277,6 +281,15 @@ static inline __le16 ieee802154_daddr_mode(__le16 fc)
return fc & cpu_to_le16(IEEE802154_FCTL_DADDR);
}
+/*
+ * ieee802154_saddr_mode - get saddr mode from fc
+ * @fc: frame control bytes in little-endian byteorder
+ */
+static inline __le16 ieee802154_saddr_mode(__le16 fc)
+{
+ return fc & cpu_to_le16(IEEE802154_FCTL_SADDR);
+}
+
/**
* ieee802154_is_valid_psdu_len - check if psdu len is valid
* available lengths:
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index b3f7cd8..5e73c5d 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -287,6 +287,56 @@ static inline unsigned char *ieee802154_skb_dst_pan(__le16 fc,
}
/**
+ * ieee802154_skb_src_pan - get the pointer to source pan field
+ * @fc: mac header frame control field
+ * @skb: skb where the source pan pointer will be get from
+ */
+static inline unsigned char *ieee802154_skb_src_pan(__le16 fc,
+ const struct sk_buff *skb)
+{
+ unsigned char *src_pan;
+
+ switch (ieee802154_saddr_mode(fc)) {
+ case cpu_to_le16(IEEE802154_FCTL_ADDR_NONE):
+ src_pan = NULL;
+ break;
+ case cpu_to_le16(IEEE802154_FCTL_SADDR_SHORT):
+ case cpu_to_le16(IEEE802154_FCTL_SADDR_EXTENDED):
+ src_pan = skb_mac_header(skb) +
+ IEEE802154_FC_LEN +
+ IEEE802154_SEQ_LEN;
+
+ switch (ieee802154_daddr_mode(fc)) {
+ case cpu_to_le16(IEEE802154_FCTL_ADDR_NONE):
+ break;
+ case cpu_to_le16(IEEE802154_FCTL_DADDR_SHORT):
+ if (!ieee802154_is_intra_pan(fc)) {
+ src_pan += IEEE802154_PAN_ID_LEN +
+ IEEE802154_SHORT_ADDR_LEN;
+ }
+ break;
+ case cpu_to_le16(IEEE802154_FCTL_DADDR_EXTENDED):
+ if (!ieee802154_is_intra_pan(fc)) {
+ src_pan += IEEE802154_PAN_ID_LEN +
+ IEEE802154_EXTENDED_ADDR_LEN;
+ }
+ break;
+ default:
+ WARN_ONCE(1, "invalid addr mode detected");
+ src_pan = NULL;
+ break;
+ }
+ break;
+ default:
+ WARN_ONCE(1, "invalid addr mode detected");
+ src_pan = NULL;
+ break;
+ }
+
+ return src_pan;
+}
+
+/**
* ieee802154_be64_to_le64 - copies and convert be64 to le64
* @le64_dst: le64 destination pointer
* @be64_src: be64 source pointer
--
2.9.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCHv2 bluetooth-next 3/8] ieee802154: 6lowpan: fix intra pan id check
2016-06-27 22:00 [PATCHv2 bluetooth-next 0/8] ieee802154: pending/new fixes and cleanup/features Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 1/8] ieee802154: add ieee802154_skb_dst_pan helper Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 2/8] ieee802154: add ieee802154_skb_src_pan helper Alexander Aring
@ 2016-06-27 22:00 ` Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 4/8] ieee802154: fix skb get fc on big endian Alexander Aring
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Alexander Aring @ 2016-06-27 22:00 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
The RIOT-OS stack does send intra-pan frames but don't set the intra pan
flag inside the mac header. It seems this is valid frame addressing but
inefficient. Anyway this patch adds a new function for intra pan
addressing, doesn't matter if intra pan flag or source and destination
are the same. The newly introduction function will be used to check on
intra pan addressing for 6lowpan.
Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
include/net/mac802154.h | 19 +++++++++++++++++++
net/ieee802154/6lowpan/rx.c | 2 +-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index 5e73c5d..b7f79bd 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -337,6 +337,25 @@ static inline unsigned char *ieee802154_skb_src_pan(__le16 fc,
}
/**
+ * ieee802154_skb_is_intra_pan_addressing - checks whenever the mac addressing
+ * is an intra pan communication
+ * @fc: mac header frame control field
+ * @skb: skb where the source and destination pan should be get from
+ */
+static inline bool ieee802154_skb_is_intra_pan_addressing(__le16 fc,
+ const struct sk_buff *skb)
+{
+ unsigned char *dst_pan = ieee802154_skb_dst_pan(fc, skb),
+ *src_pan = ieee802154_skb_src_pan(fc, skb);
+
+ /* if one is NULL is no intra pan addressing */
+ if (!dst_pan || !src_pan)
+ return false;
+
+ return !memcmp(dst_pan, src_pan, IEEE802154_PAN_ID_LEN);
+}
+
+/**
* ieee802154_be64_to_le64 - copies and convert be64 to le64
* @le64_dst: le64 destination pointer
* @be64_src: be64 source pointer
diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
index ef185dd..649e7d45 100644
--- a/net/ieee802154/6lowpan/rx.c
+++ b/net/ieee802154/6lowpan/rx.c
@@ -262,7 +262,7 @@ static inline bool lowpan_rx_h_check(struct sk_buff *skb)
/* check on ieee802154 conform 6LoWPAN header */
if (!ieee802154_is_data(fc) ||
- !ieee802154_is_intra_pan(fc))
+ !ieee802154_skb_is_intra_pan_addressing(fc, skb))
return false;
/* check if we can dereference the dispatch */
--
2.9.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCHv2 bluetooth-next 4/8] ieee802154: fix skb get fc on big endian
2016-06-27 22:00 [PATCHv2 bluetooth-next 0/8] ieee802154: pending/new fixes and cleanup/features Alexander Aring
` (2 preceding siblings ...)
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 3/8] ieee802154: 6lowpan: fix intra pan id check Alexander Aring
@ 2016-06-27 22:00 ` Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 5/8] 6lowpan: ndisc: set invalid unicast short addr to unspec Alexander Aring
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Alexander Aring @ 2016-06-27 22:00 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch fixes ieee802154_get_fc_from_skb function on big endian
machines. The function get_unaligned_le16 converts the byte order to
host byte order but we want to keep the byte order like in mac header.
Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
include/net/mac802154.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index b7f79bd..6500355 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -247,6 +247,8 @@ struct ieee802154_ops {
*/
static inline __le16 ieee802154_get_fc_from_skb(const struct sk_buff *skb)
{
+ __le16 fc;
+
/* check if we can fc at skb_mac_header of sk buffer */
if (unlikely(!skb_mac_header_was_set(skb) ||
(skb_tail_pointer(skb) - skb_mac_header(skb)) < 2)) {
@@ -254,7 +256,8 @@ static inline __le16 ieee802154_get_fc_from_skb(const struct sk_buff *skb)
return cpu_to_le16(0);
}
- return get_unaligned_le16(skb_mac_header(skb));
+ memcpy(&fc, skb_mac_header(skb), IEEE802154_FC_LEN);
+ return fc;
}
/**
--
2.9.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCHv2 bluetooth-next 5/8] 6lowpan: ndisc: set invalid unicast short addr to unspec
2016-06-27 22:00 [PATCHv2 bluetooth-next 0/8] ieee802154: pending/new fixes and cleanup/features Alexander Aring
` (3 preceding siblings ...)
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 4/8] ieee802154: fix skb get fc on big endian Alexander Aring
@ 2016-06-27 22:00 ` Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 6/8] atusb: don't change csma settings while set channel Alexander Aring
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Alexander Aring @ 2016-06-27 22:00 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring, linux-bluetooth
When receiving neighbour information with short address option field we
should check the complete range of invalid short addresses and set it to
one invalid address setting which is the unspecified address. This
address is also used when by creating at first a new neighbour entry to
indicate no short address is set.
Cc: linux-bluetooth@vger.kernel.org
Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
net/6lowpan/ndisc.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/6lowpan/ndisc.c b/net/6lowpan/ndisc.c
index 79c5fa9..86450b7 100644
--- a/net/6lowpan/ndisc.c
+++ b/net/6lowpan/ndisc.c
@@ -97,10 +97,13 @@ static void lowpan_ndisc_802154_update(struct neighbour *n, u32 flags,
}
write_lock_bh(&n->lock);
- if (lladdr_short)
+ if (lladdr_short) {
ieee802154_be16_to_le16(&neigh->short_addr, lladdr_short);
- else
+ if (!lowpan_802154_is_valid_src_short_addr(neigh->short_addr))
+ neigh->short_addr = cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC);
+ } else {
neigh->short_addr = cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC);
+ }
write_unlock_bh(&n->lock);
}
--
2.9.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCHv2 bluetooth-next 6/8] atusb: don't change csma settings while set channel
2016-06-27 22:00 [PATCHv2 bluetooth-next 0/8] ieee802154: pending/new fixes and cleanup/features Alexander Aring
` (4 preceding siblings ...)
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 5/8] 6lowpan: ndisc: set invalid unicast short addr to unspec Alexander Aring
@ 2016-06-27 22:00 ` Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 7/8] ieee802154: cleanup WARN_ON for fc fetch Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 8/8] fakelb: allow to run as monitor Alexander Aring
7 siblings, 0 replies; 10+ messages in thread
From: Alexander Aring @ 2016-06-27 22:00 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring, Stefan Schmidt
This patch fixes the behaviour to not overwrite csma settings when
set channel afterwards.
Cc: Stefan Schmidt <stefan@osg.samsung.com>
Acked-by: Stefan Schmidt <stefan@osg.samsung.com>
Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
drivers/net/ieee802154/atusb.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
index 52c9051..1056ed1 100644
--- a/drivers/net/ieee802154/atusb.c
+++ b/drivers/net/ieee802154/atusb.c
@@ -366,11 +366,7 @@ static int atusb_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
struct atusb *atusb = hw->priv;
int ret;
- /* This implicitly sets the CCA (Clear Channel Assessment) mode to 0,
- * "Mode 3a, Carrier sense OR energy above threshold".
- * We should probably make this configurable. @@@
- */
- ret = atusb_write_reg(atusb, RG_PHY_CC_CCA, channel);
+ ret = atusb_write_subreg(atusb, SR_CHANNEL, channel);
if (ret < 0)
return ret;
msleep(1); /* @@@ ugly synchronization */
--
2.9.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCHv2 bluetooth-next 7/8] ieee802154: cleanup WARN_ON for fc fetch
2016-06-27 22:00 [PATCHv2 bluetooth-next 0/8] ieee802154: pending/new fixes and cleanup/features Alexander Aring
` (5 preceding siblings ...)
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 6/8] atusb: don't change csma settings while set channel Alexander Aring
@ 2016-06-27 22:00 ` Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 8/8] fakelb: allow to run as monitor Alexander Aring
7 siblings, 0 replies; 10+ messages in thread
From: Alexander Aring @ 2016-06-27 22:00 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
This patch cleanups the WARN_ON which occurs when the sk buffer has
insufficient buffer space by moving the WARN_ON into if condition.
Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
include/net/mac802154.h | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index 6500355..b35aa2c 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -250,11 +250,10 @@ static inline __le16 ieee802154_get_fc_from_skb(const struct sk_buff *skb)
__le16 fc;
/* check if we can fc at skb_mac_header of sk buffer */
- if (unlikely(!skb_mac_header_was_set(skb) ||
- (skb_tail_pointer(skb) - skb_mac_header(skb)) < 2)) {
- WARN_ON(1);
+ if (WARN_ON(!skb_mac_header_was_set(skb) ||
+ (skb_tail_pointer(skb) -
+ skb_mac_header(skb)) < IEEE802154_FC_LEN))
return cpu_to_le16(0);
- }
memcpy(&fc, skb_mac_header(skb), IEEE802154_FC_LEN);
return fc;
--
2.9.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCHv2 bluetooth-next 8/8] fakelb: allow to run as monitor
2016-06-27 22:00 [PATCHv2 bluetooth-next 0/8] ieee802154: pending/new fixes and cleanup/features Alexander Aring
` (6 preceding siblings ...)
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 7/8] ieee802154: cleanup WARN_ON for fc fetch Alexander Aring
@ 2016-06-27 22:00 ` Alexander Aring
7 siblings, 0 replies; 10+ messages in thread
From: Alexander Aring @ 2016-06-27 22:00 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel, Alexander Aring
For my RIOT-OS in userspace experiments I need to create a fakelb
monitor interface. The fakelb doesn't filter anything on L2 and is a
purely raw interface. Because nl802154 checks on promiscuous mode which
need to supported by creating monitors this patch adds some no-op
promiscuous mode setting and the promiscuous flag.
Signed-off-by: Alexander Aring <aar@pengutronix.de>
---
drivers/net/ieee802154/fakelb.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c
index 860d4ae..0becf0a 100644
--- a/drivers/net/ieee802154/fakelb.c
+++ b/drivers/net/ieee802154/fakelb.c
@@ -112,6 +112,12 @@ static void fakelb_hw_stop(struct ieee802154_hw *hw)
write_unlock_bh(&fakelb_ifup_phys_lock);
}
+static int
+fakelb_set_promiscuous_mode(struct ieee802154_hw *hw, const bool on)
+{
+ return 0;
+}
+
static const struct ieee802154_ops fakelb_ops = {
.owner = THIS_MODULE,
.xmit_async = fakelb_hw_xmit,
@@ -119,6 +125,7 @@ static const struct ieee802154_ops fakelb_ops = {
.set_channel = fakelb_hw_channel,
.start = fakelb_hw_start,
.stop = fakelb_hw_stop,
+ .set_promiscuous_mode = fakelb_set_promiscuous_mode,
};
/* Number of dummy devices to be set up by this module. */
@@ -174,6 +181,7 @@ static int fakelb_add_one(struct device *dev)
hw->phy->current_channel = 13;
phy->channel = hw->phy->current_channel;
+ hw->flags = IEEE802154_HW_PROMISCUOUS;
hw->parent = dev;
err = ieee802154_register_hw(hw);
--
2.9.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCHv2 bluetooth-next 2/8] ieee802154: add ieee802154_skb_src_pan helper
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 2/8] ieee802154: add ieee802154_skb_src_pan helper Alexander Aring
@ 2016-06-28 10:28 ` Alexander Aring
0 siblings, 0 replies; 10+ messages in thread
From: Alexander Aring @ 2016-06-28 10:28 UTC (permalink / raw)
To: linux-wpan; +Cc: kernel
Hi,
On 06/28/2016 12:00 AM, Alexander Aring wrote:
> This patch adds ieee802154_skb_src_pan function to get the pointer
> address of the source pan id at skb mac pointer.
>
> Signed-off-by: Alexander Aring <aar@pengutronix.de>
> ---
> include/linux/ieee802154.h | 13 ++++++++++++
> include/net/mac802154.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 63 insertions(+)
>
...
>
> /**
> + * ieee802154_skb_src_pan - get the pointer to source pan field
> + * @fc: mac header frame control field
> + * @skb: skb where the source pan pointer will be get from
> + */
> +static inline unsigned char *ieee802154_skb_src_pan(__le16 fc,
> + const struct sk_buff *skb)
> +{
> + unsigned char *src_pan;
> +
> + switch (ieee802154_saddr_mode(fc)) {
> + case cpu_to_le16(IEEE802154_FCTL_ADDR_NONE):
> + src_pan = NULL;
> + break;
> + case cpu_to_le16(IEEE802154_FCTL_SADDR_SHORT):
> + case cpu_to_le16(IEEE802154_FCTL_SADDR_EXTENDED):
> + src_pan = skb_mac_header(skb) +
> + IEEE802154_FC_LEN +
> + IEEE802154_SEQ_LEN;
> +
> + switch (ieee802154_daddr_mode(fc)) {
> + case cpu_to_le16(IEEE802154_FCTL_ADDR_NONE):
This case is more complicated than it looks like:
If it's intra_pan and there is no destination pan (because daddr is
none), then the source pan should be NULL. If it's not intra_pan then
there is no destination address but source address is available with
own pan id field.
I will fix it in v3.
> + break;
> + case cpu_to_le16(IEEE802154_FCTL_DADDR_SHORT):
> + if (!ieee802154_is_intra_pan(fc)) {
> + src_pan += IEEE802154_PAN_ID_LEN +
> + IEEE802154_SHORT_ADDR_LEN;
> + }
> + break;
> + case cpu_to_le16(IEEE802154_FCTL_DADDR_EXTENDED):
> + if (!ieee802154_is_intra_pan(fc)) {
> + src_pan += IEEE802154_PAN_ID_LEN +
> + IEEE802154_EXTENDED_ADDR_LEN;
> + }
> + break;
> + default:
> + WARN_ONCE(1, "invalid addr mode detected");
> + src_pan = NULL;
> + break;
> + }
> + break;
- Alex
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-06-28 10:28 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-27 22:00 [PATCHv2 bluetooth-next 0/8] ieee802154: pending/new fixes and cleanup/features Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 1/8] ieee802154: add ieee802154_skb_dst_pan helper Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 2/8] ieee802154: add ieee802154_skb_src_pan helper Alexander Aring
2016-06-28 10:28 ` Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 3/8] ieee802154: 6lowpan: fix intra pan id check Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 4/8] ieee802154: fix skb get fc on big endian Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 5/8] 6lowpan: ndisc: set invalid unicast short addr to unspec Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 6/8] atusb: don't change csma settings while set channel Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 7/8] ieee802154: cleanup WARN_ON for fc fetch Alexander Aring
2016-06-27 22:00 ` [PATCHv2 bluetooth-next 8/8] fakelb: allow to run as monitor Alexander Aring
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.