Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 101 lines (74 sloc) 2.922 kb
b6ecb00 sustrik TCP address related functionality moved to tcp_address_t
sustrik authored
1 /*
ac7717b sustrik 250bpm copyrights added
sustrik authored
2 Copyright (c) 2009-2011 250bpm s.r.o.
8e21d64 sustrik Copyright dates adjusted to reflect reality
sustrik authored
3 Copyright (c) 2007-2009 iMatix Corporation
b6ecb00 sustrik TCP address related functionality moved to tcp_address_t
sustrik authored
4 Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
5
6 This file is part of 0MQ.
7
8 0MQ is free software; you can redistribute it and/or modify it under
9 the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 0MQ is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef __ZMQ_TCP_ADDRESS_HPP_INCLUDED__
23 #define __ZMQ_TCP_ADDRESS_HPP_INCLUDED__
24
25 #include "platform.hpp"
26
898ee99 sustrik Windows build fixed
sustrik authored
27 #if defined ZMQ_HAVE_WINDOWS
28 #include "windows.hpp"
29 #else
b6ecb00 sustrik TCP address related functionality moved to tcp_address_t
sustrik authored
30 #include <sys/socket.h>
31 #include <netinet/in.h>
898ee99 sustrik Windows build fixed
sustrik authored
32 #endif
b6ecb00 sustrik TCP address related functionality moved to tcp_address_t
sustrik authored
33
34 namespace zmq
35 {
36
37 class tcp_address_t
38 {
39 public:
40
41 tcp_address_t ();
7b8e728 Sergey KHripchenko implement zmq_unbind(),zmq_disconnect(), zmq->sock->getsockopt(ZMQ_LAST_...
shripchenko authored
42 tcp_address_t (const sockaddr *sa, socklen_t sa_len);
2eb6b32 Sergey KHripchenko fixes for
shripchenko authored
43 virtual ~tcp_address_t ();
b6ecb00 sustrik TCP address related functionality moved to tcp_address_t
sustrik authored
44
45 // This function translates textual TCP address into an address
46 // strcuture. If 'local' is true, names are resolved as local interface
47 // names. If it is false, names are resolved as remote hostnames.
48 // If 'ipv4only' is true, the name will never resolve to IPv6 address.
49 int resolve (const char* name_, bool local_, bool ipv4only_);
50
7b8e728 Sergey KHripchenko implement zmq_unbind(),zmq_disconnect(), zmq->sock->getsockopt(ZMQ_LAST_...
shripchenko authored
51 // The opposite to resolve()
52 virtual int to_string (std::string &addr_);
53
898ee99 sustrik Windows build fixed
sustrik authored
54 #if defined ZMQ_HAVE_WINDOWS
b9fb48f Staffan Gimåker Resolve addresses in the calling thread on connect.
gimaker authored
55 unsigned short family () const;
898ee99 sustrik Windows build fixed
sustrik authored
56 #else
b9fb48f Staffan Gimåker Resolve addresses in the calling thread on connect.
gimaker authored
57 sa_family_t family () const;
898ee99 sustrik Windows build fixed
sustrik authored
58 #endif
b9fb48f Staffan Gimåker Resolve addresses in the calling thread on connect.
gimaker authored
59 const sockaddr *addr () const;
60 socklen_t addrlen () const;
b6ecb00 sustrik TCP address related functionality moved to tcp_address_t
sustrik authored
61
acba6bd Sergey KHripchenko Implement ZMQ_TCP_ACCEPT_FILTER setsockopt() for listening TCP sockets.
shripchenko authored
62 protected:
b6ecb00 sustrik TCP address related functionality moved to tcp_address_t
sustrik authored
63
80a5f60 sustrik NIC name resolution moved to tcp_address_t
sustrik authored
64 int resolve_nic_name (const char *nic_, bool ipv4only_);
65 int resolve_interface (const char *interface_, bool ipv4only_);
b6ecb00 sustrik TCP address related functionality moved to tcp_address_t
sustrik authored
66 int resolve_hostname (const char *hostname_, bool ipv4only_);
67
68 union {
69 sockaddr generic;
70 sockaddr_in ipv4;
71 sockaddr_in6 ipv6;
72 } address;
acba6bd Sergey KHripchenko Implement ZMQ_TCP_ACCEPT_FILTER setsockopt() for listening TCP sockets.
shripchenko authored
73 };
74
75 class tcp_address_mask_t : public tcp_address_t
76 {
77 public:
78
79 tcp_address_mask_t ();
80
81 // This function enhances tcp_address_t::resolve() with ability to parse
82 // additional cidr-like(/xx) mask value at the end of the name string.
83 // Works only with remote hostnames.
84 int resolve (const char* name_, bool ipv4only_);
b6ecb00 sustrik TCP address related functionality moved to tcp_address_t
sustrik authored
85
7b8e728 Sergey KHripchenko implement zmq_unbind(),zmq_disconnect(), zmq->sock->getsockopt(ZMQ_LAST_...
shripchenko authored
86 // The opposite to resolve()
87 int to_string (std::string &addr_);
88
acba6bd Sergey KHripchenko Implement ZMQ_TCP_ACCEPT_FILTER setsockopt() for listening TCP sockets.
shripchenko authored
89 const int mask () const;
90
c77dc98 Sergey KHripchenko some spaces cleanups + delete unused anymore zmq::max_sockets + some min...
shripchenko authored
91 const bool match_address (const struct sockaddr *ss, const socklen_t ss_len) const;
acba6bd Sergey KHripchenko Implement ZMQ_TCP_ACCEPT_FILTER setsockopt() for listening TCP sockets.
shripchenko authored
92
93 private:
94
95 int address_mask;
b6ecb00 sustrik TCP address related functionality moved to tcp_address_t
sustrik authored
96 };
acba6bd Sergey KHripchenko Implement ZMQ_TCP_ACCEPT_FILTER setsockopt() for listening TCP sockets.
shripchenko authored
97
b6ecb00 sustrik TCP address related functionality moved to tcp_address_t
sustrik authored
98 }
99
100 #endif
Something went wrong with that request. Please try again.