Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd5002b5 authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder: vsock compiles on host

Currently not tested, since connecting doesn't work. However, this helps
avoid the ifndef business.


Bug: 185269356
Test: binderRpcTest
Change-Id: I3b93e0a97e671d3d939979f00bc1e297f593a31d
parent 4fccd098
Loading
Loading
Loading
Loading
+0 −4
Original line number Original line Diff line number Diff line
@@ -49,8 +49,6 @@ bool RpcServer::setupUnixDomainServer(const char* path) {
    return setupSocketServer(UnixSocketAddress(path));
    return setupSocketServer(UnixSocketAddress(path));
}
}


#ifdef __BIONIC__

bool RpcServer::setupVsockServer(unsigned int port) {
bool RpcServer::setupVsockServer(unsigned int port) {
    // realizing value w/ this type at compile time to avoid ubsan abort
    // realizing value w/ this type at compile time to avoid ubsan abort
    constexpr unsigned int kAnyCid = VMADDR_CID_ANY;
    constexpr unsigned int kAnyCid = VMADDR_CID_ANY;
@@ -58,8 +56,6 @@ bool RpcServer::setupVsockServer(unsigned int port) {
    return setupSocketServer(VsockSocketAddress(kAnyCid, port));
    return setupSocketServer(VsockSocketAddress(kAnyCid, port));
}
}


#endif // __BIONIC__

bool RpcServer::setupInetServer(unsigned int port, unsigned int* assignedPort) {
bool RpcServer::setupInetServer(unsigned int port, unsigned int* assignedPort) {
    const char* kAddr = "127.0.0.1";
    const char* kAddr = "127.0.0.1";


+0 −4
Original line number Original line Diff line number Diff line
@@ -61,14 +61,10 @@ bool RpcSession::setupUnixDomainClient(const char* path) {
    return setupSocketClient(UnixSocketAddress(path));
    return setupSocketClient(UnixSocketAddress(path));
}
}


#ifdef __BIONIC__

bool RpcSession::setupVsockClient(unsigned int cid, unsigned int port) {
bool RpcSession::setupVsockClient(unsigned int cid, unsigned int port) {
    return setupSocketClient(VsockSocketAddress(cid, port));
    return setupSocketClient(VsockSocketAddress(cid, port));
}
}


#endif // __BIONIC__

bool RpcSession::setupInetClient(const char* addr, unsigned int port) {
bool RpcSession::setupInetClient(const char* addr, unsigned int port) {
    auto aiStart = InetSocketAddress::getAddrInfo(addr, port);
    auto aiStart = InetSocketAddress::getAddrInfo(addr, port);
    if (aiStart == nullptr) return false;
    if (aiStart == nullptr) return false;
+1 −7
Original line number Original line Diff line number Diff line
@@ -24,9 +24,7 @@
#include <sys/types.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/un.h>


#ifdef __BIONIC__
#include "vm_sockets.h"
#include <linux/vm_sockets.h>
#endif


namespace android {
namespace android {


@@ -59,8 +57,6 @@ private:
    sockaddr_un mAddr;
    sockaddr_un mAddr;
};
};


#ifdef __BIONIC__

class VsockSocketAddress : public RpcSocketAddress {
class VsockSocketAddress : public RpcSocketAddress {
public:
public:
    VsockSocketAddress(unsigned int cid, unsigned int port)
    VsockSocketAddress(unsigned int cid, unsigned int port)
@@ -80,8 +76,6 @@ private:
    sockaddr_vm mAddr;
    sockaddr_vm mAddr;
};
};


#endif // __BIONIC__

class InetSocketAddress : public RpcSocketAddress {
class InetSocketAddress : public RpcSocketAddress {
public:
public:
    InetSocketAddress(const sockaddr* sockAddr, size_t size, const char* addr, unsigned int port)
    InetSocketAddress(const sockaddr* sockAddr, size_t size, const char* addr, unsigned int port)
+0 −2
Original line number Original line Diff line number Diff line
@@ -57,12 +57,10 @@ public:
     */
     */
    [[nodiscard]] bool setupUnixDomainServer(const char* path);
    [[nodiscard]] bool setupUnixDomainServer(const char* path);


#ifdef __BIONIC__
    /**
    /**
     * Creates an RPC server at the current port.
     * Creates an RPC server at the current port.
     */
     */
    [[nodiscard]] bool setupVsockServer(unsigned int port);
    [[nodiscard]] bool setupVsockServer(unsigned int port);
#endif // __BIONIC__


    /**
    /**
     * Creates an RPC server at the current port using IPv4.
     * Creates an RPC server at the current port using IPv4.
+0 −2
Original line number Original line Diff line number Diff line
@@ -52,12 +52,10 @@ public:
     */
     */
    [[nodiscard]] bool setupUnixDomainClient(const char* path);
    [[nodiscard]] bool setupUnixDomainClient(const char* path);


#ifdef __BIONIC__
    /**
    /**
     * Connects to an RPC server at the CVD & port.
     * Connects to an RPC server at the CVD & port.
     */
     */
    [[nodiscard]] bool setupVsockClient(unsigned int cvd, unsigned int port);
    [[nodiscard]] bool setupVsockClient(unsigned int cvd, unsigned int port);
#endif // __BIONIC__


    /**
    /**
     * Connects to an RPC server at the given address and port.
     * Connects to an RPC server at the given address and port.
Loading