0

OpenBSD patches for net, split from CR

net/base/host_resolver_proc.cc:
  - define AI_ADDRCONFIG as 0

net/base/listen_socket.cc:
  - Shuffle and add missing headers since the order
    of including these matters.

net/base/net_util.h:
  - Missing header for all POSIX platforms. Needed on
    OpenBSD and it won't hurt others.

net/dns/dns_config_service_posix.h:
  - Missing header for OpenBSD. The order matters here too

net/dns/dns_config_service_posix.cc:
  - Use res_init() on OpenBSD and disable RES_ROTATE
    if it is not defined

net/net.gyp:
  - Do not use libresolv on OpenBSD since it's not there,
    the resolver is in libc.
  - Include base/platform_mime_util_linux.cc in the OpenBSD builds.

BUG=
TEST=


Review URL: http://codereview.chromium.org/8336024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106604 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
robert.nagy@gmail.com
2011-10-20 22:39:26 +00:00
parent c25b4c8cdf
commit bae892f9c1
8 changed files with 37 additions and 6 deletions

@ -18,6 +18,11 @@
#define bswap_16(x) OSSwapInt16(x)
#define bswap_32(x) OSSwapInt32(x)
#define bswap_64(x) OSSwapInt64(x)
#elif defined(OS_OPENBSD)
#include <sys/endian.h>
#define bswap_16(x) swap16(x)
#define bswap_32(x) swap32(x)
#define bswap_64(x) swap64(x)
#else
#include <byteswap.h>
#endif

@ -5,6 +5,7 @@
#include "net/base/dnsrr_resolver.h"
#if defined(OS_POSIX)
#include <netinet/in.h>
#include <resolv.h>
#endif
@ -187,7 +188,11 @@ class RRResolverWorker {
bool r = true;
#if defined(OS_MACOSX) || defined(OS_OPENBSD)
if ((_res.options & RES_INIT) == 0) {
#if defined(OS_OPENBSD)
if (res_init() != 0)
#else
if (res_ninit(&_res) != 0)
#endif
r = false;
}
#else

@ -12,8 +12,8 @@
#include "net/base/net_errors.h"
#include "net/base/sys_addrinfo.h"
#if defined(OS_POSIX) && !defined(OS_MACOSX)
#include <resolv.h>
#if defined(OS_OPENBSD)
#define AI_ADDRCONFIG 0
#endif
namespace net {
@ -143,7 +143,7 @@ int SystemHostResolverProc(const std::string& host,
hints.ai_family = AF_UNSPEC;
}
#if defined(OS_WIN) || defined(OS_OPENBSD)
#if defined(OS_WIN)
// DO NOT USE AI_ADDRCONFIG ON WINDOWS.
//
// The following comment in <winsock2.h> is the best documentation I found

@ -10,8 +10,9 @@
#include <winsock2.h>
#elif defined(OS_POSIX)
#include <errno.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "net/base/net_errors.h"
#endif

@ -12,6 +12,7 @@
#include <windows.h>
#include <ws2tcpip.h>
#elif defined(OS_POSIX)
#include <sys/types.h>
#include <sys/socket.h>
#endif

@ -30,16 +30,22 @@ class DnsConfigServicePosix::ConfigReader : public SerialWorker {
success_(false) {}
void DoWork() OVERRIDE {
#if defined(OS_OPENBSD)
if ((res_init() == 0) && (_res.options & RES_INIT)) {
success_ = ConvertResToConfig(_res, &dns_config_);
#else
struct __res_state res;
if ((res_ninit(&res) == 0) && (res.options & RES_INIT)) {
success_ = ConvertResToConfig(res, &dns_config_);
#endif
} else {
// Note: res_ninit in glibc always returns 0 and sets RES_INIT.
// res_init behaves the same way.
success_ = false;
}
#if defined(OS_MACOSX)
res_ndestroy(&res);
#else
#elif !defined(OS_OPENBSD)
res_nclose(&res);
#endif
}
@ -123,7 +129,9 @@ bool ConvertResToConfig(const struct __res_state& res, DnsConfig* dns_config) {
dns_config->ndots = res.ndots;
dns_config->timeout = base::TimeDelta::FromSeconds(res.retrans);
dns_config->attempts = res.retry;
#if defined(RES_ROTATE)
dns_config->rotate = res.options & RES_ROTATE;
#endif
dns_config->edns0 = res.options & RES_USE_EDNS0;
return true;

@ -6,6 +6,8 @@
#define NET_DNS_DNS_CONFIG_SERVICE_POSIX_H_
#pragma once
#include <sys/types.h>
#include <netinet/in.h>
#include <resolv.h>
#include "base/compiler_specific.h"

@ -742,6 +742,11 @@
'proxy/proxy_config_service_linux.h',
],
}],
['OS=="openbsd"', {
'sources': [
'base/platform_mime_util_linux.cc',
],
}],
['use_kerberos==1', {
'defines': [
'USE_KERBEROS',
@ -821,7 +826,6 @@
'dependencies': [
'../build/linux/system.gyp:gconf',
'../build/linux/system.gyp:gio',
'../build/linux/system.gyp:libresolv',
],
'conditions': [
['use_openssl==1', {
@ -834,6 +838,11 @@
'../build/linux/system.gyp:ssl',
],
}],
['OS!="openbsd"', {
'dependencies': [
'../build/linux/system.gyp:libresolv',
],
}],
['OS=="solaris"', {
'link_settings': {
'ldflags': [