Use ParcelFileDescriptor instead of FileDescriptor in INetd.aidl
Stable aidl won't support FileDescriptor but ParcelFileDescriptor.
In order to migrate to stable aidl, replace all FileDescriptor in
INdetd.aidl.
Test: built, flashed, booted
system/netd/tests/runtests.sh passes
Change-Id: I331626346959f127b4c1cb2ece33db37cb8dc550
diff --git a/server/XfrmController.cpp b/server/XfrmController.cpp
index 684f5e9..de9aa0b 100644
--- a/server/XfrmController.cpp
+++ b/server/XfrmController.cpp
@@ -451,11 +451,11 @@
return !errored;
}
-netdutils::Status XfrmController::ipSecSetEncapSocketOwner(const android::base::unique_fd& socket,
- int newUid, uid_t callerUid) {
+netdutils::Status XfrmController::ipSecSetEncapSocketOwner(int socketFd, int newUid,
+ uid_t callerUid) {
ALOGD("XfrmController:%s, line=%d", __FUNCTION__, __LINE__);
- const int fd = socket.get();
+ const int fd = socketFd;
struct stat info;
if (fstat(fd, &info)) {
return netdutils::statusFromErrno(errno, "Failed to stat socket file descriptor");
@@ -470,7 +470,7 @@
int optval;
socklen_t optlen = sizeof(optval);
netdutils::Status status =
- getSyscallInstance().getsockopt(Fd(socket), IPPROTO_UDP, UDP_ENCAP, &optval, &optlen);
+ getSyscallInstance().getsockopt(Fd(fd), IPPROTO_UDP, UDP_ENCAP, &optval, &optlen);
if (status != netdutils::status::ok) {
return status;
}
@@ -695,8 +695,8 @@
}
netdutils::Status XfrmController::ipSecApplyTransportModeTransform(
- const android::base::unique_fd& socket, int32_t transformId, int32_t direction,
- const std::string& sourceAddress, const std::string& destinationAddress, int32_t spi) {
+ int socketFd, int32_t transformId, int32_t direction, const std::string& sourceAddress,
+ const std::string& destinationAddress, int32_t spi) {
ALOGD("XfrmController::%s, line=%d", __FUNCTION__, __LINE__);
ALOGD("transformId=%d", transformId);
ALOGD("direction=%d", direction);
@@ -704,7 +704,8 @@
ALOGD("destinationAddress=%s", destinationAddress.c_str());
ALOGD("spi=%0.8x", spi);
- StatusOr<sockaddr_storage> ret = getSyscallInstance().getsockname<sockaddr_storage>(Fd(socket));
+ StatusOr<sockaddr_storage> ret =
+ getSyscallInstance().getsockname<sockaddr_storage>(Fd(socketFd));
if (!isOk(ret)) {
ALOGE("Failed to get socket info in %s", __FUNCTION__);
return ret;
@@ -755,7 +756,7 @@
return netdutils::statusFromErrno(EAFNOSUPPORT, "Invalid address family");
}
- status = getSyscallInstance().setsockopt(Fd(socket), sockLayer, sockOpt, policy);
+ status = getSyscallInstance().setsockopt(Fd(socketFd), sockLayer, sockOpt, policy);
if (!isOk(status)) {
ALOGE("Error setting socket option for XFRM! (%s)", toString(status).c_str());
}
@@ -763,11 +764,11 @@
return status;
}
-netdutils::Status
-XfrmController::ipSecRemoveTransportModeTransform(const android::base::unique_fd& socket) {
+netdutils::Status XfrmController::ipSecRemoveTransportModeTransform(int socketFd) {
ALOGD("XfrmController::%s, line=%d", __FUNCTION__, __LINE__);
- StatusOr<sockaddr_storage> ret = getSyscallInstance().getsockname<sockaddr_storage>(Fd(socket));
+ StatusOr<sockaddr_storage> ret =
+ getSyscallInstance().getsockname<sockaddr_storage>(Fd(socketFd));
if (!isOk(ret)) {
ALOGE("Failed to get socket info in %s! (%s)", __FUNCTION__, toString(ret).c_str());
return ret;
@@ -790,7 +791,7 @@
// Kernel will delete the security policy on this socket for both direction
// if optval is set to NULL and optlen is set to 0.
netdutils::Status status =
- getSyscallInstance().setsockopt(Fd(socket), sockLayer, sockOpt, nullptr, 0);
+ getSyscallInstance().setsockopt(Fd(socketFd), sockLayer, sockOpt, nullptr, 0);
if (!isOk(status)) {
ALOGE("Error removing socket option for XFRM! (%s)", toString(status).c_str());
}