| diff --git a/system/netd/client/NetdClient.cpp b/system/netd/client/NetdClient.cpp |
| index 392b0af..36be012 100644 |
| --- a/system/netd/client/NetdClient.cpp |
| +++ b/system/netd/client/NetdClient.cpp |
| @@ -19,9 +19,15 @@ |
| #include <errno.h> |
| #include <sys/socket.h> |
| #include <unistd.h> |
| +#include <string.h> |
| |
| #include <atomic> |
| |
| +#define LOG_TAG "NetdClient" |
| +#include "log/log.h" |
| + |
| + |
| + |
| #include "Fwmark.h" |
| #include "FwmarkClient.h" |
| #include "FwmarkCommand.h" |
| @@ -181,11 +187,31 @@ extern "C" unsigned getNetworkForProcess() { |
| } |
| |
| extern "C" int setNetworkForSocket(unsigned netId, int socketFd) { |
| + int ret = 0; |
| + unsigned int get_mark = 0; |
| + |
| + |
| if (socketFd < 0) { |
| return -EBADF; |
| } |
| + #if 0 |
| FwmarkCommand command = {FwmarkCommand::SELECT_NETWORK, netId, 0}; |
| return FwmarkClient().send(&command, socketFd); |
| + #endif |
| + |
| + socklen_t fwmarkLen = sizeof(get_mark); |
| + printf("[setNetworkForSocket] netId[%d] socketFd[%d]", netId, socketFd); |
| + |
| + if (setsockopt(socketFd, SOL_SOCKET, SO_MARK, &netId, |
| + sizeof(netId)) == -1) { |
| + ALOGE("setNetworkForSocket SO_MARK(%s)", strerror(errno)); |
| + return -errno; |
| + } |
| + |
| + ret = getsockopt(socketFd, SOL_SOCKET, SO_MARK, &get_mark, &fwmarkLen); |
| + ALOGE("setNetworkForSocket get_mark(%d)", get_mark); |
| + |
| + return ret; |
| } |
| |
| extern "C" int setNetworkForProcess(unsigned netId) { |