diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-04-14 15:43:59 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-04-14 18:52:56 -0700 |
| commit | 82b322a37bcf890275f91b56a9a0347be056be9d (patch) | |
| tree | 42a5f763f963c178b854e9326ef89f0d21582424 /src/sp/protocol/survey0/survey.c | |
| parent | 2b967f48a669f7199c40bc730f800e53d6d4fb72 (diff) | |
| download | nng-82b322a37bcf890275f91b56a9a0347be056be9d.tar.gz nng-82b322a37bcf890275f91b56a9a0347be056be9d.tar.bz2 nng-82b322a37bcf890275f91b56a9a0347be056be9d.zip | |
Log protocol connections rejected by protocol.
Diffstat (limited to 'src/sp/protocol/survey0/survey.c')
| -rw-r--r-- | src/sp/protocol/survey0/survey.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/src/sp/protocol/survey0/survey.c b/src/sp/protocol/survey0/survey.c index dc7346c7..3197f743 100644 --- a/src/sp/protocol/survey0/survey.c +++ b/src/sp/protocol/survey0/survey.c @@ -1,5 +1,5 @@ // -// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -27,7 +27,7 @@ static void surv0_pipe_send_cb(void *); static void surv0_pipe_recv_cb(void *); struct surv0_ctx { - surv0_sock * sock; + surv0_sock *sock; uint32_t survey_id; // survey id nni_lmq recv_lmq; nni_list recv_queue; @@ -51,8 +51,8 @@ struct surv0_sock { // surv0_pipe is our per-pipe protocol private structure. struct surv0_pipe { - nni_pipe * pipe; - surv0_sock * sock; + nni_pipe *pipe; + surv0_sock *sock; nni_lmq send_queue; nni_list_node node; nni_aio aio_send; @@ -64,7 +64,7 @@ struct surv0_pipe { static void surv0_ctx_abort(surv0_ctx *ctx, int err) { - nni_aio * aio; + nni_aio *aio; surv0_sock *sock = ctx->sock; while ((aio = nni_list_first(&ctx->recv_queue)) != NULL) { @@ -103,8 +103,8 @@ surv0_ctx_fini(void *arg) static void surv0_ctx_init(void *c, void *s) { - surv0_ctx * ctx = c; - surv0_sock * sock = s; + surv0_ctx *ctx = c; + surv0_sock *sock = s; int len; nng_duration tmo; @@ -131,7 +131,7 @@ surv0_ctx_init(void *c, void *s) static void surv0_ctx_cancel(nni_aio *aio, void *arg, int rv) { - surv0_ctx * ctx = arg; + surv0_ctx *ctx = arg; surv0_sock *sock = ctx->sock; nni_mtx_lock(&sock->mtx); if (nni_list_active(&ctx->recv_queue, aio)) { @@ -148,10 +148,10 @@ surv0_ctx_cancel(nni_aio *aio, void *arg, int rv) static void surv0_ctx_recv(void *arg, nni_aio *aio) { - surv0_ctx * ctx = arg; - surv0_sock *sock = ctx->sock; - nni_msg * msg; - nni_time now; + surv0_ctx *ctx = arg; + surv0_sock *sock = ctx->sock; + nni_msg *msg; + nni_time now; nni_duration timeout; if (nni_aio_begin(aio) != 0) { @@ -200,10 +200,10 @@ again: static void surv0_ctx_send(void *arg, nni_aio *aio) { - surv0_ctx * ctx = arg; - surv0_sock * sock = ctx->sock; - surv0_pipe * pipe; - nni_msg * msg = nni_aio_get_msg(aio); + surv0_ctx *ctx = arg; + surv0_sock *sock = ctx->sock; + surv0_pipe *pipe; + nni_msg *msg = nni_aio_get_msg(aio); size_t len = nni_msg_len(msg); nng_duration survey_time; int rv; @@ -360,6 +360,9 @@ surv0_pipe_start(void *arg) surv0_sock *s = p->sock; if (nni_pipe_peer(p->pipe) != NNG_SURVEYOR0_PEER) { + nng_log_warn("NNG-PEER-MISMATCH", + "Peer protocol mismatch: %d != %d, rejected.", + nni_pipe_peer(p->pipe), NNG_SURVEYOR0_PEER); return (NNG_EPROTO); } @@ -394,7 +397,7 @@ surv0_pipe_send_cb(void *arg) { surv0_pipe *p = arg; surv0_sock *sock = p->sock; - nni_msg * msg; + nni_msg *msg; if (nni_aio_result(&p->aio_send) != 0) { nni_msg_free(nni_aio_get_msg(&p->aio_send)); @@ -422,10 +425,10 @@ surv0_pipe_recv_cb(void *arg) { surv0_pipe *p = arg; surv0_sock *sock = p->sock; - surv0_ctx * ctx; - nni_msg * msg; + surv0_ctx *ctx; + nni_msg *msg; uint32_t id; - nni_aio * aio; + nni_aio *aio; if (nni_aio_result(&p->aio_recv) != 0) { nni_pipe_close(p->pipe); @@ -470,7 +473,7 @@ static int surv0_ctx_set_survey_time( void *arg, const void *buf, size_t sz, nni_opt_type t) { - surv0_ctx * ctx = arg; + surv0_ctx *ctx = arg; nng_duration expire; int rv; if ((rv = nni_copyin_ms(&expire, buf, sz, t)) == 0) { |
