-hope springs eternal
[oweals/gnunet.git] / src / gns / gnunet-service-gns_resolver.h
index 1b54d3c2ce3f2f14ba0e68911c19a4db520aaf61..8b0a05e5f984786a9294f91aabfad620c4b8d4ef 100644 (file)
@@ -11,6 +11,7 @@
 #define DHT_GNS_REPLICATION_LEVEL 5
 
 #define GNUNET_GNS_MAX_PARALLEL_LOOKUPS 500
+#define GNUNET_GNS_MAX_NS_TASKS 500
 
 /*
  * DLL to hold the authority chain
@@ -88,12 +89,22 @@ typedef void (*ResolutionResultProcessor) (void *cls,
  * RSL_RECORD_EXISTS: the name to lookup exists
  * RSL_RECORD_EXPIRED: the name in the record expired
  * RSL_TIMED_OUT: resolution timed out
+ * RSL_DELEGATE_VPN: Found VPN delegation
+ * RSL_DELEGATE_NS: Found NS delegation
+ * RSL_DELEGATE_PKEY: Found PKEY delegation
+ * RSL_CNAME_FOUND: Found CNAME record
+ * RSL_PKEY_REVOKED: Found PKEY has been revoked
  */
 enum ResolutionStatus
 {
   RSL_RECORD_EXISTS = 1,
   RSL_RECORD_EXPIRED = 2,
-  RSL_TIMED_OUT = 4
+  RSL_TIMED_OUT = 4,
+  RSL_DELEGATE_VPN = 8,
+  RSL_DELEGATE_NS = 16,
+  RSL_DELEGATE_PKEY = 32,
+  RSL_CNAME_FOUND = 64,
+  RSL_PKEY_REVOKED = 128
 };
 
 /**
@@ -108,6 +119,19 @@ enum ResolutionStatus
  */
 struct ResolverHandle
 {
+
+  /* DLL */
+  struct ResolverHandle *next;
+
+  /* DLL */
+  struct ResolverHandle *prev;
+
+  /* Last record data found */
+  struct GNUNET_NAMESTORE_RecordData rd;
+
+  /* Number of last record data found */
+  unsigned int rd_count;
+
   /* The name to resolve */
   char name[MAX_DNS_NAME_LENGTH];
 
@@ -129,6 +153,33 @@ struct ResolverHandle
   /* timeout set for this lookup task */
   struct GNUNET_TIME_Relative timeout;
 
+  /* a handle to a vpn request */
+  struct GNUNET_VPN_RedirectionRequest *vpn_handle;
+
+  /* a socket for a dns request */
+  struct GNUNET_NETWORK_Handle *dns_sock;
+
+  /* a synthesized dns name */
+  char dns_name[MAX_DNS_NAME_LENGTH];
+
+  /* the authoritative dns zone */
+  char dns_zone[MAX_DNS_NAME_LENGTH];
+
+  /* the address of the DNS server FIXME not needed? */
+  struct sockaddr_in dns_addr;
+
+  /* handle to the local stub resolver request */
+  struct GNUNET_RESOLVER_RequestHandle *dns_resolver_handle;
+
+  /* select task for DNS */
+  GNUNET_SCHEDULER_TaskIdentifier dns_read_task;
+
+  /* pointer to raw dns query payload FIXME needs to be freed/NULL */
+  char *dns_raw_packet;
+
+  /* size of the raw dns query */
+  size_t dns_raw_packet_size;
+
   /* timeout task for the lookup */
   GNUNET_SCHEDULER_TaskIdentifier timeout_task;
 
@@ -173,6 +224,11 @@ struct ResolverHandle
    */
   unsigned long long id;
 
+  /**
+   * Pending Namestore task
+   */
+  struct GNUNET_NAMESTORE_QueueEntry *namestore_task;
+
 };
 
 
@@ -234,6 +290,9 @@ struct GetNameAuthorityHandle
 {
   /* the name to look up authority for */
   char name[MAX_DNS_NAME_LENGTH];
+
+  /* the result */
+  char result[MAX_DNS_NAME_LENGTH];
   
   /* Method to call on result */
   GetAuthorityResultProcessor proc;
@@ -247,6 +306,12 @@ struct GetNameAuthorityHandle
  */
 struct GetPseuAuthorityHandle
 {
+  /* DLL */
+  struct GetPseuAuthorityHandle *next;
+
+  /* DLL */
+  struct GetPseuAuthorityHandle *prev;
+
   /* the name to store the zone under */
   char name[MAX_DNS_LABEL_LENGTH];
 
@@ -265,8 +330,23 @@ struct GetPseuAuthorityHandle
   /* timeout task for lookup */
   GNUNET_SCHEDULER_TaskIdentifier timeout;
 
-  /* Head of the authority list */
-  struct AuthorityChain *ahead;
+  /* Authority to shorten */
+  struct AuthorityChain *auth;
+
+  /* handle to namestore request */
+  struct GNUNET_NAMESTORE_QueueEntry* namestore_task;
+};
+
+/**
+ * Namestore queue entries in background
+ */
+struct NamestoreBGTask
+{
+  /* node in heap */
+  struct GNUNET_CONTAINER_HeapNode *node;
+
+  /* queue entry */
+  struct GNUNET_NAMESTORE_QueueEntry *qe;
 };
 
 /**
@@ -276,6 +356,7 @@ struct GetPseuAuthorityHandle
  * @param nh handle to the namestore
  * @param dh handle to the dht
  * @param lz the local zone
+ * @param c configuration handle
  * @param max_bg_queries maximum amount of background queries
  * @param ignore_pending ignore records that still require user confirmation
  *        on lookup
@@ -285,6 +366,7 @@ int
 gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh,
                   struct GNUNET_DHT_Handle *dh,
                   struct GNUNET_CRYPTO_ShortHashCode lz,
+                  const struct GNUNET_CONFIGURATION_Handle *c,
                   unsigned long long max_bg_queries,
                   int ignore_pending);