6LoWPAN devices have an EUI-64 address rather than an EUI-48 address.
Use the full EUI-64 address when generating the clock identity to
avoid duplicates.

The constant ARPHRD_6LOWPAN is not yet present in the glibc version of
if_arp.h, so define it locally in missing.h if necessary.

Signed-off-by: Michael Brown <mbr...@fensystems.co.uk>
---

v2: Local definition of ARPHRD_6LOWPAN moved to missing.h as requested
    by Miroslav Lichvar

 missing.h | 5 +++++
 sk.c      | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/missing.h b/missing.h
index 16ae97a..d85c5ad 100644
--- a/missing.h
+++ b/missing.h
@@ -26,6 +26,7 @@
 #include <time.h>
 #include <sys/syscall.h>
 #include <sys/timex.h>
+#include <net/if_arp.h>
 #include <unistd.h>
 
 #ifndef ADJ_TAI
@@ -105,6 +106,10 @@ enum {
 #define IFLA_BOND_MAX   (__IFLA_BOND_MAX - 1)
 #endif /*IFLA_BOND_MAX*/
 
+#ifndef ARPHRD_6LOWPAN
+#define ARPHRD_6LOWPAN 825
+#endif
+
 #ifdef __UCLIBC__
 
 #if (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L) && \
diff --git a/sk.c b/sk.c
index 72926ab..6017206 100644
--- a/sk.c
+++ b/sk.c
@@ -238,6 +238,11 @@ int sk_interface_macaddr(const char *name, struct address 
*mac)
                        }
                        mac->sll.sll_halen = EUI64;
                        break;
+               case ARPHRD_6LOWPAN:
+                       memcpy(mac->sll.sll_addr, &ifreq.ifr_hwaddr.sa_data,
+                              GUID_LEN);
+                       mac->sll.sll_halen = EUI64;
+                       break;
                default:
                        memcpy(mac->sll.sll_addr, &ifreq.ifr_hwaddr.sa_data, 
MAC_LEN);
                        mac->sll.sll_halen = EUI48;
-- 
2.14.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to