Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c03f2bf3 authored by Chiachang Wang's avatar Chiachang Wang Committed by android-build-merger
Browse files

Merge "Update type in RoutingAttribute" am: 5ea7a0be am: 242ab140

am: 43dd490b

Change-Id: Idc81bcf6fa900373ba2607a53a390e7b90d81574
parents 1446afad 43dd490b
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@ package com.android.networkstack.netlink;


import static android.net.netlink.InetDiagMessage.InetDiagReqV2;
import static android.net.netlink.InetDiagMessage.InetDiagReqV2;
import static android.net.netlink.NetlinkConstants.INET_DIAG_MEMINFO;
import static android.net.netlink.NetlinkConstants.INET_DIAG_MEMINFO;
import static android.net.netlink.NetlinkConstants.NLA_ALIGNTO;
import static android.net.netlink.NetlinkConstants.NLMSG_DONE;
import static android.net.netlink.NetlinkConstants.NLMSG_DONE;
import static android.net.netlink.NetlinkConstants.SOCKDIAG_MSG_HEADER_SIZE;
import static android.net.netlink.NetlinkConstants.SOCKDIAG_MSG_HEADER_SIZE;
import static android.net.netlink.NetlinkConstants.SOCK_DIAG_BY_FAMILY;
import static android.net.netlink.NetlinkConstants.SOCK_DIAG_BY_FAMILY;
@@ -40,6 +39,7 @@ import static android.system.OsConstants.SOL_SOCKET;
import static android.system.OsConstants.SO_SNDTIMEO;
import static android.system.OsConstants.SO_SNDTIMEO;


import android.content.Context;
import android.content.Context;
import android.net.netlink.NetlinkConstants;
import android.net.netlink.NetlinkSocket;
import android.net.netlink.NetlinkSocket;
import android.net.netlink.StructInetDiagMsg;
import android.net.netlink.StructInetDiagMsg;
import android.net.netlink.StructNlMsgHdr;
import android.net.netlink.StructNlMsgHdr;
@@ -252,7 +252,7 @@ public class TcpSocketTracker {
        while (bytes.position() < remainingDataSize) {
        while (bytes.position() < remainingDataSize) {
            final RoutingAttribute rtattr =
            final RoutingAttribute rtattr =
                    new RoutingAttribute(bytes.getShort(), bytes.getShort());
                    new RoutingAttribute(bytes.getShort(), bytes.getShort());
            final int dataLen = rtattr.getDataLength();
            final short dataLen = rtattr.getDataLength();
            if (rtattr.rtaType == RoutingAttribute.INET_DIAG_INFO) {
            if (rtattr.rtaType == RoutingAttribute.INET_DIAG_INFO) {
                tcpInfo = TcpInfo.parse(bytes, dataLen);
                tcpInfo = TcpInfo.parse(bytes, dataLen);
            } else if (rtattr.rtaType == RoutingAttribute.INET_DIAG_MARK) {
            } else if (rtattr.rtaType == RoutingAttribute.INET_DIAG_MARK) {
@@ -358,7 +358,7 @@ public class TcpSocketTracker {
     * @param len the remaining length to skip.
     * @param len the remaining length to skip.
     */
     */
    private void skipRemainingAttributesBytesAligned(@NonNull final ByteBuffer buffer,
    private void skipRemainingAttributesBytesAligned(@NonNull final ByteBuffer buffer,
            final int len) {
            final short len) {
        // Data in {@Code RoutingAttribute} is followed after header with size {@Code NLA_ALIGNTO}
        // Data in {@Code RoutingAttribute} is followed after header with size {@Code NLA_ALIGNTO}
        // bytes long for each block. Next attribute will start after the padding bytes if any.
        // bytes long for each block. Next attribute will start after the padding bytes if any.
        // If all remaining bytes after header are valid in a data block, next attr will just start
        // If all remaining bytes after header are valid in a data block, next attr will just start
@@ -372,7 +372,7 @@ public class TcpSocketTracker {
        // [HEADER(L=5)][   4-Bytes DATA      ][ HEADER(L=8) ][4 bytes DATA][Next attr]
        // [HEADER(L=5)][   4-Bytes DATA      ][ HEADER(L=8) ][4 bytes DATA][Next attr]
        // [ 5 valid bytes ][3 padding bytes  ][      8 valid bytes        ]   ...
        // [ 5 valid bytes ][3 padding bytes  ][      8 valid bytes        ]   ...
        final int cur = buffer.position();
        final int cur = buffer.position();
        buffer.position(cur + ((len + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1)));
        buffer.position(cur + NetlinkConstants.alignedLengthOf(len));
    }
    }


    private void log(final String str) {
    private void log(final String str) {
@@ -401,8 +401,8 @@ public class TcpSocketTracker {
            rtaLen = len;
            rtaLen = len;
            rtaType = type;
            rtaType = type;
        }
        }
        public int getDataLength() {
        public short getDataLength() {
            return rtaLen - HEADER_LENGTH;
            return (short) (rtaLen - HEADER_LENGTH);
        }
        }
    }
    }