libbinder: dynamically accept clients
Server listens on a single port and add clients.
The server looks like this:
while True:
accept client
read client id
if new id:
create new rpc connection
else:
attach thread to existing rpc connection
Roadmap:
- having client add connections only when needed (currently they are
all added at initialization time) - when this change is made, the
server will also need to enforce the max threads per client.
- allowing RpcConnection to create reverse connections with an
threadpool to serve calls in the other direction
- replacing connection IDs with something like TLS
- access controls for who can connect to who in pKVM context
Bug: 185167543
Test: binderRpcTest
Change-Id: I510d23a50cf839c39bc8107c1b0dae24dee3bc7b
diff --git a/libs/binder/RpcWireFormat.h b/libs/binder/RpcWireFormat.h
index 56af0d3..a7e8a52 100644
--- a/libs/binder/RpcWireFormat.h
+++ b/libs/binder/RpcWireFormat.h
@@ -51,6 +51,8 @@
RPC_SPECIAL_TRANSACT_GET_CONNECTION_ID = 2,
};
+constexpr int32_t RPC_CONNECTION_ID_NEW = -1;
+
// serialization is like:
// |RpcWireHeader|struct desginated by 'command'| (over and over again)