In particular this moves NetworkCapabilies#
appendStringRepresentationOfBitMaskToStringBuilder to this
class. It also moves some other NetworkCapabilitiesUtils
methods that are better homed in this new class.
Test: new test in this patch
Change-Id: I16374d7ca1da92052bb814bde796602d62f5c42e
This re-submit aosp/1387135 but define TYPE_CNAME locally to
prevent from using non-finalize API.
Bug: 139774492
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.DnsPacketUtilsTest
Change-Id: Ib2e98292be994ca09845c6857b8884f9bcdaba80
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.
(apparently this field is never accessed, as the test only looks at family)
Bug: 245472520
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I879c1637a87587b7bc1c13013ea9c5e655c141eb
Revert "[ST02.1] Add TYPE_CNAME constant to DnsResolver"
Revert submission 1387135-st02
Reason for revert: Usage of TYPE_CNAME in a library shared among
modules does not interact well with current module release process
Reverted Changes:
Ib5616c65c:[ST02.2] Use the getters of DnsHeader
I5e58f99b0:[ST02.1] Add TYPE_CNAME constant to DnsResolver
I0c1547cbc:[ST02] Add methods for synthesizing DNS packets
Change-Id: I9f8de47c9ba9fb4db7cf3695966f222f68a9a290
Upcoming CL will modify StructInetDiagSockId.
So, as a preparation, this CL adds test for existing behavior of
StructInetDiagSockId.
Bug: 217624062
Test: atest NetworkStaticLibTests
Change-Id: I6ef475bec050ba2689a8df6182be36a6fccd9bfb
This is useful as an array version of Collections.indexOfSubList().
Bug: 242630963
Test: atest NetworkStaticLibTests
Change-Id: I36724791ceece1348826a51cb2a975e169dfecc6
EthernetTetheringTest has parseMapKeyValue that decodes the string
encoded by BpfDump#toBase64EncodedString
Upcoming CL also wants to decode the encoded string.
So this CL renames parseMapKeyValue to fromBase64EncodedString and moves
to BpfDump with refactoring
Bug: 217624062
Test: atest NetworkStaticLibTests
Change-Id: I6ec302aaaa3e8779119cf153567cb032828f5daf
This is needed by ConnectivityServiceTest, refer to the
counter part CL in the module git.
This CL also fix guarded by annotation and remove the
increment/decrement method with count methods, which
is not very useful.
Test: TH
Bug: 235771502
Change-Id: Iaab681bf456e14afb4c6ddf700eb3308abead35f
Move base64 related bpf map function and constant from BpfCoordinator.
This is preparation for testing BPF map in ClatCoordinator.
Test: atest NetworkStaticLibTests
Change-Id: I3a23393abe5b108cdb8d621e99b74fd20847474e
Add a method to check if the current kernel version is at least from a
given version.
Bug: 236783925
Test: atest com.android.testutils.DeviceInfoUtilsTest --iterations
Change-Id: If0509b8ccad895c31d9447fee06789540002f666
Throwable could be used as a type argument to catch(), but it would
possibly never be caught, because the method only catches Exception.
Notably, junit assertions fail with AssertionError, which is not a
subclass of Exception. Due to that, tests or utilities like
DeviceConfigRule that have failing assertions in catch() would not
run the subsequent cleanup steps.
Bug: 210377950
Test: atest CleanupTest
Change-Id: I54e2922cb466f077ba4d219f8c3c6f885316296c
Add a class Version and string helper for handling a three-part
kernel version number.
Test: atest com.android.testutils.DeviceInfoUtilsTest
Bug: 232332847
Change-Id: I0f229e935bd8332ef2ef93fc910a576df9c054ae
Ipv6 payload length doesn't include header length.
rfc8200 section 3
https://tools.ietf.org/html/rfc8200
Payload Length 16-bit unsigned integer. Length of the IPv6
payload, i.e., the rest of the packet
following this IPv6 header, in octets.
Bug: 215655463
Test: atest NetworkStaticLibTests
Change-Id: Ifdc871125b0fe2eb3a8909b8b0723a62dbe44bcf
NetlinkEvent#parse relies on message-specific classes to parse
the payload of the message. If these classes do not consume the
entire message, parse does not advance to the end of the
message. This means that any code that loops over a ByteBuffer
parsing messages one at a time (e.g., NetlinkMonitor) will think
that there is still a message left to parse, and will attempt
to parse the remainder of the message as a new netlink message.
This is obviously incorrect for any buffer that contains more
than one netlink message.
Bug: 163492391
Test: existing unit tests
Change-Id: Ifdb9748068857f75ca00c58f0c40f19809aae5c9
Currently the netlink parsing code doesn't advance to the end of message
if it doesn't consume the entire message, that results in the remaining
attributes will be considered as a new netlink message, parsing the
attributes will fail and return null. Have a testcase to verify this case.
Bug: 163492391
Test: atest NetworkStaticLibsTests
Change-Id: I2719cd917f9932d5e77002e615845076784139a2
Support IPv6 packet builder and verify with UDP packet unit test.
Bug: 215655463
Test: atest NetworkStaticLibTests
Change-Id: I5edf0ffbc9b37ecf0e0a6da0dc7d04716fc4c38c
The class keeps track of the counters under different uid,
fire exception if the counter exceeded the specified maximum
value.
This is reimplemented and generalized based on the one
inside ConnectivityService.
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.PerUidCounterTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.PerUidCounterTest
Bug: 229103088
Change-Id: I7dfb16342e3ca4eab45bb40f2e1355981e04b44b
Change #selectBestRoute to account for non-unicast routes.
Method is used to detect if the address is reachable and via which
gateway. From that point of view, address being best matched by
a non-unicast route is equivalent to the address not being matched by
any route at all.
Method's implementation is adjusted to reflect the above logic. This
allows to avoid changing method's usages.
Bug: 186082280
Test: atest NetworkStaticLibTests:NetUtilsTest
Change-Id: I03f19d611fd8c7019cf13062bbeb1662d41402f4
Thankfully this is not actually a security vulnerability, because
the sign bit just gets set, and the conversion to long performs
sign extension. Still, it would break when adding one with 32.
To avoid repeats of this same mistake, convert the creation of
masks to using a function in a way that makes it impossible.
Test: new test for this in NetworkCapabilitiesUtilsTest
Change-Id: Iadbbca6b09b02d98e45a43984f7749e1a795ce02