44 #define TIME_THRESH 10 59 #define SERIES_DELAY \ 60 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS, 10) 71 #define NS_BATCH_SIZE 1024 416 static char label[64];
419 dot = strchr (req->
hostname, (
unsigned char)
'.');
425 if (((
size_t) (dot - req->
hostname)) >=
sizeof(label))
447 static char raw[512];
457 memset (&p, 0,
sizeof(p));
467 "Failed to pack query for hostname `%s'\n",
472 if (*raw_size >
sizeof(raw))
475 "Failed to pack query for hostname `%s'\n",
499 while (NULL != (rec = req->
rec_head))
613 char ip[INET6_ADDRSTRLEN + 1];
614 socklen_t ip_size = (socklen_t)
sizeof(ip);
618 if (0 != strcasecmp (rec->
name, gc->
ns))
628 dst_len =
sizeof(dst);
638 if (NULL == inet_ntop (AF_INET, rec->
data.
raw.
data, ip, ip_size))
665 if (NULL == inet_ntop (AF_INET6, rec->
data.
raw.
data, ip, ip_size))
747 dst_len =
sizeof(dst);
754 "DNS returned record from zone `%s' of type %u while resolving `%s'\n",
756 (
unsigned int) rec->
type,
766 "DNS returned expired record for `%s'\n",
769 "# expired records obtained from DNS",
776 "DNS returned record that expires at %s for `%s'\n",
806 "Converted OOB (`%s') NS record for `%s'\n",
818 "Converted NS record for `%s' using glue\n",
831 "Converting CNAME (`%s') record for `%s'\n",
841 "FIXME: not supported: %s DNAME %s\n",
851 "Converting MX (`%s') record for `%s'\n",
864 "Converting SOA record for `%s'\n",
875 "Converting SRV record for `%s'\n",
889 "Converting PTR record for `%s' (weird)\n",
900 "Converting CERT record for `%s'\n",
914 "Converting record of type %u for `%s'\n",
915 (
unsigned int) rec->
type,
947 "Failed to store zone data for `%s': %s\n",
954 "Stored records under `%s' (%d)\n",
963 static uint64_t total_ns_latency_cnt;
969 if (0 == total_ns_latency_cnt)
971 total_ns_latency_cnt++;
972 if (0 == (total_ns_latency_cnt % 1000))
979 "Processed 1000 records in %s\n",
982 "# average NAMESTORE PUT latency (μs)",
984 / total_ns_latency_cnt,
999 "# Regular processing completed without NAMESTORE",
1003 "# Regular processing completed with NAMESTORE PUT",
1007 "# average request processing latency (μs)",
1008 runtime.rel_value_us,
1011 "# total time spent idle (μs)",
1039 unsigned int rd_count;
1053 "Stub gave up on DNS reply for `%s'\n",
1068 if (req->
id != dns->
id)
1071 "DNS ID did not match request, ignoring reply\n");
1083 "Failed to parse DNS reply for `%s'\n",
1121 "# average DNS lookup latency (μs)",
1128 for (rec = req->
rec_head; NULL != rec; rec = rec->
next)
1137 "Obtained %u records for `%s'\n",
1146 "# empty DNS replies (usually NXDOMAIN)",
1157 unsigned int off = 0;
1160 for (rec = req->
rec_head; NULL != rec; rec = rec->
next)
1161 rd[off++] = rec->
grd;
1186 unsigned int series;
1201 if (NULL != req->
qe)
1203 if (NULL != req->
rs)
1215 "Requesting resolution for `%s'\n",
1237 "Stopped processing queue (%u+%u/%u)]\n",
1247 "Stopped processing queue: empty queue\n");
1253 "Waiting until %s for next record (`%s') to expire\n",
1313 while (NULL != (req = req_head))
1316 if (NULL != req->
qe)
1323 if (NULL != req->
qe)
1327 if (NULL != zone_it)
1342 if (NULL != req_heap)
1347 if (NULL != ns_pending)
1353 while (NULL != (zone = zone_head))
1389 "Failed to load data from namestore for zone `%s'\n",
1410 unsigned int rd_count,
1420 "Obtained NAMESTORE reply, %llu left in round\n",
1422 if (0 == ns_iterator_trigger_next)
1426 "# NAMESTORE records requested from cache",
1427 ns_iterator_trigger_next,
1438 "Ignoring record `%s' in zone `%s': not on my list!\n",
1447 for (
unsigned int i = 0; i < rd_count; i++)
1467 "Empty record set in namestore for `%s'\n",
1472 unsigned int pos = 0;
1487 "Hot-start with %u existing records for `%s'\n",
1494 "Adding `%s' to worklist to start at %s\n",
1518 "Refusing invalid hostname `%s'\n",
1523 dot = strchr (hostname, (
unsigned char)
'.');
1527 "Refusing invalid hostname `%s' (lacks '.')\n",
1532 for (zone = zone_head; NULL !=
zone; zone = zone->
next)
1533 if (0 == strcmp (zone->
domain, dot + 1))
1539 "Domain name `%s' not in ego list!\n",
1544 hlen = strlen (hostname) + 1;
1559 "Duplicate hostname `%s' ignored\n",
1599 static struct Zone *last;
1602 if (NULL != zone_it)
1606 "Finished iteration over zone `%s'!\n",
1610 "# NAMESTORE records requested from cache",
1616 if (zone_tail == last)
1621 "Finished all NAMESTORE iterations!\n");
1623 "# Domain names without cached reply",
1639 "Starting iteration over zone `%s'!\n",
1643 "# NAMESTORE records requested from cache",
1668 static uint64_t idot;
1678 while (NULL != fgets (hn,
sizeof(hn), stdin))
1680 if (strlen (hn) > 0)
1681 hn[strlen (hn) - 1] =
'\0';
1685 if (0 == idot % 100000)
1692 "Read 100000 domain names in %s\n",
1699 "Done reading %llu domain names\n",
1700 (
unsigned long long) idot);
1752 if (NULL == zone_head)
1786 const char *cfgfile,
1795 if (NULL == ns_pending)
1797 fprintf (stderr,
"Failed to allocate memory for main hash map\n");
1803 fprintf (stderr,
"Failed to initialize GNUnet DNS STUB\n");
1806 if (NULL == args[0])
1809 "You must provide a list of DNS resolvers on the command line\n");
1812 for (
unsigned int i = 0; NULL != args[i]; i++)
1816 fprintf (stderr,
"Failed to use `%s' for DNS resolver\n", args[i]);
1848 "size to use for the main hash map"),
1852 "minimum-expiration",
1854 gettext_noop (
"minimum expiration time we assume for imported records"),
1863 "gnunet-zoneimport",
1864 "import DNS zone into namestore",
1871 "Rejected %u names, had %u cached, did %u lookups, stored %u record sets\n" 1872 "Found %u records, %u lookups failed, %u/%u pending on shutdown\n",
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time)...
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
static struct GNUNET_TIME_Relative total_dns_latency
Sum of DNS latencies observed.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
char * domain
Domain of the zone (i.e.
struct GNUNET_DNSPARSER_Record * answers
Array of all answers in the packet, must contain "num_answers" entries.
uint16_t type
See GNUNET_DNSPARSER_TYPE_*.
static struct GNUNET_NAMESTORE_ZoneIterator * zone_it
Current zone iteration handle.
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
uint16_t type
See GNUNET_DNSPARSER_TYPE_*.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct Request * req
Request we are processing.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
uint64_t rel_value_us
The actual value.
static void process_record(void *cls, const struct GNUNET_DNSPARSER_Record *rec)
We received rec for req.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
int main(int argc, char *const *argv)
Call with IP address of resolver to query.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
char * hostname
Hostname we are resolving.
static unsigned int pending_rs
The number of NAMESTORE record store operations that are outstanding.
#define GNUNET_DNSPARSER_TYPE_CNAME
char * mxhost
Name of the mail server.
struct GNUNET_DNSPARSER_SrvRecord * srv
SRV data for SRV records.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
#define GNUNET_GNSRECORD_TYPE_GNS2DNS
Delegation to DNS.
static uint64_t total_dns_latency_cnt
Number of DNS requests counted in latency total.
static struct Request * req_tail
Active requests are kept in a DLL.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Process requests from the queue, then if the queue is not empty, try again.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_DNSSTUB_stop(struct GNUNET_DNSSTUB_Context *ctx)
Cleanup DNSSTUB resolver.
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 MAX_RETRIES
How often do we retry a query before giving up for good?
uint16_t id
random 16-bit DNS query identifier.
static void for_all_records(const struct GNUNET_DNSPARSER_Packet *p, RecordProcessor rp, void *rp_cls)
Call rp for each record in p, regardless of what response section it is in.
static void do_shutdown(void *cls)
Clean up and terminate the process.
int GNUNET_DNSSTUB_add_dns_ip(struct GNUNET_DNSSTUB_Context *ctx, const char *dns_ip)
Add nameserver for use by the DNSSTUB.
int GNUNET_DNSPARSER_builder_add_srv(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_SrvRecord *srv)
Add an SRV record to the UDP packet at the given location.
uint16_t id
DNS ID (to match replies to requests).
A private key for an identity as per LSD0001.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static struct GNUNET_NAMESTORE_Handle * ns
Namestore handle.
static int ret
Return value of the commandline.
void GNUNET_DNSPARSER_free_packet(struct GNUNET_DNSPARSER_Packet *p)
Free memory taken by a packet.
size_t data_size
Number of bytes in data.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Definition of a command line option.
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
struct GNUNET_DNSPARSER_Record * additional_records
Array of all additional answers in the packet, must contain "num_additional_records" entries...
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
static unsigned int failures
Number of lookups that failed.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#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.
Internal representation of the hash map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
void(* RecordProcessor)(void *cls, const struct GNUNET_DNSPARSER_Record *rec)
Callback for for_all_records.
unsigned int issue_num
How often did we issue this query? (And failed, reset to zero once we were successful.)
static uint64_t total_reg_proc_dns_ns
Number of records processed (DNS lookup, with NAMESTORE) in total.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
static void iterate_zones(void *cls)
Iterate over all of the zones we care about and see which records we may need to re-fetch when...
static struct GNUNET_TIME_Absolute start_time_reg_proc
Start time of the regular processing.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
#define GNUNET_DNSPARSER_TYPE_PTR
static void free_records(struct Request *req)
Free records associated with req.
uint16_t dns_traffic_class
See GNUNET_TUN_DNS_CLASS_*.
static char * zone
Name of the zone we manage.
static unsigned int rejects
How many hostnames did we reject (malformed).
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
static void store_completed_cb(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
Handle for a zone iterator operation.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
#define GNUNET_DNSPARSER_TYPE_SOA
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.
const void * data
Binary value stored in the DNS record.
static struct GNUNET_OS_Process * p
Helper process we started.
Closure for process_record().
static struct GNUNET_IDENTITY_Handle * id
Handle to the identity service.
static char * value
Value of the record to add/remove.
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.
static void ns_lookup_error_cb(void *cls)
Function called if GNUNET_NAMESTORE_records_lookup() failed.
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 Record * rec_head
Head of records that should be published in GNS for this hostname.
struct GNUNET_DNSSTUB_Context * GNUNET_DNSSTUB_start(unsigned int num_sockets)
Start a DNS stub resolver.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Connection to the NAMESTORE service.
int found
Set to GNUNET_YES if glue was found.
#define GNUNET_DNSPARSER_TYPE_DNAME
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
uint64_t expiration_time
Expiration time for the DNS record.
static struct GNUNET_CONTAINER_MultiHashMap * ns_pending
Hash map of requests for which we may still get a response from the namestore.
static unsigned int map_size
Command-line argument specifying desired size of the hash map with all of our pending names...
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
struct GNUNET_CONTAINER_HeapNode * hn
Requests are kept in a heap while waiting to be resolved.
struct Record * next
Kept in a DLL.
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
struct GNUNET_IDENTITY_PrivateKey key
Private key of the zone.
union GNUNET_DNSPARSER_Record::@24 data
Payload of the record (which one of these is valid depends on the 'type').
Handle to a node in a heap.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
int GNUNET_DNSPARSER_builder_add_soa(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_SoaRecord *soa)
Add an SOA record to the UDP packet at the given location.
struct GNUNET_TIME_Absolute expires
At what time does the (earliest) of the returned records for this name expire? At this point...
struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Subtract relative timestamp from the other.
Heap with the minimum cost at the root.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT)...
static unsigned int pending
The number of DNS queries that are outstanding.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
struct GNUNET_DNSPARSER_Record * authority_records
Array of all authority records in the packet, must contain "num_authority_records" entries...
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the heap.
Handle to the stub resolver.
static struct GNUNET_TIME_Relative idle_time
Time we slept just waiting for work.
struct GNUNET_DNSPARSER_Query * queries
Array of all queries in the packet, must contain "num_queries" entries.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
const char * ns
NS name we are looking for glue for.
static unsigned int record_sets
Number of record sets given to namestore.
static struct GNUNET_CONTAINER_Heap * req_heap
Heap of all requests to perform, sorted by the time we should next do the request (i...
static const char * get_label(struct Request *req)
Return just the label of the hostname in req.
int GNUNET_DNSPARSER_builder_add_cert(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_CertRecord *cert)
Add CERT record to the UDP packet at the given location.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
struct GNUNET_DNSSTUB_RequestSocket * GNUNET_DNSSTUB_resolve(struct GNUNET_DNSSTUB_Context *ctx, const void *request, size_t request_len, GNUNET_DNSSTUB_ResultCallback rc, void *rc_cls)
Perform DNS resolution using our default IP from init.
#define THRESH
Maximum number of queries pending at the same time.
static void process_stdin(void *cls)
Begin processing hostnames from stdin.
static struct Zone * zone_tail
Tail of list of zones we are managing.
static struct Request * req_head
Active requests are kept in a DLL.
#define GNUNET_free_nz(ptr)
Wrapper around free.
struct Record * rec_tail
Tail of records that should be published in GNS for this hostname.
#define MAX_SERIES
How many DNS requests do we at most issue in rapid series?
There must only be one value per key; storing a value should fail if a value under the same key alrea...
static void identity_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
Method called to inform about the egos of this peer.
size_t data_len
Number of bytes in data.
An QueueEntry used to store information for a pending NAMESTORE record operation. ...
void * data
Binary record data.
int GNUNET_DNSPARSER_builder_add_mx(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_MxRecord *mx)
Add an MX record to the UDP packet at the given location.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
static int free_request_it(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator called during do_shutdown() to free requests in the ns_pending map.
int issue_num
How often did we issue this query?
#define GNUNET_DNSPARSER_TYPE_TXT
static uint64_t total_reg_proc_dns
Number of records processed (DNS lookup, no NAMESTORE) in total.
int GNUNET_DNSPARSER_check_name(const char *name)
Check if a hostname in UTF-8 format can be coded into valid IDNA.
unsigned int num_authority_records
Number of authoritative answers in the packet, should be 0 for queries.
struct Request * req
Overall request we are processing.
static void ns_lookup_result_cb(void *cls, const struct GNUNET_IDENTITY_PrivateKey *key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
static int move_to_queue(void *cls, const struct GNUNET_HashCode *key, void *value)
We have completed the initial iteration over the namestore's database.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define SERIES_DELAY
How long do we wait at least between series of requests?
#define GNUNET_TIME_UNIT_DAYS
One day.
#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...
Record for the request to be stored by GNS.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
static struct Zone * zone_head
Head of list of zones we are managing.
struct GNUNET_NAMESTORE_QueueEntry * qe
Active request with the namestore.
#define NS_BATCH_SIZE
How many requests do we request from NAMESTORE in one batch during our initial iteration?
struct GNUNET_TIME_Absolute expiration_time
When does the record expire?
static void insert_sorted(struct Request *req)
Insert req into DLL sorted by next fetch time.
struct GNUNET_DNSSTUB_RequestSocket * rs
Socket used to make the request, NULL if not active.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
static unsigned int cached
Number of records we had cached.
struct GNUNET_TIME_Absolute op_start_time
While we are fetching the record, the value is set to the starting time of the GNS operation...
static char * hostname
Our hostname; we give this to all the peers we start.
static void queue(const char *hostname)
Add hostname to the list of requests to be made.
struct GNUNET_DNSPARSER_MxRecord * mx
MX data for MX records.
uint32_t record_type
Type of the GNS/DNS record.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
#define GNUNET_DNSPARSER_TYPE_AAAA
struct Record * prev
Kept in a DLL.
void GNUNET_DNSSTUB_resolve_cancel(struct GNUNET_DNSSTUB_RequestSocket *rs)
Cancel DNS resolution.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_min(struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
Return the minimum of two absolute time values.
static void process_result(void *cls, const struct GNUNET_TUN_DnsHeader *dns, size_t dns_len)
Function called with the result of a DNS resolution.
#define GNUNET_DNSPARSER_TYPE_NS
struct Zone * next
Kept in a DLL.
const struct GNUNET_IDENTITY_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Easy-to-process, parsed version of a DNS packet.
static void check_for_glue(void *cls, const struct GNUNET_DNSPARSER_Record *rec)
Try to find glue records for a given NS record.
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static void add_record(struct Request *req, uint32_t type, struct GNUNET_TIME_Absolute expiration_time, const void *data, size_t data_len)
Add record to the GNS record set for req.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
void * GNUNET_CONTAINER_heap_remove_root(struct GNUNET_CONTAINER_Heap *heap)
Remove root of the heap.
static struct GNUNET_SCHEDULER_Task * t
Main task.
static uint64_t ns_iterator_trigger_next
After how many more results must ns_lookup_result_cb() ask the namestore for more?
static struct GNUNET_TIME_Absolute sleep_time_reg_proc
Last time we worked before going idle.
const struct Zone * zone
Zone responsible for this request.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
static char * rp
Relying party.
char * name
Name of the record that the query is for (0-terminated).
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
unsigned int num_queries
Number of queries in the packet.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
static void free_request(struct Request *req)
Free req and data structures reachable from it.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
Time for absolute times used by GNUnet, in microseconds.
static struct GNUNET_TIME_Relative minimum_expiration_time
How long do DNS records have to last at least after being imported?
static unsigned int records
Number of records we found.
static unsigned int lookups
Number of lookups we performed overall.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
This expiration time of the record is a relative time (not an absolute time).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
int GNUNET_DNSPARSER_builder_add_name(char *dst, size_t dst_len, size_t *off, const char *name)
Add a DNS name to the UDP packet at the given location, converting the name to IDNA notation as neces...
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
UDP socket we are using for sending DNS requests to the Internet.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
static void process_queue(void *cls)
Process as many requests as possible from the queue.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct Zone * prev
Kept in a DLL.
static void * build_dns_query(struct Request *req, size_t *raw_size)
Build DNS query for hostname.
#define GNUNET_DNSPARSER_TYPE_SRV
uint32_t data
The data value.
struct GNUNET_GNSRECORD_Data grd
GNS record.
struct GNUNET_DNSPARSER_Packet * p
Answer we got back and are currently parsing, or NULL if not active.
struct GNUNET_DNSPARSER_RawRecord raw
Raw data for all other types.
#define GNUNET_DNSPARSER_TYPE_A
Closure for check_for_glue.
#define GNUNET_DNSPARSER_TYPE_CERT
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_DNSPARSER_CertRecord * cert
CERT data for CERT records.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Some zones may include authoritative records for other zones, such as foo.com.uk or bar...