diff options
author | David Timber <mieabby@gmail.com> | 2020-08-21 16:58:23 +0930 |
---|---|---|
committer | David Timber <mieabby@gmail.com> | 2020-08-21 16:58:23 +0930 |
commit | 076671e7aa28451de087088c2e47f9e6064ae434 (patch) | |
tree | 68c1bd3ed02c3491996a060cbeb4d4430366cdf6 /src/util_ct.h | |
parent | d1f520233b807f0ac4cc4019ce88759262f3c9bf (diff) |
Protocol change ...
* Add series of macros for protocol: prne_getmsbN() and prne_recmb_msgN()
* Bugfix: prne_nstreq()
* Protocol changes
* prne_htbt_host_info.rerun_cnt -> prne_htbt_host_info.crash_cnt
* prne_htbt_host_info.host_cred_len: range 0 - 255
* prne_htbt_host_info.host_cred is now base64 string
* prne_htbt_bin_meta.args_len: 16bit to 12bit
* Rest reserved bits
* And PRNE_HTBT_ARG_MEM_MAX is set to 4095
Diffstat (limited to 'src/util_ct.h')
-rw-r--r-- | src/util_ct.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/util_ct.h b/src/util_ct.h index b408808..4f40949 100644 --- a/src/util_ct.h +++ b/src/util_ct.h @@ -45,6 +45,44 @@ #define prne_dbgmast(expr, ...) #endif +/********************************************************************** +* Endianess Independent Byte Extraction +***********************************************************************/ +/* prne_getmsbN(x, n) +* +* Extract nth most significant byte of x. +*/ +#define prne_getmsb(x, n, w, s)\ + (uint8_t)(((w)(x) & (w)0xFF << (s - 8 * (n))) >> (s - 8 * (n))) +#define prne_getmsb64(x, n) prne_getmsb((x), (n), uint_fast64_t, 56) +#define prne_getmsb32(x, n) prne_getmsb((x), (n), uint_fast32_t, 24) +#define prne_getmsb16(x, n) prne_getmsb((x), (n), uint_fast16_t, 8) + +/* prne_recmb_msbN(...) +* +* Recombine bytes in big-endian order to uintN. +*/ +#define prne_recmb_msb64(a, b, c, d, e, f, g, h) (\ + ((uint_fast64_t)(a) << 56) |\ + ((uint_fast64_t)(b) << 48) |\ + ((uint_fast64_t)(c) << 40) |\ + ((uint_fast64_t)(d) << 32) |\ + ((uint_fast64_t)(e) << 24) |\ + ((uint_fast64_t)(f) << 16) |\ + ((uint_fast64_t)(g) << 8) |\ + ((uint_fast64_t)(h) << 0)\ +) +#define prne_recmb_msb32(a, b, c, d) (\ + ((uint_fast32_t)(a) << 24) |\ + ((uint_fast32_t)(b) << 16) |\ + ((uint_fast32_t)(c) << 8) |\ + ((uint_fast32_t)(d) << 0)\ +) +#define prne_recmb_msb16(a, b) (\ + ((uint_fast16_t)(a) << 8) |\ + ((uint_fast16_t)(b) << 0)\ +) + /* Machine Characteristics */ #define PRNE_ENDIAN_LITTLE 1 |