Limit C linkage to public symbols
Switched all internal functions to C++ linkage. This makes it harder to
accidentally call a function with a mismatched signature, and paves the
way to using C++ data structures internally.
This is the current list of symbols expoted by libnetd_resolv.so:
_resolv_delete_cache_for_net
_resolv_flush_cache_for_net
_resolv_set_nameservers_for_net
android_getaddrinfofornet
android_getaddrinfofornetcontext
android_gethostbyaddrfornet
android_gethostbyaddrfornetcontext
android_gethostbynamefornet
android_gethostbynamefornetcontext
android_net_res_stats_aggregate
android_net_res_stats_get_info_for_net
android_net_res_stats_get_usable_servers
A mass-renaming pass would improve consistency. Perhaps we could use
the prefix "netd_resolv_", or just "resolv_" for brevity. Once we begin
shipping netd binaries using this interface, we might have to live with
it for some time.
Test: atest netd_integration_test (after flashing with new netd binary)
Change-Id: I52f32add73fd908ad4a715ef8f8aff1f8d9733d0
diff --git a/resolv/resolv_netid.h b/resolv/resolv_netid.h
index f410ed1..aa4757f 100644
--- a/resolv/resolv_netid.h
+++ b/resolv/resolv_netid.h
@@ -48,12 +48,9 @@
*/
#define MARK_UNSET 0u
-__BEGIN_DECLS
-
struct __res_params;
struct addrinfo;
-
-#define __used_in_netd __attribute__((visibility("default")))
+struct hostent;
/*
* A struct to capture context relevant to network operations.
@@ -81,34 +78,33 @@
#define NET_CONTEXT_FLAG_USE_LOCAL_NAMESERVERS 0x00000001
#define NET_CONTEXT_FLAG_USE_EDNS 0x00000002
-struct hostent* android_gethostbyaddrfornet(const void*, socklen_t, int, unsigned,
- unsigned) __used_in_netd;
-struct hostent* android_gethostbynamefornet(const char*, int, unsigned, unsigned) __used_in_netd;
-int android_getaddrinfofornet(const char*, const char*, const struct addrinfo*, unsigned, unsigned,
- struct addrinfo**) __used_in_netd;
+LIBNETD_RESOLV_PUBLIC hostent* android_gethostbyaddrfornet(const void*, socklen_t, int, unsigned,
+ unsigned);
+LIBNETD_RESOLV_PUBLIC hostent* android_gethostbynamefornet(const char*, int, unsigned, unsigned);
+LIBNETD_RESOLV_PUBLIC int android_getaddrinfofornet(const char*, const char*,
+ const addrinfo*, unsigned, unsigned,
+ addrinfo**);
/*
* TODO: consider refactoring android_getaddrinfo_proxy() to serve as an
* explore_fqdn() dispatch table method, with the below function only making DNS calls.
*/
-struct hostent* android_gethostbyaddrfornetcontext(
- const void*, socklen_t, int, const struct android_net_context*) __used_in_netd;
-struct hostent* android_gethostbynamefornetcontext(
- const char*, int, const struct android_net_context*) __used_in_netd;
-int android_getaddrinfofornetcontext(const char*, const char*, const struct addrinfo*,
- const struct android_net_context*,
- struct addrinfo**) __used_in_netd;
+LIBNETD_RESOLV_PUBLIC hostent* android_gethostbyaddrfornetcontext(const void*, socklen_t, int,
+ const android_net_context*);
+LIBNETD_RESOLV_PUBLIC hostent* android_gethostbynamefornetcontext(const char*, int,
+ const android_net_context*);
+LIBNETD_RESOLV_PUBLIC int android_getaddrinfofornetcontext(const char*, const char*,
+ const addrinfo*,
+ const android_net_context*, addrinfo**);
-/* set name servers for a network */
-extern int _resolv_set_nameservers_for_net(unsigned netid, const char** servers,
- unsigned numservers, const char* domains,
- const struct __res_params* params) __used_in_netd;
+// Set name servers for a network
+LIBNETD_RESOLV_PUBLIC int _resolv_set_nameservers_for_net(unsigned netid, const char** servers,
+ unsigned numservers, const char* domains,
+ const __res_params* params);
-/* flush the cache associated with a certain network */
-extern void _resolv_flush_cache_for_net(unsigned netid) __used_in_netd;
+// Flush the cache associated with a certain network
+LIBNETD_RESOLV_PUBLIC void _resolv_flush_cache_for_net(unsigned netid);
-/* delete the cache associated with a certain network */
-extern void _resolv_delete_cache_for_net(unsigned netid) __used_in_netd;
-
-__END_DECLS
+// Delete the cache associated with a certain network
+LIBNETD_RESOLV_PUBLIC void _resolv_delete_cache_for_net(unsigned netid);
#endif /* _RESOLV_NETID_H */