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

Commit 16a9284d authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN Committed by Gerrit Code Review
Browse files

Merge "Fix SocketUtils API"

parents e0ef527d 8709cc6b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -475,7 +475,7 @@ public class ApfFilter {
            socket = Os.socket(AF_PACKET, SOCK_RAW, ETH_P_IPV6);
            SocketAddress addr = makePacketSocketAddress(
                    (short) ETH_P_IPV6, mInterfaceParams.index);
            SocketUtils.bindSocket(socket, addr);
            Os.bind(socket, addr);
            SocketUtils.attachRaFilter(socket, mApfCapabilities.apfPacketFormat);
        } catch(SocketException|ErrnoException e) {
            Log.e(TAG, "Error starting filter", e);
+2 −3
Original line number Diff line number Diff line
@@ -317,7 +317,7 @@ public class DhcpClient extends StateMachine {
        try {
            mPacketSock = Os.socket(AF_PACKET, SOCK_RAW, ETH_P_IP);
            SocketAddress addr = makePacketSocketAddress((short) ETH_P_IP, mIface.index);
            SocketUtils.bindSocket(mPacketSock, addr);
            Os.bind(mPacketSock, addr);
            SocketUtils.attachDhcpFilter(mPacketSock);
        } catch(SocketException|ErrnoException e) {
            Log.e(TAG, "Error creating packet socket", e);
@@ -412,8 +412,7 @@ public class DhcpClient extends StateMachine {
        try {
            if (encap == DhcpPacket.ENCAP_L2) {
                if (DBG) Log.d(TAG, "Broadcasting " + description);
                SocketUtils.sendTo(
                        mPacketSock, buf.array(), 0, buf.limit(), 0, mInterfaceBroadcastAddr);
                Os.sendto(mPacketSock, buf.array(), 0, buf.limit(), 0, mInterfaceBroadcastAddr);
            } else if (encap == DhcpPacket.ENCAP_BOOTP && to.equals(INADDR_BROADCAST)) {
                if (DBG) Log.d(TAG, "Broadcasting " + description);
                // We only send L3-encapped broadcasts in DhcpRebindingState,
+1 −2
Original line number Diff line number Diff line
@@ -104,8 +104,7 @@ public class ConnectivityPacketTracker {
            try {
                s = Os.socket(AF_PACKET, SOCK_RAW | SOCK_NONBLOCK, 0);
                SocketUtils.attachControlPacketFilter(s, ARPHRD_ETHER);
                SocketUtils.bindSocket(
                        s, makePacketSocketAddress((short) ETH_P_ALL, mInterface.index));
                Os.bind(s, makePacketSocketAddress((short) ETH_P_ALL, mInterface.index));
            } catch (ErrnoException | IOException e) {
                logError("Failed to create packet tracking socket: ", e);
                closeFd(s);
+1 −2
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import android.net.netlink.StructNdMsg;
import android.net.util.NetworkStackUtils;
import android.net.util.PacketReader;
import android.net.util.SharedLog;
import android.net.util.SocketUtils;
import android.os.Handler;
import android.os.SystemClock;
import android.system.ErrnoException;
@@ -150,7 +149,7 @@ public class IpNeighborMonitor extends PacketReader {

        try {
            fd = Os.socket(AF_NETLINK, SOCK_DGRAM | SOCK_NONBLOCK, NETLINK_ROUTE);
            SocketUtils.bindSocket(fd, makeNetlinkSocketAddress(0, OsConstants.RTMGRP_NEIGH));
            Os.bind(fd, makeNetlinkSocketAddress(0, OsConstants.RTMGRP_NEIGH));
            NetlinkSocket.connectToKernel(fd);

            if (VDBG) {