From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:46:44 +0000 (+0100) Subject: fix self id to allow for host byte order X-Git-Tag: 1.2~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f529c2243ef570e736355d0d463757fc0ae215a;p=thirdparty%2Fnqptp.git fix self id to allow for host byte order --- diff --git a/nqptp-utilities.c b/nqptp-utilities.c index b444e1e..aa3d2d3 100644 --- a/nqptp-utilities.c +++ b/nqptp-utilities.c @@ -18,6 +18,7 @@ */ #include "nqptp-utilities.h" +#include "general-utilities.h" #include #include // fcntl etc. #include // getifaddrs @@ -155,7 +156,7 @@ void debug_print_buffer(int level, char *buf, size_t buf_len) { uint64_t get_self_clock_id() { // make up a clock ID based on an interfaces' MAC - char local_clock_id[8]; + unsigned char local_clock_id[8]; int len = 0; struct ifaddrs *ifaddr = NULL; struct ifaddrs *ifa = NULL; @@ -205,8 +206,6 @@ uint64_t get_self_clock_id() { local_clock_id[3] = 0xFF; local_clock_id[4] = 0xFE; } - // it's in Network Byte Order! - uint64_t result; - memcpy(&result, local_clock_id, sizeof(result)); - return result; + // convert to host byte order + return nctoh64(local_clock_id); }