/src/libzmq/src/udp_engine.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | |
2 | | #ifndef __ZMQ_UDP_ENGINE_HPP_INCLUDED__ |
3 | | #define __ZMQ_UDP_ENGINE_HPP_INCLUDED__ |
4 | | |
5 | | #include "io_object.hpp" |
6 | | #include "i_engine.hpp" |
7 | | #include "address.hpp" |
8 | | #include "msg.hpp" |
9 | | |
10 | 0 | #define MAX_UDP_MSG 8192 |
11 | | |
12 | | namespace zmq |
13 | | { |
14 | | class io_thread_t; |
15 | | class session_base_t; |
16 | | |
17 | | class udp_engine_t ZMQ_FINAL : public io_object_t, public i_engine |
18 | | { |
19 | | public: |
20 | | udp_engine_t (const options_t &options_); |
21 | | ~udp_engine_t (); |
22 | | |
23 | | int init (address_t *address_, bool send_, bool recv_); |
24 | | |
25 | 0 | bool has_handshake_stage () ZMQ_FINAL { return false; }; |
26 | | |
27 | | // i_engine interface implementation. |
28 | | // Plug the engine to the session. |
29 | | void plug (zmq::io_thread_t *io_thread_, class session_base_t *session_); |
30 | | |
31 | | // Terminate and deallocate the engine. Note that 'detached' |
32 | | // events are not fired on termination. |
33 | | void terminate (); |
34 | | |
35 | | // This method is called by the session to signalise that more |
36 | | // messages can be written to the pipe. |
37 | | bool restart_input (); |
38 | | |
39 | | // This method is called by the session to signalise that there |
40 | | // are messages to send available. |
41 | | void restart_output (); |
42 | | |
43 | 0 | void zap_msg_available () {}; |
44 | | |
45 | | void in_event (); |
46 | | void out_event (); |
47 | | |
48 | | const endpoint_uri_pair_t &get_endpoint () const; |
49 | | |
50 | | private: |
51 | | int resolve_raw_address (const char *name_, size_t length_); |
52 | | static void sockaddr_to_msg (zmq::msg_t *msg_, const sockaddr_in *addr_); |
53 | | |
54 | | static int set_udp_reuse_address (fd_t s_, bool on_); |
55 | | static int set_udp_reuse_port (fd_t s_, bool on_); |
56 | | // Indicate, if the multicast data being sent should be looped back |
57 | | static int set_udp_multicast_loop (fd_t s_, bool is_ipv6_, bool loop_); |
58 | | // Set multicast TTL |
59 | | static int set_udp_multicast_ttl (fd_t s_, bool is_ipv6_, int hops_); |
60 | | // Set multicast address/interface |
61 | | int set_udp_multicast_iface (fd_t s_, |
62 | | bool is_ipv6_, |
63 | | const udp_address_t *addr_); |
64 | | // Join a multicast group |
65 | | int add_membership (fd_t s_, const udp_address_t *addr_); |
66 | | |
67 | | // Function to handle network issues. |
68 | | void error (error_reason_t reason_); |
69 | | |
70 | | const endpoint_uri_pair_t _empty_endpoint; |
71 | | |
72 | | bool _plugged; |
73 | | |
74 | | fd_t _fd; |
75 | | session_base_t *_session; |
76 | | handle_t _handle; |
77 | | address_t *_address; |
78 | | |
79 | | options_t _options; |
80 | | |
81 | | sockaddr_in _raw_address; |
82 | | const struct sockaddr *_out_address; |
83 | | zmq_socklen_t _out_address_len; |
84 | | |
85 | | char _out_buffer[MAX_UDP_MSG]; |
86 | | char _in_buffer[MAX_UDP_MSG]; |
87 | | bool _send_enabled; |
88 | | bool _recv_enabled; |
89 | | }; |
90 | | } |
91 | | |
92 | | #endif |