From 15bde4c46b707f7a95c7ea6650a3f02d67e50530 Mon Sep 17 00:00:00 2001 From: David Timber Date: Mon, 12 Jul 2021 16:16:22 +1000 Subject: Impl proone-htbtclient, bugfix, --enable-mttools * Remove --enable-hostinfod and add --enable-mttools, which enables hostinfod and htbtclient * Change PRNE_HTBT_PROTO_PORT so that the macro can be used in another macro expression(for help message) * Add prne_mbedtls_perror() * proone-htbtclient: implement hostinfo command * proone-htbthost * Add --hostcred option * Response with status frame on ENOMEM * htbt: add prne_htbt_serrc_tostr() and prne_htbt_gen_msgid() * Add prne_ctoupper(), prne_ctolower(), prne_cisspace(), prne_cisprint() * The added functions are the locale-independent equivalent of their POSIX counterparts * Remove Use of the POSIX functions * Add test unit --- src/protocol.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/protocol.c') diff --git a/src/protocol.c b/src/protocol.c index f936787..6598ad8 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -1041,3 +1041,17 @@ char **prne_htbt_parse_args ( return ret; } + +uint16_t prne_htbt_gen_msgid (void *ctx, uint16_t(*rnd_f)(void*)) { + return (rnd_f(ctx) % PRNE_HTBT_MSG_ID_DELTA) + PRNE_HTBT_MSG_ID_MIN; +} + +const char *prne_htbt_serrc_tostr (const prne_htbt_ser_rc_t x) { + switch (x) { + case PRNE_HTBT_SER_RC_OK: return "ok"; + case PRNE_HTBT_SER_RC_MORE_BUF: return "more buf"; + case PRNE_HTBT_SER_RC_ERRNO: return "errno"; + case PRNE_HTBT_SER_RC_FMT_ERR: return "format error"; + } + return NULL; +} -- cgit