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