[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r26754 - in gnunet/src: dht hostlist include peerinfo peeri
From: |
gnunet |
Subject: |
[GNUnet-SVN] r26754 - in gnunet/src: dht hostlist include peerinfo peerinfo-tool topology transport |
Date: |
Thu, 4 Apr 2013 14:02:43 +0200 |
Author: wachs
Date: 2013-04-04 14:02:43 +0200 (Thu, 04 Apr 2013)
New Revision: 26754
Modified:
gnunet/src/dht/gnunet-service-dht_hello.c
gnunet/src/hostlist/hostlist-server.c
gnunet/src/include/gnunet_peerinfo_service.h
gnunet/src/peerinfo-tool/gnunet-peerinfo.c
gnunet/src/peerinfo/gnunet-service-peerinfo.c
gnunet/src/peerinfo/peerinfo.h
gnunet/src/peerinfo/peerinfo_api.c
gnunet/src/peerinfo/peerinfo_api_notify.c
gnunet/src/peerinfo/test_peerinfo_api.c
gnunet/src/topology/gnunet-daemon-topology.c
gnunet/src/transport/gnunet-service-transport_validation.c
Log:
peerinfo API change + changes in code using api
Modified: gnunet/src/dht/gnunet-service-dht_hello.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_hello.c 2013-04-04 11:07:00 UTC (rev
26753)
+++ gnunet/src/dht/gnunet-service-dht_hello.c 2013-04-04 12:02:43 UTC (rev
26754)
@@ -98,7 +98,7 @@
void
GDS_HELLO_init ()
{
- pnc = GNUNET_PEERINFO_notify (GDS_cfg, &process_hello, NULL);
+ pnc = GNUNET_PEERINFO_notify (GDS_cfg, GNUNET_NO, &process_hello, NULL);
peer_to_hello = GNUNET_CONTAINER_multihashmap_create (256, GNUNET_NO);
}
Modified: gnunet/src/hostlist/hostlist-server.c
===================================================================
--- gnunet/src/hostlist/hostlist-server.c 2013-04-04 11:07:00 UTC (rev
26753)
+++ gnunet/src/hostlist/hostlist-server.c 2013-04-04 12:02:43 UTC (rev
26754)
@@ -673,7 +673,7 @@
if (daemon_handle_v6 != NULL)
hostlist_task_v6 = prepare_daemon (daemon_handle_v6);
- notify = GNUNET_PEERINFO_notify (cfg, &process_notify, NULL);
+ notify = GNUNET_PEERINFO_notify (cfg, GNUNET_NO, &process_notify, NULL);
return GNUNET_OK;
}
Modified: gnunet/src/include/gnunet_peerinfo_service.h
===================================================================
--- gnunet/src/include/gnunet_peerinfo_service.h 2013-04-04 11:07:00 UTC
(rev 26753)
+++ gnunet/src/include/gnunet_peerinfo_service.h 2013-04-04 12:02:43 UTC
(rev 26754)
@@ -145,28 +145,28 @@
/**
- * Call a method for each known matching host to get its HELLO.
- * The callback method will be invoked once for each matching
- * host and then finally once with a NULL pointer. After that final
- * invocation, the iterator context must no longer be used.
+ * Call a method for each known matching host. The callback method
+ * will be invoked once for each matching host and then finally once
+ * with a NULL pointer. After that final invocation, the iterator
+ * context must no longer be used.
*
- * Instead of calling this function with 'peer == NULL'
- * it is often better to use 'GNUNET_PEERINFO_notify'.
+ * Instead of calling this function with 'peer == NULL' it is often
+ * better to use 'GNUNET_PEERINFO_notify'.
*
* @param h handle to the peerinfo service
+ * @param include_friend_only include HELLO messages for friends only
* @param peer restrict iteration to this peer only (can be NULL)
* @param timeout how long to wait until timing out
* @param callback the method to call for each peer
* @param callback_cls closure for callback
- * @return NULL on error (in this case, 'callback' is never called!),
- * otherwise an iterator context
+ * @return iterator context
*/
struct GNUNET_PEERINFO_IteratorContext *
GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
+
int include_friend_only,
const struct GNUNET_PeerIdentity *peer,
struct GNUNET_TIME_Relative timeout,
- GNUNET_PEERINFO_Processor callback,
- void *callback_cls);
+ GNUNET_PEERINFO_Processor callback, void
*callback_cls);
@@ -189,17 +189,21 @@
/**
* Call a method whenever our known information about peers
* changes. Initially calls the given function for all known
- * peers and then only signals changes. Note that it is
- * possible (i.e. on disconnects) that the callback is called
- * twice with the same peer information.
+ * peers and then only signals changes.
*
+ * If include_friend_only is set to GNUNET_YES peerinfo will include HELLO
+ * messages which are intended for friend to friend mode and which do not
+ * have to be gossiped. Otherwise these messages are skipped.
+ *
* @param cfg configuration to use
+ * @param include_friend_only include HELLO messages for friends only
* @param callback the method to call for each peer
* @param callback_cls closure for callback
* @return NULL on error
*/
struct GNUNET_PEERINFO_NotifyContext *
GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg,
+
int include_friend_only,
GNUNET_PEERINFO_Processor callback, void
*callback_cls);
Modified: gnunet/src/peerinfo/gnunet-service-peerinfo.c
===================================================================
--- gnunet/src/peerinfo/gnunet-service-peerinfo.c 2013-04-04 11:07:00 UTC
(rev 26753)
+++ gnunet/src/peerinfo/gnunet-service-peerinfo.c 2013-04-04 12:02:43 UTC
(rev 26754)
@@ -90,6 +90,7 @@
static struct GNUNET_STATISTICS_Handle *stats;
+
/**
* Notify all clients in the notify list about the
* given host entry changing.
@@ -638,9 +639,10 @@
{
const struct ListPeerMessage *lpm;
struct GNUNET_SERVER_TransmitContext *tc;
+ int friend_only;
lpm = (const struct ListPeerMessage *) message;
- GNUNET_break (0 == ntohl (lpm->reserved));
+ friend_only = ntohl (lpm->include_friend_only);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received for peer
`%4s'\n",
"GET", GNUNET_i2s (&lpm->peer));
tc = GNUNET_SERVER_transmit_context_create (client);
@@ -663,8 +665,12 @@
handle_get_all (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
+ const struct ListAllPeersMessage *lapm;
struct GNUNET_SERVER_TransmitContext *tc;
+ int friend_only;
+ lapm = (const struct ListAllPeersMessage *) message;
+ friend_only = ntohl (lapm->include_friend_only);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received\n", "GET_ALL");
tc = GNUNET_SERVER_transmit_context_create (client);
GNUNET_CONTAINER_multihashmap_iterate (hostmap, &add_to_tc, tc);
@@ -709,7 +715,11 @@
handle_notify (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received\n", "NOTIFY");
+ struct NotifyMessage *nm = (struct NotifyMessage *) message;
+ int friend_only;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received\n",
"NOTIFY");
+ friend_only = ntohl (nm->include_friend_only);
GNUNET_SERVER_client_mark_monitor (client);
GNUNET_SERVER_notification_context_add (notify_list, client);
GNUNET_CONTAINER_multihashmap_iterate (hostmap, &do_notify_entry, client);
@@ -773,9 +783,9 @@
{&handle_get, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_GET,
sizeof (struct ListPeerMessage)},
{&handle_get_all, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL,
- sizeof (struct GNUNET_MessageHeader)},
+ sizeof (struct ListAllPeersMessage)},
{&handle_notify, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY,
- sizeof (struct GNUNET_MessageHeader)},
+ sizeof (struct NotifyMessage)},
{NULL, NULL, 0, 0}
};
char *peerdir;
Modified: gnunet/src/peerinfo/peerinfo.h
===================================================================
--- gnunet/src/peerinfo/peerinfo.h 2013-04-04 11:07:00 UTC (rev 26753)
+++ gnunet/src/peerinfo/peerinfo.h 2013-04-04 12:02:43 UTC (rev 26754)
@@ -31,22 +31,22 @@
GNUNET_NETWORK_STRUCT_BEGIN
/**
- * Message requesting a listing of all known peers,
- * possibly restricted to the specified peer identity.
+ * Message requesting a listing of peers,
+ * restricted to the specified peer identity.
*/
struct ListPeerMessage
{
/**
- * Type will be GNUNET_MESSAGE_TYPE_PEERINFO_GET or
- * GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL.
+ * Type will be GNUNET_MESSAGE_TYPE_PEERINFO_GET
+ * .
*/
struct GNUNET_MessageHeader header;
/**
- * Always zero.
+ * Include friend only HELLOs and peers in callbacks
*/
- uint32_t reserved GNUNET_PACKED;
+ uint32_t include_friend_only GNUNET_PACKED;
/**
* Restrict to peers with this identity (optional
@@ -56,8 +56,44 @@
};
+/**
+ * Message requesting a listing of all peers,
+ * restricted to the specified peer identity.
+ */
+struct ListAllPeersMessage
+{
+ /**
+ * Type will be GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL
+ */
+ struct GNUNET_MessageHeader header;
+ /**
+ * Include friend only HELLOs and peers in callbacks
+ */
+ uint32_t include_friend_only GNUNET_PACKED;
+
+};
+
+
/**
+ * Header for all communications.
+ */
+struct NotifyMessage
+{
+ /**
+ * Type will be GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY
+ */
+ struct GNUNET_MessageHeader header;
+
+ /**
+ * Include friend only HELLOs and peers in callbacks
+ */
+ uint32_t include_friend_only GNUNET_PACKED;
+
+};
+
+
+/**
* Message used to inform the client about
* a particular peer; this message is optionally followed
* by a HELLO message for the respective peer (if available).
Modified: gnunet/src/peerinfo/peerinfo_api.c
===================================================================
--- gnunet/src/peerinfo/peerinfo_api.c 2013-04-04 11:07:00 UTC (rev 26753)
+++ gnunet/src/peerinfo/peerinfo_api.c 2013-04-04 12:02:43 UTC (rev 26754)
@@ -692,6 +692,7 @@
* better to use 'GNUNET_PEERINFO_notify'.
*
* @param h handle to the peerinfo service
+ * @param include_friend_only include HELLO messages for friends only
* @param peer restrict iteration to this peer only (can be NULL)
* @param timeout how long to wait until timing out
* @param callback the method to call for each peer
@@ -700,11 +701,12 @@
*/
struct GNUNET_PEERINFO_IteratorContext *
GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
+
int include_friend_only,
const struct GNUNET_PeerIdentity *peer,
struct GNUNET_TIME_Relative timeout,
GNUNET_PEERINFO_Processor callback, void
*callback_cls)
{
- struct GNUNET_MessageHeader *lapm;
+ struct ListAllPeersMessage *lapm;
struct ListPeerMessage *lpm;
struct GNUNET_PEERINFO_IteratorContext *ic;
struct GNUNET_PEERINFO_AddContext *ac;
@@ -716,11 +718,12 @@
"Requesting list of peers from PEERINFO service\n");
ac =
GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_AddContext) +
- sizeof (struct GNUNET_MessageHeader));
- ac->size = sizeof (struct GNUNET_MessageHeader);
- lapm = (struct GNUNET_MessageHeader *) &ac[1];
- lapm->size = htons (sizeof (struct GNUNET_MessageHeader));
- lapm->type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL);
+ sizeof (struct ListAllPeersMessage));
+ ac->size = sizeof (struct ListAllPeersMessage);
+ lapm = (struct ListAllPeersMessage *) &ac[1];
+ lapm->header.size = htons (sizeof (struct ListAllPeersMessage));
+ lapm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL);
+ lapm->include_friend_only = htonl (include_friend_only);
}
else
{
@@ -734,6 +737,7 @@
lpm = (struct ListPeerMessage *) &ac[1];
lpm->header.size = htons (sizeof (struct ListPeerMessage));
lpm->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_GET);
+ lpm->include_friend_only = htonl (include_friend_only);
memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity));
ic->have_peer = GNUNET_YES;
ic->peer = *peer;
Modified: gnunet/src/peerinfo/peerinfo_api_notify.c
===================================================================
--- gnunet/src/peerinfo/peerinfo_api_notify.c 2013-04-04 11:07:00 UTC (rev
26753)
+++ gnunet/src/peerinfo/peerinfo_api_notify.c 2013-04-04 12:02:43 UTC (rev
26754)
@@ -69,6 +69,11 @@
*/
GNUNET_SCHEDULER_TaskIdentifier task;
+ /**
+ * Include friend only HELLOs in callbacks
+ */
+
+ int include_friend_only;
};
@@ -195,7 +200,7 @@
transmit_notify_request (void *cls, size_t size, void *buf)
{
struct GNUNET_PEERINFO_NotifyContext *nc = cls;
- struct GNUNET_MessageHeader hdr;
+ struct NotifyMessage nm;
nc->init = NULL;
if (buf == NULL)
@@ -205,10 +210,11 @@
request_notifications (nc);
return 0;
}
- GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
- hdr.size = htons (sizeof (struct GNUNET_MessageHeader));
- hdr.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY);
- memcpy (buf, &hdr, sizeof (struct GNUNET_MessageHeader));
+ GNUNET_assert (size >= sizeof (struct NotifyMessage));
+ nm.header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY);
+ nm.header.size = htons (sizeof (struct NotifyMessage));
+ nm.include_friend_only = htonl (nc->include_friend_only);
+ memcpy (buf, &nm, sizeof (struct NotifyMessage));
receive_notifications (nc);
return sizeof (struct GNUNET_MessageHeader);
}
@@ -226,7 +232,7 @@
GNUNET_assert (NULL == nc->init);
nc->init =
GNUNET_CLIENT_notify_transmit_ready (nc->client,
- sizeof (struct
GNUNET_MessageHeader),
+ sizeof (struct NotifyMessage),
GNUNET_TIME_UNIT_FOREVER_REL,
GNUNET_YES,
&transmit_notify_request,
nc);
@@ -238,13 +244,19 @@
* changes. Initially calls the given function for all known
* peers and then only signals changes.
*
+ * If include_friend_only is set to GNUNET_YES peerinfo will include HELLO
+ * messages which are intended for friend to friend mode and which do not
+ * have to be gossiped. Otherwise these messages are skipped.
+ *
* @param cfg configuration to use
+ * @param include_friend_only include HELLO messages for friends only
* @param callback the method to call for each peer
* @param callback_cls closure for callback
* @return NULL on error
*/
struct GNUNET_PEERINFO_NotifyContext *
GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg,
+
int include_friend_only,
GNUNET_PEERINFO_Processor callback, void *callback_cls)
{
struct GNUNET_PEERINFO_NotifyContext *nc;
@@ -262,6 +274,7 @@
nc->client = client;
nc->callback = callback;
nc->callback_cls = callback_cls;
+ nc->include_friend_only = include_friend_only;
request_notifications (nc);
return nc;
}
Modified: gnunet/src/peerinfo/test_peerinfo_api.c
===================================================================
--- gnunet/src/peerinfo/test_peerinfo_api.c 2013-04-04 11:07:00 UTC (rev
26753)
+++ gnunet/src/peerinfo/test_peerinfo_api.c 2013-04-04 12:02:43 UTC (rev
26754)
@@ -120,7 +120,7 @@
/* try again */
retries++;
add_peer ();
- ic = GNUNET_PEERINFO_iterate (h, NULL,
+ ic = GNUNET_PEERINFO_iterate (h, GNUNET_NO, NULL,
GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 15), &process,
cls);
@@ -152,7 +152,7 @@
h = GNUNET_PEERINFO_connect (cfg);
GNUNET_assert (NULL != h);
add_peer ();
- ic = GNUNET_PEERINFO_iterate (h, NULL,
+ ic = GNUNET_PEERINFO_iterate (h, GNUNET_NO, NULL,
GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 15), &process, cls);
}
Modified: gnunet/src/peerinfo-tool/gnunet-peerinfo.c
===================================================================
--- gnunet/src/peerinfo-tool/gnunet-peerinfo.c 2013-04-04 11:07:00 UTC (rev
26753)
+++ gnunet/src/peerinfo-tool/gnunet-peerinfo.c 2013-04-04 12:02:43 UTC (rev
26754)
@@ -106,6 +106,11 @@
*/
unsigned int off;
+ /**
+ * Hello was friend only, GNUNET_YES or GNUNET_NO
+ */
+ int friend_only;
+
};
@@ -120,6 +125,11 @@
static int be_quiet;
/**
+ * Option '-f'
+ */
+static int include_friend_only;
+
+/**
* Option '-s'
*/
static int get_self;
@@ -211,7 +221,8 @@
unsigned int i;
GNUNET_CRYPTO_hash_to_enc (&pc->peer.hashPubKey, &enc);
- printf (_("Peer `%s'\n"),
+ printf (_("%sPeer `%s'\n"),
+ (GNUNET_YES == pc->friend_only) ? "F2F: " : "",
(const char *) &enc);
for (i = 0; i < pc->num_addresses; i++)
{
@@ -321,6 +332,7 @@
{
struct GNUNET_CRYPTO_HashAsciiEncoded enc;
struct PrintContext *pc;
+ int friend_only;
if (NULL == peer)
{
@@ -335,10 +347,13 @@
tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
return;
}
+ friend_only = GNUNET_HELLO_is_friend_only (hello);
if ((GNUNET_YES == be_quiet) || (NULL == hello))
{
GNUNET_CRYPTO_hash_to_enc (&peer->hashPubKey, &enc);
- printf ("%s\n", (const char *) &enc);
+ printf ("%s%s\n",
+ (GNUNET_YES == friend_only) ? "F2F: " : "",
+ (const char *) &enc);
return;
}
pc = GNUNET_malloc (sizeof (struct PrintContext));
@@ -346,6 +361,7 @@
pc_tail,
pc);
pc->peer = *peer;
+ pc->friend_only = friend_only;
GNUNET_HELLO_iterate_addresses (hello,
GNUNET_NO,
&count_address,
@@ -608,7 +624,7 @@
{
get_info = GNUNET_NO;
GPI_plugins_load (cfg);
- pic = GNUNET_PEERINFO_iterate (peerinfo, NULL,
+ pic = GNUNET_PEERINFO_iterate (peerinfo, include_friend_only, NULL,
TIMEOUT,
&print_peer_info, NULL);
return;
@@ -627,7 +643,7 @@
if (GNUNET_YES == get_uri)
{
GPI_plugins_load (cfg);
- pic = GNUNET_PEERINFO_iterate (peerinfo, &my_peer_identity,
+ pic = GNUNET_PEERINFO_iterate (peerinfo,include_friend_only,
&my_peer_identity,
TIMEOUT, &print_my_uri, NULL);
get_uri = GNUNET_NO;
return;
@@ -653,6 +669,9 @@
{'q', "quiet", NULL,
gettext_noop ("output only the identity strings"),
0, &GNUNET_GETOPT_set_one, &be_quiet},
+ {'f', "friends", NULL,
+ gettext_noop ("include friend-only information"),
+ 0, &GNUNET_GETOPT_set_one, &include_friend_only},
{'s', "self", NULL,
gettext_noop ("output our own identity only"),
0, &GNUNET_GETOPT_set_one, &get_self},
Modified: gnunet/src/topology/gnunet-daemon-topology.c
===================================================================
--- gnunet/src/topology/gnunet-daemon-topology.c 2013-04-04 11:07:00 UTC
(rev 26753)
+++ gnunet/src/topology/gnunet-daemon-topology.c 2013-04-04 12:02:43 UTC
(rev 26754)
@@ -918,7 +918,7 @@
_("Error in communication with PEERINFO service: %s\n"),
err_msg);
GNUNET_PEERINFO_notify_cancel (peerinfo_notify);
- peerinfo_notify = GNUNET_PEERINFO_notify (cfg, &process_peer, NULL);
+ peerinfo_notify = GNUNET_PEERINFO_notify (cfg, GNUNET_NO, &process_peer,
NULL);
return;
}
GNUNET_assert (peer != NULL);
@@ -991,7 +991,7 @@
handle = server;
my_identity = *my_id;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I am peer `%s'\n", GNUNET_i2s (my_id));
- peerinfo_notify = GNUNET_PEERINFO_notify (cfg, &process_peer, NULL);
+ peerinfo_notify = GNUNET_PEERINFO_notify (cfg, GNUNET_NO, &process_peer,
NULL);
}
Modified: gnunet/src/transport/gnunet-service-transport_validation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.c 2013-04-04
11:07:00 UTC (rev 26753)
+++ gnunet/src/transport/gnunet-service-transport_validation.c 2013-04-04
12:02:43 UTC (rev 26754)
@@ -800,7 +800,7 @@
validations_fast_start_threshold,
validation_delay.rel_value);
validation_map = GNUNET_CONTAINER_multihashmap_create (VALIDATION_MAP_SIZE,
GNUNET_NO);
- pnc = GNUNET_PEERINFO_notify (GST_cfg, &process_peerinfo_hello, NULL);
+ pnc = GNUNET_PEERINFO_notify (GST_cfg, GNUNET_YES, &process_peerinfo_hello,
NULL);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r26754 - in gnunet/src: dht hostlist include peerinfo peerinfo-tool topology transport,
gnunet <=