- add sources.
[platform/framework/web/crosswalk.git] / src / net / dns / mdns_client.cc
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
3 // found in the LICENSE file.
4
5 #include "net/dns/mdns_client.h"
6
7 #include "net/dns/dns_protocol.h"
8 #include "net/dns/mdns_client_impl.h"
9
10 namespace net {
11
12 namespace {
13
14 const char kMDnsMulticastGroupIPv4[] = "224.0.0.251";
15 const char kMDnsMulticastGroupIPv6[] = "FF02::FB";
16
17 IPEndPoint GetMDnsIPEndPoint(const char* address) {
18   IPAddressNumber multicast_group_number;
19   bool success = ParseIPLiteralToNumber(address,
20                                         &multicast_group_number);
21   DCHECK(success);
22   return IPEndPoint(multicast_group_number,
23                     dns_protocol::kDefaultPortMulticast);
24 }
25
26 }  // namespace
27
28 // static
29 scoped_ptr<MDnsClient> MDnsClient::CreateDefault() {
30   return scoped_ptr<MDnsClient>(
31       new MDnsClientImpl(MDnsConnection::SocketFactory::CreateDefault()));
32 }
33
34 IPEndPoint GetMDnsIPEndPoint(AddressFamily address_family) {
35   switch (address_family) {
36   case ADDRESS_FAMILY_IPV4:
37     return GetMDnsIPEndPoint(kMDnsMulticastGroupIPv4);
38   case ADDRESS_FAMILY_IPV6:
39     return GetMDnsIPEndPoint(kMDnsMulticastGroupIPv6);
40   default:
41     NOTREACHED();
42     return IPEndPoint();
43   }
44 }
45
46 }  // namespace net