Improve IPv6 networking for radio
RIL only announced addresses supplied by the emulator host. For IPv6 the
guest uses Neighbor Discovery Protocol to determine which IPv6 addresses
to assign to an interface and what gateway to use. This was not
reflected in RIL though which meant that the Android framework was
unaware of the radio using these addresses. There are now CTS tests that
rely on the framework knowing which addresses are assigned to verify
that connections to external servers are made from the correct
interface. These tests would fail on the radio interface.
In addition to providing interface addresses RIL also provides DNS
servers. It would only provide whatever DNS servers the DHCP client
could find. On networks that are configured to use IPv6 DNS servers this
left the radio interface without any usable DNS servers.
This change adds an interface monitor to the RIL that is looking for
address changes on the radio network interface. It then sends updates to
the framework whenever the addresses change. And to solve the specific
IPv6 problem it looks at IPv6 addreses. RIL still expects the IPv4
address to either be hardcoded for the Wifi case or supplied by the
emulator host if the Wifi feature is not enabled.
To fix the IPv6 DNS server issue the ipv6proxy will now inspect each
incoming Router Advertisement packet and extract any IPv6 DNS servers
provided in those packets. The proxy will set a system property for each
extracted DNS server. The RIL will then take the value from these system
properties and use in its messages to the framework, indicating which
DNS servers to use.
Test: run cts -m CtsNetTestCases -t
android.net.cts.ConnectivityManagerTest#testOpenConnection
BUG: 111691186
Merged-In: Ia970d2dda18c2615cacca496701c67f2066530a7
(cherry picked from commit 6ef3b9b3299bef6f3cc57c5d0933f846ee98f277)
diff --git a/ril/if_monitor.h b/ril/if_monitor.h
new file mode 100644
index 0000000..118bf88
--- /dev/null
+++ b/ril/if_monitor.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2018, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ifMonitor;
+
+struct ifAddress {
+ int family;
+ int prefix;
+ unsigned char addr[16];
+};
+
+// A callback for when the addresses on an interface changes
+typedef void (*ifMonitorCallback)(unsigned int /*interface index*/,
+ const struct ifAddress* /*addresses*/,
+ size_t /*number of addresses */);
+
+struct ifMonitor* ifMonitorCreate();
+void ifMonitorFree(struct ifMonitor* monitor);
+
+void ifMonitorSetCallback(struct ifMonitor* monitor,
+ ifMonitorCallback callback);
+void ifMonitorRunAsync(struct ifMonitor* monitor);
+void ifMonitorStop(struct ifMonitor* monitor);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+