X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Flibcollectdclient%2Fnetwork_parse.c;h=2365ab0addf575c037735654a3c992be8511b463;hb=890f917d8e907420f884a8d45af734575e13037c;hp=67034116b9f90a6b0e7f869c71713efdf2978de2;hpb=aecd05a0a0ec4d745506a67a937de6d1d6b33db5;p=collectd.git diff --git a/src/libcollectdclient/network_parse.c b/src/libcollectdclient/network_parse.c index 67034116..2365ab0a 100644 --- a/src/libcollectdclient/network_parse.c +++ b/src/libcollectdclient/network_parse.c @@ -43,6 +43,23 @@ #include #elif HAVE_SYS_ENDIAN_H #include +#else /* fallback */ +__attribute__((const)) static uint16_t be16toh(uint16_t n) { + uint8_t tmp[2]; + memmove(tmp, &n, sizeof(tmp)); + + return ((uint16_t)tmp[0] << 8) | ((uint16_t)tmp[1] << 0); +} + +__attribute__((const)) static uint64_t be64toh(uint64_t n) { + uint8_t tmp[8]; + memmove(tmp, &n, sizeof(tmp)); + + return ((uint64_t)tmp[0] << 56) | ((uint64_t)tmp[1] << 48) | + ((uint64_t)tmp[2] << 40) | ((uint64_t)tmp[3] << 32) | + ((uint64_t)tmp[4] << 24) | ((uint64_t)tmp[5] << 16) | + ((uint64_t)tmp[6] << 8) | ((uint64_t)tmp[7] << 0); +} #endif #if HAVE_GCRYPT_H