2 * Copyright (C) 2014 Tobias Brunner
4 * Copyright (C) secunet Security Networks AG
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>.
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
18 * @defgroup android_dns_proxy android_dns_proxy
19 * @{ @ingroup android_backend
22 #ifndef ANDROID_DNS_PROXY_H_
23 #define ANDROID_DNS_PROXY_H_
25 #include <ip_packet.h>
27 typedef struct android_dns_proxy_t android_dns_proxy_t
;
30 * Callback called to deliver a DNS response packet.
32 * @param data data supplied during registration of the callback
33 * @param packet DNS response packet (has to be destroyed)
35 typedef void (*dns_proxy_response_cb_t
)(void *data
, ip_packet_t
*packet
);
40 struct android_dns_proxy_t
{
43 * Handle an outbound DNS packet (if the packet is one)
45 * @param packet packet to handle
46 * @return TRUE if handled, FALSE otherwise (no DNS)
48 bool (*handle
)(android_dns_proxy_t
*this, ip_packet_t
*packet
);
51 * Register the callback used to deliver DNS response packets.
53 * @param cb the callback function
54 * @param data optional data provided to callback
56 void (*register_cb
)(android_dns_proxy_t
*this, dns_proxy_response_cb_t cb
,
60 * Unregister the callback used to deliver DNS response packets.
62 * @param cb the callback function
63 * @param data optional data provided to callback
65 void (*unregister_cb
)(android_dns_proxy_t
*this, dns_proxy_response_cb_t cb
);
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.
71 * @param hostname hostname to add (gets cloned)
73 void (*add_hostname
)(android_dns_proxy_t
*this, char *hostname
);
76 * Destroy an instance.
78 void (*destroy
)(android_dns_proxy_t
*this);
84 android_dns_proxy_t
*android_dns_proxy_create();
86 #endif /** ANDROID_DNS_PROXY_H_ @}*/