aboutsummaryrefslogtreecommitdiff
path: root/src/proone-hostinfod.c
diff options
context:
space:
mode:
authorDavid Timber <mieabby@gmail.com>2021-09-11 11:11:40 +0800
committerDavid Timber <mieabby@gmail.com>2021-09-11 11:11:40 +0800
commiteb56a23613638ca705f5be707cacc1b0989a2a76 (patch)
tree09d8fe6e428608421c7062399d1821121d254af6 /src/proone-hostinfod.c
parent8219894fcb3c4c89b55a0dd0afcbbda4ded5aea3 (diff)
Use prne_htbt_gen_msgid() to unify msg_id gen algo
* Add PRNE_HTBT_MSG_ID_NOTIFY for protocol error w/o associated msg_id * Remove PRNE_HTBT_MSG_ID_MAX(wrong value)
Diffstat (limited to 'src/proone-hostinfod.c')
-rw-r--r--src/proone-hostinfod.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/proone-hostinfod.c b/src/proone-hostinfod.c
index ea6536b..97f4d09 100644
--- a/src/proone-hostinfod.c
+++ b/src/proone-hostinfod.c
@@ -1414,6 +1414,12 @@ END: // CATCH
return ret;
}
+static uint16_t gen_msgid (void *ctx) {
+ uint16_t ret = PRNE_HTBT_MSG_ID_MIN;
+ prne_rnd((prne_rnd_t*)ctx, (uint8_t*)&ret, sizeof(ret));
+ return ret;
+}
+
static int proc_client_stream (th_ctx_t *ctx, client_ctx_t *c) {
prne_htbt_msg_head_t mh;
prne_htbt_ser_rc_t src;
@@ -1444,10 +1450,7 @@ static int proc_client_stream (th_ctx_t *ctx, client_ctx_t *c) {
}
mh.op = PRNE_HTBT_OP_HOST_INFO;
- prne_rnd(&ctx->rnd, (uint8_t*)&mh.id, sizeof(mh.id));
- mh.id =
- PRNE_HTBT_MSG_ID_MIN +
- ((mh.id % PRNE_HTBT_MSG_ID_MAX) - PRNE_HTBT_MSG_ID_MIN);
+ mh.id = prne_htbt_gen_msgid(&ctx->rnd, gen_msgid);
prne_htbt_ser_msg_head(NULL, 0, &actual, &mh);
if (prne_alloc_iobuf(c->ib + 1, actual)) {