resolv_netid.h revision 8563802b04347951d8878747a830987e5ca145f5
1ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak/*
2ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * Copyright (C) 2014 The Android Open Source Project
3ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * All rights reserved.
4ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak *
5ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * Redistribution and use in source and binary forms, with or without
6ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * modification, are permitted provided that the following conditions
7ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * are met:
8ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak *  * Redistributions of source code must retain the above copyright
9ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak *    notice, this list of conditions and the following disclaimer.
10ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak *  * Redistributions in binary form must reproduce the above copyright
11ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak *    notice, this list of conditions and the following disclaimer in
12ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak *    the documentation and/or other materials provided with the
13ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak *    distribution.
14ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak *
15ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * SUCH DAMAGE.
27ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak */
28ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak#ifndef _RESOLV_NETID_H
29ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak#define _RESOLV_NETID_H
30ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak
31ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak/* This header contains declarations related to per-network DNS
32ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * server selection. They are used by system/netd/ and should not be
33ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * exposed by the C library's public NDK headers.
34ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak */
35ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak#include <sys/cdefs.h>
36ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak#include <netinet/in.h>
37ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak
38ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak/*
39ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * Passing NETID_UNSET as the netId causes system/netd/DnsProxyListener.cpp to
40ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * fill in the appropriate default netId for the query.
41ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak */
42ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak#define NETID_UNSET 0u
43ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak
44ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak/*
45ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak * MARK_UNSET represents the default (i.e. unset) value for a socket mark.
46ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak */
47ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak#define MARK_UNSET 0u
48ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak
49ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak__BEGIN_DECLS
50ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak
51ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczakstruct addrinfo;
52ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak
538563802b04347951d8878747a830987e5ca145f5Elliott Hughes#define __used_in_netd __attribute__((visibility ("default")))
548563802b04347951d8878747a830987e5ca145f5Elliott Hughes
558563802b04347951d8878747a830987e5ca145f5Elliott Hughesstruct hostent *android_gethostbyaddrfornet(const void *, socklen_t, int, unsigned, unsigned) __used_in_netd;
568563802b04347951d8878747a830987e5ca145f5Elliott Hughesstruct hostent *android_gethostbynamefornet(const char *, int, unsigned, unsigned) __used_in_netd;
57ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczakint android_getaddrinfofornet(const char *, const char *, const struct addrinfo *, unsigned,
588563802b04347951d8878747a830987e5ca145f5Elliott Hughes		unsigned, struct addrinfo **) __used_in_netd;
59ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak
60ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak/* set name servers for a network */
61ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczakextern void _resolv_set_nameservers_for_net(unsigned netid,
628563802b04347951d8878747a830987e5ca145f5Elliott Hughes    const char** servers, int numservers, const char *domains) __used_in_netd;
63ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak
64ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak/* flush the cache associated with a certain network */
658563802b04347951d8878747a830987e5ca145f5Elliott Hughesextern void _resolv_flush_cache_for_net(unsigned netid) __used_in_netd;
668563802b04347951d8878747a830987e5ca145f5Elliott Hughes
678563802b04347951d8878747a830987e5ca145f5Elliott Hughes/* Internal use only. */
688563802b04347951d8878747a830987e5ca145f5Elliott Hughesstruct hostent *android_gethostbyaddrfornet_proxy(const void *, socklen_t, int , unsigned);
698563802b04347951d8878747a830987e5ca145f5Elliott Hughesint android_getnameinfofornet(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t,
708563802b04347951d8878747a830987e5ca145f5Elliott Hughes		 int, unsigned, unsigned);
71ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak
72ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak__END_DECLS
73ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak
74ea9bf6788144b83cc51c454b2bfe6b980d6e947cSzymon Jakubczak#endif /* _RESOLV_NETID_H */
75