Commit Graph

1615 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
5b9074cf7e Optionally use MdnsAdvertiser for advertising
Based on a flag, use MdnsAdvertiser for advertising instead of the
legacy mdnsresponder implementation.

Bug: 241738458
Test: atest NsdServiceTest
Change-Id: I2d5069097c11f2959e3792cac326d179a3116479
2023-01-18 23:23:43 +09:00
Paul Hu
b58deb706c New API to stop service resolution
Resolve service may take long time due to network issue or
using wrong service information, but users are not able to stop
it. They can only wait for the callback of resolveService to end,
which sometimes takes a long time. Thus, add the new API that
users can stop the service resolution.

Bug: 245369943
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I6b6183c8c73f8db981b9afa51fbc73bf886d9ed3
2023-01-18 10:10:25 +00:00
Paul Hu
38f5d4661b Merge "Implement service resolved callback" 2023-01-18 01:43:28 +00:00
Remi NGUYEN VAN
aa15a8ea5d Merge changes I69128db9,I13db22f8
* changes:
  Implement onServiceConflict
  Add replying to queries
2023-01-18 01:13:35 +00:00
Remi NGUYEN VAN
fe73104cc1 Merge "Factor out response decoding into MdnsPacket" 2023-01-18 01:12:58 +00:00
Paul Hu
f71485f351 Merge changes I298816ac,I3f41b4fe,Ibd782029
* changes:
  Implement service lost callback
  Implement service found callback
  Use MdnsDiscoveryManager for discovery
2023-01-17 15:51:54 +00:00
Paul Hu
75069ed47e Implement service resolved callback
Service resolved should be notified when receive the
onServiceFound callbacks from MdnsServiceBrowserListener

Bug: 254166302
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I681720065084bf3449c5b1ab44cd4ed6a659dcdb
2023-01-17 23:25:08 +08:00
Remi NGUYEN VAN
b1b7fab156 Implement onServiceConflict
Implement the onServiceConflict callback in MdnsAdvertiser, refactoring
the conflict detection to reuse it both in onServiceConflict (when a
conflict is detected on the network after add) and at service add time.

Bug: 241738458
Test: atest MdnsAdvertiserTest
Change-Id: I69128db936296bd2c5e90e9f00df19fd881e1748
2023-01-17 23:21:28 +09:00
Remi NGUYEN VAN
46676497eb Add replying to queries
MdnsInterfaceAdvertiser registers to receive incoming packets, and
sends replies to queries as built by MdnsRecordRepository.

Bug: 241738458
Test: atest
Change-Id: I13db22f8efc870b6e0747d105f6bc8f759910f81
2023-01-17 23:10:42 +09:00
Remi NGUYEN VAN
5fbaea55d8 Factor out response decoding into MdnsPacket
Factor out generic packet decoding into MdnsPacket, out from
MdnsResponseDecoder.

This allows reusing the same decoding code for replies, and other kinds
of MdnsPackets.

Bug: 241738458
Test: atest MdnsResponseDecoderTests MdnsPacketTest
Change-Id: I4380f80240ed5a367accfc1b0c595967ee475578
2023-01-17 23:00:34 +09:00
Paul Hu
319751a572 Implement service lost callback
Service lost should be notified when receive the
onServiceNameRemoved callbacks from
MdnsServiceBrowserListener.

Bug: 254166302
Test: atest FrameworksNetTests
Change-Id: I298816ac186efeda85cea4cd11f3beab6b341bc5
2023-01-17 21:26:26 +08:00
Chiachang Wang
c42f1adfd5 Merge "[DK1]Add TCP polling mechanism" 2023-01-17 13:04:04 +00:00
Paul Hu
019621e070 Implement service found callback
Service found should be notified when receives the
onServiceNameDiscovered callbacks from
MdnsServiceBrowserListener.

Bug: 254166302
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I3f41b4fe85cd85ad356fa764663187a88914412c
2023-01-17 20:07:22 +08:00
Paul Hu
23fa202478 Use MdnsDiscoveryManager for discovery
Register/Unregister the listener to/from MdnsDiscoveryManager
when discovery started/stopped.

Bug: 254166302
Test: atest FrameworksNetTests CtsNetTestsCases
Change-Id: Ibd782029826ac5856c608165928cd942e46dd9a4
2023-01-17 19:16:50 +08:00
Jean Chalard
76ee573dda Merge "Rename mXXXNetworkAgent to mXXXAgent" 2023-01-17 08:12:31 +00:00
Aaron Huang
a3ed25924e Merge "Remove dev recorder from NetworkStatsService" 2023-01-17 07:27:35 +00:00
Treehugger Robot
6366d7c2db Merge "Import CallbackEntries in ConnectivityServiceTest" 2023-01-17 07:24:53 +00:00
chiachangwang
6a9f0db983 [DK1]Add TCP polling mechanism
Add TCP polling mechanism in KeepaliveTracker to understand if
there are any TCP sockets in the target network. This is a
preparation commit for dynamically control keepalive based on
the existence of TCP sockets. This is non-functional now since
there is no caller to retrieve the information now.

Bug: 259000745
Test: atest FrameworksNetTests
Test: Manually test by creating TCP sockets on the target network
      in device and check if deisgn works.
Change-Id: I355ac340cad2fac618bb9d65fb1b1539ea644959
2023-01-17 07:24:48 +00:00
Paul Hu
1b81be6de6 Merge "Create the MdnsDiscoveryManager" 2023-01-17 07:05:13 +00:00
Chalard Jean
dda2fd4883 Rename mXXXNetworkAgent to mXXXAgent
In the context of ConnectivityServiceTest this is plenty
clear, so terser is better.

Test: ConnectivityServiceTest
Change-Id: Id20afc8a81a6c00c932ffae3b8dbc2919773d35b
2023-01-17 14:44:31 +09:00
Chalard Jean
cc231ceed2 Import CallbackEntries in ConnectivityServiceTest
This is not ambiguous so less verbose is a lot simpler

Test: ConnectivityServiceTest
Change-Id: I47cc689441a20fa5409268e133f9e5ca59216a5d
2023-01-17 14:44:29 +09:00
Remi NGUYEN VAN
fa94865739 Merge changes I3b1ad1be,Id4c2e610
* changes:
  Implement exit announcements
  Implement announcements on probing success
2023-01-17 01:36:05 +00:00
Paul Hu
4bd98ef68e Create the MdnsDiscoveryManager
Create the MdnsDiscoveryManager for mdns discovery and resolution
if the feature is enable.

Bug: 254166302
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I4d7591b50cb06f0efcc0dde9834b775c513cceff
2023-01-17 00:26:01 +08:00
Remi NGUYEN VAN
e4bd27f919 Implement exit announcements
Build ExitAnnouncementInfo in MdnsRecordRepository.exitService. Use a
separate class for AnnouncementInfo and ExitAnnouncementInfo, so
announcement callbacks can differentiate each case.

Bug: 241738458
Test: atest
Change-Id: I3b1ad1bef3dc1514479d7c789ef06b6a7de02e59
2023-01-16 19:20:36 +09:00
Remi NGUYEN VAN
bdc2d50c49 Implement announcements on probing success
Once probing succeeds, the advertiser sends announcements for its
records as per RFC6762 8.3.

Implement MdnsRecordRepository.onProbingSucceeded to return the
AnnouncementInfo which will be sent.

Bug: 241738458
Test: atest
Change-Id: Id4c2e610911fdf471a6d6ae08c2127fbf1530dc7
2023-01-16 17:33:54 +09:00
Aaron Huang
2500069488 Merge "Remove *_WILDCARD constants from NetworkTemplate" 2023-01-16 07:56:09 +00:00
Aaron Huang
99348b1664 Merge "Remove mSubscriberId from NetworkTemplate" 2023-01-16 07:55:26 +00:00
Kangping Dong
707a996c9b add TRANSPORT_THREAD to NetworkCapabilities
This commit also updates to use V11 dnsresolver APIs which was V9.

Bug: 262683651
Test: unit tests
Change-Id: Ifbd71157012dc66ec0f377beef9fa59d1c8620b8
2023-01-16 10:51:56 +08:00
Paul Hu
2bb41be9d3 Merge "Move mDNS code to service-connectivity-t" 2023-01-13 12:33:28 +00:00
Paul Hu
03a51d5674 Move mDNS code to service-connectivity-t
Instead of using a separate service-mdns library, move the code to
service-connectivity-t.

service-connectivity-t is chosen because it has access to hidden API of
classes that were made updatable in T, such as NsdServiceInfo and
NsdManager. mdns code can be there as it is only loaded on T+.

Bug: 241738458
Test: atest
Change-Id: I7eb6c9ab8bf0e0a614ea2994c6ed80a1a780241f
2023-01-13 16:42:48 +08:00
Treehugger Robot
18967e69f2 Merge "Cleanup TestableNetworkCallback#assertNoCallback" 2023-01-13 07:41:06 +00:00
Remi NGUYEN VAN
73990178e5 Merge "Add unit tests for probing" 2023-01-13 04:05:46 +00:00
Paul Hu
6ea0c1d05b Merge "Add MdnsMultinetworkSocketClient" 2023-01-13 03:58:19 +00:00
Remi NGUYEN VAN
65df28291a Merge "Remove PacketRepeater destinationsSupplier logic" 2023-01-13 01:51:07 +00:00
Remi NGUYEN VAN
5e5393ffde Add unit tests for probing
Add tests for MdnsRecordRepository and MdnsInterfaceAdvertiser
implementations of probing.

Bug: 241738458
Test: atest
Change-Id: If41a387f14e805e81b6d0d8217d081ca053e340f
2023-01-12 19:36:43 +09:00
Jean Chalard
526df99b53 Merge "Apply "most-recent" delivery policy to CONNECTIVITY_ACTION." 2023-01-12 06:37:26 +00:00
Yan Yan
19aa23db7e Merge "Expose APIs to migrate IpSecTransform" 2023-01-11 18:52:59 +00:00
Paul Hu
637d9833f8 Add MdnsMultinetworkSocketClient
Add MdnsMultinetworkSocketClient which is using for managing
multinetwork for discovery and resolution. If the requests are
specified the network to do the discovery or resolution, it
should send the queries and receive the responses on the active
networks only. This can save the resource by reducing unnecessary
queries and align the behavior with mdnsresponder.

Bug: 254166302
Test: atest FramworksNetTests
Change-Id: I9f49ac11e70cb945f9a90efc5eb684be87801286
2023-01-12 00:47:46 +08:00
Remi NGUYEN VAN
49ae3f0d51 Remove PacketRepeater destinationsSupplier logic
PacketRepeater can just try to send to both v4 and v6 multicast
addresses, and rely on MdnsReplySender to check whether the sockets have
(automatically) joined the v4 or v6 groups, so there is no need to use
this unusual lambda setup anymore.

Bug: 264947218
Test: atest MdnsProberTest MdnsAnnouncerTest
Change-Id: I09e0fa4bf14e1f31f2d2508f17e23adf1415feb7
2023-01-11 18:47:35 +09:00
Junyu Lai
73bf06f6b5 Merge "Enterprise slicing for profile blocking default" 2023-01-11 07:23:58 +00:00
Remi NGUYEN VAN
125ff06cba Merge "Add MdnsAdvertiser" 2023-01-11 05:45:32 +00:00
Junyu Lai
35665cc887 Enterprise slicing for profile blocking default
Test: atest ConnectivityServiceTest#testProfileNetworkPreferenceBlocking_networkChanges \
      ConnectivityServiceTest#testProfileNetworkPreferenceBlocking_changePreference \
      --rerun-until-failure 100
Bug: 263219497

Change-Id: Idbda582542bcabf0156e2bab9f8bea42fc908cae
2023-01-11 10:47:00 +08:00
Yan Yan
81c2160a63 Expose APIs to migrate IpSecTransform
This commit exposes APIs to migrate a tunnel mode transform to
new source/destination addresses, as required by MOBIKE.

By calling the exposed API, the caller only caches the new
address in the transform. To complete the migration, caller
MUST apply the tranform to the appropriate tunnel.

This API design is mainly based on the kernel interface and use
cases. The Linux kernel requires Android to provide both the
IpSecTransform and the IpSecTunnelInterface to perform the
migration. And in most cases those two instances are managed
by different entities: IpSecTranform is managed by the key
exchange protocol (e.g. IKE) and IpSecTunnelInterface is managed by
the security tunnel provider (e.g. VPN, VCN, and IWLAN). Thus the
migration process has been designed to have two steps where the
key exchange protocol negotiates and caches the new address,
passes out the updated transform, and the security tunnel
provider applies the transform to a tunnel.

Another benefit of this API is it can also apply to the case
where the network peer does not support MOBIKE and thus cannot
update the existing transforms. In this case, the key exchange
protocol can create a new transform and give it to the security
tunnel provider, and the tunnel provider can still call "apply"
to perform migration without needing to know the details of the
transform update process.

Bug: 169171001
Test: atest FrameworksNetTests, IpSecManagerTunnelTest
Change-Id: I0658cdb09fb31f7e0fb9d0b07f37c2b72b6e705f
2023-01-10 19:09:05 +00:00
Remi NGUYEN VAN
314db00b3f Add MdnsAdvertiser
MdnsAdvertiser takes requests to advertise services on given Networks,
and relays them to internal maps of MdnsInterfaceAdvertisers.
SocketProvider is used to create the sockets for the requested networks.

It also ensures that added services do not have name conflicts, as
registration of one service should use the same name on all interfaces,
so any conflict means that every MdnsInterfaceAdvertiser needs to use a
different name. Names are automatically updated with a number suffix
(like "service (2)", "service (3)"), similarly to the legacy
mdnsresponder implementation.

The implementatio of MdnsInterfaceAdvertiser will be added in a
different change.

Bug: 241738458
Test: atest

Change-Id: I21aa93c681dd179b9d6ec425bc0f247a10ba5b0b
2023-01-10 22:04:05 +09:00
Sudheer Shanka
2453a3ada2 Apply "most-recent" delivery policy to CONNECTIVITY_ACTION.
This allows us to skip any older CONNECTIVITY_ACTION broadcasts
waiting to be delivered when a new broadcast is dispatched.

Bug: 255545931
Test: TH
Change-Id: Iac5da2f727e295d1775bfe91358900f316258be4
2023-01-09 03:21:44 +00:00
Oli Lan
04898c7a2b Update VpnManagerServiceTest to work with lockdown VPN main user changes.
Bug: 259515323
Test: atest VpnManagerServiceTest
Change-Id: If56a9994bc89c09bedc8709e5b9db871372f7418
2023-01-06 16:43:47 +00:00
Chalard Jean
0b1720af1e Cleanup TestableNetworkCallback#assertNoCallback
Test: FrameworksNetTests
      CtsNetTestCases
      FrameworksNetIntegrationTests
      NetworkStackTests
      NetworkStaticLibTests
      TetheringTests
      MtsTetheringTestLatestSdk
      TetheringIntegrationTest
Change-Id: I2d585d628648cae6fa503145f2f0ded77f982605
2023-01-06 16:50:25 +09:00
Jean Chalard
a8e13ec811 Merge "Rename isStrictMode to better names" 2023-01-06 06:14:26 +00:00
Aaron Huang
2e18f3ed8f Remove dev recorder from NetworkStatsService
In the original design that using qtaguid module to get the
stats, mDevRecorder was for interface-level summary which
may include non IP layer traffic and mXtRecorder was for
interface-level summary which is only IP layer traffic.

It's migrated to use xt_bpf to read ifaces stats currently
since the qtaguid proc file is no longer exist. Both
readNetworkStatsSummaryXt() and readNetworkStatsSummaryDev()
return stats from bpf iface stats map. mDevRecorder has the
same content as mXtRecorder, and there's no usage actually
reference to mDevRecorder. Thus mDevRecorder can be removed.

Bug: 241880278
Test: FrameworksNetTests
      CtsNetTestCases
Change-Id: Ib0fe823517c81989ee01dc8835ab69a9da818162
2022-12-28 23:43:12 +08:00
Aaron Huang
ece181997c Remove *_WILDCARD constants from NetworkTemplate
NetworkTemplate was moved into mainline module and
provide Builder for external users to build template.
MATCH_MOBILE_WILDCARD and MATCH_WIFI_WILDCARD are not
exposed so currently the usage of these two constants
only in module. This change is to remove the constants.

After removing the constants, two methods matchesWifi
and matchesMobile are changed to adapt the original
matches[Wifi|Mobile]Wildcard behavior.

Bug: 238843364
Test: FrameworksNetTests
Change-Id: I9e156b504ce4eb903b39279e443fad27bc921186
2022-12-28 18:49:37 +08:00