From 1d650869f32c56f6d49d898c38f7525191a60bd1 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 4 Jan 2017 02:10:13 -0800 Subject: Initial cut at TCP, totally untested beyond compilation. This also adds checks in the protocols to verify that pipe peers are of the proper protocol. --- src/protocol/reqrep/rep.c | 3 +++ src/protocol/reqrep/req.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/protocol/reqrep') diff --git a/src/protocol/reqrep/rep.c b/src/protocol/reqrep/rep.c index ca59d799..8c375b61 100644 --- a/src/protocol/reqrep/rep.c +++ b/src/protocol/reqrep/rep.c @@ -137,6 +137,9 @@ nni_rep_pipe_add(void *arg) nni_rep_sock *rep = rp->rep; int rv; + if (nni_pipe_peer(rp->pipe) != NNG_PROTO_REQ) { + return (NNG_EPROTO); + } nni_mtx_lock(&rep->mx); rv = nni_idhash_insert(rep->pipes, nni_pipe_id(rp->pipe), rp); nni_mtx_unlock(&rep->mx); diff --git a/src/protocol/reqrep/req.c b/src/protocol/reqrep/req.c index 4ce66ab6..b9981c3c 100644 --- a/src/protocol/reqrep/req.c +++ b/src/protocol/reqrep/req.c @@ -138,9 +138,10 @@ nni_req_pipe_fini(void *arg) static int nni_req_pipe_add(void *arg) { - // We have nothing to do, since we don't need to maintain a global - // list of related pipes. - NNI_ARG_UNUSED(arg); + nni_req_pipe *rp = arg; + if (nni_pipe_peer(rp->pipe) != NNG_PROTO_REP) { + return (NNG_EPROTO); + } return (0); } -- cgit v1.2.3-70-g09d2