X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Flibcollectdclient%2Fnetwork_parse.c;h=49b1a007b8920f079b8afcf0f7ef8788e905dcea;hp=67034116b9f90a6b0e7f869c71713efdf2978de2;hb=a9e50e9e30ecde17e167e271060c8183bfcbf407;hpb=aecd05a0a0ec4d745506a67a937de6d1d6b33db5 diff --git a/src/libcollectdclient/network_parse.c b/src/libcollectdclient/network_parse.c index 67034116..49b1a007 100644 --- a/src/libcollectdclient/network_parse.c +++ b/src/libcollectdclient/network_parse.c @@ -31,6 +31,7 @@ #include "collectd/lcc_features.h" #include "collectd/network_parse.h" +#include "globals.h" #include #include @@ -43,6 +44,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 @@ -432,7 +450,7 @@ static int decrypt_aes256(buffer_t *b, void *iv, size_t iv_size, uint8_t pwhash[32] = {0}; gcry_md_hash_buffer(GCRY_MD_SHA256, pwhash, password, strlen(password)); - fprintf(stderr, "sizeof(iv) = %zu\n", sizeof(iv)); + fprintf(stderr, "sizeof(iv) = %" PRIsz "\n", sizeof(iv)); if (gcry_cipher_setkey(cipher, pwhash, sizeof(pwhash)) || gcry_cipher_setiv(cipher, iv, iv_size) || gcry_cipher_decrypt(cipher, b->data, b->len, /* in = */ NULL, @@ -517,7 +535,7 @@ static int network_parse(void *data, size_t data_size, lcc_security_level_t sl, if ((sz < 5) || (((size_t)sz - 4) > b->len)) { DEBUG("lcc_network_parse(): invalid 'sz' field: sz = %" PRIu16 - ", b->len = %zu\n", + ", b->len = %" PRIsz "\n", sz, b->len); return EINVAL; }