};
-/**
- * Response from FS service with a result for a previous FS search.
- * Note that queries for DBLOCKS and IBLOCKS that have received a
- * single response are considered done.
- */
-struct ContentMessage
-{
-
- /**
- * Message type will be
- * GNUNET_MESSAGE_TYPE_FS_CONTENT.
- */
- struct GNUNET_MessageHeader header;
-
- /**
- * Type of the content that was found,
- * should never be 0.
- */
- uint32_t type GNUNET_PACKED;
-
- /**
- * When will this result expire?
- */
- struct GNUNET_TIME_AbsoluteNBO expiration;
-
- /* followed by the actual block of data */
-
-};
-
/**
* Only the (mandatory) query is included.
*/
/**
- * Message sent between peers providing FS-content.
+ * Response from FS service with a result for a previous FS search.
+ * Note that queries for DBLOCKS and IBLOCKS that have received a
+ * single response are considered done. This message is transmitted
+ * between peers as well as between the service and a client.
*/
struct PutMessage
{
struct GNUNET_MessageHeader header;
/**
- * Type of the block (in big endian).
+ * Type of the block (in big endian). Should never be zero.
*/
uint32_t type GNUNET_PACKED;
/**
* When does this result expire?
*/
- struct GNUNET_TIME_RelativeNBO expiration;
+ struct GNUNET_TIME_AbsoluteNBO expiration;
/* this is followed by the actual encrypted content */
#include "fs.h"
#include "fs_tree.h"
-#define DEBUG_DOWNLOAD GNUNET_NO
+#define DEBUG_DOWNLOAD GNUNET_YES
/**
* We're storing the IBLOCKS after the
const struct GNUNET_MessageHeader * msg)
{
struct GNUNET_FS_DownloadContext *dc = cls;
- const struct ContentMessage *cm;
+ const struct PutMessage *cm;
uint16_t msize;
if ( (NULL == msg) ||
- (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_CONTENT) ||
- (ntohs (msg->size) <= sizeof (struct ContentMessage)) )
+ (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
+ (sizeof (struct PutMessage) > ntohs(msg->size)) )
{
+ GNUNET_break (msg == NULL);
try_reconnect (dc);
return;
}
- msize = ntohs (msg->size);
- cm = (const struct ContentMessage*) msg;
+ msize = ntohs(msg->size);
+ cm = (const struct PutMessage*) msg;
process_result (dc,
ntohl (cm->type),
&cm[1],
- msize - sizeof (struct ContentMessage));
+ msize - sizeof (struct PutMessage));
if (dc->client == NULL)
return; /* fatal error */
/* continue receiving */
const struct GNUNET_MessageHeader * msg)
{
struct GNUNET_FS_SearchContext *sc = cls;
- const struct ContentMessage *cm;
+ const struct PutMessage *cm;
uint16_t msize;
if ( (NULL == msg) ||
- (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_CONTENT) ||
- (ntohs (msg->size) <= sizeof (struct ContentMessage)) )
+ (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
+ (ntohs (msg->size) <= sizeof (struct PutMessage)) )
{
try_reconnect (sc);
return;
}
msize = ntohs (msg->size);
- cm = (const struct ContentMessage*) msg;
+ cm = (const struct PutMessage*) msg;
process_result (sc,
ntohl (cm->type),
GNUNET_TIME_absolute_ntoh (cm->expiration),
&cm[1],
- msize - sizeof (struct ContentMessage));
+ msize - sizeof (struct PutMessage));
/* continue receiving */
GNUNET_CLIENT_receive (sc->client,
&receive_results,
GNUNET_TIME_UNIT_FOREVER_REL,
&transmit_to_client,
cl);
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitted %u bytes to client\n",
+ (unsigned int) msize);
+#endif
return msize;
}
struct ClientResponseMessage *creply;
struct ClientList *cl;
struct PutMessage *pm;
- struct ContentMessage *cm;
struct ConnectedPeer *cp;
GNUNET_HashCode chash;
GNUNET_HashCode mhash;
pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT);
pm->header.size = htons (msize);
pm->type = htonl (prq->type);
- pm->expiration = GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining (prq->expiration));
- memcpy (&creply[1], prq->data, prq->size);
+ pm->expiration = GNUNET_TIME_absolute_hton (prq->expiration);
+ memcpy (&pm[1], prq->data, prq->size);
if (NULL == cl->th)
cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client,
msize,
GNUNET_h2s (key),
(unsigned int) cp->pid);
#endif
- msize = sizeof (struct ContentMessage) + prq->size;
+ msize = sizeof (struct PutMessage) + prq->size;
reply = GNUNET_malloc (msize + sizeof (struct PendingMessage));
reply->cont = &transmit_reply_continuation;
reply->cont_cls = pr;
reply->msize = msize;
reply->priority = (uint32_t) -1; /* send replies first! */
- cm = (struct ContentMessage*) &reply[1];
- cm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_CONTENT);
- cm->header.size = htons (msize);
- cm->type = htonl (prq->type);
- cm->expiration = GNUNET_TIME_absolute_hton (prq->expiration);
- memcpy (&reply[1], prq->data, prq->size);
+ pm = (struct PutMessage*) &reply[1];
+ pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT);
+ pm->header.size = htons (msize);
+ pm->type = htonl (prq->type);
+ pm->expiration = GNUNET_TIME_absolute_hton (prq->expiration);
+ memcpy (&pm[1], prq->data, prq->size);
add_to_pending_messages_for_peer (cp, reply, pr);
}
put = (const struct PutMessage*) message;
dsize = msize - sizeof (struct PutMessage);
type = ntohl (put->type);
- expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_ntoh (put->expiration));
+ expiration = GNUNET_TIME_absolute_ntoh (put->expiration);
/* first, validate! */
switch (type)
#include "gnunet-service-fs_indexing.h"
#include "fs.h"
-#define DEBUG_FS GNUNET_NO
-
+#define DEBUG_FS GNUNET_YES
/**
* In-memory information about indexed files (also available
to remove the OnDemand block from the DS! */
return GNUNET_SYSERR;
}
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "On-demand encoded block for query `%s'\n",
+ GNUNET_h2s (key));
+#endif
cont (cont_cls,
key,
nsize,
#include "gnunet_arm_service.h"
#include "gnunet_fs_service.h"
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_YES
#define START_ARM GNUNET_YES
timeout_kill_task (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- if (publish != NULL)
- {
- GNUNET_FS_publish_stop (publish);
- publish = NULL;
- }
if (download != NULL)
{
GNUNET_FS_download_stop (download, GNUNET_YES);
download = NULL;
}
+ else if (publish != NULL)
+ {
+ GNUNET_FS_publish_stop (publish);
+ publish = NULL;
+ }
timeout_kill = GNUNET_SCHEDULER_NO_TASK;
err = 1;
}
*/
#define GNUNET_MESSAGE_TYPE_FS_START_SEARCH 136
-/**
- * FS service has found content matching this client's
- * request.
- */
-#define GNUNET_MESSAGE_TYPE_FS_CONTENT 137
-
/**
* P2P request for content (one FS to another).
*/
-#define GNUNET_MESSAGE_TYPE_FS_GET 138
+#define GNUNET_MESSAGE_TYPE_FS_GET 137
/**
- * P2P response with content or active
- * migration of content.
+ * P2P response with content or active migration of content. Also
+ * used between the service and clients (in response to START_SEARCH).
*/
-#define GNUNET_MESSAGE_TYPE_FS_PUT 139
+#define GNUNET_MESSAGE_TYPE_FS_PUT 138
/**
* Type used to match 'all' message types.