[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r26751 - in gnunet/src: hello include peerinfo testbed topo
From: |
gnunet |
Subject: |
[GNUnet-SVN] r26751 - in gnunet/src: hello include peerinfo testbed topology transport |
Date: |
Thu, 4 Apr 2013 11:43:10 +0200 |
Author: wachs
Date: 2013-04-04 11:43:10 +0200 (Thu, 04 Apr 2013)
New Revision: 26751
Modified:
gnunet/src/hello/gnunet-hello.c
gnunet/src/hello/hello.c
gnunet/src/include/gnunet_hello_lib.h
gnunet/src/include/gnunet_protocols.h
gnunet/src/peerinfo/gnunet-service-peerinfo.c
gnunet/src/peerinfo/peerinfo.conf.in
gnunet/src/testbed/gnunet-service-testbed_oc.c
gnunet/src/topology/gnunet-daemon-topology.c
gnunet/src/transport/gnunet-service-transport.c
gnunet/src/transport/gnunet-service-transport_clients.c
gnunet/src/transport/gnunet-service-transport_validation.c
gnunet/src/transport/plugin_transport_udp_broadcasting.c
gnunet/src/transport/plugin_transport_wlan.c
gnunet/src/transport/transport_api.c
Log:
changes for mantis 0002676
Modified: gnunet/src/hello/gnunet-hello.c
===================================================================
--- gnunet/src/hello/gnunet-hello.c 2013-04-04 09:25:22 UTC (rev 26750)
+++ gnunet/src/hello/gnunet-hello.c 2013-04-04 09:43:10 UTC (rev 26751)
@@ -110,7 +110,6 @@
struct GNUNET_HELLO_Message *result;
struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pk;
uint64_t fsize;
- int friend_only;
GNUNET_log_setup ("gnunet-hello", "INFO", NULL);
if (argc != 2)
@@ -168,12 +167,8 @@
argv[1]);
return 1;
}
- friend_only = GNUNET_NO;
- if (GNUNET_MESSAGE_TYPE_HELLO == GNUNET_HELLO_get_type (orig))
- friend_only = GNUNET_NO;
- if (GNUNET_MESSAGE_TYPE_FRIEND_HELLO == GNUNET_HELLO_get_type (orig))
- friend_only = GNUNET_YES;
- result = GNUNET_HELLO_create (&pk, &add_from_hello, &orig, friend_only);
+ result = GNUNET_HELLO_create (&pk, &add_from_hello, &orig,
+ GNUNET_HELLO_is_friend_only (orig));
GNUNET_assert (NULL != result);
fh = GNUNET_DISK_file_open (argv[1],
GNUNET_DISK_OPEN_WRITE,
Modified: gnunet/src/hello/hello.c
===================================================================
--- gnunet/src/hello/hello.c 2013-04-04 09:25:22 UTC (rev 26750)
+++ gnunet/src/hello/hello.c 2013-04-04 09:43:10 UTC (rev 26751)
@@ -52,9 +52,9 @@
struct GNUNET_MessageHeader header;
/**
- * Always zero (for alignment).
+ * Use in F2F mode: Do not gossip this HELLO message
*/
- uint32_t reserved GNUNET_PACKED;
+ uint32_t friend_only GNUNET_PACKED;
/**
* The public key of the peer.
@@ -104,23 +104,21 @@
};
-/**
- * Return HELLO type
+/** Return HELLO type
*
* @param h HELLO Message to test
- * @return GNUNET_MESSAGE_TYPE_HELLO or GNUNET_MESSAGE_TYPE_FRIEND_HELLO or 0
on error
+ * @return GNUNET_YES or GNUNET_NO
*/
-uint16_t
-GNUNET_HELLO_get_type (const struct GNUNET_HELLO_Message *h)
+int
+GNUNET_HELLO_is_friend_only (const struct GNUNET_HELLO_Message *h)
{
- if (GNUNET_MESSAGE_TYPE_HELLO == ntohs(h->header.type))
- return GNUNET_MESSAGE_TYPE_HELLO;
- if (GNUNET_MESSAGE_TYPE_FRIEND_HELLO == ntohs(h->header.type))
- return GNUNET_MESSAGE_TYPE_FRIEND_HELLO;
- return 0;
+ if (GNUNET_YES == ntohl(h->friend_only))
+ return GNUNET_YES;
+ return GNUNET_NO;
}
+
/**
* Copy the given address information into
* the given buffer using the format of HELLOs.
@@ -231,6 +229,9 @@
size_t ret;
struct GNUNET_HELLO_Message *hello;
+ GNUNET_assert (NULL != publicKey);
+ GNUNET_assert ((GNUNET_YES == friend_only) || (GNUNET_NO == friend_only));
+
max = sizeof (buffer);
used = 0;
if (addrgen != NULL)
@@ -242,11 +243,10 @@
}
}
hello = GNUNET_malloc (sizeof (struct GNUNET_HELLO_Message) + used);
- if (GNUNET_NO == friend_only)
- hello->header.type = htons (GNUNET_MESSAGE_TYPE_HELLO);
- else
- hello->header.type = htons (GNUNET_MESSAGE_TYPE_FRIEND_HELLO);
+ hello->header.type = htons (GNUNET_MESSAGE_TYPE_HELLO);
hello->header.size = htons (sizeof (struct GNUNET_HELLO_Message) + used);
+ hello->friend_only = htonl (friend_only);
+
memcpy (&hello->publicKey, publicKey,
sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded));
memcpy (&hello[1], buffer, used);
@@ -282,8 +282,7 @@
msize = GNUNET_HELLO_size (msg);
if ((msize < sizeof (struct GNUNET_HELLO_Message)) ||
- ((ntohs (msg->header.type) != GNUNET_MESSAGE_TYPE_HELLO) &&
- (ntohs (msg->header.type) !=
GNUNET_MESSAGE_TYPE_FRIEND_HELLO)))
+ (ntohs (msg->header.type) != GNUNET_MESSAGE_TYPE_HELLO))
return NULL;
ret = NULL;
if (return_modified)
@@ -431,21 +430,11 @@
{
struct MergeContext mc = { h1, h2, NULL, NULL, 0, 0, 0 };
int friend_only;
- if (h1->header.type != h2->header.type)
- {
- /* Trying to merge different HELLO types */
- GNUNET_break (0);
- return NULL;
- }
- if (GNUNET_MESSAGE_TYPE_HELLO == (ntohs(h1->header.type)))
- friend_only = GNUNET_NO;
- else if (GNUNET_MESSAGE_TYPE_FRIEND_HELLO == (ntohs(h1->header.type)))
- friend_only = GNUNET_YES;
+
+ if (h1->friend_only != h2->friend_only)
+ friend_only = GNUNET_YES; /* One of the HELLOs is friend only */
else
- {
- GNUNET_break (0);
- return NULL;
- }
+ friend_only = ntohl (h1->friend_only); /* Both HELLO's have the same
type */
return GNUNET_HELLO_create (&h1->publicKey, &merge_addr, &mc,
friend_only);
}
@@ -526,8 +515,7 @@
uint16_t ret = ntohs (hello->header.size);
if ((ret < sizeof (struct GNUNET_HELLO_Message)) ||
- ((ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO) &&
- (ntohs (hello->header.type) !=
GNUNET_MESSAGE_TYPE_FRIEND_HELLO)))
+ (ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO))
return 0;
return ret;
}
@@ -547,8 +535,7 @@
uint16_t ret = ntohs (hello->header.size);
if ((ret < sizeof (struct GNUNET_HELLO_Message)) ||
- ((ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO) &&
- (ntohs (hello->header.type) !=
GNUNET_MESSAGE_TYPE_FRIEND_HELLO)))
+ (ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO))
return GNUNET_SYSERR;
*publicKey = hello->publicKey;
return GNUNET_OK;
@@ -569,8 +556,7 @@
uint16_t ret = ntohs (hello->header.size);
if ((ret < sizeof (struct GNUNET_HELLO_Message)) ||
- ((ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO) &&
- (ntohs (hello->header.type) !=
GNUNET_MESSAGE_TYPE_FRIEND_HELLO)))
+ (ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO))
return GNUNET_SYSERR;
GNUNET_CRYPTO_hash (&hello->publicKey,
sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded),
@@ -593,8 +579,7 @@
uint16_t ret = ntohs (hello->header.size);
if ((ret < sizeof (struct GNUNET_HELLO_Message)) ||
- ((ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO) &&
- (ntohs (hello->header.type) !=
GNUNET_MESSAGE_TYPE_FRIEND_HELLO)))
+ (ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO))
return NULL;
return &hello->header;
Modified: gnunet/src/include/gnunet_hello_lib.h
===================================================================
--- gnunet/src/include/gnunet_hello_lib.h 2013-04-04 09:25:22 UTC (rev
26750)
+++ gnunet/src/include/gnunet_hello_lib.h 2013-04-04 09:43:10 UTC (rev
26751)
@@ -145,15 +145,16 @@
*/
struct GNUNET_HELLO_Message;
-/**
- * Return HELLO type
+
+/** Return HELLO type
*
* @param h HELLO Message to test
- * @param GNUNET_MESSAGE_TYPE_HELLO or GNUNET_MESSAGE_TYPE_FRIEND_HELLO or 0
on error
+ * @return GNUNET_YES or GNUNET_NO
*/
-uint16_t
-GNUNET_HELLO_get_type (const struct GNUNET_HELLO_Message *h);
+int
+GNUNET_HELLO_is_friend_only (const struct GNUNET_HELLO_Message *h);
+
/**
* Copy the given address information into
* the given buffer using the format of HELLOs.
Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h 2013-04-04 09:25:22 UTC (rev
26750)
+++ gnunet/src/include/gnunet_protocols.h 2013-04-04 09:43:10 UTC (rev
26751)
@@ -107,16 +107,17 @@
******************************************************************************/
/**
- * HELLO message used for communicating peer addresses.
+ * Previously used for HELLO messages used for communicating peer addresses.
* Managed by libgnunethello.
*/
-#define GNUNET_MESSAGE_TYPE_HELLO 16
+#define GNUNET_MESSAGE_TYPE_HELLO_LEGACY 16
/**
- * HELLO message used for communicating peer addresses with friends only.
+ * HELLO message with friend only flag used for communicating peer addresses.
+ * Managed by libgnunethello.
*/
-#define GNUNET_MESSAGE_TYPE_FRIEND_HELLO 17
+#define GNUNET_MESSAGE_TYPE_HELLO 17
/*******************************************************************************
* FRAGMENTATION message types
Modified: gnunet/src/peerinfo/gnunet-service-peerinfo.c
===================================================================
--- gnunet/src/peerinfo/gnunet-service-peerinfo.c 2013-04-04 09:25:22 UTC
(rev 26750)
+++ gnunet/src/peerinfo/gnunet-service-peerinfo.c 2013-04-04 09:43:10 UTC
(rev 26751)
@@ -769,7 +769,6 @@
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
static const struct GNUNET_SERVER_MessageHandler handlers[] = {
- {&handle_hello, NULL, GNUNET_MESSAGE_TYPE_FRIEND_HELLO, 0},
{&handle_hello, NULL, GNUNET_MESSAGE_TYPE_HELLO, 0},
{&handle_get, NULL, GNUNET_MESSAGE_TYPE_PEERINFO_GET,
sizeof (struct ListPeerMessage)},
Modified: gnunet/src/peerinfo/peerinfo.conf.in
===================================================================
--- gnunet/src/peerinfo/peerinfo.conf.in 2013-04-04 09:25:22 UTC (rev
26750)
+++ gnunet/src/peerinfo/peerinfo.conf.in 2013-04-04 09:43:10 UTC (rev
26751)
@@ -18,7 +18,7 @@
# REJECT_FROM =
# REJECT_FROM6 =
# PREFIX =
-HOSTS = $SERVICEHOME/data/hosts/
+HOSTS = $SERVICEHOME/peerinfo/
# Option to disable all disk IO; only useful for testbed runs
# (large-scale experiments); disables persistence of HELLOs!
Modified: gnunet/src/testbed/gnunet-service-testbed_oc.c
===================================================================
--- gnunet/src/testbed/gnunet-service-testbed_oc.c 2013-04-04 09:25:22 UTC
(rev 26750)
+++ gnunet/src/testbed/gnunet-service-testbed_oc.c 2013-04-04 09:43:10 UTC
(rev 26751)
@@ -1514,8 +1514,7 @@
}
msg = (const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *) message;
if ((NULL == msg->hello) ||
- ((GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type)) &&
- (GNUNET_MESSAGE_TYPE_FRIEND_HELLO != ntohs (msg->hello->type))))
+ ((GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type))))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
Modified: gnunet/src/topology/gnunet-daemon-topology.c
===================================================================
--- gnunet/src/topology/gnunet-daemon-topology.c 2013-04-04 09:25:22 UTC
(rev 26750)
+++ gnunet/src/topology/gnunet-daemon-topology.c 2013-04-04 09:43:10 UTC
(rev 26751)
@@ -1274,7 +1274,6 @@
{
static struct GNUNET_CORE_MessageHandler handlers[] = {
{&handle_encrypted_hello, GNUNET_MESSAGE_TYPE_HELLO, 0},
- {&handle_encrypted_hello, GNUNET_MESSAGE_TYPE_FRIEND_HELLO, 0},
{NULL, 0, 0}
};
unsigned long long opt;
Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c 2013-04-04 09:25:22 UTC
(rev 26750)
+++ gnunet/src/transport/gnunet-service-transport.c 2013-04-04 09:43:10 UTC
(rev 26751)
@@ -242,7 +242,6 @@
switch (type)
{
case GNUNET_MESSAGE_TYPE_HELLO:
- case GNUNET_MESSAGE_TYPE_FRIEND_HELLO:
GST_validation_handle_hello (message);
return ret;
case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c 2013-04-04
09:25:22 UTC (rev 26750)
+++ gnunet/src/transport/gnunet-service-transport_clients.c 2013-04-04
09:43:10 UTC (rev 26751)
@@ -978,8 +978,6 @@
GNUNET_MESSAGE_TYPE_TRANSPORT_START, sizeof (struct StartMessage)},
{&clients_handle_hello, NULL,
GNUNET_MESSAGE_TYPE_HELLO, 0},
- {&clients_handle_hello, NULL,
- GNUNET_MESSAGE_TYPE_FRIEND_HELLO, 0},
{&clients_handle_send, NULL,
GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, 0},
{&clients_handle_request_connect, NULL,
Modified: gnunet/src/transport/gnunet-service-transport_validation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.c 2013-04-04
09:25:22 UTC (rev 26750)
+++ gnunet/src/transport/gnunet-service-transport_validation.c 2013-04-04
09:43:10 UTC (rev 26751)
@@ -1283,11 +1283,11 @@
(const struct GNUNET_HELLO_Message *) hello;
struct ValidateAddressContext vac;
struct GNUNET_HELLO_Message *h;
- int type;
int friend;
-
- if ((GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) ||
+ friend = GNUNET_HELLO_is_friend_only (hm);
+ if (((GNUNET_YES != friend) && (GNUNET_NO != friend)) ||
+ (GNUNET_OK != GNUNET_HELLO_get_id (hm, &vac.pid)) ||
(GNUNET_OK != GNUNET_HELLO_get_key (hm, &vac.public_key)))
{
/* malformed HELLO */
@@ -1298,19 +1298,6 @@
memcmp (&GST_my_identity, &vac.pid, sizeof (struct GNUNET_PeerIdentity)))
return;
/* Add peer identity without addresses to peerinfo service */
- type = ntohs(hello->type);
- switch (type) {
- case GNUNET_MESSAGE_TYPE_HELLO:
- friend = GNUNET_NO;
- break;
- case GNUNET_MESSAGE_TYPE_FRIEND_HELLO:
- friend = GNUNET_YES;
- break;
- default:
- GNUNET_break (0);
- friend = GNUNET_NO;
- break;
- }
h = GNUNET_HELLO_create (&vac.public_key, NULL, NULL, friend);
GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL);
Modified: gnunet/src/transport/plugin_transport_udp_broadcasting.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp_broadcasting.c 2013-04-04
09:25:22 UTC (rev 26750)
+++ gnunet/src/transport/plugin_transport_udp_broadcasting.c 2013-04-04
09:43:10 UTC (rev 26751)
@@ -394,6 +394,17 @@
void
setup_broadcast (struct Plugin *plugin, struct sockaddr_in6 *serverAddrv6,
struct sockaddr_in *serverAddrv4)
{
+ const struct GNUNET_MessageHeader *hello;
+ hello = plugin->env->get_our_hello ();
+
+ if (GNUNET_YES == GNUNET_HELLO_is_friend_only((const struct
GNUNET_HELLO_Message *) hello))
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ _("Disabling HELLO broadcasting due to friend-to-friend only
configuration!\n"));
+ return;
+ }
+
+
/* create IPv4 broadcast socket */
plugin->broadcast_ipv4 = GNUNET_NO;
if (plugin->sockv4 != NULL)
Modified: gnunet/src/transport/plugin_transport_wlan.c
===================================================================
--- gnunet/src/transport/plugin_transport_wlan.c 2013-04-04 09:25:22 UTC
(rev 26750)
+++ gnunet/src/transport/plugin_transport_wlan.c 2013-04-04 09:43:10 UTC
(rev 26751)
@@ -1149,7 +1149,6 @@
switch (ntohs (hdr->type))
{
- case GNUNET_MESSAGE_TYPE_FRIEND_HELLO:
case GNUNET_MESSAGE_TYPE_HELLO:
if (GNUNET_OK !=
GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hdr,
&tmpsource))
Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c 2013-04-04 09:25:22 UTC (rev
26750)
+++ gnunet/src/transport/transport_api.c 2013-04-04 09:43:10 UTC (rev
26751)
@@ -497,7 +497,6 @@
switch (ntohs (msg->type))
{
case GNUNET_MESSAGE_TYPE_HELLO:
- case GNUNET_MESSAGE_TYPE_FRIEND_HELLO:
if (GNUNET_OK !=
GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) msg, &me))
{
@@ -1293,8 +1292,7 @@
if (NULL == handle->client)
return NULL;
- GNUNET_break ((ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO) ||
- (ntohs (hello->type) ==
GNUNET_MESSAGE_TYPE_FRIEND_HELLO));
+ GNUNET_break (ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO);
size = ntohs (hello->size);
GNUNET_break (size >= sizeof (struct GNUNET_MessageHeader));
if (GNUNET_OK !=
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r26751 - in gnunet/src: hello include peerinfo testbed topology transport,
gnunet <=