Chris@16
|
1 //
|
Chris@16
|
2 // ip/multicast.hpp
|
Chris@16
|
3 // ~~~~~~~~~~~~~~~~
|
Chris@16
|
4 //
|
Chris@101
|
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
Chris@16
|
6 //
|
Chris@16
|
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9 //
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_ASIO_IP_MULTICAST_HPP
|
Chris@16
|
12 #define BOOST_ASIO_IP_MULTICAST_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
15 # pragma once
|
Chris@16
|
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/asio/detail/config.hpp>
|
Chris@16
|
19 #include <cstddef>
|
Chris@16
|
20 #include <boost/asio/ip/detail/socket_option.hpp>
|
Chris@16
|
21
|
Chris@16
|
22 #include <boost/asio/detail/push_options.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 namespace boost {
|
Chris@16
|
25 namespace asio {
|
Chris@16
|
26 namespace ip {
|
Chris@16
|
27 namespace multicast {
|
Chris@16
|
28
|
Chris@16
|
29 /// Socket option to join a multicast group on a specified interface.
|
Chris@16
|
30 /**
|
Chris@16
|
31 * Implements the IPPROTO_IP/IP_ADD_MEMBERSHIP socket option.
|
Chris@16
|
32 *
|
Chris@16
|
33 * @par Examples
|
Chris@16
|
34 * Setting the option to join a multicast group:
|
Chris@16
|
35 * @code
|
Chris@16
|
36 * boost::asio::ip::udp::socket socket(io_service);
|
Chris@16
|
37 * ...
|
Chris@16
|
38 * boost::asio::ip::address multicast_address =
|
Chris@16
|
39 * boost::asio::ip::address::from_string("225.0.0.1");
|
Chris@16
|
40 * boost::asio::ip::multicast::join_group option(multicast_address);
|
Chris@16
|
41 * socket.set_option(option);
|
Chris@16
|
42 * @endcode
|
Chris@16
|
43 *
|
Chris@16
|
44 * @par Concepts:
|
Chris@16
|
45 * SettableSocketOption.
|
Chris@16
|
46 */
|
Chris@16
|
47 #if defined(GENERATING_DOCUMENTATION)
|
Chris@16
|
48 typedef implementation_defined join_group;
|
Chris@16
|
49 #else
|
Chris@16
|
50 typedef boost::asio::ip::detail::socket_option::multicast_request<
|
Chris@16
|
51 BOOST_ASIO_OS_DEF(IPPROTO_IP),
|
Chris@16
|
52 BOOST_ASIO_OS_DEF(IP_ADD_MEMBERSHIP),
|
Chris@16
|
53 BOOST_ASIO_OS_DEF(IPPROTO_IPV6),
|
Chris@16
|
54 BOOST_ASIO_OS_DEF(IPV6_JOIN_GROUP)> join_group;
|
Chris@16
|
55 #endif
|
Chris@16
|
56
|
Chris@16
|
57 /// Socket option to leave a multicast group on a specified interface.
|
Chris@16
|
58 /**
|
Chris@16
|
59 * Implements the IPPROTO_IP/IP_DROP_MEMBERSHIP socket option.
|
Chris@16
|
60 *
|
Chris@16
|
61 * @par Examples
|
Chris@16
|
62 * Setting the option to leave a multicast group:
|
Chris@16
|
63 * @code
|
Chris@16
|
64 * boost::asio::ip::udp::socket socket(io_service);
|
Chris@16
|
65 * ...
|
Chris@16
|
66 * boost::asio::ip::address multicast_address =
|
Chris@16
|
67 * boost::asio::ip::address::from_string("225.0.0.1");
|
Chris@16
|
68 * boost::asio::ip::multicast::leave_group option(multicast_address);
|
Chris@16
|
69 * socket.set_option(option);
|
Chris@16
|
70 * @endcode
|
Chris@16
|
71 *
|
Chris@16
|
72 * @par Concepts:
|
Chris@16
|
73 * SettableSocketOption.
|
Chris@16
|
74 */
|
Chris@16
|
75 #if defined(GENERATING_DOCUMENTATION)
|
Chris@16
|
76 typedef implementation_defined leave_group;
|
Chris@16
|
77 #else
|
Chris@16
|
78 typedef boost::asio::ip::detail::socket_option::multicast_request<
|
Chris@16
|
79 BOOST_ASIO_OS_DEF(IPPROTO_IP),
|
Chris@16
|
80 BOOST_ASIO_OS_DEF(IP_DROP_MEMBERSHIP),
|
Chris@16
|
81 BOOST_ASIO_OS_DEF(IPPROTO_IPV6),
|
Chris@16
|
82 BOOST_ASIO_OS_DEF(IPV6_LEAVE_GROUP)> leave_group;
|
Chris@16
|
83 #endif
|
Chris@16
|
84
|
Chris@16
|
85 /// Socket option for local interface to use for outgoing multicast packets.
|
Chris@16
|
86 /**
|
Chris@16
|
87 * Implements the IPPROTO_IP/IP_MULTICAST_IF socket option.
|
Chris@16
|
88 *
|
Chris@16
|
89 * @par Examples
|
Chris@16
|
90 * Setting the option:
|
Chris@16
|
91 * @code
|
Chris@16
|
92 * boost::asio::ip::udp::socket socket(io_service);
|
Chris@16
|
93 * ...
|
Chris@16
|
94 * boost::asio::ip::address_v4 local_interface =
|
Chris@16
|
95 * boost::asio::ip::address_v4::from_string("1.2.3.4");
|
Chris@16
|
96 * boost::asio::ip::multicast::outbound_interface option(local_interface);
|
Chris@16
|
97 * socket.set_option(option);
|
Chris@16
|
98 * @endcode
|
Chris@16
|
99 *
|
Chris@16
|
100 * @par Concepts:
|
Chris@16
|
101 * SettableSocketOption.
|
Chris@16
|
102 */
|
Chris@16
|
103 #if defined(GENERATING_DOCUMENTATION)
|
Chris@16
|
104 typedef implementation_defined outbound_interface;
|
Chris@16
|
105 #else
|
Chris@16
|
106 typedef boost::asio::ip::detail::socket_option::network_interface<
|
Chris@16
|
107 BOOST_ASIO_OS_DEF(IPPROTO_IP),
|
Chris@16
|
108 BOOST_ASIO_OS_DEF(IP_MULTICAST_IF),
|
Chris@16
|
109 BOOST_ASIO_OS_DEF(IPPROTO_IPV6),
|
Chris@16
|
110 BOOST_ASIO_OS_DEF(IPV6_MULTICAST_IF)> outbound_interface;
|
Chris@16
|
111 #endif
|
Chris@16
|
112
|
Chris@16
|
113 /// Socket option for time-to-live associated with outgoing multicast packets.
|
Chris@16
|
114 /**
|
Chris@16
|
115 * Implements the IPPROTO_IP/IP_MULTICAST_TTL socket option.
|
Chris@16
|
116 *
|
Chris@16
|
117 * @par Examples
|
Chris@16
|
118 * Setting the option:
|
Chris@16
|
119 * @code
|
Chris@16
|
120 * boost::asio::ip::udp::socket socket(io_service);
|
Chris@16
|
121 * ...
|
Chris@16
|
122 * boost::asio::ip::multicast::hops option(4);
|
Chris@16
|
123 * socket.set_option(option);
|
Chris@16
|
124 * @endcode
|
Chris@16
|
125 *
|
Chris@16
|
126 * @par
|
Chris@16
|
127 * Getting the current option value:
|
Chris@16
|
128 * @code
|
Chris@16
|
129 * boost::asio::ip::udp::socket socket(io_service);
|
Chris@16
|
130 * ...
|
Chris@16
|
131 * boost::asio::ip::multicast::hops option;
|
Chris@16
|
132 * socket.get_option(option);
|
Chris@16
|
133 * int ttl = option.value();
|
Chris@16
|
134 * @endcode
|
Chris@16
|
135 *
|
Chris@16
|
136 * @par Concepts:
|
Chris@16
|
137 * GettableSocketOption, SettableSocketOption.
|
Chris@16
|
138 */
|
Chris@16
|
139 #if defined(GENERATING_DOCUMENTATION)
|
Chris@16
|
140 typedef implementation_defined hops;
|
Chris@16
|
141 #else
|
Chris@16
|
142 typedef boost::asio::ip::detail::socket_option::multicast_hops<
|
Chris@16
|
143 BOOST_ASIO_OS_DEF(IPPROTO_IP),
|
Chris@16
|
144 BOOST_ASIO_OS_DEF(IP_MULTICAST_TTL),
|
Chris@16
|
145 BOOST_ASIO_OS_DEF(IPPROTO_IPV6),
|
Chris@16
|
146 BOOST_ASIO_OS_DEF(IPV6_MULTICAST_HOPS)> hops;
|
Chris@16
|
147 #endif
|
Chris@16
|
148
|
Chris@16
|
149 /// Socket option determining whether outgoing multicast packets will be
|
Chris@16
|
150 /// received on the same socket if it is a member of the multicast group.
|
Chris@16
|
151 /**
|
Chris@16
|
152 * Implements the IPPROTO_IP/IP_MULTICAST_LOOP socket option.
|
Chris@16
|
153 *
|
Chris@16
|
154 * @par Examples
|
Chris@16
|
155 * Setting the option:
|
Chris@16
|
156 * @code
|
Chris@16
|
157 * boost::asio::ip::udp::socket socket(io_service);
|
Chris@16
|
158 * ...
|
Chris@16
|
159 * boost::asio::ip::multicast::enable_loopback option(true);
|
Chris@16
|
160 * socket.set_option(option);
|
Chris@16
|
161 * @endcode
|
Chris@16
|
162 *
|
Chris@16
|
163 * @par
|
Chris@16
|
164 * Getting the current option value:
|
Chris@16
|
165 * @code
|
Chris@16
|
166 * boost::asio::ip::udp::socket socket(io_service);
|
Chris@16
|
167 * ...
|
Chris@16
|
168 * boost::asio::ip::multicast::enable_loopback option;
|
Chris@16
|
169 * socket.get_option(option);
|
Chris@16
|
170 * bool is_set = option.value();
|
Chris@16
|
171 * @endcode
|
Chris@16
|
172 *
|
Chris@16
|
173 * @par Concepts:
|
Chris@16
|
174 * GettableSocketOption, SettableSocketOption.
|
Chris@16
|
175 */
|
Chris@16
|
176 #if defined(GENERATING_DOCUMENTATION)
|
Chris@16
|
177 typedef implementation_defined enable_loopback;
|
Chris@16
|
178 #else
|
Chris@16
|
179 typedef boost::asio::ip::detail::socket_option::multicast_enable_loopback<
|
Chris@16
|
180 BOOST_ASIO_OS_DEF(IPPROTO_IP),
|
Chris@16
|
181 BOOST_ASIO_OS_DEF(IP_MULTICAST_LOOP),
|
Chris@16
|
182 BOOST_ASIO_OS_DEF(IPPROTO_IPV6),
|
Chris@16
|
183 BOOST_ASIO_OS_DEF(IPV6_MULTICAST_LOOP)> enable_loopback;
|
Chris@16
|
184 #endif
|
Chris@16
|
185
|
Chris@16
|
186 } // namespace multicast
|
Chris@16
|
187 } // namespace ip
|
Chris@16
|
188 } // namespace asio
|
Chris@16
|
189 } // namespace boost
|
Chris@16
|
190
|
Chris@16
|
191 #include <boost/asio/detail/pop_options.hpp>
|
Chris@16
|
192
|
Chris@16
|
193 #endif // BOOST_ASIO_IP_MULTICAST_HPP
|