From 33d31c58c1036acdef9f7d6cb3bb27881e6e26cb Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 20 Sep 2021 19:08:36 +0200 Subject: dhtu: handle connect --- src/dhtu/plugin_dhtu_gnunet.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'src') 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. @@ -86,6 +89,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. */ @@ -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; } -- cgit v1.2.3