GNUnet GNS interceptor logic. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_dns_service.h"
#include "gnunet-service-gns.h"
#include "gnunet-service-gns_resolver.h"
#include "gnunet-service-gns_interceptor.h"
#include "gns.h"
Go to the source code of this file.
Data Structures | |
struct | InterceptLookupHandle |
Handle to a DNS intercepted resolution request. More... | |
Macros | |
#define | MAX_RECURSION 256 |
How deep do we allow recursions to go before we abort? More... | |
Functions | |
static void | reply_to_dns (void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd) |
Reply to dns request with the result from our lookup. More... | |
static void | handle_dns_request (void *cls, struct GNUNET_DNS_RequestHandle *rh, size_t request_length, const char *request) |
The DNS request handler. More... | |
int | GNS_interceptor_init (const struct GNUNET_CONFIGURATION_Handle *c) |
Initialize DNS interceptor. More... | |
void | GNS_interceptor_done () |
Disconnect from interceptor. More... | |
Variables | |
static struct GNUNET_DNS_Handle * | dns_handle |
Our handle to the DNS handler library. More... | |
static struct InterceptLookupHandle * | ilh_head |
Head of the DLL. More... | |
static struct InterceptLookupHandle * | ilh_tail |
Tail of the DLL. More... | |
GNUnet GNS interceptor logic.
Definition in file gnunet-service-gns_interceptor.c.
#define MAX_RECURSION 256 |
How deep do we allow recursions to go before we abort?
Definition at line 38 of file gnunet-service-gns_interceptor.c.
|
static |
Reply to dns request with the result from our lookup.
cls | the closure to the request (an InterceptLookupHandle) |
rd_count | the number of records to return |
rd | the record data |
Definition at line 98 of file gnunet-service-gns_interceptor.c.
References _, GNUNET_TIME_Absolute::abs_value_us, GNUNET_DNSPARSER_Packet::additional_records, GNUNET_DNSPARSER_Packet::answers, GNUNET_TUN_DnsFlags::authoritative_answer, data, GNUNET_DNSPARSER_RawRecord::data, GNUNET_DNSPARSER_Record::data, GNUNET_DNSPARSER_RawRecord::data_len, data_size, GNUNET_GNSRECORD_Data::data_size, GNUNET_DNSPARSER_Record::dns_traffic_class, GNUNET_DNSPARSER_Record::expiration_time, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_DNSPARSER_Packet::flags, GNUNET_break, GNUNET_break_op, GNUNET_CONTAINER_DLL_remove, GNUNET_DNS_request_answer(), GNUNET_DNSPARSER_free_packet(), GNUNET_DNSPARSER_pack(), GNUNET_DNSPARSER_parse_mx(), GNUNET_DNSPARSER_parse_name(), GNUNET_DNSPARSER_parse_soa(), GNUNET_DNSPARSER_parse_uri(), GNUNET_DNSPARSER_TYPE_CNAME, GNUNET_DNSPARSER_TYPE_MX, GNUNET_DNSPARSER_TYPE_NS, GNUNET_DNSPARSER_TYPE_PTR, GNUNET_DNSPARSER_TYPE_SOA, GNUNET_DNSPARSER_TYPE_SRV, GNUNET_DNSPARSER_TYPE_URI, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_TUN_DNS_CLASS_INTERNET, GNUNET_TUN_DNS_RETURN_CODE_NAME_ERROR, GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR, GNUNET_DNSPARSER_Record::hostname, ilh_head, ilh_tail, GNUNET_DNSPARSER_Record::mx, GNUNET_DNSPARSER_Query::name, GNUNET_DNSPARSER_Record::name, GNUNET_DNSPARSER_Packet::num_additional_records, GNUNET_DNSPARSER_Packet::num_answers, InterceptLookupHandle::packet, GNUNET_DNSPARSER_Packet::queries, GNUNET_TUN_DnsFlags::query_or_response, GNUNET_DNSPARSER_Record::raw, rd, rd_count, GNUNET_GNSRECORD_Data::record_type, InterceptLookupHandle::request_handle, ret, GNUNET_TUN_DnsFlags::return_code, GNUNET_DNSPARSER_Record::soa, GNUNET_DNSPARSER_Query::type, GNUNET_DNSPARSER_Record::type, and GNUNET_DNSPARSER_Record::uri.
Referenced by handle_dns_request().
|
static |
The DNS request handler.
Called for every incoming DNS request.
cls | closure, unused |
rh | request handle to user for reply |
request_length | number of bytes in request |
request | UDP payload of the DNS request |
Definition at line 327 of file gnunet-service-gns_interceptor.c.
References GNS_find_tld(), GNS_get_tld(), GNS_resolver_lookup(), GNUNET_CONTAINER_DLL_insert, GNUNET_DNS_request_forward(), GNUNET_DNSPARSER_free_packet(), GNUNET_DNSPARSER_parse(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_GNS_LO_DEFAULT, GNUNET_log, GNUNET_new, GNUNET_YES, ilh_head, ilh_tail, InterceptLookupHandle::lookup, MAX_RECURSION, p, InterceptLookupHandle::packet, reply_to_dns(), request, and InterceptLookupHandle::request_handle.
Referenced by GNS_interceptor_init().
int GNS_interceptor_init | ( | const struct GNUNET_CONFIGURATION_Handle * | c | ) |
Initialize DNS interceptor.
c | the configuration |
Definition at line 386 of file gnunet-service-gns_interceptor.c.
References _, dns_handle, GNUNET_DNS_connect(), GNUNET_DNS_FLAG_PRE_RESOLUTION, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SYSERR, GNUNET_YES, and handle_dns_request().
Referenced by run().
void GNS_interceptor_done | ( | void | ) |
Disconnect from interceptor.
Stops the interceptor.
Definition at line 408 of file gnunet-service-gns_interceptor.c.
References dns_handle, GNS_resolver_lookup_cancel(), GNUNET_CONTAINER_DLL_remove, GNUNET_DNS_disconnect(), GNUNET_DNS_request_drop(), GNUNET_DNSPARSER_free_packet(), GNUNET_free, ilh_head, ilh_tail, InterceptLookupHandle::lookup, InterceptLookupHandle::packet, and InterceptLookupHandle::request_handle.
Referenced by shutdown_task().
|
static |
Our handle to the DNS handler library.
Definition at line 77 of file gnunet-service-gns_interceptor.c.
Referenced by GNS_interceptor_done(), and GNS_interceptor_init().
|
static |
Head of the DLL.
Definition at line 82 of file gnunet-service-gns_interceptor.c.
Referenced by GNS_interceptor_done(), handle_dns_request(), and reply_to_dns().
|
static |
Tail of the DLL.
Definition at line 87 of file gnunet-service-gns_interceptor.c.
Referenced by GNS_interceptor_done(), handle_dns_request(), and reply_to_dns().