diff options
Diffstat (limited to 'src/core/gnunet-service-core.c')
-rw-r--r-- | src/core/gnunet-service-core.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 29f084d04..bfb17b6c8 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -1307,6 +1307,49 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
1307 | 1307 | ||
1308 | 1308 | ||
1309 | /** | 1309 | /** |
1310 | * Handle CORE_ITERATE_PEERS request. | ||
1311 | */ | ||
1312 | static void | ||
1313 | handle_client_iterate_peers (void *cls, | ||
1314 | struct GNUNET_SERVER_Client *client, | ||
1315 | const struct GNUNET_MessageHeader *message) | ||
1316 | |||
1317 | { | ||
1318 | struct Neighbour *n; | ||
1319 | struct ConnectNotifyMessage cnm; | ||
1320 | struct GNUNET_MessageHeader done_msg; | ||
1321 | struct GNUNET_SERVER_TransmitContext *tc; | ||
1322 | |||
1323 | /* notify new client about existing neighbours */ | ||
1324 | cnm.header.size = htons (sizeof (struct ConnectNotifyMessage)); | ||
1325 | cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT); | ||
1326 | done_msg.size = htons (sizeof (struct GNUNET_MessageHeader)); | ||
1327 | done_msg.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT); | ||
1328 | tc = GNUNET_SERVER_transmit_context_create (client); | ||
1329 | n = neighbours; | ||
1330 | cnm.ats_count = htonl (0); | ||
1331 | cnm.ats.type = htonl (0); | ||
1332 | cnm.ats.value = htonl (0); | ||
1333 | while (n != NULL) | ||
1334 | { | ||
1335 | if (n->status == PEER_STATE_KEY_CONFIRMED) | ||
1336 | { | ||
1337 | #if DEBUG_CORE_CLIENT | ||
1338 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1339 | "Sending `%s' message to client.\n", "NOTIFY_CONNECT"); | ||
1340 | #endif | ||
1341 | cnm.peer = n->peer; | ||
1342 | GNUNET_SERVER_transmit_context_append_message (tc, &cnm.header); | ||
1343 | } | ||
1344 | n = n->next; | ||
1345 | } | ||
1346 | GNUNET_SERVER_transmit_context_append_message (tc, &done_msg); | ||
1347 | GNUNET_SERVER_transmit_context_run (tc, | ||
1348 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
1349 | } | ||
1350 | |||
1351 | |||
1352 | /** | ||
1310 | * Handle REQUEST_INFO request. | 1353 | * Handle REQUEST_INFO request. |
1311 | */ | 1354 | */ |
1312 | static void | 1355 | static void |
@@ -4191,6 +4234,9 @@ run (void *cls, | |||
4191 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 4234 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
4192 | {&handle_client_init, NULL, | 4235 | {&handle_client_init, NULL, |
4193 | GNUNET_MESSAGE_TYPE_CORE_INIT, 0}, | 4236 | GNUNET_MESSAGE_TYPE_CORE_INIT, 0}, |
4237 | {&handle_client_iterate_peers, NULL, | ||
4238 | GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS, | ||
4239 | sizeof (struct GNUNET_MessageHeader)}, | ||
4194 | {&handle_client_request_info, NULL, | 4240 | {&handle_client_request_info, NULL, |
4195 | GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO, | 4241 | GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO, |
4196 | sizeof (struct RequestInfoMessage)}, | 4242 | sizeof (struct RequestInfoMessage)}, |