gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r20039 - in gnunet/src: gns include


From: gnunet
Subject: [GNUnet-SVN] r20039 - in gnunet/src: gns include
Date: Sun, 26 Feb 2012 15:34:56 +0100

Author: schanzen
Date: 2012-02-26 15:34:56 +0100 (Sun, 26 Feb 2012)
New Revision: 20039

Added:
   gnunet/src/include/block_gns.h
Removed:
   gnunet/src/gns/block_gns.h
Modified:
   gnunet/src/gns/gnunet-gns-lookup.c
   gnunet/src/gns/gnunet-service-gns.c
   gnunet/src/gns/plugin_block_gns.c
   gnunet/src/include/gnunet_gns_service.h
Log:
-doxygen, more block plugin


Deleted: gnunet/src/gns/block_gns.h
===================================================================
--- gnunet/src/gns/block_gns.h  2012-02-26 14:23:43 UTC (rev 20038)
+++ gnunet/src/gns/block_gns.h  2012-02-26 14:34:56 UTC (rev 20039)
@@ -1,93 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2012 Christian Grothoff (and other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file include/block_gns.h
- * @brief fs block formats (shared between fs and block)
- * @author Martin Schanzenbach
- */
-#ifndef BLOCK_GNS_H
-#define BLOCK_GNS_H
-
-#include "gnunet_util_lib.h"
-
-GNUNET_NETWORK_STRUCT_BEGIN
-
-/**
- * @brief a simgle record inside a record block
- */
-struct GNSRecordBlock
-{
-  /**
-   * the record type
-   */
-  uint32_t type GNUNET_PACKED;
-
-  /**
-   * expiration time of the record
-   */
-  struct GNUNET_TIME_AbsoluteNBO expiration;
-
-  /**
-   * length of the data
-   */
-  uint32_t data_length GNUNET_PACKED;
-  
-  /* record flags */
-  uint32_t flags GNUNET_PACKED;
-
-  //Class of the record?
-
-  /* followed by the record data */
-}
-
-/**
- * @brief a record block for a given name of a single authority
- */
-struct GNSNameRecordBlock
-{
-
-  /**
-   * GNUNET_RSA_Signature using RSA-key generated from the records.
-   */
-  struct GNUNET_CRYPTO_RsaSignature signature;
-
-  /**
-   * What is being signed and why?
-   */
-  struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
-
-  /**
-   * The public key of the authority
-   */
-  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
-
-  /* 0-terminated name here */
-
-  /* number of records that follow */
-  uint32_t rd_num GNUNET_PACKED;
-
-  /* variable-size GNSRecordBlocks follows here */
-
-
-};
-
-GNUNET_NETWORK_STRUCT_END
-#endif

Modified: gnunet/src/gns/gnunet-gns-lookup.c
===================================================================
--- gnunet/src/gns/gnunet-gns-lookup.c  2012-02-26 14:23:43 UTC (rev 20038)
+++ gnunet/src/gns/gnunet-gns-lookup.c  2012-02-26 14:34:56 UTC (rev 20039)
@@ -104,15 +104,9 @@
  * operation that expects a reply
  *
  * @param cls closure
- * @param exp when will this value expire
- * @param key key of the result
- * @param get_path peers on reply path (or NULL if not recorded)
- * @param get_path_length number of entries in get_path
- * @param put_path peers on the PUT path (or NULL if not recorded)
- * @param put_path_length number of entries in get_path
- * @param type type of the result
- * @param size number of bytes in data
- * @param data pointer to the result data
+ * @param name name
+ * @param record a record
+ * @param num_records number of records
  */
 static void
 lookup_result_iterator (void *cls,

Modified: gnunet/src/gns/gnunet-service-gns.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns.c 2012-02-26 14:23:43 UTC (rev 20038)
+++ gnunet/src/gns/gnunet-service-gns.c 2012-02-26 14:34:56 UTC (rev 20039)
@@ -303,7 +303,7 @@
  * Start DHT lookup for a name -> PKEY (compare NS) record in
  * query->authority's zone
  *
- * @param query the pending gns query
+ * @param rh the pending gns query
  * @param name the name of the PKEY record
  */
 void
@@ -459,7 +459,7 @@
  * Start DHT lookup for a (name -> query->record_type) record in
  * query->authority's zone
  *
- * @param query the pending gns query
+ * @param rh the pending gns query context
  * @param name the name to query record
  */
 void
@@ -501,7 +501,7 @@
  * @param expiration expiration date of the record data set in the namestore
  * @param name the name for which we need an authority
  * @param rd_count the number of records with 'name'
- * @param data the record data
+ * @param rd the record data
  * @param signature the signature of the authority for the record data
  */
 void
@@ -697,7 +697,7 @@
  * @param expiration expiration date of the namestore entry
  * @param name the name for which we need an authority
  * @param rd_count the number of records with 'name'
- * @param data the record data
+ * @param rd the record data
  * @param signature the signature of the authority for the record data
  */
 static void
@@ -854,7 +854,7 @@
  * If it is then try to resolve directly.
  * If not then first have to resolve the authoritative entities.
  *
- * @param query the pending lookup
+ * @param rh the pending lookup
  * @param zone the zone we are currently resolving in
  */
 void
@@ -889,7 +889,7 @@
  *
  * Setup a new query and try to resolve
  *
- * @param rh the request handle of the DNS request from a client
+ * @param request the request handle of the DNS request from a client
  * @param p the DNS query packet we received
  * @param q the DNS query we received parsed from p
  */

Modified: gnunet/src/gns/plugin_block_gns.c
===================================================================
--- gnunet/src/gns/plugin_block_gns.c   2012-02-26 14:23:43 UTC (rev 20038)
+++ gnunet/src/gns/plugin_block_gns.c   2012-02-26 14:34:56 UTC (rev 20039)
@@ -61,10 +61,86 @@
                           size_t xquery_size, const void *reply_block,
                           size_t reply_block_size)
 {
-  if (type != GNUNET_BLOCK_TYPE_GNS_RECORD)
+  if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
     return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
+
+  struct GNUNET_CRYPTO_RsaSignature *signature;
+  struct GNUNET_CRYPTO_RsaSignaturePurpose *purpose;
+  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key;
+  char* name;
+  GNUNET_HashCode pkey_hash;
+  GNUNET_HashCode query_pkey;
+  GNUNET_HashCode name_hash;
+
+  uint32_t rd_num;
+  uint32_t type;
+  struct GNUNET_TIME_AbsoluteNBO;
+  uint32_t data_length;
+  uint32_t flags;
+
+  char* pos = (char*) reply_block;
+  signature = pos;
+  pos += sizeof(struct GNUNET_CRYPTO_RsaSignature);
+  pos += sizeof(struct GNUNET_CRYPTO_RsaSignaturePurpose);
+
+  public_key = pos;
+  pos += sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded);
+  name = pos;
+  pos += namelen(name); //Off by 1?
+
+  GNUNET_CRYPTO_hash(public_key,
+                     sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
+                     &pkey_hash);
+
+  GNUNET_CRYPTO_hash(name, strlen(name), &name_hash);
+
+  GNUNET_CRYPTO_hash_xor(query, &name_hash, &query_pkey);
   
-  //FIXME check signatures here
+  //Check query key against public key
+  if (0 != GNUNET_CRYPTO_hash_cmp(&query_pkey, &pkey_hash))
+    return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
+
+  rd_count = ntohl(*pos);
+  pos += sizeof(uint32_t);
+
+  struct GNUNET_NAMESTORE_RecordData rd[rd_count];
+  int i = 0;
+
+  for (i=0; i<rd_count; i++)
+  {
+    rd[i].type = ntohl(*pos);
+    pos += sizeof(uint32_t);
+    rd[i].expiration =
+      GNUNET_TIME_relative_ntoh(*((struct GNUNET_TIME_AbsoluteNBO*)pos));
+    pos += sizeof(struct GNUNET_TIME_AbsoluteNBO);
+    rd[i].data_length = ntohl(*pos);
+    pos += sizeof(uint32_t);
+    rd[i].flags = ntohl(*pos);
+    pos += sizeof(uint32_t);
+    rd[i].data = pos;
+    pos += rd[i].data_length;
+  }
+
+  if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (public_key,
+                                                      name,
+                                                      rd_count,
+                                                      rd,
+                                                      signature))
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Signature invalid\n");
+    return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
+  }
+
+  //Cache
+  GNUNET_NAMESTORE_record_put (handle, //FIXME where do i get this from?
+                               &pkey_hash,
+                               name,
+                               expiration, //FIXME uh where do i get this from?
+                               rd_count,
+                               rd,
+                               signature,
+                               NULL, //cont
+                               NULL); //cls
   return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
 }
 

Copied: gnunet/src/include/block_gns.h (from rev 20031, 
gnunet/src/gns/block_gns.h)
===================================================================
--- gnunet/src/include/block_gns.h                              (rev 0)
+++ gnunet/src/include/block_gns.h      2012-02-26 14:34:56 UTC (rev 20039)
@@ -0,0 +1,93 @@
+/*
+     This file is part of GNUnet.
+     (C) 2012 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file include/block_gns.h
+ * @brief fs block formats (shared between fs and block)
+ * @author Martin Schanzenbach
+ */
+#ifndef BLOCK_GNS_H
+#define BLOCK_GNS_H
+
+#include "gnunet_util_lib.h"
+
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * @brief a simgle record inside a record block
+ */
+struct GNSRecordBlock
+{
+  /**
+   * the record type
+   */
+  uint32_t type GNUNET_PACKED;
+
+  /**
+   * expiration time of the record
+   */
+  struct GNUNET_TIME_AbsoluteNBO expiration;
+
+  /**
+   * length of the data
+   */
+  uint32_t data_length GNUNET_PACKED;
+  
+  /* record flags */
+  uint32_t flags GNUNET_PACKED;
+
+  //Class of the record?
+
+  /* followed by the record data */
+}
+
+/**
+ * @brief a record block for a given name of a single authority
+ */
+struct GNSNameRecordBlock
+{
+
+  /**
+   * GNUNET_RSA_Signature using RSA-key generated from the records.
+   */
+  struct GNUNET_CRYPTO_RsaSignature signature;
+
+  /**
+   * What is being signed and why?
+   */
+  struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
+
+  /**
+   * The public key of the authority
+   */
+  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
+
+  /* 0-terminated name here */
+
+  /* number of records that follow */
+  uint32_t rd_num GNUNET_PACKED;
+
+  /* variable-size GNSRecordBlocks follows here */
+
+
+};
+
+GNUNET_NETWORK_STRUCT_END
+#endif

Modified: gnunet/src/include/gnunet_gns_service.h
===================================================================
--- gnunet/src/include/gnunet_gns_service.h     2012-02-26 14:23:43 UTC (rev 
20038)
+++ gnunet/src/include/gnunet_gns_service.h     2012-02-26 14:34:56 UTC (rev 
20039)
@@ -121,13 +121,14 @@
  * @param handle handle to the GNS service
  * @param timeout how long to wait for transmission of this request to the 
service
  * // FIXME: what happens afterwards?
- * @param type expected type of the response object
+ * @param handle handle to the GNS service
+ * @param timeout timeout of request
  * @param name the name to look up
  * @param type the GNUNET_GNS_RecordType to look for
  * @param iter function to call on each result
  * @param iter_cls closure for iter
  *
- * @return handle to stop the async get
+ * @return handle to stop the async lookup
  */
 struct GNUNET_GNS_LookupHandle *
 GNUNET_GNS_lookup_start (struct GNUNET_GNS_Handle *handle,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]