mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-19 00:46:05 +01:00
Problem: parameter naming style inconsistent
Solution: define and apply parameter naming style: lower_case_
This commit is contained in:
parent
79d5ac3dee
commit
c581f43c97
10
.clang-tidy
10
.clang-tidy
@ -42,7 +42,7 @@ Checks: "*,\
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: ''
|
||||
# AnalyzeTemporaryDtors: false
|
||||
# CheckOptions:
|
||||
CheckOptions:
|
||||
# - key: cert-dcl59-cpp.HeaderFileExtensions
|
||||
# value: h,hh,hpp,hxx
|
||||
# - key: cert-err61-cpp.CheckThrowTemporaries
|
||||
@ -287,8 +287,8 @@ HeaderFilterRegex: ''
|
||||
# value: ''
|
||||
# - key: readability-identifier-naming.NamespaceSuffix
|
||||
# value: ''
|
||||
# - key: readability-identifier-naming.ParameterCase
|
||||
# value: aNy_CasE
|
||||
- key: readability-identifier-naming.ParameterCase
|
||||
value: lower_case
|
||||
# - key: readability-identifier-naming.ParameterPackCase
|
||||
# value: aNy_CasE
|
||||
# - key: readability-identifier-naming.ParameterPackPrefix
|
||||
@ -297,8 +297,8 @@ HeaderFilterRegex: ''
|
||||
# value: ''
|
||||
# - key: readability-identifier-naming.ParameterPrefix
|
||||
# value: ''
|
||||
# - key: readability-identifier-naming.ParameterSuffix
|
||||
# value: ''
|
||||
- key: readability-identifier-naming.ParameterSuffix
|
||||
value: '_'
|
||||
# - key: readability-identifier-naming.PrivateMemberCase
|
||||
# value: aNy_CasE
|
||||
# - key: readability-identifier-naming.PrivateMemberPrefix
|
||||
|
124
include/zmq.h
124
include/zmq.h
@ -199,10 +199,10 @@ typedef unsigned __int8 uint8_t;
|
||||
ZMQ_EXPORT int zmq_errno (void);
|
||||
|
||||
/* Resolves system errors and 0MQ errors to human-readable string. */
|
||||
ZMQ_EXPORT const char *zmq_strerror (int errnum);
|
||||
ZMQ_EXPORT const char *zmq_strerror (int errnum_);
|
||||
|
||||
/* Run-time API version detection */
|
||||
ZMQ_EXPORT void zmq_version (int *major, int *minor, int *patch);
|
||||
ZMQ_EXPORT void zmq_version (int *major_, int *minor_, int *patch_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* 0MQ infrastructure (a.k.a. context) initialisation & termination. */
|
||||
@ -224,15 +224,15 @@ ZMQ_EXPORT void zmq_version (int *major, int *minor, int *patch);
|
||||
#define ZMQ_THREAD_SCHED_POLICY_DFLT -1
|
||||
|
||||
ZMQ_EXPORT void *zmq_ctx_new (void);
|
||||
ZMQ_EXPORT int zmq_ctx_term (void *context);
|
||||
ZMQ_EXPORT int zmq_ctx_shutdown (void *context);
|
||||
ZMQ_EXPORT int zmq_ctx_set (void *context, int option, int optval);
|
||||
ZMQ_EXPORT int zmq_ctx_get (void *context, int option);
|
||||
ZMQ_EXPORT int zmq_ctx_term (void *context_);
|
||||
ZMQ_EXPORT int zmq_ctx_shutdown (void *context_);
|
||||
ZMQ_EXPORT int zmq_ctx_set (void *context_, int option_, int optval_);
|
||||
ZMQ_EXPORT int zmq_ctx_get (void *context_, int option_);
|
||||
|
||||
/* Old (legacy) API */
|
||||
ZMQ_EXPORT void *zmq_init (int io_threads);
|
||||
ZMQ_EXPORT int zmq_term (void *context);
|
||||
ZMQ_EXPORT int zmq_ctx_destroy (void *context);
|
||||
ZMQ_EXPORT void *zmq_init (int io_threads_);
|
||||
ZMQ_EXPORT int zmq_term (void *context_);
|
||||
ZMQ_EXPORT int zmq_ctx_destroy (void *context_);
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
@ -258,24 +258,24 @@ typedef struct zmq_msg_t
|
||||
#endif
|
||||
} zmq_msg_t;
|
||||
|
||||
typedef void(zmq_free_fn) (void *data, void *hint);
|
||||
typedef void(zmq_free_fn) (void *data_, void *hint_);
|
||||
|
||||
ZMQ_EXPORT int zmq_msg_init (zmq_msg_t *msg);
|
||||
ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg, size_t size);
|
||||
ZMQ_EXPORT int zmq_msg_init (zmq_msg_t *msg_);
|
||||
ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg_, size_t size_);
|
||||
ZMQ_EXPORT int zmq_msg_init_data (
|
||||
zmq_msg_t *msg, void *data, size_t size, zmq_free_fn *ffn, void *hint);
|
||||
ZMQ_EXPORT int zmq_msg_send (zmq_msg_t *msg, void *s, int flags);
|
||||
ZMQ_EXPORT int zmq_msg_recv (zmq_msg_t *msg, void *s, int flags);
|
||||
ZMQ_EXPORT int zmq_msg_close (zmq_msg_t *msg);
|
||||
ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest, zmq_msg_t *src);
|
||||
ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src);
|
||||
ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg);
|
||||
ZMQ_EXPORT size_t zmq_msg_size (const zmq_msg_t *msg);
|
||||
ZMQ_EXPORT int zmq_msg_more (const zmq_msg_t *msg);
|
||||
ZMQ_EXPORT int zmq_msg_get (const zmq_msg_t *msg, int property);
|
||||
ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int property, int optval);
|
||||
ZMQ_EXPORT const char *zmq_msg_gets (const zmq_msg_t *msg,
|
||||
const char *property);
|
||||
zmq_msg_t *msg_, void *data_, size_t size_, zmq_free_fn *ffn_, void *hint_);
|
||||
ZMQ_EXPORT int zmq_msg_send (zmq_msg_t *msg_, void *s_, int flags_);
|
||||
ZMQ_EXPORT int zmq_msg_recv (zmq_msg_t *msg_, void *s_, int flags_);
|
||||
ZMQ_EXPORT int zmq_msg_close (zmq_msg_t *msg_);
|
||||
ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest_, zmq_msg_t *src_);
|
||||
ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest_, zmq_msg_t *src_);
|
||||
ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg_);
|
||||
ZMQ_EXPORT size_t zmq_msg_size (const zmq_msg_t *msg_);
|
||||
ZMQ_EXPORT int zmq_msg_more (const zmq_msg_t *msg_);
|
||||
ZMQ_EXPORT int zmq_msg_get (const zmq_msg_t *msg_, int property_);
|
||||
ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg_, int property_, int optval_);
|
||||
ZMQ_EXPORT const char *zmq_msg_gets (const zmq_msg_t *msg_,
|
||||
const char *property_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* 0MQ socket definition. */
|
||||
@ -438,20 +438,21 @@ ZMQ_EXPORT const char *zmq_msg_gets (const zmq_msg_t *msg,
|
||||
#define ZMQ_EVENT_MONITOR_STOPPED 0x0400
|
||||
#define ZMQ_EVENT_ALL 0xFFFF
|
||||
|
||||
ZMQ_EXPORT void *zmq_socket (void *, int type);
|
||||
ZMQ_EXPORT int zmq_close (void *s);
|
||||
ZMQ_EXPORT void *zmq_socket (void *, int type_);
|
||||
ZMQ_EXPORT int zmq_close (void *s_);
|
||||
ZMQ_EXPORT int
|
||||
zmq_setsockopt (void *s, int option, const void *optval, size_t optvallen);
|
||||
zmq_setsockopt (void *s_, int option_, const void *optval_, size_t optvallen_);
|
||||
ZMQ_EXPORT int
|
||||
zmq_getsockopt (void *s, int option, void *optval, size_t *optvallen);
|
||||
ZMQ_EXPORT int zmq_bind (void *s, const char *addr);
|
||||
ZMQ_EXPORT int zmq_connect (void *s, const char *addr);
|
||||
ZMQ_EXPORT int zmq_unbind (void *s, const char *addr);
|
||||
ZMQ_EXPORT int zmq_disconnect (void *s, const char *addr);
|
||||
ZMQ_EXPORT int zmq_send (void *s, const void *buf, size_t len, int flags);
|
||||
ZMQ_EXPORT int zmq_send_const (void *s, const void *buf, size_t len, int flags);
|
||||
ZMQ_EXPORT int zmq_recv (void *s, void *buf, size_t len, int flags);
|
||||
ZMQ_EXPORT int zmq_socket_monitor (void *s, const char *addr, int events);
|
||||
zmq_getsockopt (void *s_, int option_, void *optval_, size_t *optvallen_);
|
||||
ZMQ_EXPORT int zmq_bind (void *s_, const char *addr_);
|
||||
ZMQ_EXPORT int zmq_connect (void *s_, const char *addr_);
|
||||
ZMQ_EXPORT int zmq_unbind (void *s_, const char *addr_);
|
||||
ZMQ_EXPORT int zmq_disconnect (void *s_, const char *addr_);
|
||||
ZMQ_EXPORT int zmq_send (void *s_, const void *buf_, size_t len_, int flags_);
|
||||
ZMQ_EXPORT int
|
||||
zmq_send_const (void *s_, const void *buf_, size_t len_, int flags_);
|
||||
ZMQ_EXPORT int zmq_recv (void *s_, void *buf_, size_t len_, int flags_);
|
||||
ZMQ_EXPORT int zmq_socket_monitor (void *s_, const char *addr_, int events_);
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
@ -477,24 +478,24 @@ typedef struct zmq_pollitem_t
|
||||
|
||||
#define ZMQ_POLLITEMS_DFLT 16
|
||||
|
||||
ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout);
|
||||
ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Message proxying */
|
||||
/******************************************************************************/
|
||||
|
||||
ZMQ_EXPORT int zmq_proxy (void *frontend, void *backend, void *capture);
|
||||
ZMQ_EXPORT int zmq_proxy_steerable (void *frontend,
|
||||
void *backend,
|
||||
void *capture,
|
||||
void *control);
|
||||
ZMQ_EXPORT int zmq_proxy (void *frontend_, void *backend_, void *capture_);
|
||||
ZMQ_EXPORT int zmq_proxy_steerable (void *frontend_,
|
||||
void *backend_,
|
||||
void *capture_,
|
||||
void *control_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Probe library capabilities */
|
||||
/******************************************************************************/
|
||||
|
||||
#define ZMQ_HAS_CAPABILITIES 1
|
||||
ZMQ_EXPORT int zmq_has (const char *capability);
|
||||
ZMQ_EXPORT int zmq_has (const char *capability_);
|
||||
|
||||
/* Deprecated aliases */
|
||||
#define ZMQ_STREAMER 1
|
||||
@ -502,44 +503,45 @@ ZMQ_EXPORT int zmq_has (const char *capability);
|
||||
#define ZMQ_QUEUE 3
|
||||
|
||||
/* Deprecated methods */
|
||||
ZMQ_EXPORT int zmq_device (int type, void *frontend, void *backend);
|
||||
ZMQ_EXPORT int zmq_sendmsg (void *s, zmq_msg_t *msg, int flags);
|
||||
ZMQ_EXPORT int zmq_recvmsg (void *s, zmq_msg_t *msg, int flags);
|
||||
ZMQ_EXPORT int zmq_device (int type_, void *frontend_, void *backend_);
|
||||
ZMQ_EXPORT int zmq_sendmsg (void *s_, zmq_msg_t *msg_, int flags_);
|
||||
ZMQ_EXPORT int zmq_recvmsg (void *s_, zmq_msg_t *msg_, int flags_);
|
||||
struct iovec;
|
||||
ZMQ_EXPORT int
|
||||
zmq_sendiov (void *s, struct iovec *iov, size_t count, int flags);
|
||||
zmq_sendiov (void *s_, struct iovec *iov_, size_t count_, int flags_);
|
||||
ZMQ_EXPORT int
|
||||
zmq_recviov (void *s, struct iovec *iov, size_t *count, int flags);
|
||||
zmq_recviov (void *s_, struct iovec *iov_, size_t *count_, int flags_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Encryption functions */
|
||||
/******************************************************************************/
|
||||
|
||||
/* Encode data with Z85 encoding. Returns encoded data */
|
||||
ZMQ_EXPORT char *zmq_z85_encode (char *dest, const uint8_t *data, size_t size);
|
||||
ZMQ_EXPORT char *
|
||||
zmq_z85_encode (char *dest_, const uint8_t *data_, size_t size_);
|
||||
|
||||
/* Decode data with Z85 encoding. Returns decoded data */
|
||||
ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, const char *string);
|
||||
ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest_, const char *string_);
|
||||
|
||||
/* Generate z85-encoded public and private keypair with tweetnacl/libsodium. */
|
||||
/* Returns 0 on success. */
|
||||
ZMQ_EXPORT int zmq_curve_keypair (char *z85_public_key, char *z85_secret_key);
|
||||
ZMQ_EXPORT int zmq_curve_keypair (char *z85_public_key_, char *z85_secret_key_);
|
||||
|
||||
/* Derive the z85-encoded public key from the z85-encoded secret key. */
|
||||
/* Returns 0 on success. */
|
||||
ZMQ_EXPORT int zmq_curve_public (char *z85_public_key,
|
||||
const char *z85_secret_key);
|
||||
ZMQ_EXPORT int zmq_curve_public (char *z85_public_key_,
|
||||
const char *z85_secret_key_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Atomic utility methods */
|
||||
/******************************************************************************/
|
||||
|
||||
ZMQ_EXPORT void *zmq_atomic_counter_new (void);
|
||||
ZMQ_EXPORT void zmq_atomic_counter_set (void *counter, int value);
|
||||
ZMQ_EXPORT int zmq_atomic_counter_inc (void *counter);
|
||||
ZMQ_EXPORT int zmq_atomic_counter_dec (void *counter);
|
||||
ZMQ_EXPORT int zmq_atomic_counter_value (void *counter);
|
||||
ZMQ_EXPORT void zmq_atomic_counter_destroy (void **counter_p);
|
||||
ZMQ_EXPORT void zmq_atomic_counter_set (void *counter_, int value_);
|
||||
ZMQ_EXPORT int zmq_atomic_counter_inc (void *counter_);
|
||||
ZMQ_EXPORT int zmq_atomic_counter_dec (void *counter_);
|
||||
ZMQ_EXPORT int zmq_atomic_counter_value (void *counter_);
|
||||
ZMQ_EXPORT void zmq_atomic_counter_destroy (void **counter_p_);
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
@ -570,10 +572,10 @@ ZMQ_EXPORT void zmq_sleep (int seconds_);
|
||||
typedef void(zmq_thread_fn) (void *);
|
||||
|
||||
/* Start a thread. Returns a handle to the thread. */
|
||||
ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn *func, void *arg);
|
||||
ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn *func_, void *arg_);
|
||||
|
||||
/* Wait for thread to complete then free up resources. */
|
||||
ZMQ_EXPORT void zmq_threadclose (void *thread);
|
||||
ZMQ_EXPORT void zmq_threadclose (void *thread_);
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -143,34 +143,35 @@ class atomic_counter_t
|
||||
}
|
||||
|
||||
// Atomic subtraction. Returns false if the counter drops to zero.
|
||||
inline bool sub (integer_t decrement)
|
||||
inline bool sub (integer_t decrement_)
|
||||
{
|
||||
#if defined ZMQ_ATOMIC_COUNTER_WINDOWS
|
||||
LONG delta = -((LONG) decrement);
|
||||
LONG delta = -((LONG) decrement_);
|
||||
integer_t old = InterlockedExchangeAdd ((LONG *) &value, delta);
|
||||
return old - decrement != 0;
|
||||
return old - decrement_ != 0;
|
||||
#elif defined ZMQ_ATOMIC_COUNTER_INTRINSIC
|
||||
integer_t nv = __atomic_sub_fetch (&value, decrement, __ATOMIC_ACQ_REL);
|
||||
integer_t nv =
|
||||
__atomic_sub_fetch (&value, decrement_, __ATOMIC_ACQ_REL);
|
||||
return nv != 0;
|
||||
#elif defined ZMQ_ATOMIC_COUNTER_CXX11
|
||||
integer_t old = value.fetch_sub (decrement, std::memory_order_acq_rel);
|
||||
return old - decrement != 0;
|
||||
integer_t old = value.fetch_sub (decrement_, std::memory_order_acq_rel);
|
||||
return old - decrement_ != 0;
|
||||
#elif defined ZMQ_ATOMIC_COUNTER_ATOMIC_H
|
||||
int32_t delta = -((int32_t) decrement);
|
||||
int32_t delta = -((int32_t) decrement_);
|
||||
integer_t nv = atomic_add_32_nv (&value, delta);
|
||||
return nv != 0;
|
||||
#elif defined ZMQ_ATOMIC_COUNTER_TILE
|
||||
int32_t delta = -((int32_t) decrement);
|
||||
int32_t delta = -((int32_t) decrement_);
|
||||
integer_t nv = arch_atomic_add (&value, delta);
|
||||
return nv != 0;
|
||||
#elif defined ZMQ_ATOMIC_COUNTER_X86
|
||||
integer_t oldval = -decrement;
|
||||
integer_t oldval = -decrement_;
|
||||
volatile integer_t *val = &value;
|
||||
__asm__ volatile("lock; xaddl %0,%1"
|
||||
: "=r"(oldval), "=m"(*val)
|
||||
: "0"(oldval), "m"(*val)
|
||||
: "cc", "memory");
|
||||
return oldval != decrement;
|
||||
return oldval != decrement_;
|
||||
#elif defined ZMQ_ATOMIC_COUNTER_ARM
|
||||
integer_t old_value, flag, tmp;
|
||||
__asm__ volatile(" dmb sy\n\t"
|
||||
@ -182,12 +183,12 @@ class atomic_counter_t
|
||||
" dmb sy\n\t"
|
||||
: "=&r"(old_value), "=&r"(flag), "=&r"(tmp),
|
||||
"+Qo"(value)
|
||||
: "Ir"(decrement), "r"(&value)
|
||||
: "Ir"(decrement_), "r"(&value)
|
||||
: "cc");
|
||||
return old_value - decrement != 0;
|
||||
#elif defined ZMQ_ATOMIC_COUNTER_MUTEX
|
||||
sync.lock ();
|
||||
value -= decrement;
|
||||
value -= decrement_;
|
||||
bool result = value ? true : false;
|
||||
sync.unlock ();
|
||||
return result;
|
||||
|
@ -242,7 +242,7 @@ struct atomic_value_t
|
||||
{
|
||||
atomic_value_t (const int value_) : value (value_) {}
|
||||
|
||||
atomic_value_t (const atomic_value_t &src) : value (src.load ()) {}
|
||||
atomic_value_t (const atomic_value_t &src_) : value (src_.load ()) {}
|
||||
|
||||
void store (const int value_)
|
||||
{
|
||||
@ -288,7 +288,7 @@ struct atomic_value_t
|
||||
#endif
|
||||
|
||||
private:
|
||||
atomic_value_t &operator= (const atomic_value_t &src);
|
||||
atomic_value_t &operator= (const atomic_value_t &src_);
|
||||
};
|
||||
}
|
||||
|
||||
|
69
src/blob.hpp
69
src/blob.hpp
@ -74,9 +74,9 @@ struct blob_t
|
||||
blob_t () : data_ (0), size_ (0), owned_ (true) {}
|
||||
|
||||
// Creates a blob_t of a given size, with uninitialized content.
|
||||
explicit blob_t (const size_t size) :
|
||||
data_ (static_cast<unsigned char *> (malloc (size))),
|
||||
size_ (size),
|
||||
explicit blob_t (const size_t size_) :
|
||||
data_ (static_cast<unsigned char *> (malloc (size_))),
|
||||
size_ (size_),
|
||||
owned_ (true)
|
||||
{
|
||||
alloc_assert (data_);
|
||||
@ -84,22 +84,22 @@ struct blob_t
|
||||
|
||||
// Creates a blob_t of a given size, an initializes content by copying
|
||||
// from another buffer.
|
||||
blob_t (const unsigned char *const data, const size_t size) :
|
||||
data_ (static_cast<unsigned char *> (malloc (size))),
|
||||
size_ (size),
|
||||
blob_t (const unsigned char *const data_, const size_t size_) :
|
||||
data_ (static_cast<unsigned char *> (malloc (size_))),
|
||||
size_ (size_),
|
||||
owned_ (true)
|
||||
{
|
||||
alloc_assert (data_);
|
||||
memcpy (data_, data, size_);
|
||||
alloc_assert (this->data_);
|
||||
memcpy (this->data_, data_, size_);
|
||||
}
|
||||
|
||||
// Creates a blob_t for temporary use that only references a
|
||||
// pre-allocated block of data.
|
||||
// Use with caution and ensure that the blob_t will not outlive
|
||||
// the referenced data.
|
||||
blob_t (unsigned char *const data, const size_t size, reference_tag_t) :
|
||||
data_ (data),
|
||||
size_ (size),
|
||||
blob_t (unsigned char *const data_, const size_t size_, reference_tag_t) :
|
||||
data_ (data_),
|
||||
size_ (size_),
|
||||
owned_ (false)
|
||||
{
|
||||
}
|
||||
@ -114,32 +114,33 @@ struct blob_t
|
||||
unsigned char *data () { return data_; }
|
||||
|
||||
// Defines an order relationship on blob_t.
|
||||
bool operator< (blob_t const &other) const
|
||||
bool operator< (blob_t const &other_) const
|
||||
{
|
||||
int cmpres = memcmp (data_, other.data_, std::min (size_, other.size_));
|
||||
return cmpres < 0 || (cmpres == 0 && size_ < other.size_);
|
||||
int cmpres =
|
||||
memcmp (data_, other_.data_, std::min (size_, other_.size_));
|
||||
return cmpres < 0 || (cmpres == 0 && size_ < other_.size_);
|
||||
}
|
||||
|
||||
// Sets a blob_t to a deep copy of another blob_t.
|
||||
void set_deep_copy (blob_t const &other)
|
||||
void set_deep_copy (blob_t const &other_)
|
||||
{
|
||||
clear ();
|
||||
data_ = static_cast<unsigned char *> (malloc (other.size_));
|
||||
data_ = static_cast<unsigned char *> (malloc (other_.size_));
|
||||
alloc_assert (data_);
|
||||
size_ = other.size_;
|
||||
size_ = other_.size_;
|
||||
owned_ = true;
|
||||
memcpy (data_, other.data_, size_);
|
||||
memcpy (data_, other_.data_, size_);
|
||||
}
|
||||
|
||||
// Sets a blob_t to a copy of a given buffer.
|
||||
void set (const unsigned char *const data, const size_t size)
|
||||
void set (const unsigned char *const data_, const size_t size_)
|
||||
{
|
||||
clear ();
|
||||
data_ = static_cast<unsigned char *> (malloc (size));
|
||||
alloc_assert (data_);
|
||||
size_ = size;
|
||||
this->data_ = static_cast<unsigned char *> (malloc (size_));
|
||||
alloc_assert (this->data_);
|
||||
this->size_ = size_;
|
||||
owned_ = true;
|
||||
memcpy (data_, data, size_);
|
||||
memcpy (this->data_, data_, size_);
|
||||
}
|
||||
|
||||
// Empties a blob_t.
|
||||
@ -163,21 +164,21 @@ struct blob_t
|
||||
blob_t (const blob_t &) = delete;
|
||||
blob_t &operator= (const blob_t &) = delete;
|
||||
|
||||
blob_t (blob_t &&other) :
|
||||
data_ (other.data_),
|
||||
size_ (other.size_),
|
||||
owned_ (other.owned_)
|
||||
blob_t (blob_t &&other_) :
|
||||
data_ (other_.data_),
|
||||
size_ (other_.size_),
|
||||
owned_ (other_.owned_)
|
||||
{
|
||||
other.owned_ = false;
|
||||
other_.owned_ = false;
|
||||
}
|
||||
blob_t &operator= (blob_t &&other)
|
||||
blob_t &operator= (blob_t &&other_)
|
||||
{
|
||||
if (this != &other) {
|
||||
if (this != &other_) {
|
||||
clear ();
|
||||
data_ = other.data_;
|
||||
size_ = other.size_;
|
||||
owned_ = other.owned_;
|
||||
other.owned_ = false;
|
||||
data_ = other_.data_;
|
||||
size_ = other_.size_;
|
||||
owned_ = other_.owned_;
|
||||
other_.owned_ = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class io_thread_t;
|
||||
class client_t : public socket_base_t
|
||||
{
|
||||
public:
|
||||
client_t (zmq::ctx_t *parent_, uint32_t tid_, int sid);
|
||||
client_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||
~client_t ();
|
||||
|
||||
protected:
|
||||
|
26
src/ctx.cpp
26
src/ctx.cpp
@ -55,14 +55,14 @@
|
||||
#define ZMQ_CTX_TAG_VALUE_GOOD 0xabadcafe
|
||||
#define ZMQ_CTX_TAG_VALUE_BAD 0xdeadbeef
|
||||
|
||||
int clipped_maxsocket (int max_requested)
|
||||
int clipped_maxsocket (int max_requested_)
|
||||
{
|
||||
if (max_requested >= zmq::poller_t::max_fds ()
|
||||
if (max_requested_ >= zmq::poller_t::max_fds ()
|
||||
&& zmq::poller_t::max_fds () != -1)
|
||||
// -1 because we need room for the reaper mailbox.
|
||||
max_requested = zmq::poller_t::max_fds () - 1;
|
||||
max_requested_ = zmq::poller_t::max_fds () - 1;
|
||||
|
||||
return max_requested;
|
||||
return max_requested_;
|
||||
}
|
||||
|
||||
zmq::ctx_t::ctx_t () :
|
||||
@ -608,14 +608,14 @@ void zmq::ctx_t::connect_pending (const char *addr_,
|
||||
|
||||
void zmq::ctx_t::connect_inproc_sockets (
|
||||
zmq::socket_base_t *bind_socket_,
|
||||
options_t &bind_options,
|
||||
options_t &bind_options_,
|
||||
const pending_connection_t &pending_connection_,
|
||||
side side_)
|
||||
{
|
||||
bind_socket_->inc_seqnum ();
|
||||
pending_connection_.bind_pipe->set_tid (bind_socket_->get_tid ());
|
||||
|
||||
if (!bind_options.recv_routing_id) {
|
||||
if (!bind_options_.recv_routing_id) {
|
||||
msg_t msg;
|
||||
const bool ok = pending_connection_.bind_pipe->read (&msg);
|
||||
zmq_assert (ok);
|
||||
@ -632,8 +632,8 @@ void zmq::ctx_t::connect_inproc_sockets (
|
||||
|| pending_connection_.endpoint.options.type == ZMQ_SUB);
|
||||
|
||||
if (!conflate) {
|
||||
pending_connection_.connect_pipe->set_hwms_boost (bind_options.sndhwm,
|
||||
bind_options.rcvhwm);
|
||||
pending_connection_.connect_pipe->set_hwms_boost (bind_options_.sndhwm,
|
||||
bind_options_.rcvhwm);
|
||||
pending_connection_.bind_pipe->set_hwms_boost (
|
||||
pending_connection_.endpoint.options.sndhwm,
|
||||
pending_connection_.endpoint.options.rcvhwm);
|
||||
@ -641,8 +641,8 @@ void zmq::ctx_t::connect_inproc_sockets (
|
||||
pending_connection_.connect_pipe->set_hwms (
|
||||
pending_connection_.endpoint.options.rcvhwm,
|
||||
pending_connection_.endpoint.options.sndhwm);
|
||||
pending_connection_.bind_pipe->set_hwms (bind_options.rcvhwm,
|
||||
bind_options.sndhwm);
|
||||
pending_connection_.bind_pipe->set_hwms (bind_options_.rcvhwm,
|
||||
bind_options_.sndhwm);
|
||||
} else {
|
||||
pending_connection_.connect_pipe->set_hwms (-1, -1);
|
||||
pending_connection_.bind_pipe->set_hwms (-1, -1);
|
||||
@ -667,10 +667,10 @@ void zmq::ctx_t::connect_inproc_sockets (
|
||||
if (pending_connection_.endpoint.options.recv_routing_id
|
||||
&& pending_connection_.endpoint.socket->check_tag ()) {
|
||||
msg_t routing_id;
|
||||
const int rc = routing_id.init_size (bind_options.routing_id_size);
|
||||
const int rc = routing_id.init_size (bind_options_.routing_id_size);
|
||||
errno_assert (rc == 0);
|
||||
memcpy (routing_id.data (), bind_options.routing_id,
|
||||
bind_options.routing_id_size);
|
||||
memcpy (routing_id.data (), bind_options_.routing_id,
|
||||
bind_options_.routing_id_size);
|
||||
routing_id.set_flags (msg_t::routing_id);
|
||||
const bool written = pending_connection_.bind_pipe->write (&routing_id);
|
||||
zmq_assert (written);
|
||||
|
@ -251,7 +251,7 @@ class ctx_t : public thread_ctx_t
|
||||
};
|
||||
void
|
||||
connect_inproc_sockets (zmq::socket_base_t *bind_socket_,
|
||||
options_t &bind_options,
|
||||
options_t &bind_options_,
|
||||
const pending_connection_t &pending_connection_,
|
||||
side side_);
|
||||
|
||||
|
@ -154,10 +154,10 @@ int zmq::curve_client_t::produce_hello (msg_t *msg_)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int zmq::curve_client_t::process_welcome (const uint8_t *msg_data,
|
||||
size_t msg_size)
|
||||
int zmq::curve_client_t::process_welcome (const uint8_t *msg_data_,
|
||||
size_t msg_size_)
|
||||
{
|
||||
int rc = tools.process_welcome (msg_data, msg_size, cn_precom);
|
||||
int rc = tools.process_welcome (msg_data_, msg_size_, cn_precom);
|
||||
|
||||
if (rc == -1) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
@ -203,10 +203,10 @@ int zmq::curve_client_t::produce_initiate (msg_t *msg_)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int zmq::curve_client_t::process_ready (const uint8_t *msg_data,
|
||||
size_t msg_size)
|
||||
int zmq::curve_client_t::process_ready (const uint8_t *msg_data_,
|
||||
size_t msg_size_)
|
||||
{
|
||||
if (msg_size < 30) {
|
||||
if (msg_size_ < 30) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
session->get_endpoint (),
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_READY);
|
||||
@ -214,7 +214,7 @@ int zmq::curve_client_t::process_ready (const uint8_t *msg_data,
|
||||
return -1;
|
||||
}
|
||||
|
||||
const size_t clen = (msg_size - 14) + crypto_box_BOXZEROBYTES;
|
||||
const size_t clen = (msg_size_ - 14) + crypto_box_BOXZEROBYTES;
|
||||
|
||||
uint8_t ready_nonce[crypto_box_NONCEBYTES];
|
||||
uint8_t *ready_plaintext =
|
||||
@ -225,12 +225,12 @@ int zmq::curve_client_t::process_ready (const uint8_t *msg_data,
|
||||
alloc_assert (ready_box);
|
||||
|
||||
memset (ready_box, 0, crypto_box_BOXZEROBYTES);
|
||||
memcpy (ready_box + crypto_box_BOXZEROBYTES, msg_data + 14,
|
||||
memcpy (ready_box + crypto_box_BOXZEROBYTES, msg_data_ + 14,
|
||||
clen - crypto_box_BOXZEROBYTES);
|
||||
|
||||
memcpy (ready_nonce, "CurveZMQREADY---", 16);
|
||||
memcpy (ready_nonce + 16, msg_data + 6, 8);
|
||||
cn_peer_nonce = get_uint64 (msg_data + 6);
|
||||
memcpy (ready_nonce + 16, msg_data_ + 6, 8);
|
||||
cn_peer_nonce = get_uint64 (msg_data_ + 6);
|
||||
|
||||
int rc = crypto_box_open_afternm (ready_plaintext, ready_box, clen,
|
||||
ready_nonce, cn_precom);
|
||||
@ -258,8 +258,8 @@ int zmq::curve_client_t::process_ready (const uint8_t *msg_data,
|
||||
return rc;
|
||||
}
|
||||
|
||||
int zmq::curve_client_t::process_error (const uint8_t *msg_data,
|
||||
size_t msg_size)
|
||||
int zmq::curve_client_t::process_error (const uint8_t *msg_data_,
|
||||
size_t msg_size_)
|
||||
{
|
||||
if (state != expect_welcome && state != expect_ready) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
@ -267,22 +267,22 @@ int zmq::curve_client_t::process_error (const uint8_t *msg_data,
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
if (msg_size < 7) {
|
||||
if (msg_size_ < 7) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
session->get_endpoint (),
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR);
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
const size_t error_reason_len = static_cast<size_t> (msg_data[6]);
|
||||
if (error_reason_len > msg_size - 7) {
|
||||
const size_t error_reason_len = static_cast<size_t> (msg_data_[6]);
|
||||
if (error_reason_len > msg_size_ - 7) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
session->get_endpoint (),
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR);
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
const char *error_reason = reinterpret_cast<const char *> (msg_data) + 7;
|
||||
const char *error_reason = reinterpret_cast<const char *> (msg_data_) + 7;
|
||||
handle_error_reason (error_reason, error_reason_len);
|
||||
state = error_received;
|
||||
return 0;
|
||||
|
@ -72,10 +72,10 @@ class curve_client_t : public curve_mechanism_base_t
|
||||
curve_client_tools_t tools;
|
||||
|
||||
int produce_hello (msg_t *msg_);
|
||||
int process_welcome (const uint8_t *cmd_data, size_t data_size);
|
||||
int process_welcome (const uint8_t *cmd_data_, size_t data_size_);
|
||||
int produce_initiate (msg_t *msg_);
|
||||
int process_ready (const uint8_t *cmd_data, size_t data_size);
|
||||
int process_error (const uint8_t *cmd_data, size_t data_size);
|
||||
int process_ready (const uint8_t *cmd_data_, size_t data_size_);
|
||||
int process_error (const uint8_t *cmd_data_, size_t data_size_);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -51,11 +51,11 @@ namespace zmq
|
||||
{
|
||||
struct curve_client_tools_t
|
||||
{
|
||||
static int produce_hello (void *data,
|
||||
const uint8_t *server_key,
|
||||
const uint64_t cn_nonce,
|
||||
const uint8_t *cn_public,
|
||||
const uint8_t *cn_secret)
|
||||
static int produce_hello (void *data_,
|
||||
const uint8_t *server_key_,
|
||||
const uint64_t cn_nonce_,
|
||||
const uint8_t *cn_public_,
|
||||
const uint8_t *cn_secret_)
|
||||
{
|
||||
uint8_t hello_nonce[crypto_box_NONCEBYTES];
|
||||
uint8_t hello_plaintext[crypto_box_ZEROBYTES + 64];
|
||||
@ -63,17 +63,17 @@ struct curve_client_tools_t
|
||||
|
||||
// Prepare the full nonce
|
||||
memcpy (hello_nonce, "CurveZMQHELLO---", 16);
|
||||
put_uint64 (hello_nonce + 16, cn_nonce);
|
||||
put_uint64 (hello_nonce + 16, cn_nonce_);
|
||||
|
||||
// Create Box [64 * %x0](C'->S)
|
||||
memset (hello_plaintext, 0, sizeof hello_plaintext);
|
||||
|
||||
int rc = crypto_box (hello_box, hello_plaintext, sizeof hello_plaintext,
|
||||
hello_nonce, server_key, cn_secret);
|
||||
hello_nonce, server_key_, cn_secret_);
|
||||
if (rc == -1)
|
||||
return -1;
|
||||
|
||||
uint8_t *hello = static_cast<uint8_t *> (data);
|
||||
uint8_t *hello = static_cast<uint8_t *> (data_);
|
||||
|
||||
memcpy (hello, "\x05HELLO", 6);
|
||||
// CurveZMQ major and minor version numbers
|
||||
@ -81,7 +81,7 @@ struct curve_client_tools_t
|
||||
// Anti-amplification padding
|
||||
memset (hello + 8, 0, 72);
|
||||
// Client public connection key
|
||||
memcpy (hello + 80, cn_public, crypto_box_PUBLICKEYBYTES);
|
||||
memcpy (hello + 80, cn_public_, crypto_box_PUBLICKEYBYTES);
|
||||
// Short nonce, prefixed by "CurveZMQHELLO---"
|
||||
memcpy (hello + 112, hello_nonce + 16, 8);
|
||||
// Signature, Box [64 * %x0](C'->S)
|
||||
@ -90,15 +90,15 @@ struct curve_client_tools_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_welcome (const uint8_t *msg_data,
|
||||
size_t msg_size,
|
||||
const uint8_t *server_key,
|
||||
const uint8_t *cn_secret,
|
||||
uint8_t *cn_server,
|
||||
uint8_t *cn_cookie,
|
||||
uint8_t *cn_precom)
|
||||
static int process_welcome (const uint8_t *msg_data_,
|
||||
size_t msg_size_,
|
||||
const uint8_t *server_key_,
|
||||
const uint8_t *cn_secret_,
|
||||
uint8_t *cn_server_,
|
||||
uint8_t *cn_cookie_,
|
||||
uint8_t *cn_precom_)
|
||||
{
|
||||
if (msg_size != 168) {
|
||||
if (msg_size_ != 168) {
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
@ -109,42 +109,42 @@ struct curve_client_tools_t
|
||||
|
||||
// Open Box [S' + cookie](C'->S)
|
||||
memset (welcome_box, 0, crypto_box_BOXZEROBYTES);
|
||||
memcpy (welcome_box + crypto_box_BOXZEROBYTES, msg_data + 24, 144);
|
||||
memcpy (welcome_box + crypto_box_BOXZEROBYTES, msg_data_ + 24, 144);
|
||||
|
||||
memcpy (welcome_nonce, "WELCOME-", 8);
|
||||
memcpy (welcome_nonce + 8, msg_data + 8, 16);
|
||||
memcpy (welcome_nonce + 8, msg_data_ + 8, 16);
|
||||
|
||||
int rc =
|
||||
crypto_box_open (welcome_plaintext, welcome_box, sizeof welcome_box,
|
||||
welcome_nonce, server_key, cn_secret);
|
||||
welcome_nonce, server_key_, cn_secret_);
|
||||
if (rc != 0) {
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy (cn_server, welcome_plaintext + crypto_box_ZEROBYTES, 32);
|
||||
memcpy (cn_cookie, welcome_plaintext + crypto_box_ZEROBYTES + 32,
|
||||
memcpy (cn_server_, welcome_plaintext + crypto_box_ZEROBYTES, 32);
|
||||
memcpy (cn_cookie_, welcome_plaintext + crypto_box_ZEROBYTES + 32,
|
||||
16 + 80);
|
||||
|
||||
// Message independent precomputation
|
||||
rc = crypto_box_beforenm (cn_precom, cn_server, cn_secret);
|
||||
rc = crypto_box_beforenm (cn_precom_, cn_server_, cn_secret_);
|
||||
zmq_assert (rc == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int produce_initiate (void *data,
|
||||
size_t size,
|
||||
const uint64_t cn_nonce,
|
||||
const uint8_t *server_key,
|
||||
const uint8_t *public_key,
|
||||
const uint8_t *secret_key,
|
||||
const uint8_t *cn_public,
|
||||
const uint8_t *cn_secret,
|
||||
const uint8_t *cn_server,
|
||||
const uint8_t *cn_cookie,
|
||||
const uint8_t *metadata_plaintext,
|
||||
const size_t metadata_length)
|
||||
static int produce_initiate (void *data_,
|
||||
size_t size_,
|
||||
const uint64_t cn_nonce_,
|
||||
const uint8_t *server_key_,
|
||||
const uint8_t *public_key_,
|
||||
const uint8_t *secret_key_,
|
||||
const uint8_t *cn_public_,
|
||||
const uint8_t *cn_secret_,
|
||||
const uint8_t *cn_server_,
|
||||
const uint8_t *cn_cookie_,
|
||||
const uint8_t *metadata_plaintext_,
|
||||
const size_t metadata_length_)
|
||||
{
|
||||
uint8_t vouch_nonce[crypto_box_NONCEBYTES];
|
||||
uint8_t vouch_plaintext[crypto_box_ZEROBYTES + 64];
|
||||
@ -152,120 +152,122 @@ struct curve_client_tools_t
|
||||
|
||||
// Create vouch = Box [C',S](C->S')
|
||||
memset (vouch_plaintext, 0, crypto_box_ZEROBYTES);
|
||||
memcpy (vouch_plaintext + crypto_box_ZEROBYTES, cn_public, 32);
|
||||
memcpy (vouch_plaintext + crypto_box_ZEROBYTES + 32, server_key, 32);
|
||||
memcpy (vouch_plaintext + crypto_box_ZEROBYTES, cn_public_, 32);
|
||||
memcpy (vouch_plaintext + crypto_box_ZEROBYTES + 32, server_key_, 32);
|
||||
|
||||
memcpy (vouch_nonce, "VOUCH---", 8);
|
||||
randombytes (vouch_nonce + 8, 16);
|
||||
|
||||
int rc = crypto_box (vouch_box, vouch_plaintext, sizeof vouch_plaintext,
|
||||
vouch_nonce, cn_server, secret_key);
|
||||
vouch_nonce, cn_server_, secret_key_);
|
||||
if (rc == -1)
|
||||
return -1;
|
||||
|
||||
uint8_t initiate_nonce[crypto_box_NONCEBYTES];
|
||||
uint8_t *initiate_box = static_cast<uint8_t *> (
|
||||
malloc (crypto_box_BOXZEROBYTES + 144 + metadata_length));
|
||||
malloc (crypto_box_BOXZEROBYTES + 144 + metadata_length_));
|
||||
alloc_assert (initiate_box);
|
||||
uint8_t *initiate_plaintext = static_cast<uint8_t *> (
|
||||
malloc (crypto_box_ZEROBYTES + 128 + metadata_length));
|
||||
malloc (crypto_box_ZEROBYTES + 128 + metadata_length_));
|
||||
alloc_assert (initiate_plaintext);
|
||||
|
||||
// Create Box [C + vouch + metadata](C'->S')
|
||||
memset (initiate_plaintext, 0, crypto_box_ZEROBYTES);
|
||||
memcpy (initiate_plaintext + crypto_box_ZEROBYTES, public_key, 32);
|
||||
memcpy (initiate_plaintext + crypto_box_ZEROBYTES, public_key_, 32);
|
||||
memcpy (initiate_plaintext + crypto_box_ZEROBYTES + 32, vouch_nonce + 8,
|
||||
16);
|
||||
memcpy (initiate_plaintext + crypto_box_ZEROBYTES + 48,
|
||||
vouch_box + crypto_box_BOXZEROBYTES, 80);
|
||||
memcpy (initiate_plaintext + crypto_box_ZEROBYTES + 48 + 80,
|
||||
metadata_plaintext, metadata_length);
|
||||
metadata_plaintext_, metadata_length_);
|
||||
|
||||
memcpy (initiate_nonce, "CurveZMQINITIATE", 16);
|
||||
put_uint64 (initiate_nonce + 16, cn_nonce);
|
||||
put_uint64 (initiate_nonce + 16, cn_nonce_);
|
||||
|
||||
rc = crypto_box (initiate_box, initiate_plaintext,
|
||||
crypto_box_ZEROBYTES + 128 + metadata_length,
|
||||
initiate_nonce, cn_server, cn_secret);
|
||||
crypto_box_ZEROBYTES + 128 + metadata_length_,
|
||||
initiate_nonce, cn_server_, cn_secret_);
|
||||
free (initiate_plaintext);
|
||||
|
||||
if (rc == -1)
|
||||
return -1;
|
||||
|
||||
uint8_t *initiate = static_cast<uint8_t *> (data);
|
||||
uint8_t *initiate = static_cast<uint8_t *> (data_);
|
||||
|
||||
zmq_assert (size
|
||||
== 113 + 128 + crypto_box_BOXZEROBYTES + metadata_length);
|
||||
zmq_assert (size_
|
||||
== 113 + 128 + crypto_box_BOXZEROBYTES + metadata_length_);
|
||||
|
||||
memcpy (initiate, "\x08INITIATE", 9);
|
||||
// Cookie provided by the server in the WELCOME command
|
||||
memcpy (initiate + 9, cn_cookie, 96);
|
||||
memcpy (initiate + 9, cn_cookie_, 96);
|
||||
// Short nonce, prefixed by "CurveZMQINITIATE"
|
||||
memcpy (initiate + 105, initiate_nonce + 16, 8);
|
||||
// Box [C + vouch + metadata](C'->S')
|
||||
memcpy (initiate + 113, initiate_box + crypto_box_BOXZEROBYTES,
|
||||
128 + metadata_length + crypto_box_BOXZEROBYTES);
|
||||
128 + metadata_length_ + crypto_box_BOXZEROBYTES);
|
||||
free (initiate_box);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool is_handshake_command_welcome (const uint8_t *msg_data,
|
||||
const size_t msg_size)
|
||||
static bool is_handshake_command_welcome (const uint8_t *msg_data_,
|
||||
const size_t msg_size_)
|
||||
{
|
||||
return is_handshake_command (msg_data, msg_size, "\7WELCOME");
|
||||
return is_handshake_command (msg_data_, msg_size_, "\7WELCOME");
|
||||
}
|
||||
|
||||
static bool is_handshake_command_ready (const uint8_t *msg_data,
|
||||
const size_t msg_size)
|
||||
static bool is_handshake_command_ready (const uint8_t *msg_data_,
|
||||
const size_t msg_size_)
|
||||
{
|
||||
return is_handshake_command (msg_data, msg_size, "\5READY");
|
||||
return is_handshake_command (msg_data_, msg_size_, "\5READY");
|
||||
}
|
||||
|
||||
static bool is_handshake_command_error (const uint8_t *msg_data,
|
||||
const size_t msg_size)
|
||||
static bool is_handshake_command_error (const uint8_t *msg_data_,
|
||||
const size_t msg_size_)
|
||||
{
|
||||
return is_handshake_command (msg_data, msg_size, "\5ERROR");
|
||||
return is_handshake_command (msg_data_, msg_size_, "\5ERROR");
|
||||
}
|
||||
|
||||
// non-static functions
|
||||
curve_client_tools_t (
|
||||
const uint8_t (&curve_public_key)[crypto_box_PUBLICKEYBYTES],
|
||||
const uint8_t (&curve_secret_key)[crypto_box_SECRETKEYBYTES],
|
||||
const uint8_t (&curve_server_key)[crypto_box_PUBLICKEYBYTES])
|
||||
const uint8_t (&curve_public_key_)[crypto_box_PUBLICKEYBYTES],
|
||||
const uint8_t (&curve_secret_key_)[crypto_box_SECRETKEYBYTES],
|
||||
const uint8_t (&curve_server_key_)[crypto_box_PUBLICKEYBYTES])
|
||||
{
|
||||
int rc;
|
||||
memcpy (public_key, curve_public_key, crypto_box_PUBLICKEYBYTES);
|
||||
memcpy (secret_key, curve_secret_key, crypto_box_SECRETKEYBYTES);
|
||||
memcpy (server_key, curve_server_key, crypto_box_PUBLICKEYBYTES);
|
||||
memcpy (public_key, curve_public_key_, crypto_box_PUBLICKEYBYTES);
|
||||
memcpy (secret_key, curve_secret_key_, crypto_box_SECRETKEYBYTES);
|
||||
memcpy (server_key, curve_server_key_, crypto_box_PUBLICKEYBYTES);
|
||||
|
||||
// Generate short-term key pair
|
||||
rc = crypto_box_keypair (cn_public, cn_secret);
|
||||
zmq_assert (rc == 0);
|
||||
}
|
||||
|
||||
int produce_hello (void *data, const uint64_t cn_nonce) const
|
||||
int produce_hello (void *data_, const uint64_t cn_nonce_) const
|
||||
{
|
||||
return produce_hello (data, server_key, cn_nonce, cn_public, cn_secret);
|
||||
return produce_hello (data_, server_key, cn_nonce_, cn_public,
|
||||
cn_secret);
|
||||
}
|
||||
|
||||
int process_welcome (const uint8_t *msg_data,
|
||||
size_t msg_size,
|
||||
uint8_t *cn_precom)
|
||||
int process_welcome (const uint8_t *msg_data_,
|
||||
size_t msg_size_,
|
||||
uint8_t *cn_precom_)
|
||||
{
|
||||
return process_welcome (msg_data, msg_size, server_key, cn_secret,
|
||||
cn_server, cn_cookie, cn_precom);
|
||||
return process_welcome (msg_data_, msg_size_, server_key, cn_secret,
|
||||
cn_server, cn_cookie, cn_precom_);
|
||||
}
|
||||
|
||||
int produce_initiate (void *data,
|
||||
size_t size,
|
||||
const uint64_t cn_nonce,
|
||||
const uint8_t *metadata_plaintext,
|
||||
const size_t metadata_length)
|
||||
int produce_initiate (void *data_,
|
||||
size_t size_,
|
||||
const uint64_t cn_nonce_,
|
||||
const uint8_t *metadata_plaintext_,
|
||||
const size_t metadata_length_)
|
||||
{
|
||||
return produce_initiate (
|
||||
data, size, cn_nonce, server_key, public_key, secret_key, cn_public,
|
||||
cn_secret, cn_server, cn_cookie, metadata_plaintext, metadata_length);
|
||||
return produce_initiate (data_, size_, cn_nonce_, server_key,
|
||||
public_key, secret_key, cn_public, cn_secret,
|
||||
cn_server, cn_cookie, metadata_plaintext_,
|
||||
metadata_length_);
|
||||
}
|
||||
|
||||
// Our public key (C)
|
||||
@ -291,11 +293,11 @@ struct curve_client_tools_t
|
||||
|
||||
private:
|
||||
template <size_t N>
|
||||
static bool is_handshake_command (const uint8_t *msg_data,
|
||||
const size_t msg_size,
|
||||
const char (&prefix)[N])
|
||||
static bool is_handshake_command (const uint8_t *msg_data_,
|
||||
const size_t msg_size_,
|
||||
const char (&prefix_)[N])
|
||||
{
|
||||
return msg_size >= (N - 1) && !memcmp (msg_data, prefix, N - 1);
|
||||
return msg_size_ >= (N - 1) && !memcmp (msg_data_, prefix_, N - 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -484,9 +484,10 @@ int zmq::curve_server_t::produce_error (msg_t *msg_) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void zmq::curve_server_t::send_zap_request (const uint8_t *key)
|
||||
void zmq::curve_server_t::send_zap_request (const uint8_t *key_)
|
||||
{
|
||||
zap_client_t::send_zap_request ("CURVE", 5, key, crypto_box_PUBLICKEYBYTES);
|
||||
zap_client_t::send_zap_request ("CURVE", 5, key_,
|
||||
crypto_box_PUBLICKEYBYTES);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -79,7 +79,7 @@ class curve_server_t : public zap_client_common_handshake_t,
|
||||
int produce_ready (msg_t *msg_);
|
||||
int produce_error (msg_t *msg_) const;
|
||||
|
||||
void send_zap_request (const uint8_t *key);
|
||||
void send_zap_request (const uint8_t *key_);
|
||||
};
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
|
@ -118,10 +118,10 @@ template <> class dbuffer_t<msg_t>
|
||||
return has_msg;
|
||||
}
|
||||
|
||||
inline bool probe (bool (*fn) (const msg_t &))
|
||||
inline bool probe (bool (*fn_) (const msg_t &))
|
||||
{
|
||||
scoped_lock_t lock (sync);
|
||||
return (*fn) (*front);
|
||||
return (*fn_) (*front);
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ class socket_base_t;
|
||||
class dealer_t : public socket_base_t
|
||||
{
|
||||
public:
|
||||
dealer_t (zmq::ctx_t *parent_, uint32_t tid_, int sid);
|
||||
dealer_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||
~dealer_t ();
|
||||
|
||||
protected:
|
||||
|
@ -149,9 +149,9 @@ class decoder_base_t : public i_decoder
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void resize_buffer (std::size_t new_size)
|
||||
virtual void resize_buffer (std::size_t new_size_)
|
||||
{
|
||||
allocator.resize (new_size);
|
||||
allocator.resize (new_size_);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -47,12 +47,12 @@ zmq::shared_message_memory_allocator::shared_message_memory_allocator (
|
||||
}
|
||||
|
||||
zmq::shared_message_memory_allocator::shared_message_memory_allocator (
|
||||
std::size_t bufsize_, std::size_t maxMessages) :
|
||||
std::size_t bufsize_, std::size_t max_messages_) :
|
||||
buf (NULL),
|
||||
bufsize (0),
|
||||
max_size (bufsize_),
|
||||
msg_content (NULL),
|
||||
maxCounters (maxMessages)
|
||||
maxCounters (max_messages_)
|
||||
{
|
||||
}
|
||||
|
||||
@ -130,10 +130,10 @@ void zmq::shared_message_memory_allocator::inc_ref ()
|
||||
(reinterpret_cast<zmq::atomic_counter_t *> (buf))->add (1);
|
||||
}
|
||||
|
||||
void zmq::shared_message_memory_allocator::call_dec_ref (void *, void *hint)
|
||||
void zmq::shared_message_memory_allocator::call_dec_ref (void *, void *hint_)
|
||||
{
|
||||
zmq_assert (hint);
|
||||
unsigned char *buf = static_cast<unsigned char *> (hint);
|
||||
zmq_assert (hint_);
|
||||
unsigned char *buf = static_cast<unsigned char *> (hint_);
|
||||
zmq::atomic_counter_t *c = reinterpret_cast<zmq::atomic_counter_t *> (buf);
|
||||
|
||||
if (!c->sub (1)) {
|
||||
|
@ -58,7 +58,7 @@ class c_single_allocator
|
||||
|
||||
std::size_t size () const { return bufsize; }
|
||||
|
||||
void resize (std::size_t new_size) { bufsize = new_size; }
|
||||
void resize (std::size_t new_size_) { bufsize = new_size_; }
|
||||
|
||||
private:
|
||||
std::size_t bufsize;
|
||||
@ -84,7 +84,7 @@ class shared_message_memory_allocator
|
||||
|
||||
// Create an allocator for a maximum number of messages
|
||||
shared_message_memory_allocator (std::size_t bufsize_,
|
||||
std::size_t maxMessages);
|
||||
std::size_t max_messages_);
|
||||
|
||||
~shared_message_memory_allocator ();
|
||||
|
||||
@ -103,7 +103,7 @@ class shared_message_memory_allocator
|
||||
|
||||
void inc_ref ();
|
||||
|
||||
static void call_dec_ref (void *, void *buffer);
|
||||
static void call_dec_ref (void *, void *buffer_);
|
||||
|
||||
std::size_t size () const;
|
||||
|
||||
@ -113,7 +113,7 @@ class shared_message_memory_allocator
|
||||
// Return pointer to the first byte of the buffer.
|
||||
unsigned char *buffer () { return buf; }
|
||||
|
||||
void resize (std::size_t new_size) { bufsize = new_size; }
|
||||
void resize (std::size_t new_size_) { bufsize = new_size_; }
|
||||
|
||||
zmq::msg_t::content_t *provide_content () { return msg_content; }
|
||||
|
||||
|
@ -44,7 +44,7 @@ class io_thread_t;
|
||||
class dgram_t : public socket_base_t
|
||||
{
|
||||
public:
|
||||
dgram_t (zmq::ctx_t *parent_, uint32_t tid_, int sid);
|
||||
dgram_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||
~dgram_t ();
|
||||
|
||||
// Overrides of functions from socket_base_t.
|
||||
|
@ -95,7 +95,7 @@ const char *zmq::wsa_error ()
|
||||
return wsa_error_no (WSAGetLastError (), NULL);
|
||||
}
|
||||
|
||||
const char *zmq::wsa_error_no (int no_, const char *wsae_wouldblock_string)
|
||||
const char *zmq::wsa_error_no (int no_, const char *wsae_wouldblock_string_)
|
||||
{
|
||||
// TODO: It seems that list of Windows socket errors is longer than this.
|
||||
// Investigate whether there's a way to convert it into the string
|
||||
@ -116,7 +116,7 @@ const char *zmq::wsa_error_no (int no_, const char *wsae_wouldblock_string)
|
||||
case WSAEMFILE:
|
||||
return "Too many open files";
|
||||
case WSAEWOULDBLOCK:
|
||||
return wsae_wouldblock_string;
|
||||
return wsae_wouldblock_string_;
|
||||
case WSAEINPROGRESS:
|
||||
return "Operation now in progress";
|
||||
case WSAEALREADY:
|
||||
@ -225,9 +225,9 @@ void zmq::win_error (char *buffer_, size_t buffer_size_)
|
||||
zmq_assert (rc);
|
||||
}
|
||||
|
||||
int zmq::wsa_error_to_errno (int errcode)
|
||||
int zmq::wsa_error_to_errno (int errcode_)
|
||||
{
|
||||
switch (errcode) {
|
||||
switch (errcode_) {
|
||||
// 10004 - Interrupted system call.
|
||||
case WSAEINTR:
|
||||
return EINTR;
|
||||
|
@ -75,9 +75,9 @@ namespace zmq
|
||||
const char *wsa_error ();
|
||||
const char *
|
||||
wsa_error_no (int no_,
|
||||
const char *wsae_wouldblock_string = "Operation would block");
|
||||
const char *wsae_wouldblock_string_ = "Operation would block");
|
||||
void win_error (char *buffer_, size_t buffer_size_);
|
||||
int wsa_error_to_errno (int errcode);
|
||||
int wsa_error_to_errno (int errcode_);
|
||||
}
|
||||
|
||||
// Provides convenient way to check WSA-style errors on Windows.
|
||||
|
@ -51,7 +51,7 @@ class i_decoder
|
||||
// When the decoder needs more data, 0 is returned.
|
||||
// On error, -1 is returned and errno is set accordingly.
|
||||
virtual int
|
||||
decode (const unsigned char *data_, size_t size_, size_t &processed) = 0;
|
||||
decode (const unsigned char *data_, size_t size_, size_t &processed_) = 0;
|
||||
|
||||
virtual msg_t *msg () = 0;
|
||||
};
|
||||
|
@ -47,7 +47,7 @@ struct i_encoder
|
||||
// are filled to a supplied buffer. If no buffer is supplied (data_
|
||||
// is NULL) encoder will provide buffer of its own.
|
||||
// Function returns 0 when a new message is required.
|
||||
virtual size_t encode (unsigned char **data_, size_t size) = 0;
|
||||
virtual size_t encode (unsigned char **data_, size_t size_) = 0;
|
||||
|
||||
// Load a new message into encoder.
|
||||
virtual void load_msg (msg_t *msg_) = 0;
|
||||
|
18
src/ip.cpp
18
src/ip.cpp
@ -193,10 +193,10 @@ int zmq::get_peer_ip_address (fd_t sockfd_, std::string &ip_addr_)
|
||||
return static_cast<int> (u.sa.sa_family);
|
||||
}
|
||||
|
||||
void zmq::set_ip_type_of_service (fd_t s_, int iptos)
|
||||
void zmq::set_ip_type_of_service (fd_t s_, int iptos_)
|
||||
{
|
||||
int rc = setsockopt (s_, IPPROTO_IP, IP_TOS,
|
||||
reinterpret_cast<char *> (&iptos), sizeof (iptos));
|
||||
reinterpret_cast<char *> (&iptos_), sizeof (iptos_));
|
||||
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
wsa_assert (rc != SOCKET_ERROR);
|
||||
@ -207,7 +207,7 @@ void zmq::set_ip_type_of_service (fd_t s_, int iptos)
|
||||
// Windows and Hurd do not support IPV6_TCLASS
|
||||
#if !defined(ZMQ_HAVE_WINDOWS) && defined(IPV6_TCLASS)
|
||||
rc = setsockopt (s_, IPPROTO_IPV6, IPV6_TCLASS,
|
||||
reinterpret_cast<char *> (&iptos), sizeof (iptos));
|
||||
reinterpret_cast<char *> (&iptos_), sizeof (iptos_));
|
||||
|
||||
// If IPv6 is not enabled ENOPROTOOPT will be returned on Linux and
|
||||
// EINVAL on OSX
|
||||
@ -311,15 +311,15 @@ void zmq::shutdown_network ()
|
||||
}
|
||||
|
||||
#if defined ZMQ_HAVE_WINDOWS
|
||||
static void tune_socket (const SOCKET socket)
|
||||
static void tune_socket (const SOCKET socket_)
|
||||
{
|
||||
BOOL tcp_nodelay = 1;
|
||||
int rc =
|
||||
setsockopt (socket, IPPROTO_TCP, TCP_NODELAY,
|
||||
setsockopt (socket_, IPPROTO_TCP, TCP_NODELAY,
|
||||
reinterpret_cast<char *> (&tcp_nodelay), sizeof tcp_nodelay);
|
||||
wsa_assert (rc != SOCKET_ERROR);
|
||||
|
||||
zmq::tcp_tune_loopback_fast_path (socket);
|
||||
zmq::tcp_tune_loopback_fast_path (socket_);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -659,12 +659,12 @@ int zmq::make_fdpair (fd_t *r_, fd_t *w_)
|
||||
#endif
|
||||
}
|
||||
|
||||
void zmq::make_socket_noninheritable (fd_t sock)
|
||||
void zmq::make_socket_noninheritable (fd_t sock_)
|
||||
{
|
||||
#if defined ZMQ_HAVE_WINDOWS && !defined _WIN32_WCE \
|
||||
&& !defined ZMQ_HAVE_WINDOWS_UWP
|
||||
// On Windows, preventing sockets to be inherited by child processes.
|
||||
const BOOL brc = SetHandleInformation (reinterpret_cast<HANDLE> (sock),
|
||||
const BOOL brc = SetHandleInformation (reinterpret_cast<HANDLE> (sock_),
|
||||
HANDLE_FLAG_INHERIT, 0);
|
||||
win_assert (brc);
|
||||
#endif
|
||||
@ -674,7 +674,7 @@ void zmq::make_socket_noninheritable (fd_t sock)
|
||||
// If there 's no SOCK_CLOEXEC, let's try the second best option.
|
||||
// Race condition can cause socket not to be closed (if fork happens
|
||||
// between accept and this point).
|
||||
const int rc = fcntl (sock, F_SETFD, FD_CLOEXEC);
|
||||
const int rc = fcntl (sock_, F_SETFD, FD_CLOEXEC);
|
||||
errno_assert (rc != -1);
|
||||
#endif
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ void enable_ipv4_mapping (fd_t s_);
|
||||
int get_peer_ip_address (fd_t sockfd_, std::string &ip_addr_);
|
||||
|
||||
// Sets the IP Type-Of-Service for the underlying socket
|
||||
void set_ip_type_of_service (fd_t s_, int iptos);
|
||||
void set_ip_type_of_service (fd_t s_, int iptos_);
|
||||
|
||||
// Sets the SO_NOSIGPIPE option for the underlying socket.
|
||||
// Return 0 on success, -1 if the connection has been closed by the peer
|
||||
@ -70,7 +70,7 @@ int make_fdpair (fd_t *r_, fd_t *w_);
|
||||
|
||||
// Makes a socket non-inheritable to child processes.
|
||||
// Asserts on any failure.
|
||||
void make_socket_noninheritable (fd_t sock);
|
||||
void make_socket_noninheritable (fd_t sock_);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -60,26 +60,26 @@ socklen_t zmq::ip_addr_t::sockaddr_len () const
|
||||
}
|
||||
}
|
||||
|
||||
void zmq::ip_addr_t::set_port (uint16_t port)
|
||||
void zmq::ip_addr_t::set_port (uint16_t port_)
|
||||
{
|
||||
if (family () == AF_INET6) {
|
||||
ipv6.sin6_port = htons (port);
|
||||
ipv6.sin6_port = htons (port_);
|
||||
} else {
|
||||
ipv4.sin_port = htons (port);
|
||||
ipv4.sin_port = htons (port_);
|
||||
}
|
||||
}
|
||||
|
||||
// Construct an "ANY" address for the given family
|
||||
zmq::ip_addr_t zmq::ip_addr_t::any (int family)
|
||||
zmq::ip_addr_t zmq::ip_addr_t::any (int family_)
|
||||
{
|
||||
ip_addr_t addr;
|
||||
|
||||
if (family == AF_INET) {
|
||||
if (family_ == AF_INET) {
|
||||
sockaddr_in *ip4_addr = &addr.ipv4;
|
||||
memset (ip4_addr, 0, sizeof (*ip4_addr));
|
||||
ip4_addr->sin_family = AF_INET;
|
||||
ip4_addr->sin_addr.s_addr = htonl (INADDR_ANY);
|
||||
} else if (family == AF_INET6) {
|
||||
} else if (family_ == AF_INET6) {
|
||||
sockaddr_in6 *ip6_addr = &addr.ipv6;
|
||||
|
||||
memset (ip6_addr, 0, sizeof (*ip6_addr));
|
||||
@ -551,8 +551,8 @@ int zmq::ip_resolver_t::resolve_nic_name (ip_addr_t *ip_addr_, const char *nic_)
|
||||
|
||||
#include <netioapi.h>
|
||||
|
||||
int zmq::ip_resolver_t::get_interface_name (unsigned long index,
|
||||
char **dest) const
|
||||
int zmq::ip_resolver_t::get_interface_name (unsigned long index_,
|
||||
char **dest_) const
|
||||
{
|
||||
#ifdef ZMQ_HAVE_WINDOWS_UWP
|
||||
char *buffer = (char *) malloc (1024);
|
||||
@ -564,7 +564,7 @@ int zmq::ip_resolver_t::get_interface_name (unsigned long index,
|
||||
char *if_name_result = NULL;
|
||||
|
||||
#if !defined ZMQ_HAVE_WINDOWS_TARGET_XP && !defined ZMQ_HAVE_WINDOWS_UWP
|
||||
if_name_result = if_indextoname (index, buffer);
|
||||
if_name_result = if_indextoname (index_, buffer);
|
||||
#endif
|
||||
|
||||
if (if_name_result == NULL) {
|
||||
@ -572,27 +572,28 @@ int zmq::ip_resolver_t::get_interface_name (unsigned long index,
|
||||
return -1;
|
||||
}
|
||||
|
||||
*dest = buffer;
|
||||
*dest_ = buffer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int zmq::ip_resolver_t::wchar_to_utf8 (const WCHAR *src, char **dest) const
|
||||
int zmq::ip_resolver_t::wchar_to_utf8 (const WCHAR *src_, char **dest_) const
|
||||
{
|
||||
int rc;
|
||||
int buffer_len =
|
||||
WideCharToMultiByte (CP_UTF8, 0, src, -1, NULL, 0, NULL, 0);
|
||||
WideCharToMultiByte (CP_UTF8, 0, src_, -1, NULL, 0, NULL, 0);
|
||||
|
||||
char *buffer = static_cast<char *> (malloc (buffer_len));
|
||||
alloc_assert (buffer);
|
||||
|
||||
rc = WideCharToMultiByte (CP_UTF8, 0, src, -1, buffer, buffer_len, NULL, 0);
|
||||
rc =
|
||||
WideCharToMultiByte (CP_UTF8, 0, src_, -1, buffer, buffer_len, NULL, 0);
|
||||
|
||||
if (rc == 0) {
|
||||
free (buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*dest = buffer;
|
||||
*dest_ = buffer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ union ip_addr_t
|
||||
|
||||
void set_port (uint16_t);
|
||||
|
||||
static ip_addr_t any (int family);
|
||||
static ip_addr_t any (int family_);
|
||||
};
|
||||
|
||||
class ip_resolver_options_t
|
||||
@ -94,8 +94,8 @@ class ip_resolver_t
|
||||
int resolve_getaddrinfo (ip_addr_t *ip_addr_, const char *addr_);
|
||||
|
||||
#if defined ZMQ_HAVE_WINDOWS
|
||||
int get_interface_name (unsigned long index, char **dest) const;
|
||||
int wchar_to_utf8 (const WCHAR *src, char **dest) const;
|
||||
int get_interface_name (unsigned long index_, char **dest_) const;
|
||||
int wchar_to_utf8 (const WCHAR *src_, char **dest_) const;
|
||||
#endif
|
||||
|
||||
// Virtual functions that are overriden in tests
|
||||
|
@ -51,18 +51,18 @@ zmq::mailbox_safe_t::~mailbox_safe_t ()
|
||||
sync->unlock ();
|
||||
}
|
||||
|
||||
void zmq::mailbox_safe_t::add_signaler (signaler_t *signaler)
|
||||
void zmq::mailbox_safe_t::add_signaler (signaler_t *signaler_)
|
||||
{
|
||||
signalers.push_back (signaler);
|
||||
signalers.push_back (signaler_);
|
||||
}
|
||||
|
||||
void zmq::mailbox_safe_t::remove_signaler (signaler_t *signaler)
|
||||
void zmq::mailbox_safe_t::remove_signaler (signaler_t *signaler_)
|
||||
{
|
||||
std::vector<signaler_t *>::iterator it = signalers.begin ();
|
||||
|
||||
// TODO: make a copy of array and signal outside the lock
|
||||
for (; it != signalers.end (); ++it) {
|
||||
if (*it == signaler)
|
||||
if (*it == signaler_)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -54,8 +54,8 @@ class mailbox_safe_t : public i_mailbox
|
||||
int recv (command_t *cmd_, int timeout_);
|
||||
|
||||
// Add signaler to mailbox which will be called when a message is ready
|
||||
void add_signaler (signaler_t *signaler);
|
||||
void remove_signaler (signaler_t *signaler);
|
||||
void add_signaler (signaler_t *signaler_);
|
||||
void remove_signaler (signaler_t *signaler_);
|
||||
void clear_signalers ();
|
||||
|
||||
#ifdef HAVE_FORK
|
||||
|
@ -45,9 +45,10 @@ zmq::mechanism_t::~mechanism_t ()
|
||||
{
|
||||
}
|
||||
|
||||
void zmq::mechanism_t::set_peer_routing_id (const void *id_ptr, size_t id_size)
|
||||
void zmq::mechanism_t::set_peer_routing_id (const void *id_ptr_,
|
||||
size_t id_size_)
|
||||
{
|
||||
routing_id.set (static_cast<const unsigned char *> (id_ptr), id_size);
|
||||
routing_id.set (static_cast<const unsigned char *> (id_ptr_), id_size_);
|
||||
}
|
||||
|
||||
void zmq::mechanism_t::peer_routing_id (msg_t *msg_)
|
||||
@ -93,7 +94,7 @@ const char socket_type_scatter[] = "SCATTER";
|
||||
const char socket_type_dgram[] = "DGRAM";
|
||||
#endif
|
||||
|
||||
const char *zmq::mechanism_t::socket_type_string (int socket_type) const
|
||||
const char *zmq::mechanism_t::socket_type_string (int socket_type_) const
|
||||
{
|
||||
// TODO the order must of the names must correspond to the values resp. order of ZMQ_* socket type definitions in zmq.h!
|
||||
static const char *names[] = {
|
||||
@ -108,67 +109,67 @@ const char *zmq::mechanism_t::socket_type_string (int socket_type) const
|
||||
#endif
|
||||
};
|
||||
static const size_t names_count = sizeof (names) / sizeof (names[0]);
|
||||
zmq_assert (socket_type >= 0 && socket_type < (int) names_count);
|
||||
return names[socket_type];
|
||||
zmq_assert (socket_type_ >= 0 && socket_type_ < (int) names_count);
|
||||
return names[socket_type_];
|
||||
}
|
||||
|
||||
static size_t property_len (size_t name_len, size_t value_len)
|
||||
static size_t property_len (size_t name_len_, size_t value_len_)
|
||||
{
|
||||
return 1 + name_len + 4 + value_len;
|
||||
return 1 + name_len_ + 4 + value_len_;
|
||||
}
|
||||
|
||||
static size_t name_len (const char *name)
|
||||
static size_t name_len (const char *name_)
|
||||
{
|
||||
const size_t name_len = strlen (name);
|
||||
const size_t name_len = strlen (name_);
|
||||
zmq_assert (name_len <= 255);
|
||||
return name_len;
|
||||
}
|
||||
|
||||
size_t zmq::mechanism_t::add_property (unsigned char *ptr,
|
||||
size_t ptr_capacity,
|
||||
const char *name,
|
||||
const void *value,
|
||||
size_t value_len)
|
||||
size_t zmq::mechanism_t::add_property (unsigned char *ptr_,
|
||||
size_t ptr_capacity_,
|
||||
const char *name_,
|
||||
const void *value_,
|
||||
size_t value_len_)
|
||||
{
|
||||
const size_t name_len = ::name_len (name);
|
||||
const size_t total_len = ::property_len (name_len, value_len);
|
||||
zmq_assert (total_len <= ptr_capacity);
|
||||
const size_t name_len = ::name_len (name_);
|
||||
const size_t total_len = ::property_len (name_len, value_len_);
|
||||
zmq_assert (total_len <= ptr_capacity_);
|
||||
|
||||
*ptr++ = static_cast<unsigned char> (name_len);
|
||||
memcpy (ptr, name, name_len);
|
||||
ptr += name_len;
|
||||
zmq_assert (value_len <= 0x7FFFFFFF);
|
||||
put_uint32 (ptr, static_cast<uint32_t> (value_len));
|
||||
ptr += 4;
|
||||
memcpy (ptr, value, value_len);
|
||||
*ptr_++ = static_cast<unsigned char> (name_len);
|
||||
memcpy (ptr_, name_, name_len);
|
||||
ptr_ += name_len;
|
||||
zmq_assert (value_len_ <= 0x7FFFFFFF);
|
||||
put_uint32 (ptr_, static_cast<uint32_t> (value_len_));
|
||||
ptr_ += 4;
|
||||
memcpy (ptr_, value_, value_len_);
|
||||
|
||||
return total_len;
|
||||
}
|
||||
|
||||
size_t zmq::mechanism_t::property_len (const char *name, size_t value_len)
|
||||
size_t zmq::mechanism_t::property_len (const char *name_, size_t value_len_)
|
||||
{
|
||||
return ::property_len (name_len (name), value_len);
|
||||
return ::property_len (name_len (name_), value_len_);
|
||||
}
|
||||
|
||||
#define ZMTP_PROPERTY_SOCKET_TYPE "Socket-Type"
|
||||
#define ZMTP_PROPERTY_IDENTITY "Identity"
|
||||
|
||||
size_t zmq::mechanism_t::add_basic_properties (unsigned char *buf,
|
||||
size_t buf_capacity) const
|
||||
size_t zmq::mechanism_t::add_basic_properties (unsigned char *buf_,
|
||||
size_t buf_capacity_) const
|
||||
{
|
||||
unsigned char *ptr = buf;
|
||||
unsigned char *ptr = buf_;
|
||||
|
||||
// Add socket type property
|
||||
const char *socket_type = socket_type_string (options.type);
|
||||
ptr += add_property (ptr, buf_capacity, ZMTP_PROPERTY_SOCKET_TYPE,
|
||||
ptr += add_property (ptr, buf_capacity_, ZMTP_PROPERTY_SOCKET_TYPE,
|
||||
socket_type, strlen (socket_type));
|
||||
|
||||
// Add identity (aka routing id) property
|
||||
if (options.type == ZMQ_REQ || options.type == ZMQ_DEALER
|
||||
|| options.type == ZMQ_ROUTER) {
|
||||
ptr +=
|
||||
add_property (ptr, buf_capacity - (ptr - buf), ZMTP_PROPERTY_IDENTITY,
|
||||
options.routing_id, options.routing_id_size);
|
||||
ptr += add_property (ptr, buf_capacity_ - (ptr - buf_),
|
||||
ZMTP_PROPERTY_IDENTITY, options.routing_id,
|
||||
options.routing_id_size);
|
||||
}
|
||||
|
||||
|
||||
@ -176,10 +177,10 @@ size_t zmq::mechanism_t::add_basic_properties (unsigned char *buf,
|
||||
options.app_metadata.begin ();
|
||||
it != options.app_metadata.end (); ++it)
|
||||
ptr +=
|
||||
add_property (ptr, buf_capacity - (ptr - buf), it->first.c_str (),
|
||||
add_property (ptr, buf_capacity_ - (ptr - buf_), it->first.c_str (),
|
||||
it->second.c_str (), strlen (it->second.c_str ()));
|
||||
|
||||
return ptr - buf;
|
||||
return ptr - buf_;
|
||||
}
|
||||
|
||||
size_t zmq::mechanism_t::basic_properties_len () const
|
||||
|
@ -73,11 +73,11 @@ class mechanism_t
|
||||
// Returns the status of this mechanism.
|
||||
virtual status_t status () const = 0;
|
||||
|
||||
void set_peer_routing_id (const void *id_ptr, size_t id_size);
|
||||
void set_peer_routing_id (const void *id_ptr_, size_t id_size_);
|
||||
|
||||
void peer_routing_id (msg_t *msg_);
|
||||
|
||||
void set_user_id (const void *user_id, size_t size);
|
||||
void set_user_id (const void *user_id_, size_t size_);
|
||||
|
||||
const blob_t &get_user_id () const;
|
||||
|
||||
@ -88,29 +88,30 @@ class mechanism_t
|
||||
protected:
|
||||
// Only used to identify the socket for the Socket-Type
|
||||
// property in the wire protocol.
|
||||
const char *socket_type_string (int socket_type) const;
|
||||
const char *socket_type_string (int socket_type_) const;
|
||||
|
||||
static size_t add_property (unsigned char *ptr,
|
||||
size_t ptr_capacity,
|
||||
const char *name,
|
||||
const void *value,
|
||||
size_t value_len);
|
||||
static size_t property_len (const char *name, size_t value_len);
|
||||
static size_t add_property (unsigned char *ptr_,
|
||||
size_t ptr_capacity_,
|
||||
const char *name_,
|
||||
const void *value_,
|
||||
size_t value_len_);
|
||||
static size_t property_len (const char *name_, size_t value_len_);
|
||||
|
||||
size_t add_basic_properties (unsigned char *ptr, size_t ptr_capacity) const;
|
||||
size_t add_basic_properties (unsigned char *ptr_,
|
||||
size_t ptr_capacity_) const;
|
||||
size_t basic_properties_len () const;
|
||||
|
||||
void make_command_with_basic_properties (msg_t *msg_,
|
||||
const char *prefix,
|
||||
size_t prefix_len) const;
|
||||
const char *prefix_,
|
||||
size_t prefix_len_) const;
|
||||
|
||||
// Parses a metadata.
|
||||
// Metadata consists of a list of properties consisting of
|
||||
// name and value as size-specified strings.
|
||||
// Returns 0 on success and -1 on error, in which case errno is set.
|
||||
int parse_metadata (const unsigned char *ptr_,
|
||||
size_t length,
|
||||
bool zap_flag = false);
|
||||
size_t length_,
|
||||
bool zap_flag_ = false);
|
||||
|
||||
// This is called by parse_property method whenever it
|
||||
// parses a new property. The function should return 0
|
||||
|
@ -52,15 +52,15 @@ int zmq::mechanism_base_t::check_basic_command_structure (msg_t *msg_)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void zmq::mechanism_base_t::handle_error_reason (const char *error_reason,
|
||||
size_t error_reason_len)
|
||||
void zmq::mechanism_base_t::handle_error_reason (const char *error_reason_,
|
||||
size_t error_reason_len_)
|
||||
{
|
||||
if (error_reason_len == 3 && error_reason[1] == '0'
|
||||
&& error_reason[2] == '0' && error_reason[0] >= '3'
|
||||
&& error_reason[0] <= '5') {
|
||||
if (error_reason_len_ == 3 && error_reason_[1] == '0'
|
||||
&& error_reason_[2] == '0' && error_reason_[0] >= '3'
|
||||
&& error_reason_[0] <= '5') {
|
||||
// it is a ZAP status code, so emit an authentication failure event
|
||||
session->get_socket ()->event_handshake_failed_auth (
|
||||
session->get_endpoint (), (error_reason[0] - '0') * 100);
|
||||
session->get_endpoint (), (error_reason_[0] - '0') * 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,8 @@ class mechanism_base_t : public mechanism_t
|
||||
|
||||
int check_basic_command_structure (msg_t *msg_);
|
||||
|
||||
void handle_error_reason (const char *error_reason,
|
||||
size_t error_reason_len);
|
||||
void handle_error_reason (const char *error_reason_,
|
||||
size_t error_reason_len_);
|
||||
|
||||
bool zap_required () const;
|
||||
};
|
||||
|
@ -30,16 +30,16 @@
|
||||
#include "precompiled.hpp"
|
||||
#include "metadata.hpp"
|
||||
|
||||
zmq::metadata_t::metadata_t (const dict_t &dict) : ref_cnt (1), dict (dict)
|
||||
zmq::metadata_t::metadata_t (const dict_t &dict_) : ref_cnt (1), dict (dict_)
|
||||
{
|
||||
}
|
||||
|
||||
const char *zmq::metadata_t::get (const std::string &property) const
|
||||
const char *zmq::metadata_t::get (const std::string &property_) const
|
||||
{
|
||||
dict_t::const_iterator it = dict.find (property);
|
||||
dict_t::const_iterator it = dict.find (property_);
|
||||
if (it == dict.end ()) {
|
||||
/** \todo remove this when support for the deprecated name "Identity" is dropped */
|
||||
if (property == "Identity")
|
||||
if (property_ == "Identity")
|
||||
return get (ZMQ_MSG_PROPERTY_ROUTING_ID);
|
||||
|
||||
return NULL;
|
||||
|
@ -42,11 +42,11 @@ class metadata_t
|
||||
public:
|
||||
typedef std::map<std::string, std::string> dict_t;
|
||||
|
||||
metadata_t (const dict_t &dict);
|
||||
metadata_t (const dict_t &dict_);
|
||||
|
||||
// Returns pointer to property value or NULL if
|
||||
// property is not found.
|
||||
const char *get (const std::string &property) const;
|
||||
const char *get (const std::string &property_) const;
|
||||
|
||||
void add_ref ();
|
||||
|
||||
|
11
src/msg.cpp
11
src/msg.cpp
@ -52,8 +52,11 @@ bool zmq::msg_t::check () const
|
||||
return u.base.type >= type_min && u.base.type <= type_max;
|
||||
}
|
||||
|
||||
int zmq::msg_t::init (
|
||||
void *data_, size_t size_, msg_free_fn *ffn_, void *hint, content_t *content_)
|
||||
int zmq::msg_t::init (void *data_,
|
||||
size_t size_,
|
||||
msg_free_fn *ffn_,
|
||||
void *hint_,
|
||||
content_t *content_)
|
||||
{
|
||||
if (size_ < max_vsm_size) {
|
||||
int const rc = init_size (size_);
|
||||
@ -65,9 +68,9 @@ int zmq::msg_t::init (
|
||||
return -1;
|
||||
}
|
||||
} else if (content_) {
|
||||
return init_external_storage (content_, data_, size_, ffn_, hint);
|
||||
return init_external_storage (content_, data_, size_, ffn_, hint_);
|
||||
} else {
|
||||
return init_data (data_, size_, ffn_, hint);
|
||||
return init_data (data_, size_, ffn_, hint_);
|
||||
}
|
||||
}
|
||||
|
||||
|
22
src/msg.hpp
22
src/msg.hpp
@ -43,7 +43,7 @@
|
||||
// Note that it has to be declared as "C" so that it is the same as
|
||||
// zmq_free_fn defined in zmq.h.
|
||||
extern "C" {
|
||||
typedef void(msg_free_fn) (void *data, void *hint);
|
||||
typedef void(msg_free_fn) (void *data_, void *hint_);
|
||||
}
|
||||
|
||||
namespace zmq
|
||||
@ -83,10 +83,10 @@ class msg_t
|
||||
bool check () const;
|
||||
int init ();
|
||||
|
||||
int init (void *data,
|
||||
int init (void *data_,
|
||||
size_t size_,
|
||||
msg_free_fn *ffn_,
|
||||
void *hint,
|
||||
void *hint_,
|
||||
content_t *content_ = NULL);
|
||||
|
||||
int init_size (size_t size_);
|
||||
@ -123,7 +123,7 @@ class msg_t
|
||||
int reset_routing_id ();
|
||||
const char *group ();
|
||||
int set_group (const char *group_);
|
||||
int set_group (const char *, size_t length);
|
||||
int set_group (const char *, size_t length_);
|
||||
|
||||
// After calling this function you can copy the message in POD-style
|
||||
// refs_ times. No need to call copy.
|
||||
@ -252,21 +252,21 @@ class msg_t
|
||||
} u;
|
||||
};
|
||||
|
||||
inline int close_and_return (zmq::msg_t *msg, int echo)
|
||||
inline int close_and_return (zmq::msg_t *msg_, int echo_)
|
||||
{
|
||||
// Since we abort on close failure we preserve errno for success case.
|
||||
int err = errno;
|
||||
const int rc = msg->close ();
|
||||
const int rc = msg_->close ();
|
||||
errno_assert (rc == 0);
|
||||
errno = err;
|
||||
return echo;
|
||||
return echo_;
|
||||
}
|
||||
|
||||
inline int close_and_return (zmq::msg_t msg[], int count, int echo)
|
||||
inline int close_and_return (zmq::msg_t msg_[], int count_, int echo_)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
close_and_return (&msg[i], 0);
|
||||
return echo;
|
||||
for (int i = 0; i < count_; i++)
|
||||
close_and_return (&msg_[i], 0);
|
||||
return echo_;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,17 +150,17 @@ int zmq::null_mechanism_t::process_handshake_command (msg_t *msg_)
|
||||
return rc;
|
||||
}
|
||||
|
||||
int zmq::null_mechanism_t::process_ready_command (const unsigned char *cmd_data,
|
||||
size_t data_size)
|
||||
int zmq::null_mechanism_t::process_ready_command (
|
||||
const unsigned char *cmd_data_, size_t data_size_)
|
||||
{
|
||||
ready_command_received = true;
|
||||
return parse_metadata (cmd_data + 6, data_size - 6);
|
||||
return parse_metadata (cmd_data_ + 6, data_size_ - 6);
|
||||
}
|
||||
|
||||
int zmq::null_mechanism_t::process_error_command (const unsigned char *cmd_data,
|
||||
size_t data_size)
|
||||
int zmq::null_mechanism_t::process_error_command (
|
||||
const unsigned char *cmd_data_, size_t data_size_)
|
||||
{
|
||||
if (data_size < 7) {
|
||||
if (data_size_ < 7) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
session->get_endpoint (),
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR);
|
||||
@ -168,8 +168,8 @@ int zmq::null_mechanism_t::process_error_command (const unsigned char *cmd_data,
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
const size_t error_reason_len = static_cast<size_t> (cmd_data[6]);
|
||||
if (error_reason_len > data_size - 7) {
|
||||
const size_t error_reason_len = static_cast<size_t> (cmd_data_[6]);
|
||||
if (error_reason_len > data_size_ - 7) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
session->get_endpoint (),
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR);
|
||||
@ -177,7 +177,7 @@ int zmq::null_mechanism_t::process_error_command (const unsigned char *cmd_data,
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
const char *error_reason = reinterpret_cast<const char *> (cmd_data) + 7;
|
||||
const char *error_reason = reinterpret_cast<const char *> (cmd_data_) + 7;
|
||||
handle_error_reason (error_reason, error_reason_len);
|
||||
error_command_received = true;
|
||||
return 0;
|
||||
|
@ -43,7 +43,7 @@ class null_mechanism_t : public zap_client_t
|
||||
{
|
||||
public:
|
||||
null_mechanism_t (session_base_t *session_,
|
||||
const std::string &peer_address,
|
||||
const std::string &peer_address_,
|
||||
const options_t &options_);
|
||||
virtual ~null_mechanism_t ();
|
||||
|
||||
@ -61,8 +61,10 @@ class null_mechanism_t : public zap_client_t
|
||||
bool zap_request_sent;
|
||||
bool zap_reply_received;
|
||||
|
||||
int process_ready_command (const unsigned char *cmd_data, size_t data_size);
|
||||
int process_error_command (const unsigned char *cmd_data, size_t data_size);
|
||||
int process_ready_command (const unsigned char *cmd_data_,
|
||||
size_t data_size_);
|
||||
int process_error_command (const unsigned char *cmd_data_,
|
||||
size_t data_size_);
|
||||
|
||||
void send_zap_request ();
|
||||
};
|
||||
|
@ -58,9 +58,9 @@ uint32_t zmq::object_t::get_tid ()
|
||||
return tid;
|
||||
}
|
||||
|
||||
void zmq::object_t::set_tid (uint32_t id)
|
||||
void zmq::object_t::set_tid (uint32_t id_)
|
||||
{
|
||||
tid = id;
|
||||
tid = id_;
|
||||
}
|
||||
|
||||
zmq::ctx_t *zmq::object_t::get_ctx ()
|
||||
|
@ -57,7 +57,7 @@ class object_t
|
||||
virtual ~object_t ();
|
||||
|
||||
uint32_t get_tid ();
|
||||
void set_tid (uint32_t id);
|
||||
void set_tid (uint32_t id_);
|
||||
ctx_t *get_ctx ();
|
||||
void process_command (zmq::command_t &cmd_);
|
||||
void send_inproc_connected (zmq::socket_base_t *socket_);
|
||||
@ -73,7 +73,7 @@ class object_t
|
||||
void unregister_endpoints (zmq::socket_base_t *socket_);
|
||||
zmq::endpoint_t find_endpoint (const char *addr_);
|
||||
void pend_connection (const std::string &addr_,
|
||||
const endpoint_t &endpoint,
|
||||
const endpoint_t &endpoint_,
|
||||
pipe_t **pipes_);
|
||||
void connect_pending (const char *addr_, zmq::socket_base_t *bind_socket_);
|
||||
|
||||
|
@ -249,18 +249,18 @@ zmq::options_t::options_t () :
|
||||
#endif
|
||||
}
|
||||
|
||||
int zmq::options_t::set_curve_key (uint8_t *destination,
|
||||
int zmq::options_t::set_curve_key (uint8_t *destination_,
|
||||
const void *optval_,
|
||||
size_t optvallen_)
|
||||
{
|
||||
switch (optvallen_) {
|
||||
case CURVE_KEYSIZE:
|
||||
memcpy (destination, optval_, optvallen_);
|
||||
memcpy (destination_, optval_, optvallen_);
|
||||
mechanism = ZMQ_CURVE;
|
||||
return 0;
|
||||
|
||||
case CURVE_KEYSIZE_Z85 + 1:
|
||||
if (zmq_z85_decode (destination, (char *) optval_)) {
|
||||
if (zmq_z85_decode (destination_, (char *) optval_)) {
|
||||
mechanism = ZMQ_CURVE;
|
||||
return 0;
|
||||
}
|
||||
@ -270,7 +270,7 @@ int zmq::options_t::set_curve_key (uint8_t *destination,
|
||||
char z85_key[CURVE_KEYSIZE_Z85 + 1];
|
||||
memcpy (z85_key, (char *) optval_, optvallen_);
|
||||
z85_key[CURVE_KEYSIZE_Z85] = 0;
|
||||
if (zmq_z85_decode (destination, z85_key)) {
|
||||
if (zmq_z85_decode (destination_, z85_key)) {
|
||||
mechanism = ZMQ_CURVE;
|
||||
return 0;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ struct options_t
|
||||
{
|
||||
options_t ();
|
||||
|
||||
int set_curve_key (uint8_t *destination,
|
||||
int set_curve_key (uint8_t *destination_,
|
||||
const void *optval_,
|
||||
size_t optvallen_);
|
||||
|
||||
|
@ -44,7 +44,7 @@ class io_thread_t;
|
||||
class pair_t : public socket_base_t
|
||||
{
|
||||
public:
|
||||
pair_t (zmq::ctx_t *parent_, uint32_t tid_, int sid);
|
||||
pair_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||
~pair_t ();
|
||||
|
||||
// Overrides of functions from socket_base_t.
|
||||
|
@ -138,10 +138,10 @@ int zmq::plain_client_t::produce_hello (msg_t *msg_) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int zmq::plain_client_t::process_welcome (const unsigned char *cmd_data,
|
||||
size_t data_size)
|
||||
int zmq::plain_client_t::process_welcome (const unsigned char *cmd_data_,
|
||||
size_t data_size_)
|
||||
{
|
||||
LIBZMQ_UNUSED (cmd_data);
|
||||
LIBZMQ_UNUSED (cmd_data_);
|
||||
|
||||
if (state != waiting_for_welcome) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
@ -149,7 +149,7 @@ int zmq::plain_client_t::process_welcome (const unsigned char *cmd_data,
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
if (data_size != 8) {
|
||||
if (data_size_ != 8) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
session->get_endpoint (),
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME);
|
||||
@ -167,8 +167,8 @@ int zmq::plain_client_t::produce_initiate (msg_t *msg_) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int zmq::plain_client_t::process_ready (const unsigned char *cmd_data,
|
||||
size_t data_size)
|
||||
int zmq::plain_client_t::process_ready (const unsigned char *cmd_data_,
|
||||
size_t data_size_)
|
||||
{
|
||||
if (state != waiting_for_ready) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
@ -176,7 +176,7 @@ int zmq::plain_client_t::process_ready (const unsigned char *cmd_data,
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
const int rc = parse_metadata (cmd_data + 6, data_size - 6);
|
||||
const int rc = parse_metadata (cmd_data_ + 6, data_size_ - 6);
|
||||
if (rc == 0)
|
||||
state = ready;
|
||||
else
|
||||
@ -186,8 +186,8 @@ int zmq::plain_client_t::process_ready (const unsigned char *cmd_data,
|
||||
return rc;
|
||||
}
|
||||
|
||||
int zmq::plain_client_t::process_error (const unsigned char *cmd_data,
|
||||
size_t data_size)
|
||||
int zmq::plain_client_t::process_error (const unsigned char *cmd_data_,
|
||||
size_t data_size_)
|
||||
{
|
||||
if (state != waiting_for_welcome && state != waiting_for_ready) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
@ -195,22 +195,22 @@ int zmq::plain_client_t::process_error (const unsigned char *cmd_data,
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
if (data_size < 7) {
|
||||
if (data_size_ < 7) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
session->get_endpoint (),
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR);
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
const size_t error_reason_len = static_cast<size_t> (cmd_data[6]);
|
||||
if (error_reason_len > data_size - 7) {
|
||||
const size_t error_reason_len = static_cast<size_t> (cmd_data_[6]);
|
||||
if (error_reason_len > data_size_ - 7) {
|
||||
session->get_socket ()->event_handshake_failed_protocol (
|
||||
session->get_endpoint (),
|
||||
ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR);
|
||||
errno = EPROTO;
|
||||
return -1;
|
||||
}
|
||||
const char *error_reason = reinterpret_cast<const char *> (cmd_data) + 7;
|
||||
const char *error_reason = reinterpret_cast<const char *> (cmd_data_) + 7;
|
||||
handle_error_reason (error_reason, error_reason_len);
|
||||
state = error_command_received;
|
||||
return 0;
|
||||
|
@ -64,9 +64,9 @@ class plain_client_t : public mechanism_base_t
|
||||
int produce_hello (msg_t *msg_) const;
|
||||
int produce_initiate (msg_t *msg_) const;
|
||||
|
||||
int process_welcome (const unsigned char *cmd_data, size_t data_size);
|
||||
int process_ready (const unsigned char *cmd_data, size_t data_size);
|
||||
int process_error (const unsigned char *cmd_data, size_t data_size);
|
||||
int process_welcome (const unsigned char *cmd_data_, size_t data_size_);
|
||||
int process_ready (const unsigned char *cmd_data_, size_t data_size_);
|
||||
int process_error (const unsigned char *cmd_data_, size_t data_size_);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -246,13 +246,13 @@ int zmq::plain_server_t::produce_error (msg_t *msg_) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void zmq::plain_server_t::send_zap_request (const std::string &username,
|
||||
const std::string &password)
|
||||
void zmq::plain_server_t::send_zap_request (const std::string &username_,
|
||||
const std::string &password_)
|
||||
{
|
||||
const uint8_t *credentials[] = {
|
||||
reinterpret_cast<const uint8_t *> (username.c_str ()),
|
||||
reinterpret_cast<const uint8_t *> (password.c_str ())};
|
||||
size_t credentials_sizes[] = {username.size (), password.size ()};
|
||||
reinterpret_cast<const uint8_t *> (username_.c_str ()),
|
||||
reinterpret_cast<const uint8_t *> (password_.c_str ())};
|
||||
size_t credentials_sizes[] = {username_.size (), password_.size ()};
|
||||
zap_client_t::send_zap_request ("PLAIN", 5, credentials, credentials_sizes,
|
||||
2);
|
||||
}
|
||||
|
@ -58,8 +58,8 @@ class plain_server_t : public zap_client_common_handshake_t
|
||||
int process_hello (msg_t *msg_);
|
||||
int process_initiate (msg_t *msg_);
|
||||
|
||||
void send_zap_request (const std::string &username,
|
||||
const std::string &password);
|
||||
void send_zap_request (const std::string &username_,
|
||||
const std::string &password_);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -110,9 +110,9 @@ int capture (class zmq::socket_base_t *capture_,
|
||||
}
|
||||
|
||||
int forward (class zmq::socket_base_t *from_,
|
||||
zmq_socket_stats_t *from_stats,
|
||||
zmq_socket_stats_t *from_stats_,
|
||||
class zmq::socket_base_t *to_,
|
||||
zmq_socket_stats_t *to_stats,
|
||||
zmq_socket_stats_t *to_stats_,
|
||||
class zmq::socket_base_t *capture_,
|
||||
zmq::msg_t &msg_)
|
||||
{
|
||||
@ -145,60 +145,61 @@ int forward (class zmq::socket_base_t *from_,
|
||||
}
|
||||
|
||||
// A multipart message counts as 1 packet:
|
||||
from_stats->msg_in++;
|
||||
from_stats->bytes_in += complete_msg_size;
|
||||
to_stats->msg_out++;
|
||||
to_stats->bytes_out += complete_msg_size;
|
||||
from_stats_->msg_in++;
|
||||
from_stats_->bytes_in += complete_msg_size;
|
||||
to_stats_->msg_out++;
|
||||
to_stats_->bytes_out += complete_msg_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int loop_and_send_multipart_stat (zmq::socket_base_t *control_,
|
||||
uint64_t stat,
|
||||
bool first,
|
||||
bool more)
|
||||
uint64_t stat_,
|
||||
bool first_,
|
||||
bool more_)
|
||||
{
|
||||
int rc;
|
||||
zmq::msg_t msg;
|
||||
|
||||
// VSM of 8 bytes can't fail to init
|
||||
msg.init_size (sizeof (uint64_t));
|
||||
memcpy (msg.data (), (const void *) &stat, sizeof (uint64_t));
|
||||
memcpy (msg.data (), (const void *) &stat_, sizeof (uint64_t));
|
||||
|
||||
// if the first message is handed to the pipe successfully then the HWM
|
||||
// is not full, which means failures are due to interrupts (on Windows pipes
|
||||
// are TCP sockets), so keep retrying
|
||||
do {
|
||||
rc = control_->send (&msg, more ? ZMQ_SNDMORE : 0);
|
||||
} while (!first && rc != 0 && errno == EAGAIN);
|
||||
rc = control_->send (&msg, more_ ? ZMQ_SNDMORE : 0);
|
||||
} while (!first_ && rc != 0 && errno == EAGAIN);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int reply_stats (class zmq::socket_base_t *control_,
|
||||
zmq_socket_stats_t *frontend_stats,
|
||||
zmq_socket_stats_t *backend_stats)
|
||||
zmq_socket_stats_t *frontend_stats_,
|
||||
zmq_socket_stats_t *backend_stats_)
|
||||
{
|
||||
// first part: frontend stats - the first send might fail due to HWM
|
||||
if (loop_and_send_multipart_stat (control_, frontend_stats->msg_in, true,
|
||||
if (loop_and_send_multipart_stat (control_, frontend_stats_->msg_in, true,
|
||||
true)
|
||||
!= 0)
|
||||
return -1;
|
||||
|
||||
loop_and_send_multipart_stat (control_, frontend_stats->bytes_in, false,
|
||||
loop_and_send_multipart_stat (control_, frontend_stats_->bytes_in, false,
|
||||
true);
|
||||
loop_and_send_multipart_stat (control_, frontend_stats->msg_out, false,
|
||||
loop_and_send_multipart_stat (control_, frontend_stats_->msg_out, false,
|
||||
true);
|
||||
loop_and_send_multipart_stat (control_, frontend_stats->bytes_out, false,
|
||||
loop_and_send_multipart_stat (control_, frontend_stats_->bytes_out, false,
|
||||
true);
|
||||
|
||||
// second part: backend stats
|
||||
loop_and_send_multipart_stat (control_, backend_stats->msg_in, false, true);
|
||||
loop_and_send_multipart_stat (control_, backend_stats->bytes_in, false,
|
||||
loop_and_send_multipart_stat (control_, backend_stats_->msg_in, false,
|
||||
true);
|
||||
loop_and_send_multipart_stat (control_, backend_stats->msg_out, false,
|
||||
loop_and_send_multipart_stat (control_, backend_stats_->bytes_in, false,
|
||||
true);
|
||||
loop_and_send_multipart_stat (control_, backend_stats->bytes_out, false,
|
||||
loop_and_send_multipart_stat (control_, backend_stats_->msg_out, false,
|
||||
true);
|
||||
loop_and_send_multipart_stat (control_, backend_stats_->bytes_out, false,
|
||||
false);
|
||||
|
||||
return 0;
|
||||
|
@ -119,7 +119,7 @@ static unsigned int random_refcount = 0;
|
||||
static zmq::mutex_t random_sync;
|
||||
#endif
|
||||
|
||||
static void manage_random (bool init)
|
||||
static void manage_random (bool init_)
|
||||
{
|
||||
#if defined(ZMQ_USE_TWEETNACL) && !defined(ZMQ_HAVE_WINDOWS) \
|
||||
&& !defined(ZMQ_HAVE_GETRANDOM)
|
||||
@ -129,7 +129,7 @@ static void manage_random (bool init)
|
||||
static zmq::mutex_t random_sync;
|
||||
#endif
|
||||
|
||||
if (init) {
|
||||
if (init_) {
|
||||
zmq::scoped_lock_t locker (random_sync);
|
||||
|
||||
if (random_refcount == 0) {
|
||||
@ -148,7 +148,7 @@ static void manage_random (bool init)
|
||||
}
|
||||
|
||||
#elif defined(ZMQ_USE_LIBSODIUM)
|
||||
if (init) {
|
||||
if (init_) {
|
||||
int rc = sodium_init ();
|
||||
zmq_assert (rc != -1);
|
||||
} else {
|
||||
|
@ -50,7 +50,7 @@ class raw_decoder_t : public i_decoder
|
||||
virtual void get_buffer (unsigned char **data_, size_t *size_);
|
||||
|
||||
virtual int
|
||||
decode (const unsigned char *data_, size_t size_, size_t &processed);
|
||||
decode (const unsigned char *data_, size_t size_, size_t &processed_);
|
||||
|
||||
virtual msg_t *msg () { return &in_progress; }
|
||||
|
||||
|
@ -42,7 +42,7 @@ class socket_base_t;
|
||||
class rep_t : public router_t
|
||||
{
|
||||
public:
|
||||
rep_t (zmq::ctx_t *parent_, uint32_t tid_, int sid);
|
||||
rep_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||
~rep_t ();
|
||||
|
||||
// Overrides of functions from socket_base_t.
|
||||
|
@ -37,10 +37,10 @@
|
||||
#include "likely.hpp"
|
||||
|
||||
extern "C" {
|
||||
static void free_id (void *data, void *hint)
|
||||
static void free_id (void *data_, void *hint_)
|
||||
{
|
||||
LIBZMQ_UNUSED (hint);
|
||||
free (data);
|
||||
LIBZMQ_UNUSED (hint_);
|
||||
free (data_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class pipe_t;
|
||||
class router_t : public socket_base_t
|
||||
{
|
||||
public:
|
||||
router_t (zmq::ctx_t *parent_, uint32_t tid_, int sid);
|
||||
router_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||
~router_t ();
|
||||
|
||||
// Overrides of functions from socket_base_t.
|
||||
@ -61,7 +61,7 @@ class router_t : public socket_base_t
|
||||
void xread_activated (zmq::pipe_t *pipe_);
|
||||
void xwrite_activated (zmq::pipe_t *pipe_);
|
||||
void xpipe_terminated (zmq::pipe_t *pipe_);
|
||||
int get_peer_state (const void *identity, size_t identity_size) const;
|
||||
int get_peer_state (const void *identity_, size_t identity_size_) const;
|
||||
|
||||
protected:
|
||||
// Rollback any message parts that were sent but not yet flushed.
|
||||
|
@ -103,11 +103,11 @@ zmq::select_t::handle_t zmq::select_t::add_fd (fd_t fd_, i_poll_events *events_)
|
||||
}
|
||||
|
||||
zmq::select_t::fd_entries_t::iterator
|
||||
zmq::select_t::find_fd_entry_by_handle (fd_entries_t &fd_entries,
|
||||
zmq::select_t::find_fd_entry_by_handle (fd_entries_t &fd_entries_,
|
||||
handle_t handle_)
|
||||
{
|
||||
fd_entries_t::iterator fd_entry_it;
|
||||
for (fd_entry_it = fd_entries.begin (); fd_entry_it != fd_entries.end ();
|
||||
for (fd_entry_it = fd_entries_.begin (); fd_entry_it != fd_entries_.end ();
|
||||
++fd_entry_it)
|
||||
if (fd_entry_it->fd == handle_)
|
||||
break;
|
||||
@ -158,9 +158,9 @@ void zmq::select_t::trigger_events (const fd_entries_t &fd_entries_,
|
||||
|
||||
#if defined ZMQ_HAVE_WINDOWS
|
||||
int zmq::select_t::try_retire_fd_entry (
|
||||
family_entries_t::iterator family_entry_it, zmq::fd_t &handle_)
|
||||
family_entries_t::iterator family_entry_it_, zmq::fd_t &handle_)
|
||||
{
|
||||
family_entry_t &family_entry = family_entry_it->second;
|
||||
family_entry_t &family_entry = family_entry_it_->second;
|
||||
|
||||
fd_entries_t::iterator fd_entry_it =
|
||||
find_fd_entry_by_handle (family_entry.fd_entries, handle_);
|
||||
@ -171,7 +171,7 @@ int zmq::select_t::try_retire_fd_entry (
|
||||
fd_entry_t &fd_entry = *fd_entry_it;
|
||||
zmq_assert (fd_entry.fd != retired_fd);
|
||||
|
||||
if (family_entry_it != current_family_entry_it) {
|
||||
if (family_entry_it_ != current_family_entry_it) {
|
||||
// Family is not currently being iterated and can be safely
|
||||
// modified in-place. So later it can be skipped without
|
||||
// re-verifying its content.
|
||||
@ -530,9 +530,9 @@ void zmq::select_t::cleanup_retired ()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool zmq::select_t::is_retired_fd (const fd_entry_t &entry)
|
||||
bool zmq::select_t::is_retired_fd (const fd_entry_t &entry_)
|
||||
{
|
||||
return (entry.fd == retired_fd);
|
||||
return (entry_.fd == retired_fd);
|
||||
}
|
||||
|
||||
zmq::select_t::family_entry_t::family_entry_t () : has_retired (false)
|
||||
|
@ -135,7 +135,7 @@ class select_t : public worker_poller_base_t
|
||||
// See loop for details.
|
||||
family_entries_t::iterator current_family_entry_it;
|
||||
|
||||
int try_retire_fd_entry (family_entries_t::iterator family_entry_it,
|
||||
int try_retire_fd_entry (family_entries_t::iterator family_entry_it_,
|
||||
zmq::fd_t &handle_);
|
||||
|
||||
static const size_t fd_family_cache_size = 8;
|
||||
@ -155,10 +155,10 @@ class select_t : public worker_poller_base_t
|
||||
bool cleanup_retired (family_entry_t &family_entry_);
|
||||
|
||||
// Checks if an fd_entry_t is retired.
|
||||
static bool is_retired_fd (const fd_entry_t &entry);
|
||||
static bool is_retired_fd (const fd_entry_t &entry_);
|
||||
|
||||
static fd_entries_t::iterator
|
||||
find_fd_entry_by_handle (fd_entries_t &fd_entries, handle_t handle_);
|
||||
find_fd_entry_by_handle (fd_entries_t &fd_entries_, handle_t handle_);
|
||||
|
||||
select_t (const select_t &);
|
||||
const select_t &operator= (const select_t &);
|
||||
|
@ -48,7 +48,7 @@ class pipe_t;
|
||||
class server_t : public socket_base_t
|
||||
{
|
||||
public:
|
||||
server_t (zmq::ctx_t *parent_, uint32_t tid_, int sid);
|
||||
server_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||
~server_t ();
|
||||
|
||||
// Overrides of functions from socket_base_t.
|
||||
|
@ -416,7 +416,7 @@ void zmq::session_base_t::process_attach (i_engine *engine_)
|
||||
}
|
||||
|
||||
void zmq::session_base_t::engine_error (
|
||||
zmq::stream_engine_t::error_reason_t reason)
|
||||
zmq::stream_engine_t::error_reason_t reason_)
|
||||
{
|
||||
// Engine is dead. Let's forget about it.
|
||||
engine = NULL;
|
||||
@ -425,11 +425,11 @@ void zmq::session_base_t::engine_error (
|
||||
if (pipe)
|
||||
clean_pipes ();
|
||||
|
||||
zmq_assert (reason == stream_engine_t::connection_error
|
||||
|| reason == stream_engine_t::timeout_error
|
||||
|| reason == stream_engine_t::protocol_error);
|
||||
zmq_assert (reason_ == stream_engine_t::connection_error
|
||||
|| reason_ == stream_engine_t::timeout_error
|
||||
|| reason_ == stream_engine_t::protocol_error);
|
||||
|
||||
switch (reason) {
|
||||
switch (reason_) {
|
||||
case stream_engine_t::timeout_error:
|
||||
/* FALLTHROUGH */
|
||||
case stream_engine_t::connection_error:
|
||||
|
@ -60,7 +60,7 @@ class session_base_t : public own_t, public io_object_t, public i_pipe_events
|
||||
// Following functions are the interface exposed towards the engine.
|
||||
virtual void reset ();
|
||||
void flush ();
|
||||
void engine_error (zmq::stream_engine_t::error_reason_t reason);
|
||||
void engine_error (zmq::stream_engine_t::error_reason_t reason_);
|
||||
|
||||
// i_pipe_events interface implementation.
|
||||
void read_activated (zmq::pipe_t *pipe_);
|
||||
|
@ -978,12 +978,12 @@ int zmq::socket_base_t::connect (const char *addr_)
|
||||
|
||||
void zmq::socket_base_t::add_endpoint (const char *addr_,
|
||||
own_t *endpoint_,
|
||||
pipe_t *pipe)
|
||||
pipe_t *pipe_)
|
||||
{
|
||||
// Activate the session. Make it a child of this socket.
|
||||
launch_child (endpoint_);
|
||||
endpoints.ZMQ_MAP_INSERT_OR_EMPLACE (std::string (addr_),
|
||||
endpoint_pipe_t (endpoint_, pipe));
|
||||
endpoint_pipe_t (endpoint_, pipe_));
|
||||
}
|
||||
|
||||
int zmq::socket_base_t::term_endpoint (const char *addr_)
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include "pipe.hpp"
|
||||
|
||||
extern "C" {
|
||||
void zmq_free_event (void *data, void *hint);
|
||||
void zmq_free_event (void *data_, void *hint_);
|
||||
}
|
||||
|
||||
namespace zmq
|
||||
@ -87,8 +87,8 @@ class socket_base_t : public own_t,
|
||||
int term_endpoint (const char *addr_);
|
||||
int send (zmq::msg_t *msg_, int flags_);
|
||||
int recv (zmq::msg_t *msg_, int flags_);
|
||||
void add_signaler (signaler_t *s);
|
||||
void remove_signaler (signaler_t *s);
|
||||
void add_signaler (signaler_t *s_);
|
||||
void remove_signaler (signaler_t *s_);
|
||||
int close ();
|
||||
|
||||
// These functions are used by the polling mechanism to determine
|
||||
@ -97,8 +97,8 @@ class socket_base_t : public own_t,
|
||||
bool has_out ();
|
||||
|
||||
// Joining and leaving groups
|
||||
int join (const char *group);
|
||||
int leave (const char *group);
|
||||
int join (const char *group_);
|
||||
int leave (const char *group_);
|
||||
|
||||
// Using this function reaper thread ask the socket to register with
|
||||
// its poller.
|
||||
@ -137,8 +137,8 @@ class socket_base_t : public own_t,
|
||||
|
||||
// Query the state of a specific peer. The default implementation
|
||||
// always returns an ENOTSUP error.
|
||||
virtual int get_peer_state (const void *identity,
|
||||
size_t identity_size) const;
|
||||
virtual int get_peer_state (const void *identity_,
|
||||
size_t identity_size_) const;
|
||||
|
||||
protected:
|
||||
socket_base_t (zmq::ctx_t *parent_,
|
||||
@ -198,7 +198,7 @@ class socket_base_t : public own_t,
|
||||
void stop_monitor (bool send_monitor_stopped_event_ = true);
|
||||
|
||||
// Creates new endpoint ID and adds the endpoint to the map.
|
||||
void add_endpoint (const char *addr_, own_t *endpoint_, pipe_t *pipe);
|
||||
void add_endpoint (const char *addr_, own_t *endpoint_, pipe_t *pipe_);
|
||||
|
||||
// Map of open endpoints.
|
||||
typedef std::pair<own_t *, pipe_t *> endpoint_pipe_t;
|
||||
|
@ -33,10 +33,10 @@
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
static bool is_thread_safe (zmq::socket_base_t &socket)
|
||||
static bool is_thread_safe (zmq::socket_base_t &socket_)
|
||||
{
|
||||
// do not use getsockopt here, since that would fail during context termination
|
||||
return socket.is_thread_safe ();
|
||||
return socket_.is_thread_safe ();
|
||||
}
|
||||
|
||||
zmq::socket_poller_t::socket_poller_t () :
|
||||
@ -399,9 +399,9 @@ void zmq::socket_poller_t::rebuild ()
|
||||
}
|
||||
|
||||
void zmq::socket_poller_t::zero_trail_events (
|
||||
zmq::socket_poller_t::event_t *events_, int n_events_, int found)
|
||||
zmq::socket_poller_t::event_t *events_, int n_events_, int found_)
|
||||
{
|
||||
for (int i = found; i < n_events_; ++i) {
|
||||
for (int i = found_; i < n_events_; ++i) {
|
||||
events_[i].socket = NULL;
|
||||
events_[i].fd = 0;
|
||||
events_[i].user_data = NULL;
|
||||
@ -415,9 +415,9 @@ int zmq::socket_poller_t::check_events (zmq::socket_poller_t::event_t *events_,
|
||||
#elif defined ZMQ_POLL_BASED_ON_SELECT
|
||||
int zmq::socket_poller_t::check_events (zmq::socket_poller_t::event_t *events_,
|
||||
int n_events_,
|
||||
fd_set &inset,
|
||||
fd_set &outset,
|
||||
fd_set &errset)
|
||||
fd_set &inset_,
|
||||
fd_set &outset_,
|
||||
fd_set &errset_)
|
||||
#endif
|
||||
{
|
||||
int found = 0;
|
||||
@ -461,11 +461,11 @@ int zmq::socket_poller_t::check_events (zmq::socket_poller_t::event_t *events_,
|
||||
|
||||
short events = 0;
|
||||
|
||||
if (FD_ISSET (it->fd, &inset))
|
||||
if (FD_ISSET (it->fd, &inset_))
|
||||
events |= ZMQ_POLLIN;
|
||||
if (FD_ISSET (it->fd, &outset))
|
||||
if (FD_ISSET (it->fd, &outset_))
|
||||
events |= ZMQ_POLLOUT;
|
||||
if (FD_ISSET (it->fd, &errset))
|
||||
if (FD_ISSET (it->fd, &errset_))
|
||||
events |= ZMQ_POLLERR;
|
||||
#endif //POLL_SELECT
|
||||
|
||||
@ -483,11 +483,11 @@ int zmq::socket_poller_t::check_events (zmq::socket_poller_t::event_t *events_,
|
||||
}
|
||||
|
||||
//Return 0 if timeout is expired otherwise 1
|
||||
int zmq::socket_poller_t::adjust_timeout (zmq::clock_t &clock,
|
||||
int zmq::socket_poller_t::adjust_timeout (zmq::clock_t &clock_,
|
||||
long timeout_,
|
||||
uint64_t &now,
|
||||
uint64_t &end,
|
||||
bool &first_pass)
|
||||
uint64_t &now_,
|
||||
uint64_t &end_,
|
||||
bool &first_pass_)
|
||||
{
|
||||
// If socket_poller_t::timeout is zero, exit immediately whether there
|
||||
// are events or not.
|
||||
@ -497,8 +497,8 @@ int zmq::socket_poller_t::adjust_timeout (zmq::clock_t &clock,
|
||||
// At this point we are meant to wait for events but there are none.
|
||||
// If timeout is infinite we can just loop until we get some events.
|
||||
if (timeout_ < 0) {
|
||||
if (first_pass)
|
||||
first_pass = false;
|
||||
if (first_pass_)
|
||||
first_pass_ = false;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -506,15 +506,15 @@ int zmq::socket_poller_t::adjust_timeout (zmq::clock_t &clock,
|
||||
// we get a timestamp of when the polling have begun. (We assume that
|
||||
// first pass have taken negligible time). We also compute the time
|
||||
// when the polling should time out.
|
||||
now = clock.now_ms ();
|
||||
if (first_pass) {
|
||||
end = now + timeout_;
|
||||
first_pass = false;
|
||||
now_ = clock_.now_ms ();
|
||||
if (first_pass_) {
|
||||
end_ = now_ + timeout_;
|
||||
first_pass_ = false;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Find out whether timeout have expired.
|
||||
if (now >= end)
|
||||
if (now_ >= end_)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
@ -67,15 +67,15 @@ class socket_poller_t
|
||||
short events;
|
||||
} event_t;
|
||||
|
||||
int add (socket_base_t *socket, void *user_data, short events);
|
||||
int modify (socket_base_t *socket, short events);
|
||||
int remove (socket_base_t *socket);
|
||||
int add (socket_base_t *socket_, void *user_data_, short events_);
|
||||
int modify (socket_base_t *socket_, short events_);
|
||||
int remove (socket_base_t *socket_);
|
||||
|
||||
int add_fd (fd_t fd, void *user_data, short events);
|
||||
int modify_fd (fd_t fd, short events);
|
||||
int remove_fd (fd_t fd);
|
||||
int add_fd (fd_t fd_, void *user_data_, short events_);
|
||||
int modify_fd (fd_t fd_, short events_);
|
||||
int remove_fd (fd_t fd_);
|
||||
|
||||
int wait (event_t *event, int n_events, long timeout);
|
||||
int wait (event_t *event_, int n_events_, long timeout_);
|
||||
|
||||
inline int size (void) { return static_cast<int> (items.size ()); };
|
||||
|
||||
@ -85,21 +85,21 @@ class socket_poller_t
|
||||
private:
|
||||
void zero_trail_events (zmq::socket_poller_t::event_t *events_,
|
||||
int n_events_,
|
||||
int found);
|
||||
int found_);
|
||||
#if defined ZMQ_POLL_BASED_ON_POLL
|
||||
int check_events (zmq::socket_poller_t::event_t *events_, int n_events_);
|
||||
#elif defined ZMQ_POLL_BASED_ON_SELECT
|
||||
int check_events (zmq::socket_poller_t::event_t *events_,
|
||||
int n_events_,
|
||||
fd_set &inset,
|
||||
fd_set &outset,
|
||||
fd_set &errset);
|
||||
fd_set &inset_,
|
||||
fd_set &outset_,
|
||||
fd_set &errset_);
|
||||
#endif
|
||||
int adjust_timeout (zmq::clock_t &clock,
|
||||
int adjust_timeout (zmq::clock_t &clock_,
|
||||
long timeout_,
|
||||
uint64_t &now,
|
||||
uint64_t &end,
|
||||
bool &first_pass);
|
||||
uint64_t &now_,
|
||||
uint64_t &end_,
|
||||
bool &first_pass_);
|
||||
void rebuild ();
|
||||
|
||||
// Used to check whether the object is a socket_poller.
|
||||
|
@ -144,13 +144,13 @@ zmq::socks_request_encoder_t::socks_request_encoder_t () :
|
||||
{
|
||||
}
|
||||
|
||||
void zmq::socks_request_encoder_t::encode (const socks_request_t &req)
|
||||
void zmq::socks_request_encoder_t::encode (const socks_request_t &req_)
|
||||
{
|
||||
zmq_assert (req.hostname.size () <= UINT8_MAX);
|
||||
zmq_assert (req_.hostname.size () <= UINT8_MAX);
|
||||
|
||||
unsigned char *ptr = buf;
|
||||
*ptr++ = 0x05;
|
||||
*ptr++ = req.command;
|
||||
*ptr++ = req_.command;
|
||||
*ptr++ = 0x00;
|
||||
|
||||
#if defined ZMQ_HAVE_OPENVMS && defined __ia64 && __INITIAL_POINTER_SIZE == 64
|
||||
@ -164,7 +164,7 @@ void zmq::socks_request_encoder_t::encode (const socks_request_t &req)
|
||||
// Suppress potential DNS lookups.
|
||||
hints.ai_flags = AI_NUMERICHOST;
|
||||
|
||||
const int rc = getaddrinfo (req.hostname.c_str (), NULL, &hints, &res);
|
||||
const int rc = getaddrinfo (req_.hostname.c_str (), NULL, &hints, &res);
|
||||
if (rc == 0 && res->ai_family == AF_INET) {
|
||||
const struct sockaddr_in *sockaddr_in =
|
||||
reinterpret_cast<const struct sockaddr_in *> (res->ai_addr);
|
||||
@ -179,16 +179,16 @@ void zmq::socks_request_encoder_t::encode (const socks_request_t &req)
|
||||
ptr += 16;
|
||||
} else {
|
||||
*ptr++ = 0x03;
|
||||
*ptr++ = static_cast<unsigned char> (req.hostname.size ());
|
||||
memcpy (ptr, req.hostname.c_str (), req.hostname.size ());
|
||||
ptr += req.hostname.size ();
|
||||
*ptr++ = static_cast<unsigned char> (req_.hostname.size ());
|
||||
memcpy (ptr, req_.hostname.c_str (), req_.hostname.size ());
|
||||
ptr += req_.hostname.size ();
|
||||
}
|
||||
|
||||
if (rc == 0)
|
||||
freeaddrinfo (res);
|
||||
|
||||
*ptr++ = req.port / 256;
|
||||
*ptr++ = req.port % 256;
|
||||
*ptr++ = req_.port / 256;
|
||||
*ptr++ = req_.port % 256;
|
||||
|
||||
bytes_encoded = ptr - buf;
|
||||
bytes_written = 0;
|
||||
|
@ -38,7 +38,7 @@ namespace zmq
|
||||
{
|
||||
struct socks_greeting_t
|
||||
{
|
||||
socks_greeting_t (uint8_t method);
|
||||
socks_greeting_t (uint8_t method_);
|
||||
socks_greeting_t (uint8_t *methods_, uint8_t num_methods_);
|
||||
|
||||
uint8_t methods[UINT8_MAX];
|
||||
@ -94,7 +94,7 @@ class socks_request_encoder_t
|
||||
{
|
||||
public:
|
||||
socks_request_encoder_t ();
|
||||
void encode (const socks_request_t &req);
|
||||
void encode (const socks_request_t &req_);
|
||||
int output (fd_t fd_);
|
||||
bool has_pending_data () const;
|
||||
void reset ();
|
||||
|
@ -235,16 +235,16 @@ void zmq::socks_connecter_t::initiate_connect ()
|
||||
}
|
||||
|
||||
int zmq::socks_connecter_t::process_server_response (
|
||||
const socks_choice_t &response)
|
||||
const socks_choice_t &response_)
|
||||
{
|
||||
// We do not support any authentication method for now.
|
||||
return response.method == 0 ? 0 : -1;
|
||||
return response_.method == 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
int zmq::socks_connecter_t::process_server_response (
|
||||
const socks_response_t &response)
|
||||
const socks_response_t &response_)
|
||||
{
|
||||
return response.response_code == 0 ? 0 : -1;
|
||||
return response_.response_code == 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
void zmq::socks_connecter_t::timer_event (int id_)
|
||||
|
@ -91,8 +91,8 @@ class socks_connecter_t : public own_t, public io_object_t
|
||||
// Internal function to start the actual connection establishment.
|
||||
void initiate_connect ();
|
||||
|
||||
int process_server_response (const socks_choice_t &response);
|
||||
int process_server_response (const socks_response_t &response);
|
||||
int process_server_response (const socks_choice_t &response_);
|
||||
int process_server_response (const socks_response_t &response_);
|
||||
|
||||
int parse_address (const std::string &address_,
|
||||
std::string &hostname_,
|
||||
|
@ -42,7 +42,7 @@ class pipe_t;
|
||||
class stream_t : public socket_base_t
|
||||
{
|
||||
public:
|
||||
stream_t (zmq::ctx_t *parent_, uint32_t tid_, int sid);
|
||||
stream_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
||||
~stream_t ();
|
||||
|
||||
// Overrides of functions from socket_base_t.
|
||||
|
@ -958,7 +958,7 @@ int zmq::stream_engine_t::push_one_then_decode_and_push (msg_t *msg_)
|
||||
return rc;
|
||||
}
|
||||
|
||||
void zmq::stream_engine_t::error (error_reason_t reason)
|
||||
void zmq::stream_engine_t::error (error_reason_t reason_)
|
||||
{
|
||||
if (options.raw_socket && options.raw_notify) {
|
||||
// For raw sockets, send a final 0-length message to the application
|
||||
@ -971,7 +971,7 @@ void zmq::stream_engine_t::error (error_reason_t reason)
|
||||
zmq_assert (session);
|
||||
#ifdef ZMQ_BUILD_DRAFT_API
|
||||
// protocol errors have been signaled already at the point where they occurred
|
||||
if (reason != protocol_error
|
||||
if (reason_ != protocol_error
|
||||
&& (mechanism == NULL
|
||||
|| mechanism->status () == mechanism_t::handshaking)) {
|
||||
int err = errno;
|
||||
@ -980,7 +980,7 @@ void zmq::stream_engine_t::error (error_reason_t reason)
|
||||
#endif
|
||||
socket->event_disconnected (endpoint, s);
|
||||
session->flush ();
|
||||
session->engine_error (reason);
|
||||
session->engine_error (reason_);
|
||||
unplug ();
|
||||
delete this;
|
||||
}
|
||||
@ -995,19 +995,19 @@ void zmq::stream_engine_t::set_handshake_timer ()
|
||||
}
|
||||
}
|
||||
|
||||
bool zmq::stream_engine_t::init_properties (properties_t &properties)
|
||||
bool zmq::stream_engine_t::init_properties (properties_t &properties_)
|
||||
{
|
||||
if (peer_address.empty ())
|
||||
return false;
|
||||
properties.ZMQ_MAP_INSERT_OR_EMPLACE (
|
||||
properties_.ZMQ_MAP_INSERT_OR_EMPLACE (
|
||||
std::string (ZMQ_MSG_PROPERTY_PEER_ADDRESS), peer_address);
|
||||
|
||||
// Private property to support deprecated SRCFD
|
||||
std::ostringstream stream;
|
||||
stream << static_cast<int> (s);
|
||||
std::string fd_string = stream.str ();
|
||||
properties.ZMQ_MAP_INSERT_OR_EMPLACE (std::string ("__fd"),
|
||||
ZMQ_MOVE (fd_string));
|
||||
properties_.ZMQ_MAP_INSERT_OR_EMPLACE (std::string ("__fd"),
|
||||
ZMQ_MOVE (fd_string));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ class stream_engine_t : public io_object_t, public i_engine
|
||||
|
||||
stream_engine_t (fd_t fd_,
|
||||
const options_t &options_,
|
||||
const std::string &endpoint);
|
||||
const std::string &endpoint_);
|
||||
~stream_engine_t ();
|
||||
|
||||
// i_engine interface implementation.
|
||||
@ -91,7 +91,7 @@ class stream_engine_t : public io_object_t, public i_engine
|
||||
void unplug ();
|
||||
|
||||
// Function to handle network disconnections.
|
||||
void error (error_reason_t reason);
|
||||
void error (error_reason_t reason_);
|
||||
|
||||
// Receives the greeting message from the peer.
|
||||
int receive_greeting ();
|
||||
@ -102,13 +102,13 @@ class stream_engine_t : public io_object_t, public i_engine
|
||||
int routing_id_msg (msg_t *msg_);
|
||||
int process_routing_id_msg (msg_t *msg_);
|
||||
|
||||
int next_handshake_command (msg_t *msg);
|
||||
int process_handshake_command (msg_t *msg);
|
||||
int next_handshake_command (msg_t *msg_);
|
||||
int process_handshake_command (msg_t *msg_);
|
||||
|
||||
int pull_msg_from_session (msg_t *msg_);
|
||||
int push_msg_to_session (msg_t *msg);
|
||||
int push_msg_to_session (msg_t *msg_);
|
||||
|
||||
int push_raw_msg_to_session (msg_t *msg);
|
||||
int push_raw_msg_to_session (msg_t *msg_);
|
||||
|
||||
int write_credential (msg_t *msg_);
|
||||
int pull_and_encode (msg_t *msg_);
|
||||
@ -117,15 +117,15 @@ class stream_engine_t : public io_object_t, public i_engine
|
||||
|
||||
void mechanism_ready ();
|
||||
|
||||
size_t add_property (unsigned char *ptr,
|
||||
const char *name,
|
||||
const void *value,
|
||||
size_t value_len);
|
||||
size_t add_property (unsigned char *ptr_,
|
||||
const char *name_,
|
||||
const void *value_,
|
||||
size_t value_len_);
|
||||
|
||||
void set_handshake_timer ();
|
||||
|
||||
typedef metadata_t::dict_t properties_t;
|
||||
bool init_properties (properties_t &properties);
|
||||
bool init_properties (properties_t &properties_);
|
||||
|
||||
int process_command_message (msg_t *msg_);
|
||||
int produce_ping_message (msg_t *msg_);
|
||||
|
@ -54,19 +54,19 @@ zmq::tcp_address_t::tcp_address_t () : _has_src_addr (false)
|
||||
memset (&source_address, 0, sizeof (source_address));
|
||||
}
|
||||
|
||||
zmq::tcp_address_t::tcp_address_t (const sockaddr *sa, socklen_t sa_len) :
|
||||
zmq::tcp_address_t::tcp_address_t (const sockaddr *sa_, socklen_t sa_len_) :
|
||||
_has_src_addr (false)
|
||||
{
|
||||
zmq_assert (sa && sa_len > 0);
|
||||
zmq_assert (sa_ && sa_len_ > 0);
|
||||
|
||||
memset (&address, 0, sizeof (address));
|
||||
memset (&source_address, 0, sizeof (source_address));
|
||||
if (sa->sa_family == AF_INET
|
||||
&& sa_len >= static_cast<socklen_t> (sizeof (address.ipv4)))
|
||||
memcpy (&address.ipv4, sa, sizeof (address.ipv4));
|
||||
else if (sa->sa_family == AF_INET6
|
||||
&& sa_len >= static_cast<socklen_t> (sizeof (address.ipv6)))
|
||||
memcpy (&address.ipv6, sa, sizeof (address.ipv6));
|
||||
if (sa_->sa_family == AF_INET
|
||||
&& sa_len_ >= static_cast<socklen_t> (sizeof (address.ipv4)))
|
||||
memcpy (&address.ipv4, sa_, sizeof (address.ipv4));
|
||||
else if (sa_->sa_family == AF_INET6
|
||||
&& sa_len_ >= static_cast<socklen_t> (sizeof (address.ipv6)))
|
||||
memcpy (&address.ipv6, sa_, sizeof (address.ipv6));
|
||||
}
|
||||
|
||||
zmq::tcp_address_t::~tcp_address_t ()
|
||||
@ -278,29 +278,30 @@ int zmq::tcp_address_mask_t::to_string (std::string &addr_)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool zmq::tcp_address_mask_t::match_address (const struct sockaddr *ss,
|
||||
const socklen_t ss_len) const
|
||||
bool zmq::tcp_address_mask_t::match_address (const struct sockaddr *ss_,
|
||||
const socklen_t ss_len_) const
|
||||
{
|
||||
zmq_assert (address_mask != -1 && ss != NULL
|
||||
&& ss_len >= (socklen_t) sizeof (struct sockaddr));
|
||||
zmq_assert (address_mask != -1 && ss_ != NULL
|
||||
&& ss_len_ >= (socklen_t) sizeof (struct sockaddr));
|
||||
|
||||
if (ss->sa_family != address.generic.sa_family)
|
||||
if (ss_->sa_family != address.generic.sa_family)
|
||||
return false;
|
||||
|
||||
if (address_mask > 0) {
|
||||
int mask;
|
||||
const uint8_t *our_bytes, *their_bytes;
|
||||
if (ss->sa_family == AF_INET6) {
|
||||
zmq_assert (ss_len == sizeof (struct sockaddr_in6));
|
||||
their_bytes = reinterpret_cast<const uint8_t *> (&(
|
||||
(reinterpret_cast<const struct sockaddr_in6 *> (ss))->sin6_addr));
|
||||
if (ss_->sa_family == AF_INET6) {
|
||||
zmq_assert (ss_len_ == sizeof (struct sockaddr_in6));
|
||||
their_bytes = reinterpret_cast<const uint8_t *> (
|
||||
&((reinterpret_cast<const struct sockaddr_in6 *> (ss_))
|
||||
->sin6_addr));
|
||||
our_bytes =
|
||||
reinterpret_cast<const uint8_t *> (&address.ipv6.sin6_addr);
|
||||
mask = sizeof (struct in6_addr) * 8;
|
||||
} else {
|
||||
zmq_assert (ss_len == sizeof (struct sockaddr_in));
|
||||
their_bytes = reinterpret_cast<const uint8_t *> (
|
||||
&((reinterpret_cast<const struct sockaddr_in *> (ss))->sin_addr));
|
||||
zmq_assert (ss_len_ == sizeof (struct sockaddr_in));
|
||||
their_bytes = reinterpret_cast<const uint8_t *> (&(
|
||||
(reinterpret_cast<const struct sockaddr_in *> (ss_))->sin_addr));
|
||||
our_bytes =
|
||||
reinterpret_cast<const uint8_t *> (&address.ipv4.sin_addr);
|
||||
mask = sizeof (struct in_addr) * 8;
|
||||
|
@ -43,7 +43,7 @@ class tcp_address_t
|
||||
{
|
||||
public:
|
||||
tcp_address_t ();
|
||||
tcp_address_t (const sockaddr *sa, socklen_t sa_len);
|
||||
tcp_address_t (const sockaddr *sa_, socklen_t sa_len_);
|
||||
virtual ~tcp_address_t ();
|
||||
|
||||
// This function translates textual TCP address into an address
|
||||
@ -88,8 +88,8 @@ class tcp_address_mask_t : public tcp_address_t
|
||||
|
||||
int mask () const;
|
||||
|
||||
bool match_address (const struct sockaddr *ss,
|
||||
const socklen_t ss_len) const;
|
||||
bool match_address (const struct sockaddr *ss_,
|
||||
const socklen_t ss_len_) const;
|
||||
|
||||
private:
|
||||
int address_mask;
|
||||
|
@ -419,13 +419,13 @@ zmq::fd_t zmq::tcp_connecter_t::connect ()
|
||||
return result;
|
||||
}
|
||||
|
||||
bool zmq::tcp_connecter_t::tune_socket (const fd_t fd)
|
||||
bool zmq::tcp_connecter_t::tune_socket (const fd_t fd_)
|
||||
{
|
||||
const int rc = tune_tcp_socket (fd)
|
||||
const int rc = tune_tcp_socket (fd_)
|
||||
| tune_tcp_keepalives (
|
||||
fd, options.tcp_keepalive, options.tcp_keepalive_cnt,
|
||||
fd_, options.tcp_keepalive, options.tcp_keepalive_cnt,
|
||||
options.tcp_keepalive_idle, options.tcp_keepalive_intvl)
|
||||
| tune_tcp_maxrt (fd, options.tcp_maxrt);
|
||||
| tune_tcp_maxrt (fd_, options.tcp_maxrt);
|
||||
return rc == 0;
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ class tcp_connecter_t : public own_t, public io_object_t
|
||||
fd_t connect ();
|
||||
|
||||
// Tunes a connected socket.
|
||||
bool tune_socket (fd_t fd);
|
||||
bool tune_socket (fd_t fd_);
|
||||
|
||||
// Address to connect to. Owned by session_base_t.
|
||||
address_t *const addr;
|
||||
|
@ -83,11 +83,11 @@ void zmq::thread_t::stop ()
|
||||
}
|
||||
|
||||
void zmq::thread_t::setSchedulingParameters (
|
||||
int priority_, int schedulingPolicy_, const std::set<int> &affinity_cpus_)
|
||||
int priority_, int scheduling_policy_, const std::set<int> &affinity_cpus_)
|
||||
{
|
||||
// not implemented
|
||||
LIBZMQ_UNUSED (priority_);
|
||||
LIBZMQ_UNUSED (schedulingPolicy_);
|
||||
LIBZMQ_UNUSED (scheduling_policy_);
|
||||
LIBZMQ_UNUSED (affinity_cpus_);
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ class thread_t
|
||||
// Sets the thread scheduling parameters. Only implemented for
|
||||
// pthread. Has no effect on other platforms.
|
||||
void setSchedulingParameters (int priority_,
|
||||
int schedulingPolicy_,
|
||||
int scheduling_policy_,
|
||||
const std::set<int> &affinity_cpus_);
|
||||
|
||||
// Sets the thread name, 16 characters max including terminating NUL.
|
||||
|
@ -66,9 +66,9 @@ struct zmq::timers_t::match_by_id
|
||||
{
|
||||
match_by_id (int timer_id_) : timer_id (timer_id_) {}
|
||||
|
||||
bool operator() (timersmap_t::value_type const &entry) const
|
||||
bool operator() (timersmap_t::value_type const &entry_) const
|
||||
{
|
||||
return entry.second.timer_id == timer_id;
|
||||
return entry_.second.timer_id == timer_id;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -38,7 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace zmq
|
||||
{
|
||||
typedef void(timers_timer_fn) (int timer_id, void *arg);
|
||||
typedef void(timers_timer_fn) (int timer_id_, void *arg_);
|
||||
|
||||
class timers_t
|
||||
{
|
||||
@ -49,21 +49,21 @@ class timers_t
|
||||
// Add timer to the set, timer repeats forever, or until cancel is called.
|
||||
// Returns a timer_id that is used to cancel the timer.
|
||||
// Returns -1 if there was an error.
|
||||
int add (size_t interval, timers_timer_fn handler, void *arg);
|
||||
int add (size_t interval_, timers_timer_fn handler_, void *arg_);
|
||||
|
||||
// Set the interval of the timer.
|
||||
// This method is slow, cancelling exsting and adding a new timer yield better performance.
|
||||
// Returns 0 on success and -1 on error.
|
||||
int set_interval (int timer_id, size_t interval);
|
||||
int set_interval (int timer_id_, size_t interval_);
|
||||
|
||||
// Reset the timer.
|
||||
// This method is slow, cancelling exsting and adding a new timer yield better performance.
|
||||
// Returns 0 on success and -1 on error.
|
||||
int reset (int timer_id);
|
||||
int reset (int timer_id_);
|
||||
|
||||
// Cancel a timer.
|
||||
// Returns 0 on success and -1 on error.
|
||||
int cancel (int timer_id);
|
||||
int cancel (int timer_id_);
|
||||
|
||||
// Returns the time in millisecond until the next timer.
|
||||
// Returns -1 if no timer is due.
|
||||
|
@ -57,18 +57,20 @@ int randombytes_close (void);
|
||||
/* Do not call manually! Use random_open from random.hpp */
|
||||
int sodium_init (void);
|
||||
|
||||
int crypto_box_keypair (u8 *y, u8 *x);
|
||||
int crypto_box_afternm (u8 *c, const u8 *m, u64 d, const u8 *n, const u8 *k);
|
||||
int crypto_box_keypair (u8 *y_, u8 *x_);
|
||||
int crypto_box_afternm (
|
||||
u8 *c_, const u8 *m_, u64 d_, const u8 *n_, const u8 *k_);
|
||||
int crypto_box_open_afternm (
|
||||
u8 *m, const u8 *c, u64 d, const u8 *n, const u8 *k);
|
||||
u8 *m_, const u8 *c_, u64 d_, const u8 *n_, const u8 *k_);
|
||||
int crypto_box (
|
||||
u8 *c, const u8 *m, u64 d, const u8 *n, const u8 *y, const u8 *x);
|
||||
u8 *c_, const u8 *m_, u64 d_, const u8 *n_, const u8 *y_, const u8 *x_);
|
||||
int crypto_box_open (
|
||||
u8 *m, const u8 *c, u64 d, const u8 *n, const u8 *y, const u8 *x);
|
||||
int crypto_box_beforenm (u8 *k, const u8 *y, const u8 *x);
|
||||
int crypto_scalarmult_base (u8 *q, const u8 *n);
|
||||
int crypto_secretbox (u8 *c, const u8 *m, u64 d, const u8 *n, const u8 *k);
|
||||
int crypto_secretbox_open (u8 *m, const u8 *c, u64 d, const u8 *n, const u8 *k);
|
||||
u8 *m_, const u8 *c_, u64 d_, const u8 *n_, const u8 *y_, const u8 *x_);
|
||||
int crypto_box_beforenm (u8 *k_, const u8 *y_, const u8 *x_);
|
||||
int crypto_scalarmult_base (u8 *q_, const u8 *n_);
|
||||
int crypto_secretbox (u8 *c_, const u8 *m_, u64 d_, const u8 *n_, const u8 *k_);
|
||||
int crypto_secretbox_open (
|
||||
u8 *m_, const u8 *c_, u64 d_, const u8 *n_, const u8 *k_);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -287,20 +287,20 @@ void zmq::udp_engine_t::terminate ()
|
||||
delete this;
|
||||
}
|
||||
|
||||
void zmq::udp_engine_t::sockaddr_to_msg (zmq::msg_t *msg, sockaddr_in *addr)
|
||||
void zmq::udp_engine_t::sockaddr_to_msg (zmq::msg_t *msg_, sockaddr_in *addr_)
|
||||
{
|
||||
const char *const name = inet_ntoa (addr->sin_addr);
|
||||
const char *const name = inet_ntoa (addr_->sin_addr);
|
||||
|
||||
char port[6];
|
||||
sprintf (port, "%d", static_cast<int> (ntohs (addr->sin_port)));
|
||||
sprintf (port, "%d", static_cast<int> (ntohs (addr_->sin_port)));
|
||||
|
||||
const int size = static_cast<int> (strlen (name))
|
||||
+ static_cast<int> (strlen (port)) + 1
|
||||
+ 1; // Colon + NULL
|
||||
const int rc = msg->init_size (size);
|
||||
const int rc = msg_->init_size (size);
|
||||
errno_assert (rc == 0);
|
||||
msg->set_flags (msg_t::more);
|
||||
char *address = static_cast<char *> (msg->data ());
|
||||
msg_->set_flags (msg_t::more);
|
||||
char *address = static_cast<char *> (msg_->data ());
|
||||
|
||||
strcpy (address, name);
|
||||
strcat (address, ":");
|
||||
|
@ -47,7 +47,7 @@ class udp_engine_t : public io_object_t, public i_engine
|
||||
|
||||
private:
|
||||
int resolve_raw_address (char *addr_, size_t length_);
|
||||
void sockaddr_to_msg (zmq::msg_t *msg, sockaddr_in *addr);
|
||||
void sockaddr_to_msg (zmq::msg_t *msg_, sockaddr_in *addr_);
|
||||
|
||||
bool plugged;
|
||||
|
||||
|
@ -77,32 +77,32 @@ int zmq::v2_decoder_t::flags_ready (unsigned char const *)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int zmq::v2_decoder_t::one_byte_size_ready (unsigned char const *read_from)
|
||||
int zmq::v2_decoder_t::one_byte_size_ready (unsigned char const *read_from_)
|
||||
{
|
||||
return size_ready (tmpbuf[0], read_from);
|
||||
return size_ready (tmpbuf[0], read_from_);
|
||||
}
|
||||
|
||||
int zmq::v2_decoder_t::eight_byte_size_ready (unsigned char const *read_from)
|
||||
int zmq::v2_decoder_t::eight_byte_size_ready (unsigned char const *read_from_)
|
||||
{
|
||||
// The payload size is encoded as 64-bit unsigned integer.
|
||||
// The most significant byte comes first.
|
||||
const uint64_t msg_size = get_uint64 (tmpbuf);
|
||||
|
||||
return size_ready (msg_size, read_from);
|
||||
return size_ready (msg_size, read_from_);
|
||||
}
|
||||
|
||||
int zmq::v2_decoder_t::size_ready (uint64_t msg_size,
|
||||
unsigned char const *read_pos)
|
||||
int zmq::v2_decoder_t::size_ready (uint64_t msg_size_,
|
||||
unsigned char const *read_pos_)
|
||||
{
|
||||
// Message size must not exceed the maximum allowed size.
|
||||
if (maxmsgsize >= 0)
|
||||
if (unlikely (msg_size > static_cast<uint64_t> (maxmsgsize))) {
|
||||
if (unlikely (msg_size_ > static_cast<uint64_t> (maxmsgsize))) {
|
||||
errno = EMSGSIZE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Message size must fit into size_t data type.
|
||||
if (unlikely (msg_size != static_cast<size_t> (msg_size))) {
|
||||
if (unlikely (msg_size_ != static_cast<size_t> (msg_size_))) {
|
||||
errno = EMSGSIZE;
|
||||
return -1;
|
||||
}
|
||||
@ -115,18 +115,18 @@ int zmq::v2_decoder_t::size_ready (uint64_t msg_size,
|
||||
|
||||
shared_message_memory_allocator &allocator = get_allocator ();
|
||||
if (unlikely (!zero_copy
|
||||
|| ((unsigned char *) read_pos + msg_size
|
||||
|| ((unsigned char *) read_pos_ + msg_size_
|
||||
> (allocator.data () + allocator.size ())))) {
|
||||
// a new message has started, but the size would exceed the pre-allocated arena
|
||||
// this happens every time when a message does not fit completely into the buffer
|
||||
rc = in_progress.init_size (static_cast<size_t> (msg_size));
|
||||
rc = in_progress.init_size (static_cast<size_t> (msg_size_));
|
||||
} else {
|
||||
// construct message using n bytes from the buffer as storage
|
||||
// increase buffer ref count
|
||||
// if the message will be a large message, pass a valid refcnt memory location as well
|
||||
rc =
|
||||
in_progress.init (const_cast<unsigned char *> (read_pos),
|
||||
static_cast<size_t> (msg_size),
|
||||
in_progress.init (const_cast<unsigned char *> (read_pos_),
|
||||
static_cast<size_t> (msg_size_),
|
||||
shared_message_memory_allocator::call_dec_ref,
|
||||
allocator.buffer (), allocator.provide_content ());
|
||||
|
||||
|
38
src/wire.hpp
38
src/wire.hpp
@ -37,9 +37,9 @@ namespace zmq
|
||||
// Helper functions to convert different integer types to/from network
|
||||
// byte order.
|
||||
|
||||
inline void put_uint8 (unsigned char *buffer_, uint8_t value)
|
||||
inline void put_uint8 (unsigned char *buffer_, uint8_t value_)
|
||||
{
|
||||
*buffer_ = value;
|
||||
*buffer_ = value_;
|
||||
}
|
||||
|
||||
inline uint8_t get_uint8 (const unsigned char *buffer_)
|
||||
@ -47,10 +47,10 @@ inline uint8_t get_uint8 (const unsigned char *buffer_)
|
||||
return *buffer_;
|
||||
}
|
||||
|
||||
inline void put_uint16 (unsigned char *buffer_, uint16_t value)
|
||||
inline void put_uint16 (unsigned char *buffer_, uint16_t value_)
|
||||
{
|
||||
buffer_[0] = static_cast<unsigned char> (((value) >> 8) & 0xff);
|
||||
buffer_[1] = static_cast<unsigned char> (value & 0xff);
|
||||
buffer_[0] = static_cast<unsigned char> (((value_) >> 8) & 0xff);
|
||||
buffer_[1] = static_cast<unsigned char> (value_ & 0xff);
|
||||
}
|
||||
|
||||
inline uint16_t get_uint16 (const unsigned char *buffer_)
|
||||
@ -59,12 +59,12 @@ inline uint16_t get_uint16 (const unsigned char *buffer_)
|
||||
| (static_cast<uint16_t> (buffer_[1]));
|
||||
}
|
||||
|
||||
inline void put_uint32 (unsigned char *buffer_, uint32_t value)
|
||||
inline void put_uint32 (unsigned char *buffer_, uint32_t value_)
|
||||
{
|
||||
buffer_[0] = static_cast<unsigned char> (((value) >> 24) & 0xff);
|
||||
buffer_[1] = static_cast<unsigned char> (((value) >> 16) & 0xff);
|
||||
buffer_[2] = static_cast<unsigned char> (((value) >> 8) & 0xff);
|
||||
buffer_[3] = static_cast<unsigned char> (value & 0xff);
|
||||
buffer_[0] = static_cast<unsigned char> (((value_) >> 24) & 0xff);
|
||||
buffer_[1] = static_cast<unsigned char> (((value_) >> 16) & 0xff);
|
||||
buffer_[2] = static_cast<unsigned char> (((value_) >> 8) & 0xff);
|
||||
buffer_[3] = static_cast<unsigned char> (value_ & 0xff);
|
||||
}
|
||||
|
||||
inline uint32_t get_uint32 (const unsigned char *buffer_)
|
||||
@ -75,16 +75,16 @@ inline uint32_t get_uint32 (const unsigned char *buffer_)
|
||||
| (static_cast<uint32_t> (buffer_[3]));
|
||||
}
|
||||
|
||||
inline void put_uint64 (unsigned char *buffer_, uint64_t value)
|
||||
inline void put_uint64 (unsigned char *buffer_, uint64_t value_)
|
||||
{
|
||||
buffer_[0] = static_cast<unsigned char> (((value) >> 56) & 0xff);
|
||||
buffer_[1] = static_cast<unsigned char> (((value) >> 48) & 0xff);
|
||||
buffer_[2] = static_cast<unsigned char> (((value) >> 40) & 0xff);
|
||||
buffer_[3] = static_cast<unsigned char> (((value) >> 32) & 0xff);
|
||||
buffer_[4] = static_cast<unsigned char> (((value) >> 24) & 0xff);
|
||||
buffer_[5] = static_cast<unsigned char> (((value) >> 16) & 0xff);
|
||||
buffer_[6] = static_cast<unsigned char> (((value) >> 8) & 0xff);
|
||||
buffer_[7] = static_cast<unsigned char> (value & 0xff);
|
||||
buffer_[0] = static_cast<unsigned char> (((value_) >> 56) & 0xff);
|
||||
buffer_[1] = static_cast<unsigned char> (((value_) >> 48) & 0xff);
|
||||
buffer_[2] = static_cast<unsigned char> (((value_) >> 40) & 0xff);
|
||||
buffer_[3] = static_cast<unsigned char> (((value_) >> 32) & 0xff);
|
||||
buffer_[4] = static_cast<unsigned char> (((value_) >> 24) & 0xff);
|
||||
buffer_[5] = static_cast<unsigned char> (((value_) >> 16) & 0xff);
|
||||
buffer_[6] = static_cast<unsigned char> (((value_) >> 8) & 0xff);
|
||||
buffer_[7] = static_cast<unsigned char> (value_ & 0xff);
|
||||
}
|
||||
|
||||
inline uint64_t get_uint64 (const unsigned char *buffer_)
|
||||
|
@ -170,12 +170,12 @@ template <typename T, int N> class ypipe_t : public ypipe_base_t<T>
|
||||
// Applies the function fn to the first elemenent in the pipe
|
||||
// and returns the value returned by the fn.
|
||||
// The pipe mustn't be empty or the function crashes.
|
||||
inline bool probe (bool (*fn) (const T &))
|
||||
inline bool probe (bool (*fn_) (const T &))
|
||||
{
|
||||
bool rc = check_read ();
|
||||
zmq_assert (rc);
|
||||
|
||||
return (*fn) (queue.front ());
|
||||
return (*fn_) (queue.front ());
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -47,7 +47,7 @@ template <typename T> class ypipe_base_t
|
||||
virtual bool flush () = 0;
|
||||
virtual bool check_read () = 0;
|
||||
virtual bool read (T *value_) = 0;
|
||||
virtual bool probe (bool (*fn) (const T &)) = 0;
|
||||
virtual bool probe (bool (*fn_) (const T &)) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ template <typename T> class ypipe_conflate_t : public ypipe_base_t<T>
|
||||
// Applies the function fn to the first elemenent in the pipe
|
||||
// and returns the value returned by the fn.
|
||||
// The pipe mustn't be empty or the function crashes.
|
||||
inline bool probe (bool (*fn) (const T &)) { return dbuffer.probe (fn); }
|
||||
inline bool probe (bool (*fn_) (const T &)) { return dbuffer.probe (fn_); }
|
||||
|
||||
protected:
|
||||
dbuffer_t<T> dbuffer;
|
||||
|
@ -43,20 +43,20 @@ zap_client_t::zap_client_t (session_base_t *const session_,
|
||||
{
|
||||
}
|
||||
|
||||
void zap_client_t::send_zap_request (const char *mechanism,
|
||||
size_t mechanism_length,
|
||||
const uint8_t *credentials,
|
||||
size_t credentials_size)
|
||||
void zap_client_t::send_zap_request (const char *mechanism_,
|
||||
size_t mechanism_length_,
|
||||
const uint8_t *credentials_,
|
||||
size_t credentials_size_)
|
||||
{
|
||||
send_zap_request (mechanism, mechanism_length, &credentials,
|
||||
&credentials_size, 1);
|
||||
send_zap_request (mechanism_, mechanism_length_, &credentials_,
|
||||
&credentials_size_, 1);
|
||||
}
|
||||
|
||||
void zap_client_t::send_zap_request (const char *mechanism,
|
||||
size_t mechanism_length,
|
||||
const uint8_t **credentials,
|
||||
size_t *credentials_sizes,
|
||||
size_t credentials_count)
|
||||
void zap_client_t::send_zap_request (const char *mechanism_,
|
||||
size_t mechanism_length_,
|
||||
const uint8_t **credentials_,
|
||||
size_t *credentials_sizes_,
|
||||
size_t credentials_count_)
|
||||
{
|
||||
// write_zap_msg cannot fail. It could only fail if the HWM was exceeded,
|
||||
// but on the ZAP socket, the HWM is disabled.
|
||||
@ -113,21 +113,21 @@ void zap_client_t::send_zap_request (const char *mechanism,
|
||||
errno_assert (rc == 0);
|
||||
|
||||
// Mechanism frame
|
||||
rc = msg.init_size (mechanism_length);
|
||||
rc = msg.init_size (mechanism_length_);
|
||||
errno_assert (rc == 0);
|
||||
memcpy (msg.data (), mechanism, mechanism_length);
|
||||
if (credentials_count)
|
||||
memcpy (msg.data (), mechanism_, mechanism_length_);
|
||||
if (credentials_count_)
|
||||
msg.set_flags (msg_t::more);
|
||||
rc = session->write_zap_msg (&msg);
|
||||
errno_assert (rc == 0);
|
||||
|
||||
// Credentials frames
|
||||
for (size_t i = 0; i < credentials_count; ++i) {
|
||||
rc = msg.init_size (credentials_sizes[i]);
|
||||
for (size_t i = 0; i < credentials_count_; ++i) {
|
||||
rc = msg.init_size (credentials_sizes_[i]);
|
||||
errno_assert (rc == 0);
|
||||
if (i < credentials_count - 1)
|
||||
if (i < credentials_count_ - 1)
|
||||
msg.set_flags (msg_t::more);
|
||||
memcpy (msg.data (), credentials[i], credentials_sizes[i]);
|
||||
memcpy (msg.data (), credentials_[i], credentials_sizes_[i]);
|
||||
rc = session->write_zap_msg (&msg);
|
||||
errno_assert (rc == 0);
|
||||
}
|
||||
|
@ -41,16 +41,16 @@ class zap_client_t : public virtual mechanism_base_t
|
||||
const std::string &peer_address_,
|
||||
const options_t &options_);
|
||||
|
||||
void send_zap_request (const char *mechanism,
|
||||
size_t mechanism_length,
|
||||
const uint8_t *credentials,
|
||||
size_t credentials_size);
|
||||
void send_zap_request (const char *mechanism_,
|
||||
size_t mechanism_length_,
|
||||
const uint8_t *credentials_,
|
||||
size_t credentials_size_);
|
||||
|
||||
void send_zap_request (const char *mechanism,
|
||||
size_t mechanism_length,
|
||||
const uint8_t **credentials,
|
||||
size_t *credentials_sizes,
|
||||
size_t credentials_count);
|
||||
void send_zap_request (const char *mechanism_,
|
||||
size_t mechanism_length_,
|
||||
const uint8_t **credentials_,
|
||||
size_t *credentials_sizes_,
|
||||
size_t credentials_count_);
|
||||
|
||||
virtual int receive_and_process_zap_reply ();
|
||||
virtual void handle_zap_status_code ();
|
||||
@ -80,7 +80,7 @@ class zap_client_common_handshake_t : public zap_client_t
|
||||
zap_client_common_handshake_t (session_base_t *const session_,
|
||||
const std::string &peer_address_,
|
||||
const options_t &options_,
|
||||
state_t zap_reply_ok_state);
|
||||
state_t zap_reply_ok_state_);
|
||||
|
||||
// methods from mechanism_t
|
||||
status_t status () const;
|
||||
|
24
src/zmq.cpp
24
src/zmq.cpp
@ -1327,7 +1327,7 @@ int zmq_poller_wait (void *poller_, zmq_poller_event_t *event_, long timeout_)
|
||||
|
||||
int zmq_poller_wait_all (void *poller_,
|
||||
zmq_poller_event_t *events_,
|
||||
int n_events,
|
||||
int n_events_,
|
||||
long timeout_)
|
||||
{
|
||||
if (-1 == check_poller (poller_))
|
||||
@ -1337,7 +1337,7 @@ int zmq_poller_wait_all (void *poller_,
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
if (n_events < 0) {
|
||||
if (n_events_ < 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
@ -1345,7 +1345,7 @@ int zmq_poller_wait_all (void *poller_,
|
||||
int rc =
|
||||
(static_cast<zmq::socket_poller_t *> (poller_))
|
||||
->wait (reinterpret_cast<zmq::socket_poller_t::event_t *> (events_),
|
||||
n_events, timeout_);
|
||||
n_events_, timeout_);
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -1487,38 +1487,38 @@ int zmq_device (int /* type */, void *frontend_, void *backend_)
|
||||
|
||||
// Probe library capabilities; for now, reports on transport and security
|
||||
|
||||
int zmq_has (const char *capability)
|
||||
int zmq_has (const char *capability_)
|
||||
{
|
||||
#if !defined(ZMQ_HAVE_WINDOWS) && !defined(ZMQ_HAVE_OPENVMS)
|
||||
if (strcmp (capability, "ipc") == 0)
|
||||
if (strcmp (capability_, "ipc") == 0)
|
||||
return true;
|
||||
#endif
|
||||
#if defined(ZMQ_HAVE_OPENPGM)
|
||||
if (strcmp (capability, "pgm") == 0)
|
||||
if (strcmp (capability_, "pgm") == 0)
|
||||
return true;
|
||||
#endif
|
||||
#if defined(ZMQ_HAVE_TIPC)
|
||||
if (strcmp (capability, "tipc") == 0)
|
||||
if (strcmp (capability_, "tipc") == 0)
|
||||
return true;
|
||||
#endif
|
||||
#if defined(ZMQ_HAVE_NORM)
|
||||
if (strcmp (capability, "norm") == 0)
|
||||
if (strcmp (capability_, "norm") == 0)
|
||||
return true;
|
||||
#endif
|
||||
#if defined(ZMQ_HAVE_CURVE)
|
||||
if (strcmp (capability, "curve") == 0)
|
||||
if (strcmp (capability_, "curve") == 0)
|
||||
return true;
|
||||
#endif
|
||||
#if defined(HAVE_LIBGSSAPI_KRB5)
|
||||
if (strcmp (capability, "gssapi") == 0)
|
||||
if (strcmp (capability_, "gssapi") == 0)
|
||||
return true;
|
||||
#endif
|
||||
#if defined(ZMQ_HAVE_VMCI)
|
||||
if (strcmp (capability, "vmci") == 0)
|
||||
if (strcmp (capability_, "vmci") == 0)
|
||||
return true;
|
||||
#endif
|
||||
#if defined(ZMQ_BUILD_DRAFT_API)
|
||||
if (strcmp (capability, "draft") == 0)
|
||||
if (strcmp (capability_, "draft") == 0)
|
||||
return true;
|
||||
#endif
|
||||
// Whatever the application asked for, we don't have
|
||||
|
@ -100,14 +100,14 @@ unsigned long zmq_stopwatch_intermediate (void *watch_);
|
||||
#define ZMQ_ZERO_COPY_RECV 10
|
||||
|
||||
/* DRAFT Socket methods. */
|
||||
int zmq_join (void *s, const char *group);
|
||||
int zmq_leave (void *s, const char *group);
|
||||
int zmq_join (void *s_, const char *group_);
|
||||
int zmq_leave (void *s_, const char *group_);
|
||||
|
||||
/* DRAFT Msg methods. */
|
||||
int zmq_msg_set_routing_id (zmq_msg_t *msg, uint32_t routing_id);
|
||||
uint32_t zmq_msg_routing_id (zmq_msg_t *msg);
|
||||
int zmq_msg_set_group (zmq_msg_t *msg, const char *group);
|
||||
const char *zmq_msg_group (zmq_msg_t *msg);
|
||||
int zmq_msg_set_routing_id (zmq_msg_t *msg_, uint32_t routing_id_);
|
||||
uint32_t zmq_msg_routing_id (zmq_msg_t *msg_);
|
||||
int zmq_msg_set_group (zmq_msg_t *msg_, const char *group_);
|
||||
const char *zmq_msg_group (zmq_msg_t *msg_);
|
||||
|
||||
/* DRAFT Msg property names. */
|
||||
#define ZMQ_MSG_PROPERTY_ROUTING_ID "Routing-Id"
|
||||
@ -132,47 +132,53 @@ typedef struct zmq_poller_event_t
|
||||
} zmq_poller_event_t;
|
||||
|
||||
void *zmq_poller_new (void);
|
||||
int zmq_poller_destroy (void **poller_p);
|
||||
int zmq_poller_add (void *poller, void *socket, void *user_data, short events);
|
||||
int zmq_poller_modify (void *poller, void *socket, short events);
|
||||
int zmq_poller_remove (void *poller, void *socket);
|
||||
int zmq_poller_wait (void *poller, zmq_poller_event_t *event, long timeout);
|
||||
int zmq_poller_wait_all (void *poller,
|
||||
zmq_poller_event_t *events,
|
||||
int n_events,
|
||||
long timeout);
|
||||
int zmq_poller_destroy (void **poller_p_);
|
||||
int zmq_poller_add (void *poller_,
|
||||
void *socket_,
|
||||
void *user_data_,
|
||||
short events_);
|
||||
int zmq_poller_modify (void *poller_, void *socket_, short events_);
|
||||
int zmq_poller_remove (void *poller_, void *socket_);
|
||||
int zmq_poller_wait (void *poller_, zmq_poller_event_t *event_, long timeout_);
|
||||
int zmq_poller_wait_all (void *poller_,
|
||||
zmq_poller_event_t *events_,
|
||||
int n_events_,
|
||||
long timeout_);
|
||||
|
||||
#if defined _WIN32
|
||||
int zmq_poller_add_fd (void *poller, SOCKET fd, void *user_data, short events);
|
||||
int zmq_poller_modify_fd (void *poller, SOCKET fd, short events);
|
||||
int zmq_poller_remove_fd (void *poller, SOCKET fd);
|
||||
int zmq_poller_add_fd (void *poller_,
|
||||
SOCKET fd_,
|
||||
void *user_data_,
|
||||
short events_);
|
||||
int zmq_poller_modify_fd (void *poller_, SOCKET fd_, short events_);
|
||||
int zmq_poller_remove_fd (void *poller_, SOCKET fd_);
|
||||
#else
|
||||
int zmq_poller_add_fd (void *poller, int fd, void *user_data, short events);
|
||||
int zmq_poller_modify_fd (void *poller, int fd, short events);
|
||||
int zmq_poller_remove_fd (void *poller, int fd);
|
||||
#endif
|
||||
|
||||
int zmq_socket_get_peer_state (void *socket,
|
||||
const void *routing_id,
|
||||
size_t routing_id_size);
|
||||
int zmq_socket_get_peer_state (void *socket_,
|
||||
const void *routing_id_,
|
||||
size_t routing_id_size_);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Scheduling timers */
|
||||
/******************************************************************************/
|
||||
|
||||
typedef void(zmq_timer_fn) (int timer_id, void *arg);
|
||||
typedef void(zmq_timer_fn) (int timer_id_, void *arg_);
|
||||
|
||||
void *zmq_timers_new (void);
|
||||
int zmq_timers_destroy (void **timers_p);
|
||||
int zmq_timers_add (void *timers,
|
||||
size_t interval,
|
||||
zmq_timer_fn handler,
|
||||
void *arg);
|
||||
int zmq_timers_cancel (void *timers, int timer_id);
|
||||
int zmq_timers_set_interval (void *timers, int timer_id, size_t interval);
|
||||
int zmq_timers_reset (void *timers, int timer_id);
|
||||
long zmq_timers_timeout (void *timers);
|
||||
int zmq_timers_execute (void *timers);
|
||||
int zmq_timers_destroy (void **timers_p_);
|
||||
int zmq_timers_add (void *timers_,
|
||||
size_t interval_,
|
||||
zmq_timer_fn handler_,
|
||||
void *arg_);
|
||||
int zmq_timers_cancel (void *timers_, int timer_id_);
|
||||
int zmq_timers_set_interval (void *timers_, int timer_id_, size_t interval_);
|
||||
int zmq_timers_reset (void *timers_, int timer_id_);
|
||||
long zmq_timers_timeout (void *timers_);
|
||||
int zmq_timers_execute (void *timers_);
|
||||
|
||||
#endif // ZMQ_BUILD_DRAFT_API
|
||||
|
||||
|
@ -80,17 +80,17 @@ unsigned long zmq_stopwatch_stop (void *watch_)
|
||||
return res;
|
||||
}
|
||||
|
||||
void *zmq_threadstart (zmq_thread_fn *func, void *arg)
|
||||
void *zmq_threadstart (zmq_thread_fn *func_, void *arg_)
|
||||
{
|
||||
zmq::thread_t *thread = new (std::nothrow) zmq::thread_t;
|
||||
alloc_assert (thread);
|
||||
thread->start (func, arg);
|
||||
thread->start (func_, arg_);
|
||||
return thread;
|
||||
}
|
||||
|
||||
void zmq_threadclose (void *thread)
|
||||
void zmq_threadclose (void *thread_)
|
||||
{
|
||||
zmq::thread_t *pThread = static_cast<zmq::thread_t *> (thread);
|
||||
zmq::thread_t *pThread = static_cast<zmq::thread_t *> (thread_);
|
||||
pThread->stop ();
|
||||
LIBZMQ_DELETE (pThread);
|
||||
}
|
||||
@ -127,31 +127,31 @@ static uint8_t decoder[96] = {
|
||||
// dest. Size must be a multiple of 4.
|
||||
// Returns NULL and sets errno = EINVAL for invalid input.
|
||||
|
||||
char *zmq_z85_encode (char *dest, const uint8_t *data, size_t size)
|
||||
char *zmq_z85_encode (char *dest_, const uint8_t *data_, size_t size_)
|
||||
{
|
||||
if (size % 4 != 0) {
|
||||
if (size_ % 4 != 0) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
unsigned int char_nbr = 0;
|
||||
unsigned int byte_nbr = 0;
|
||||
uint32_t value = 0;
|
||||
while (byte_nbr < size) {
|
||||
while (byte_nbr < size_) {
|
||||
// Accumulate value in base 256 (binary)
|
||||
value = value * 256 + data[byte_nbr++];
|
||||
value = value * 256 + data_[byte_nbr++];
|
||||
if (byte_nbr % 4 == 0) {
|
||||
// Output value in base 85
|
||||
unsigned int divisor = 85 * 85 * 85 * 85;
|
||||
while (divisor) {
|
||||
dest[char_nbr++] = encoder[value / divisor % 85];
|
||||
dest_[char_nbr++] = encoder[value / divisor % 85];
|
||||
divisor /= 85;
|
||||
}
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
assert (char_nbr == size * 5 / 4);
|
||||
dest[char_nbr] = 0;
|
||||
return dest;
|
||||
assert (char_nbr == size_ * 5 / 4);
|
||||
dest_[char_nbr] = 0;
|
||||
return dest_;
|
||||
}
|
||||
|
||||
|
||||
@ -161,19 +161,19 @@ char *zmq_z85_encode (char *dest, const uint8_t *data, size_t size)
|
||||
// must be a multiple of 5.
|
||||
// Returns NULL and sets errno = EINVAL for invalid input.
|
||||
|
||||
uint8_t *zmq_z85_decode (uint8_t *dest, const char *string)
|
||||
uint8_t *zmq_z85_decode (uint8_t *dest_, const char *string_)
|
||||
{
|
||||
unsigned int byte_nbr = 0;
|
||||
unsigned int char_nbr = 0;
|
||||
uint32_t value = 0;
|
||||
while (string[char_nbr]) {
|
||||
while (string_[char_nbr]) {
|
||||
// Accumulate value in base 85
|
||||
if (UINT32_MAX / 85 < value) {
|
||||
// Invalid z85 encoding, represented value exceeds 0xffffffff
|
||||
goto error_inval;
|
||||
}
|
||||
value *= 85;
|
||||
uint8_t index = string[char_nbr++] - 32;
|
||||
uint8_t index = string_[char_nbr++] - 32;
|
||||
if (index >= sizeof (decoder)) {
|
||||
// Invalid z85 encoding, character outside range
|
||||
goto error_inval;
|
||||
@ -188,7 +188,7 @@ uint8_t *zmq_z85_decode (uint8_t *dest, const char *string)
|
||||
// Output value in base 256
|
||||
unsigned int divisor = 256 * 256 * 256;
|
||||
while (divisor) {
|
||||
dest[byte_nbr++] = value / divisor % 256;
|
||||
dest_[byte_nbr++] = value / divisor % 256;
|
||||
divisor /= 256;
|
||||
}
|
||||
value = 0;
|
||||
@ -197,8 +197,8 @@ uint8_t *zmq_z85_decode (uint8_t *dest, const char *string)
|
||||
if (char_nbr % 5 != 0) {
|
||||
goto error_inval;
|
||||
}
|
||||
assert (byte_nbr == strlen (string) * 4 / 5);
|
||||
return dest;
|
||||
assert (byte_nbr == strlen (string_) * 4 / 5);
|
||||
return dest_;
|
||||
|
||||
error_inval:
|
||||
errno = EINVAL;
|
||||
@ -211,7 +211,7 @@ error_inval:
|
||||
// Returns 0 on success, -1 on failure, setting errno.
|
||||
// Sets errno = ENOTSUP in the absence of a CURVE library.
|
||||
|
||||
int zmq_curve_keypair (char *z85_public_key, char *z85_secret_key)
|
||||
int zmq_curve_keypair (char *z85_public_key_, char *z85_secret_key_)
|
||||
{
|
||||
#if defined(ZMQ_HAVE_CURVE)
|
||||
#if crypto_box_PUBLICKEYBYTES != 32 || crypto_box_SECRETKEYBYTES != 32
|
||||
@ -224,14 +224,14 @@ int zmq_curve_keypair (char *z85_public_key, char *z85_secret_key)
|
||||
zmq::random_open ();
|
||||
|
||||
int res = crypto_box_keypair (public_key, secret_key);
|
||||
zmq_z85_encode (z85_public_key, public_key, 32);
|
||||
zmq_z85_encode (z85_secret_key, secret_key, 32);
|
||||
zmq_z85_encode (z85_public_key_, public_key, 32);
|
||||
zmq_z85_encode (z85_secret_key_, secret_key, 32);
|
||||
|
||||
zmq::random_close ();
|
||||
|
||||
return res;
|
||||
#else
|
||||
(void) z85_public_key, (void) z85_secret_key;
|
||||
(void) z85_public_key_, (void) z85_secret_key_;
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
#endif
|
||||
@ -243,7 +243,7 @@ int zmq_curve_keypair (char *z85_public_key, char *z85_secret_key)
|
||||
// Returns 0 on success, -1 on failure, setting errno.
|
||||
// Sets errno = ENOTSUP in the absence of a CURVE library.
|
||||
|
||||
int zmq_curve_public (char *z85_public_key, const char *z85_secret_key)
|
||||
int zmq_curve_public (char *z85_public_key_, const char *z85_secret_key_)
|
||||
{
|
||||
#if defined(ZMQ_HAVE_CURVE)
|
||||
#if crypto_box_PUBLICKEYBYTES != 32 || crypto_box_SECRETKEYBYTES != 32
|
||||
@ -255,18 +255,18 @@ int zmq_curve_public (char *z85_public_key, const char *z85_secret_key)
|
||||
|
||||
zmq::random_open ();
|
||||
|
||||
if (zmq_z85_decode (secret_key, z85_secret_key) == NULL)
|
||||
if (zmq_z85_decode (secret_key, z85_secret_key_) == NULL)
|
||||
return -1;
|
||||
|
||||
// Return codes are suppressed as none of these can actually fail.
|
||||
crypto_scalarmult_base (public_key, secret_key);
|
||||
zmq_z85_encode (z85_public_key, public_key, 32);
|
||||
zmq_z85_encode (z85_public_key_, public_key, 32);
|
||||
|
||||
zmq::random_close ();
|
||||
|
||||
return 0;
|
||||
#else
|
||||
(void) z85_public_key, (void) z85_secret_key;
|
||||
(void) z85_public_key_, (void) z85_secret_key_;
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user