| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_UDP_UDP_SOCKET_LIBEVENT_H_ | 5 #ifndef NET_UDP_UDP_SOCKET_LIBEVENT_H_ |
| 6 #define NET_UDP_UDP_SOCKET_LIBEVENT_H_ | 6 #define NET_UDP_UDP_SOCKET_LIBEVENT_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 // Sets corresponding flags in |socket_options_| to allow sending | 112 // Sets corresponding flags in |socket_options_| to allow sending |
| 113 // and receiving packets to and from broadcast addresses. Should be | 113 // and receiving packets to and from broadcast addresses. Should be |
| 114 // called before Bind(). | 114 // called before Bind(). |
| 115 void AllowBroadcast(); | 115 void AllowBroadcast(); |
| 116 | 116 |
| 117 // Join the multicast group. | 117 // Join the multicast group. |
| 118 // |group_address| is the group address to join, could be either | 118 // |group_address| is the group address to join, could be either |
| 119 // an IPv4 or IPv6 address. | 119 // an IPv4 or IPv6 address. |
| 120 // Return a network error code. | 120 // Return a network error code. |
| 121 int JoinGroup(const IPAddressNumber& group_address) const; | 121 int JoinGroup(const IPAddressNumber& group_address); |
| 122 | 122 |
| 123 // Leave the multicast group. | 123 // Leave the multicast group. |
| 124 // |group_address| is the group address to leave, could be either | 124 // |group_address| is the group address to leave, could be either |
| 125 // an IPv4 or IPv6 address. If the socket hasn't joined the group, | 125 // an IPv4 or IPv6 address. If the socket hasn't joined the group, |
| 126 // it will be ignored. | 126 // it will be ignored. |
| 127 // It's optional to leave the multicast group before destroying | 127 // It's optional to leave the multicast group before destroying |
| 128 // the socket. It will be done by the OS. | 128 // the socket. It will be done by the OS. |
| 129 // Return a network error code. | 129 // Return a network error code. |
| 130 int LeaveGroup(const IPAddressNumber& group_address) const; | 130 int LeaveGroup(const IPAddressNumber& group_address); |
| 131 |
| 132 // Set interface to use for multicast. If |interface_index| set to 0, default |
| 133 // interface is used. Must be called before |JoinGroup| or |LeaveGroup|. |
| 134 int SetMulticastInterface(uint32 interface_index); |
| 131 | 135 |
| 132 // Set the time-to-live option for UDP packets sent to the multicast | 136 // Set the time-to-live option for UDP packets sent to the multicast |
| 133 // group address. The default value of this option is 1. | 137 // group address. The default value of this option is 1. |
| 134 // Cannot be negative or more than 255. | 138 // Cannot be negative or more than 255. |
| 135 // Should be called before Bind(). | 139 // Should be called before Bind(). |
| 136 // Return a network error code. | 140 // Return a network error code. |
| 137 int SetMulticastTimeToLive(int time_to_live); | 141 int SetMulticastTimeToLive(int time_to_live); |
| 138 | 142 |
| 139 // Set the loopback flag for UDP socket. If this flag is true, the host | 143 // Set the loopback flag for UDP socket. If this flag is true, the host |
| 140 // will receive packets sent to the joined group from itself. | 144 // will receive packets sent to the joined group from itself. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 int DoBind(const IPEndPoint& address); | 234 int DoBind(const IPEndPoint& address); |
| 231 int RandomBind(const IPEndPoint& address); | 235 int RandomBind(const IPEndPoint& address); |
| 232 | 236 |
| 233 int socket_; | 237 int socket_; |
| 234 int addr_family_; | 238 int addr_family_; |
| 235 | 239 |
| 236 // Bitwise-or'd combination of SocketOptions. Specifies the set of | 240 // Bitwise-or'd combination of SocketOptions. Specifies the set of |
| 237 // options that should be applied to |socket_| before Bind(). | 241 // options that should be applied to |socket_| before Bind(). |
| 238 int socket_options_; | 242 int socket_options_; |
| 239 | 243 |
| 244 // Multicast interface. |
| 245 uint32 multicast_interface_; |
| 246 |
| 240 // Multicast socket options cached for SetSocketOption. | 247 // Multicast socket options cached for SetSocketOption. |
| 241 // Cannot be used after Bind(). | 248 // Cannot be used after Bind(). |
| 242 int multicast_time_to_live_; | 249 int multicast_time_to_live_; |
| 243 | 250 |
| 244 // How to do source port binding, used only when UDPSocket is part of | 251 // How to do source port binding, used only when UDPSocket is part of |
| 245 // UDPClientSocket, since UDPServerSocket provides Bind. | 252 // UDPClientSocket, since UDPServerSocket provides Bind. |
| 246 DatagramSocket::BindType bind_type_; | 253 DatagramSocket::BindType bind_type_; |
| 247 | 254 |
| 248 // PRNG function for generating port numbers. | 255 // PRNG function for generating port numbers. |
| 249 RandIntCallback rand_int_cb_; | 256 RandIntCallback rand_int_cb_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 278 CompletionCallback write_callback_; | 285 CompletionCallback write_callback_; |
| 279 | 286 |
| 280 BoundNetLog net_log_; | 287 BoundNetLog net_log_; |
| 281 | 288 |
| 282 DISALLOW_COPY_AND_ASSIGN(UDPSocketLibevent); | 289 DISALLOW_COPY_AND_ASSIGN(UDPSocketLibevent); |
| 283 }; | 290 }; |
| 284 | 291 |
| 285 } // namespace net | 292 } // namespace net |
| 286 | 293 |
| 287 #endif // NET_UDP_UDP_SOCKET_LIBEVENT_H_ | 294 #endif // NET_UDP_UDP_SOCKET_LIBEVENT_H_ |
| OLD | NEW |