Merge "Rename method connectSocketToNetlink to connectToKernel" into main
This commit is contained in:
@@ -900,7 +900,7 @@ public class AutomaticOnOffKeepaliveTracker {
|
||||
public FileDescriptor createConnectedNetlinkSocket()
|
||||
throws ErrnoException, SocketException {
|
||||
final FileDescriptor fd = NetlinkUtils.createNetLinkInetDiagSocket();
|
||||
NetlinkUtils.connectSocketToNetlink(fd);
|
||||
NetlinkUtils.connectToKernel(fd);
|
||||
Os.setsockoptTimeval(fd, SOL_SOCKET, SO_SNDTIMEO,
|
||||
StructTimeval.fromMillis(IO_TIMEOUT_MS));
|
||||
return fd;
|
||||
|
||||
@@ -109,7 +109,7 @@ public class NetlinkMonitor extends PacketReader {
|
||||
}
|
||||
}
|
||||
Os.bind(fd, makeNetlinkSocketAddress(0, mBindGroups));
|
||||
NetlinkUtils.connectSocketToNetlink(fd);
|
||||
NetlinkUtils.connectToKernel(fd);
|
||||
|
||||
if (DBG) {
|
||||
final SocketAddress nlAddr = Os.getsockname(fd);
|
||||
|
||||
@@ -33,7 +33,7 @@ import static com.android.net.module.util.netlink.NetlinkConstants.stringForProt
|
||||
import static com.android.net.module.util.netlink.NetlinkUtils.DEFAULT_RECV_BUFSIZE;
|
||||
import static com.android.net.module.util.netlink.NetlinkUtils.IO_TIMEOUT_MS;
|
||||
import static com.android.net.module.util.netlink.NetlinkUtils.TCP_ALIVE_STATE_FILTER;
|
||||
import static com.android.net.module.util.netlink.NetlinkUtils.connectSocketToNetlink;
|
||||
import static com.android.net.module.util.netlink.NetlinkUtils.connectToKernel;
|
||||
import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_DUMP;
|
||||
import static com.android.net.module.util.netlink.StructNlMsgHdr.NLM_F_REQUEST;
|
||||
|
||||
@@ -266,7 +266,7 @@ public class InetDiagMessage extends NetlinkMessage {
|
||||
FileDescriptor fd = null;
|
||||
try {
|
||||
fd = NetlinkUtils.netlinkSocketForProto(NETLINK_INET_DIAG);
|
||||
NetlinkUtils.connectSocketToNetlink(fd);
|
||||
connectToKernel(fd);
|
||||
uid = lookupUid(protocol, local, remote, fd);
|
||||
} catch (ErrnoException | SocketException | IllegalArgumentException
|
||||
| InterruptedIOException e) {
|
||||
@@ -426,8 +426,8 @@ public class InetDiagMessage extends NetlinkMessage {
|
||||
try {
|
||||
dumpFd = NetlinkUtils.createNetLinkInetDiagSocket();
|
||||
destroyFd = NetlinkUtils.createNetLinkInetDiagSocket();
|
||||
connectSocketToNetlink(dumpFd);
|
||||
connectSocketToNetlink(destroyFd);
|
||||
connectToKernel(dumpFd);
|
||||
connectToKernel(destroyFd);
|
||||
|
||||
for (int family : List.of(AF_INET, AF_INET6)) {
|
||||
try {
|
||||
|
||||
@@ -153,7 +153,7 @@ public class NetlinkUtils {
|
||||
final FileDescriptor fd = netlinkSocketForProto(nlProto);
|
||||
|
||||
try {
|
||||
connectSocketToNetlink(fd);
|
||||
connectToKernel(fd);
|
||||
sendMessage(fd, msg, 0, msg.length, IO_TIMEOUT_MS);
|
||||
receiveNetlinkAck(fd);
|
||||
} catch (InterruptedIOException e) {
|
||||
@@ -244,7 +244,7 @@ public class NetlinkUtils {
|
||||
* @throws ErrnoException if the {@code fd} could not connect to kernel successfully
|
||||
* @throws SocketException if there is an error accessing a socket.
|
||||
*/
|
||||
public static void connectSocketToNetlink(FileDescriptor fd)
|
||||
public static void connectToKernel(@NonNull FileDescriptor fd)
|
||||
throws ErrnoException, SocketException {
|
||||
Os.connect(fd, makeNetlinkSocketAddress(0, 0));
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class NetlinkUtilsTest {
|
||||
final FileDescriptor fd = NetlinkUtils.netlinkSocketForProto(NETLINK_ROUTE);
|
||||
assertNotNull(fd);
|
||||
|
||||
NetlinkUtils.connectSocketToNetlink(fd);
|
||||
NetlinkUtils.connectToKernel(fd);
|
||||
|
||||
final NetlinkSocketAddress localAddr = (NetlinkSocketAddress) Os.getsockname(fd);
|
||||
assertNotNull(localAddr);
|
||||
@@ -153,7 +153,7 @@ public class NetlinkUtilsTest {
|
||||
final FileDescriptor fd = NetlinkUtils.netlinkSocketForProto(NETLINK_ROUTE);
|
||||
assertNotNull(fd);
|
||||
|
||||
NetlinkUtils.connectSocketToNetlink(fd);
|
||||
NetlinkUtils.connectToKernel(fd);
|
||||
|
||||
final NetlinkSocketAddress localAddr = (NetlinkSocketAddress) Os.getsockname(fd);
|
||||
assertNotNull(localAddr);
|
||||
|
||||
Reference in New Issue
Block a user