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/dns/dns_protocol.h" | 7 #include "net/dns/dns_protocol.h" |
8 #include "net/dns/mdns_client_impl.h" | 8 #include "net/dns/mdns_client_impl.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 const char kMDnsMulticastGroupIPv4[] = "224.0.0.251"; | 14 const char kMDnsMulticastGroupIPv4[] = "224.0.0.251"; |
15 const char kMDnsMulticastGroupIPv6[] = "FF02::FB"; | 15 const char kMDnsMulticastGroupIPv6[] = "FF02::FB"; |
16 | 16 |
17 IPEndPoint GetMDnsIPEndPoint(const char* address) { | 17 IPEndPoint GetMDnsIPEndPoint(const char* address) { |
18 IPAddressNumber multicast_group_number; | 18 IPAddressNumber multicast_group_number; |
19 bool success = ParseIPLiteralToNumber(address, | 19 bool success = ParseIPLiteralToNumber(address, |
20 &multicast_group_number); | 20 &multicast_group_number); |
21 DCHECK(success); | 21 DCHECK(success); |
22 return IPEndPoint(multicast_group_number, | 22 return IPEndPoint(multicast_group_number, |
23 dns_protocol::kDefaultPortMulticast); | 23 dns_protocol::kDefaultPortMulticast); |
24 } | 24 } |
25 | 25 |
26 } // namespace | 26 } // namespace |
27 | 27 |
28 // static | 28 // static |
| 29 scoped_ptr<MDnsSocketFactory> MDnsSocketFactory::CreateDefault() { |
| 30 return scoped_ptr<MDnsSocketFactory>(new MDnsSocketFactoryImpl); |
| 31 } |
| 32 |
| 33 // static |
29 scoped_ptr<MDnsClient> MDnsClient::CreateDefault() { | 34 scoped_ptr<MDnsClient> MDnsClient::CreateDefault() { |
30 return scoped_ptr<MDnsClient>( | 35 return scoped_ptr<MDnsClient>(new MDnsClientImpl()); |
31 new MDnsClientImpl(MDnsConnection::SocketFactory::CreateDefault())); | |
32 } | 36 } |
33 | 37 |
34 IPEndPoint GetMDnsIPEndPoint(AddressFamily address_family) { | 38 IPEndPoint GetMDnsIPEndPoint(AddressFamily address_family) { |
35 switch (address_family) { | 39 switch (address_family) { |
36 case ADDRESS_FAMILY_IPV4: | 40 case ADDRESS_FAMILY_IPV4: |
37 return GetMDnsIPEndPoint(kMDnsMulticastGroupIPv4); | 41 return GetMDnsIPEndPoint(kMDnsMulticastGroupIPv4); |
38 case ADDRESS_FAMILY_IPV6: | 42 case ADDRESS_FAMILY_IPV6: |
39 return GetMDnsIPEndPoint(kMDnsMulticastGroupIPv6); | 43 return GetMDnsIPEndPoint(kMDnsMulticastGroupIPv6); |
40 default: | 44 default: |
41 NOTREACHED(); | 45 NOTREACHED(); |
42 return IPEndPoint(); | 46 return IPEndPoint(); |
43 } | 47 } |
44 } | 48 } |
45 | 49 |
46 } // namespace net | 50 } // namespace net |
OLD | NEW |