summaryrefslogtreecommitdiffstats
path: root/net/dns/dns_test_util.cc
blob: a3962524dcc93bee2401974546a7aca61efc7ad2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/dns/dns_test_util.h"

#include "base/message_loop.h"

namespace net {

bool ConvertStringsToIPAddressList(
    const char* const ip_strings[], size_t size, IPAddressList* address_list) {
  DCHECK(address_list);
  IPAddressList ip_addresses;
  for (size_t i = 0; i < size; ++i) {
    IPAddressNumber ip;
    if (!ParseIPLiteralToNumber(ip_strings[i], &ip))
      return false;
    ip_addresses.push_back(ip);
  }
  address_list->swap(ip_addresses);
  return true;
}

bool CreateDnsAddress(
    const char* ip_string, uint16 port, IPEndPoint* endpoint) {
  DCHECK(endpoint);
  IPAddressNumber ip_address;
  if (!ParseIPLiteralToNumber(ip_string, &ip_address))
    return false;
  *endpoint = IPEndPoint(ip_address, port);
  return true;
}

}  // namespace net