diff options
-rw-r--r-- | src/ats/ats_api.c | 18 | ||||
-rw-r--r-- | src/core/Makefile.am | 1 | ||||
-rw-r--r-- | src/core/core.h | 92 | ||||
-rw-r--r-- | src/core/core_api.c | 225 | ||||
-rw-r--r-- | src/core/gnunet-service-core.c | 159 | ||||
-rw-r--r-- | src/core/gnunet-service-core_clients.c | 3 | ||||
-rw-r--r-- | src/core/gnunet-service-core_neighbours.c | 8 | ||||
-rw-r--r-- | src/core/gnunet-service-core_sessions.c | 82 | ||||
-rw-r--r-- | src/core/gnunet-service-core_sessions.h | 12 | ||||
-rw-r--r-- | src/core/test_core_api_preferences.c | 501 | ||||
-rw-r--r-- | src/include/gnunet_core_service.h | 70 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 5 |
12 files changed, 10 insertions, 1166 deletions
diff --git a/src/ats/ats_api.c b/src/ats/ats_api.c index 48f15a73f..53ab6e9ca 100644 --- a/src/ats/ats_api.c +++ b/src/ats/ats_api.c | |||
@@ -140,19 +140,21 @@ set_bw_connections (void *cls, const GNUNET_HashCode * key, void *value) | |||
140 | ar->bandwidth_out = sbc->bw_out; | 140 | ar->bandwidth_out = sbc->bw_out; |
141 | GNUNET_BANDWIDTH_tracker_update_quota (&ar->available_recv_window, | 141 | GNUNET_BANDWIDTH_tracker_update_quota (&ar->available_recv_window, |
142 | ar->bandwidth_in); | 142 | ar->bandwidth_in); |
143 | sbc->atc->alloc_cb (sbc->atc->alloc_cb_cls, | 143 | if (NULL != sbc->atc->alloc_cb) |
144 | (const struct GNUNET_PeerIdentity *) key, | 144 | sbc->atc->alloc_cb (sbc->atc->alloc_cb_cls, |
145 | ar->plugin_name, ar->session, ar->plugin_addr, | 145 | (const struct GNUNET_PeerIdentity *) key, |
146 | ar->plugin_addr_len, ar->bandwidth_out, ar->bandwidth_in); | 146 | ar->plugin_name, ar->session, ar->plugin_addr, |
147 | ar->plugin_addr_len, ar->bandwidth_out, ar->bandwidth_in); | ||
147 | } | 148 | } |
148 | else if (ntohl (ar->bandwidth_out.value__) > 0) | 149 | else if (ntohl (ar->bandwidth_out.value__) > 0) |
149 | { | 150 | { |
150 | ar->bandwidth_in = GNUNET_BANDWIDTH_value_init (0); | 151 | ar->bandwidth_in = GNUNET_BANDWIDTH_value_init (0); |
151 | ar->bandwidth_out = GNUNET_BANDWIDTH_value_init (0); | 152 | ar->bandwidth_out = GNUNET_BANDWIDTH_value_init (0); |
152 | sbc->atc->alloc_cb (sbc->atc->alloc_cb_cls, | 153 | if (NULL != sbc->atc->alloc_cb) |
153 | (const struct GNUNET_PeerIdentity *) key, | 154 | sbc->atc->alloc_cb (sbc->atc->alloc_cb_cls, |
154 | ar->plugin_name, ar->session, ar->plugin_addr, | 155 | (const struct GNUNET_PeerIdentity *) key, |
155 | ar->plugin_addr_len, ar->bandwidth_out, ar->bandwidth_in); | 156 | ar->plugin_name, ar->session, ar->plugin_addr, |
157 | ar->plugin_addr_len, ar->bandwidth_out, ar->bandwidth_in); | ||
156 | } | 158 | } |
157 | return GNUNET_YES; | 159 | return GNUNET_YES; |
158 | } | 160 | } |
diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 9c559f764..f9c1a18e0 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am | |||
@@ -68,7 +68,6 @@ gnunet_core_list_connections_DEPENDENCIES = \ | |||
68 | check_PROGRAMS = \ | 68 | check_PROGRAMS = \ |
69 | test_core_api_start_only \ | 69 | test_core_api_start_only \ |
70 | test_core_api \ | 70 | test_core_api \ |
71 | test_core_api_preferences \ | ||
72 | test_core_api_reliability \ | 71 | test_core_api_reliability \ |
73 | test_core_quota_compliance_symmetric \ | 72 | test_core_quota_compliance_symmetric \ |
74 | test_core_quota_compliance_asymmetric_send_limited \ | 73 | test_core_quota_compliance_asymmetric_send_limited \ |
diff --git a/src/core/core.h b/src/core/core.h index f57d2b597..abbe9acc0 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
@@ -239,98 +239,6 @@ struct NotifyTrafficMessage | |||
239 | 239 | ||
240 | 240 | ||
241 | /** | 241 | /** |
242 | * Message sent to the core asking for configuration | ||
243 | * information and possibly preference changes. | ||
244 | */ | ||
245 | struct RequestInfoMessage | ||
246 | { | ||
247 | /** | ||
248 | * Header with type GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONFIGURE | ||
249 | */ | ||
250 | struct GNUNET_MessageHeader header; | ||
251 | |||
252 | /** | ||
253 | * Unique request ID. | ||
254 | */ | ||
255 | uint32_t rim_id GNUNET_PACKED; | ||
256 | |||
257 | /** | ||
258 | * Reserved, always zero. | ||
259 | */ | ||
260 | uint32_t reserved GNUNET_PACKED; | ||
261 | |||
262 | /** | ||
263 | * Number of bytes of inbound traffic to reserve, can | ||
264 | * be negative (to unreserve). NBO. | ||
265 | */ | ||
266 | int32_t reserve_inbound GNUNET_PACKED; | ||
267 | |||
268 | /** | ||
269 | * Increment the current traffic preference for the given peer by | ||
270 | * the specified amont. The traffic preference is used to determine | ||
271 | * the share of bandwidth this peer will typcially be assigned. | ||
272 | */ | ||
273 | uint64_t preference_change GNUNET_PACKED; | ||
274 | |||
275 | /** | ||
276 | * Identity of the peer being configured. | ||
277 | */ | ||
278 | struct GNUNET_PeerIdentity peer; | ||
279 | |||
280 | }; | ||
281 | |||
282 | |||
283 | /** | ||
284 | * Response from the core to a "RequestInfoMessage" | ||
285 | * providing traffic status information for a peer. | ||
286 | */ | ||
287 | struct ConfigurationInfoMessage | ||
288 | { | ||
289 | /** | ||
290 | * Header with type GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO | ||
291 | */ | ||
292 | struct GNUNET_MessageHeader header; | ||
293 | |||
294 | /** | ||
295 | * Amount of traffic (inbound number of bytes) that was reserved in | ||
296 | * response to the configuration change request. Negative for | ||
297 | * "unreserved" bytes. | ||
298 | */ | ||
299 | int32_t reserved_amount GNUNET_PACKED; | ||
300 | |||
301 | /** | ||
302 | * If the reservation request could not be satisfied (reserved_amount | ||
303 | * was zero), how long should the client wait until retrying? 0 if | ||
304 | * bandwidth was reserved. | ||
305 | */ | ||
306 | struct GNUNET_TIME_RelativeNBO reserve_delay; | ||
307 | |||
308 | /** | ||
309 | * Unique request ID. | ||
310 | */ | ||
311 | uint32_t rim_id GNUNET_PACKED; | ||
312 | |||
313 | /** | ||
314 | * Available bandwidth out for this peer, | ||
315 | * 0 if we have been disconnected. | ||
316 | */ | ||
317 | struct GNUNET_BANDWIDTH_Value32NBO bw_out; | ||
318 | |||
319 | /** | ||
320 | * Current traffic preference for the peer. | ||
321 | * 0 if we have been disconnected. | ||
322 | */ | ||
323 | uint64_t preference; | ||
324 | |||
325 | /** | ||
326 | * Identity of the peer. | ||
327 | */ | ||
328 | struct GNUNET_PeerIdentity peer; | ||
329 | |||
330 | }; | ||
331 | |||
332 | |||
333 | /** | ||
334 | * Client notifying core about the maximum-priority | 242 | * Client notifying core about the maximum-priority |
335 | * message it has in the queue for a particular target. | 243 | * message it has in the queue for a particular target. |
336 | */ | 244 | */ |
diff --git a/src/core/core_api.c b/src/core/core_api.c index c740f593c..16668e9fc 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -73,30 +73,6 @@ struct PeerRecord | |||
73 | struct GNUNET_CORE_TransmitHandle *pending_tail; | 73 | struct GNUNET_CORE_TransmitHandle *pending_tail; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Pending callback waiting for peer information, or NULL for none. | ||
77 | */ | ||
78 | GNUNET_CORE_PeerConfigurationInfoCallback pcic; | ||
79 | |||
80 | /** | ||
81 | * Closure for pcic. | ||
82 | */ | ||
83 | void *pcic_cls; | ||
84 | |||
85 | /** | ||
86 | * Pointer to free when we call pcic and to use to cancel | ||
87 | * preference change on disconnect. | ||
88 | */ | ||
89 | struct GNUNET_CORE_InformationRequestContext *pcic_ptr; | ||
90 | |||
91 | /** | ||
92 | * Request information ID for the given pcic (needed in case a | ||
93 | * request is cancelled after being submitted to core and a new | ||
94 | * one is generated; in this case, we need to avoid matching the | ||
95 | * reply to the first (cancelled) request to the second request). | ||
96 | */ | ||
97 | uint32_t rim_id; | ||
98 | |||
99 | /** | ||
100 | * ID of timeout task for the 'pending_head' handle | 76 | * ID of timeout task for the 'pending_head' handle |
101 | * which is the one with the smallest timeout. | 77 | * which is the one with the smallest timeout. |
102 | */ | 78 | */ |
@@ -275,11 +251,6 @@ struct GNUNET_CORE_Handle | |||
275 | struct GNUNET_TIME_Relative retry_backoff; | 251 | struct GNUNET_TIME_Relative retry_backoff; |
276 | 252 | ||
277 | /** | 253 | /** |
278 | * Request information ID generator. | ||
279 | */ | ||
280 | uint32_t rim_id_gen; | ||
281 | |||
282 | /** | ||
283 | * Number of messages we are allowed to queue per target. | 254 | * Number of messages we are allowed to queue per target. |
284 | */ | 255 | */ |
285 | unsigned int queue_size; | 256 | unsigned int queue_size; |
@@ -424,8 +395,6 @@ disconnect_and_free_peer_entry (void *cls, const GNUNET_HashCode * key, | |||
424 | struct GNUNET_CORE_Handle *h = cls; | 395 | struct GNUNET_CORE_Handle *h = cls; |
425 | struct GNUNET_CORE_TransmitHandle *th; | 396 | struct GNUNET_CORE_TransmitHandle *th; |
426 | struct PeerRecord *pr = value; | 397 | struct PeerRecord *pr = value; |
427 | GNUNET_CORE_PeerConfigurationInfoCallback pcic; | ||
428 | void *pcic_cls; | ||
429 | 398 | ||
430 | if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 399 | if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
431 | { | 400 | { |
@@ -443,13 +412,6 @@ disconnect_and_free_peer_entry (void *cls, const GNUNET_HashCode * key, | |||
443 | h->disconnects (h->cls, &pr->peer); | 412 | h->disconnects (h->cls, &pr->peer); |
444 | /* all requests should have been cancelled, clean up anyway, just in case */ | 413 | /* all requests should have been cancelled, clean up anyway, just in case */ |
445 | GNUNET_break (pr->queue_size == 0); | 414 | GNUNET_break (pr->queue_size == 0); |
446 | if (NULL != (pcic = pr->pcic)) | ||
447 | { | ||
448 | GNUNET_break (0); | ||
449 | pcic_cls = pr->pcic_cls; | ||
450 | GNUNET_CORE_peer_change_preference_cancel (pr->pcic_ptr); | ||
451 | pcic (pcic_cls, &pr->peer, 0, GNUNET_TIME_UNIT_FOREVER_REL); | ||
452 | } | ||
453 | while (NULL != (th = pr->pending_head)) | 415 | while (NULL != (th = pr->pending_head)) |
454 | { | 416 | { |
455 | GNUNET_break (0); | 417 | GNUNET_break (0); |
@@ -823,12 +785,10 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
823 | const struct DisconnectNotifyMessage *dnm; | 785 | const struct DisconnectNotifyMessage *dnm; |
824 | const struct NotifyTrafficMessage *ntm; | 786 | const struct NotifyTrafficMessage *ntm; |
825 | const struct GNUNET_MessageHeader *em; | 787 | const struct GNUNET_MessageHeader *em; |
826 | const struct ConfigurationInfoMessage *cim; | ||
827 | const struct PeerStatusNotifyMessage *psnm; | 788 | const struct PeerStatusNotifyMessage *psnm; |
828 | const struct SendMessageReady *smr; | 789 | const struct SendMessageReady *smr; |
829 | const struct GNUNET_CORE_MessageHandler *mh; | 790 | const struct GNUNET_CORE_MessageHandler *mh; |
830 | GNUNET_CORE_StartupCallback init; | 791 | GNUNET_CORE_StartupCallback init; |
831 | GNUNET_CORE_PeerConfigurationInfoCallback pcic; | ||
832 | struct PeerRecord *pr; | 792 | struct PeerRecord *pr; |
833 | struct GNUNET_CORE_TransmitHandle *th; | 793 | struct GNUNET_CORE_TransmitHandle *th; |
834 | unsigned int hpos; | 794 | unsigned int hpos; |
@@ -1190,48 +1150,6 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1190 | GNUNET_CONTAINER_DLL_insert (h->ready_peer_head, h->ready_peer_tail, pr); | 1150 | GNUNET_CONTAINER_DLL_insert (h->ready_peer_head, h->ready_peer_tail, pr); |
1191 | trigger_next_request (h, GNUNET_NO); | 1151 | trigger_next_request (h, GNUNET_NO); |
1192 | break; | 1152 | break; |
1193 | case GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO: | ||
1194 | if (ntohs (msg->size) != sizeof (struct ConfigurationInfoMessage)) | ||
1195 | { | ||
1196 | GNUNET_break (0); | ||
1197 | reconnect_later (h); | ||
1198 | return; | ||
1199 | } | ||
1200 | cim = (const struct ConfigurationInfoMessage *) msg; | ||
1201 | if (0 == memcmp (&h->me, &cim->peer, sizeof (struct GNUNET_PeerIdentity))) | ||
1202 | { | ||
1203 | /* self-change!? */ | ||
1204 | GNUNET_break (0); | ||
1205 | return; | ||
1206 | } | ||
1207 | #if DEBUG_CORE | ||
1208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1209 | "Received notification about configuration update for `%s' with RIM %u.\n", | ||
1210 | GNUNET_i2s (&cim->peer), (unsigned int) ntohl (cim->rim_id)); | ||
1211 | #endif | ||
1212 | pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &cim->peer.hashPubKey); | ||
1213 | if (pr == NULL) | ||
1214 | { | ||
1215 | GNUNET_break (0); | ||
1216 | reconnect_later (h); | ||
1217 | return; | ||
1218 | } | ||
1219 | if (pr->rim_id != ntohl (cim->rim_id)) | ||
1220 | { | ||
1221 | #if DEBUG_CORE | ||
1222 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1223 | "Reservation ID mismatch in notification...\n"); | ||
1224 | #endif | ||
1225 | break; | ||
1226 | } | ||
1227 | pcic = pr->pcic; | ||
1228 | pr->pcic = NULL; | ||
1229 | GNUNET_free_non_null (pr->pcic_ptr); | ||
1230 | pr->pcic_ptr = NULL; | ||
1231 | if (pcic != NULL) | ||
1232 | pcic (pr->pcic_cls, &pr->peer, ntohl (cim->reserved_amount), | ||
1233 | GNUNET_TIME_relative_ntoh (cim->reserve_delay)); | ||
1234 | break; | ||
1235 | default: | 1153 | default: |
1236 | reconnect_later (h); | 1154 | reconnect_later (h); |
1237 | return; | 1155 | return; |
@@ -1632,147 +1550,4 @@ GNUNET_CORE_notify_transmit_ready_cancel (struct GNUNET_CORE_TransmitHandle *th) | |||
1632 | } | 1550 | } |
1633 | 1551 | ||
1634 | 1552 | ||
1635 | /* ****************** GNUNET_CORE_peer_change_preference ******************** */ | ||
1636 | |||
1637 | |||
1638 | struct GNUNET_CORE_InformationRequestContext | ||
1639 | { | ||
1640 | |||
1641 | /** | ||
1642 | * Our connection to the service. | ||
1643 | */ | ||
1644 | struct GNUNET_CORE_Handle *h; | ||
1645 | |||
1646 | /** | ||
1647 | * Link to control message, NULL if CM was sent. | ||
1648 | */ | ||
1649 | struct ControlMessage *cm; | ||
1650 | |||
1651 | /** | ||
1652 | * Link to peer record. | ||
1653 | */ | ||
1654 | struct PeerRecord *pr; | ||
1655 | }; | ||
1656 | |||
1657 | |||
1658 | /** | ||
1659 | * CM was sent, remove link so we don't double-free. | ||
1660 | * | ||
1661 | * @param cls the 'struct GNUNET_CORE_InformationRequestContext' | ||
1662 | * @param success were we successful? | ||
1663 | */ | ||
1664 | static void | ||
1665 | change_preference_send_continuation (void *cls, int success) | ||
1666 | { | ||
1667 | struct GNUNET_CORE_InformationRequestContext *irc = cls; | ||
1668 | |||
1669 | irc->cm = NULL; | ||
1670 | } | ||
1671 | |||
1672 | |||
1673 | /** | ||
1674 | * Obtain statistics and/or change preferences for the given peer. | ||
1675 | * | ||
1676 | * @param h core handle | ||
1677 | * @param peer identifies the peer | ||
1678 | * @param amount reserve N bytes for receiving, negative | ||
1679 | * amounts can be used to undo a (recent) reservation; | ||
1680 | * @param preference increase incoming traffic share preference by this amount; | ||
1681 | * in the absence of "amount" reservations, we use this | ||
1682 | * preference value to assign proportional bandwidth shares | ||
1683 | * to all connected peers | ||
1684 | * @param info function to call with the resulting configuration information | ||
1685 | * @param info_cls closure for info | ||
1686 | * @return NULL on error | ||
1687 | */ | ||
1688 | struct GNUNET_CORE_InformationRequestContext * | ||
1689 | GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h, | ||
1690 | const struct GNUNET_PeerIdentity *peer, | ||
1691 | int32_t amount, uint64_t preference, | ||
1692 | GNUNET_CORE_PeerConfigurationInfoCallback | ||
1693 | info, void *info_cls) | ||
1694 | { | ||
1695 | struct GNUNET_CORE_InformationRequestContext *irc; | ||
1696 | struct PeerRecord *pr; | ||
1697 | struct RequestInfoMessage *rim; | ||
1698 | struct ControlMessage *cm; | ||
1699 | |||
1700 | pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &peer->hashPubKey); | ||
1701 | if (NULL == pr) | ||
1702 | { | ||
1703 | /* attempt to change preference on peer that is not connected */ | ||
1704 | GNUNET_assert (0); | ||
1705 | return NULL; | ||
1706 | } | ||
1707 | if (pr->pcic != NULL) | ||
1708 | { | ||
1709 | /* second change before first one is done */ | ||
1710 | GNUNET_break (0); | ||
1711 | return NULL; | ||
1712 | } | ||
1713 | irc = GNUNET_malloc (sizeof (struct GNUNET_CORE_InformationRequestContext)); | ||
1714 | irc->h = h; | ||
1715 | irc->pr = pr; | ||
1716 | cm = GNUNET_malloc (sizeof (struct ControlMessage) + | ||
1717 | sizeof (struct RequestInfoMessage)); | ||
1718 | cm->cont = &change_preference_send_continuation; | ||
1719 | cm->cont_cls = irc; | ||
1720 | irc->cm = cm; | ||
1721 | rim = (struct RequestInfoMessage *) &cm[1]; | ||
1722 | rim->header.size = htons (sizeof (struct RequestInfoMessage)); | ||
1723 | rim->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO); | ||
1724 | rim->rim_id = htonl (pr->rim_id = h->rim_id_gen++); | ||
1725 | rim->reserved = htonl (0); | ||
1726 | rim->reserve_inbound = htonl (amount); | ||
1727 | rim->preference_change = GNUNET_htonll (preference); | ||
1728 | rim->peer = *peer; | ||
1729 | #if DEBUG_CORE | ||
1730 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1731 | "Queueing CHANGE PREFERENCE request for peer `%s' with RIM %u\n", | ||
1732 | GNUNET_i2s (peer), (unsigned int) pr->rim_id); | ||
1733 | #endif | ||
1734 | GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head, | ||
1735 | h->control_pending_tail, cm); | ||
1736 | pr->pcic = info; | ||
1737 | pr->pcic_cls = info_cls; | ||
1738 | pr->pcic_ptr = irc; /* for free'ing irc */ | ||
1739 | if (NULL != h->client) | ||
1740 | trigger_next_request (h, GNUNET_NO); | ||
1741 | return irc; | ||
1742 | } | ||
1743 | |||
1744 | |||
1745 | /** | ||
1746 | * Cancel request for getting information about a peer. | ||
1747 | * Note that an eventual change in preference, trust or bandwidth | ||
1748 | * assignment MAY have already been committed at the time, | ||
1749 | * so cancelling a request is NOT sure to undo the original | ||
1750 | * request. The original request may or may not still commit. | ||
1751 | * The only thing cancellation ensures is that the callback | ||
1752 | * from the original request will no longer be called. | ||
1753 | * | ||
1754 | * @param irc context returned by the original GNUNET_CORE_peer_get_info call | ||
1755 | */ | ||
1756 | void | ||
1757 | GNUNET_CORE_peer_change_preference_cancel (struct | ||
1758 | GNUNET_CORE_InformationRequestContext | ||
1759 | *irc) | ||
1760 | { | ||
1761 | struct GNUNET_CORE_Handle *h = irc->h; | ||
1762 | struct PeerRecord *pr = irc->pr; | ||
1763 | |||
1764 | GNUNET_assert (pr->pcic_ptr == irc); | ||
1765 | if (irc->cm != NULL) | ||
1766 | { | ||
1767 | GNUNET_CONTAINER_DLL_remove (h->control_pending_head, | ||
1768 | h->control_pending_tail, irc->cm); | ||
1769 | GNUNET_free (irc->cm); | ||
1770 | } | ||
1771 | pr->pcic = NULL; | ||
1772 | pr->pcic_cls = NULL; | ||
1773 | pr->pcic_ptr = NULL; | ||
1774 | GNUNET_free (irc); | ||
1775 | } | ||
1776 | |||
1777 | |||
1778 | /* end of core_api.c */ | 1553 | /* end of core_api.c */ |
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index ae424edad..5d262fdc6 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -567,11 +567,6 @@ struct Neighbour | |||
567 | struct GNUNET_BANDWIDTH_Tracker available_send_window; | 567 | struct GNUNET_BANDWIDTH_Tracker available_send_window; |
568 | 568 | ||
569 | /** | 569 | /** |
570 | * Tracking bandwidth for receiving from this peer. | ||
571 | */ | ||
572 | struct GNUNET_BANDWIDTH_Tracker available_recv_window; | ||
573 | |||
574 | /** | ||
575 | * How valueable were the messages of this peer recently? | 570 | * How valueable were the messages of this peer recently? |
576 | */ | 571 | */ |
577 | unsigned long long current_preference; | 572 | unsigned long long current_preference; |
@@ -884,45 +879,6 @@ get_neighbour_timeout (struct Neighbour *n) | |||
884 | 879 | ||
885 | 880 | ||
886 | /** | 881 | /** |
887 | * Helper function for update_preference_sum. | ||
888 | */ | ||
889 | static int | ||
890 | update_preference (void *cls, const GNUNET_HashCode * key, void *value) | ||
891 | { | ||
892 | unsigned long long *ps = cls; | ||
893 | struct Neighbour *n = value; | ||
894 | |||
895 | n->current_preference /= 2; | ||
896 | *ps += n->current_preference; | ||
897 | return GNUNET_OK; | ||
898 | } | ||
899 | |||
900 | |||
901 | /** | ||
902 | * A preference value for a neighbour was update. Update | ||
903 | * the preference sum accordingly. | ||
904 | * | ||
905 | * @param inc how much was a preference value increased? | ||
906 | */ | ||
907 | static void | ||
908 | update_preference_sum (unsigned long long inc) | ||
909 | { | ||
910 | unsigned long long os; | ||
911 | |||
912 | os = preference_sum; | ||
913 | preference_sum += inc; | ||
914 | if (preference_sum >= os) | ||
915 | return; /* done! */ | ||
916 | /* overflow! compensate by cutting all values in half! */ | ||
917 | preference_sum = 0; | ||
918 | GNUNET_CONTAINER_multihashmap_iterate (neighbours, &update_preference, | ||
919 | &preference_sum); | ||
920 | GNUNET_STATISTICS_set (stats, gettext_noop ("# total peer preference"), | ||
921 | preference_sum, GNUNET_NO); | ||
922 | } | ||
923 | |||
924 | |||
925 | /** | ||
926 | * Find the entry for the given neighbour. | 882 | * Find the entry for the given neighbour. |
927 | * | 883 | * |
928 | * @param peer identity of the neighbour | 884 | * @param peer identity of the neighbour |
@@ -1605,112 +1561,6 @@ handle_client_have_peer (void *cls, struct GNUNET_SERVER_Client *client, | |||
1605 | 1561 | ||
1606 | 1562 | ||
1607 | /** | 1563 | /** |
1608 | * Handle REQUEST_INFO request. | ||
1609 | * | ||
1610 | * @param cls unused | ||
1611 | * @param client client sending the request | ||
1612 | * @param message iteration request message | ||
1613 | */ | ||
1614 | static void | ||
1615 | handle_client_request_info (void *cls, struct GNUNET_SERVER_Client *client, | ||
1616 | const struct GNUNET_MessageHeader *message) | ||
1617 | { | ||
1618 | const struct RequestInfoMessage *rcm; | ||
1619 | struct Client *pos; | ||
1620 | struct Neighbour *n; | ||
1621 | struct ConfigurationInfoMessage cim; | ||
1622 | int32_t want_reserv; | ||
1623 | int32_t got_reserv; | ||
1624 | unsigned long long old_preference; | ||
1625 | struct GNUNET_TIME_Relative rdelay; | ||
1626 | |||
1627 | rdelay = GNUNET_TIME_relative_get_zero (); | ||
1628 | #if DEBUG_CORE_CLIENT | ||
1629 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core service receives `%s' request.\n", | ||
1630 | "REQUEST_INFO"); | ||
1631 | #endif | ||
1632 | pos = clients; | ||
1633 | while (pos != NULL) | ||
1634 | { | ||
1635 | if (client == pos->client_handle) | ||
1636 | break; | ||
1637 | pos = pos->next; | ||
1638 | } | ||
1639 | if (pos == NULL) | ||
1640 | { | ||
1641 | GNUNET_break (0); | ||
1642 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1643 | return; | ||
1644 | } | ||
1645 | |||
1646 | rcm = (const struct RequestInfoMessage *) message; | ||
1647 | n = find_neighbour (&rcm->peer); | ||
1648 | memset (&cim, 0, sizeof (cim)); | ||
1649 | if ((n != NULL) && (GNUNET_YES == n->is_connected)) | ||
1650 | { | ||
1651 | want_reserv = ntohl (rcm->reserve_inbound); | ||
1652 | if (want_reserv < 0) | ||
1653 | { | ||
1654 | got_reserv = want_reserv; | ||
1655 | } | ||
1656 | else if (want_reserv > 0) | ||
1657 | { | ||
1658 | rdelay = | ||
1659 | GNUNET_BANDWIDTH_tracker_get_delay (&n->available_recv_window, | ||
1660 | want_reserv); | ||
1661 | if (rdelay.rel_value == 0) | ||
1662 | got_reserv = want_reserv; | ||
1663 | else | ||
1664 | got_reserv = 0; /* all or nothing */ | ||
1665 | } | ||
1666 | else | ||
1667 | got_reserv = 0; | ||
1668 | GNUNET_BANDWIDTH_tracker_consume (&n->available_recv_window, got_reserv); | ||
1669 | old_preference = n->current_preference; | ||
1670 | n->current_preference += GNUNET_ntohll (rcm->preference_change); | ||
1671 | if (old_preference > n->current_preference) | ||
1672 | { | ||
1673 | /* overflow; cap at maximum value */ | ||
1674 | n->current_preference = ULLONG_MAX; | ||
1675 | } | ||
1676 | update_preference_sum (n->current_preference - old_preference); | ||
1677 | #if DEBUG_CORE_QUOTA | ||
1678 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1679 | "Received reservation request for %d bytes for peer `%4s', reserved %d bytes, suggesting delay of %llu ms\n", | ||
1680 | (int) want_reserv, GNUNET_i2s (&rcm->peer), (int) got_reserv, | ||
1681 | (unsigned long long) rdelay.rel_value); | ||
1682 | #endif | ||
1683 | cim.reserved_amount = htonl (got_reserv); | ||
1684 | cim.reserve_delay = GNUNET_TIME_relative_hton (rdelay); | ||
1685 | cim.bw_out = n->bw_out; | ||
1686 | cim.preference = n->current_preference; | ||
1687 | } | ||
1688 | else | ||
1689 | { | ||
1690 | /* Technically, this COULD happen (due to asynchronous behavior), | ||
1691 | * but it should be rare, so we should generate an info event | ||
1692 | * to help diagnosis of serious errors that might be masked by this */ | ||
1693 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1694 | _ | ||
1695 | ("Client asked for preference change with peer `%s', which is not connected!\n"), | ||
1696 | GNUNET_i2s (&rcm->peer)); | ||
1697 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1698 | return; | ||
1699 | } | ||
1700 | cim.header.size = htons (sizeof (struct ConfigurationInfoMessage)); | ||
1701 | cim.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO); | ||
1702 | cim.peer = rcm->peer; | ||
1703 | cim.rim_id = rcm->rim_id; | ||
1704 | #if DEBUG_CORE_CLIENT | ||
1705 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n", | ||
1706 | "CONFIGURATION_INFO"); | ||
1707 | #endif | ||
1708 | send_to_client (pos, &cim.header, GNUNET_NO); | ||
1709 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1710 | } | ||
1711 | |||
1712 | |||
1713 | /** | ||
1714 | * Free the given entry for the neighbour (it has | 1564 | * Free the given entry for the neighbour (it has |
1715 | * already been removed from the list at this point). | 1565 | * already been removed from the list at this point). |
1716 | * | 1566 | * |
@@ -4298,11 +4148,7 @@ neighbour_quota_update (void *cls, | |||
4298 | (n->bw_out.value__ != q_out_min.value__)) | 4148 | (n->bw_out.value__ != q_out_min.value__)) |
4299 | { | 4149 | { |
4300 | if (n->bw_in.value__ != q_in.value__) | 4150 | if (n->bw_in.value__ != q_in.value__) |
4301 | { | ||
4302 | n->bw_in = q_in; | 4151 | n->bw_in = q_in; |
4303 | GNUNET_BANDWIDTH_tracker_update_quota (&n->available_recv_window, | ||
4304 | n->bw_in); | ||
4305 | } | ||
4306 | if (n->bw_out.value__ != q_out_min.value__) | 4152 | if (n->bw_out.value__ != q_out_min.value__) |
4307 | n->bw_out = q_out_min; | 4153 | n->bw_out = q_out_min; |
4308 | if (GNUNET_YES == n->is_connected) | 4154 | if (GNUNET_YES == n->is_connected) |
@@ -4356,8 +4202,6 @@ handle_transport_notify_connect (void *cls, | |||
4356 | update_neighbour_performance (n, ats, ats_count); | 4202 | update_neighbour_performance (n, ats, ats_count); |
4357 | GNUNET_BANDWIDTH_tracker_init (&n->available_send_window, n->bw_out, | 4203 | GNUNET_BANDWIDTH_tracker_init (&n->available_send_window, n->bw_out, |
4358 | MAX_WINDOW_TIME_S); | 4204 | MAX_WINDOW_TIME_S); |
4359 | GNUNET_BANDWIDTH_tracker_init (&n->available_recv_window, n->bw_in, | ||
4360 | MAX_WINDOW_TIME_S); | ||
4361 | #if DEBUG_CORE | 4205 | #if DEBUG_CORE |
4362 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received connection from `%4s'.\n", | 4206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received connection from `%4s'.\n", |
4363 | GNUNET_i2s (&n->peer)); | 4207 | GNUNET_i2s (&n->peer)); |
@@ -4520,9 +4364,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
4520 | GNUNET_MESSAGE_TYPE_CORE_PEER_CONNECTED, | 4364 | GNUNET_MESSAGE_TYPE_CORE_PEER_CONNECTED, |
4521 | sizeof (struct GNUNET_MessageHeader) + | 4365 | sizeof (struct GNUNET_MessageHeader) + |
4522 | sizeof (struct GNUNET_PeerIdentity)}, | 4366 | sizeof (struct GNUNET_PeerIdentity)}, |
4523 | {&handle_client_request_info, NULL, | ||
4524 | GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO, | ||
4525 | sizeof (struct RequestInfoMessage)}, | ||
4526 | {&handle_client_send_request, NULL, | 4367 | {&handle_client_send_request, NULL, |
4527 | GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST, | 4368 | GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST, |
4528 | sizeof (struct SendMessageRequest)}, | 4369 | sizeof (struct SendMessageRequest)}, |
diff --git a/src/core/gnunet-service-core_clients.c b/src/core/gnunet-service-core_clients.c index 4a380e02d..597eddbd9 100644 --- a/src/core/gnunet-service-core_clients.c +++ b/src/core/gnunet-service-core_clients.c | |||
@@ -726,9 +726,6 @@ GSC_CLIENTS_init (struct GNUNET_SERVER_Handle *server) | |||
726 | GNUNET_MESSAGE_TYPE_CORE_PEER_CONNECTED, | 726 | GNUNET_MESSAGE_TYPE_CORE_PEER_CONNECTED, |
727 | sizeof (struct GNUNET_MessageHeader) + | 727 | sizeof (struct GNUNET_MessageHeader) + |
728 | sizeof (struct GNUNET_PeerIdentity)}, | 728 | sizeof (struct GNUNET_PeerIdentity)}, |
729 | {&GSC_SESSIONS_handle_client_request_info, NULL, | ||
730 | GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO, | ||
731 | sizeof (struct RequestInfoMessage)}, | ||
732 | {&handle_client_send_request, NULL, | 729 | {&handle_client_send_request, NULL, |
733 | GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST, | 730 | GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST, |
734 | sizeof (struct SendMessageRequest)}, | 731 | sizeof (struct SendMessageRequest)}, |
diff --git a/src/core/gnunet-service-core_neighbours.c b/src/core/gnunet-service-core_neighbours.c index 774c173dc..0548766d0 100644 --- a/src/core/gnunet-service-core_neighbours.c +++ b/src/core/gnunet-service-core_neighbours.c | |||
@@ -113,11 +113,6 @@ struct Neighbour | |||
113 | */ | 113 | */ |
114 | GNUNET_SCHEDULER_TaskIdentifier retry_plaintext_task; | 114 | GNUNET_SCHEDULER_TaskIdentifier retry_plaintext_task; |
115 | 115 | ||
116 | /** | ||
117 | * Tracking bandwidth for sending to this peer. | ||
118 | */ | ||
119 | struct GNUNET_BANDWIDTH_Tracker available_recv_window; | ||
120 | |||
121 | }; | 116 | }; |
122 | 117 | ||
123 | 118 | ||
@@ -345,9 +340,6 @@ handle_transport_notify_connect (void *cls, | |||
345 | #endif | 340 | #endif |
346 | n = GNUNET_malloc (sizeof (struct Neighbour)); | 341 | n = GNUNET_malloc (sizeof (struct Neighbour)); |
347 | n->peer = *peer; | 342 | n->peer = *peer; |
348 | GNUNET_BANDWIDTH_tracker_init (&n->available_recv_window, | ||
349 | GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, | ||
350 | MAX_WINDOW_TIME_S); | ||
351 | GNUNET_assert (GNUNET_OK == | 343 | GNUNET_assert (GNUNET_OK == |
352 | GNUNET_CONTAINER_multihashmap_put (neighbours, | 344 | GNUNET_CONTAINER_multihashmap_put (neighbours, |
353 | &n->peer.hashPubKey, n, | 345 | &n->peer.hashPubKey, n, |
diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c index 6ab97d7d0..c82c72863 100644 --- a/src/core/gnunet-service-core_sessions.c +++ b/src/core/gnunet-service-core_sessions.c | |||
@@ -122,12 +122,6 @@ struct Session | |||
122 | GNUNET_SCHEDULER_TaskIdentifier cork_task; | 122 | GNUNET_SCHEDULER_TaskIdentifier cork_task; |
123 | 123 | ||
124 | /** | 124 | /** |
125 | * Tracking bandwidth for receiving from this peer. | ||
126 | * // FIXME: need to set it! | ||
127 | */ | ||
128 | struct GNUNET_BANDWIDTH_Tracker available_recv_window; | ||
129 | |||
130 | /** | ||
131 | * Available bandwidth out for this peer (current target). This | 125 | * Available bandwidth out for this peer (current target). This |
132 | * value should be the 'MIN' of 'bw_out_internal_limit' and | 126 | * value should be the 'MIN' of 'bw_out_internal_limit' and |
133 | * 'bw_out_external_limit'. | 127 | * 'bw_out_external_limit'. |
@@ -732,82 +726,6 @@ GSC_SESSIONS_handle_client_have_peer (void *cls, struct GNUNET_SERVER_Client *cl | |||
732 | 726 | ||
733 | 727 | ||
734 | /** | 728 | /** |
735 | * Handle REQUEST_INFO request. For this request type, the client must | ||
736 | * have transmitted an INIT first. | ||
737 | * | ||
738 | * @param cls unused | ||
739 | * @param client client sending the request | ||
740 | * @param message iteration request message | ||
741 | */ | ||
742 | void | ||
743 | GSC_SESSIONS_handle_client_request_info (void *cls, struct GNUNET_SERVER_Client *client, | ||
744 | const struct GNUNET_MessageHeader *message) | ||
745 | { | ||
746 | const struct RequestInfoMessage *rcm; | ||
747 | struct Session *session; | ||
748 | struct ConfigurationInfoMessage cim; | ||
749 | int32_t want_reserv; | ||
750 | int32_t got_reserv; | ||
751 | struct GNUNET_TIME_Relative rdelay; | ||
752 | |||
753 | rdelay = GNUNET_TIME_UNIT_ZERO; | ||
754 | #if DEBUG_CORE_CLIENT | ||
755 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
756 | "Core service receives `%s' request.\n", | ||
757 | "REQUEST_INFO"); | ||
758 | #endif | ||
759 | rcm = (const struct RequestInfoMessage *) message; | ||
760 | session = find_session (&rcm->peer); | ||
761 | if (NULL == session) | ||
762 | { | ||
763 | /* Technically, this COULD happen (due to asynchronous behavior), | ||
764 | * but it should be rare, so we should generate an info event | ||
765 | * to help diagnosis of serious errors that might be masked by this */ | ||
766 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
767 | _("Client asked for preference change with peer `%s', which is not connected!\n"), | ||
768 | GNUNET_i2s (&rcm->peer)); | ||
769 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
770 | return; | ||
771 | } | ||
772 | |||
773 | want_reserv = ntohl (rcm->reserve_inbound); | ||
774 | if (want_reserv < 0) | ||
775 | { | ||
776 | got_reserv = want_reserv; | ||
777 | } | ||
778 | else if (want_reserv > 0) | ||
779 | { | ||
780 | rdelay = | ||
781 | GNUNET_BANDWIDTH_tracker_get_delay (&session->available_recv_window, | ||
782 | want_reserv); | ||
783 | if (rdelay.rel_value == 0) | ||
784 | got_reserv = want_reserv; | ||
785 | else | ||
786 | got_reserv = 0; /* all or nothing */ | ||
787 | } | ||
788 | else | ||
789 | got_reserv = 0; | ||
790 | GNUNET_BANDWIDTH_tracker_consume (&session->available_recv_window, got_reserv); | ||
791 | #if DEBUG_CORE_QUOTA | ||
792 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
793 | "Received reservation request for %d bytes for peer `%4s', reserved %d bytes, suggesting delay of %llu ms\n", | ||
794 | (int) want_reserv, GNUNET_i2s (&rcm->peer), (int) got_reserv, | ||
795 | (unsigned long long) rdelay.rel_value); | ||
796 | #endif | ||
797 | cim.header.size = htons (sizeof (struct ConfigurationInfoMessage)); | ||
798 | cim.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO); | ||
799 | cim.reserved_amount = htonl (got_reserv); | ||
800 | cim.reserve_delay = GNUNET_TIME_relative_hton (rdelay); | ||
801 | cim.rim_id = rcm->rim_id; | ||
802 | cim.bw_out = session->bw_out; | ||
803 | cim.preference = 0; /* FIXME: remove */ | ||
804 | cim.peer = rcm->peer; | ||
805 | GSC_CLIENTS_send_to_client (client, &cim.header, GNUNET_NO); | ||
806 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
807 | } | ||
808 | |||
809 | |||
810 | /** | ||
811 | * Update information about a session. | 729 | * Update information about a session. |
812 | * | 730 | * |
813 | * @param peer peer who's session should be updated | 731 | * @param peer peer who's session should be updated |
diff --git a/src/core/gnunet-service-core_sessions.h b/src/core/gnunet-service-core_sessions.h index 787a431ee..4bc073b65 100644 --- a/src/core/gnunet-service-core_sessions.h +++ b/src/core/gnunet-service-core_sessions.h | |||
@@ -157,18 +157,6 @@ GSC_SESSIONS_handle_client_have_peer (void *cls, struct GNUNET_SERVER_Client *cl | |||
157 | const struct GNUNET_MessageHeader *message); | 157 | const struct GNUNET_MessageHeader *message); |
158 | 158 | ||
159 | 159 | ||
160 | /** | ||
161 | * Handle REQUEST_INFO request. For this request type, the client must have | ||
162 | * transmitted an INIT first. | ||
163 | * | ||
164 | * @param cls unused | ||
165 | * @param client client sending the request | ||
166 | * @param message iteration request message | ||
167 | */ | ||
168 | void | ||
169 | GSC_SESSIONS_handle_client_request_info (void *cls, struct GNUNET_SERVER_Client *client, | ||
170 | const struct GNUNET_MessageHeader *message); | ||
171 | |||
172 | 160 | ||
173 | /** | 161 | /** |
174 | * Initialize sessions subsystem. | 162 | * Initialize sessions subsystem. |
diff --git a/src/core/test_core_api_preferences.c b/src/core/test_core_api_preferences.c deleted file mode 100644 index 6d7f52953..000000000 --- a/src/core/test_core_api_preferences.c +++ /dev/null | |||
@@ -1,501 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file core/test_core_api_preferences.c | ||
22 | * @brief testcase for core_api.c's GNUNET_CORE_change_preference | ||
23 | */ | ||
24 | #include "platform.h" | ||
25 | #include "gnunet_common.h" | ||
26 | #include "gnunet_arm_service.h" | ||
27 | #include "gnunet_core_service.h" | ||
28 | #include "gnunet_getopt_lib.h" | ||
29 | #include "gnunet_os_lib.h" | ||
30 | #include "gnunet_program_lib.h" | ||
31 | #include "gnunet_scheduler_lib.h" | ||
32 | #include "gnunet_transport_service.h" | ||
33 | |||
34 | #define VERBOSE GNUNET_EXTRA_LOGGING | ||
35 | |||
36 | #define START_ARM GNUNET_YES | ||
37 | |||
38 | #define MTYPE 12345 | ||
39 | |||
40 | struct PeerContext | ||
41 | { | ||
42 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
43 | struct GNUNET_CORE_Handle *ch; | ||
44 | struct GNUNET_PeerIdentity id; | ||
45 | struct GNUNET_TRANSPORT_Handle *th; | ||
46 | struct GNUNET_TRANSPORT_GetHelloHandle *ghh; | ||
47 | struct GNUNET_MessageHeader *hello; | ||
48 | int connect_status; | ||
49 | #if START_ARM | ||
50 | struct GNUNET_OS_Process *arm_proc; | ||
51 | #endif | ||
52 | }; | ||
53 | |||
54 | static struct PeerContext p1; | ||
55 | |||
56 | static struct PeerContext p2; | ||
57 | |||
58 | static GNUNET_SCHEDULER_TaskIdentifier err_task; | ||
59 | |||
60 | static int ok; | ||
61 | |||
62 | #if VERBOSE | ||
63 | #define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) | ||
64 | #else | ||
65 | #define OKPP do { ok++; } while (0) | ||
66 | #endif | ||
67 | |||
68 | static struct GNUNET_CORE_InformationRequestContext *irc; | ||
69 | |||
70 | static struct GNUNET_CORE_TransmitHandle *th; | ||
71 | |||
72 | static GNUNET_SCHEDULER_TaskIdentifier irc_task; | ||
73 | |||
74 | static GNUNET_SCHEDULER_TaskIdentifier ask_task; | ||
75 | |||
76 | static unsigned int total_reserve = 5; | ||
77 | |||
78 | |||
79 | static void | ||
80 | process_hello (void *cls, const struct GNUNET_MessageHeader *message); | ||
81 | |||
82 | static void | ||
83 | terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
84 | { | ||
85 | #if VERBOSE | ||
86 | fprintf (stderr, "Regular shutdown\n"); | ||
87 | #endif | ||
88 | GNUNET_assert (ok == 6); | ||
89 | GNUNET_assert (NULL == irc); | ||
90 | GNUNET_TRANSPORT_get_hello_cancel (p1.ghh); | ||
91 | GNUNET_TRANSPORT_get_hello_cancel (p2.ghh); | ||
92 | GNUNET_CORE_disconnect (p1.ch); | ||
93 | GNUNET_CORE_disconnect (p2.ch); | ||
94 | GNUNET_TRANSPORT_disconnect (p1.th); | ||
95 | GNUNET_TRANSPORT_disconnect (p2.th); | ||
96 | ok = 0; | ||
97 | } | ||
98 | |||
99 | |||
100 | static void | ||
101 | terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
102 | { | ||
103 | err_task = GNUNET_SCHEDULER_NO_TASK; | ||
104 | #if VERBOSE | ||
105 | fprintf (stderr, "ENDING ANGRILY %u\n", ok); | ||
106 | #endif | ||
107 | GNUNET_break (0); | ||
108 | if (NULL != irc) | ||
109 | { | ||
110 | GNUNET_CORE_peer_change_preference_cancel (irc); | ||
111 | irc = NULL; | ||
112 | } | ||
113 | if (GNUNET_SCHEDULER_NO_TASK != irc_task) | ||
114 | { | ||
115 | GNUNET_SCHEDULER_cancel (irc_task); | ||
116 | irc_task = GNUNET_SCHEDULER_NO_TASK; | ||
117 | } | ||
118 | if (GNUNET_SCHEDULER_NO_TASK != ask_task) | ||
119 | { | ||
120 | GNUNET_SCHEDULER_cancel (ask_task); | ||
121 | ask_task = GNUNET_SCHEDULER_NO_TASK; | ||
122 | } | ||
123 | GNUNET_TRANSPORT_get_hello_cancel (p1.ghh); | ||
124 | GNUNET_TRANSPORT_get_hello_cancel (p2.ghh); | ||
125 | GNUNET_CORE_disconnect (p1.ch); | ||
126 | GNUNET_CORE_disconnect (p2.ch); | ||
127 | GNUNET_TRANSPORT_disconnect (p1.th); | ||
128 | GNUNET_TRANSPORT_disconnect (p2.th); | ||
129 | ok = 42; | ||
130 | } | ||
131 | |||
132 | |||
133 | static size_t | ||
134 | transmit_ready (void *cls, size_t size, void *buf) | ||
135 | { | ||
136 | struct PeerContext *p = cls; | ||
137 | struct GNUNET_MessageHeader *m; | ||
138 | |||
139 | th = NULL; | ||
140 | GNUNET_assert (ok == 4); | ||
141 | OKPP; | ||
142 | GNUNET_assert (p == &p1); | ||
143 | GNUNET_assert (buf != NULL); | ||
144 | m = (struct GNUNET_MessageHeader *) buf; | ||
145 | m->type = htons (MTYPE); | ||
146 | m->size = htons (sizeof (struct GNUNET_MessageHeader)); | ||
147 | err_task = | ||
148 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | ||
149 | (GNUNET_TIME_UNIT_SECONDS, 120), | ||
150 | &terminate_task_error, NULL); | ||
151 | |||
152 | return sizeof (struct GNUNET_MessageHeader); | ||
153 | } | ||
154 | |||
155 | static void | ||
156 | preference_cb (void *cls, const struct GNUNET_PeerIdentity *peer, | ||
157 | int32_t amount, | ||
158 | struct GNUNET_TIME_Relative res_delay); | ||
159 | |||
160 | static void | ||
161 | do_reserve (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
162 | { | ||
163 | struct PeerContext *pc = cls; | ||
164 | |||
165 | irc_task = GNUNET_SCHEDULER_NO_TASK; | ||
166 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
167 | { | ||
168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
169 | "Aborted during attempt to request reservation\n"); | ||
170 | return; | ||
171 | } | ||
172 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
173 | "Requesting reservatin of 32k from core in 1s!\n"); | ||
174 | irc = | ||
175 | GNUNET_CORE_peer_change_preference (p1.ch, &p2.id, | ||
176 | 1000000 /* bandwidth for 1s */ , | ||
177 | 0, &preference_cb, pc); | ||
178 | } | ||
179 | |||
180 | static void | ||
181 | preference_cb (void *cls, const struct GNUNET_PeerIdentity *peer, | ||
182 | int32_t amount, | ||
183 | struct GNUNET_TIME_Relative res_delay) | ||
184 | { | ||
185 | struct PeerContext *pc = cls; | ||
186 | |||
187 | irc = NULL; | ||
188 | if (0 == amount) | ||
189 | { | ||
190 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
191 | "Delaying reservation request by %llu ms!\n", | ||
192 | (unsigned long long) res_delay.rel_value); | ||
193 | irc_task = GNUNET_SCHEDULER_add_delayed (res_delay, &do_reserve, pc); | ||
194 | return; | ||
195 | } | ||
196 | total_reserve--; | ||
197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reservation done!\n"); | ||
198 | if (total_reserve > 0) | ||
199 | { | ||
200 | irc_task = GNUNET_SCHEDULER_add_now (&do_reserve, pc); | ||
201 | return; | ||
202 | } | ||
203 | GNUNET_SCHEDULER_cancel (err_task); | ||
204 | err_task = GNUNET_SCHEDULER_NO_TASK; | ||
205 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
206 | "Asking core (1) for transmission to peer `%4s'\n", | ||
207 | GNUNET_i2s (&p2.id)); | ||
208 | if (NULL == | ||
209 | (th = | ||
210 | GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_YES, 0, | ||
211 | GNUNET_TIME_relative_multiply | ||
212 | (GNUNET_TIME_UNIT_SECONDS, 45), | ||
213 | &p2.id, | ||
214 | sizeof (struct GNUNET_MessageHeader), | ||
215 | &transmit_ready, &p1))) | ||
216 | { | ||
217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
218 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | ||
219 | GNUNET_i2s (&p2.id)); | ||
220 | } | ||
221 | } | ||
222 | |||
223 | |||
224 | static void | ||
225 | connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, | ||
226 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | ||
227 | { | ||
228 | struct PeerContext *pc = cls; | ||
229 | |||
230 | if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) | ||
231 | return; | ||
232 | GNUNET_assert (pc->connect_status == 0); | ||
233 | pc->connect_status = 1; | ||
234 | if (pc == &p1) | ||
235 | { | ||
236 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
237 | "Encrypted connection established to peer `%4s'\n", | ||
238 | GNUNET_i2s (peer)); | ||
239 | if (GNUNET_SCHEDULER_NO_TASK != ask_task) | ||
240 | { | ||
241 | GNUNET_SCHEDULER_cancel (ask_task); | ||
242 | ask_task = GNUNET_SCHEDULER_NO_TASK; | ||
243 | } | ||
244 | GNUNET_SCHEDULER_cancel (err_task); | ||
245 | err_task = | ||
246 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | ||
247 | (GNUNET_TIME_UNIT_SECONDS, 120), | ||
248 | &terminate_task_error, NULL); | ||
249 | irc_task = GNUNET_SCHEDULER_add_now (&do_reserve, pc); | ||
250 | } | ||
251 | } | ||
252 | |||
253 | |||
254 | static void | ||
255 | disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | ||
256 | { | ||
257 | struct PeerContext *pc = cls; | ||
258 | |||
259 | if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) | ||
260 | return; | ||
261 | pc->connect_status = 0; | ||
262 | if (GNUNET_SCHEDULER_NO_TASK != irc_task) | ||
263 | { | ||
264 | GNUNET_SCHEDULER_cancel (irc_task); | ||
265 | irc_task = GNUNET_SCHEDULER_NO_TASK; | ||
266 | } | ||
267 | if (0 == memcmp (peer, &p1.id, sizeof (struct GNUNET_PeerIdentity))) | ||
268 | { | ||
269 | if (irc != NULL) | ||
270 | { | ||
271 | GNUNET_CORE_peer_change_preference_cancel (irc); | ||
272 | irc = NULL; | ||
273 | } | ||
274 | if (th != NULL) | ||
275 | { | ||
276 | GNUNET_CORE_notify_transmit_ready_cancel (th); | ||
277 | th = NULL; | ||
278 | } | ||
279 | } | ||
280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Encrypted connection to `%4s' cut\n", | ||
281 | GNUNET_i2s (peer)); | ||
282 | } | ||
283 | |||
284 | |||
285 | static int | ||
286 | inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, | ||
287 | const struct GNUNET_MessageHeader *message, | ||
288 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | ||
289 | { | ||
290 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
291 | "Core provides inbound data from `%4s'.\n", GNUNET_i2s (other)); | ||
292 | return GNUNET_OK; | ||
293 | } | ||
294 | |||
295 | |||
296 | static int | ||
297 | outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other, | ||
298 | const struct GNUNET_MessageHeader *message, | ||
299 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | ||
300 | { | ||
301 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
302 | "Core notifies about outbound data for `%4s'.\n", | ||
303 | GNUNET_i2s (other)); | ||
304 | return GNUNET_OK; | ||
305 | } | ||
306 | |||
307 | |||
308 | |||
309 | static int | ||
310 | process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, | ||
311 | const struct GNUNET_MessageHeader *message, | ||
312 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | ||
313 | { | ||
314 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving message from `%4s'.\n", | ||
315 | GNUNET_i2s (peer)); | ||
316 | GNUNET_assert (ok == 5); | ||
317 | OKPP; | ||
318 | GNUNET_SCHEDULER_cancel (err_task); | ||
319 | err_task = GNUNET_SCHEDULER_NO_TASK; | ||
320 | GNUNET_SCHEDULER_add_now (&terminate_task, NULL); | ||
321 | return GNUNET_OK; | ||
322 | } | ||
323 | |||
324 | |||
325 | static struct GNUNET_CORE_MessageHandler handlers[] = { | ||
326 | {&process_mtype, MTYPE, sizeof (struct GNUNET_MessageHeader)}, | ||
327 | {NULL, 0, 0} | ||
328 | }; | ||
329 | |||
330 | |||
331 | |||
332 | static void | ||
333 | ask_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
334 | { | ||
335 | ask_task = | ||
336 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &ask_connect_task, | ||
337 | NULL); | ||
338 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
339 | "Asking core (1) AGAIN to connect to peer `%4s'\n", | ||
340 | GNUNET_i2s (&p2.id)); | ||
341 | GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); | ||
342 | } | ||
343 | |||
344 | |||
345 | static void | ||
346 | init_notify (void *cls, struct GNUNET_CORE_Handle *server, | ||
347 | const struct GNUNET_PeerIdentity *my_identity) | ||
348 | { | ||
349 | struct PeerContext *p = cls; | ||
350 | |||
351 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core connection to `%4s' established\n", | ||
352 | GNUNET_i2s (my_identity)); | ||
353 | GNUNET_assert (server != NULL); | ||
354 | p->id = *my_identity; | ||
355 | p->ch = server; | ||
356 | if (cls == &p1) | ||
357 | { | ||
358 | GNUNET_assert (ok == 2); | ||
359 | OKPP; | ||
360 | /* connect p2 */ | ||
361 | GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, | ||
362 | &disconnect_notify, NULL, &inbound_notify, GNUNET_YES, | ||
363 | &outbound_notify, GNUNET_YES, handlers); | ||
364 | } | ||
365 | else | ||
366 | { | ||
367 | GNUNET_assert (ok == 3); | ||
368 | OKPP; | ||
369 | GNUNET_assert (cls == &p2); | ||
370 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
371 | "Asking core (1) to connect to peer `%4s'\n", | ||
372 | GNUNET_i2s (&p2.id)); | ||
373 | err_task = | ||
374 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | ||
375 | (GNUNET_TIME_UNIT_SECONDS, 60), | ||
376 | &terminate_task_error, NULL); | ||
377 | if (GNUNET_SCHEDULER_NO_TASK != ask_task) | ||
378 | GNUNET_SCHEDULER_cancel (ask_task); | ||
379 | ask_task = | ||
380 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
381 | &ask_connect_task, NULL); | ||
382 | GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); | ||
383 | } | ||
384 | } | ||
385 | |||
386 | |||
387 | static void | ||
388 | process_hello (void *cls, const struct GNUNET_MessageHeader *message) | ||
389 | { | ||
390 | struct PeerContext *p = cls; | ||
391 | |||
392 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
393 | "Received (my) `%s' from transport service\n", "HELLO"); | ||
394 | GNUNET_assert (message != NULL); | ||
395 | p->hello = GNUNET_malloc (ntohs (message->size)); | ||
396 | memcpy (p->hello, message, ntohs (message->size)); | ||
397 | if ((p == &p1) && (p2.th != NULL)) | ||
398 | GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL); | ||
399 | if ((p == &p2) && (p1.th != NULL)) | ||
400 | GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL); | ||
401 | |||
402 | if ((p == &p1) && (p2.hello != NULL) && (p1.th != NULL)) | ||
403 | GNUNET_TRANSPORT_offer_hello (p1.th, p2.hello, NULL, NULL); | ||
404 | if ((p == &p2) && (p1.hello != NULL) && (p2.th != NULL)) | ||
405 | GNUNET_TRANSPORT_offer_hello (p2.th, p1.hello, NULL, NULL); | ||
406 | } | ||
407 | |||
408 | |||
409 | |||
410 | static void | ||
411 | setup_peer (struct PeerContext *p, const char *cfgname) | ||
412 | { | ||
413 | p->cfg = GNUNET_CONFIGURATION_create (); | ||
414 | #if START_ARM | ||
415 | p->arm_proc = | ||
416 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", | ||
417 | "gnunet-service-arm", | ||
418 | #if VERBOSE | ||
419 | "-L", "DEBUG", | ||
420 | #endif | ||
421 | "-c", cfgname, NULL); | ||
422 | #endif | ||
423 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | ||
424 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); | ||
425 | GNUNET_assert (p->th != NULL); | ||
426 | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); | ||
427 | } | ||
428 | |||
429 | |||
430 | static void | ||
431 | run (void *cls, char *const *args, const char *cfgfile, | ||
432 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
433 | { | ||
434 | GNUNET_assert (ok == 1); | ||
435 | OKPP; | ||
436 | setup_peer (&p1, "test_core_quota_asymmetric_recv_limited_peer1.conf"); | ||
437 | setup_peer (&p2, "test_core_quota_asymmetric_recv_limited_peer2.conf"); | ||
438 | GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, | ||
439 | &disconnect_notify, NULL, &inbound_notify, GNUNET_YES, | ||
440 | &outbound_notify, GNUNET_YES, handlers); | ||
441 | } | ||
442 | |||
443 | static void | ||
444 | stop_arm (struct PeerContext *p) | ||
445 | { | ||
446 | #if START_ARM | ||
447 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) | ||
448 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
449 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) | ||
450 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | ||
451 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", | ||
452 | GNUNET_OS_process_get_pid (p->arm_proc)); | ||
453 | GNUNET_OS_process_close (p->arm_proc); | ||
454 | p->arm_proc = NULL; | ||
455 | #endif | ||
456 | GNUNET_CONFIGURATION_destroy (p->cfg); | ||
457 | } | ||
458 | |||
459 | static int | ||
460 | check () | ||
461 | { | ||
462 | char *const argv[] = { "test-core-api-preferences", | ||
463 | "-c", | ||
464 | "test_core_api_data.conf", | ||
465 | #if VERBOSE | ||
466 | "-L", "DEBUG", | ||
467 | #endif | ||
468 | NULL | ||
469 | }; | ||
470 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
471 | GNUNET_GETOPT_OPTION_END | ||
472 | }; | ||
473 | ok = 1; | ||
474 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | ||
475 | "test-core-api-preferences", "nohelp", options, &run, | ||
476 | &ok); | ||
477 | stop_arm (&p1); | ||
478 | stop_arm (&p2); | ||
479 | return ok; | ||
480 | } | ||
481 | |||
482 | int | ||
483 | main (int argc, char *argv[]) | ||
484 | { | ||
485 | int ret; | ||
486 | |||
487 | GNUNET_log_setup ("test-core-api", | ||
488 | #if VERBOSE | ||
489 | "DEBUG", | ||
490 | #else | ||
491 | "WARNING", | ||
492 | #endif | ||
493 | NULL); | ||
494 | ret = check (); | ||
495 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); | ||
496 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-2"); | ||
497 | |||
498 | return ret; | ||
499 | } | ||
500 | |||
501 | /* end of test_core_api_preferences.c */ | ||
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h index 7419b44a2..366986b4b 100644 --- a/src/include/gnunet_core_service.h +++ b/src/include/gnunet_core_service.h | |||
@@ -240,76 +240,6 @@ GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle); | |||
240 | 240 | ||
241 | 241 | ||
242 | /** | 242 | /** |
243 | * Function called with perference change information about the given peer. | ||
244 | * | ||
245 | * @param cls closure | ||
246 | * @param peer identifies the peer | ||
247 | * @param amount set to the amount that was actually reserved or unreserved; | ||
248 | * either the full requested amount or zero (no partial reservations) | ||
249 | * @param res_delay if the reservation could not be satisfied (amount was 0), how | ||
250 | * long should the client wait until re-trying? | ||
251 | */ | ||
252 | typedef void (*GNUNET_CORE_PeerConfigurationInfoCallback) (void *cls, | ||
253 | const struct | ||
254 | GNUNET_PeerIdentity * | ||
255 | peer, | ||
256 | int32_t amount, | ||
257 | struct | ||
258 | GNUNET_TIME_Relative | ||
259 | res_delay); | ||
260 | |||
261 | |||
262 | |||
263 | /** | ||
264 | * Context that can be used to cancel a peer information request. | ||
265 | */ | ||
266 | struct GNUNET_CORE_InformationRequestContext; | ||
267 | |||
268 | |||
269 | /** | ||
270 | * Obtain statistics and/or change preferences for the given peer. | ||
271 | * You can only have one such pending request per peer. | ||
272 | * | ||
273 | * @param h core handle | ||
274 | * @param peer identifies the peer | ||
275 | * @param amount reserve N bytes for receiving, negative | ||
276 | * amounts can be used to undo a (recent) reservation; | ||
277 | * @param preference increase incoming traffic share preference by this amount; | ||
278 | * in the absence of "amount" reservations, we use this | ||
279 | * preference value to assign proportional bandwidth shares | ||
280 | * to all connected peers | ||
281 | * @param info function to call with the resulting configuration information | ||
282 | * @param info_cls closure for info | ||
283 | * @return NULL on error | ||
284 | * @deprecated will be replaced soon | ||
285 | */ | ||
286 | struct GNUNET_CORE_InformationRequestContext * | ||
287 | GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h, | ||
288 | const struct GNUNET_PeerIdentity *peer, | ||
289 | int32_t amount, uint64_t preference, | ||
290 | GNUNET_CORE_PeerConfigurationInfoCallback | ||
291 | info, void *info_cls); | ||
292 | |||
293 | |||
294 | /** | ||
295 | * Cancel request for getting information about a peer. | ||
296 | * Note that an eventual change in preference, trust or bandwidth | ||
297 | * assignment MAY have already been committed at the time, | ||
298 | * so cancelling a request is NOT sure to undo the original | ||
299 | * request. The original request may or may not still commit. | ||
300 | * The only thing cancellation ensures is that the callback | ||
301 | * from the original request will no longer be called. | ||
302 | * | ||
303 | * @param irc context returned by the original GNUNET_CORE_peer_get_info call | ||
304 | * @deprecated will be replaced soon | ||
305 | */ | ||
306 | void | ||
307 | GNUNET_CORE_peer_change_preference_cancel (struct | ||
308 | GNUNET_CORE_InformationRequestContext | ||
309 | *irc); | ||
310 | |||
311 | |||
312 | /** | ||
313 | * Iterate over all connected peers. Calls peer_cb with each | 243 | * Iterate over all connected peers. Calls peer_cb with each |
314 | * connected peer, and then once with NULL to indicate that all peers | 244 | * connected peer, and then once with NULL to indicate that all peers |
315 | * have been handled. | 245 | * have been handled. |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 78b3a5c94..1b95d847b 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -402,11 +402,6 @@ extern "C" | |||
402 | #define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND 71 | 402 | #define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND 71 |
403 | 403 | ||
404 | /** | 404 | /** |
405 | * Request from client to "configure" P2P connection. | ||
406 | */ | ||
407 | #define GNUNET_MESSAGE_TYPE_CORE_REQUEST_INFO 72 | ||
408 | |||
409 | /** | ||
410 | * Response from server about (possibly updated) P2P | 405 | * Response from server about (possibly updated) P2P |
411 | * connection configuration. | 406 | * connection configuration. |
412 | */ | 407 | */ |