1/*
2 Copyright (c) 2007-2017 Contributors as noted in the AUTHORS file
3
4 This file is part of libzmq, the ZeroMQ core engine in C++.
5
6 libzmq is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License (LGPL) as published
8 by the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 As a special exception, the Contributors give you permission to link
12 this library with independent modules to produce an executable,
13 regardless of the license terms of these independent modules, and to
14 copy and distribute the resulting executable under terms of your choice,
15 provided that you also meet, for each linked independent module, the
16 terms and conditions of the license of that module. An independent
17 module is a module which is not derived from or based on this library.
18 If you modify this library, you must extend this exception to your
19 version of the library.
20
21 libzmq is distributed in the hope that it will be useful, but WITHOUT
22 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
24 License for more details.
25
26 You should have received a copy of the GNU Lesser General Public License
27 along with this program. If not, see <http://www.gnu.org/licenses/>.
28*/
29
30#ifndef __TESTUTIL_MONITORING_HPP_INCLUDED__
31#define __TESTUTIL_MONITORING_HPP_INCLUDED__
32
33#include "../include/zmq.h"
34#include "../src/stdint.hpp"
35
36#include <stddef.h>
37
38// General, i.e. non-security specific, monitor utilities
39
40int get_monitor_event_with_timeout (void *monitor_,
41 int *value_,
42 char **address_,
43 int timeout_);
44
45int get_monitor_event (void *monitor_, int *value_, char **address_);
46
47void expect_monitor_event (void *monitor_, int expected_event_);
48
49void print_unexpected_event_stderr (int event_,
50 int err_,
51 int expected_event_,
52 int expected_err_);
53
54// expects that one or more occurrences of the expected event are received
55// via the specified socket monitor
56// returns the number of occurrences of the expected event
57// interrupts, if a ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL with EPIPE, ECONNRESET
58// or ECONNABORTED occurs; in this case, 0 is returned
59// this should be investigated further, see
60// https://github.com/zeromq/libzmq/issues/2644
61int expect_monitor_event_multiple (void *server_mon_,
62 int expected_event_,
63 int expected_err_ = -1,
64 bool optional_ = false);
65
66int64_t get_monitor_event_v2 (void *monitor_,
67 uint64_t *value_,
68 char **local_address_,
69 char **remote_address_);
70
71void expect_monitor_event_v2 (void *monitor_,
72 int64_t expected_event_,
73 const char *expected_local_address_ = NULL,
74 const char *expected_remote_address_ = NULL);
75#endif
76