diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-06 22:10:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-06 22:10:48 +0000 |
commit | 5c862712d9c389fced47fde9abdc9458da319aef (patch) | |
tree | 3d17ba8b4fc5ef821882b65aaf6c3d1a798c6ed3 /src/transport/gnunet-service-transport_clients.c | |
parent | 55c16b6ab6a83a594303efccff1e59a022470982 (diff) | |
download | gnunet-5c862712d9c389fced47fde9abdc9458da319aef.tar.gz gnunet-5c862712d9c389fced47fde9abdc9458da319aef.zip |
removing GNUNET_TRANSPORT_monitor_validation-API
Diffstat (limited to 'src/transport/gnunet-service-transport_clients.c')
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 265 |
1 files changed, 0 insertions, 265 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index b9bccc08b..3df62011c 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -244,16 +244,6 @@ static struct MonitoringClient *peer_monitoring_clients_head; | |||
244 | static struct MonitoringClient *peer_monitoring_clients_tail; | 244 | static struct MonitoringClient *peer_monitoring_clients_tail; |
245 | 245 | ||
246 | /** | 246 | /** |
247 | * Head of linked list of validation monitoring clients. | ||
248 | */ | ||
249 | static struct MonitoringClient *val_monitoring_clients_head; | ||
250 | |||
251 | /** | ||
252 | * Tail of linked list of validation monitoring clients. | ||
253 | */ | ||
254 | static struct MonitoringClient *val_monitoring_clients_tail; | ||
255 | |||
256 | /** | ||
257 | * Notification context, to send updates on changes to active addresses | 247 | * Notification context, to send updates on changes to active addresses |
258 | * of our neighbours. | 248 | * of our neighbours. |
259 | */ | 249 | */ |
@@ -387,47 +377,6 @@ setup_peer_monitoring_client (struct GNUNET_SERVER_Client *client, | |||
387 | 377 | ||
388 | 378 | ||
389 | /** | 379 | /** |
390 | * Setup a new monitoring client using the given server client handle and | ||
391 | * the peer identity. | ||
392 | * | ||
393 | * @param client server's client handle to create our internal handle for | ||
394 | * @param peer identity of the peer to monitor the addresses of, | ||
395 | * zero to monitor all neighrours. | ||
396 | * @return handle to the new monitoring client | ||
397 | */ | ||
398 | static struct MonitoringClient * | ||
399 | setup_val_monitoring_client (struct GNUNET_SERVER_Client *client, | ||
400 | struct GNUNET_PeerIdentity *peer) | ||
401 | { | ||
402 | struct MonitoringClient *mc; | ||
403 | |||
404 | GNUNET_assert (NULL == | ||
405 | lookup_monitoring_client (val_monitoring_clients_head, | ||
406 | client)); | ||
407 | mc = GNUNET_new (struct MonitoringClient); | ||
408 | mc->client = client; | ||
409 | mc->peer = *peer; | ||
410 | GNUNET_CONTAINER_DLL_insert (val_monitoring_clients_head, | ||
411 | val_monitoring_clients_tail, | ||
412 | mc); | ||
413 | GNUNET_SERVER_notification_context_add (val_nc, client); | ||
414 | |||
415 | if (0 != memcmp (peer, | ||
416 | &all_zeros, | ||
417 | sizeof (struct GNUNET_PeerIdentity))) | ||
418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
419 | "Client %p started monitoring of the peer `%s'\n", | ||
420 | mc, | ||
421 | GNUNET_i2s (peer)); | ||
422 | else | ||
423 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
424 | "Client %p started monitoring all peers\n", | ||
425 | mc); | ||
426 | return mc; | ||
427 | } | ||
428 | |||
429 | |||
430 | /** | ||
431 | * Function called to notify a client about the socket being ready to | 380 | * Function called to notify a client about the socket being ready to |
432 | * queue more data. @a buf will be NULL and @a size zero if the socket | 381 | * queue more data. @a buf will be NULL and @a size zero if the socket |
433 | * was closed for writing in the meantime. | 382 | * was closed for writing in the meantime. |
@@ -568,15 +517,6 @@ client_disconnect_notification (void *cls, | |||
568 | mc); | 517 | mc); |
569 | GNUNET_free (mc); | 518 | GNUNET_free (mc); |
570 | } | 519 | } |
571 | mc = lookup_monitoring_client (val_monitoring_clients_head, | ||
572 | client); | ||
573 | if (NULL != mc) | ||
574 | { | ||
575 | GNUNET_CONTAINER_DLL_remove (val_monitoring_clients_head, | ||
576 | val_monitoring_clients_tail, | ||
577 | mc); | ||
578 | GNUNET_free (mc); | ||
579 | } | ||
580 | tc = lookup_client (client); | 520 | tc = lookup_client (client); |
581 | if (NULL == tc) | 521 | if (NULL == tc) |
582 | return; | 522 | return; |
@@ -1091,55 +1031,6 @@ compose_address_iterate_response_message (const struct GNUNET_PeerIdentity *peer | |||
1091 | 1031 | ||
1092 | 1032 | ||
1093 | /** | 1033 | /** |
1094 | * Compose #PeerIterateResponseMessage using the given peer and address. | ||
1095 | * | ||
1096 | * @param peer identity of the peer | ||
1097 | * @param address the address, NULL on disconnect | ||
1098 | * @return composed message | ||
1099 | */ | ||
1100 | static struct ValidationIterateResponseMessage * | ||
1101 | compose_validation_iterate_response_message (const struct GNUNET_PeerIdentity *peer, | ||
1102 | const struct GNUNET_HELLO_Address *address) | ||
1103 | { | ||
1104 | struct ValidationIterateResponseMessage *msg; | ||
1105 | size_t size; | ||
1106 | size_t tlen; | ||
1107 | size_t alen; | ||
1108 | char *addr; | ||
1109 | |||
1110 | GNUNET_assert (NULL != peer); | ||
1111 | if (NULL != address) | ||
1112 | { | ||
1113 | tlen = strlen (address->transport_name) + 1; | ||
1114 | alen = address->address_length; | ||
1115 | } | ||
1116 | else | ||
1117 | { | ||
1118 | tlen = 0; | ||
1119 | alen = 0; | ||
1120 | } | ||
1121 | size = (sizeof (struct ValidationIterateResponseMessage) + alen + tlen); | ||
1122 | msg = GNUNET_malloc (size); | ||
1123 | msg->header.size = htons (size); | ||
1124 | msg->header.type = | ||
1125 | htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE); | ||
1126 | msg->reserved = htonl (0); | ||
1127 | msg->peer = *peer; | ||
1128 | msg->addrlen = htonl (alen); | ||
1129 | msg->pluginlen = htonl (tlen); | ||
1130 | |||
1131 | if (NULL != address) | ||
1132 | { | ||
1133 | msg->local_address_info = htonl((uint32_t) address->local_info); | ||
1134 | addr = (char *) &msg[1]; | ||
1135 | memcpy (addr, address->address, alen); | ||
1136 | memcpy (&addr[alen], address->transport_name, tlen); | ||
1137 | } | ||
1138 | return msg; | ||
1139 | } | ||
1140 | |||
1141 | |||
1142 | /** | ||
1143 | * Context for #send_validation_information() and | 1034 | * Context for #send_validation_information() and |
1144 | * #send_peer_information(). | 1035 | * #send_peer_information(). |
1145 | */ | 1036 | */ |
@@ -1163,44 +1054,6 @@ struct IterationContext | |||
1163 | 1054 | ||
1164 | 1055 | ||
1165 | /** | 1056 | /** |
1166 | * Output information of validation entries to the given client. | ||
1167 | * | ||
1168 | * @param cls the `struct IterationContext *` | ||
1169 | * @param address the address | ||
1170 | * @param last_validation point in time when last validation was performed | ||
1171 | * @param valid_until point in time how long address is valid | ||
1172 | * @param next_validation point in time when next validation will be performed | ||
1173 | * @param state state of validation notification | ||
1174 | */ | ||
1175 | static void | ||
1176 | send_validation_information (void *cls, | ||
1177 | const struct GNUNET_HELLO_Address *address, | ||
1178 | struct GNUNET_TIME_Absolute last_validation, | ||
1179 | struct GNUNET_TIME_Absolute valid_until, | ||
1180 | struct GNUNET_TIME_Absolute next_validation, | ||
1181 | enum GNUNET_TRANSPORT_ValidationState state) | ||
1182 | { | ||
1183 | struct IterationContext *pc = cls; | ||
1184 | struct ValidationIterateResponseMessage *msg; | ||
1185 | |||
1186 | if ( (GNUNET_YES != pc->all) && | ||
1187 | (0 != memcmp (&address->peer, &pc->id, sizeof (pc->id))) ) | ||
1188 | return; | ||
1189 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1190 | "Sending information about for validation entry for peer `%s' using address `%s'\n", | ||
1191 | GNUNET_i2s (&address->peer), | ||
1192 | (NULL != address) ? GST_plugins_a2s (address) : "<none>"); | ||
1193 | msg = compose_validation_iterate_response_message (&address->peer, address); | ||
1194 | msg->last_validation = GNUNET_TIME_absolute_hton(last_validation); | ||
1195 | msg->valid_until = GNUNET_TIME_absolute_hton(valid_until); | ||
1196 | msg->next_validation = GNUNET_TIME_absolute_hton(next_validation); | ||
1197 | msg->state = htonl ((uint32_t) state); | ||
1198 | GNUNET_SERVER_transmit_context_append_message (pc->tc, &msg->header); | ||
1199 | GNUNET_free (msg); | ||
1200 | } | ||
1201 | |||
1202 | |||
1203 | /** | ||
1204 | * Output information of neighbours to the given client. | 1057 | * Output information of neighbours to the given client. |
1205 | * | 1058 | * |
1206 | * @param cls the `struct PeerIterationContext *` | 1059 | * @param cls the `struct PeerIterationContext *` |
@@ -1306,78 +1159,6 @@ clients_handle_monitor_peers (void *cls, | |||
1306 | 1159 | ||
1307 | 1160 | ||
1308 | /** | 1161 | /** |
1309 | * Client asked to obtain information about a specific or all validation | ||
1310 | * processes | ||
1311 | * | ||
1312 | * @param cls unused | ||
1313 | * @param client the client | ||
1314 | * @param message the peer address information request | ||
1315 | */ | ||
1316 | static void | ||
1317 | clients_handle_monitor_validation (void *cls, | ||
1318 | struct GNUNET_SERVER_Client *client, | ||
1319 | const struct GNUNET_MessageHeader *message) | ||
1320 | { | ||
1321 | struct GNUNET_SERVER_TransmitContext *tc; | ||
1322 | struct PeerMonitorMessage *msg; | ||
1323 | struct IterationContext pc; | ||
1324 | |||
1325 | if (ntohs (message->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_REQUEST) | ||
1326 | { | ||
1327 | GNUNET_break (0); | ||
1328 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1329 | return; | ||
1330 | } | ||
1331 | if (ntohs (message->size) != sizeof (struct ValidationMonitorMessage)) | ||
1332 | { | ||
1333 | GNUNET_break (0); | ||
1334 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1335 | return; | ||
1336 | } | ||
1337 | msg = (struct PeerMonitorMessage *) message; | ||
1338 | if ( (GNUNET_YES != ntohl (msg->one_shot)) && | ||
1339 | (NULL != lookup_monitoring_client (val_monitoring_clients_head, client)) ) | ||
1340 | { | ||
1341 | GNUNET_break (0); | ||
1342 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1343 | return; | ||
1344 | } | ||
1345 | GNUNET_SERVER_disable_receive_done_warning (client); | ||
1346 | GNUNET_SERVER_client_mark_monitor (client); | ||
1347 | pc.tc = tc = GNUNET_SERVER_transmit_context_create (client); | ||
1348 | |||
1349 | /* Send initial list */ | ||
1350 | if (0 == memcmp (&msg->peer, | ||
1351 | &all_zeros, | ||
1352 | sizeof (struct GNUNET_PeerIdentity))) | ||
1353 | { | ||
1354 | /* iterate over all neighbours */ | ||
1355 | pc.all = GNUNET_YES; | ||
1356 | pc.id = msg->peer; | ||
1357 | } | ||
1358 | else | ||
1359 | { | ||
1360 | /* just return one neighbour */ | ||
1361 | pc.all = GNUNET_NO; | ||
1362 | pc.id = msg->peer; | ||
1363 | } | ||
1364 | GST_validation_iterate (&send_validation_information, | ||
1365 | &pc); | ||
1366 | |||
1367 | if (GNUNET_YES != ntohl (msg->one_shot)) | ||
1368 | { | ||
1369 | setup_val_monitoring_client (client, &msg->peer); | ||
1370 | } | ||
1371 | else | ||
1372 | { | ||
1373 | GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, | ||
1374 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE); | ||
1375 | } | ||
1376 | GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL); | ||
1377 | } | ||
1378 | |||
1379 | |||
1380 | /** | ||
1381 | * Function called by the plugin with information about the | 1162 | * Function called by the plugin with information about the |
1382 | * current sessions managed by the plugin (for monitoring). | 1163 | * current sessions managed by the plugin (for monitoring). |
1383 | * | 1164 | * |
@@ -1514,9 +1295,6 @@ GST_clients_start (struct GNUNET_SERVER_Handle *server) | |||
1514 | {&clients_handle_monitor_peers, NULL, | 1295 | {&clients_handle_monitor_peers, NULL, |
1515 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST, | 1296 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST, |
1516 | sizeof (struct PeerMonitorMessage)}, | 1297 | sizeof (struct PeerMonitorMessage)}, |
1517 | {&clients_handle_monitor_validation, NULL, | ||
1518 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_REQUEST, | ||
1519 | sizeof (struct ValidationMonitorMessage)}, | ||
1520 | {&GST_blacklist_handle_init, NULL, | 1298 | {&GST_blacklist_handle_init, NULL, |
1521 | GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT, | 1299 | GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT, |
1522 | sizeof (struct GNUNET_MessageHeader)}, | 1300 | sizeof (struct GNUNET_MessageHeader)}, |
@@ -1658,49 +1436,6 @@ GST_clients_broadcast_peer_notification (const struct GNUNET_PeerIdentity *peer, | |||
1658 | 1436 | ||
1659 | 1437 | ||
1660 | /** | 1438 | /** |
1661 | * Broadcast the new validation changes to all clients monitoring the peer. | ||
1662 | * | ||
1663 | * @param peer peer this update is about (never NULL) | ||
1664 | * @param address address, NULL on disconnect | ||
1665 | * @param last_validation point in time when last validation was performed | ||
1666 | * @param valid_until point in time how long address is valid | ||
1667 | * @param next_validation point in time when next validation will be performed | ||
1668 | * @param state state of validation notification | ||
1669 | */ | ||
1670 | void | ||
1671 | GST_clients_broadcast_validation_notification (const struct GNUNET_PeerIdentity *peer, | ||
1672 | const struct GNUNET_HELLO_Address *address, | ||
1673 | struct GNUNET_TIME_Absolute last_validation, | ||
1674 | struct GNUNET_TIME_Absolute valid_until, | ||
1675 | struct GNUNET_TIME_Absolute next_validation, | ||
1676 | enum GNUNET_TRANSPORT_ValidationState state) | ||
1677 | { | ||
1678 | struct ValidationIterateResponseMessage *msg; | ||
1679 | struct MonitoringClient *mc; | ||
1680 | |||
1681 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1682 | "Sending information about for validation entry for peer `%s' using address `%s'\n", | ||
1683 | GNUNET_i2s(peer), | ||
1684 | (address != NULL) ? GST_plugins_a2s (address) : "<none>"); | ||
1685 | msg = compose_validation_iterate_response_message (peer, address); | ||
1686 | msg->last_validation = GNUNET_TIME_absolute_hton(last_validation); | ||
1687 | msg->valid_until = GNUNET_TIME_absolute_hton(valid_until); | ||
1688 | msg->next_validation = GNUNET_TIME_absolute_hton(next_validation); | ||
1689 | msg->state = htonl ((uint32_t) state); | ||
1690 | for (mc = val_monitoring_clients_head; NULL != mc; mc = mc->next) | ||
1691 | if ((0 == memcmp (&mc->peer, &all_zeros, | ||
1692 | sizeof (struct GNUNET_PeerIdentity))) || | ||
1693 | (0 == memcmp (&mc->peer, peer, | ||
1694 | sizeof (struct GNUNET_PeerIdentity)))) | ||
1695 | GNUNET_SERVER_notification_context_unicast (val_nc, | ||
1696 | mc->client, | ||
1697 | &msg->header, | ||
1698 | GNUNET_NO); | ||
1699 | GNUNET_free (msg); | ||
1700 | } | ||
1701 | |||
1702 | |||
1703 | /** | ||
1704 | * Mark the peer as down so we don't call the continuation | 1439 | * Mark the peer as down so we don't call the continuation |
1705 | * context in the future. | 1440 | * context in the future. |
1706 | * | 1441 | * |