(there's bpf related stuff in here)
Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7fcc19cdf48e468dfcbe5ee34f7bc07e261756b8
Make HexDump as a part of module-shared library, being able to share
among of modules. As the first step, moving it to frameworks/libs/net
and be able to use inside net-utils-device-common.
Bug: 177622619
Test: m
Change-Id: I640f343dc6c334b7b4d44960cd043e32a989898d
For the same reason as aosp/1549479, the old method
needs to call the new one. It's not enough that they have
the same implementation ; when NF calls the old one, it
needs to indeed call the overridden new version.
Test: TH
Change-Id: I5e8700fc7455317da382f2328e3f548b3392ca41
This isn't new code, this is basically copied verbatim from
//system/bpf/libbpf_android/include/bpf/BpfUtils.h
Test: atest BpfMapTest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I80523c9ee0c1e4431f3192eb409ad68c737390a6
The existing implementations override the function with the
int, so the default impl of the function with the int has
to call the new one, not the other way around. Otherwise,
when implementations are migrated to overriding the new one
the old code continues to call the function with the int
and that wouldn't work as expected if it didn't call the
newly overridden method.
Test: TH
Change-Id: Ic31cec6481781e0185a0ba150be52390597737e7
Lots of methods are needed to check if the caller has any of
permission. So add PermissionUtils to support
enforceAnyPermissionOf() and checkAnyPermissionOf() usage.
Bug: 177187957
Test: buid, flash, boot to home.
Change-Id: Ie282989f1e73b614093feff28c497af6573a9ef8
Also move CollectionUtils which is a dependency.
NetworkCapabilitiesUtils is needed in BatteryStatsImpl, which is in
frameworks/base/core, so it uses the framework-common library.
The current framework-common target cannot use androidx annotations due
to users of this filegroup. This is being addressed in another change;
use android.annotation annotations in the meantime.
Bug: 174436414
Test: m
Change-Id: Ie188572a6db7c1bea37550a3410d7d828409a902
Adjusting visibility to accomodate migration of
frameworks/opt/net/wifi to packages/modules/Wifi.
BUG: 137323948
Test: TH
Change-Id: Iee3f2dc6fc5f3262fa9e81626a3e15a3226e4ab7
Querying the APK version can be relatively expensive, so cache it with a
static. Package version cannot change without restarting the process.
Also add some testing for flags being equal to the min/max values.
Bug: 17454103
Test: atest NetworkStaticLibTests
Change-Id: I18c298beb843e0a9f76162d353623bb15ab155f1
While networks can have multiple transports, users generally think of
them as "wifi", "mobile data", "vpn" and expect them to be classified
as such in UI such as settings.
Add a getDisplayTransport utility that returns which transport should
be used for UI display, from a list of transports of a network.
Bug: 174436414
Test: atest NetworkStaticLibTests
Change-Id: Iaefb47bcaa2f6ce2e7a2ae5011c340154009ac3c
Split DeviceConfig and collections-related utilities to CollectionUtils
and DeviceConfigUtils in frameworks/libs/net.
Also add implementations for contains(array, value), to avoid usage of
internal non-API utils.
The original tests are based on mockito-extended, so also add to
NetworkStackTests as a dependency. This also requires setting the test
app as debuggable in its manifest.
Bug: 17454103
Test: atest NetworkStaticLibTests
Change-Id: Ie9bed66a08b7370ebe50d0a7240b788f8b31aa77
MacAddress class is helpful to represent a 48-bits long MAC Address,
we have to use 6-bytes array to interpret a MAC Address without a
specific annotation type. To better parse the MAC Address appeared
in the ether header, link-layer address option or Bpf class, it's
worth supporting this specific type.
Bug: 163492391
Test: atest NetworkStaticLibTests
Change-Id: I1f716e5d4f38372fc5b7ee32e208d55a072c1e51
Add paths to visibility needed for tests.
Soong allows specifying paths w/o validation. Once the
migration is complete, we can remove the old path in
visibility rules.
BUG: 137323948
Test: TH
Merged-In: Id19c650246a8f3d55d7b6a874840a6eebcd9eb17
Change-Id: I68de6a67b978ed5a2e721adf41329af349076696
Exempt-From-Owner-Approval: Cleanup CL
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