38 #define MAX_RECURSION 256
108 unsigned int num_answers;
109 unsigned int skip_answers;
110 unsigned int skip_additional;
116 if (
rd[i].record_type == query->
type)
125 packet->
answers = answer_records;
132 if (
rd[i].record_type == query->
type)
134 answer_records[i - skip_answers].
name = query->
name;
136 switch (
rd[i].record_type)
146 (NULL == answer_records[i].
data.hostname))
154 answer_records[i - skip_answers].
data.
soa
159 (NULL == answer_records[i].
data.soa))
172 answer_records[i - skip_answers].
data.
mx
177 (NULL == answer_records[i].
data.hostname))
198 additional_records[i - skip_additional].
name = query->
name;
200 switch (
rd[i].record_type)
210 (NULL == additional_records[i].
data.hostname))
218 additional_records[i - skip_additional].
data.
soa
223 (NULL == additional_records[i].
data.hostname))
231 additional_records[i - skip_additional].
data.
mx
236 (NULL == additional_records[i].
data.hostname))
251 additional_records[i - skip_additional].
data.
raw.
data =
278 _ (
"Error converting GNS response to DNS response!\n"));
311 size_t request_length,
319 "Hijacked a DNS request. Processing.\n");
323 "Received malformed DNS packet, leaving it untouched.\n");
329 if (1 !=
p->num_queries)
332 "Not exactly one query in DNS packet. Forwarding untouched.\n");
360 "Request for `%s' is forwarded to DNS untouched.\n",
371 "DNS hijacking enabled. Connecting to DNS service.\n");
379 _ (
"Failed to connect to the DNS service!\n"));
IPC messages between GNS API and GNS service.
static int ret
Return value of the commandline.
static size_t data_size
Number of bytes in data.
uint32_t data
The data value.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static char * zone
Name of the zone being managed.
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
const char * GNS_get_tld(const char *name)
Obtain the TLD of the given name.
int GNS_find_tld(const char *tld_str, struct GNUNET_IDENTITY_PublicKey *pkey)
Find GNS zone belonging to TLD tld.
GNU Name System (main service)
static void handle_dns_request(void *cls, struct GNUNET_DNS_RequestHandle *rh, size_t request_length, const char *request)
The DNS request handler.
int GNS_interceptor_init(const struct GNUNET_CONFIGURATION_Handle *c)
Initialize DNS interceptor.
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.
static struct InterceptLookupHandle * ilh_head
Head of the DLL.
#define MAX_RECURSION
How deep do we allow recursions to go before we abort?
static struct InterceptLookupHandle * ilh_tail
Tail of the DLL.
void GNS_interceptor_done()
Disconnect from interceptor.
static struct GNUNET_DNS_Handle * dns_handle
Our handle to the DNS handler library.
void GNS_resolver_lookup_cancel(struct GNS_ResolverHandle *rh)
Cancel active resolution (i.e.
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.
static struct GNUNET_OS_Process * p
Helper process we started.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
API to access the DNS service.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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.
void GNUNET_DNSPARSER_free_packet(struct GNUNET_DNSPARSER_Packet *p)
Free memory taken by a packet.
#define GNUNET_DNSPARSER_TYPE_SRV
#define GNUNET_DNSPARSER_TYPE_SOA
#define GNUNET_DNSPARSER_TYPE_PTR
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.
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.
#define GNUNET_DNSPARSER_TYPE_NS
#define GNUNET_DNSPARSER_TYPE_CNAME
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.
#define GNUNET_DNSPARSER_TYPE_MX
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 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.
void GNUNET_DNS_disconnect(struct GNUNET_DNS_Handle *dh)
Disconnect from the DNS service.
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...
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...
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...
@ GNUNET_DNS_FLAG_PRE_RESOLUTION
This client should be called on requests that have not yet been resolved as this client provides a re...
@ GNUNET_GNS_LO_DEFAULT
Defaults, look in cache, then in DHT.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
#define GNUNET_log(kind,...)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_TUN_DNS_RETURN_CODE_NAME_ERROR
#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...
#define GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR
RFC 1035 codes.
Handle to a currently pending resolution.
Easy-to-process, parsed version of a DNS packet.
struct GNUNET_DNSPARSER_Query * queries
Array of all queries in the packet, must contain "num_queries" entries.
unsigned int num_answers
Number of answers in the packet, should be 0 for queries.
struct GNUNET_TUN_DnsFlags flags
Bitfield of DNS flags.
struct GNUNET_DNSPARSER_Record * answers
Array of all answers in the packet, must contain "num_answers" entries.
unsigned int num_additional_records
Number of additional records in the packet, should be 0 for queries.
struct GNUNET_DNSPARSER_Record * additional_records
Array of all additional answers in the packet, must contain "num_additional_records" entries.
uint16_t type
See GNUNET_DNSPARSER_TYPE_*.
char * name
Name of the record that the query is for (0-terminated).
void * data
Binary record data.
size_t data_len
Number of bytes in data.
uint16_t dns_traffic_class
See GNUNET_TUN_DNS_CLASS_*.
struct GNUNET_DNSPARSER_SoaRecord * soa
SOA data for SOA records.
struct GNUNET_DNSPARSER_MxRecord * mx
MX data for MX records.
char * hostname
For NS, CNAME and PTR records, this is the uncompressed 0-terminated hostname.
uint16_t type
See GNUNET_DNSPARSER_TYPE_*.
struct GNUNET_TIME_Absolute expiration_time
When does the record expire?
union GNUNET_DNSPARSER_Record::@24 data
Payload of the record (which one of these is valid depends on the 'type').
char * name
Name of the record that the query is for (0-terminated).
struct GNUNET_DNSPARSER_RawRecord raw
Raw data for all other types.
Handle to identify an individual DNS request.
uint32_t record_type
Type of the GNS/DNS record.
size_t data_size
Number of bytes in data.
uint64_t expiration_time
Expiration time for the DNS record.
An identity key as per LSD0001.
uint64_t abs_value_us
The actual value.
unsigned int query_or_response
query:0, response:1
unsigned int return_code
See GNUNET_TUN_DNS_RETURN_CODE_ defines.
unsigned int authoritative_answer
Set to 1 if this is an authoritative answer.
Handle to a DNS intercepted reslution request.
struct InterceptLookupHandle * prev
We keep these in a DLL.
struct GNUNET_DNSPARSER_Packet * packet
the dns parser packet received
struct GNS_ResolverHandle * lookup
Handle for the lookup operation.
struct InterceptLookupHandle * next
We keep these in a DLL.
struct GNUNET_DNS_RequestHandle * request_handle
the request handle to reply to