[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7062 - in GNUnet: . doc/man libltdl src/applications/datas
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7062 - in GNUnet: . doc/man libltdl src/applications/datastore src/applications/fs src/applications/fs/collection src/applications/fs/ecrs src/applications/fs/gap src/applications/fs/namespace src/applications/fs/tools src/applications/sqstore_mysql src/applications/testing src/include src/server src/setup/lib src/setup/ncurses src/transports src/util/network src/util/network_client src/util/pseudonym src/util/string |
Date: |
Sat, 7 Jun 2008 00:00:59 -0600 (MDT) |
Author: grothoff
Date: 2008-06-07 00:00:59 -0600 (Sat, 07 Jun 2008)
New Revision: 7062
Added:
GNUnet/src/applications/fs/namespace/namespace_update_test.c
GNUnet/src/util/string/parser.c
Removed:
GNUnet/src/applications/fs/ecrs/uri.h
Modified:
GNUnet/doc/man/gnunet-insert.1
GNUnet/libltdl/ltdl.c
GNUnet/src/applications/datastore/datastore.c
GNUnet/src/applications/fs/collection/collection.c
GNUnet/src/applications/fs/collection/collectiontest.c
GNUnet/src/applications/fs/ecrs/Makefile.am
GNUnet/src/applications/fs/ecrs/ecrs.h
GNUnet/src/applications/fs/ecrs/namespace.c
GNUnet/src/applications/fs/ecrs/namespacetest.c
GNUnet/src/applications/fs/ecrs/search.c
GNUnet/src/applications/fs/ecrs/upload.c
GNUnet/src/applications/fs/ecrs/uri.c
GNUnet/src/applications/fs/ecrs/uritest.c
GNUnet/src/applications/fs/ecrs_core.c
GNUnet/src/applications/fs/gap/fs.c
GNUnet/src/applications/fs/namespace/Makefile.am
GNUnet/src/applications/fs/namespace/info.c
GNUnet/src/applications/fs/namespace/namespace_infotest.c
GNUnet/src/applications/fs/namespace/root_info.c
GNUnet/src/applications/fs/namespace/update_info.c
GNUnet/src/applications/fs/namespace/uri.c
GNUnet/src/applications/fs/tools/gnunet-insert.c
GNUnet/src/applications/fs/tools/gnunet-pseudonym.c
GNUnet/src/applications/fs/tools/gnunet-unindex.c
GNUnet/src/applications/sqstore_mysql/mysql.c
GNUnet/src/applications/testing/remote.c
GNUnet/src/applications/testing/remotetopologies.c
GNUnet/src/applications/testing/testing.c
GNUnet/src/include/ecrs_core.h
GNUnet/src/include/gnunet_collection_lib.h
GNUnet/src/include/gnunet_ecrs_lib.h
GNUnet/src/include/gnunet_fsui_lib.h
GNUnet/src/include/gnunet_namespace_lib.h
GNUnet/src/include/gnunet_protocols.h
GNUnet/src/include/gnunet_util_string.h
GNUnet/src/server/connection.c
GNUnet/src/setup/lib/gns.c
GNUnet/src/setup/ncurses/mconf.c
GNUnet/src/transports/http.c
GNUnet/src/util/network/dns.c
GNUnet/src/util/network_client/tcpio.c
GNUnet/src/util/pseudonym/info_test.c
GNUnet/src/util/pseudonym/notification.c
GNUnet/src/util/string/Makefile.am
GNUnet/todo
Log:
updating to new and improved namespace APIs -- without periodic updates
Modified: GNUnet/doc/man/gnunet-insert.1
===================================================================
--- GNUnet/doc/man/gnunet-insert.1 2008-06-07 04:37:48 UTC (rev 7061)
+++ GNUnet/doc/man/gnunet-insert.1 2008-06-07 06:00:59 UTC (rev 7062)
@@ -136,21 +136,6 @@
2087.
.TP
-\fB\-i \fISECONDS\fR, \fB\-\-interval=\fISECONDS\fR
-Specifies the update frequency of the content in seconds. This option
-is only valid together with the \-P option. If no current and next ID
-are specified, the system picks some random start values for the
-sequence.
-
-.PP
-Most recent update can be found by gnunet\-gtk
-automatically. gnunet\-search will print all edition ids between the
-insertion time and the current time. A new search can be then
-performed with one of the printed keys. Also, using gnunet\-insert
-for updating content is cumbersome, in the future gnunet\-gtk will
-provide a more interactive way to manage content updates.
-
-.TP
\fB\-k \fIKEYWORD\fR, \fB\-\-key=KEYWORD\fR
additional key to index the content with (to add multiple keys,
specify multiple times). Each additional key is case-sensitive. Can be
@@ -199,9 +184,6 @@
current ID (this) and the next ID is used to compute all future IDs.
Note that specifying \-i and \-N without \-t hardly ever makes sense.
-The ID can be given in HEX notation, otherwise the HEX code is derived
-by hashing the given ID string.
-
.TP
\fB\-p \fIPRIORITY\fR, \fB\-\-prio=\fIPRIORITY\fR
Executive summary: You probably don't need it.
@@ -224,36 +206,12 @@
compute the GNUnet URI for a file without actually sharing it.
.TP
-\fB\-S\fR, \fB\-\-sporadic\fR
-This option specifies that the file will be updated sporadically but
-not periodically. It is only valid in conjunction with the \-P
-option. It is implied if \-N is specified but not \-i. It cannot be
-used together with the \-i option. Use \-S if you intend to publish
-an update at an unknown point in the future and if you want
-gnunet\-insert to pick a random identifier for that future content.
-
-If you use \-P but not \-S, \-N or \-i, the content will not be updateable.
-
-.TP
\fB\-t \fIID\fR, \fB\-\-this=\fIID\fR
Specifies the ID of the SBlock. This option is only valid together
with the\ -s option and together with either the option \-b or only a
single filename on the command-line.
-The ID can be given in HEX notation, otherwise the HEX code is derived
-by hashing the given ID string which may be a natural language
-keyword.
-
.TP
-\fB\-T \fITIME\fR, \fB\-\-time=\fITIME\fR
-Specifies the SBlock creation time. The required format depends on
-your locale.
-
-This option can be used to publish past and future periodical
-SBlocks. The option works best when used together with \-e. Default
-time is the current time.
-
-.TP
\fB\-u \fIURI\fR, \fB\-\-uri=\fIURI\fR
This option can be used to specify the URI of a file instead of
a filename (this is the only case where the otherwise mandatory
@@ -265,11 +223,6 @@
for which the URI is known but the content is not locally available.
.TP
-\fB\-U \fIID\fR, \fB\-\-update=\fIID\fR
-When updating an entry in the namespace, this option can be used
-to specify the ID of the previous entry.
-
-.TP
\fB\-v\fR, \fB\-\-version\fR
Print the version number.
@@ -320,17 +273,16 @@
\fBSecure publishing with namespaces\fR
-Insert file COPYING with pseudonym RIAA (\-P) and with identifier \fBgpl\fR
(\-t) and no updates:
+Insert file COPYING with pseudonym RIAA-2 (\-P) and with identifier \fBgpl\fR
(\-t) and no updates:
- # gnunet\-insert \-P RIAA \-t gpl COPYING
+ # gnunet\-insert \-P RIAA-2 \-t gpl COPYING
-Recursively index /home/ogg and build a matching directory
-structure. Insert the top\-level directory into the namespace under
-the pseudonym RIAA (\-P) under identifier MUSIC (\-t) and promise to
-provide an update with identifier VIDEOS (\-N) at an arbitrary point
-in the future (\-S is implied by lack of \-i and presence of \-N):
+Recursively index /home/ogg and build a matching directory structure.
+Insert the top\-level directory into the namespace under the pseudonym
+RIAA-2 (\-P) under identifier 'MUSIC' (\-t) and promise to provide an
+update with identifier 'VIDEOS' (\-N):
- # gnunet\-insert \-P RIAA \-t MUSIC \-N VIDEOS /home/ogg
+ # gnunet\-insert \-P RIAA-2 \-t MUSIC \-N VIDEOS /home/ogg
Recursively insert (\-n) /var/lib/mysql and build a matching
directory structure, but disable the use of libextractor to extract
@@ -342,14 +294,14 @@
# gnunet\-insert \-nV /var/lib/mysql
-Create a periodical SBlock with a sporadic update interval and announce
+Create a namespace entry 'root' in namespace MPAA-1 and announce
that the next update will be called 'next':
- # gnunet\-insert \-P MPAA \-N next \-S noise.mp3
+ # gnunet\-insert \-P MPAA-1 -t root \-N next noise.mp3
-Update the periodical SBlock using settings from a previous time:
+Update the previous entry, do not allow any future updates:
- # gnunet\-insert \-P MPAA \-t next -N nextnext noise_updated.mp3
+ # gnunet\-insert \-P MPAA-1 \-t next noise_updated.mp3
.SH FILES
Modified: GNUnet/libltdl/ltdl.c
===================================================================
--- GNUnet/libltdl/ltdl.c 2008-06-07 04:37:48 UTC (rev 7061)
+++ GNUnet/libltdl/ltdl.c 2008-06-07 06:00:59 UTC (rev 7062)
@@ -1770,9 +1770,9 @@
*) (((struct
dylib_command
*)
- lc)->
- dylib.name.
- offset +
+ lc)->dylib.
+ name.offset
+ +
(unsigned
long)
lc));
Modified: GNUnet/src/applications/datastore/datastore.c
===================================================================
--- GNUnet/src/applications/datastore/datastore.c 2008-06-07 04:37:48 UTC
(rev 7061)
+++ GNUnet/src/applications/datastore/datastore.c 2008-06-07 06:00:59 UTC
(rev 7062)
@@ -389,9 +389,9 @@
stat_filter_failed =
stats->create (gettext_noop ("# bloom filter false positives"));
- stats->set (stats->
- create (gettext_noop ("# bytes allowed in datastore")),
- quota);
+ stats->
+ set (stats->create (gettext_noop ("# bytes allowed in datastore")),
+ quota);
}
state = capi->service_request ("state");
if (state != NULL)
Modified: GNUnet/src/applications/fs/collection/collection.c
===================================================================
--- GNUnet/src/applications/fs/collection/collection.c 2008-06-07 04:37:48 UTC
(rev 7061)
+++ GNUnet/src/applications/fs/collection/collection.c 2008-06-07 06:00:59 UTC
(rev 7062)
@@ -45,6 +45,8 @@
*/
#define COLLECTION "collection"
+#define COLLECTION_ROOT "root"
+
/**
* How long does a collection advertisement live?
*/
@@ -57,40 +59,30 @@
{
/**
- * What is the last ID for the publication?
+ * What is the pseudonym ID for the publication?
*/
GNUNET_HashCode pid;
/**
- * What is the last ID for the publication?
+ * Anonymity level for the collection. (NBO)
*/
- GNUNET_HashCode lastId;
+ unsigned int anonymityLevel;
/**
- * What is the next ID for the publication?
+ * Priority of the collection (NBO).
*/
- GNUNET_HashCode nextId;
+ unsigned int priority;
/**
- * What is the update interval? (NBO!)
+ * Has this collection changed since the last publication?
*/
- GNUNET_Int32Time updateInterval;
+ int changed;
/**
- * What is the update interval? (NBO!)
+ * Revision counter
*/
- GNUNET_Int32Time lastPublication;
+ unsigned int revision;
- /**
- * Anonymity level for the collection. (NBO)
- */
- unsigned int anonymityLevel;
-
- /**
- * Priority of the collection (NBO).
- */
- unsigned int priority;
-
} CollectionData;
@@ -114,10 +106,6 @@
*/
unsigned int file_count;
- /**
- * Has this collection changed since the last publication?
- */
- int changed;
} CollectionInfo;
@@ -211,27 +199,22 @@
return;
}
collectionData = GNUNET_malloc (sizeof (CollectionInfo));
+ memset (collectionData, 0, sizeof (CollectionInfo));
memcpy (&collectionData->data, buf, sizeof (CollectionData));
pos = &buf[sizeof (CollectionData)];
rsize -= sizeof (CollectionData);
+ if (rsize < 2 * sizeof (int))
+ goto ERR;
len = ntohl (*(int *) pos);
if (len > 1024 * 1024 * 4)
- {
- GNUNET_GE_BREAK (ectx, 0);
- len = 1024 * 1024 * 4;
- }
- GNUNET_array_grow (collectionData->files, collectionData->file_count, len);
+ goto ERR;
pos += sizeof (int);
- collectionData->changed = ntohl (*(int *) pos);
- pos += sizeof (int);
mlen = ntohl (*(unsigned int *) pos);
pos += sizeof (unsigned int);
- rsize -= 3 * sizeof (int);
+ rsize -= 2 * sizeof (int);
if (mlen > rsize)
- {
- GNUNET_GE_BREAK (ectx, 0);
- mlen = rsize;
- }
+ goto ERR;
+ GNUNET_array_grow (collectionData->files, collectionData->file_count, len);
collectionData->meta = GNUNET_meta_data_deserialize (ectx, pos, mlen);
rsize -= mlen;
pos += mlen;
@@ -292,6 +275,13 @@
collectionData->file_count,
collectionData->file_count - 1);
}
+ return;
+ERR:
+ MUNMAP (buf, (size_t) size);
+ CLOSE (fd);
+ GNUNET_free (fn);
+ GNUNET_free (collectionData);
+ collectionData = NULL;
}
static void
@@ -345,7 +335,6 @@
GNUNET_GE_BREAK (ectx, collectionData->file_count <= 1024 * 1024 * 4);
WRITE (fd, collectionData, sizeof (CollectionData));
WRITEINT (fd, collectionData->file_count);
- WRITEINT (fd, collectionData->changed);
WRITEINT (fd, mlen);
WRITE (fd, buf, mlen);
GNUNET_free (buf);
@@ -376,6 +365,24 @@
GNUNET_free (fn);
}
+static void
+free_collection_data ()
+{
+ unsigned int i;
+
+ if (collectionData == NULL)
+ return;
+ GNUNET_meta_data_destroy (collectionData->meta);
+ for (i = 0; i < collectionData->file_count; i++)
+ {
+ GNUNET_meta_data_destroy (collectionData->files[i].meta);
+ GNUNET_ECRS_uri_destroy (collectionData->files[i].uri);
+ }
+ GNUNET_array_grow (collectionData->files, collectionData->file_count, 0);
+ GNUNET_free (collectionData);
+ collectionData = NULL;
+}
+
/**
* Shutdown collection module.
*/
@@ -383,7 +390,7 @@
GNUNET_CO_done ()
{
writeCO ();
- GNUNET_CO_collection_stop ();
+ free_collection_data ();
GNUNET_mutex_destroy (lock);
lock = NULL;
ectx = NULL;
@@ -403,20 +410,16 @@
int
GNUNET_CO_collection_start (unsigned int anonymityLevel,
unsigned int prio,
- GNUNET_Int32Time updateInterval,
const struct GNUNET_MetaData *meta)
{
struct GNUNET_ECRS_URI *advertisement;
struct GNUNET_ECRS_URI *rootURI;
- GNUNET_HashCode nextId;
- GNUNET_Int32Time now;
+ const char *root = COLLECTION_ROOT;
GNUNET_mutex_lock (lock);
GNUNET_CO_collection_stop (); /* cancel old collection */
advertisement = GNUNET_ECRS_keyword_string_to_uri (ectx, COLLECTION);
GNUNET_GE_ASSERT (ectx, advertisement != NULL);
- GNUNET_get_time_int32 (&now);
- GNUNET_create_random_hash (&nextId);
rootURI = GNUNET_ECRS_namespace_create (ectx,
cfg,
meta,
@@ -424,24 +427,20 @@
prio,
GNUNET_get_time () +
COLLECTION_ADV_LIFETIME,
- advertisement, &nextId);
+ advertisement, root);
+ GNUNET_ECRS_uri_destroy (advertisement);
if (rootURI == NULL)
{
- GNUNET_ECRS_uri_destroy (advertisement);
GNUNET_mutex_unlock (lock);
return GNUNET_SYSERR;
}
+ GNUNET_ECRS_uri_destroy (rootURI);
collectionData = GNUNET_malloc (sizeof (CollectionInfo));
memset (collectionData, 0, sizeof (CollectionInfo));
- GNUNET_create_random_hash (&collectionData->data.lastId);
GNUNET_ECRS_uri_get_namespace_from_sks (rootURI, &collectionData->data.pid);
- collectionData->data.nextId = nextId;
- collectionData->data.updateInterval = htonl (updateInterval);
- collectionData->data.anonymityLevel = htonl (anonymityLevel);
collectionData->data.priority = htonl (prio);
+ collectionData->data.anonymityLevel = htonl (anonymityLevel);
collectionData->meta = GNUNET_meta_data_duplicate (meta);
- GNUNET_ECRS_uri_destroy (advertisement);
- GNUNET_ECRS_uri_destroy (rootURI);
GNUNET_mutex_unlock (lock);
return GNUNET_OK;
}
@@ -454,8 +453,6 @@
int
GNUNET_CO_collection_stop ()
{
- unsigned int i;
-
GNUNET_mutex_lock (lock);
if (collectionData == NULL)
{
@@ -463,15 +460,7 @@
return GNUNET_SYSERR;
}
GNUNET_ECRS_namespace_delete (ectx, cfg, &collectionData->data.pid);
- GNUNET_meta_data_destroy (collectionData->meta);
- for (i = 0; i < collectionData->file_count; i++)
- {
- GNUNET_meta_data_destroy (collectionData->files[i].meta);
- GNUNET_ECRS_uri_destroy (collectionData->files[i].uri);
- }
- GNUNET_array_grow (collectionData->files, collectionData->file_count, 0);
- GNUNET_free (collectionData);
- collectionData = NULL;
+ free_collection_data ();
GNUNET_mutex_unlock (lock);
return GNUNET_OK;
}
@@ -498,67 +487,30 @@
}
/**
- * GNUNET_ND_UPLOAD an update of the current collection information to the
+ * Publish an update of the current collection information to the
* network now. The function has no effect if the collection has not
* changed since the last publication. If we are currently not
* collecting, this function does nothing.
- *
- * Note that clients typically don't have to call this
- * function explicitly. CO will call the function on
- * exit (for sporadically updated collections), on any
- * change to the collection (for immediately updated
- * content) or when the publication time has arrived
- * (for periodically updated collections).
- *
- * However, clients may want to call this function if
- * explicit publication of an update at another
- * time is desired.
*/
void
GNUNET_CO_collection_publish_now ()
{
- GNUNET_HashCode delta;
- GNUNET_Int32Time now;
struct GNUNET_ECRS_URI *uri;
struct GNUNET_ECRS_URI *directoryURI;
unsigned long long dirLen;
char *tmpName;
int fd;
char *dirData;
+ char this_revision_string[128];
+ char next_revision_string[128];
GNUNET_mutex_lock (lock);
- if ((collectionData == NULL) || (collectionData->changed == GNUNET_NO))
+ if ((collectionData == NULL) ||
+ (ntohl (collectionData->data.changed) == GNUNET_NO))
{
GNUNET_mutex_unlock (lock);
return;
}
- GNUNET_get_time_int32 (&now);
- if ((ntohl (collectionData->data.updateInterval) !=
- GNUNET_ECRS_SBLOCK_UPDATE_NONE)
- && (ntohl (collectionData->data.updateInterval) !=
- GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC)
- && (ntohl (collectionData->data.lastPublication) +
- ntohl (collectionData->data.updateInterval) < now))
- {
- GNUNET_mutex_unlock (lock);
- return;
- }
- if ((ntohl (collectionData->data.updateInterval) !=
- GNUNET_ECRS_SBLOCK_UPDATE_NONE)
- && (ntohl (collectionData->data.updateInterval) !=
- GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC))
- {
- GNUNET_hash_difference (&collectionData->data.nextId,
- &collectionData->data.lastId, &delta);
- collectionData->data.lastId = collectionData->data.nextId;
- GNUNET_hash_sum (&collectionData->data.nextId,
- &delta, &collectionData->data.nextId);
- }
- else
- {
- collectionData->data.lastId = collectionData->data.nextId;
- GNUNET_create_random_hash (&collectionData->data.nextId);
- }
tmpName = GNUNET_strdup ("/tmp/gnunet-collectionXXXXXX");
fd = mkstemp (tmpName);
if (fd == -1)
@@ -575,12 +527,9 @@
GNUNET_OK == GNUNET_ECRS_directory_create (ectx,
&dirData,
&dirLen,
- collectionData->
- file_count,
- collectionData->
- files,
- collectionData->
- meta));
+
collectionData->file_count,
+
collectionData->files,
+
collectionData->meta));
if (-1 == WRITE (fd, dirData, dirLen))
{
GNUNET_GE_LOG_STRERROR (ectx,
@@ -594,10 +543,10 @@
GNUNET_free (dirData);
CLOSE (fd);
if (GNUNET_OK != GNUNET_ECRS_file_upload (ectx, cfg, tmpName, GNUNET_NO,
/* indexing */
- ntohl (collectionData->data.
- anonymityLevel),
- ntohl (collectionData->data.
- priority),
+ ntohl (collectionData->
+ data.anonymityLevel),
+ ntohl (collectionData->
+ data.priority),
GNUNET_get_time () +
COLLECTION_ADV_LIFETIME, NULL,
NULL, NULL, NULL, &directoryURI))
@@ -609,25 +558,33 @@
}
UNLINK (tmpName);
GNUNET_free (tmpName);
+ if (ntohl (collectionData->data.revision) == 0)
+ strcpy (this_revision_string, COLLECTION_ROOT);
+ else
+ GNUNET_snprintf (this_revision_string,
+ sizeof (this_revision_string),
+ _("Revision %u"), ntohl (collectionData->data.revision));
+ GNUNET_snprintf (next_revision_string,
+ sizeof (next_revision_string),
+ _("Revision %u"),
+ ntohl (collectionData->data.revision) + 1);
uri = GNUNET_ECRS_namespace_add_content (ectx,
cfg,
&collectionData->data.pid,
- ntohl (collectionData->data.
- anonymityLevel),
- ntohl (collectionData->data.
- priority),
+ ntohl (collectionData->
+ data.anonymityLevel),
+ ntohl (collectionData->
+ data.priority),
GNUNET_get_time () +
- COLLECTION_ADV_LIFETIME, now,
- ntohl (collectionData->data.
- updateInterval),
- &collectionData->data.lastId,
- &collectionData->data.nextId,
- directoryURI,
+ COLLECTION_ADV_LIFETIME,
+ this_revision_string,
+ next_revision_string, directoryURI,
collectionData->meta);
if (uri != NULL)
{
- collectionData->data.lastPublication = htonl (now);
- collectionData->changed = GNUNET_NO;
+ collectionData->data.revision =
+ htonl (ntohl (collectionData->data.revision) + 1);
+ collectionData->data.changed = htonl (GNUNET_NO);
GNUNET_ECRS_uri_destroy (uri);
}
GNUNET_mutex_unlock (lock);
@@ -638,13 +595,6 @@
* the given file information in that collection.
* If we are currently not collecting, this function
* does nothing.
- *
- * Note that clients typically don't have to call this
- * function explicitly -- by using the CO library it
- * should be called automatically by CO code whenever
- * needed. However, the function maybe useful if you're
- * inserting files using libECRS directly or need other
- * ways to explicitly extend a collection.
*/
void
GNUNET_CO_collection_add_item (const GNUNET_ECRS_FileInfo * fi)
@@ -679,10 +629,7 @@
fc.uri = GNUNET_ECRS_uri_duplicate (fi->uri);
fc.meta = GNUNET_meta_data_duplicate (fi->meta);
GNUNET_array_append (collectionData->files, collectionData->file_count, fc);
- collectionData->changed = GNUNET_YES;
- if (ntohl (collectionData->data.updateInterval) ==
- GNUNET_ECRS_SBLOCK_UPDATE_NONE)
- GNUNET_CO_collection_publish_now ();
+ collectionData->data.changed = htonl (GNUNET_YES);
GNUNET_mutex_unlock (lock);
}
Modified: GNUnet/src/applications/fs/collection/collectiontest.c
===================================================================
--- GNUnet/src/applications/fs/collection/collectiontest.c 2008-06-07
04:37:48 UTC (rev 7061)
+++ GNUnet/src/applications/fs/collection/collectiontest.c 2008-06-07
06:00:59 UTC (rev 7062)
@@ -72,8 +72,7 @@
/* ACTUAL TEST CODE */
GNUNET_CO_collection_stop ();
CHECK (NULL == GNUNET_CO_collection_get_name ());
- CHECK (GNUNET_OK == GNUNET_CO_collection_start (1, 100, 60, /* 60s */
- meta));
+ CHECK (GNUNET_OK == GNUNET_CO_collection_start (1, 100, meta));
have = GNUNET_CO_collection_get_name ();
CHECK (NULL != have);
CHECK (GNUNET_meta_data_test_equal (have, meta));
Modified: GNUnet/src/applications/fs/ecrs/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/ecrs/Makefile.am 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/applications/fs/ecrs/Makefile.am 2008-06-07 06:00:59 UTC (rev
7062)
@@ -16,7 +16,7 @@
tree.c tree.h \
unindex.c \
upload.c \
- uri.c uri.h
+ uri.c
libgnunetecrs_la_LIBADD = \
-lz \
-lextractor \
Modified: GNUnet/src/applications/fs/ecrs/ecrs.h
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrs.h 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/applications/fs/ecrs/ecrs.h 2008-06-07 06:00:59 UTC (rev
7062)
@@ -97,7 +97,7 @@
struct
{
GNUNET_HashCode namespace;
- GNUNET_HashCode identifier;
+ char *identifier;
} sks;
GNUNET_EC_FileIdentifier fi;
Location loc;
Modified: GNUnet/src/applications/fs/ecrs/namespace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespace.c 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/applications/fs/ecrs/namespace.c 2008-06-07 06:00:59 UTC (rev
7062)
@@ -34,7 +34,6 @@
#define PSEUDODIR "data/namespace/keys/"
#define INITVALUE "GNUnet!!"
-#define MAX_NBLOCK_SIZE 32000
#define MAX_SBLOCK_SIZE 32000
static char *
@@ -120,6 +119,36 @@
}
/**
+ * Write the private key of the namespace to a file.
+ */
+static int
+write_namespace_key (struct GNUNET_GC_Configuration *cfg,
+ const struct GNUNET_RSA_PrivateKey *key)
+{
+ GNUNET_RSA_PrivateKeyEncoded *namespace_priv_key_encoded;
+ char *fileName;
+ GNUNET_RSA_PublicKey pubk;
+ GNUNET_HashCode pid;
+
+ GNUNET_RSA_get_public_key (key, &pubk);
+ GNUNET_hash (&pubk, sizeof (GNUNET_RSA_PublicKey), &pid);
+ fileName = getPseudonymFileName (NULL, cfg, &pid);
+ if (GNUNET_YES == GNUNET_disk_file_test (NULL, fileName))
+ {
+ GNUNET_GE_BREAK (NULL, 0); /* hash collision!? */
+ GNUNET_free (fileName);
+ return GNUNET_SYSERR;
+ }
+ namespace_priv_key_encoded = GNUNET_RSA_encode_key (key);
+ GNUNET_disk_file_write (NULL, fileName,
+ (const char *) namespace_priv_key_encoded,
+ ntohs (namespace_priv_key_encoded->len), "600");
+ GNUNET_free (fileName);
+ GNUNET_free (namespace_priv_key_encoded);
+ return GNUNET_OK;
+}
+
+/**
* Create a new namespace (and publish an advertismement).
* This publishes both an GNUNET_EC_NBlock in the namespace itself
* as well as KNBlocks under all keywords specified in
@@ -147,14 +176,10 @@
unsigned int priority,
GNUNET_CronTime expiration,
const struct GNUNET_ECRS_URI *advertisementURI,
- const GNUNET_HashCode * rootEntry)
+ const char *rootEntry)
{
struct GNUNET_ECRS_URI *rootURI;
- char *fileName;
- struct GNUNET_RSA_PrivateKey *hk;
- GNUNET_RSA_PrivateKeyEncoded *hke;
- char *dst;
- unsigned short len;
+ struct GNUNET_RSA_PrivateKey *namespace_priv_key;
GNUNET_HashCode hc;
struct GNUNET_ClientServerConnection *sock;
GNUNET_DatastoreValue *value;
@@ -162,15 +187,14 @@
unsigned int size;
unsigned int mdsize;
struct GNUNET_RSA_PrivateKey *pk;
- GNUNET_RSA_PublicKey pubk;
- GNUNET_HashCode pid;
- GNUNET_EC_NBlock *nb;
- GNUNET_EC_KNBlock *knb;
+ GNUNET_EC_SBlock *sb;
+ GNUNET_EC_KSBlock *ksb;
char **keywords;
const char *keyword;
unsigned int keywordCount;
int i;
char *cpy;
+ char *rtgt;
if ((advertisementURI != NULL)
&& (!GNUNET_ECRS_uri_test_ksk (advertisementURI)))
@@ -178,102 +202,77 @@
GNUNET_GE_BREAK (ectx, 0);
return NULL;
}
- hk = GNUNET_RSA_create_key ();
- GNUNET_RSA_get_public_key (hk, &pubk);
- GNUNET_hash (&pubk, sizeof (GNUNET_RSA_PublicKey), &pid);
- fileName = getPseudonymFileName (ectx, cfg, &pid);
- if (GNUNET_YES == GNUNET_disk_file_test (ectx, fileName))
+ namespace_priv_key = GNUNET_RSA_create_key ();
+ if (GNUNET_OK != write_namespace_key (cfg, namespace_priv_key))
{
- GNUNET_GE_BREAK (NULL, 0); /* hash collision!? */
- GNUNET_free (fileName);
+ GNUNET_RSA_free_key (namespace_priv_key);
return NULL;
}
- hke = GNUNET_RSA_encode_key (hk);
- len = ntohs (hke->len);
- dst = (char *) hke;
- GNUNET_disk_file_write (ectx, fileName, dst, len, "600");
- GNUNET_free (fileName);
- GNUNET_free (dst);
/* create advertisements */
mdsize = GNUNET_meta_data_get_serialized_size (meta, GNUNET_SERIALIZE_PART);
- size = mdsize + sizeof (GNUNET_EC_NBlock);
- if (size > MAX_NBLOCK_SIZE)
+ size = mdsize + sizeof (GNUNET_EC_SBlock) + strlen (rootEntry) + 2;
+ if (size > MAX_SBLOCK_SIZE)
{
- size = MAX_NBLOCK_SIZE;
- value = GNUNET_malloc (sizeof (GNUNET_DatastoreValue) + size);
- nb = (GNUNET_EC_NBlock *) & value[1];
- nb->type = htonl (GNUNET_ECRS_BLOCKTYPE_NAMESPACE);
- mdsize = size - sizeof (GNUNET_EC_NBlock);
- mdsize = GNUNET_meta_data_serialize (ectx,
- meta,
- (char *) &nb[1],
- mdsize, GNUNET_SERIALIZE_PART);
- if (mdsize == -1)
- {
- GNUNET_GE_BREAK (ectx, 0);
- GNUNET_ECRS_namespace_delete (ectx, cfg, &pid);
- GNUNET_RSA_free_key (hk);
- return NULL;
- }
- size = sizeof (GNUNET_EC_NBlock) + mdsize;
+ size = MAX_SBLOCK_SIZE;
+ mdsize = size - sizeof (GNUNET_EC_SBlock) - strlen (rootEntry) - 2;
}
- else
+ value = GNUNET_malloc (sizeof (GNUNET_DatastoreValue) + size);
+ memset (value, 0, sizeof (GNUNET_DatastoreValue) + size);
+ sb = (GNUNET_EC_SBlock *) & value[1];
+ sb->type = htonl (GNUNET_ECRS_BLOCKTYPE_SIGNED);
+ GNUNET_RSA_get_public_key (namespace_priv_key, &sb->subspace);
+ rtgt = (char *) &sb[1];
+ memcpy (rtgt, rootEntry, strlen (rootEntry) + 1);
+ mdsize = GNUNET_meta_data_serialize (ectx,
+ meta,
+ &rtgt[strlen (rootEntry) + 2],
+ mdsize, GNUNET_SERIALIZE_PART);
+ if (mdsize == -1)
{
- value = GNUNET_malloc (sizeof (GNUNET_DatastoreValue) + size);
- nb = (GNUNET_EC_NBlock *) & value[1];
- nb->type = htonl (GNUNET_ECRS_BLOCKTYPE_NAMESPACE);
- GNUNET_meta_data_serialize (ectx,
- meta,
- (char *) &nb[1], mdsize,
- GNUNET_SERIALIZE_FULL);
+ GNUNET_GE_BREAK (ectx, 0);
+ GNUNET_RSA_free_key (namespace_priv_key);
+ GNUNET_free (value);
+ return NULL;
}
+ size = mdsize + sizeof (GNUNET_EC_SBlock) + strlen (rootEntry) + 2;
+ GNUNET_GE_ASSERT (ectx,
+ GNUNET_OK == GNUNET_RSA_sign (namespace_priv_key,
+ size
+ -
+ sizeof
+ (GNUNET_RSA_Signature) -
+ sizeof
+ (GNUNET_RSA_PublicKey) -
+ sizeof (unsigned int),
+ &sb->identifier,
+ &sb->signature));
value->size = htonl (sizeof (GNUNET_DatastoreValue) + size);
- value->type = htonl (GNUNET_ECRS_BLOCKTYPE_NAMESPACE);
+ value->type = htonl (GNUNET_ECRS_BLOCKTYPE_SIGNED);
value->priority = htonl (priority);
value->anonymity_level = htonl (anonymityLevel);
value->expiration_time = GNUNET_htonll (expiration);
sock = GNUNET_client_connection_create (ectx, cfg);
-
- /* publish GNUNET_EC_NBlock */
- memset (&nb->identifier, 0, sizeof (GNUNET_HashCode));
- GNUNET_RSA_get_public_key (hk, &nb->subspace);
- GNUNET_hash (&nb->subspace, sizeof (GNUNET_RSA_PublicKey), &nb->namespace);
- rootURI = GNUNET_malloc (sizeof (URI));
- rootURI->type = sks;
- rootURI->data.sks.namespace = nb->namespace;
- rootURI->data.sks.identifier = *rootEntry;
-
- nb->rootEntry = *rootEntry;
-
- GNUNET_GE_ASSERT (ectx,
- GNUNET_OK == GNUNET_RSA_sign (hk,
- mdsize +
- 3 *
- sizeof (GNUNET_HashCode),
- &nb->identifier,
- &nb->signature));
if (GNUNET_OK != GNUNET_FS_insert (sock, value))
{
GNUNET_GE_BREAK (ectx, 0);
- GNUNET_free (rootURI);
GNUNET_free (value);
GNUNET_client_connection_destroy (sock);
- GNUNET_RSA_free_key (hk);
- GNUNET_ECRS_namespace_delete (ectx, cfg, &pid);
+ GNUNET_RSA_free_key (namespace_priv_key);
return NULL;
}
/* publish KNBlocks */
- size += sizeof (GNUNET_EC_KNBlock) - sizeof (GNUNET_EC_NBlock);
+ size += sizeof (GNUNET_EC_KSBlock) - sizeof (GNUNET_EC_SBlock);
knvalue = GNUNET_malloc (sizeof (GNUNET_DatastoreValue) + size);
*knvalue = *value;
- knvalue->type = htonl (GNUNET_ECRS_BLOCKTYPE_KEYWORD_FOR_NAMESPACE);
+ knvalue->type = htonl (GNUNET_ECRS_BLOCKTYPE_KEYWORD_SIGNED);
knvalue->size = htonl (sizeof (GNUNET_DatastoreValue) + size);
- knb = (GNUNET_EC_KNBlock *) & knvalue[1];
- knb->type = htonl (GNUNET_ECRS_BLOCKTYPE_KEYWORD_FOR_NAMESPACE);
- memcpy (&knb->nblock, nb, sizeof (GNUNET_EC_NBlock) + mdsize);
+ ksb = (GNUNET_EC_KSBlock *) & knvalue[1];
+ ksb->type = htonl (GNUNET_ECRS_BLOCKTYPE_KEYWORD_SIGNED);
+ memcpy (&ksb->sblock,
+ sb, sizeof (GNUNET_EC_SBlock) + mdsize + strlen (rootEntry) + 2);
if (advertisementURI != NULL)
{
@@ -282,7 +281,8 @@
cpy =
GNUNET_malloc (size - sizeof (GNUNET_EC_KBlock) -
sizeof (unsigned int));
- memcpy (cpy, &knb->nblock,
+ memcpy (cpy,
+ &ksb->sblock,
size - sizeof (GNUNET_EC_KBlock) - sizeof (unsigned int));
for (i = 0; i < keywordCount; i++)
{
@@ -291,52 +291,100 @@
mandatory or not -- ignore for hashing! */
GNUNET_hash (&keyword[1], strlen (&keyword[1]), &hc);
pk = GNUNET_RSA_create_key_from_hash (&hc);
- GNUNET_RSA_get_public_key (pk, &knb->kblock.keyspace);
+ GNUNET_RSA_get_public_key (pk, &ksb->kblock.keyspace);
GNUNET_GE_ASSERT (ectx,
size - sizeof (GNUNET_EC_KBlock) -
sizeof (unsigned int) ==
- sizeof (GNUNET_EC_NBlock) + mdsize);
- GNUNET_ECRS_encryptInPlace (&hc, &knb->nblock,
+ sizeof (GNUNET_EC_SBlock) + mdsize +
+ strlen (rootEntry) + 2);
+ GNUNET_ECRS_encryptInPlace (&hc, &ksb->sblock,
size - sizeof (GNUNET_EC_KBlock) -
sizeof (unsigned int));
GNUNET_GE_ASSERT (ectx,
GNUNET_OK == GNUNET_RSA_sign (pk,
+ size -
sizeof
- (GNUNET_EC_NBlock) +
- mdsize,
- &knb->nblock,
- &knb->kblock.
- signature));
+ (GNUNET_EC_KBlock) -
+ sizeof (unsigned
+ int),
+ &ksb->sblock,
+ &ksb->
+ kblock.signature));
/* extra check: verify sig */
GNUNET_RSA_free_key (pk);
if (GNUNET_OK != GNUNET_FS_insert (sock, knvalue))
{
GNUNET_GE_BREAK (ectx, 0);
- GNUNET_free (rootURI);
- GNUNET_ECRS_namespace_delete (ectx, cfg, &pid);
GNUNET_free (cpy);
GNUNET_free (knvalue);
GNUNET_free (value);
GNUNET_client_connection_destroy (sock);
- GNUNET_RSA_free_key (hk);
+ GNUNET_RSA_free_key (namespace_priv_key);
return NULL;
}
/* restore nblock to avoid re-encryption! */
- memcpy (&knb->nblock,
+ memcpy (&ksb->sblock,
cpy,
size - sizeof (GNUNET_EC_KBlock) - sizeof (unsigned int));
}
GNUNET_free (cpy);
}
+ rootURI = GNUNET_malloc (sizeof (URI));
+ rootURI->type = sks;
+ GNUNET_hash (&sb->subspace,
+ sizeof (GNUNET_RSA_PublicKey), &rootURI->data.sks.namespace);
+ rootURI->data.sks.identifier = GNUNET_strdup (rootEntry);
GNUNET_free (knvalue);
GNUNET_free (value);
GNUNET_client_connection_destroy (sock);
- GNUNET_RSA_free_key (hk);
+ GNUNET_RSA_free_key (namespace_priv_key);
return rootURI;
}
+static struct GNUNET_RSA_PrivateKey *
+read_namespace_key (struct GNUNET_GC_Configuration *cfg,
+ const GNUNET_HashCode * pid)
+{
+ char *fileName;
+ GNUNET_RSA_PrivateKeyEncoded *hke;
+ struct GNUNET_RSA_PrivateKey *hk;
+ char *dst;
+ unsigned long long len;
+
+ fileName = getPseudonymFileName (NULL, cfg, pid);
+ if (GNUNET_OK != GNUNET_disk_file_size (NULL, fileName, &len, GNUNET_YES))
+ {
+ GNUNET_free (fileName);
+ return NULL;
+ }
+ if (len < 2)
+ {
+ GNUNET_GE_LOG (NULL, GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
+ _("File `%s' does not contain a pseudonym.\n"),
+ fileName);
+ GNUNET_free (fileName);
+ return NULL;
+ }
+ dst = GNUNET_malloc (len);
+ len = GNUNET_disk_file_read (NULL, fileName, len, dst);
+ hke = (GNUNET_RSA_PrivateKeyEncoded *) dst;
+ if (ntohs (hke->len) != len)
+ {
+ GNUNET_GE_LOG (NULL, GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
+ _("Format of pseudonym `%s' is invalid.\n"), fileName);
+ GNUNET_free (fileName);
+ GNUNET_free (hke);
+ return NULL;
+ }
+ GNUNET_free (fileName);
+ hk = GNUNET_RSA_decode_key (hke);
+ GNUNET_free (hke);
+ return hk;
+}
+
+
/**
* Add an entry into a namespace.
*
@@ -354,10 +402,8 @@
unsigned int anonymityLevel,
unsigned int priority,
GNUNET_CronTime expiration,
- GNUNET_Int32Time creationTime,
- GNUNET_Int32Time updateInterval,
- const GNUNET_HashCode * thisId,
- const GNUNET_HashCode * nextId,
+ const char *thisId,
+ const char *nextId,
const struct GNUNET_ECRS_URI *dstU,
const struct GNUNET_MetaData *md)
{
@@ -368,117 +414,68 @@
unsigned int mdsize;
struct GNUNET_RSA_PrivateKey *hk;
GNUNET_EC_SBlock *sb;
- GNUNET_HashCode namespace;
char *dstURI;
char *destPos;
- char *fileName;
- GNUNET_RSA_PrivateKeyEncoded *hke;
- char *dst;
- unsigned long long len;
- GNUNET_HashCode hc;
+ GNUNET_HashCode hc; /* hash of thisId = key */
+ GNUNET_HashCode hc2; /* hash of hc = identifier */
int ret;
+ unsigned int nidlen;
- /* FIRST: read pseudonym! */
- fileName = getPseudonymFileName (ectx, cfg, pid);
- if (GNUNET_OK != GNUNET_disk_file_size (ectx, fileName, &len, GNUNET_YES))
- {
- GNUNET_free (fileName);
- return NULL;
- }
- if (len < 2)
- {
- GNUNET_GE_LOG (ectx, GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
- _("File `%s' does not contain a pseudonym.\n"),
- fileName);
- GNUNET_free (fileName);
- return NULL;
- }
- dst = GNUNET_malloc (len);
- len = GNUNET_disk_file_read (ectx, fileName, len, dst);
- hke = (GNUNET_RSA_PrivateKeyEncoded *) dst;
- if (ntohs (hke->len) != len)
- {
- GNUNET_GE_LOG (ectx, GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
- _("Format of pseudonym `%s' is invalid.\n"), fileName);
- GNUNET_free (fileName);
- GNUNET_free (hke);
- return NULL;
- }
- GNUNET_free (fileName);
- hk = GNUNET_RSA_decode_key (hke);
- GNUNET_free (hke);
+ hk = read_namespace_key (cfg, pid);
if (hk == NULL)
return NULL;
/* THEN: construct GNUNET_EC_SBlock */
dstURI = GNUNET_ECRS_uri_to_string (dstU);
mdsize = GNUNET_meta_data_get_serialized_size (md, GNUNET_SERIALIZE_PART);
- size = mdsize + sizeof (GNUNET_EC_SBlock) + strlen (dstURI) + 1;
+ if (nextId == NULL)
+ nextId = "";
+ nidlen = strlen (nextId) + 1;
+ size = mdsize + sizeof (GNUNET_EC_SBlock) + strlen (dstURI) + 1 + nidlen;
if (size > MAX_SBLOCK_SIZE)
{
size = MAX_SBLOCK_SIZE;
- value = GNUNET_malloc (sizeof (GNUNET_DatastoreValue) + size);
- sb = (GNUNET_EC_SBlock *) & value[1];
- sb->type = htonl (GNUNET_ECRS_BLOCKTYPE_SIGNED);
- destPos = (char *) &sb[1];
- memcpy (destPos, dstURI, strlen (dstURI) + 1);
- mdsize = size - sizeof (GNUNET_EC_SBlock) - strlen (dstURI) - 1;
- mdsize = GNUNET_meta_data_serialize (ectx,
- md,
- &destPos[strlen (dstURI) + 1],
- mdsize, GNUNET_SERIALIZE_PART);
- if (mdsize == -1)
- {
- GNUNET_GE_BREAK (ectx, 0);
- GNUNET_free (dstURI);
- GNUNET_RSA_free_key (hk);
- GNUNET_free (value);
- return NULL;
- }
- size = sizeof (GNUNET_EC_SBlock) + mdsize + strlen (dstURI) + 1;
+ mdsize =
+ size - (sizeof (GNUNET_EC_SBlock) + strlen (dstURI) + 1 + nidlen);
}
- else
+ value = GNUNET_malloc (sizeof (GNUNET_DatastoreValue) + size);
+ sb = (GNUNET_EC_SBlock *) & value[1];
+ sb->type = htonl (GNUNET_ECRS_BLOCKTYPE_SIGNED);
+ destPos = (char *) &sb[1];
+ memcpy (destPos, nextId, nidlen);
+ destPos += nidlen;
+ memcpy (destPos, dstURI, strlen (dstURI) + 1);
+ destPos += strlen (dstURI) + 1;
+ mdsize = GNUNET_meta_data_serialize (ectx,
+ md,
+ destPos,
+ mdsize, GNUNET_SERIALIZE_PART);
+ if (mdsize == -1)
{
- value = GNUNET_malloc (sizeof (GNUNET_DatastoreValue) + size);
- sb = (GNUNET_EC_SBlock *) & value[1];
- sb->type = htonl (GNUNET_ECRS_BLOCKTYPE_SIGNED);
- destPos = (char *) &sb[1];
- memcpy (destPos, dstURI, strlen (dstURI) + 1);
- GNUNET_meta_data_serialize (ectx,
- md,
- &destPos[strlen (dstURI) + 1],
- mdsize, GNUNET_SERIALIZE_FULL);
+ GNUNET_GE_BREAK (ectx, 0);
+ GNUNET_free (dstURI);
+ GNUNET_RSA_free_key (hk);
+ GNUNET_free (value);
+ return NULL;
}
+ size = sizeof (GNUNET_EC_SBlock) + mdsize + strlen (dstURI) + 1 + nidlen;
value->size = htonl (sizeof (GNUNET_DatastoreValue) + size);
value->type = htonl (GNUNET_ECRS_BLOCKTYPE_SIGNED);
value->priority = htonl (priority);
value->anonymity_level = htonl (anonymityLevel);
value->expiration_time = GNUNET_htonll (expiration);
-
- /* update GNUNET_EC_SBlock specific data */
- sb->creationTime = htonl (creationTime);
- sb->updateInterval = htonl (updateInterval);
- sb->nextIdentifier = *nextId;
-
- GNUNET_hash_difference (thisId, nextId, &sb->identifierIncrement);
- GNUNET_hash (thisId, sizeof (GNUNET_HashCode), &hc);
- GNUNET_RSA_get_public_key (hk, &sb->subspace);
- GNUNET_hash (&sb->subspace, sizeof (GNUNET_RSA_PublicKey), &namespace);
- GNUNET_hash_xor (&hc, &namespace, &sb->identifier); /* sb->identifier =
primary key in query! */
-
+ GNUNET_hash (thisId, strlen (thisId), &hc);
+ GNUNET_hash (&hc, sizeof (GNUNET_HashCode), &hc2);
uri = GNUNET_malloc (sizeof (URI));
uri->type = sks;
- uri->data.sks.namespace = namespace;
- uri->data.sks.identifier = *thisId;
-
- GNUNET_ECRS_encryptInPlace (thisId,
- &sb->creationTime,
- size
- - sizeof (unsigned int)
- - sizeof (GNUNET_RSA_Signature)
- - sizeof (GNUNET_RSA_PublicKey) -
- sizeof (GNUNET_HashCode));
- /* FINALLY: GNUNET_RSA_sign & publish GNUNET_EC_SBlock */
+ GNUNET_RSA_get_public_key (hk, &sb->subspace);
+ GNUNET_hash (&sb->subspace,
+ sizeof (GNUNET_RSA_PublicKey), &uri->data.sks.namespace);
+ GNUNET_GE_BREAK (ectx, 0 == memcmp (&uri->data.sks.namespace,
+ pid, sizeof (GNUNET_HashCode)));
+ uri->data.sks.identifier = GNUNET_strdup (thisId);
+ GNUNET_hash_xor (&hc2, &uri->data.sks.namespace, &sb->identifier);
+ GNUNET_ECRS_encryptInPlace (&hc, &sb[1], size - sizeof (GNUNET_EC_SBlock));
GNUNET_GE_ASSERT (ectx,
GNUNET_OK == GNUNET_RSA_sign (hk,
size
@@ -491,7 +488,6 @@
&sb->identifier,
&sb->signature));
GNUNET_RSA_free_key (hk);
-
sock = GNUNET_client_connection_create (ectx, cfg);
ret = GNUNET_FS_insert (sock, value);
if (ret != GNUNET_OK)
Modified: GNUnet/src/applications/fs/ecrs/namespacetest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespacetest.c 2008-06-07 04:37:48 UTC
(rev 7061)
+++ GNUnet/src/applications/fs/ecrs/namespacetest.c 2008-06-07 06:00:59 UTC
(rev 7062)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2005, 2006 Christian Grothoff (and other contributing authors)
+ (C) 2005, 2006, 2008 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
@@ -66,42 +66,33 @@
testNamespace ()
{
GNUNET_HashCode pid;
- GNUNET_HashCode root;
- GNUNET_HashCode thisId;
- GNUNET_HashCode nextId;
struct GNUNET_ECRS_URI *adv;
- struct GNUNET_ECRS_URI *uri;
struct GNUNET_ECRS_URI *advURI;
struct GNUNET_ECRS_URI *rootURI;
struct GNUNET_MetaData *meta;
meta = GNUNET_meta_data_create ();
adv = GNUNET_ECRS_keyword_string_to_uri (NULL, "testNamespace");
- GNUNET_hash ("root", 4, &root);
rootURI =
GNUNET_ECRS_namespace_create (NULL,
cfg,
meta,
0, 0,
GNUNET_get_time () +
- 15 * GNUNET_CRON_MINUTES, adv, &root);
- GNUNET_ECRS_uri_get_namespace_from_sks (rootURI, &pid);
+ 15 * GNUNET_CRON_MINUTES, adv, "root");
CHECK (NULL != rootURI);
- GNUNET_hash ("this", 4, &thisId);
- GNUNET_hash ("next", 4, &nextId);
- uri = rootURI; /* just for fun: NS::this advertises NS::root
*/
+ GNUNET_ECRS_uri_get_namespace_from_sks (rootURI, &pid);
advURI = GNUNET_ECRS_namespace_add_content (NULL, cfg, &pid, 1, /*
anonymity */
1000, /* priority */
5 * GNUNET_CRON_MINUTES +
GNUNET_get_time (),
- GNUNET_get_time_int32 (NULL) +
- 300, 0, &thisId, &nextId, uri,
- meta);
+ "this", "next", rootURI, meta);
CHECK (NULL != advURI);
fprintf (stderr, "Starting namespace search...\n");
CHECK (GNUNET_OK == GNUNET_ECRS_search (NULL,
cfg,
- advURI, 1, &spcb, uri, &tt, NULL));
+ advURI, 1, &spcb, rootURI, &tt,
+ NULL));
fprintf (stderr, "Completed namespace search...\n");
CHECK (GNUNET_OK == GNUNET_ECRS_namespace_delete (NULL, cfg, &pid));
CHECK (GNUNET_SYSERR == GNUNET_ECRS_namespace_delete (NULL, cfg, &pid));
Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/applications/fs/ecrs/search.c 2008-06-07 06:00:59 UTC (rev
7062)
@@ -153,13 +153,15 @@
{
GNUNET_HashCode keys[2];
GNUNET_HashCode hk; /* hk = GNUNET_hash(identifier) */
+ GNUNET_HashCode hk2; /* hk2 = GNUNET_hash(hk) */
- GNUNET_hash (&uri->data.sks.identifier, sizeof (GNUNET_HashCode),
- &hk);
- GNUNET_hash_xor (&hk, &uri->data.sks.namespace, &keys[0]); /*
compute routing key r = H(identifier) ^ namespace */
+ GNUNET_hash (uri->data.sks.identifier,
+ strlen (uri->data.sks.identifier), &hk);
+ GNUNET_hash (&hk, sizeof (GNUNET_HashCode), &hk2);
+ /* compute routing key keys[0] = H(key) ^ namespace */
+ GNUNET_hash_xor (&hk2, &uri->data.sks.namespace, &keys[0]);
keys[1] = uri->data.sks.namespace;
- add_search (GNUNET_ECRS_BLOCKTYPE_SIGNED, 2, &keys[0],
&uri->data.sks.identifier, /* identifier = decryption key */
- sqc);
+ add_search (GNUNET_ECRS_BLOCKTYPE_SIGNED, 2, &keys[0], &hk, sqc);
break;
}
case ksk:
@@ -210,89 +212,69 @@
}
/**
- * Compute the "current" ID of an updateable GNUNET_EC_SBlock. Will set the ID
- * of the sblock itself for non-updateable content, the ID of the next
- * identifier for sporadically updated SBlocks and the ID computed from
- * the timing function for periodically updated SBlocks.
- *
- * @param sb the GNUNET_EC_SBlock (must be in plaintext)
- * @param now the time for which the ID should be computed
- * @param c the resulting current ID (set)
+ * We found an GNUNET_EC_SBlock. Decode the meta-data and call
+ * the callback of the SQC with the root-URI for the namespace,
+ * together with the namespace advertisement. Also, if this is
+ * a result with updates, automatically start the search for
+ * updates.
*/
static int
-compute_id_at_time (const GNUNET_EC_SBlock * sb, GNUNET_Int32Time now,
- GNUNET_HashCode * c)
-{
- GNUNET_Int32Time pos;
- GNUNET_HashCode tmp;
- unsigned int iter;
-
- if (ntohl (sb->updateInterval) == SBLOCK_UPDATE_SPORADIC)
- {
- memcpy (c, &sb->nextIdentifier, sizeof (GNUNET_HashCode));
- return GNUNET_OK;
- }
- if (ntohl (sb->updateInterval) == SBLOCK_UPDATE_NONE)
- {
- /* H(N-I)^S is the current routing key, so N-I = k */
- GNUNET_hash_difference (&sb->identifierIncrement, &sb->nextIdentifier,
- c);
- return GNUNET_OK;
- }
- GNUNET_GE_ASSERT (NULL, ntohl (sb->updateInterval) != 0);
- pos = ntohl (sb->creationTime);
- GNUNET_hash_difference (&sb->identifierIncrement, &sb->nextIdentifier, c);
-
- iter =
- (now - (pos + ntohl (sb->updateInterval))) / ntohl (sb->updateInterval);
- if (iter > 0xFFFF)
- /* too many iterators, signal error! */
- return GNUNET_SYSERR;
- while (pos + ntohl (sb->updateInterval) < now)
- {
- pos += ntohl (sb->updateInterval);
- GNUNET_hash_sum (c, &sb->identifierIncrement, &tmp);
- *c = tmp;
- }
- return GNUNET_OK;
-}
-
-/**
- * We found an GNUNET_EC_NBlock. Decode the meta-data and call the callback of
- * the SQC with the root-URI for the namespace, together with the
- * namespace advertisement.
- */
-static int
-process_nblock_result (const GNUNET_EC_NBlock * nb,
+process_sblock_result (const GNUNET_EC_SBlock * sb,
const GNUNET_HashCode * key,
unsigned int size,
struct GNUNET_ECRS_SearchContext *sqc)
{
+ static GNUNET_HashCode allZeros;
struct GNUNET_GE_Context *ectx = sqc->ectx;
GNUNET_ECRS_FileInfo fi;
- struct GNUNET_ECRS_URI uri;
+ struct GNUNET_ECRS_URI updateURI;
int ret;
+ const char *id;
+ const char *uris;
+ unsigned int len;
+ unsigned int off;
+ int isRoot;
- fi.meta = GNUNET_meta_data_deserialize (ectx,
- (const char *) &nb[1],
- size - sizeof (GNUNET_EC_NBlock));
+ len = size - sizeof (GNUNET_EC_SBlock);
+ off = GNUNET_string_buffer_tokenize ((const char *) &sb[1],
+ len, 2, &id, &uris);
+ if (off == 0)
+ {
+ GNUNET_GE_BREAK_OP (ectx, 0); /* sblock malformed */
+ return GNUNET_SYSERR;
+ }
+ fi.meta = GNUNET_meta_data_deserialize (ectx, &id[off], len - off);
if (fi.meta == NULL)
{
- GNUNET_GE_BREAK (ectx, 0); /* nblock malformed */
+ GNUNET_GE_BREAK_OP (ectx, 0); /* sblock malformed */
return GNUNET_SYSERR;
}
- fi.uri = &uri;
- uri.type = sks;
- uri.data.sks.namespace = nb->namespace;
- uri.data.sks.identifier = nb->rootEntry;
+ isRoot = 0 == memcmp (&sb->identifier, &allZeros, sizeof (GNUNET_HashCode));
+ fi.uri = GNUNET_ECRS_string_to_uri (ectx, uris);
+ if (fi.uri == NULL)
+ {
+ GNUNET_GE_BREAK_OP (ectx, 0); /* sblock malformed */
+ GNUNET_meta_data_destroy (fi.meta);
+ return GNUNET_SYSERR;
+ }
if (sqc->spcb != NULL)
{
- ret = sqc->spcb (&fi, key, GNUNET_YES, sqc->spcbClosure);
+ ret = sqc->spcb (&fi, key, isRoot, sqc->spcbClosure);
if (ret == GNUNET_SYSERR)
sqc->aborted = GNUNET_YES;
}
else
ret = GNUNET_OK;
+ if (strlen (id) > 0)
+ {
+ updateURI.type = sks;
+ GNUNET_hash (&sb->subspace,
+ sizeof (GNUNET_RSA_PublicKey),
+ &updateURI.data.sks.namespace);
+ updateURI.data.sks.identifier = GNUNET_strdup (id);
+ add_search_for_uri (&updateURI, sqc);
+ GNUNET_free (updateURI.data.sks.identifier);
+ }
GNUNET_meta_data_destroy (fi.meta);
return ret;
}
@@ -331,7 +313,7 @@
&value[1], GNUNET_YES,
&query))
{
- GNUNET_GE_BREAK (NULL, 0);
+ GNUNET_GE_BREAK_OP (NULL, 0);
return GNUNET_SYSERR;
}
if (!((0 == memcmp (&query,
@@ -361,7 +343,7 @@
if (size < sizeof (GNUNET_EC_KBlock))
{
- GNUNET_GE_BREAK (NULL, 0);
+ GNUNET_GE_BREAK_OP (NULL, 0);
return GNUNET_SYSERR;
}
kb = GNUNET_malloc (size);
@@ -382,7 +364,7 @@
j++;
if (j == size)
{
- GNUNET_GE_BREAK (ectx, 0); /* kblock malformed */
+ GNUNET_GE_BREAK_OP (ectx, 0); /* kblock malformed */
GNUNET_free (kb);
return GNUNET_SYSERR;
}
@@ -393,14 +375,14 @@
kb)[j], size - j);
if (fi.meta == NULL)
{
- GNUNET_GE_BREAK (ectx, 0); /* kblock malformed */
+ GNUNET_GE_BREAK_OP (ectx, 0); /* kblock malformed */
GNUNET_free (kb);
return GNUNET_SYSERR;
}
fi.uri = GNUNET_ECRS_string_to_uri (ectx, dstURI);
if (fi.uri == NULL)
{
- GNUNET_GE_BREAK (ectx, 0); /* kblock malformed */
+ GNUNET_GE_BREAK_OP (ectx, 0); /* kblock malformed */
GNUNET_meta_data_destroy (fi.meta);
GNUNET_free (kb);
return GNUNET_SYSERR;
@@ -419,126 +401,49 @@
GNUNET_free (kb);
return ret;
}
- case GNUNET_ECRS_BLOCKTYPE_NAMESPACE:
+ case GNUNET_ECRS_BLOCKTYPE_SIGNED:
{
- const GNUNET_EC_NBlock *nb;
+ GNUNET_EC_SBlock *sb;
+ int ret;
- if (size < sizeof (GNUNET_EC_NBlock))
- return GNUNET_SYSERR;
- nb = (const GNUNET_EC_NBlock *) &value[1];
- return process_nblock_result (nb, NULL, size, sqc);
+ if (size < sizeof (GNUNET_EC_SBlock))
+ {
+ GNUNET_GE_BREAK_OP (ectx, 0); /* sblock malformed */
+ return GNUNET_SYSERR;
+ }
+ sb = GNUNET_malloc (size);
+ memcpy (sb, &value[1], size);
+ GNUNET_ECRS_decryptInPlace (&ps->decryptKey,
+ &sb[1], size - sizeof (GNUNET_EC_SBlock));
+ ret = process_sblock_result (sb, &ps->decryptKey, size, sqc);
+ GNUNET_free (sb);
+ return ret;
}
- case GNUNET_ECRS_BLOCKTYPE_KEYWORD_FOR_NAMESPACE:
+ case GNUNET_ECRS_BLOCKTYPE_KEYWORD_SIGNED:
{
- GNUNET_EC_KNBlock *kb;
+ GNUNET_EC_KSBlock *kb;
int ret;
- if (size < sizeof (GNUNET_EC_KNBlock))
- return GNUNET_SYSERR;
+ if (size < sizeof (GNUNET_EC_KSBlock))
+ {
+ GNUNET_GE_BREAK_OP (ectx, 0); /* ksblock malformed */
+ return GNUNET_SYSERR;
+ }
kb = GNUNET_malloc (size);
memcpy (kb, &value[1], size);
GNUNET_ECRS_decryptInPlace (&ps->decryptKey,
- &kb->nblock,
+ &kb->sblock,
size - sizeof (GNUNET_EC_KBlock) -
sizeof (unsigned int));
ret =
- process_nblock_result (&kb->nblock, &ps->decryptKey,
- size - sizeof (GNUNET_EC_KNBlock) +
- sizeof (GNUNET_EC_NBlock), sqc);
+ process_sblock_result (&kb->sblock, &ps->decryptKey,
+ size - sizeof (GNUNET_EC_KSBlock) +
+ sizeof (GNUNET_EC_SBlock), sqc);
GNUNET_free (kb);
return ret;
}
- case GNUNET_ECRS_BLOCKTYPE_SIGNED:
- {
- GNUNET_EC_SBlock *sb;
- const char *dstURI;
- int j;
- GNUNET_Int32Time now;
- GNUNET_HashCode updateId;
- URI updateURI;
-
- if (size < sizeof (GNUNET_EC_SBlock))
- return GNUNET_SYSERR;
- sb = GNUNET_malloc (size);
- memcpy (sb, &value[1], size);
- GNUNET_ECRS_decryptInPlace (&ps->decryptKey,
- &sb->creationTime,
- size
- - sizeof (unsigned int)
- - sizeof (GNUNET_RSA_Signature)
- - sizeof (GNUNET_RSA_PublicKey)
- - sizeof (GNUNET_HashCode));
- j = 0;
- dstURI = (const char *) &sb[1];
- while ((j < size - sizeof (GNUNET_EC_SBlock)) && (dstURI[j] != '\0'))
- j++;
- if (j == size - sizeof (GNUNET_EC_SBlock))
- {
- GNUNET_GE_BREAK (ectx, 0); /* sblock malformed */
- GNUNET_free (sb);
- return GNUNET_SYSERR;
- }
- j++;
- /* j == strlen(dstURI) + 1 */
- fi.meta = GNUNET_meta_data_deserialize (ectx,
- &dstURI[j],
- size - j -
- sizeof (GNUNET_EC_SBlock));
- if (fi.meta == NULL)
- {
- GNUNET_GE_BREAK (ectx, 0); /* sblock malformed */
- GNUNET_free (sb);
- return GNUNET_SYSERR;
- }
- fi.uri = GNUNET_ECRS_string_to_uri (ectx, dstURI);
- if (fi.uri == NULL)
- {
- GNUNET_GE_BREAK (ectx, 0); /* sblock malformed */
- GNUNET_meta_data_destroy (fi.meta);
- GNUNET_free (sb);
- return GNUNET_SYSERR;
- }
- if (sqc->spcb != NULL)
- {
- ret = sqc->spcb (&fi, NULL, GNUNET_NO, sqc->spcbClosure);
- if (ret == GNUNET_SYSERR)
- sqc->aborted = GNUNET_YES;
- }
- else
- ret = GNUNET_OK;
- GNUNET_ECRS_uri_destroy (fi.uri);
- GNUNET_meta_data_destroy (fi.meta);
-
- /* compute current/NEXT URI (if updateable GNUNET_EC_SBlock) and issue
- respective query automatically! */
- GNUNET_get_time_int32 (&now);
- if (GNUNET_OK != compute_id_at_time (sb, now, &updateId))
- {
- GNUNET_free (sb);
- return GNUNET_SYSERR;
- }
- if (0 ==
- memcmp (&updateId, &ps->decryptKey, sizeof (GNUNET_HashCode)))
- {
- GNUNET_free (sb);
- return ret; /* have latest version */
- }
- if (ps->keyCount != 2)
- {
- GNUNET_GE_BREAK (ectx, 0);
- GNUNET_free (sb);
- return GNUNET_SYSERR;
- }
-
- updateURI.type = sks;
- updateURI.data.sks.namespace = ((GNUNET_HashCode *) & ps[1])[1];
- updateURI.data.sks.identifier = updateId;
- add_search_for_uri (&updateURI, sqc);
- GNUNET_free (sb);
- return ret;
- }
default:
- GNUNET_GE_BREAK (ectx, 0);
+ GNUNET_GE_BREAK_OP (ectx, 0);
break;
} /* end switch */
return GNUNET_OK;
Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/applications/fs/ecrs/upload.c 2008-06-07 06:00:59 UTC (rev
7062)
@@ -36,7 +36,6 @@
#include "ecrs.h"
#include "ecrs_core.h"
#include "fs.h"
-#include "uri.h"
#include "tree.h"
#define DEBUG_UPLOAD GNUNET_NO
Modified: GNUnet/src/applications/fs/ecrs/uri.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.c 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/applications/fs/ecrs/uri.c 2008-06-07 06:00:59 UTC (rev
7062)
@@ -161,24 +161,21 @@
* Generate a subspace URI.
*/
static char *
-createSubspaceURI (const GNUNET_HashCode * namespace,
- const GNUNET_HashCode * identifier)
+createSubspaceURI (const GNUNET_HashCode * namespace, const char *identifier)
{
size_t n;
char *ret;
GNUNET_EncName ns;
- GNUNET_EncName id;
n =
- sizeof (GNUNET_EncName) * 2 + strlen (GNUNET_ECRS_URI_PREFIX) +
- strlen (GNUNET_ECRS_SUBSPACE_INFIX) + 1;
+ sizeof (GNUNET_EncName) + strlen (GNUNET_ECRS_URI_PREFIX) +
+ strlen (GNUNET_ECRS_SUBSPACE_INFIX) + 1 + strlen (identifier);
ret = GNUNET_malloc (n);
GNUNET_hash_to_enc (namespace, &ns);
- GNUNET_hash_to_enc (identifier, &id);
GNUNET_snprintf (ret, n,
"%s%s%s/%s",
GNUNET_ECRS_URI_PREFIX, GNUNET_ECRS_SUBSPACE_INFIX,
- (char *) &ns, (char *) &id);
+ (const char *) &ns, identifier);
return ret;
}
@@ -263,7 +260,7 @@
uri->data.ksk.keywordCount);
case sks:
return createSubspaceURI (&uri->data.sks.namespace,
- &uri->data.sks.identifier);
+ uri->data.sks.identifier);
case chk:
return createFileURI (&uri->data.fi);
case loc:
@@ -492,7 +489,7 @@
static int
parseSubspaceURI (struct GNUNET_GE_Context *ectx,
const char *uri,
- GNUNET_HashCode * namespace, GNUNET_HashCode * identifier)
+ GNUNET_HashCode * namespace, char **identifier)
{
unsigned int pos;
size_t slen;
@@ -522,15 +519,7 @@
GNUNET_free (up);
return GNUNET_SYSERR;
}
- if ((slen != pos + 2 * sizeof (GNUNET_EncName) - 1) ||
- (GNUNET_OK !=
- GNUNET_enc_to_hash (&up[pos + sizeof (GNUNET_EncName)], identifier)))
- {
- if (up[slen - 1] == '\\')
- up[--slen] = '\0';
- GNUNET_hash (&up[pos + sizeof (GNUNET_EncName)],
- slen - (pos + sizeof (GNUNET_EncName)), identifier);
- }
+ *identifier = GNUNET_strdup (&up[pos + sizeof (GNUNET_EncName)]);
GNUNET_free (up);
return GNUNET_OK;
}
@@ -726,6 +715,9 @@
GNUNET_array_grow (uri->data.ksk.keywords, uri->data.ksk.keywordCount,
0);
break;
+ case sks:
+ GNUNET_free (uri->data.sks.identifier);
+ break;
case loc:
break;
default:
@@ -764,21 +756,19 @@
}
/**
- * Get the content ID of an SKS URI.
+ * Get the content identifier of an SKS URI.
*
- * @return GNUNET_OK on success
+ * @return NULL on error
*/
-int
-GNUNET_ECRS_uri_get_content_hash_from_sks (const struct GNUNET_ECRS_URI *uri,
- GNUNET_HashCode * id)
+char *
+GNUNET_ECRS_uri_get_content_id_from_sks (const struct GNUNET_ECRS_URI *uri)
{
if (!GNUNET_ECRS_uri_test_sks (uri))
{
GNUNET_GE_BREAK (NULL, 0);
- return GNUNET_SYSERR;
+ return NULL;
}
- *id = uri->data.sks.identifier;
- return GNUNET_OK;
+ return GNUNET_strdup (uri->data.sks.identifier);
}
/**
@@ -1029,9 +1019,8 @@
if ((0 == memcmp (&uri1->data.sks.namespace,
&uri2->data.sks.namespace,
sizeof (GNUNET_HashCode))) &&
- (0 == memcmp (&uri1->data.sks.identifier,
- &uri2->data.sks.identifier,
- sizeof (GNUNET_HashCode))))
+ (0 == strcmp (uri1->data.sks.identifier,
+ uri2->data.sks.identifier)))
return GNUNET_YES;
return GNUNET_NO;
Deleted: GNUnet/src/applications/fs/ecrs/uri.h
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.h 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/applications/fs/ecrs/uri.h 2008-06-07 06:00:59 UTC (rev
7062)
@@ -1,31 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004 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 2, 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.
-*/
-
-#ifndef URI_H
-#define URI_H
-
-#include "ecrs_core.h"
-
-/**
- * Generate a file URI.
- */
-char *createFileURI (const GNUNET_EC_FileIdentifier * fi);
-
-#endif
Modified: GNUnet/src/applications/fs/ecrs/uritest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uritest.c 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/applications/fs/ecrs/uritest.c 2008-06-07 06:00:59 UTC (rev
7062)
@@ -170,7 +170,7 @@
uri = GNUNET_ECRS_uri_to_string (ret);
if (0 != strcmp (uri,
-
"gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/TOJB1NAAUVJKJAGQHRHS22N9I8VM32C0ESN4EFS836IT950E1MP7LGC5V2GE3LFO9U4BP23VQPTH8DPIOC2CONT9LM76ULVL00KAHVO"))
+
"gnunet://ecrs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test"))
{
GNUNET_ECRS_uri_destroy (ret);
GNUNET_free (uri);
Modified: GNUnet/src/applications/fs/ecrs_core.c
===================================================================
--- GNUnet/src/applications/fs/ecrs_core.c 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/applications/fs/ecrs_core.c 2008-06-07 06:00:59 UTC (rev
7062)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other
contributing authors)
+ (C) 2001, 2002, 2003, 2004, 2005, 2008 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
@@ -211,50 +211,27 @@
GNUNET_hash (&kb->keyspace, sizeof (GNUNET_RSA_PublicKey), query);
return GNUNET_OK;
}
- case GNUNET_ECRS_BLOCKTYPE_NAMESPACE:
+ case GNUNET_ECRS_BLOCKTYPE_KEYWORD_SIGNED:
{
- const GNUNET_EC_NBlock *nb;
- if (size < sizeof (GNUNET_EC_NBlock))
+ const GNUNET_EC_KSBlock *ks;
+ if (size < sizeof (GNUNET_EC_KSBlock))
{
GNUNET_GE_BREAK (NULL, 0);
return GNUNET_SYSERR;
}
- nb = (const GNUNET_EC_NBlock *) data;
+ ks = (const GNUNET_EC_KSBlock *) data;
if ((verify == GNUNET_YES) &&
- (GNUNET_OK != GNUNET_RSA_verify (&nb->identifier,
- size
- - sizeof (GNUNET_RSA_Signature)
- - sizeof (GNUNET_RSA_PublicKey)
- - sizeof (unsigned int),
- &nb->signature, &nb->subspace)))
- {
- GNUNET_GE_BREAK (NULL, 0);
- return GNUNET_SYSERR;
- }
- *query = nb->namespace; /* XOR with all zeros makes no difference... */
- return GNUNET_OK;
- }
- case GNUNET_ECRS_BLOCKTYPE_KEYWORD_FOR_NAMESPACE:
- {
- const GNUNET_EC_KNBlock *kb;
- if (size < sizeof (GNUNET_EC_KNBlock))
- {
- GNUNET_GE_BREAK (NULL, 0);
- return GNUNET_SYSERR;
- }
- kb = (const GNUNET_EC_KNBlock *) data;
- if ((verify == GNUNET_YES) &&
- ((GNUNET_OK != GNUNET_RSA_verify (&kb->nblock,
+ ((GNUNET_OK != GNUNET_RSA_verify (&ks->sblock,
size
- sizeof (GNUNET_EC_KBlock)
- sizeof (unsigned int),
- &kb->kblock.signature,
- &kb->kblock.keyspace))))
+ &ks->kblock.signature,
+ &ks->kblock.keyspace))))
{
GNUNET_GE_BREAK (NULL, 0);
return GNUNET_SYSERR;
}
- GNUNET_hash (&kb->kblock.keyspace, sizeof (GNUNET_RSA_PublicKey),
+ GNUNET_hash (&ks->kblock.keyspace, sizeof (GNUNET_RSA_PublicKey),
query);
return GNUNET_OK;
}
@@ -320,17 +297,9 @@
if (0 == memcmp (&keys[1], &h, sizeof (GNUNET_HashCode)))
return GNUNET_OK;
return GNUNET_SYSERR;
- case GNUNET_ECRS_BLOCKTYPE_NAMESPACE:
- if (keyCount != 2)
- return GNUNET_SYSERR; /* no match */
- GNUNET_hash (&((const GNUNET_EC_NBlock *) data)->subspace,
- sizeof (GNUNET_RSA_PublicKey), &h);
- if (0 != memcmp (&keys[1], &h, sizeof (GNUNET_HashCode)))
- return GNUNET_SYSERR;
- return GNUNET_OK;
case GNUNET_ECRS_BLOCKTYPE_DATA:
case GNUNET_ECRS_BLOCKTYPE_KEYWORD:
- case GNUNET_ECRS_BLOCKTYPE_KEYWORD_FOR_NAMESPACE:
+ case GNUNET_ECRS_BLOCKTYPE_KEYWORD_SIGNED:
if (keyCount != 1)
GNUNET_GE_BREAK (NULL, 0); /* keyCount should be 1 */
return GNUNET_OK; /* if query matches, everything matches! */
Modified: GNUnet/src/applications/fs/gap/fs.c
===================================================================
--- GNUnet/src/applications/fs/gap/fs.c 2008-06-07 04:37:48 UTC (rev 7061)
+++ GNUnet/src/applications/fs/gap/fs.c 2008-06-07 06:00:59 UTC (rev 7062)
@@ -765,9 +765,8 @@
GNUNET_GE_ASSERT (ectx, sizeof (GNUNET_EC_DBlock) == 4);
GNUNET_GE_ASSERT (ectx, sizeof (GNUNET_EC_IBlock) == 132);
GNUNET_GE_ASSERT (ectx, sizeof (GNUNET_EC_KBlock) == 524);
- GNUNET_GE_ASSERT (ectx, sizeof (GNUNET_EC_SBlock) == 724);
- GNUNET_GE_ASSERT (ectx, sizeof (GNUNET_EC_NBlock) == 716);
- GNUNET_GE_ASSERT (ectx, sizeof (GNUNET_EC_KNBlock) == 1244);
+ GNUNET_GE_ASSERT (ectx, sizeof (GNUNET_EC_SBlock) == 588);
+ GNUNET_GE_ASSERT (ectx, sizeof (GNUNET_EC_KSBlock) == 1116);
if ((-1 == GNUNET_GC_get_configuration_value_number (coreAPI->cfg, "LOAD",
"HARDCPULIMIT", 0, 100000, /* 1000 CPUs!? */
0, /* 0 == no
limit */
Modified: GNUnet/src/applications/fs/namespace/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/namespace/Makefile.am 2008-06-07 04:37:48 UTC
(rev 7061)
+++ GNUnet/src/applications/fs/namespace/Makefile.am 2008-06-07 06:00:59 UTC
(rev 7062)
@@ -14,7 +14,8 @@
$(top_builddir)/src/util/libgnunetutil.la
check_PROGRAMS = \
- namespace_infotest
+ namespace_infotest \
+ namespace_update_test
TESTS = $(check_PROGRAMS)
@@ -27,4 +28,11 @@
$(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
$(top_builddir)/src/util/libgnunetutil.la
+namespace_update_test_SOURCES = \
+ namespace_update_test.c
+namespace_update_test_LDADD = \
+ $(top_builddir)/src/applications/fs/namespace/libgnunetnamespace.la \
+ $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
Modified: GNUnet/src/applications/fs/namespace/info.c
===================================================================
--- GNUnet/src/applications/fs/namespace/info.c 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/applications/fs/namespace/info.c 2008-06-07 06:00:59 UTC (rev
7062)
@@ -46,7 +46,7 @@
GNUNET_CronTime insertExpiration,
const struct GNUNET_MetaData *meta,
const struct GNUNET_ECRS_URI *advertisementURI,
- const GNUNET_HashCode * rootEntry)
+ const char *rootEntry)
{
struct GNUNET_ECRS_URI *ret;
GNUNET_HashCode id;
Modified: GNUnet/src/applications/fs/namespace/namespace_infotest.c
===================================================================
--- GNUnet/src/applications/fs/namespace/namespace_infotest.c 2008-06-07
04:37:48 UTC (rev 7061)
+++ GNUnet/src/applications/fs/namespace/namespace_infotest.c 2008-06-07
06:00:59 UTC (rev 7062)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2005, 2006 Christian Grothoff (and other contributing authors)
+ (C) 2005, 2006, 2008 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
@@ -22,9 +22,6 @@
* @file applications/fs/fsui/namespace_infotest.c
* @brief testcase for namespace_info.c
* @author Christian Grothoff
- *
- * TODO:
- * - more comprehensive testcase!
*/
#include "platform.h"
@@ -37,6 +34,7 @@
static struct GNUNET_GE_Context *ectx;
+
int
main (int argc, char *argv[])
{
@@ -45,8 +43,8 @@
struct GNUNET_ECRS_URI *uri = NULL;
struct GNUNET_ECRS_URI *euri = NULL;
struct GNUNET_MetaData *meta = NULL;
- GNUNET_HashCode root;
GNUNET_HashCode nsid;
+ char *test_root;
int old;
int newVal;
struct GNUNET_GC_Configuration *cfg;
@@ -69,14 +67,13 @@
/* ACTUAL TEST CODE */
meta = GNUNET_meta_data_create ();
GNUNET_meta_data_insert (meta, 0, "test");
- GNUNET_create_random_hash (&root);
uri = GNUNET_NS_namespace_create (ectx,
cfg,
1,
1,
GNUNET_get_time () +
10 * GNUNET_CRON_MINUTES, meta,
- NULL, &root);
+ NULL, "root");
CHECK (uri != NULL);
GNUNET_ECRS_uri_get_namespace_from_sks (uri, &nsid);
old = GNUNET_NS_namespace_list_contents (ectx, cfg, &nsid, NULL, NULL);
@@ -85,11 +82,14 @@
1,
1,
GNUNET_get_time () +
- 10 * GNUNET_CRON_MINUTES, &nsid, 42,
- NULL, &root, NULL, uri, meta);
+ 10 * GNUNET_CRON_MINUTES, &nsid,
+ "this", "next", uri, meta);
CHECK (euri != NULL);
newVal = GNUNET_NS_namespace_list_contents (ectx, cfg, &nsid, NULL, NULL);
CHECK (old < newVal);
+ test_root = GNUNET_NS_namespace_get_root (ectx, cfg, &nsid);
+ CHECK (0 == strcmp (test_root, "root"));
+ GNUNET_free (test_root);
CHECK (GNUNET_OK == GNUNET_NS_namespace_delete (ectx, cfg, &nsid));
/* END OF TEST CODE */
FAILURE:
Added: GNUnet/src/applications/fs/namespace/namespace_update_test.c
===================================================================
--- GNUnet/src/applications/fs/namespace/namespace_update_test.c
(rev 0)
+++ GNUnet/src/applications/fs/namespace/namespace_update_test.c
2008-06-07 06:00:59 UTC (rev 7062)
@@ -0,0 +1,169 @@
+/*
+ This file is part of GNUnet.
+ (C) 2005, 2006, 2008 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 2, 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 applications/fs/fsui/namespace_infotest.c
+ * @brief testcase for namespace_info.c
+ * @author Christian Grothoff
+ *
+ * TODO:
+ * - test insertion of content
+ * - computation of next identifier,
+ * - publication of updated content
+ * - search under original key (add search URI)
+ * - finding of updated content (add code to validate!)
+ */
+
+#include "platform.h"
+#include "gnunet_util.h"
+#include "gnunet_ecrs_lib.h"
+#include "gnunet_fsui_lib.h"
+#include "gnunet_namespace_lib.h"
+
+#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GNUNET_GE_BREAK(ectx, 0); goto
FAILURE; }
+
+static struct GNUNET_GE_Context *ectx;
+
+static char *root;
+
+static int
+iter (void *cls,
+ const GNUNET_ECRS_FileInfo * uri,
+ const char *lastId, const char *nextId)
+{
+ char **res = cls;
+ if (0 == strcmp (lastId, root))
+ (*res) = GNUNET_strdup (nextId);
+ return GNUNET_OK;
+}
+
+static void *
+eventProc (void *unused, const GNUNET_FSUI_Event * event)
+{
+ if (event->type != GNUNET_FSUI_search_result)
+ return NULL;
+ /* check if we got the desired result! */
+ return NULL;
+}
+
+int
+main (int argc, char *argv[])
+{
+ pid_t daemon;
+ int ok;
+ struct GNUNET_ECRS_URI *uri = NULL;
+ struct GNUNET_ECRS_URI *euri = NULL;
+ struct GNUNET_ECRS_URI *furi = NULL;
+ struct GNUNET_ECRS_URI *suri = NULL;
+ struct GNUNET_MetaData *meta = NULL;
+ GNUNET_HashCode nsid;
+ char *thisId;
+ struct GNUNET_FSUI_Context *ctx = NULL;
+ struct GNUNET_GC_Configuration *cfg;
+ struct GNUNET_FSUI_SearchList *sl = NULL;
+
+ if (1)
+ return 0; /* test disabled for now */
+ GNUNET_disable_entropy_gathering ();
+ cfg = GNUNET_GC_create ();
+ if (-1 == GNUNET_GC_parse_configuration (cfg, "check.conf"))
+ {
+ GNUNET_GC_free (cfg);
+ return -1;
+ }
+ daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
+ GNUNET_GE_ASSERT (NULL, daemon > 0);
+ CHECK (GNUNET_OK ==
+ GNUNET_wait_for_daemon_running (NULL, cfg,
+ 30 * GNUNET_CRON_SECONDS));
+ ok = GNUNET_YES;
+ GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS); /* give apps time to
start */
+
+ /* ACTUAL TEST CODE */
+ meta = GNUNET_meta_data_create ();
+ GNUNET_meta_data_insert (meta, 0, "test");
+ uri = GNUNET_NS_namespace_create (ectx,
+ cfg,
+ 1,
+ 1,
+ GNUNET_get_time () +
+ 10 * GNUNET_CRON_MINUTES, meta,
+ NULL, "root");
+ CHECK (uri != NULL);
+ GNUNET_ECRS_uri_get_namespace_from_sks (uri, &nsid);
+ /* publish original file */
+ euri = GNUNET_NS_add_to_namespace (ectx,
+ cfg,
+ 1,
+ 1,
+ GNUNET_get_time () +
+ 10 * GNUNET_CRON_MINUTES, &nsid,
+ "this", "next", uri, meta);
+ CHECK (euri != NULL);
+ /* get automatically selected "nextID" of original publication */
+ thisId = NULL;
+ GNUNET_NS_namespace_list_contents (ectx, cfg, &nsid, &iter, &thisId);
+ CHECK (0 != strcmp ("next", thisId));
+ /* publish update */
+ furi = GNUNET_NS_add_to_namespace (ectx,
+ cfg,
+ 1,
+ 1,
+ GNUNET_get_time () +
+ 10 * GNUNET_CRON_MINUTES, &nsid,
+ thisId, "future", euri, meta);
+ CHECK (furi != NULL);
+ /* do namespace search for *original*
+ content; hope to find update! */
+ ctx =
+ GNUNET_FSUI_start (ectx, cfg, "namespace-update-test", 16, GNUNET_NO,
+ &eventProc, NULL);
+ CHECK (ctx != NULL);
+ /* FIXME: generate suri! */
+ sl = GNUNET_FSUI_search_start (ctx, 0, suri);
+ CHECK (sl != NULL);
+ /* wait for results... */
+
+
+ CHECK (GNUNET_OK == GNUNET_NS_namespace_delete (ectx, cfg, &nsid));
+ /* END OF TEST CODE */
+FAILURE:
+ if (uri != NULL)
+ GNUNET_ECRS_uri_destroy (uri);
+ if (euri != NULL)
+ GNUNET_ECRS_uri_destroy (euri);
+ if (furi != NULL)
+ GNUNET_ECRS_uri_destroy (furi);
+ if (suri != NULL)
+ GNUNET_ECRS_uri_destroy (suri);
+ if (meta != NULL)
+ GNUNET_meta_data_destroy (meta);
+ if (sl != NULL)
+ GNUNET_FSUI_search_stop (sl);
+ if (ctx != NULL)
+ GNUNET_FSUI_stop (ctx);
+ GNUNET_ECRS_namespace_delete (ectx, cfg, &nsid);
+
+ GNUNET_GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
+ GNUNET_GC_free (cfg);
+ return (ok == GNUNET_YES) ? 0 : 1;
+}
+
+/* end of namespace_infotest.c */
Modified: GNUnet/src/applications/fs/namespace/root_info.c
===================================================================
--- GNUnet/src/applications/fs/namespace/root_info.c 2008-06-07 04:37:48 UTC
(rev 7061)
+++ GNUnet/src/applications/fs/namespace/root_info.c 2008-06-07 06:00:59 UTC
(rev 7062)
@@ -26,30 +26,42 @@
#include "platform.h"
#include "gnunet_directories.h"
+#include "gnunet_ecrs_lib.h"
#include "gnunet_namespace_lib.h"
#include "gnunet_util.h"
#include "common.h"
/**
* Get the root of the namespace (if we have one).
- * @return GNUNET_SYSERR on error, GNUNET_OK on success
+ *
+ * @return NULL on error
*/
-int
+char *
GNUNET_NS_namespace_get_root (struct GNUNET_GE_Context *ectx,
struct GNUNET_GC_Configuration *cfg,
- const GNUNET_HashCode * ns_id,
- GNUNET_HashCode * root)
+ const GNUNET_HashCode * ns_id)
{
char *fn;
- int ret;
+ char *ret;
+ unsigned long long size;
fn = GNUNET_NS_internal_get_data_filename_ (ectx,
cfg, NS_ROOTS_DIR, ns_id, NULL);
- if (sizeof (GNUNET_HashCode)
- == GNUNET_disk_file_read (ectx, fn, sizeof (GNUNET_HashCode), root))
- ret = GNUNET_OK;
- else
- ret = GNUNET_SYSERR;
+ if ((GNUNET_OK !=
+ GNUNET_disk_file_size (ectx, fn, &size, GNUNET_YES)) ||
+ (size == 0) || (size > GNUNET_MAX_BUFFER_SIZE))
+ {
+ GNUNET_free (fn);
+ return NULL;
+ }
+ ret = GNUNET_malloc (size + 1);
+ ret[size] = '\0';
+ if (size != GNUNET_disk_file_read (ectx, fn, size, ret))
+ {
+ GNUNET_free (fn);
+ GNUNET_free (ret);
+ return NULL;
+ }
GNUNET_free (fn);
return ret;
}
@@ -59,9 +71,9 @@
struct GNUNET_GC_Configuration *cfg,
const struct GNUNET_ECRS_URI *uri)
{
+ GNUNET_HashCode ns;
char *fn;
- GNUNET_HashCode ns;
- GNUNET_HashCode rt;
+ char *root;
if (GNUNET_OK != GNUNET_ECRS_uri_get_namespace_from_sks (uri, &ns))
{
@@ -70,8 +82,12 @@
}
fn = GNUNET_NS_internal_get_data_filename_ (ectx,
cfg, NS_ROOTS_DIR, &ns, NULL);
- if (GNUNET_OK == GNUNET_ECRS_uri_get_content_hash_from_sks (uri, &rt))
- GNUNET_disk_file_write (ectx, fn, &rt, sizeof (GNUNET_HashCode), "644");
+ root = GNUNET_ECRS_uri_get_content_id_from_sks (uri);
+ if (root != NULL)
+ {
+ GNUNET_disk_file_write (ectx, fn, root, strlen (root), "644");
+ GNUNET_free (root);
+ }
GNUNET_free (fn);
}
Modified: GNUnet/src/applications/fs/namespace/update_info.c
===================================================================
--- GNUnet/src/applications/fs/namespace/update_info.c 2008-06-07 04:37:48 UTC
(rev 7061)
+++ GNUnet/src/applications/fs/namespace/update_info.c 2008-06-07 06:00:59 UTC
(rev 7062)
@@ -30,15 +30,6 @@
#include "gnunet_util.h"
#include "common.h"
-
-struct UpdateData
-{
- GNUNET_Int32Time updateInterval;
- GNUNET_Int32Time lastPubTime;
- GNUNET_HashCode nextId;
- GNUNET_HashCode thisId;
-};
-
/**
* Read content update information about content
* published in the given namespace under 'lastId'.
@@ -50,29 +41,27 @@
read_update_data (struct GNUNET_GE_Context *ectx,
struct GNUNET_GC_Configuration *cfg,
const GNUNET_HashCode * nsid,
- const GNUNET_HashCode * lastId,
- GNUNET_HashCode * nextId,
- GNUNET_ECRS_FileInfo * fi,
- GNUNET_Int32Time * updateInterval,
- GNUNET_Int32Time * lastPubTime)
+ const GNUNET_HashCode * lid,
+ char **thisId, char **nextId, GNUNET_ECRS_FileInfo * fi)
{
char *fn;
- struct UpdateData *buf;
- char *uri;
+ char *buf;
unsigned long long size;
- size_t pos;
+ unsigned int pos;
+ const char *pthis;
+ const char *pnext;
+ const char *puri;
fn = GNUNET_NS_internal_get_data_filename_ (ectx,
- cfg,
- NS_UPDATE_DIR, nsid, lastId);
+ cfg, NS_UPDATE_DIR, nsid, lid);
if (GNUNET_OK != GNUNET_disk_file_size (ectx, fn, &size, GNUNET_YES))
{
GNUNET_free (fn);
return GNUNET_SYSERR;
}
- if ((size == 0) ||
- (size <= sizeof (struct UpdateData)) || (size > 1024 * 1024 * 16))
+ if ((size == 0) || (size > 1024 * 1024 * 16))
{
+ UNLINK (fn);
GNUNET_free (fn);
return GNUNET_SYSERR;
}
@@ -80,38 +69,28 @@
if (size != GNUNET_disk_file_read (ectx, fn, size, buf))
{
GNUNET_free (buf);
+ UNLINK (fn);
GNUNET_free (fn);
return GNUNET_SYSERR;
}
GNUNET_free (fn);
- if (0 != memcmp (lastId, &buf->thisId, sizeof (GNUNET_HashCode)))
+ pos = GNUNET_string_buffer_tokenize (buf, size, 3, &pthis, &pnext, &puri);
+ if (pos == 0)
{
+ GNUNET_GE_BREAK (NULL, 0);
GNUNET_free (buf);
return GNUNET_SYSERR;
}
- uri = (char *) &buf[1];
- size -= sizeof (struct UpdateData);
- pos = 0;
- while ((pos < size) && (uri[pos] != '\0'))
- pos++;
- pos++;
- size -= pos;
- if (size == 0)
- {
- GNUNET_free (buf);
- GNUNET_GE_BREAK (ectx, 0);
- return GNUNET_SYSERR;
- }
if (fi != NULL)
{
- fi->meta = GNUNET_meta_data_deserialize (ectx, &uri[pos], size);
+ fi->meta = GNUNET_meta_data_deserialize (ectx, &buf[pos], size - pos);
if (fi->meta == NULL)
{
GNUNET_free (buf);
GNUNET_GE_BREAK (ectx, 0);
return GNUNET_SYSERR;
}
- fi->uri = GNUNET_ECRS_string_to_uri (ectx, uri);
+ fi->uri = GNUNET_ECRS_string_to_uri (ectx, puri);
if (fi->uri == NULL)
{
GNUNET_meta_data_destroy (fi->meta);
@@ -121,12 +100,10 @@
return GNUNET_SYSERR;
}
}
- if (updateInterval != NULL)
- *updateInterval = ntohl (buf->updateInterval);
- if (lastPubTime != NULL)
- *lastPubTime = ntohl (buf->lastPubTime);
if (nextId != NULL)
- *nextId = buf->nextId;
+ *nextId = GNUNET_strdup (pnext);
+ if (thisId != NULL)
+ *thisId = GNUNET_strdup (pthis);
GNUNET_free (buf);
return GNUNET_OK;
}
@@ -138,97 +115,49 @@
write_update_data (struct GNUNET_GE_Context *ectx,
struct GNUNET_GC_Configuration *cfg,
const GNUNET_HashCode * nsid,
- const GNUNET_HashCode * thisId,
- const GNUNET_HashCode * nextId,
- const GNUNET_ECRS_FileInfo * fi,
- const GNUNET_Int32Time updateInterval,
- const GNUNET_Int32Time lastPubTime)
+ const char *thisId,
+ const char *nextId, const GNUNET_ECRS_FileInfo * fi)
{
char *fn;
char *uri;
size_t metaSize;
size_t size;
- struct UpdateData *buf;
+ char *buf;
+ unsigned int pos;
+ GNUNET_HashCode tid;
+ if (nextId == NULL)
+ nextId = "";
+ GNUNET_hash (thisId, strlen (thisId), &tid);
uri = GNUNET_ECRS_uri_to_string (fi->uri);
metaSize =
GNUNET_meta_data_get_serialized_size (fi->meta, GNUNET_SERIALIZE_FULL);
- size = sizeof (struct UpdateData) + metaSize + strlen (uri) + 1;
+ size = metaSize +
+ GNUNET_string_buffer_fill (NULL, 0, 3, uri, thisId, nextId);
buf = GNUNET_malloc (size);
- buf->nextId = *nextId;
- buf->thisId = *thisId;
- buf->updateInterval = htonl (updateInterval);
- buf->lastPubTime = htonl (lastPubTime);
- memcpy (&buf[1], uri, strlen (uri) + 1);
+ pos = GNUNET_string_buffer_fill (buf, size, 3, thisId, nextId, uri);
+ GNUNET_GE_ASSERT (ectx, pos != 0);
GNUNET_GE_ASSERT (ectx,
metaSize ==
GNUNET_meta_data_serialize (ectx,
fi->meta,
- &((char *)
- &buf[1])[strlen (uri) +
- 1], metaSize,
+ &buf[pos], metaSize,
GNUNET_SERIALIZE_FULL));
GNUNET_free (uri);
fn = GNUNET_NS_internal_get_data_filename_ (ectx,
- cfg,
- NS_UPDATE_DIR, nsid, thisId);
+ cfg, NS_UPDATE_DIR, nsid, &tid);
GNUNET_disk_file_write (ectx, fn, buf, size, "400"); /* no editing, just
deletion */
GNUNET_free (fn);
GNUNET_free (buf);
return GNUNET_OK;
}
-
/**
- * Compute the next ID for peridodically updated content.
- * @param updateInterval MUST be a peridic interval (not NONE or SPORADIC)
- * @param thisId MUST be known to NAMESPACE
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
- */
-int
-GNUNET_NS_compute_next_identifier (struct GNUNET_GE_Context *ectx,
- struct GNUNET_GC_Configuration *cfg,
- const GNUNET_HashCode * nsid,
- const GNUNET_HashCode * lastId,
- const GNUNET_HashCode * thisId,
- GNUNET_Int32Time updateInterval,
- GNUNET_HashCode * nextId)
-{
- GNUNET_HashCode delta;
- GNUNET_CronTime now;
- GNUNET_Int32Time tnow;
- GNUNET_Int32Time lastTime;
- GNUNET_Int32Time ui;
-
- if ((updateInterval == GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC) ||
- (updateInterval == GNUNET_ECRS_SBLOCK_UPDATE_NONE))
- return GNUNET_SYSERR;
-
- if (GNUNET_OK != read_update_data (ectx,
- cfg, nsid, lastId, NULL, NULL, &ui,
- &lastTime))
- return GNUNET_SYSERR;
- GNUNET_hash_difference (lastId, thisId, &delta);
- now = GNUNET_get_time ();
- GNUNET_get_time_int32 (&tnow);
- *nextId = *thisId;
- while (lastTime < tnow + updateInterval / 2)
- {
- lastTime += updateInterval;
- GNUNET_hash_sum (nextId, &delta, nextId);
- }
- return GNUNET_OK;
-}
-
-
-/**
* Add an entry into a namespace (also for publishing
* updates).
*
* @param name in which namespace to publish
- * @param updateInterval the desired frequency for updates
- * @param lastId the ID of the last value (maybe NULL)
- * @param thisId the ID of the update (maybe NULL)
+ * @param thisId the ID of the current value
* @param nextId the ID of the next update (maybe NULL)
* @param dst to which URI should the namespace entry refer?
* @param md what meta-data should be associated with the
@@ -242,162 +171,38 @@
unsigned int insertPriority,
GNUNET_CronTime insertExpiration,
const GNUNET_HashCode * nsid,
- GNUNET_Int32Time updateInterval,
- const GNUNET_HashCode * lastId,
- const GNUNET_HashCode * thisId,
- const GNUNET_HashCode * nextId,
+ const char *thisId,
+ const char *nextId,
const struct GNUNET_ECRS_URI *dst,
const struct GNUNET_MetaData *md)
{
- GNUNET_Int32Time creationTime;
- GNUNET_HashCode nid;
- GNUNET_HashCode tid;
- GNUNET_HashCode delta;
- GNUNET_Int32Time now;
- GNUNET_Int32Time lastTime;
- GNUNET_Int32Time lastInterval;
GNUNET_ECRS_FileInfo fi;
- char *old;
struct GNUNET_ECRS_URI *uri;
- /* computation of IDs of update(s). Not as terrible as
- it looks, just enumerating all of the possible cases
- of periodic/sporadic updates and how IDs are computed. */
- creationTime = GNUNET_get_time_int32 (&now);
- if (updateInterval != GNUNET_ECRS_SBLOCK_UPDATE_NONE)
- {
- if ((lastId != NULL) &&
- (GNUNET_OK == read_update_data (ectx,
- cfg,
- nsid,
- lastId,
- &tid, NULL, &lastInterval,
- &lastTime)))
- {
- if (lastInterval != updateInterval)
- {
- GNUNET_GE_LOG (ectx,
- GNUNET_GE_WARNING | GNUNET_GE_BULK |
- GNUNET_GE_USER,
- _
- ("Publication interval for periodic publication
changed."));
- }
- /* try to compute tid and/or
- nid based on information read from lastId */
-
- if (updateInterval != GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC)
- {
- GNUNET_hash_difference (lastId, &tid, &delta);
-
- creationTime = lastTime + updateInterval;
- while (creationTime < now - updateInterval)
- {
- creationTime += updateInterval;
- GNUNET_hash_sum (&tid, &delta, &tid);
- }
- if (creationTime > GNUNET_get_time () + 7 * GNUNET_CRON_DAYS)
- {
- GNUNET_GE_LOG (ectx,
- GNUNET_GE_WARNING | GNUNET_GE_BULK |
- GNUNET_GE_USER,
- _
- ("Publishing update for periodically updated "
- "content more than a week ahead of
schedule.\n"));
- }
- if (thisId != NULL)
- tid = *thisId; /* allow override! */
- GNUNET_hash_sum (&tid, &delta, &nid);
- if (nextId != NULL)
- nid = *nextId; /* again, allow override */
- }
- else
- {
- /* sporadic ones are unpredictable,
- tid has been obtained from IO, pick random nid if
- not specified */
- if (thisId != NULL)
- tid = *thisId; /* allow user override */
- if (nextId == NULL)
- {
- GNUNET_create_random_hash (&nid);
- }
- else
- {
- nid = *nextId;
- }
- }
- }
- else
- { /* no previous ID found or given */
- if (nextId == NULL)
- {
- /* no previous block found and nextId not specified;
- pick random nid */
- GNUNET_create_random_hash (&nid);
- }
- else
- {
- nid = *nextId;
- }
- if (thisId != NULL)
- {
- tid = *thisId;
- }
- else
- {
- GNUNET_create_random_hash (&tid);
- }
- }
- }
- else
- {
- if (thisId != NULL)
- {
- nid = tid = *thisId;
- }
- else
- {
- GNUNET_create_random_hash (&tid);
- nid = tid;
- }
- }
uri = GNUNET_ECRS_namespace_add_content (ectx,
cfg,
nsid,
anonymityLevel,
insertPriority,
insertExpiration,
- creationTime,
- updateInterval, &tid, &nid, dst,
- md);
+ thisId, nextId, dst, md);
if ((uri != NULL) && (dst != NULL))
{
fi.uri = (struct GNUNET_ECRS_URI *) dst;
fi.meta = (struct GNUNET_MetaData *) md;
- write_update_data (ectx,
- cfg,
- nsid, &tid, &nid, &fi, updateInterval, creationTime);
- if (lastId != NULL)
- {
- old = GNUNET_NS_internal_get_data_filename_ (ectx,
- cfg,
- NS_UPDATE_DIR,
- nsid, lastId);
- UNLINK (old);
- GNUNET_free (old);
- }
+ write_update_data (ectx, cfg, nsid, thisId, nextId, &fi);
}
return uri;
}
struct ListNamespaceContentsClosure
{
- GNUNET_HashCode nsid;
+ struct GNUNET_GE_Context *ectx;
+ struct GNUNET_GC_Configuration *cfg;
GNUNET_NS_UpdateIterator it;
void *closure;
+ GNUNET_HashCode nsid;
int cnt;
- struct GNUNET_GE_Context *ectx;
- struct GNUNET_GC_Configuration *cfg;
};
static int
@@ -405,14 +210,12 @@
{
struct ListNamespaceContentsClosure *cls = ptr;
GNUNET_ECRS_FileInfo fi;
- GNUNET_HashCode lastId;
- GNUNET_HashCode nextId;
- GNUNET_Int32Time pubFreq;
- GNUNET_Int32Time lastTime;
- GNUNET_Int32Time nextTime;
- GNUNET_Int32Time now;
+ GNUNET_HashCode lid;
+ char *lastId;
+ char *nextId;
+ int ret;
- if (GNUNET_OK != GNUNET_enc_to_hash (fil, &lastId))
+ if (GNUNET_OK != GNUNET_enc_to_hash (fil, &lid))
{
GNUNET_GE_BREAK (cls->ectx, 0);
return GNUNET_OK;
@@ -421,38 +224,20 @@
fi.meta = NULL;
if (GNUNET_OK != read_update_data (cls->ectx,
cls->cfg,
- &cls->nsid,
- &lastId,
- &nextId, &fi, &pubFreq, &lastTime))
+ &cls->nsid, &lid, &lastId, &nextId, &fi))
{
GNUNET_GE_BREAK (cls->ectx, 0);
return GNUNET_OK;
}
cls->cnt++;
- if (pubFreq == GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC)
- {
- nextTime = 0;
- }
- else
- {
- GNUNET_get_time_int32 (&now);
- nextTime = lastTime;
- if ((nextTime + pubFreq < now) && (nextTime + pubFreq > nextTime))
- nextTime += pubFreq * ((now - nextTime) / pubFreq);
- }
+ ret = GNUNET_OK;
if (cls->it != NULL)
- {
- if (GNUNET_OK != cls->it (cls->closure,
- &fi, &lastId, &nextId, pubFreq, nextTime))
- {
- GNUNET_ECRS_uri_destroy (fi.uri);
- GNUNET_meta_data_destroy (fi.meta);
- return GNUNET_SYSERR;
- }
- }
+ ret = cls->it (cls->closure, &fi, lastId, nextId);
+ GNUNET_free (lastId);
+ GNUNET_free (nextId);
GNUNET_ECRS_uri_destroy (fi.uri);
GNUNET_meta_data_destroy (fi.meta);
- return GNUNET_OK;
+ return ret;
}
/**
Modified: GNUnet/src/applications/fs/namespace/uri.c
===================================================================
--- GNUnet/src/applications/fs/namespace/uri.c 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/applications/fs/namespace/uri.c 2008-06-07 06:00:59 UTC (rev
7062)
@@ -22,12 +22,6 @@
* @file applications/fs/namespace/uri.c
* @brief uri support
* @author Christian Grothoff
- *
- * TODO:
- * - consider remembering the char*-form of the
- * namespace identifier (optionally?)
- * => generate better names when possible!
- * (this would require changes in ECRS!)
*/
#include "platform.h"
@@ -44,11 +38,10 @@
*cfg,
const struct GNUNET_ECRS_URI *uri)
{
- GNUNET_EncName enc;
char *ret;
char *name;
GNUNET_HashCode nsid;
- GNUNET_HashCode chk;
+ char *id;
if (!GNUNET_ECRS_uri_test_sks (uri))
return NULL;
@@ -56,12 +49,12 @@
name = GNUNET_pseudonym_id_to_name (ectx, cfg, &nsid);
if (name == NULL)
return GNUNET_ECRS_uri_to_string (uri);
- GNUNET_ECRS_uri_get_content_hash_from_sks (uri, &chk);
- GNUNET_hash_to_enc (&chk, &enc);
- ret = GNUNET_malloc (strlen (name) + 4 + sizeof (GNUNET_EncName));
+ id = GNUNET_ECRS_uri_get_content_id_from_sks (uri);
+ ret = GNUNET_malloc (strlen (name) + 4 + strlen (id));
strcpy (ret, name);
strcat (ret, ": ");
- strcat (ret, (const char *) &enc);
+ strcat (ret, id);
+ GNUNET_free (id);
return ret;
}
Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c 2008-06-07 04:37:48 UTC
(rev 7061)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c 2008-06-07 06:00:59 UTC
(rev 7062)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other
contributing authors)
+ (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 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
@@ -65,18 +65,12 @@
static unsigned int priority = 365;
-static unsigned int interval = 0;
-
static char *uri_string;
static char *next_id;
static char *this_id;
-static char *prev_id;
-
-static char *creation_time;
-
static char *pseudonym;
static int do_insert;
@@ -85,21 +79,12 @@
static int do_copy;
-static int is_sporadic;
-
static int do_simulate;
static int extract_only;
static int do_disable_creation_time;
-static void
-convertId (const char *s, GNUNET_HashCode * id)
-{
- if ((s != NULL) && (GNUNET_enc_to_hash (s, id) == GNUNET_SYSERR))
- GNUNET_hash (s, strlen (s), id);
-}
-
/**
* We're done with the upload of the file, do the
* post-processing.
@@ -107,18 +92,12 @@
static void
postProcess (const struct GNUNET_ECRS_URI *uri)
{
- GNUNET_HashCode prevId;
- GNUNET_HashCode thisId;
- GNUNET_HashCode nextId;
GNUNET_HashCode nsid;
struct GNUNET_ECRS_URI *nsuri;
char *us;
if (pseudonym == NULL)
return;
- convertId (next_id, &nextId);
- convertId (this_id, &thisId);
- convertId (prev_id, &prevId);
if (GNUNET_OK != GNUNET_pseudonym_name_to_id (ectx, cfg, pseudonym, &nsid))
{
printf (_("\tUnknown namespace `%s'\n"), pseudonym);
@@ -130,11 +109,7 @@
priority,
GNUNET_get_time () +
2 * GNUNET_CRON_YEARS, &nsid,
- (GNUNET_Int32Time) interval,
- prev_id == NULL ? NULL : &prevId,
- this_id == NULL ? NULL : &thisId,
- next_id == NULL ? NULL : &nextId, uri,
- meta);
+ this_id, next_id, uri, meta);
if (nsuri != NULL)
{
us = GNUNET_ECRS_uri_to_string (nsuri);
@@ -296,10 +271,6 @@
0, &GNUNET_getopt_configure_set_one, &extract_only},
GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Make files available to
GNUnet for sharing.")), /* -h */
GNUNET_COMMAND_LINE_OPTION_HOSTNAME, /* -H */
- {'i', "interval", "SECONDS",
- gettext_noop ("set interval for availability of updates to SECONDS"
- " (for namespace insertions only)"),
- 1, &GNUNET_getopt_configure_set_uint, &interval},
{'k', "key", "KEYWORD",
gettext_noop
("add an additional keyword for the top-level file or directory"
@@ -333,26 +304,14 @@
gettext_noop ("only simulte the process but do not do any "
"actual publishing (useful to compute URIs)"),
0, &GNUNET_getopt_configure_set_one, &do_simulate},
- {'S', "sporadic", NULL,
- gettext_noop ("specifies this as an aperiodic but updated publication"
- " (for namespace insertions only)"),
- 0, &GNUNET_getopt_configure_set_one, &is_sporadic},
{'t', "this", "ID",
gettext_noop ("set the ID of this version of the publication"
" (for namespace insertions only)"),
1, &GNUNET_getopt_configure_set_string, &this_id},
- {'T', "time", "TIME",
- gettext_noop
- ("specify creation time for SBlock (see man-page for format)"),
- 1, &GNUNET_getopt_configure_set_string, &creation_time},
{'u', "uri", "URI",
gettext_noop ("URI to be published (can be used instead of passing a "
"file to add keywords to the file with the respective URI)"),
1, &GNUNET_getopt_configure_set_string, &uri_string},
- {'U', "update", "ID",
- gettext_noop ("ID of the previous version of the content"
- " (for namespace update only)"),
- 1, &GNUNET_getopt_configure_set_string, &prev_id},
GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */
GNUNET_COMMAND_LINE_OPTION_VERBOSE,
GNUNET_COMMAND_LINE_OPTION_END,
@@ -459,26 +418,6 @@
errorCode = -1;
goto quit;
}
- if (creation_time != NULL)
- {
- struct tm t;
- const char *fmt;
-
-#if ENABLE_NLS
- fmt = nl_langinfo (D_T_FMT);
-#else
- fmt = "%Y-%m-%d";
-#endif
- if ((NULL == strptime (creation_time, fmt, &t)))
- {
- GNUNET_GE_LOG_STRERROR (ectx,
- GNUNET_GE_FATAL | GNUNET_GE_USER |
- GNUNET_GE_IMMEDIATE, "strptime");
- printf (_("Parsing time failed. Use `%s' format.\n"), fmt);
- errorCode = -1;
- goto quit;
- }
- }
}
else
{ /* ordinary insertion checks */
@@ -490,14 +429,6 @@
errorCode = -1;
goto quit;
}
- if (NULL != prev_id)
- {
- fprintf (stderr,
- _("Option `%s' makes no sense without option `%s'.\n"),
- "-u", "-P");
- errorCode = -1;
- goto quit;
- }
if (NULL != this_id)
{
fprintf (stderr,
@@ -506,22 +437,6 @@
errorCode = -1;
goto quit;
}
- if (0 != interval)
- {
- fprintf (stderr,
- _("Option `%s' makes no sense without option `%s'.\n"),
- "-i", "-P");
- errorCode = -1;
- goto quit;
- }
- if (is_sporadic)
- {
- fprintf (stderr,
- _("Option `%s' makes no sense without option `%s'.\n"),
- "-S", "-P");
- errorCode = -1;
- goto quit;
- }
}
if (uri_string != NULL)
Modified: GNUnet/src/applications/fs/tools/gnunet-pseudonym.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2008-06-07 04:37:48 UTC
(rev 7061)
+++ GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2008-06-07 06:00:59 UTC
(rev 7062)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other
contributing authors)
+ (C) 2002, 2003, 2004, 2005, 2006, 2008 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
@@ -190,9 +190,8 @@
int cnt;
int success;
int i;
- GNUNET_HashCode hc;
GNUNET_HashCode nsid;
- GNUNET_HashCode rootEntry;
+ char *rootEntry;
struct GNUNET_ECRS_URI *rootURI;
char *root;
char *ns_name;
@@ -252,9 +251,7 @@
{
/* FIXME: allow other update policies */
if (GNUNET_OK == GNUNET_CO_collection_start (anonymity,
- priority,
-
GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC,
- meta))
+ priority, meta))
{
printf ("%s", _("Started collection.\n"));
}
@@ -268,12 +265,11 @@
{ /* no collection */
if (root_name == NULL)
{
- memset (&rootEntry, 0, sizeof (GNUNET_HashCode));
+ rootEntry = "root";
}
else
{
- if (GNUNET_SYSERR == GNUNET_enc_to_hash (root_name, &hc))
- GNUNET_hash (root_name, strlen (root_name), &hc);
+ rootEntry = root_name;
}
if (no_advertisement)
{
@@ -294,7 +290,7 @@
expiration +
GNUNET_get_time (),
meta,
- advertisement, &rootEntry);
+ advertisement, rootEntry);
if (rootURI == NULL)
{
printf ("%s", _("Could not create namespace.\n"));
Modified: GNUnet/src/applications/fs/tools/gnunet-unindex.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-unindex.c 2008-06-07 04:37:48 UTC
(rev 7061)
+++ GNUnet/src/applications/fs/tools/gnunet-unindex.c 2008-06-07 06:00:59 UTC
(rev 7062)
@@ -75,9 +75,9 @@
event->data.UnindexCompleted.total,
delta / GNUNET_CRON_SECONDS,
(delta ==
- 0) ? (double) (-1.0) : (double) (event->data.
- UnindexCompleted.total /
- 1024.0 *
+ 0) ? (double) (-1.0) : (double) (event->
+ data.UnindexCompleted.
+ total / 1024.0 *
GNUNET_CRON_SECONDS /
delta));
}
Modified: GNUnet/src/applications/sqstore_mysql/mysql.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysql.c 2008-06-07 04:37:48 UTC
(rev 7061)
+++ GNUnet/src/applications/sqstore_mysql/mysql.c 2008-06-07 06:00:59 UTC
(rev 7062)
@@ -1273,8 +1273,8 @@
if (type != 0)
stmt =
(vhash !=
- NULL) ? dbh->count_entry_by_hash_vhash_and_type : dbh->
- count_entry_by_hash_and_type;
+ NULL) ? dbh->
+ count_entry_by_hash_vhash_and_type : dbh->count_entry_by_hash_and_type;
else
stmt =
(vhash !=
@@ -1416,8 +1416,8 @@
else
stmt =
(vhash !=
- NULL) ? dbh->select_entry_by_hash_and_vhash : dbh->
- select_entry_by_hash;
+ NULL) ? dbh->
+ select_entry_by_hash_and_vhash : dbh->select_entry_by_hash;
if (count == 0)
limit_off = off;
else
Modified: GNUnet/src/applications/testing/remote.c
===================================================================
--- GNUnet/src/applications/testing/remote.c 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/applications/testing/remote.c 2008-06-07 06:00:59 UTC (rev
7062)
@@ -421,8 +421,7 @@
GNUNET_REMOTE_start_daemon (remote_gnunetd_path, "/tmp/",
temp, remote_config_path,
curr_host, ssh_username,
- temp_pos->
- remote_friend_file_path);
+
temp_pos->remote_friend_file_path);
GNUNET_GC_get_configuration_value_number (basecfg,
"NETWORK",
Modified: GNUnet/src/applications/testing/remotetopologies.c
===================================================================
--- GNUnet/src/applications/testing/remotetopologies.c 2008-06-07 04:37:48 UTC
(rev 7061)
+++ GNUnet/src/applications/testing/remotetopologies.c 2008-06-07 06:00:59 UTC
(rev 7062)
@@ -370,15 +370,13 @@
{
fprintf (stderr, ".");
if (GNUNET_YES == GNUNET_IDENTITY_request_connect (sock1,
- &h2->
-
senderIdentity))
+
&h2->senderIdentity))
{
ret = GNUNET_OK;
break;
}
if (GNUNET_YES == GNUNET_IDENTITY_request_connect (sock2,
- &h1->
-
senderIdentity))
+
&h1->senderIdentity))
{
ret = GNUNET_OK;
break;
Modified: GNUnet/src/applications/testing/testing.c
===================================================================
--- GNUnet/src/applications/testing/testing.c 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/applications/testing/testing.c 2008-06-07 06:00:59 UTC (rev
7062)
@@ -277,8 +277,7 @@
{
fprintf (stderr, ".");
if (GNUNET_YES == GNUNET_IDENTITY_request_connect (sock1,
- &h2->
-
senderIdentity))
+
&h2->senderIdentity))
{
ret = GNUNET_OK;
GNUNET_free_non_null (h1);
@@ -286,8 +285,7 @@
break;
}
if (GNUNET_YES == GNUNET_IDENTITY_request_connect (sock2,
- &h1->
-
senderIdentity))
+
&h1->senderIdentity))
{
ret = GNUNET_OK;
GNUNET_free_non_null (h1);
Modified: GNUnet/src/include/ecrs_core.h
===================================================================
--- GNUnet/src/include/ecrs_core.h 2008-06-07 04:37:48 UTC (rev 7061)
+++ GNUnet/src/include/ecrs_core.h 2008-06-07 06:00:59 UTC (rev 7062)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other
contributing authors)
+ (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 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
@@ -34,7 +34,7 @@
#include "gnunet_datastore_service.h"
/**
- * @brief content GNUNET_hash key
+ * @brief content hash key
*/
typedef struct
{
@@ -113,7 +113,8 @@
/* 0-terminated URI here */
- /* variable-size Meta-Data follows here! */
+ /* variable-size Meta-Data follows here
+ (or, in the case of a KSBlock, an SBlock follows) */
} GNUNET_EC_KBlock;
@@ -138,91 +139,40 @@
/* from here on signed */
/**
- * R = H(N-I)^S, used for routing!
+ * R = H(H(I))^S, used for routing, or all zeros for
+ * namespace advertisements (in which case the
+ * 0-terminated update identifier is the name of the
+ * root); the URI will be empty in this case and
+ * no encryption will be used (this type of SBlock
+ * will only be published as the encrypted part of
+ * a KSBlock).
*/
GNUNET_HashCode identifier;
- /* from here on encrypted */
+ /* from here on encrypted (with H(I)) */
- /**
- * Time at which this GNUNET_EC_SBlock was created;
- * in network byte order
- */
- GNUNET_Int32Time creationTime;
+ /* 0-terminated identifier of update follows
+ here; if strlen() == 0, no updates are allowed */
- /**
- * Interval (in seconds) how often the publisher intends to produce
- * an updated GNUNET_EC_SBlock; GNUNET_ECRS_SBLOCK_UPDATE_NONE(0) is used for
- * non-updateable SBlocks, GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC(-1) is used
- * for entries without a fixed update frequency; in network byte
- * order
- */
- GNUNET_Int32Time updateInterval;
+ /* 0-terminated URI (as string) follows here! */
- /**
- * N, the identifier that will be used for the
- * next revision of this GNUNET_EC_SBlock.
- */
- GNUNET_HashCode nextIdentifier;
-
- /**
- * I, the increment between identifiers (used to enable
- * skipping of blocks by appying multiple increments.
- */
- GNUNET_HashCode identifierIncrement;
-
- /* 0-terminated URI follows here! */
-
/* variable-size Meta-Data follows here! */
} GNUNET_EC_SBlock;
-typedef struct
-{
-
- /**
- * Type of the block (NBLOCK), in network byte order.
- */
- unsigned int type;
-
- GNUNET_RSA_Signature signature; /* 256 b */
-
- GNUNET_RSA_PublicKey subspace; /* S = H(subspace); 264 b */
-
- /**
- * Must be all zeros
- */
- GNUNET_HashCode identifier;
-
- /* The REST (from here on) is encrypted! */
-
- /**
- * Identifier of the namespace
- */
- GNUNET_HashCode namespace;
-
- /**
- * Key of an (optional) root entry into the namespace
- * (use all-zeros for not given).
- */
- GNUNET_HashCode rootEntry;
-
- /* variable-size Meta-Data follows here! */
-} GNUNET_EC_NBlock;
-
/**
- * @brief keyword-GNUNET_EC_NBlock (advertising namespace under a keyword)
+ * @brief keyword-GNUNET_EC_SBlock (advertising namespace under a keyword)
*/
typedef struct
{
/**
- * Type of the block (KNBLOCK), in network byte order.
+ * Type of the block (KSBLOCK), in network byte order.
*/
unsigned int type;
GNUNET_EC_KBlock kblock;
- GNUNET_EC_NBlock nblock;
-} GNUNET_EC_KNBlock;
+ GNUNET_EC_SBlock sblock;
+} GNUNET_EC_KSBlock;
/**
* Perform on-demand content encoding.
Modified: GNUnet/src/include/gnunet_collection_lib.h
===================================================================
--- GNUnet/src/include/gnunet_collection_lib.h 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/include/gnunet_collection_lib.h 2008-06-07 06:00:59 UTC (rev
7062)
@@ -55,7 +55,6 @@
*/
int GNUNET_CO_collection_start (unsigned int anonymityLevel,
unsigned int priority,
- GNUNET_Int32Time updateInterval,
const struct GNUNET_MetaData *meta);
/**
@@ -74,19 +73,10 @@
struct GNUNET_MetaData *GNUNET_CO_collection_get_name (void);
/**
- * GNUNET_ND_UPLOAD an update of the current collection information to the
+ * Publish an update of the current collection information to the
* network now. The function has no effect if the collection has not
* changed since the last publication. If we are currently not
* collecting, this function does nothing.
- *
- * Note that clients typically don't have to call this function
- * explicitly. CO will call the function on exit (for sporadically
- * updated collections), on any change to the collection (for
- * immediately updated content) or when the publication time has
- * arrived (for periodically updated collections).
- *
- * However, clients may want to call this function if explicit
- * publication of an update at another time is desired.
*/
void GNUNET_CO_collection_publish_now (void);
@@ -94,12 +84,6 @@
* If we are currently building a collection, publish the given file
* information in that collection. If we are currently not
* collecting, this function does nothing.
- *
- * Note that clients typically don't have to call this function
- * explicitly -- by using the CO library it should be called
- * automatically by CO code whenever needed. However, the function
- * maybe useful if you're inserting files using libECRS directly or
- * need other ways to explicitly extend a collection.
*/
void GNUNET_CO_collection_add_item (const GNUNET_ECRS_FileInfo * fi);
Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/include/gnunet_ecrs_lib.h 2008-06-07 06:00:59 UTC (rev
7062)
@@ -54,6 +54,7 @@
* 4.1.x: with new error and configuration handling
* 5.0.x: with location URIs
* 6.0.0: with support for OR in KSKs
+ * 6.1.x: with simplified namespace support
* 7.0.0: who knows? :-)
*/
#define GNUNET_ECRS_VERSION "6.0.0"
@@ -69,16 +70,7 @@
#define GNUNET_ECRS_FILE_INFIX "chk/"
#define GNUNET_ECRS_LOCATION_INFIX "loc/"
-
/**
- * Fixed GNUNET_EC_SBlock updateInterval codes. Positive values
- * are interpreted as durations (in seconds) for periodical
- * updates.
- */
-#define GNUNET_ECRS_SBLOCK_UPDATE_SPORADIC -1
-#define GNUNET_ECRS_SBLOCK_UPDATE_NONE 0
-
-/**
* Iterator over keywords
*
* @param keyword the keyword
@@ -281,11 +273,14 @@
GNUNET_HashCode * nsid);
/**
- * Get the content ID of an SKS URI.
+ * Get the content identifier of an SKS URI.
+ *
+ * @return NULL on error
*/
-int GNUNET_ECRS_uri_get_content_hash_from_sks (const struct GNUNET_ECRS_URI
- *uri, GNUNET_HashCode * nsid);
+char *GNUNET_ECRS_uri_get_content_id_from_sks (const struct GNUNET_ECRS_URI
+ *uri);
+
/**
* Is this a keyword URI?
*/
@@ -462,8 +457,6 @@
* @param meta meta-data for the namespace advertisement
* @param rootEntry name of the root entry in the namespace (for
* the namespace advertisement)
- * @param rootURI set to the URI of the namespace, NULL if
- * no advertisement was created
*
* @return URI on success, NULL on error (namespace already exists)
*/
@@ -483,8 +476,7 @@
const struct
GNUNET_ECRS_URI
*advertisementURI,
- const GNUNET_HashCode *
- rootEntry);
+ const char *rootEntry);
/**
* Check if the given namespace exists (locally).
@@ -552,16 +544,10 @@
priority,
GNUNET_CronTime
expirationTime,
- GNUNET_Int32Time
- creationTime,
- GNUNET_Int32Time
- updateInterval,
const
- GNUNET_HashCode *
- thisId,
+ char *thisId,
const
- GNUNET_HashCode *
- nextId,
+ char *nextId,
const struct
GNUNET_ECRS_URI
*dst,
Modified: GNUnet/src/include/gnunet_fsui_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fsui_lib.h 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/include/gnunet_fsui_lib.h 2008-06-07 06:00:59 UTC (rev
7062)
@@ -924,7 +924,13 @@
* @param closure extra argument to cb
* @return NULL on error
*/
-struct GNUNET_FSUI_Context *GNUNET_FSUI_start (struct GNUNET_GE_Context *ectx,
struct GNUNET_GC_Configuration *cfg, const char *name, unsigned int
threadPoolSize, int doResume, GNUNET_FSUI_EventProcessor cb, void *closure); /*
fsui.c */
+struct GNUNET_FSUI_Context *GNUNET_FSUI_start (struct GNUNET_GE_Context *ectx,
+ struct GNUNET_GC_Configuration
+ *cfg, const char *name,
+ unsigned int threadPoolSize,
+ int doResume,
+ GNUNET_FSUI_EventProcessor cb,
+ void *closure);
/**
* Stop all processes under FSUI control (may serialize
@@ -939,7 +945,14 @@
*
* @return NULL on error
*/
-struct GNUNET_FSUI_SearchList *GNUNET_FSUI_search_start (struct
GNUNET_FSUI_Context *ctx, unsigned int anonymityLevel, const struct
GNUNET_ECRS_URI *uri); /* search.c */
+struct GNUNET_FSUI_SearchList *GNUNET_FSUI_search_start (struct
+ GNUNET_FSUI_Context
+ *ctx,
+ unsigned int
+ anonymityLevel,
+ const struct
+ GNUNET_ECRS_URI
+ *uri);
/**
* Abort a search.
@@ -974,7 +987,26 @@
*
* @return NULL on error
*/
-struct GNUNET_FSUI_DownloadList *GNUNET_FSUI_download_start (struct
GNUNET_FSUI_Context *ctx, unsigned int anonymityLevel, int doRecursive, const
struct GNUNET_ECRS_URI *uri, const struct GNUNET_MetaData *meta, const char
*filename, struct GNUNET_FSUI_SearchList *parentSearch, struct
GNUNET_FSUI_DownloadList *parentDownload); /* download.c */
+struct GNUNET_FSUI_DownloadList *GNUNET_FSUI_download_start (struct
+
GNUNET_FSUI_Context
+ *ctx,
+ unsigned int
+ anonymityLevel,
+ int doRecursive,
+ const struct
+ GNUNET_ECRS_URI
+ *uri,
+ const struct
+ GNUNET_MetaData
+ *meta,
+ const char
+ *filename,
+ struct
+
GNUNET_FSUI_SearchList
+ *parentSearch,
+ struct
+
GNUNET_FSUI_DownloadList
+ *parentDownload);
/**
* Abort a download. If the dl is for a recursive download, all
Modified: GNUnet/src/include/gnunet_namespace_lib.h
===================================================================
--- GNUnet/src/include/gnunet_namespace_lib.h 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/include/gnunet_namespace_lib.h 2008-06-07 06:00:59 UTC (rev
7062)
@@ -43,19 +43,12 @@
* @param uri URI of the last content published
* @param lastId the ID of the last publication
* @param nextId the ID of the next update
- * @param publicationFrequency how often are updates scheduled?
- * @param nextPublicationTime the scheduled time for the
- * next update (0 for sporadic updates)
* @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
*/
typedef int (*GNUNET_NS_UpdateIterator) (void *cls,
const GNUNET_ECRS_FileInfo * uri,
- const GNUNET_HashCode * lastId,
- const GNUNET_HashCode * nextId,
- GNUNET_Int32Time
- publicationFrequency,
- GNUNET_Int32Time
- nextPublicationTime);
+ const char *lastId,
+ const char *nextId);
/**
* Create a new namespace (and publish an advertismement).
@@ -82,8 +75,7 @@
const struct
GNUNET_ECRS_URI
*advertisementURI,
- const GNUNET_HashCode *
- rootEntry);
+ const char *rootEntry);
/**
* Delete a local namespace. Only prevents future insertions into the
@@ -97,12 +89,11 @@
/**
* Get the root of the namespace (if we have one).
- * @return GNUNET_SYSERR on error, GNUNET_OK on success
+ * @return NULL on error, root on success
*/
-int GNUNET_NS_namespace_get_root (struct GNUNET_GE_Context *ectx,
- struct GNUNET_GC_Configuration *cfg,
- const GNUNET_HashCode * nsid,
- GNUNET_HashCode * root);
+char *GNUNET_NS_namespace_get_root (struct GNUNET_GE_Context *ectx,
+ struct GNUNET_GC_Configuration *cfg,
+ const GNUNET_HashCode * nsid);
void GNUNET_NS_namespace_set_root (struct GNUNET_GE_Context *ectx,
struct GNUNET_GC_Configuration *cfg,
@@ -110,42 +101,16 @@
/**
* Add an entry into a namespace (also for publishing
- * updates). Typical uses are (all others would be odd):
- * <ul>
- * <li>updateInterval NONE, thisId some user-specified value
- * or NULL if user wants system to pick random value;
- * nextId and lastId NULL (irrelevant)</li>
- * <li>updateInterval SPORADIC, thisId given (initial
- * submission), nextId maybe given or NULL,
- * lastId NULL</li>
- * <li>updateInterval SPORADIC, lastId given (either
- * user-provided or from listNamespaceContent
- * iterator); thisId NULL or given (from lNC);
- * nextId maybe given or NULL, depending on user preference</li>
- * <li>updateInterval non-NULL, non-SPORADIC; lastId
- * is NULL (inital submission), thisId non-NULL or
- * rarely NULL (if user does not care about name of
- * starting entry), nextId maybe NULL or not</li>
- * <li>updateInterval non-NULL, non-SPORADIC; lastId
- * is non-NULL (periodic update), thisId NULL (computed!)
- * nextID NULL (computed)</li>
- * </ul>
- * And yes, reading the ECRS paper maybe a good idea.
+ * updates).
*
* @param nsid in which namespace to publish
- * @param updateInterval the desired frequency for updates
- * @param lastId the ID of the last value (maybe NULL)
- * set if this is an update to an existing entry
- * @param thisId the ID of the update (maybe NULL if
- * lastId determines the value or if no specific value
- * is desired)
- * @param nextId the ID of the next update (maybe NULL);
- * set for sporadic updates if a specific next ID is
- * desired
+ * @param thisId the ID of the current value
+ * @param nextId the ID of a possible future update, NULL for
+ * content that can not be updated
* @param dst to which URI should the namespace entry refer?
* @param md what meta-data should be associated with the
* entry?
- * @return the resulting URI, NULL on error
+ * @return the resulting SKS URI, NULL on error
*/
struct GNUNET_ECRS_URI *GNUNET_NS_add_to_namespace (struct GNUNET_GE_Context
*ectx,
@@ -160,34 +125,14 @@
insertExpiration,
const GNUNET_HashCode *
nsid,
- GNUNET_Int32Time
- updateInterval,
- const GNUNET_HashCode *
- lastId,
- const GNUNET_HashCode *
- thisId,
- const GNUNET_HashCode *
- nextId,
+ const char *thisId,
+ const char *nextId,
const struct
GNUNET_ECRS_URI *dst,
const struct
GNUNET_MetaData *md);
/**
- * Compute the next ID for peridodically updated content.
- * @param updateInterval MUST be a peridic interval (not NONE or SPORADIC)
- * @param thisId MUST be known to NS
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
- */
-int GNUNET_NS_compute_next_identifier (struct GNUNET_GE_Context *ectx,
- struct GNUNET_GC_Configuration *cfg,
- const GNUNET_HashCode * nsid,
- const GNUNET_HashCode * lastId,
- const GNUNET_HashCode * thisId,
- GNUNET_Int32Time updateInterval,
- GNUNET_HashCode * nextId);
-
-/**
* List all updateable content in a given namespace.
*/
int GNUNET_NS_namespace_list_contents (struct GNUNET_GE_Context *ectx,
Modified: GNUnet/src/include/gnunet_protocols.h
===================================================================
--- GNUnet/src/include/gnunet_protocols.h 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/include/gnunet_protocols.h 2008-06-07 06:00:59 UTC (rev
7062)
@@ -429,14 +429,9 @@
#define GNUNET_ECRS_BLOCKTYPE_KEYWORD 3
/**
- * Namespace advertisement.
- */
-#define GNUNET_ECRS_BLOCKTYPE_NAMESPACE 4
-
-/**
* Namespace advertisement in keyword space.
*/
-#define GNUNET_ECRS_BLOCKTYPE_KEYWORD_FOR_NAMESPACE 5
+#define GNUNET_ECRS_BLOCKTYPE_KEYWORD_SIGNED 4
/**
* Type of OnDemand encoded blocks.
Modified: GNUnet/src/include/gnunet_util_string.h
===================================================================
--- GNUnet/src/include/gnunet_util_string.h 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/include/gnunet_util_string.h 2008-06-07 06:00:59 UTC (rev
7062)
@@ -254,6 +254,44 @@
const char *filename, int linenumber,
const char *function);
+
+/**
+ * Fill a buffer of the given size with
+ * count 0-terminated strings (given as varargs).
+ * If "buffer" is NULL, only compute the amount of
+ * space required (sum of "strlen(arg)+1").
+ *
+ * Unlike using "snprintf" with "%s", this function
+ * will add 0-terminators after each string. The
+ * "GNUNET_string_buffer_tokenize" function can be
+ * used to parse the buffer back into individual
+ * strings.
+ *
+ * @return number of bytes written to the buffer
+ * (or number of bytes that would have been written)
+ */
+unsigned int GNUNET_string_buffer_fill (char *buffer,
+ unsigned int size,
+ unsigned int count, ...);
+
+/**
+ * Given a buffer of a given size, find "count"
+ * 0-terminated strings in the buffer and assign
+ * the count (varargs) of type "const char**" to the
+ * locations of the respective strings in the
+ * buffer.
+ *
+ * @param buffer the buffer to parse
+ * @param size size of the buffer
+ * @param count number of strings to locate
+ * @return offset of the character after the last 0-termination
+ * in the buffer, or 0 on error.
+ */
+unsigned int GNUNET_string_buffer_tokenize (const char *buffer,
+ unsigned int size,
+ unsigned int count, ...);
+
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c 2008-06-07 04:37:48 UTC (rev 7061)
+++ GNUnet/src/server/connection.c 2008-06-07 06:00:59 UTC (rev 7062)
@@ -721,8 +721,8 @@
if (root->session.tsession != NULL)
GNUNET_GE_ASSERT (NULL,
GNUNET_OK ==
- transport->assert_associated (root->session.
- tsession,
+ transport->assert_associated (root->
+ session.tsession,
__FILE__));
root = root->overflowChain;
}
@@ -1903,8 +1903,8 @@
stats->change (stat_transmitted, p);
be->available_send_window -= p;
be->lastSequenceNumberSend++;
- GNUNET_CORE_connection_reserve_downstream_bandwidth (&be->session.
- sender, 0);
+ GNUNET_CORE_connection_reserve_downstream_bandwidth (&be->
+ session.sender, 0);
if (be->idealized_limit > be->max_transmitted_limit)
be->max_transmitted_limit = be->idealized_limit;
else /* age */
@@ -2484,8 +2484,8 @@
{
IF_GELOG (ectx,
GNUNET_GE_INFO | GNUNET_GE_BULK | GNUNET_GE_USER,
- GNUNET_hash_to_enc (&entries[u]->session.sender.
- hashPubKey, &enc));
+ GNUNET_hash_to_enc (&entries[u]->session.
+ sender.hashPubKey, &enc));
GNUNET_GE_LOG (ectx,
GNUNET_GE_INFO | GNUNET_GE_BULK | GNUNET_GE_USER,
"peer `%s' transmitted above limit: %llu bpm > %u
bpm\n",
@@ -2508,8 +2508,8 @@
#if DEBUG_CONNECTION
IF_GELOG (ectx,
GNUNET_GE_INFO | GNUNET_GE_BULK | GNUNET_GE_DEVELOPER,
- GNUNET_hash_to_enc (&entries[u]->session.sender.
- hashPubKey, &enc));
+ GNUNET_hash_to_enc (&entries[u]->session.
+ sender.hashPubKey, &enc));
GNUNET_GE_LOG (ectx,
GNUNET_GE_INFO | GNUNET_GE_BULK |
GNUNET_GE_DEVELOPER,
@@ -2570,8 +2570,8 @@
for (u = 0; u < activePeerCount; u++)
{
GNUNET_CORE_connection_reserve_downstream_bandwidth (&entries
- [u]->
- session.sender, 0);
+ [u]->session.
+ sender, 0);
entries[u]->idealized_limit = 0;
}
while ((schedulableBandwidth > activePeerCount * 100) &&
@@ -2905,8 +2905,8 @@
IF_GELOG (ectx,
GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
GNUNET_GE_DEVELOPER,
- GNUNET_hash_to_enc (&root->session.sender.
- hashPubKey, &enc));
+ GNUNET_hash_to_enc (&root->session.
+ sender.hashPubKey, &enc));
GNUNET_GE_LOG (ectx,
GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
GNUNET_GE_DEVELOPER,
@@ -3009,8 +3009,8 @@
IF_GELOG (ectx,
GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
GNUNET_GE_DEVELOPER,
- GNUNET_hash_to_enc (&root->session.sender.
- hashPubKey, &enc));
+ GNUNET_hash_to_enc (&root->session.
+ sender.hashPubKey, &enc));
GNUNET_GE_LOG (ectx,
GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
GNUNET_GE_DEVELOPER,
Modified: GNUnet/src/setup/lib/gns.c
===================================================================
--- GNUnet/src/setup/lib/gns.c 2008-06-07 04:37:48 UTC (rev 7061)
+++ GNUnet/src/setup/lib/gns.c 2008-06-07 06:00:59 UTC (rev 7062)
@@ -123,8 +123,8 @@
val = GNUNET_GC_get_configuration_value_yesno (cfg,
section,
option,
- pos->value.Boolean.
- def);
+ pos->value.
+ Boolean.def);
if (val == GNUNET_SYSERR)
{
return GNUNET_SYSERR;
@@ -139,18 +139,9 @@
if (GNUNET_SYSERR == GNUNET_GC_get_configuration_value_number (cfg,
section,
option,
- pos->
- value.
- UInt64.
- min,
- pos->
- value.
- UInt64.
- max,
- pos->
- value.
- UInt64.
- def,
+
pos->value.UInt64.min,
+
pos->value.UInt64.max,
+
pos->value.UInt64.def,
&val))
{
return GNUNET_SYSERR;
@@ -195,10 +186,7 @@
if (GNUNET_SYSERR == GNUNET_GC_get_configuration_value_string (cfg,
section,
option,
- pos->
- value.
- String.
- def,
+
pos->value.String.def,
&val))
return GNUNET_SYSERR;
GNUNET_free (pos->value.String.val);
@@ -215,14 +203,8 @@
(const
char
**)
- pos->
- value.
- String.
-
legalRange,
- pos->
- value.
- String.
- def,
+
pos->value.String.legalRange,
+
pos->value.String.def,
&ival))
return GNUNET_SYSERR;
GNUNET_free (pos->value.String.val);
Modified: GNUnet/src/setup/ncurses/mconf.c
===================================================================
--- GNUnet/src/setup/ncurses/mconf.c 2008-06-07 04:37:48 UTC (rev 7061)
+++ GNUnet/src/setup/ncurses/mconf.c 2008-06-07 06:00:59 UTC (rev 7062)
@@ -179,10 +179,8 @@
case DLG_EXIT_CANCEL:
if (0 != GNUNET_GC_set_configuration_value_string (cfg,
ectx,
- pos->
- section,
- pos->
- option,
+
pos->section,
+
pos->option,
st ==
DLG_EXIT_OK
? "YES" :
@@ -217,12 +215,9 @@
case DLG_EXIT_OK:
if (0 != GNUNET_GC_set_configuration_value_string (cfg,
ectx,
- pos->
- section,
- pos->
- option,
- fitem.
- text))
+
pos->section,
+
pos->option,
+
fitem.text))
{
show_help (pos->option,
gettext_noop
@@ -284,13 +279,9 @@
case DLG_EXIT_OK:
if (0 != GNUNET_GC_set_configuration_value_choice (cfg,
ectx,
- pos->
- section,
- pos->
- option,
- val->
- String.
- legalRange
+
pos->section,
+
pos->option,
+
val->String.legalRange
[msel]))
{
show_help (pos->option,
@@ -369,10 +360,8 @@
tmp[strlen (tmp) - 1] = '\0';
if (0 != GNUNET_GC_set_configuration_value_choice (cfg,
ectx,
- pos->
- section,
- pos->
- option,
+
pos->section,
+
pos->option,
tmp))
{
GNUNET_free (tmp);
@@ -416,12 +405,9 @@
}
if (0 != GNUNET_GC_set_configuration_value_string (cfg,
ectx,
- pos->
- section,
- pos->
- option,
- fitem.
- text))
+
pos->section,
+
pos->option,
+
fitem.text))
{
show_help (pos->option,
gettext_noop
@@ -470,10 +456,8 @@
}
if (0 != GNUNET_GC_set_configuration_value_number (cfg,
ectx,
- pos->
-
section,
- pos->
-
option,
+
pos->section,
+
pos->option,
lval))
{
show_help (pos->option,
Modified: GNUnet/src/transports/http.c
===================================================================
--- GNUnet/src/transports/http.c 2008-06-07 04:37:48 UTC (rev 7061)
+++ GNUnet/src/transports/http.c 2008-06-07 06:00:59 UTC (rev 7062)
@@ -1049,8 +1049,9 @@
cpy = sizeof (GNUNET_MessageHeader) - httpSession->cs.client.rpos1;
if (cpy > have)
cpy = have;
- memcpy (&httpSession->cs.client.
- rbuff1[httpSession->cs.client.rpos1], &inbuf[poff], cpy);
+ memcpy (&httpSession->cs.
+ client.rbuff1[httpSession->cs.client.rpos1], &inbuf[poff],
+ cpy);
httpSession->cs.client.rpos1 += cpy;
have -= cpy;
poff += cpy;
@@ -1070,8 +1071,9 @@
httpSession->cs.client.rpos2;
if (cpy > have)
cpy = have;
- memcpy (&httpSession->cs.client.
- rbuff2[httpSession->cs.client.rpos2], &inbuf[poff], cpy);
+ memcpy (&httpSession->cs.
+ client.rbuff2[httpSession->cs.client.rpos2], &inbuf[poff],
+ cpy);
have -= cpy;
poff += cpy;
httpSession->cs.client.rpos2 += cpy;
Modified: GNUnet/src/util/network/dns.c
===================================================================
--- GNUnet/src/util/network/dns.c 2008-06-07 04:37:48 UTC (rev 7061)
+++ GNUnet/src/util/network/dns.c 2008-06-07 06:00:59 UTC (rev 7062)
@@ -308,8 +308,8 @@
int s;
struct addrinfo hints;
struct addrinfo *result;
- struct in6_addr * out;
-
+ struct in6_addr *out;
+
memset (&hints, 0, sizeof (struct addrinfo));
// FIXME in PlibC
#ifndef MINGW
@@ -326,47 +326,47 @@
if (0 != (s = getaddrinfo (hostname, NULL, &hints, &result)))
{
if (domain == AF_INET6)
- {
- /* try v4 resolving + mapping */
- hints.ai_family = AF_INET;
- if (0 == getaddrinfo (hostname, NULL, &hints, &result))
- {
- GNUNET_GE_ASSERT(NULL, result->ai_addrlen == sizeof(struct
sockaddr_in));
- if (NULL == *sa)
- {
- *sa = GNUNET_malloc (sizeof(struct sockaddr_in6));
- *socklen = sizeof(struct sockaddr_in6);
- memset(*sa, 0, sizeof(struct sockaddr_in6));
- (*sa)->sa_family = AF_INET6;
- out = &((struct sockaddr_in6*)*sa)->sin6_addr;
- memcpy (*sa, result->ai_addr, result->ai_addrlen);
- ((unsigned int *) out)[2] = htonl (0xffff);
- memcpy (&((char *) out)[sizeof (struct in6_addr) -
- sizeof (struct in_addr)],
- &result->ai_addr,
- sizeof (struct in_addr));
- freeaddrinfo (result);
- return GNUNET_OK;
- }
- if (result->ai_addrlen > *socklen)
- {
- freeaddrinfo (result);
- return GNUNET_SYSERR;
- }
- *socklen = sizeof(struct sockaddr_in6);
- memset(*sa, 0, sizeof(struct sockaddr_in6));
- (*sa)->sa_family = AF_INET6;
- out = &((struct sockaddr_in6*)*sa)->sin6_addr;
- memcpy (*sa, result->ai_addr, result->ai_addrlen);
- ((unsigned int *) out)[2] = htonl (0xffff);
- memcpy (&((char *) out)[sizeof (struct in6_addr) -
- sizeof (struct in_addr)],
- &result->ai_addr,
- sizeof (struct in_addr));
- freeaddrinfo (result);
- return GNUNET_OK;
- }
- }
+ {
+ /* try v4 resolving + mapping */
+ hints.ai_family = AF_INET;
+ if (0 == getaddrinfo (hostname, NULL, &hints, &result))
+ {
+ GNUNET_GE_ASSERT (NULL,
+ result->ai_addrlen ==
+ sizeof (struct sockaddr_in));
+ if (NULL == *sa)
+ {
+ *sa = GNUNET_malloc (sizeof (struct sockaddr_in6));
+ *socklen = sizeof (struct sockaddr_in6);
+ memset (*sa, 0, sizeof (struct sockaddr_in6));
+ (*sa)->sa_family = AF_INET6;
+ out = &((struct sockaddr_in6 *) *sa)->sin6_addr;
+ memcpy (*sa, result->ai_addr, result->ai_addrlen);
+ ((unsigned int *) out)[2] = htonl (0xffff);
+ memcpy (&((char *) out)[sizeof (struct in6_addr) -
+ sizeof (struct in_addr)],
+ &result->ai_addr, sizeof (struct in_addr));
+ freeaddrinfo (result);
+ return GNUNET_OK;
+ }
+ if (result->ai_addrlen > *socklen)
+ {
+ freeaddrinfo (result);
+ return GNUNET_SYSERR;
+ }
+ *socklen = sizeof (struct sockaddr_in6);
+ memset (*sa, 0, sizeof (struct sockaddr_in6));
+ (*sa)->sa_family = AF_INET6;
+ out = &((struct sockaddr_in6 *) *sa)->sin6_addr;
+ memcpy (*sa, result->ai_addr, result->ai_addrlen);
+ ((unsigned int *) out)[2] = htonl (0xffff);
+ memcpy (&((char *) out)[sizeof (struct in6_addr) -
+ sizeof (struct in_addr)],
+ &result->ai_addr, sizeof (struct in_addr));
+ freeaddrinfo (result);
+ return GNUNET_OK;
+ }
+ }
GNUNET_GE_LOG (ectx,
GNUNET_GE_WARNING | GNUNET_GE_USER |
GNUNET_GE_BULK,
Modified: GNUnet/src/util/network_client/tcpio.c
===================================================================
--- GNUnet/src/util/network_client/tcpio.c 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/util/network_client/tcpio.c 2008-06-07 06:00:59 UTC (rev
7062)
@@ -247,15 +247,15 @@
{
/* list of address families to try for connecting,
in order of preference */
- static int addr_families[] = {
+ static int addr_families[] = {
#ifdef AF_UNSPEC
- AF_UNSPEC,
+ AF_UNSPEC,
#endif
#ifdef AF_INET6
- AF_INET6,
+ AF_INET6,
#endif
AF_INET,
- -1
+ -1
};
GNUNET_CronTime select_start;
struct sockaddr *soaddr;
@@ -337,8 +337,8 @@
((struct sockaddr_in6 *) soaddr)->sin6_port = htons (port);
osock = SOCKET (PF_INET6, SOCK_STREAM, 0);
#else
- osock = -1;
- errno = EAFNOSUPPORT;
+ osock = -1;
+ errno = EAFNOSUPPORT;
#endif
}
if (osock == -1)
Modified: GNUnet/src/util/pseudonym/info_test.c
===================================================================
--- GNUnet/src/util/pseudonym/info_test.c 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/util/pseudonym/info_test.c 2008-06-07 06:00:59 UTC (rev
7062)
@@ -29,11 +29,28 @@
#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GNUNET_GE_BREAK(ectx, 0); goto
FAILURE; }
+static struct GNUNET_MetaData *meta;
+
+
+static int
+iter (void *cls,
+ const GNUNET_HashCode *
+ pseudonym, const struct GNUNET_MetaData *md, int rating)
+{
+ int *ok = cls;
+
+ if (!GNUNET_meta_data_test_equal (md, meta))
+ {
+ *ok = GNUNET_NO;
+ GNUNET_GE_BREAK (NULL, 0);
+ }
+ return GNUNET_OK;
+}
+
int
main (int argc, char *argv[])
{
int ok;
- struct GNUNET_MetaData *meta = NULL;
GNUNET_HashCode id1;
GNUNET_HashCode rid1;
GNUNET_HashCode id2;
@@ -54,27 +71,32 @@
return -1;
}
/* ACTUAL TEST CODE */
- old = GNUNET_pseudonym_list_all (ectx, cfg, NULL, NULL);
+ old = GNUNET_pseudonym_list_all (ectx, cfg, &iter, &ok);
meta = GNUNET_meta_data_create ();
GNUNET_meta_data_insert (meta, EXTRACTOR_TITLE, "test");
GNUNET_create_random_hash (&id1);
GNUNET_pseudonym_add (ectx, cfg, &id1, meta);
- newVal = GNUNET_pseudonym_list_all (ectx, cfg, NULL, NULL);
+ newVal = GNUNET_pseudonym_list_all (ectx, cfg, &iter, &ok);
CHECK (old < newVal);
old = newVal;
name1 = GNUNET_pseudonym_id_to_name (ectx, cfg, &id1);
GNUNET_create_random_hash (&id2);
GNUNET_pseudonym_add (ectx, cfg, &id2, meta);
- newVal = GNUNET_pseudonym_list_all (ectx, cfg, NULL, NULL);
+ newVal = GNUNET_pseudonym_list_all (ectx, cfg, &iter, &ok);
CHECK (old < newVal);
name2 = GNUNET_pseudonym_id_to_name (ectx, cfg, &id2);
CHECK (name2 != NULL);
name1 = GNUNET_pseudonym_id_to_name (ectx, cfg, &id1);
CHECK (name1 != NULL);
+ CHECK (0 != strcmp (name1, name2));
CHECK (GNUNET_OK == GNUNET_pseudonym_name_to_id (ectx, cfg, name2, &rid2));
CHECK (GNUNET_OK == GNUNET_pseudonym_name_to_id (ectx, cfg, name1, &rid1));
CHECK (0 == memcmp (&id1, &rid1, sizeof (GNUNET_HashCode)));
CHECK (0 == memcmp (&id2, &rid2, sizeof (GNUNET_HashCode)));
+ CHECK (0 == GNUNET_pseudonym_rank (ectx, cfg, &id1, 0));
+ CHECK (5 == GNUNET_pseudonym_rank (ectx, cfg, &id1, 5));
+ CHECK (-5 == GNUNET_pseudonym_rank (ectx, cfg, &id1, 10));
+ CHECK (0 == GNUNET_pseudonym_rank (ectx, cfg, &id1, 5));
GNUNET_free (name1);
GNUNET_free (name2);
/* END OF TEST CODE */
Modified: GNUnet/src/util/pseudonym/notification.c
===================================================================
--- GNUnet/src/util/pseudonym/notification.c 2008-06-07 04:37:48 UTC (rev
7061)
+++ GNUnet/src/util/pseudonym/notification.c 2008-06-07 06:00:59 UTC (rev
7062)
@@ -128,6 +128,7 @@
void __attribute__ ((destructor)) GNUNET_pseudonym_ltdl_fini ()
{
+ GNUNET_GE_BREAK (NULL, head == NULL);
GNUNET_mutex_destroy (lock);
lock = NULL;
}
Modified: GNUnet/src/util/string/Makefile.am
===================================================================
--- GNUnet/src/util/string/Makefile.am 2008-06-07 04:37:48 UTC (rev 7061)
+++ GNUnet/src/util/string/Makefile.am 2008-06-07 06:00:59 UTC (rev 7062)
@@ -6,6 +6,7 @@
libstring.la
libstring_la_SOURCES = \
+ parser.c \
string.c \
xmalloc.c
Added: GNUnet/src/util/string/parser.c
===================================================================
--- GNUnet/src/util/string/parser.c (rev 0)
+++ GNUnet/src/util/string/parser.c 2008-06-07 06:00:59 UTC (rev 7062)
@@ -0,0 +1,114 @@
+/*
+ This file is part of GNUnet.
+ (C) 2008 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 2, 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 util/string/parser.c
+ * @brief string parser helper functions
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_util.h"
+
+/**
+ * Fill a buffer of the given size with
+ * count 0-terminated strings (given as varargs).
+ * If "buffer" is NULL, only compute the amount of
+ * space required (sum of "strlen(arg)+1").
+ *
+ * Unlike using "snprintf" with "%s", this function
+ * will add 0-terminators after each string. The
+ * "GNUNET_string_buffer_tokenize" function can be
+ * used to parse the buffer back into individual
+ * strings.
+ *
+ * @return number of bytes written to the buffer
+ * (or number of bytes that would have been written)
+ */
+unsigned int
+GNUNET_string_buffer_fill (char *buffer,
+ unsigned int size, unsigned int count, ...)
+{
+ unsigned int needed;
+ unsigned int slen;
+ const char *s;
+ va_list ap;
+
+ needed = 0;
+ va_start (ap, count);
+ while (count > 0)
+ {
+ s = va_arg (ap, const char *);
+ slen = strlen (s) + 1;
+ if (buffer != NULL)
+ {
+ GNUNET_GE_ASSERT (NULL, needed + slen <= size);
+ memcpy (&buffer[needed], s, slen);
+ }
+ needed += slen;
+ count--;
+ }
+ va_end (ap);
+ return needed;
+}
+
+/**
+ * Given a buffer of a given size, find "count"
+ * 0-terminated strings in the buffer and assign
+ * the count (varargs) of type "const char**" to the
+ * locations of the respective strings in the
+ * buffer.
+ *
+ * @param buffer the buffer to parse
+ * @param size size of the buffer
+ * @param count number of strings to locate
+ * @return offset of the character after the last 0-termination
+ * in the buffer, or 0 on error.
+ */
+unsigned int
+GNUNET_string_buffer_tokenize (const char *buffer,
+ unsigned int size, unsigned int count, ...)
+{
+ unsigned int start;
+ unsigned int needed;
+ const char **r;
+ va_list ap;
+
+ needed = 0;
+ va_start (ap, count);
+ while (count > 0)
+ {
+ r = va_arg (ap, const char **);
+ start = needed;
+ while ((needed < size) && (buffer[needed] != '\0'))
+ needed++;
+ if (needed == size)
+ {
+ va_end (ap);
+ return 0; /* error */
+ }
+ *r = &buffer[start];
+ needed++; /* skip 0-termination */
+ count--;
+ }
+ va_end (ap);
+ return needed;
+}
+
+/* end of parser.c */
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2008-06-07 04:37:48 UTC (rev 7061)
+++ GNUnet/todo 2008-06-07 06:00:59 UTC (rev 7062)
@@ -6,8 +6,7 @@
0.8.0 [6'08] (aka "new protocol"):
- namespaces
+ need more comprehensive testcase!
-- pseudonyms:
- + need more comprehensive testcase (notifications, etc)!
+ (in particular updated-content search finding!)
- Windows: gnunet-auto-share
- document gnunet-auto-share on webpage [RC]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7062 - in GNUnet: . doc/man libltdl src/applications/datastore src/applications/fs src/applications/fs/collection src/applications/fs/ecrs src/applications/fs/gap src/applications/fs/namespace src/applications/fs/tools src/applications/sqstore_mysql src/applications/testing src/include src/server src/setup/lib src/setup/ncurses src/transports src/util/network src/util/network_client src/util/pseudonym src/util/string,
gnunet <=