rpc_binder: Remove unused VsockFactory server code
Previous changes removed the use of RunVsockRpcServerWithFactory. Remove
the now unused code from libbinder_rpc.
Bug: 245727626
Test: builds
Change-Id: Icda0298e50cdae101d7929bb5de310e6e08ceb42
diff --git a/libs/binder/libbinder_rpc_unstable.cpp b/libs/binder/libbinder_rpc_unstable.cpp
index 88f8c94..184d3f3 100644
--- a/libs/binder/libbinder_rpc_unstable.cpp
+++ b/libs/binder/libbinder_rpc_unstable.cpp
@@ -51,35 +51,8 @@
ref->decStrong(ref);
}
-static unsigned int cidFromStructAddr(const void* addr, size_t addrlen) {
- LOG_ALWAYS_FATAL_IF(addrlen < sizeof(sockaddr_vm), "sockaddr is truncated");
- const sockaddr_vm* vaddr = reinterpret_cast<const sockaddr_vm*>(addr);
- LOG_ALWAYS_FATAL_IF(vaddr->svm_family != AF_VSOCK, "address is not a vsock");
- return vaddr->svm_cid;
-}
-
extern "C" {
-bool RunVsockRpcServerWithFactory(AIBinder* (*factory)(unsigned int cid, void* context),
- void* factoryContext, unsigned int port) {
- auto server = RpcServer::make();
- if (status_t status = server->setupVsockServer(VMADDR_CID_ANY, port); status != OK) {
- LOG(ERROR) << "Failed to set up vsock server with port " << port
- << " error: " << statusToString(status).c_str();
- return false;
- }
- server->setPerSessionRootObject([=](const void* addr, size_t addrlen) {
- unsigned int cid = cidFromStructAddr(addr, addrlen);
- return AIBinder_toPlatformBinder(factory(cid, factoryContext));
- });
-
- server->join();
-
- // Shutdown any open sessions since server failed.
- (void)server->shutdown();
- return true;
-}
-
ARpcServer* ARpcServer_newVsock(AIBinder* service, unsigned int cid, unsigned int port) {
auto server = RpcServer::make();
@@ -96,9 +69,11 @@
}
if (cid != VMADDR_CID_ANY) {
server->setConnectionFilter([=](const void* addr, size_t addrlen) {
- unsigned int remoteCid = cidFromStructAddr(addr, addrlen);
- if (cid != remoteCid) {
- LOG(ERROR) << "Rejected vsock connection from CID " << remoteCid;
+ LOG_ALWAYS_FATAL_IF(addrlen < sizeof(sockaddr_vm), "sockaddr is truncated");
+ const sockaddr_vm* vaddr = reinterpret_cast<const sockaddr_vm*>(addr);
+ LOG_ALWAYS_FATAL_IF(vaddr->svm_family != AF_VSOCK, "address is not a vsock");
+ if (cid != vaddr->svm_cid) {
+ LOG(ERROR) << "Rejected vsock connection from CID " << vaddr->svm_cid;
return false;
}
return true;