From 2e78e48503375a415d95ee8df80df9c065172abc Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Fri, 12 Feb 2010 20:49:00 +0100 Subject: Multi-hop REQ/REP, part V., peer identity is passed from init object to session --- src/object.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/object.cpp') diff --git a/src/object.cpp b/src/object.cpp index faa922e..73a17a3 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -17,6 +17,8 @@ along with this program. If not, see . */ +#include + #include "object.hpp" #include "dispatcher.hpp" #include "err.hpp" @@ -80,7 +82,9 @@ void zmq::object_t::process_command (command_t &cmd_) break; case command_t::attach: - process_attach (cmd_.args.attach.engine); + process_attach (cmd_.args.attach.engine, + cmd_.args.attach.peer_identity_size, + cmd_.args.attach.peer_identity); process_seqnum (); break; @@ -180,6 +184,7 @@ void zmq::object_t::send_own (socket_base_t *destination_, owned_t *object_) } void zmq::object_t::send_attach (session_t *destination_, i_engine *engine_, + unsigned char peer_identity_size_, unsigned char *peer_identity_, bool inc_seqnum_) { if (inc_seqnum_) @@ -189,6 +194,18 @@ void zmq::object_t::send_attach (session_t *destination_, i_engine *engine_, cmd.destination = destination_; cmd.type = command_t::attach; cmd.args.attach.engine = engine_; + if (!peer_identity_size_) { + cmd.args.attach.peer_identity_size = 0; + cmd.args.attach.peer_identity = NULL; + } + else { + cmd.args.attach.peer_identity_size = peer_identity_size_; + cmd.args.attach.peer_identity = + (unsigned char*) malloc (peer_identity_size_); + zmq_assert (cmd.args.attach.peer_identity_size); + memcpy (cmd.args.attach.peer_identity, peer_identity_, + peer_identity_size_); + } send_command (cmd); } @@ -271,7 +288,8 @@ void zmq::object_t::process_own (owned_t *object_) zmq_assert (false); } -void zmq::object_t::process_attach (i_engine *engine_) +void zmq::object_t::process_attach (i_engine *engine_, + unsigned char peer_identity_size_, unsigned char *peer_identity_) { zmq_assert (false); } -- cgit v1.2.3