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

Commit dae6f710 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Add a hasMacAddress member to InterfaceParams. am: 32336c98 am: 0dde2776

Change-Id: I3e82e2b4590f7f0dbfd19a3bed9bd6e546b86da1
parents 2988b2a1 0dde2776
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import java.net.SocketException;
public class InterfaceParams {
    public final String name;
    public final int index;
    public final boolean hasMacAddress;
    public final MacAddress macAddr;
    public final int defaultMtu;

@@ -69,7 +70,8 @@ public class InterfaceParams {
        checkArgument((index > 0), "invalid interface index");
        this.name = name;
        this.index = index;
        this.macAddr = (macAddr != null) ? macAddr : MacAddress.fromBytes(new byte[] {
        this.hasMacAddress = (macAddr != null);
        this.macAddr = hasMacAddress ? macAddr : MacAddress.fromBytes(new byte[] {
                0x02, 0x00, 0x00, 0x00, 0x00, 0x00 });
        this.defaultMtu = (defaultMtu > IPV6_MIN_MTU) ? defaultMtu : IPV6_MIN_MTU;
    }
+19 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import static junit.framework.Assert.fail;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -919,6 +920,24 @@ public class IpClientIntegrationTest {
        }
    }

    @Test
    public void testInterfaceParams() throws Exception {
        InterfaceParams params = InterfaceParams.getByName(mIfaceName);
        assertNotNull(params);
        assertEquals(mIfaceName, params.name);
        assertTrue(params.index > 0);
        assertNotNull(params.macAddr);
        assertTrue(params.hasMacAddress);

        // Sanity check.
        params = InterfaceParams.getByName("lo");
        assertNotNull(params);
        assertEquals("lo", params.name);
        assertTrue(params.index > 0);
        assertNotNull(params.macAddr);
        assertFalse(params.hasMacAddress);
    }

    @Test
    public void testDhcpInit() throws Exception {
        startIpClientProvisioning(false /* isDhcpLeaseCacheEnabled */,
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.net.util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -49,6 +50,7 @@ public class InterfaceParamsTest {
        assertEquals("lo", ifParams.name);
        assertTrue(ifParams.index > 0);
        assertNotNull(ifParams.macAddr);
        assertFalse(ifParams.hasMacAddress);
        assertTrue(ifParams.defaultMtu >= NetworkStackConstants.ETHER_MTU);
    }
}