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

source code of boost/libs/asio/include/boost/asio/ip/multicast.hpp