From 82b322a37bcf890275f91b56a9a0347be056be9d Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 14 Apr 2024 15:43:59 -0700 Subject: Log protocol connections rejected by protocol. --- src/sp/protocol/reqrep0/xreq.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/sp/protocol/reqrep0/xreq.c') diff --git a/src/sp/protocol/reqrep0/xreq.c b/src/sp/protocol/reqrep0/xreq.c index 787c230d..b0ff301b 100644 --- a/src/sp/protocol/reqrep0/xreq.c +++ b/src/sp/protocol/reqrep0/xreq.c @@ -1,5 +1,5 @@ // -// Copyright 2021 Staysail Systems, Inc. +// Copyright 2024 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -21,14 +21,14 @@ typedef struct xreq0_sock xreq0_sock; // An xreq0_sock is our per-socket protocol private structure. struct xreq0_sock { - nni_msgq * uwq; - nni_msgq * urq; + nni_msgq *uwq; + nni_msgq *urq; nni_atomic_int ttl; }; // A req0_pipe is our per-pipe protocol private structure. struct xreq0_pipe { - nni_pipe * pipe; + nni_pipe *pipe; xreq0_sock *req; nni_aio aio_getq; nni_aio aio_send; @@ -115,6 +115,9 @@ xreq0_pipe_start(void *arg) xreq0_sock *s = p->req; if (nni_pipe_peer(p->pipe) != NNG_REQ0_PEER) { + nng_log_warn("NNG-PEER-MISMATCH", + "Peer protocol mismatch: %d != %d, rejected.", + nni_pipe_peer(p->pipe), NNG_REQ0_PEER); return (NNG_EPROTO); } @@ -193,7 +196,7 @@ xreq0_recv_cb(void *arg) { xreq0_pipe *p = arg; xreq0_sock *sock = p->req; - nni_msg * msg; + nni_msg *msg; bool end; if (nni_aio_result(&p->aio_recv) != 0) { @@ -218,7 +221,7 @@ xreq0_recv_cb(void *arg) body = nni_msg_body(msg); end = ((body[0] & 0x80u) != 0); - if (nng_msg_header_append(msg, body, sizeof (uint32_t)) != 0) { + if (nng_msg_header_append(msg, body, sizeof(uint32_t)) != 0) { // TODO: bump a no-memory stat nni_msg_free(msg); // Closing the pipe may release some memory. @@ -227,7 +230,7 @@ xreq0_recv_cb(void *arg) nni_pipe_close(p->pipe); return; } - nni_msg_trim(msg, sizeof (uint32_t)); + nni_msg_trim(msg, sizeof(uint32_t)); } nni_aio_set_msg(&p->aio_putq, msg); nni_msgq_aio_put(sock->urq, &p->aio_putq); -- cgit v1.2.3-70-g09d2