aboutsummaryrefslogtreecommitdiff
path: root/src/dht/dht_api_find_peer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/dht_api_find_peer.c')
-rw-r--r--src/dht/dht_api_find_peer.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/dht/dht_api_find_peer.c b/src/dht/dht_api_find_peer.c
index 8196e394c..bcf1b50b7 100644
--- a/src/dht/dht_api_find_peer.c
+++ b/src/dht/dht_api_find_peer.c
@@ -71,28 +71,29 @@ struct GNUNET_DHT_FindPeerHandle
71 * @param reply response 71 * @param reply response
72 */ 72 */
73static void 73static void
74find_peer_reply_iterator (void *cls, 74find_peer_reply_iterator (void *cls,
75 const GNUNET_HashCode *key, 75 const GNUNET_HashCode * key,
76 const struct GNUNET_PeerIdentity * const *outgoing_path, 76 const struct GNUNET_PeerIdentity *const
77 const struct GNUNET_MessageHeader *reply) 77 *outgoing_path,
78 const struct GNUNET_MessageHeader *reply)
78{ 79{
79 struct GNUNET_DHT_FindPeerHandle *find_peer_handle = cls; 80 struct GNUNET_DHT_FindPeerHandle *find_peer_handle = cls;
80 const struct GNUNET_MessageHeader *hello; 81 const struct GNUNET_MessageHeader *hello;
81 82
82 if (ntohs (reply->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT) 83 if (ntohs (reply->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT)
83 { 84 {
84 GNUNET_break (0); 85 GNUNET_break (0);
85 return; 86 return;
86 } 87 }
87 GNUNET_assert (ntohs (reply->size) >= sizeof (struct GNUNET_MessageHeader)); 88 GNUNET_assert (ntohs (reply->size) >= sizeof (struct GNUNET_MessageHeader));
88 hello = (const struct GNUNET_MessageHeader *)&reply[1]; 89 hello = (const struct GNUNET_MessageHeader *) &reply[1];
89 if (ntohs(hello->type) != GNUNET_MESSAGE_TYPE_HELLO) 90 if (ntohs (hello->type) != GNUNET_MESSAGE_TYPE_HELLO)
90 { 91 {
91 GNUNET_break (0); 92 GNUNET_break (0);
92 return; 93 return;
93 } 94 }
94 find_peer_handle->proc (find_peer_handle->proc_cls, 95 find_peer_handle->proc (find_peer_handle->proc_cls,
95 (const struct GNUNET_HELLO_Message *)hello); 96 (const struct GNUNET_HELLO_Message *) hello);
96} 97}
97 98
98 99
@@ -112,27 +113,26 @@ find_peer_reply_iterator (void *cls,
112struct GNUNET_DHT_FindPeerHandle * 113struct GNUNET_DHT_FindPeerHandle *
113GNUNET_DHT_find_peer_start (struct GNUNET_DHT_Handle *handle, 114GNUNET_DHT_find_peer_start (struct GNUNET_DHT_Handle *handle,
114 struct GNUNET_TIME_Relative timeout, 115 struct GNUNET_TIME_Relative timeout,
115 const GNUNET_HashCode *key, 116 const GNUNET_HashCode * key,
116 enum GNUNET_DHT_RouteOption options, 117 enum GNUNET_DHT_RouteOption options,
117 GNUNET_DHT_FindPeerProcessor proc, 118 GNUNET_DHT_FindPeerProcessor proc, void *proc_cls)
118 void *proc_cls)
119{ 119{
120 struct GNUNET_DHT_FindPeerHandle *find_peer_handle; 120 struct GNUNET_DHT_FindPeerHandle *find_peer_handle;
121 struct GNUNET_DHT_FindPeerMessage find_peer_msg; 121 struct GNUNET_DHT_FindPeerMessage find_peer_msg;
122 122
123 find_peer_handle = 123 find_peer_handle = GNUNET_malloc (sizeof (struct GNUNET_DHT_FindPeerHandle));
124 GNUNET_malloc (sizeof (struct GNUNET_DHT_FindPeerHandle));
125 find_peer_handle->proc = proc; 124 find_peer_handle->proc = proc;
126 find_peer_handle->proc_cls = proc_cls; 125 find_peer_handle->proc_cls = proc_cls;
127 find_peer_msg.header.size = htons(sizeof(struct GNUNET_DHT_FindPeerMessage)); 126 find_peer_msg.header.size =
128 find_peer_msg.header.type = htons(GNUNET_MESSAGE_TYPE_DHT_FIND_PEER); 127 htons (sizeof (struct GNUNET_DHT_FindPeerMessage));
128 find_peer_msg.header.type = htons (GNUNET_MESSAGE_TYPE_DHT_FIND_PEER);
129 find_peer_handle->route_handle = 129 find_peer_handle->route_handle =
130 GNUNET_DHT_route_start (handle, key, 130 GNUNET_DHT_route_start (handle, key,
131 0, options, 131 0, options,
132 &find_peer_msg.header, 132 &find_peer_msg.header,
133 timeout, 133 timeout,
134 &find_peer_reply_iterator, find_peer_handle, 134 &find_peer_reply_iterator, find_peer_handle,
135 NULL, NULL); 135 NULL, NULL);
136 GNUNET_break (find_peer_handle->route_handle != NULL); 136 GNUNET_break (find_peer_handle->route_handle != NULL);
137 return find_peer_handle; 137 return find_peer_handle;
138} 138}