ETHER_BROADCAST is used to fill the destination mac address of ether
header, it was defined in the DhcpPacket.java, move it to a common
place for other usecases.
Also have a link mtu constant(default value is 1500 bytes), irrelevant
to specific link-layer type.
Bug: 175830307
Test: m
Change-Id: I422d284cd8fa943bd745ad29229a54515135a3c4
This fixes failures in CtsNetTestCases, where
TestableNetworkCallback.TAG cannot be used because
it uses kotlin-reflect.
Change-Id: I7e76fe224b1098c967665275eac24fcac08fca23
Fixes: 176047509
Test: atest CtsNetTestCasesLatestSdk
There doesn't seem to be a way to get any code at all
to run in a generic way on the thread that will execute
a test in android JUnit. JUnit can do it, but the android
harness imposes a thread hop.
This is inconvenent with ReadHead, because ReadHead can't
be used in multithread for semantic reasons : it would
make no sense at all. ReadHead enforces this today in a
relatively strong fashion.
But technically, the only guarantee that is needed is that
poll() is executed only on one thread in slabs of time
defined between a read barrier and a write barrier, where
the write barrier of the previous slab happen-before the
read barrier of the next slab. This in generally speaking
a bit difficult to achieve, but the tests run satisfy this
condition by starting the thread after executing the
@Before methods and joining it before executing the @After
methods. So in fact, it's safe to use ReadHead during
the befores and afters, if a bit uncomfortable, as long
as only one thread uses it during the before, one thread
during the test, and one thread during the afters.
This patch relaxes the enforcement on ReadHead to accept
the usage above. If any slab of time contains usage of
poll() on multiple threads, this will instead crash with
ConcurrentModificationException in almost all cases. It's
no longer possible to detect every possible misuse of
poll() under these conditions, but with this code it's
going to be very unlikely at each test run that the code
is incorrect and still doesn't crash, so incorrect use
should still cause at least very severe flakiness.
The main drawback, aside from the very slight performance
penalty, is that some use can be accidentally correct and
this code will now accept it. So it's possible that code
that is only accidentally correct is accepted, and a
seemingly unrelated change later breaks that correctness,
causing seemingly unrelated tests to fail.
Still, this is going to be an improvement in usability
of ReadHead. We'll no longer need to have lazy creation
of it, and it will be possible to check remaining events
after a tests runs.
Test: FrameworksNetTests NetworkStackTests
Change-Id: If87eef1686b235e53cb444a32f9985b4c2a0a901
This is not super useful because it cannot identify different
NetworkCallback objects from each other, but I've found it to be
better than nothing.
Test: manual
Change-Id: Ib402161f361c0f9fb68701bf171cbc99f598dafd
Split the original U64/UBE64 into two groups: U63/UBE63 which could be
represented by long primitive directly and U64/UBE64 which should be
represented by BigInteger class.
Also fix the endianness-related issue to support both of big-endian or
little-endian input ByteBuffer, and writeToBytes API outputs the bytes
array in appropriate order then.
Bug: 163492391
Test: atest android.net.util.StructTest --rerun-until-failure
Change-Id: Ie9c07fac6dcfceb8efdf1d6b56ce6ff1e845f477
The constants are also useful for bootclasspath code, for example in
Ikev2VpnProfile.
Bug: 174436414
Test: atest FrameworksNetTests NetworkStackTests NetworkStaticLibTests
Change-Id: I34458fe6568a73533f956f86ed7bb50d45aa7d7e
The packages/modules/Connectivity project contains module code that can
depend on net-utils-device-common or net-utils-framework-common.
Bug: 171540887
Test: m
Change-Id: Ie754e3f55d78aabff4cef2da3a2a94a1204bd5e5
per b/167962976#comment10, following project directories are being
moved under platform/packages/modules/Connectivity/...
cts/test/net --> packages/modules/Connectivity/tests/cts/net
cts/tests/tests/tethering -> packages/modules/Connectivity/tests/cts/tethering
cts/hostsidetests/net -> packages/modules/Connectivity/tests/cts/hostside
BUG: 167962976
Test: TH & Local Build
Exempt-From-Owner-Approval: PS.1 +2d by Lorenzo. fixing tab (+2 not sticky)
Change-Id: I4e13620ea16b74712a917737607bc3ed38c11cd9
jarjar should be applied on the final artifact (android_test,
android_app, java_library that goes into an apex), not on any
intermediate (android_library etc).
Bug: 171670016
Test: atest NetworkStaticTests
atest TetheringCoverageTests
atest NetworkCoverageTests
Change-Id: I86a15133112c555e08275efbde99e68315aa6bc2
The class only contains constants that should be shareable between
different modules and tests.
This rolls forward the previous change that broke
FrameworksTelephonyTests, because adding net-utils-framework-common to
net-utils-device-common caused the tests to contain a jarjared version
of net-utils-framework-common inherited from telephony code, and a
non-jarjared version inherited from net-utils-device-common. This
resulted in duplicate classes after applying jarjar to the test, which
is not supported (the build system can deduplicate if two libs include
the same class, but jarjar fails if a class after rename conflicts with
an existing class).
This new change removes the dependency on net-utils-framework-common
from net-utils-device-common.
Bug: 168868607
Test: m
Change-Id: I34bad7ec79ef0fd03e5e40b643f0d85d686c53ec
Revert "Use new test utilities from frameworks/libs/net"
Revert submission 1440811-iputils_constants_move
Reason for revert: Likely broke build in b/170438226
Reverted Changes:
Ic382d24e7:Move NetworkStackConstants to frameworks/libs/net
I0d938e296:Use new test utilities from frameworks/libs/net
Change-Id: I5e41daa85af39cfab4261ddf790c2008b2630c15
The utility is similar to the existing udpChecksum and tcpChecksum
methods, but for ICMPv6 messages.
Bug: 168868607
Test: m, followup tests using this utility
Change-Id: I41f478af89260a0225f597e672bd798932f1b5eb
The class only contains constants that should be shareable between
different modules and tests.
Bug: 168868607
Test: m
Change-Id: Ic382d24e73697d85d29fa226692bd0d64ffa0f1f
The utility classes are useful for mainline modules and their tests, for
example IpClientIntegrationTest.
Bug: 168868607
Test: m && atest NetworkStackCoverageTests
Change-Id: Ie3eea7731fa45cd58cd4acf8249da68ff3eb6a70
Setting autoStart to false allows tests to manually start the
TapPacketReader rule, either via method call (allowing callers to
specify their own Handler) or an annotation.
Bug: 168868607
Test: atest NetworkStackIntegrationTests using autoStart = false
Change-Id: Ic295d659250795c45181dc3c0ac0aaacba854f0b
This test rule allows tests to easily create a tap interface, a
TapPacketReader on it, and tear them down after the test.
Bug: 168868607
Test: atest NetworkStackIntegrationTests
Change-Id: Ibc167f5c9a8a1b295e8f6c8384a55a1e3410fcdc
Add a startAsyncForTest method to attempt to start the TapPacketReader
on its handler thread. The method will not report failures to start
(especially failures to create the socket), so it is only added in
TapPacketReader for test code, and not FdEventsReader which would be in
production code.
Rename popPacket to poll, keeping the old version as deprecated
for compatibility. "pop" normally refers to removing a packet from the
top of a LIFO stack, so it is not appropriate naming here.
Test: m
Bug: 168868607
Change-Id: I19184aaca018165856d1d5e5d24b976ae75d1664
Add utilities allowing to run lambdas with shell permissions, in kotlin
and java tests.
Bug: 168868607
Test: m
Change-Id: Iaab38d498338b9e95d263789119cd0813983087d
eventuallyExpect is inline function with reified type which
is not accessible from java. Add an open overloaded method to
support the usage.
Bug: 162323152
Test: atest CtsNetTestCasesLatestSdk:ConnectivityManagerTest
Test: atest TestableNetworkCallbackTest
Change-Id: Ifd2256e08d7e5d092d57594350ac8ed1c1727afb
Add an ArpResponder based on a generic PacketResponder class, and a
TestHttpServer based on NanoHttpd.
Test: tests based on these utilities
Bug: 160617623
Bug: 160656765
Change-Id: I50b872a8b23e8df997e8f62f0adc7c0256c4d74d
Add packet filters that are useful for filtering / testing DNS queries
and ARP requests.
This change is a prerequisite for tests verifying DNS and validation
metrics.
Test: tests using these utilities
Bug: 160617623
Bug: 160656765
Change-Id: I4216f4ec60d1a427f60fad6eb8017e36b082665f