android: Add optional filter functionality to DNS proxy
[strongswan.git] / src / frontends / android / jni / libandroidbridge / backend / android_dns_proxy.h
1 /*
2 * Copyright (C) 2014 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup android_dns_proxy android_dns_proxy
18 * @{ @ingroup android_backend
19 */
20
21 #ifndef ANDROID_DNS_PROXY_H_
22 #define ANDROID_DNS_PROXY_H_
23
24 #include <ip_packet.h>
25
26 typedef struct android_dns_proxy_t android_dns_proxy_t;
27
28 /**
29 * Callback called to deliver a DNS response packet.
30 *
31 * @param data data supplied during registration of the callback
32 * @param packet DNS response packet (has to be destroyed)
33 */
34 typedef void (*dns_proxy_response_cb_t)(void *data, ip_packet_t *packet);
35
36 /**
37 * DNS proxy class
38 */
39 struct android_dns_proxy_t {
40
41 /**
42 * Handle an outbound DNS packet (if the packet is one)
43 *
44 * @param packet packet to handle
45 * @return TRUE if handled, FALSE otherwise (no DNS)
46 */
47 bool (*handle)(android_dns_proxy_t *this, ip_packet_t *packet);
48
49 /**
50 * Register the callback used to deliver DNS response packets.
51 *
52 * @param cb the callback function
53 * @param data optional data provided to callback
54 */
55 void (*register_cb)(android_dns_proxy_t *this, dns_proxy_response_cb_t cb,
56 void *data);
57
58 /**
59 * Unregister the callback used to deliver DNS response packets.
60 *
61 * @param cb the callback function
62 * @param data optional data provided to callback
63 */
64 void (*unregister_cb)(android_dns_proxy_t *this, dns_proxy_response_cb_t cb);
65
66 /**
67 * Add a hostname for which queries are proxied. If at least one hostname
68 * is configured DNS queries for others will not be handled.
69 *
70 * @param hostname hostname to add (gets cloned)
71 */
72 void (*add_hostname)(android_dns_proxy_t *this, char *hostname);
73
74 /**
75 * Destroy an instance.
76 */
77 void (*destroy)(android_dns_proxy_t *this);
78 };
79
80 /**
81 * Create an instance.
82 */
83 android_dns_proxy_t *android_dns_proxy_create();
84
85 #endif /** ANDROID_DNS_PROXY_H_ @}*/
86