summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2021-09-20 19:08:36 +0200
committerChristian Grothoff <grothoff@gnunet.org>2021-09-20 19:27:30 +0200
commit33d31c58c1036acdef9f7d6cb3bb27881e6e26cb (patch)
tree3b4b2cfe308542fbe98a3f28c29aaf6f375f2e2a /src
parent200d95be000f9c0a9beca91370e754368d6bc59a (diff)
dhtu: handle connect
Diffstat (limited to 'src')
-rw-r--r--src/dhtu/plugin_dhtu_gnunet.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c
index ccd329e8e..e01f90bde 100644
--- a/src/dhtu/plugin_dhtu_gnunet.c
+++ b/src/dhtu/plugin_dhtu_gnunet.c
@@ -40,6 +40,7 @@ struct GNUNET_DHTU_PrivateKey
};
+GNUNET_NETWORK_STRUCT_BEGIN
/**
* Handle for a public key used by this underlay.
@@ -55,11 +56,13 @@ struct PublicKey
/**
* GNUnet uses eddsa for peers.
*/
- struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
+ struct GNUNET_PeerIdentity peer_pub;
};
+GNUNET_NETWORK_STRUCT_END
+
/**
* Opaque handle that the underlay offers for our address to be used when
* sending messages to another peer.
@@ -87,6 +90,22 @@ struct GNUNET_DHTU_Target
void *app_ctx;
/**
+ * CORE MQ to send messages to this peer.
+ */
+ struct GNUNET_MQ_Handle *mq;
+
+ /**
+ * Public key of the peer.
+ */
+ struct PublicKey pk;
+
+ /**
+ * Hash of the @a pk to identify position of the peer
+ * in the DHT.
+ */
+ struct GNUNET_DHTU_Hash peer_id;
+
+ /**
* Head of preferences expressed for this target.
*/
struct GNUNET_DHTU_PreferenceHandle *ph_head;
@@ -204,7 +223,7 @@ ip_verify (void *cls,
GNUNET_CRYPTO_eddsa_verify_ (ntohl (purpose->purpose),
purpose,
es,
- &pub->eddsa_pub))
+ &pub->peer_pub.public_key))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@@ -311,7 +330,22 @@ core_connect_cb (void *cls,
const struct GNUNET_PeerIdentity *peer,
struct GNUNET_MQ_Handle *mq)
{
- return NULL;
+ struct Plugin *plugin = cls;
+ struct GNUNET_DHTU_Target *target;
+
+ target = GNUNET_new (struct GNUNET_DHTU_Target);
+ target->mq = mq;
+ target->pk.header.size = htons (sizeof (struct PublicKey));
+ target->pk.peer_pub = *peer;
+ GNUNET_CRYPTO_hash (peer,
+ sizeof (struct GNUNET_PeerIdentity),
+ &target->peer_id.hc);
+ plugin->env->connect_cb (plugin->env->cls,
+ &target->pk.header,
+ &target->peer_id,
+ target,
+ &target->app_ctx);
+ return target;
}