messages for inter-controller overlay connect
[oweals/gnunet.git] / src / include / gnunet_ats_service.h
1 /*
2      This file is part of GNUnet.
3      (C) 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 include/gnunet_ats_service.h
22  * @brief automatic transport selection and outbound bandwidth determination
23  * @author Christian Grothoff
24  * @author Matthias Wachs
25  */
26 #ifndef GNUNET_ATS_SERVICE_H
27 #define GNUNET_ATS_SERVICE_H
28
29 #include "gnunet_constants.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_hello_lib.h"
32
33
34 enum GNUNET_ATS_Network_Type
35 {
36   GNUNET_ATS_NET_UNSPECIFIED = 0,
37   GNUNET_ATS_NET_LOOPBACK = 1,
38   GNUNET_ATS_NET_LAN = 2,
39   GNUNET_ATS_NET_WAN = 3,
40   GNUNET_ATS_NET_WLAN = 4,
41 };
42
43 /**
44  * Enum defining all known property types for ATS Enum values are used
45  * in the GNUNET_ATS_Information struct as
46  * (key,value)-pairs.
47  *
48  * Cost are always stored in uint32_t, so all units used to define costs
49  * have to be normalized to fit in uint32_t [0 .. 4.294.967.295]
50  */
51 enum GNUNET_ATS_Property
52 {
53
54   /**
55    * End of the array.
56    * @deprecated
57    */
58   GNUNET_ATS_ARRAY_TERMINATOR = 0,
59
60   /**
61    * Actual traffic on this connection from the other peer to this peer.
62    *
63    * Unit: [bytes/second]
64    */
65   GNUNET_ATS_UTILIZATION_UP,
66
67   /**
68    * Actual traffic on this connection from this peer to the other peer.
69    *
70    * Unit: [bytes/second]
71    */
72   GNUNET_ATS_UTILIZATION_DOWN,
73
74   /**
75    * Is this address located in WAN, LAN or a loopback address
76    * Value is element of GNUNET_ATS_Network_Type
77    */
78   GNUNET_ATS_NETWORK_TYPE,
79
80   /**
81    * Delay
82    * Time between when the time packet is sent and the packet arrives
83    *
84    * Unit: [ms]
85    *
86    * Examples:
87    *
88    * LAN   :    1
89    * WLAN  :    2
90    * Dialup:  500
91    */
92   GNUNET_ATS_QUALITY_NET_DELAY,
93
94   /**
95    * Distance on network layer (required for distance-vector routing).
96    *
97    * Unit: [DV-hops]
98    */
99   GNUNET_ATS_QUALITY_NET_DISTANCE,
100
101   /**
102    * Network overhead on WAN (Wide-Area Network)
103    *
104    * How many bytes are sent on the WAN when 1 kilobyte (1024 bytes)
105    * of application data is transmitted?
106    * A factor used with connect cost, bandwidth cost and energy cost
107    * to describe the overhead produced by the transport protocol
108    *
109    * Unit: [bytes/kb]
110    *
111    * Interpretation: less is better
112    *
113    * Examples:
114    *
115    * TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb]
116    * TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb]
117    * UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8  = 1090 [bytes/kb]
118    * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8  = 1110 [bytes/kb]
119    */
120   GNUNET_ATS_COST_WAN,
121
122   /**
123    * Network overhead on LAN (Local-Area Network)
124    *
125    * How many bytes are sent on the LAN when 1 kilobyte (1024 bytes)
126    * of application data is transmitted?
127    * A factor used with connect cost, bandwidth cost and energy cost
128    * to describe the overhead produced by the transport protocol
129    *
130    * Unit: [bytes/kb]
131    *
132    * Interpretation: less is better
133    *
134    * Examples:
135    *
136    * TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb]
137    * TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb]
138    * UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8  = 1090 [bytes/kb]
139    * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8  = 1110 [bytes/kb]
140    */
141   GNUNET_ATS_COST_LAN,
142
143   /**
144    * Network overhead on WLAN (Wireless Local Area Network)
145    *
146    * How many bytes are sent on the LAN when 1 kilobyte (1024 bytes)
147    * of application data is transmitted?
148    * A factor used with connect cost, bandwidth cost and energy cost
149    * to describe the overhead produced by the transport protocol
150    *
151    * Unit: [bytes/kb]
152    *
153    * Interpretation: less is better
154    *
155    * Examples:
156    *
157    * TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb]
158    * TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb]
159    * UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8  = 1090 [bytes/kb]
160    * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8  = 1110 [bytes/kb]
161    */
162   GNUNET_ATS_COST_WLAN
163       /* Cost related values */
164       /* =================== */
165   /**
166    * Volume based cost in financial units to transmit data
167    *
168    * Note: This value is not bound to a specific currency or unit and only
169    * used locally.
170    * "cent" just refers the smallest amount of money in the respective
171    * currency.
172    *
173    * Unit: [cent/MB]
174    *
175    * Interpretation: less is better
176    *
177    * Examples:
178    * LAN:  0 [cent/MB]
179    * 2G : 10 [cent/MB]
180    */
181       // GNUNET_ATS_COST_FINANCIAL_PER_VOLUME = 1,
182   /**
183    * Time based cost in financial units to transmit data
184    *
185    * Note: This value is not bound to a specific currency or unit and only
186    * used locally.
187    * "cent" just refers the smallest amount of money in the respective
188    * currency.
189    *
190    * Unit: [cent/h]
191    *
192    * Interpretation: less is better
193    *
194    * Examples:
195    * LAN   :  0 [cent/h]
196    * Dialup: 10 [cent/h]
197    */
198       // GNUNET_ATS_COST_FINANCIAL_PER_TIME = 2,
199   /**
200    * Computational costs
201    *
202    * Effort of preparing data to be sent with this transport
203    * Includes encoding, encryption and conversion of data
204    * Partial values can be summed up: c_sum = c_enc + c_enc + c_conv
205    * Resulting values depend on local system properties, e.g. CPU
206    *
207    * Unit: [ms/GB]
208    *
209    * Interpretation: less is better
210    *
211    * Examples:
212    *
213    * HTTPS with AES CBC-256:    7,382
214    * HTTPS with AES CBC-128:    5,279
215    * HTTPS with RC4-1024:       2,652
216    */
217       // GNUNET_ATS_COST_COMPUTATIONAL = 3,
218   /**
219    * Energy consumption
220    *
221    * Energy consumption using this transport when sending with a certain
222    * power at a certain bitrate. This is only an approximation based on:
223    * Energy consumption E = P / D
224    *
225    * with:
226    * Power P in Watt (J/s)
227    * Datarate D in MBit/s
228    *
229    * Conversion between power P and dBm used by WLAN in radiotap's dBm TX power:
230    *
231    * Lp(dbm) = 10 log10 (P/ 1mW)
232    *
233    * => P = 1 mW  * 10^(Lp(dbm)/10)
234    *
235    * Unit: [mJ/MB]
236    *
237    * Interpretation: less is better
238    *
239    * Examples:
240    *
241    * LAN:       0
242    * WLAN:      89 (600 mW @ 802.11g /w 54 MBit/s)
243    * Bluetooth: 267 (100 mW @ BT2.0 EDR /w 3 MBit/s)
244    */
245       // GNUNET_ATS_COST_ENERGY_CONSUMPTION = 4,
246   /**
247    * Connect cost
248    * How many bytes are transmitted to initiate a new connection using
249    * this transport?
250    *
251    * Unit: [bytes]
252    *
253    * Interpretation: less is better
254    *
255    * Examples:
256    *
257    * UDP (No connection)      :
258    *     0 bytes
259    * TCP (TCP 3-Way handshake):
260    *   220 bytes Ethernet,  172 bytes TCP/IP,  122 bytes TCP
261    * HTTP (TCP + Header)      :
262    *   477 bytes Ethernet,  429 bytes TCP/IP,  374 bytes TCP,  278 bytes HTTP
263    * HTTPS  HTTP+TLS Handshake:
264    *  2129 bytes Ethernet, 1975 bytes TCP/IP, 1755 bytes TCP, 1403 bytes HTTPS
265    *
266    * */
267       // GNUNET_ATS_COST_CONNECT = 5,
268   /**
269    * Bandwidth cost
270    *
271    * How many bandwidth is available to consume?
272    * Used to calculate which impact sending data with this transport has
273    *
274    * Unit: [kB/s]
275    *
276    * Interpretation: more is better
277    *
278    * Examples:
279    * LAN:     12,800  (100 MBit/s)
280    * WLAN:    6,912   (54 MBit/s)
281    * Dial-up: 8       (64 Kbit/s)
282    *
283    */
284       // GNUNET_ATS_COST_BANDWITH_AVAILABLE = 6,
285   /**
286    *  Network overhead
287    *
288    * How many bytes are sent over the wire when 1 kilobyte (1024 bytes)
289    * of application data is transmitted?
290    * A factor used with connect cost, bandwidth cost and energy cost
291    * to describe the overhead produced by the transport protocol
292    *
293    * Unit: [bytes/kb]
294    *
295    * Interpretation: less is better
296    *
297    * Examples:
298    *
299    * TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb]
300    * TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb]
301    * UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8  = 1090 [bytes/kb]
302    * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8  = 1110 [bytes/kb]
303    */
304       // GNUNET_ATS_COST_NETWORK_OVERHEAD = 7,
305       /* Quality related values */
306       /* ====================== */
307       /* Physical layer quality properties */
308   /**
309    * Signal strength on physical layer
310    *
311    * Unit: [dBm]
312    */
313       // GNUNET_ATS_QUALITY_PHY_SIGNAL_STRENGTH = 1025,
314   /**
315    * Collision rate on physical layer
316    *
317    * Unit: [B/s]
318    */
319       // GNUNET_ATS_QUALITY_PHY_COLLISION_RATE = 1026,
320   /**
321    * Error rate on physical layer
322    *
323    * Unit: [B/s]
324    */
325       // GNUNET_ATS_QUALITY_PHY_ERROR_RATE = 1027,
326   /**
327    * Jitter
328    * Time variations of the delay
329    * 1st derivative of a delay function
330    *
331    * Unit: [ms]
332    */
333       // GNUNET_ATS_QUALITY_NET_JITTER = 1029,
334   /**
335    * Error rate on network layer
336    *
337    * Unit: [B/s]
338    *
339    * Examples:
340    *
341    * LAN       :    0
342    * WLAN      :  400
343    * Bluetooth :  100
344    * Note: This numbers are just assumptions as an example, not
345    * measured or somehow determined
346    */
347       // GNUNET_ATS_QUALITY_NET_ERRORRATE = 1030,
348   /**
349    * Drop rate on network layer
350    * Bytes actively dismissed by a network component during transmission
351    * Reasons for dropped data can be full queues, congestion, quota violations...
352    *
353    * Unit: [B/s]
354    *
355    * Examples:
356    *
357    * LAN       :    0
358    * WLAN      :  400
359    * Bluetooth :  100
360    * Note: This numbers are just assumptions as an example, not
361    * measured or somehow determined
362    */
363       // GNUNET_ATS_QUALITY_NET_DROPRATE = 1031,
364   /**
365    * Loss rate on network layer
366    * Bytes lost during transmission
367    * Reasons can be collisions, ...
368    *
369    * Unit: [B/s]
370    *
371    * Examples:
372    *
373    * LAN       :    0
374    * WLAN      :   40
375    * Bluetooth :   10
376    * Note: This numbers are just assumptions as an example, not measured
377    * or somehow determined
378    */
379       // GNUNET_ATS_QUALITY_NET_LOSSRATE = 1032,
380   /**
381    * Throughput on network layer
382    *
383    * Unit: [kB/s]
384    *
385    * Examples:
386    *
387    * LAN   : 3400
388    * WLAN  : 1200
389    * Dialup:      4
390    *
391    */
392       // GNUNET_ATS_QUALITY_NET_THROUGHPUT = 1033,
393       /* Availability related values */
394       /* =========================== */
395   /**
396    * Is a peer reachable?
397    */
398       // GNUNET_ATS_AVAILABILITY_REACHABLE = 2048,
399   /**
400    * Is there a connection established to a peer using this transport
401    */
402       // GNUNET_ATS_AVAILABILITY_CONNECTED = 2049
403 };
404
405 /**
406  * Number of ATS quality properties
407  */
408 #define GNUNET_ATS_QualityPropertiesCount 2
409
410 /**
411  * ATS quality properties as array initializer
412  */
413 #define GNUNET_ATS_QualityProperties {GNUNET_ATS_QUALITY_NET_DELAY, GNUNET_ATS_QUALITY_NET_DISTANCE}
414
415 /**
416  * Number of ATS quality properties
417  */
418 #define GNUNET_ATS_NetworkTypeCount 5
419
420 /**
421  * ATS quality properties as array initializer
422  */
423 #define GNUNET_ATS_NetworkType {GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN}
424
425 GNUNET_NETWORK_STRUCT_BEGIN
426
427 /**
428  * struct used to communicate the transport's properties like cost and
429  * quality of service as well as high-level constraints on resource
430  * consumption.
431  *
432  *                             +---+
433  *  +-----------+ Constraints  |   |  Plugin properties +---------+
434  *  | Highlevel |------------> |ATS| <------------------|Transport|
435  *  | Component | ATS struct   |   |    ATS struct      | Plugin  |
436  *  +-----------+              |   |                    +---------+
437  *                             +---+
438  *
439  * This structure will be used by transport plugins to communicate
440  * costs to ATS or by higher level components to tell ATS their
441  * constraints.  Always a pair of (GNUNET_ATS_Property,
442  * uint32_t value).  Value is always uint32_t, so all units used to
443  * define costs have to be normalized to fit uint32_t.
444  */
445 struct GNUNET_ATS_Information
446 {
447   /**
448    * ATS property type, in network byte order.
449    */
450   uint32_t type GNUNET_PACKED;
451
452   /**
453    * ATS property value, in network byte order.
454    */
455   uint32_t value GNUNET_PACKED;
456 };
457 GNUNET_NETWORK_STRUCT_END
458
459
460 /* ******************************** Scheduling API ***************************** */
461
462 /**
463  * Handle to the ATS subsystem for bandwidth/transport scheduling information.
464  */
465 struct GNUNET_ATS_SchedulingHandle;
466
467
468 /**
469  * Opaque session handle, defined by plugins.  Contents not known to ATS.
470  */
471 struct Session;
472
473
474 /**
475  * Signature of a function called by ATS with the current bandwidth
476  * and address preferences as determined by ATS.
477  *
478  * @param cls closure
479  * @param address suggested address (including peer identity of the peer)
480  * @param session session to use
481  * @param bandwidth_out assigned outbound bandwidth for the connection
482  * @param bandwidth_in assigned inbound bandwidth for the connection
483  * @param ats performance data for the address (as far as known)
484  * @param ats_count number of performance records in 'ats'
485  */
486 typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
487                                                       const struct
488                                                       GNUNET_HELLO_Address *
489                                                       address,
490                                                       struct Session * session,
491                                                       struct
492                                                       GNUNET_BANDWIDTH_Value32NBO
493                                                       bandwidth_out,
494                                                       struct
495                                                       GNUNET_BANDWIDTH_Value32NBO
496                                                       bandwidth_in,
497                                                       const struct
498                                                       GNUNET_ATS_Information *
499                                                       ats, uint32_t ats_count);
500
501
502 /**
503  * Initialize the ATS subsystem.
504  *
505  * @param cfg configuration to use
506  * @param suggest_cb notification to call whenever the suggestation changed
507  * @param suggest_cb_cls closure for 'suggest_cb'
508  * @return ats context
509  */
510 struct GNUNET_ATS_SchedulingHandle *
511 GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
512                             GNUNET_ATS_AddressSuggestionCallback suggest_cb,
513                             void *suggest_cb_cls);
514
515
516 /**
517  * Client is done with ATS scheduling, release resources.
518  *
519  * @param sh handle to release
520  */
521 void
522 GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh);
523
524
525 /**
526  * We would like to reset the address suggestion block time for this
527  * peer
528  *
529  * @param sh handle
530  * @param peer identity of the peer we want to reset
531  */
532 void
533 GNUNET_ATS_reset_backoff (struct GNUNET_ATS_SchedulingHandle *sh,
534                           const struct GNUNET_PeerIdentity *peer);
535
536 /**
537  * We would like to establish a new connection with a peer.  ATS
538  * should suggest a good address to begin with.
539  *
540  * @param sh handle
541  * @param peer identity of the peer we need an address for
542  */
543 void
544 GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh,
545                             const struct GNUNET_PeerIdentity *peer);
546
547
548 /**
549  * We want to cancel ATS suggesting addresses for a peer.
550  *
551  * @param sh handle
552  * @param peer identity of the peer
553  */
554 void
555 GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SchedulingHandle *sh,
556                                    const struct GNUNET_PeerIdentity *peer);
557
558
559 /**
560  * Returns where the address is located: LAN or WAN or ...
561  * @param sh the GNUNET_ATS_SchedulingHandle handle
562  * @param addr address
563  * @param addrlen address length
564  * @return location as GNUNET_ATS_Information
565  */
566 struct GNUNET_ATS_Information
567 GNUNET_ATS_address_get_type (struct GNUNET_ATS_SchedulingHandle *sh,
568                              const struct sockaddr * addr,
569                              socklen_t addrlen);
570
571 /**
572  * We have a new address ATS should know. Addresses have to be added with this
573  * function before they can be: updated, set in use and destroyed
574  *
575  * @param sh handle
576  * @param address the address
577  * @param session session handle (if available)
578  * @param ats performance data for the address
579  * @param ats_count number of performance records in 'ats'
580  */
581 int
582 GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh,
583                         const struct GNUNET_HELLO_Address *address,
584                         struct Session *session,
585                         const struct GNUNET_ATS_Information *ats,
586                         uint32_t ats_count);
587
588
589 /**
590  * We have updated performance statistics for a given address.  Note
591  * that this function can be called for addresses that are currently
592  * in use as well as addresses that are valid but not actively in use.
593  * Furthermore, the peer may not even be connected to us right now (in
594  * which case the call may be ignored or the information may be stored
595  * for later use).  Update bandwidth assignments.
596  *
597  * @param sh handle
598  * @param address updated address
599  * @param session session handle (if available)
600  * @param ats performance data for the address
601  * @param ats_count number of performance records in 'ats'
602  */
603 void
604 GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
605                            const struct GNUNET_HELLO_Address *address,
606                            struct Session *session,
607                            const struct GNUNET_ATS_Information *ats,
608                            uint32_t ats_count);
609
610
611 /**
612  * An address is now in use or not used any more.
613  *
614  * @param sh handle
615  * @param address the address
616  * @param session session handle
617  * @param in_use GNUNET_YES if this address is now used, GNUNET_NO
618  * if address is not used any more
619  */
620 void
621 GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
622                            const struct GNUNET_HELLO_Address *address,
623                            struct Session *session, int in_use);
624
625
626 /**
627  * A session got destroyed, stop including it as a valid address.
628  *
629  * @param sh handle
630  * @param address the address
631  * @param session session handle that is no longer valid (if available)
632  */
633 void
634 GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *sh,
635                               const struct GNUNET_HELLO_Address *address,
636                               struct Session *session);
637
638
639 /* ******************************** Performance API ***************************** */
640
641 /**
642  * ATS Handle to obtain and/or modify performance information.
643  */
644 struct GNUNET_ATS_PerformanceHandle;
645
646
647 /**
648  * Signature of a function that is called with QoS information about a peer.
649  *
650  * @param cls closure
651  * @param address the address
652  * @param bandwidth_out assigned outbound bandwidth for the connection
653  * @param bandwidth_in assigned inbound bandwidth for the connection
654  * @param ats performance data for the address (as far as known)
655  * @param ats_count number of performance records in 'ats'
656  */
657 typedef void (*GNUNET_ATS_PeerInformationCallback) (void *cls,
658                                                     const struct
659                                                     GNUNET_HELLO_Address *
660                                                     address,
661                                                     struct
662                                                     GNUNET_BANDWIDTH_Value32NBO
663                                                     bandwidth_out,
664                                                     struct
665                                                     GNUNET_BANDWIDTH_Value32NBO
666                                                     bandwidth_in,
667                                                     const struct
668                                                     GNUNET_ATS_Information *
669                                                     ats, uint32_t ats_count);
670
671
672 /**
673  * Get handle to access performance API of the ATS subsystem.
674  *
675  * @param cfg configuration to use
676  * @param infocb function to call on performance changes, can be NULL
677  * @param infocb_cls closure for infocb
678  * @return ats performance context
679  */
680 struct GNUNET_ATS_PerformanceHandle *
681 GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
682                              GNUNET_ATS_PeerInformationCallback infocb,
683                              void *infocb_cls);
684
685
686 /**
687  * Client is done using the ATS performance subsystem, release resources.
688  *
689  * @param ph handle
690  */
691 void
692 GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph);
693
694
695 /**
696  * Function called with reservation result.
697  *
698  * @param cls closure
699  * @param peer identifies the peer
700  * @param amount set to the amount that was actually reserved or unreserved;
701  *               either the full requested amount or zero (no partial reservations)
702  * @param res_delay if the reservation could not be satisfied (amount was 0), how
703  *        long should the client wait until re-trying?
704  */
705 typedef void (*GNUNET_ATS_ReservationCallback) (void *cls,
706                                                 const struct GNUNET_PeerIdentity
707                                                 * peer, int32_t amount,
708                                                 struct GNUNET_TIME_Relative
709                                                 res_delay);
710
711
712
713 /**
714  * Context that can be used to cancel a peer information request.
715  */
716 struct GNUNET_ATS_ReservationContext;
717
718
719 /**
720  * Reserve inbound bandwidth from the given peer.  ATS will look at
721  * the current amount of traffic we receive from the peer and ensure
722  * that the peer could add 'amount' of data to its stream.
723  *
724  * @param ph performance handle
725  * @param peer identifies the peer
726  * @param amount reserve N bytes for receiving, negative
727  *                amounts can be used to undo a (recent) reservation;
728  * @param rcb function to call with the resulting reservation information
729  * @param rcb_cls closure for info
730  * @return NULL on error
731  * @deprecated will be replaced soon
732  */
733 struct GNUNET_ATS_ReservationContext *
734 GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph,
735                               const struct GNUNET_PeerIdentity *peer,
736                               int32_t amount,
737                               GNUNET_ATS_ReservationCallback rcb,
738                               void *rcb_cls);
739
740
741 /**
742  * Cancel request for reserving bandwidth.
743  *
744  * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
745  */
746 void
747 GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc);
748
749
750
751 /**
752  * Enum defining all known preference categories.
753  */
754 enum GNUNET_ATS_PreferenceKind
755 {
756
757   /**
758    * End of preference list.
759    */
760   GNUNET_ATS_PREFERENCE_END = 0,
761
762   /**
763    * Change the peer's bandwidth value (value per byte of bandwidth in
764    * the goal function) to the given amount.  The argument is followed
765    * by a double value giving the desired value (can be negative).
766    * Preference changes are forgotten if peers disconnect.
767    */
768   GNUNET_ATS_PREFERENCE_BANDWIDTH,
769
770   /**
771    * Change the peer's latency value to the given amount.  The
772    * argument is followed by a double value giving the desired value
773    * (can be negative).  The absolute score in the goal function is
774    * the inverse of the latency in ms (minimum: 1 ms) multiplied by
775    * the latency preferences.
776    */
777   GNUNET_ATS_PREFERENCE_LATENCY
778 };
779
780
781 /**
782  * Change preferences for the given peer. Preference changes are forgotten if peers
783  * disconnect.
784  *
785  * @param ph performance handle
786  * @param peer identifies the peer
787  * @param ... 0-terminated specification of the desired changes
788  */
789 void
790 GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *ph,
791                               const struct GNUNET_PeerIdentity *peer, ...);
792
793
794
795 #endif
796 /* end of file gnunet-service-transport_ats.h */