OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "net/dns/mdns_client.h" | 5 #include "net/dns/mdns_client.h" |
6 | 6 |
7 #include "net/base/net_errors.h" | 7 #include "net/base/net_errors.h" |
8 #include "net/dns/dns_protocol.h" | 8 #include "net/dns/dns_protocol.h" |
9 #include "net/dns/mdns_client_impl.h" | 9 #include "net/dns/mdns_client_impl.h" |
10 | 10 |
11 namespace net { | 11 namespace net { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 const char kMDnsMulticastGroupIPv4[] = "224.0.0.251"; | 15 const char kMDnsMulticastGroupIPv4[] = "224.0.0.251"; |
16 const char kMDnsMulticastGroupIPv6[] = "FF02::FB"; | 16 const char kMDnsMulticastGroupIPv6[] = "FF02::FB"; |
17 | 17 |
18 IPEndPoint GetMDnsIPEndPoint(const char* address) { | 18 IPEndPoint GetMDnsIPEndPoint(const char* address) { |
19 IPAddressNumber multicast_group_number; | 19 IPAddressNumber multicast_group_number; |
20 bool success = ParseIPLiteralToNumber(address, | 20 bool success = ParseIPLiteralToNumber(address, &multicast_group_number); |
21 &multicast_group_number); | |
22 DCHECK(success); | 21 DCHECK(success); |
23 return IPEndPoint(multicast_group_number, | 22 return IPEndPoint(multicast_group_number, |
24 dns_protocol::kDefaultPortMulticast); | 23 dns_protocol::kDefaultPortMulticast); |
25 } | 24 } |
26 | 25 |
27 int Bind(const IPEndPoint& multicast_addr, | 26 int Bind(const IPEndPoint& multicast_addr, |
28 uint32 interface_index, | 27 uint32 interface_index, |
29 DatagramServerSocket* socket) { | 28 DatagramServerSocket* socket) { |
30 IPAddressNumber address_any(multicast_addr.address().size()); | 29 IPAddressNumber address_any(multicast_addr.address().size()); |
31 IPEndPoint bind_endpoint(address_any, multicast_addr.port()); | 30 IPEndPoint bind_endpoint(address_any, multicast_addr.port()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 int rv = Bind(multicast_addr, interface_index, socket.get()); | 92 int rv = Bind(multicast_addr, interface_index, socket.get()); |
94 if (rv != OK) { | 93 if (rv != OK) { |
95 socket.reset(); | 94 socket.reset(); |
96 VLOG(1) << "Bind failed, endpoint=" << multicast_addr.ToStringWithoutPort() | 95 VLOG(1) << "Bind failed, endpoint=" << multicast_addr.ToStringWithoutPort() |
97 << ", error=" << rv; | 96 << ", error=" << rv; |
98 } | 97 } |
99 return socket.PassAs<DatagramServerSocket>(); | 98 return socket.PassAs<DatagramServerSocket>(); |
100 } | 99 } |
101 | 100 |
102 } // namespace net | 101 } // namespace net |
OLD | NEW |