[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 16/20: -got basics to work with dhtu and udp+ip underlay
From: |
gnunet |
Subject: |
[gnunet] 16/20: -got basics to work with dhtu and udp+ip underlay |
Date: |
Sat, 19 Feb 2022 16:20:56 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
commit 5e041b56a98c49a944804420ad53e18707c9f823
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Jan 18 21:55:13 2022 +0100
-got basics to work with dhtu and udp+ip underlay
---
src/dht/gnunet-service-dht_neighbours.c | 36 +++++++++++++++++++++++----------
src/dhtu/plugin_dhtu_ip.c | 12 ++++++-----
src/hello/hello-uri.c | 20 +++++++++++++++---
3 files changed, 49 insertions(+), 19 deletions(-)
diff --git a/src/dht/gnunet-service-dht_neighbours.c
b/src/dht/gnunet-service-dht_neighbours.c
index c4d6b7428..e4d9ec8ea 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -2428,12 +2428,19 @@ static enum GNUNET_GenericReturnValue
check_dht_p2p_hello (void *cls,
const struct GNUNET_MessageHeader *hello)
{
- struct GNUNET_HELLO_Builder *b;
+ struct Target *t = cls;
+ struct PeerInfo *peer = t->pi;
enum GNUNET_GenericReturnValue ret;
-
- b = GNUNET_HELLO_builder_from_msg (hello);
- ret = (NULL == b) ? GNUNET_SYSERR : GNUNET_OK;
- GNUNET_HELLO_builder_free (b);
+ size_t hellob_size;
+ void *hellob;
+ struct GNUNET_TIME_Absolute expiration;
+
+ ret = GNUNET_HELLO_dht_msg_to_block (hello,
+ &peer->id,
+ &hellob,
+ &hellob_size,
+ &expiration);
+ GNUNET_free (hellob);
return ret;
}
@@ -2469,30 +2476,37 @@ GDS_u_receive (void *cls,
const void *message,
size_t message_size)
{
- struct PeerInfo *pi = *tctx;
+ struct Target *t = *tctx;
struct GNUNET_MQ_MessageHandler core_handlers[] = {
GNUNET_MQ_hd_var_size (dht_p2p_get,
GNUNET_MESSAGE_TYPE_DHT_P2P_GET,
struct PeerGetMessage,
- pi),
+ t),
GNUNET_MQ_hd_var_size (dht_p2p_put,
GNUNET_MESSAGE_TYPE_DHT_P2P_PUT,
struct PeerPutMessage,
- pi),
+ t),
GNUNET_MQ_hd_var_size (dht_p2p_result,
GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT,
struct PeerResultMessage,
- pi),
+ t),
GNUNET_MQ_hd_var_size (dht_p2p_hello,
GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO,
struct GNUNET_MessageHeader,
- pi),
+ t),
GNUNET_MQ_handler_end ()
};
const struct GNUNET_MessageHeader *mh = message;
(void) cls; /* the 'struct GDS_Underlay' */
(void) sctx; /* our receiver address */
+ if (NULL == t)
+ {
+ /* Received message claiming to originate from myself?
+ Ignore! */
+ GNUNET_break_op (0);
+ return;
+ }
if (message_size < sizeof (*mh))
{
GNUNET_break_op (0);
@@ -2506,7 +2520,7 @@ GDS_u_receive (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Handling message of type %u from peer %s\n",
ntohs (mh->type),
- GNUNET_i2s (&pi->id));
+ GNUNET_i2s (&t->pi->id));
if (GNUNET_OK !=
GNUNET_MQ_handle_message (core_handlers,
mh))
diff --git a/src/dhtu/plugin_dhtu_ip.c b/src/dhtu/plugin_dhtu_ip.c
index 617f722b5..2f6d6161e 100644
--- a/src/dhtu/plugin_dhtu_ip.c
+++ b/src/dhtu/plugin_dhtu_ip.c
@@ -809,7 +809,7 @@ read_cb (void *cls)
(cmsg->cmsg_level == IPPROTO_IPV6),
cmsg->cmsg_type,
(cmsg->cmsg_type == IP_PKTINFO),
- (cmsg->cmsg_type == IPV6_RECVPKTINFO));
+ (cmsg->cmsg_type == IPV6_PKTINFO));
if ( (cmsg->cmsg_level == IPPROTO_IP) &&
(cmsg->cmsg_type == IP_PKTINFO) )
{
@@ -824,7 +824,8 @@ read_cb (void *cls)
{
struct sockaddr_in sa = {
.sin_family = AF_INET,
- .sin_addr = pi.ipi_addr
+ .sin_addr = pi.ipi_addr,
+ .sin_port = htons (plugin->port16)
};
src = find_source (plugin,
@@ -837,7 +838,7 @@ read_cb (void *cls)
GNUNET_break (0);
}
if ( (cmsg->cmsg_level == IPPROTO_IPV6) &&
- (cmsg->cmsg_type == IPV6_RECVPKTINFO) )
+ (cmsg->cmsg_type == IPV6_PKTINFO) )
{
if (CMSG_LEN (sizeof (struct in6_pktinfo)) ==
cmsg->cmsg_len)
@@ -851,6 +852,7 @@ read_cb (void *cls)
struct sockaddr_in6 sa = {
.sin6_family = AF_INET6,
.sin6_addr = pi.ipi6_addr,
+ .sin6_port = htons (plugin->port16),
.sin6_scope_id = pi.ipi6_ifindex
};
@@ -880,8 +882,8 @@ read_cb (void *cls)
return;
}
plugin->env->receive_cb (plugin->env->cls,
- dst->app_ctx,
- src->app_ctx,
+ &dst->app_ctx,
+ &src->app_ctx,
&buf[sizeof(*pid)],
ret - sizeof (*pid));
}
diff --git a/src/hello/hello-uri.c b/src/hello/hello-uri.c
index e57d49e86..bacaf697e 100644
--- a/src/hello/hello-uri.c
+++ b/src/hello/hello-uri.c
@@ -605,9 +605,13 @@ GNUNET_HELLO_builder_to_dht_hello_msg (
priv,
buf,
&blen));
- msg = GNUNET_malloc (sizeof (*msg) + blen);
+ msg = GNUNET_malloc (sizeof (*msg)
+ + blen
+ - sizeof (*block));
msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_HELLO);
- msg->header.size = htons (sizeof (*msg) + blen);
+ msg->header.size = htons (sizeof (*msg)
+ + blen
+ - sizeof (*block));
memcpy (&msg[1],
&block[1],
blen - sizeof (*block));
@@ -745,6 +749,9 @@ GNUNET_HELLO_builder_add_address (struct
GNUNET_HELLO_Builder *builder,
"://")))
{
GNUNET_break_op (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid address `%s'\n",
+ address);
return GNUNET_SYSERR;
}
if (e == address)
@@ -847,7 +854,7 @@ GNUNET_HELLO_dht_msg_to_block (const struct
GNUNET_MessageHeader *hello,
}
if (len < sizeof (*msg))
{
- GNUNET_break (0);
+ GNUNET_break_op (0);
return GNUNET_SYSERR;
}
len -= sizeof (*msg);
@@ -863,6 +870,13 @@ GNUNET_HELLO_dht_msg_to_block (const struct
GNUNET_MessageHeader *hello,
len);
b = GNUNET_HELLO_builder_from_block (*block,
*block_size);
+ if (NULL == b)
+ {
+ GNUNET_break_op (0);
+ GNUNET_free (*block);
+ *block_size = 0;
+ return GNUNET_SYSERR;
+ }
ret = verify_hello (b,
*block_expiration,
&msg->sig);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] branch master updated (25ef40ef7 -> d68731944), gnunet, 2022/02/19
- [gnunet] 02/20: -also add serialization from/to block, gnunet, 2022/02/19
- [gnunet] 03/20: incomplete first hack of new hello-uri lib, gnunet, 2022/02/19
- [gnunet] 01/20: first steps towards usable dhtu, gnunet, 2022/02/19
- [gnunet] 04/20: -conclude hello-uri implementation and test, gnunet, 2022/02/19
- [gnunet] 09/20: -DHT now takes care of queue size limit, gnunet, 2022/02/19
- [gnunet] 07/20: -more work on DHTU integration, gnunet, 2022/02/19
- [gnunet] 08/20: rebase, gnunet, 2022/02/19
- [gnunet] 13/20: -fix port initialization in addr, gnunet, 2022/02/19
- [gnunet] 11/20: -DHT: add gnunet-dht-hello for bootstrapping, gnunet, 2022/02/19
- [gnunet] 16/20: -got basics to work with dhtu and udp+ip underlay,
gnunet <=
- [gnunet] 18/20: -fix merge issues, gnunet, 2022/02/19
- [gnunet] 20/20: -fix assertion, fix key initialization, gnunet, 2022/02/19
- [gnunet] 17/20: -try to make static analysis happy, gnunet, 2022/02/19
- [gnunet] 15/20: -adding logging, minor dthu bugfixes, gnunet, 2022/02/19
- [gnunet] 19/20: -fix htons/htonl bug introduced by message format change, gnunet, 2022/02/19
- [gnunet] 12/20: -fix crashes on new DHT load/shutdown, gnunet, 2022/02/19
- [gnunet] 10/20: -add hold/drop logic, gnunet, 2022/02/19
- [gnunet] 06/20: -implement TVG, gnunet, 2022/02/19
- [gnunet] 05/20: add new HELLO_URI block support to block plugin, gnunet, 2022/02/19
- [gnunet] 14/20: -DHT: get tests to pass, gnunet, 2022/02/19