Re: [PATCH bluetooth-next 11/18] ieee802154: add ieee802154_random_extended_addr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Alex,

I have few doubts on this patch.

On Thursday 06 November 2014 01:21 AM, Alexander Aring wrote:

This patch adds a new function to generate a random IEEE 802.15.4
extended address.

Signed-off-by: Alexander Aring <alex.aring@xxxxxxxxx>
---
  include/linux/ieee802154.h | 14 ++++++++++++++
  1 file changed, 14 insertions(+)

diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
index a907fe5..d043449 100644
--- a/include/linux/ieee802154.h
+++ b/include/linux/ieee802154.h
@@ -24,6 +24,7 @@
  #define LINUX_IEEE802154_H
#include <linux/types.h>
+#include <linux/random.h>
  #include <asm/byteorder.h>
#define IEEE802154_MTU 127
@@ -215,4 +216,17 @@ static inline bool ieee802154_is_valid_extended_addr(const __le64 addr)
  		(addr != cpu_to_le64(0xffffffffffffffffULL)));
  }
+/**
+ * ieee802154_random_extended_addr - generates a random extended address
+ * @addr: extended addr pointer to place the random address
+ */
+static inline void ieee802154_random_extended_addr(__le64 *addr)

First of all why do we need this functionality. Extended address will be configured by the
user by using iz ..?

+{
+	get_random_bytes(addr, IEEE802154_EXTENDED_ADDR_LEN);
+

Here we are getting random bytes of 8.

+	/* toggle some bit if we hit an invalid extended addr */
+	if (!ieee802154_is_valid_extended_addr(*addr))
+		((u8 *)addr)[IEEE802154_EXTENDED_ADDR_LEN - 1] ^= 0x01;

If those 8 bytes not a valid addr, then you are toggling last bit, Why..?

+}
+
  #endif /* LINUX_IEEE802154_H */


--
Thanks and Regards,
Varka Bhadram.

--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux