#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "mojo/public/cpp/platform/socket_utils_posix.h"
#include <stddef.h>
#include <sys/socket.h>
#include <unistd.h>
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/posix/eintr_wrapper.h"
#include "build/build_config.h"
#if !BUILDFLAG(IS_NACL)
#include <sys/uio.h>
#endif
namespace mojo {
namespace {
#if !BUILDFLAG(IS_NACL)
bool IsRecoverableError() { … }
bool GetPeerEuid(base::PlatformFile fd, uid_t* peer_euid) { … }
bool IsPeerAuthorized(base::PlatformFile fd) { … }
#endif
#if BUILDFLAG(IS_APPLE)
constexpr int kSendmsgFlags = 0;
#else
constexpr int kSendmsgFlags = …;
#endif
}
ssize_t SocketWrite(base::PlatformFile socket,
const void* bytes,
size_t num_bytes) { … }
ssize_t SocketWritev(base::PlatformFile socket,
struct iovec* iov,
size_t num_iov) { … }
ssize_t SendmsgWithHandles(base::PlatformFile socket,
struct iovec* iov,
size_t num_iov,
const std::vector<base::ScopedFD>& descriptors) { … }
ssize_t SocketRecvmsg(base::PlatformFile socket,
void* buf,
size_t num_bytes,
std::vector<base::ScopedFD>* descriptors,
bool block) { … }
bool AcceptSocketConnection(base::PlatformFile server_fd,
base::ScopedFD* connection_fd,
bool check_peer_user) { … }
}