aboutsummaryrefslogtreecommitdiff
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
parent200d95be000f9c0a9beca91370e754368d6bc59a (diff)
downloadgnunet-33d31c58c1036acdef9f7d6cb3bb27881e6e26cb.tar.gz
gnunet-33d31c58c1036acdef9f7d6cb3bb27881e6e26cb.zip
dhtu: handle connect
-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
40 40
41}; 41};
42 42
43GNUNET_NETWORK_STRUCT_BEGIN
43 44
44/** 45/**
45 * Handle for a public key used by this underlay. 46 * Handle for a public key used by this underlay.
@@ -55,11 +56,13 @@ struct PublicKey
55 /** 56 /**
56 * GNUnet uses eddsa for peers. 57 * GNUnet uses eddsa for peers.
57 */ 58 */
58 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; 59 struct GNUNET_PeerIdentity peer_pub;
59 60
60}; 61};
61 62
62 63
64GNUNET_NETWORK_STRUCT_END
65
63/** 66/**
64 * Opaque handle that the underlay offers for our address to be used when 67 * Opaque handle that the underlay offers for our address to be used when
65 * sending messages to another peer. 68 * sending messages to another peer.
@@ -87,6 +90,22 @@ struct GNUNET_DHTU_Target
87 void *app_ctx; 90 void *app_ctx;
88 91
89 /** 92 /**
93 * CORE MQ to send messages to this peer.
94 */
95 struct GNUNET_MQ_Handle *mq;
96
97 /**
98 * Public key of the peer.
99 */
100 struct PublicKey pk;
101
102 /**
103 * Hash of the @a pk to identify position of the peer
104 * in the DHT.
105 */
106 struct GNUNET_DHTU_Hash peer_id;
107
108 /**
90 * Head of preferences expressed for this target. 109 * Head of preferences expressed for this target.
91 */ 110 */
92 struct GNUNET_DHTU_PreferenceHandle *ph_head; 111 struct GNUNET_DHTU_PreferenceHandle *ph_head;
@@ -204,7 +223,7 @@ ip_verify (void *cls,
204 GNUNET_CRYPTO_eddsa_verify_ (ntohl (purpose->purpose), 223 GNUNET_CRYPTO_eddsa_verify_ (ntohl (purpose->purpose),
205 purpose, 224 purpose,
206 es, 225 es,
207 &pub->eddsa_pub)) 226 &pub->peer_pub.public_key))
208 { 227 {
209 GNUNET_break_op (0); 228 GNUNET_break_op (0);
210 return GNUNET_SYSERR; 229 return GNUNET_SYSERR;
@@ -311,7 +330,22 @@ core_connect_cb (void *cls,
311 const struct GNUNET_PeerIdentity *peer, 330 const struct GNUNET_PeerIdentity *peer,
312 struct GNUNET_MQ_Handle *mq) 331 struct GNUNET_MQ_Handle *mq)
313{ 332{
314 return NULL; 333 struct Plugin *plugin = cls;
334 struct GNUNET_DHTU_Target *target;
335
336 target = GNUNET_new (struct GNUNET_DHTU_Target);
337 target->mq = mq;
338 target->pk.header.size = htons (sizeof (struct PublicKey));
339 target->pk.peer_pub = *peer;
340 GNUNET_CRYPTO_hash (peer,
341 sizeof (struct GNUNET_PeerIdentity),
342 &target->peer_id.hc);
343 plugin->env->connect_cb (plugin->env->cls,
344 &target->pk.header,
345 &target->peer_id,
346 target,
347 &target->app_ctx);
348 return target;
315} 349}
316 350
317 351