39 #define MAX_RECURSION 256 109 unsigned int num_answers;
110 unsigned int skip_answers;
111 unsigned int skip_additional;
116 for (i = 0; i < rd_count; i++)
117 if (rd[i].record_type == query->
type)
126 packet->
answers = answer_records;
131 for (i = 0; i < rd_count; i++)
133 if (rd[i].record_type == query->
type)
135 answer_records[i - skip_answers].
name = query->
name;
137 switch (rd[i].record_type)
146 if ((off != rd[i].data_size) ||
147 (NULL == answer_records[i].data.
hostname))
155 answer_records[i - skip_answers].
data.
soa 159 if ((off != rd[i].data_size) ||
160 (NULL == answer_records[i].data.
soa))
173 answer_records[i - skip_answers].
data.
mx 177 if ((off != rd[i].data_size) ||
178 (NULL == answer_records[i].data.
hostname))
187 answer_records[i - skip_answers].
data.
raw.
data = (
char *) rd[i].data;
199 additional_records[i - skip_additional].
name = query->
name;
201 switch (rd[i].record_type)
210 if ((off != rd[i].data_size) ||
211 (NULL == additional_records[i].data.
hostname))
219 additional_records[i - skip_additional].
data.
soa 223 if ((off != rd[i].data_size) ||
224 (NULL == additional_records[i].data.
hostname))
232 additional_records[i - skip_additional].
data.
mx 236 if ((off != rd[i].data_size) ||
237 (NULL == additional_records[i].data.
hostname))
252 additional_records[i - skip_additional].
data.
raw.
data =
279 _ (
"Error converting GNS response to DNS response!\n"));
312 size_t request_length,
320 "Hijacked a DNS request. Processing.\n");
324 "Received malformed DNS packet, leaving it untouched.\n");
334 "Not exactly one query in DNS packet. Forwarding untouched.\n");
362 "Request for `%s' is forwarded to DNS untouched.\n",
379 "DNS hijacking enabled. Connecting to DNS service.\n");
384 if (NULL == dns_handle)
387 _ (
"Failed to connect to the DNS service!\n"));
402 while (NULL != (ilh = ilh_head))
412 if (NULL != dns_handle)
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_DNSPARSER_Record * answers
Array of all answers in the packet, must contain "num_answers" entries.
uint16_t type
See GNUNET_DNSPARSER_TYPE_*.
void GNS_resolver_lookup_cancel(struct GNS_ResolverHandle *rh)
Cancel active resolution (i.e.
uint16_t type
See GNUNET_DNSPARSER_TYPE_*.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
char * GNUNET_DNSPARSER_parse_name(const char *udp_payload, size_t udp_payload_length, size_t *off)
Parse name inside of a DNS query or record.
struct InterceptLookupHandle * prev
We keep these in a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_DNSPARSER_Packet * packet
the dns parser packet received
#define GNUNET_DNSPARSER_TYPE_CNAME
static struct InterceptLookupHandle * ilh_tail
Tail of the DLL.
const char * GNS_get_tld(const char *name)
Obtain the TLD of the given name.
unsigned int return_code
See GNUNET_TUN_DNS_RETURN_CODE_ defines.
static size_t data_size
Number of bytes in data.
int GNUNET_DNSPARSER_pack(const struct GNUNET_DNSPARSER_Packet *p, uint16_t max, char **buf, size_t *buf_length)
Given a DNS packet p, generate the corresponding UDP payload.
Handle to a DNS intercepted reslution request.
static int ret
Return value of the commandline.
void GNUNET_DNSPARSER_free_packet(struct GNUNET_DNSPARSER_Packet *p)
Free memory taken by a packet.
struct GNUNET_DNSPARSER_SoaRecord * GNUNET_DNSPARSER_parse_soa(const char *udp_payload, size_t udp_payload_length, size_t *off)
Parse a DNS SOA record.
size_t data_size
Number of bytes in data.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_DNSPARSER_Record * additional_records
Array of all additional answers in the packet, must contain "num_additional_records" entries...
#define GNUNET_DNSPARSER_TYPE_MX
unsigned int num_answers
Number of answers in the packet, should be 0 for queries.
uint64_t abs_value_us
The actual value.
IPC messages between GNS API and GNS service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
int GNS_interceptor_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialized the interceptor.
Handle to a currently pending resolution.
unsigned int authoritative_answer
Set to 1 if this is an authoritative answer.
#define GNUNET_DNSPARSER_TYPE_PTR
unsigned int query_or_response
query:0, response:1
void GNUNET_DNS_disconnect(struct GNUNET_DNS_Handle *dh)
Disconnect from the DNS service.
#define GNUNET_DNSPARSER_TYPE_SOA
struct GNS_ResolverHandle * lookup
Handle for the lookup operation.
char * name
Name of the record that the query is for (0-terminated).
char * hostname
For NS, CNAME and PTR records, this is the uncompressed 0-terminated hostname.
static struct GNUNET_OS_Process * p
Helper process we started.
struct GNUNET_DNSPARSER_SoaRecord * soa
SOA data for SOA records.
unsigned int num_additional_records
Number of additional records in the packet, should be 0 for queries.
struct GNUNET_DNSPARSER_Packet * GNUNET_DNSPARSER_parse(const char *udp_payload, size_t udp_payload_length)
Parse a UDP payload of a DNS packet in to a nice struct for further processing and manipulation...
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
uint64_t expiration_time
Expiration time for the DNS record.
static struct InterceptLookupHandle * ilh_head
Head of the DLL.
static void handle_dns_request(void *cls, struct GNUNET_DNS_RequestHandle *rh, size_t request_length, const char *request)
The DNS request handler.
#define GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR
RFC 1035 codes.
union GNUNET_DNSPARSER_Record::@24 data
Payload of the record (which one of these is valid depends on the 'type').
void GNS_interceptor_done()
Disconnect from interceptor.
GNU Name System (main service)
static struct GNUNET_DNS_Handle * dns_handle
Our handle to the DNS handler library.
struct GNUNET_DNSPARSER_Query * queries
Array of all queries in the packet, must contain "num_queries" entries.
struct GNUNET_DNSPARSER_MxRecord * GNUNET_DNSPARSER_parse_mx(const char *udp_payload, size_t udp_payload_length, size_t *off)
Parse a DNS MX record.
struct InterceptLookupHandle * next
We keep these in a DLL.
size_t data_len
Number of bytes in data.
void * data
Binary record data.
struct GNUNET_DNS_RequestHandle * request_handle
the request handle to reply to
#define GNUNET_TUN_DNS_CLASS_INTERNET
A few common DNS classes (ok, only one is common, but I list a couple more to make it clear what we'r...
struct GNUNET_DNS_Handle * GNUNET_DNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_DNS_Flags flags, GNUNET_DNS_RequestHandler rh, void *rh_cls)
Connect to the service-dns.
struct GNUNET_TIME_Absolute expiration_time
When does the record expire?
void GNUNET_DNS_request_answer(struct GNUNET_DNS_RequestHandle *rh, uint16_t reply_length, const char *reply)
If a GNUNET_DNS_RequestHandler calls this function, the request is supposed to be answered with the d...
An identity key as per LSD0001.
struct GNUNET_DNSPARSER_MxRecord * mx
MX data for MX records.
int GNS_find_tld(const char *tld_str, struct GNUNET_IDENTITY_PublicKey *pkey)
Find GNS zone belonging to TLD tld.
#define GNUNET_TUN_DNS_RETURN_CODE_NAME_ERROR
uint32_t record_type
Type of the GNS/DNS record.
Handle to identify an individual DNS request.
void GNUNET_DNS_request_forward(struct GNUNET_DNS_RequestHandle *rh)
If a GNUNET_DNS_RequestHandler calls this function, the request is given to other clients or the glob...
#define GNUNET_DNSPARSER_TYPE_NS
Easy-to-process, parsed version of a DNS packet.
#define GNUNET_log(kind,...)
uint16_t dns_traffic_class
See GNUNET_TUN_DNS_CLASS_*.
void GNUNET_DNS_request_drop(struct GNUNET_DNS_RequestHandle *rh)
If a GNUNET_DNS_RequestHandler calls this function, the request is to be dropped and no response shou...
char * name
Name of the record that the query is for (0-terminated).
This client should be called on requests that have not yet been resolved as this client provides a re...
unsigned int num_queries
Number of queries in the packet.
Defaults, look in cache, then in DHT.
This expiration time of the record is a relative time (not an absolute time).
struct GNUNET_TUN_DnsFlags flags
Bitfield of DNS flags.
#define GNUNET_DNSPARSER_TYPE_SRV
uint32_t data
The data value.
struct GNUNET_DNSPARSER_RawRecord raw
Raw data for all other types.
struct GNS_ResolverHandle * GNS_resolver_lookup(const struct GNUNET_IDENTITY_PublicKey *zone, uint32_t record_type, const char *name, enum GNUNET_GNS_LocalOptions options, uint16_t recursion_depth_limit, GNS_ResultProcessor proc, void *proc_cls)
Lookup of a record in a specific zone calls lookup result processor on result.
#define MAX_RECURSION
How deep do we allow recursions to go before we abort?
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
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.