1
1
/*
2
- Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
2
+ Copyright (c) 2007-2015 Contributors as noted in the AUTHORS file
3
3
4
4
This file is part of 0MQ.
5
5
30
30
31
31
/* Version macros for compile-time API version detection */
32
32
#define ZMQ_VERSION_MAJOR 4
33
- #define ZMQ_VERSION_MINOR 0
34
- #define ZMQ_VERSION_PATCH 4
33
+ #define ZMQ_VERSION_MINOR 1
34
+ #define ZMQ_VERSION_PATCH 2
35
35
36
36
#define ZMQ_MAKE_VERSION (major , minor , patch ) \
37
37
((major) * 10000 + (minor) * 100 + (patch))
@@ -71,18 +71,9 @@ extern "C" {
71
71
#endif
72
72
73
73
/* Define integer types needed for event interface */
74
+ #define ZMQ_DEFINED_STDINT 1
74
75
#if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS
75
76
# include <inttypes.h>
76
- #elif defined _MSC_VER && _MSC_VER < 1600
77
- # ifndef int32_t
78
- typedef __int32 int32_t ;
79
- # endif
80
- # ifndef uint16_t
81
- typedef unsigned __int16 uint16_t ;
82
- # endif
83
- # ifndef uint8_t
84
- typedef unsigned __int8 uint8_t ;
85
- # endif
86
77
#else
87
78
# include <stdint.h>
88
79
#endif
@@ -158,9 +149,6 @@ typedef unsigned __int8 uint8_t;
158
149
#define ETERM (ZMQ_HAUSNUMERO + 53)
159
150
#define EMTHREAD (ZMQ_HAUSNUMERO + 54)
160
151
161
- /* Run-time API version detection */
162
- ZMQ_EXPORT void zmq_version (int * major , int * minor , int * patch );
163
-
164
152
/* This function retrieves the errno as it is known to 0MQ library. The goal */
165
153
/* of this function is to make the code 100% portable, including where 0MQ */
166
154
/* compiled with certain CRT library (on Windows) is linked to an */
@@ -170,6 +158,9 @@ ZMQ_EXPORT int zmq_errno (void);
170
158
/* Resolves system errors and 0MQ errors to human-readable string. */
171
159
ZMQ_EXPORT const char * zmq_strerror (int errnum );
172
160
161
+ /* Run-time API version detection */
162
+ ZMQ_EXPORT void zmq_version (int * major , int * minor , int * patch );
163
+
173
164
/******************************************************************************/
174
165
/* 0MQ infrastructure (a.k.a. context) initialisation & termination. */
175
166
/******************************************************************************/
@@ -178,10 +169,15 @@ ZMQ_EXPORT const char *zmq_strerror (int errnum);
178
169
/* Context options */
179
170
#define ZMQ_IO_THREADS 1
180
171
#define ZMQ_MAX_SOCKETS 2
172
+ #define ZMQ_SOCKET_LIMIT 3
173
+ #define ZMQ_THREAD_PRIORITY 3
174
+ #define ZMQ_THREAD_SCHED_POLICY 4
181
175
182
176
/* Default for new contexts */
183
177
#define ZMQ_IO_THREADS_DFLT 1
184
178
#define ZMQ_MAX_SOCKETS_DFLT 1023
179
+ #define ZMQ_THREAD_PRIORITY_DFLT -1
180
+ #define ZMQ_THREAD_SCHED_POLICY_DFLT -1
185
181
186
182
ZMQ_EXPORT void * zmq_ctx_new (void );
187
183
ZMQ_EXPORT int zmq_ctx_term (void * context );
@@ -199,7 +195,7 @@ ZMQ_EXPORT int zmq_ctx_destroy (void *context);
199
195
/* 0MQ message definition. */
200
196
/******************************************************************************/
201
197
202
- typedef struct zmq_msg_t {unsigned char _ [32 ];} zmq_msg_t ;
198
+ typedef struct zmq_msg_t {unsigned char _ [64 ];} zmq_msg_t ;
203
199
204
200
typedef void (zmq_free_fn ) (void * data , void * hint );
205
201
@@ -215,8 +211,9 @@ ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src);
215
211
ZMQ_EXPORT void * zmq_msg_data (zmq_msg_t * msg );
216
212
ZMQ_EXPORT size_t zmq_msg_size (zmq_msg_t * msg );
217
213
ZMQ_EXPORT int zmq_msg_more (zmq_msg_t * msg );
218
- ZMQ_EXPORT int zmq_msg_get (zmq_msg_t * msg , int option );
219
- ZMQ_EXPORT int zmq_msg_set (zmq_msg_t * msg , int option , int optval );
214
+ ZMQ_EXPORT int zmq_msg_get (zmq_msg_t * msg , int property );
215
+ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t * msg , int property , int optval );
216
+ ZMQ_EXPORT const char * zmq_msg_gets (zmq_msg_t * msg , const char * property );
220
217
221
218
222
219
/******************************************************************************/
@@ -270,7 +267,6 @@ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
270
267
#define ZMQ_TCP_KEEPALIVE_CNT 35
271
268
#define ZMQ_TCP_KEEPALIVE_IDLE 36
272
269
#define ZMQ_TCP_KEEPALIVE_INTVL 37
273
- #define ZMQ_TCP_ACCEPT_FILTER 38
274
270
#define ZMQ_IMMEDIATE 39
275
271
#define ZMQ_XPUB_VERBOSE 40
276
272
#define ZMQ_ROUTER_RAW 41
@@ -288,9 +284,21 @@ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
288
284
#define ZMQ_REQ_RELAXED 53
289
285
#define ZMQ_CONFLATE 54
290
286
#define ZMQ_ZAP_DOMAIN 55
287
+ #define ZMQ_ROUTER_HANDOVER 56
288
+ #define ZMQ_TOS 57
289
+ #define ZMQ_CONNECT_RID 61
290
+ #define ZMQ_GSSAPI_SERVER 62
291
+ #define ZMQ_GSSAPI_PRINCIPAL 63
292
+ #define ZMQ_GSSAPI_SERVICE_PRINCIPAL 64
293
+ #define ZMQ_GSSAPI_PLAINTEXT 65
294
+ #define ZMQ_HANDSHAKE_IVL 66
295
+ #define ZMQ_SOCKS_PROXY 68
296
+ #define ZMQ_XPUB_NODROP 69
291
297
292
298
/* Message options */
293
299
#define ZMQ_MORE 1
300
+ #define ZMQ_SRCFD 2
301
+ #define ZMQ_SHARED 3
294
302
295
303
/* Send/recv options. */
296
304
#define ZMQ_DONTWAIT 1
@@ -300,8 +308,13 @@ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
300
308
#define ZMQ_NULL 0
301
309
#define ZMQ_PLAIN 1
302
310
#define ZMQ_CURVE 2
311
+ #define ZMQ_GSSAPI 3
303
312
304
313
/* Deprecated options and aliases */
314
+ #define ZMQ_TCP_ACCEPT_FILTER 38
315
+ #define ZMQ_IPC_FILTER_PID 58
316
+ #define ZMQ_IPC_FILTER_UID 59
317
+ #define ZMQ_IPC_FILTER_GID 60
305
318
#define ZMQ_IPV4ONLY 31
306
319
#define ZMQ_DELAY_ATTACH_ON_CONNECT ZMQ_IMMEDIATE
307
320
#define ZMQ_NOBLOCK ZMQ_DONTWAIT
@@ -312,34 +325,20 @@ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
312
325
/* 0MQ socket events and monitoring */
313
326
/******************************************************************************/
314
327
315
- /* Socket transport events (tcp and ipc only) */
316
- #define ZMQ_EVENT_CONNECTED 1
317
- #define ZMQ_EVENT_CONNECT_DELAYED 2
318
- #define ZMQ_EVENT_CONNECT_RETRIED 4
319
-
320
- #define ZMQ_EVENT_LISTENING 8
321
- #define ZMQ_EVENT_BIND_FAILED 16
322
-
323
- #define ZMQ_EVENT_ACCEPTED 32
324
- #define ZMQ_EVENT_ACCEPT_FAILED 64
325
-
326
- #define ZMQ_EVENT_CLOSED 128
327
- #define ZMQ_EVENT_CLOSE_FAILED 256
328
- #define ZMQ_EVENT_DISCONNECTED 512
329
- #define ZMQ_EVENT_MONITOR_STOPPED 1024
330
-
331
- #define ZMQ_EVENT_ALL ( ZMQ_EVENT_CONNECTED | ZMQ_EVENT_CONNECT_DELAYED | \
332
- ZMQ_EVENT_CONNECT_RETRIED | ZMQ_EVENT_LISTENING | \
333
- ZMQ_EVENT_BIND_FAILED | ZMQ_EVENT_ACCEPTED | \
334
- ZMQ_EVENT_ACCEPT_FAILED | ZMQ_EVENT_CLOSED | \
335
- ZMQ_EVENT_CLOSE_FAILED | ZMQ_EVENT_DISCONNECTED | \
336
- ZMQ_EVENT_MONITOR_STOPPED)
337
-
338
- /* Socket event data */
339
- typedef struct {
340
- uint16_t event ; // id of the event as bitfield
341
- int32_t value ; // value is either error code, fd or reconnect interval
342
- } zmq_event_t ;
328
+ /* Socket transport events (TCP and IPC only) */
329
+
330
+ #define ZMQ_EVENT_CONNECTED 0x0001
331
+ #define ZMQ_EVENT_CONNECT_DELAYED 0x0002
332
+ #define ZMQ_EVENT_CONNECT_RETRIED 0x0004
333
+ #define ZMQ_EVENT_LISTENING 0x0008
334
+ #define ZMQ_EVENT_BIND_FAILED 0x0010
335
+ #define ZMQ_EVENT_ACCEPTED 0x0020
336
+ #define ZMQ_EVENT_ACCEPT_FAILED 0x0040
337
+ #define ZMQ_EVENT_CLOSED 0x0080
338
+ #define ZMQ_EVENT_CLOSE_FAILED 0x0100
339
+ #define ZMQ_EVENT_DISCONNECTED 0x0200
340
+ #define ZMQ_EVENT_MONITOR_STOPPED 0x0400
341
+ #define ZMQ_EVENT_ALL 0xFFFF
343
342
344
343
ZMQ_EXPORT void * zmq_socket (void * , int type );
345
344
ZMQ_EXPORT int zmq_close (void * s );
@@ -356,14 +355,6 @@ ZMQ_EXPORT int zmq_send_const (void *s, const void *buf, size_t len, int flags);
356
355
ZMQ_EXPORT int zmq_recv (void * s , void * buf , size_t len , int flags );
357
356
ZMQ_EXPORT int zmq_socket_monitor (void * s , const char * addr , int events );
358
357
359
- ZMQ_EXPORT int zmq_sendmsg (void * s , zmq_msg_t * msg , int flags );
360
- ZMQ_EXPORT int zmq_recvmsg (void * s , zmq_msg_t * msg , int flags );
361
-
362
- /* Experimental */
363
- struct iovec ;
364
-
365
- ZMQ_EXPORT int zmq_sendiov (void * s , struct iovec * iov , size_t count , int flags );
366
- ZMQ_EXPORT int zmq_recviov (void * s , struct iovec * iov , size_t * count , int flags );
367
358
368
359
/******************************************************************************/
369
360
/* I/O multiplexing. */
@@ -373,7 +364,7 @@ ZMQ_EXPORT int zmq_recviov (void *s, struct iovec *iov, size_t *count, int flags
373
364
#define ZMQ_POLLOUT 2
374
365
#define ZMQ_POLLERR 4
375
366
376
- typedef struct
367
+ typedef struct zmq_pollitem_t
377
368
{
378
369
void * socket ;
379
370
#if defined _WIN32
@@ -389,22 +380,78 @@ typedef struct
389
380
390
381
ZMQ_EXPORT int zmq_poll (zmq_pollitem_t * items , int nitems , long timeout );
391
382
392
- /* Built-in message proxy (3-way) */
383
+ /******************************************************************************/
384
+ /* Message proxying */
385
+ /******************************************************************************/
393
386
394
387
ZMQ_EXPORT int zmq_proxy (void * frontend , void * backend , void * capture );
388
+ ZMQ_EXPORT int zmq_proxy_steerable (void * frontend , void * backend , void * capture , void * control );
395
389
396
- /* Encode a binary key as printable text using ZMQ RFC 32 */
397
- ZMQ_EXPORT char * zmq_z85_encode (char * dest , uint8_t * data , size_t size );
390
+ /******************************************************************************/
391
+ /* Probe library capabilities */
392
+ /******************************************************************************/
398
393
399
- /* Encode a binary key from printable text per ZMQ RFC 32 */
400
- ZMQ_EXPORT uint8_t * zmq_z85_decode ( uint8_t * dest , char * string );
394
+ #define ZMQ_HAS_CAPABILITIES 1
395
+ ZMQ_EXPORT int zmq_has ( const char * capability );
401
396
402
397
/* Deprecated aliases */
403
398
#define ZMQ_STREAMER 1
404
399
#define ZMQ_FORWARDER 2
405
400
#define ZMQ_QUEUE 3
406
- /* Deprecated method */
401
+
402
+ /* Deprecated methods */
407
403
ZMQ_EXPORT int zmq_device (int type , void * frontend , void * backend );
404
+ ZMQ_EXPORT int zmq_sendmsg (void * s , zmq_msg_t * msg , int flags );
405
+ ZMQ_EXPORT int zmq_recvmsg (void * s , zmq_msg_t * msg , int flags );
406
+
407
+
408
+ /******************************************************************************/
409
+ /* Encryption functions */
410
+ /******************************************************************************/
411
+
412
+ /* Encode data with Z85 encoding. Returns encoded data */
413
+ ZMQ_EXPORT char * zmq_z85_encode (char * dest , const uint8_t * data , size_t size );
414
+
415
+ /* Decode data with Z85 encoding. Returns decoded data */
416
+ ZMQ_EXPORT uint8_t * zmq_z85_decode (uint8_t * dest , const char * string );
417
+
418
+ /* Generate z85-encoded public and private keypair with libsodium. */
419
+ /* Returns 0 on success. */
420
+ ZMQ_EXPORT int zmq_curve_keypair (char * z85_public_key , char * z85_secret_key );
421
+
422
+
423
+ /******************************************************************************/
424
+ /* These functions are not documented by man pages -- use at your own risk. */
425
+ /* If you need these to be part of the formal ZMQ API, then (a) write a man */
426
+ /* page, and (b) write a test case in tests. */
427
+ /******************************************************************************/
428
+
429
+ struct iovec ;
430
+
431
+ ZMQ_EXPORT int zmq_sendiov (void * s , struct iovec * iov , size_t count , int flags );
432
+ ZMQ_EXPORT int zmq_recviov (void * s , struct iovec * iov , size_t * count , int flags );
433
+
434
+ /* Helper functions are used by perf tests so that they don't have to care */
435
+ /* about minutiae of time-related functions on different OS platforms. */
436
+
437
+ /* Starts the stopwatch. Returns the handle to the watch. */
438
+ ZMQ_EXPORT void * zmq_stopwatch_start (void );
439
+
440
+ /* Stops the stopwatch. Returns the number of microseconds elapsed since */
441
+ /* the stopwatch was started. */
442
+ ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void * watch_ );
443
+
444
+ /* Sleeps for specified number of seconds. */
445
+ ZMQ_EXPORT void zmq_sleep (int seconds_ );
446
+
447
+ typedef void (zmq_thread_fn ) (void * );
448
+
449
+ /* Start a thread. Returns a handle to the thread. */
450
+ ZMQ_EXPORT void * zmq_threadstart (zmq_thread_fn * func , void * arg );
451
+
452
+ /* Wait for thread to complete then free up resources. */
453
+ ZMQ_EXPORT void zmq_threadclose (void * thread );
454
+
408
455
409
456
#undef ZMQ_EXPORT
410
457
0 commit comments