fix div by zero
[oweals/gnunet.git] / src / transport / gnunet-service-transport_manipulation.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2010-2015 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your 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      Affero General Public License for more details.
14     
15      You should have received a copy of the GNU Affero General Public License
16      along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /**
20  * @file transport/gnunet-service-transport_neighbours.h
21  * @brief neighbour manipulation API, allows manipulation of
22  *        performance metrics (delay and towards ATS)
23  * @author Christian Grothoff
24  */
25 #ifndef GNUNET_SERVICE_TRANSPORT_MANIPULATION_H
26 #define GNUNET_SERVICE_TRANSPORT_MANIPULATION_H
27
28 #include "platform.h"
29 #include "gnunet-service-transport_hello.h"
30 #include "gnunet-service-transport_neighbours.h"
31 #include "gnunet-service-transport_plugins.h"
32 #include "gnunet-service-transport_validation.h"
33 #include "gnunet-service-transport.h"
34 #include "transport.h"
35
36
37 /**
38  * Set traffic metric to manipulate
39  *
40  * @param message containing information
41  */
42 void
43 GST_manipulation_set_metric (const struct TrafficMetricMessage *tm);
44
45
46 /**
47  * Adapter function between transport's send function and transport plugins
48  *
49  * @param target the peer the message to send to
50  * @param msg the message received
51  * @param msg_size message size
52  * @param timeout timeout
53  * @param cont the continuation to call after sending
54  * @param cont_cls cls for continuation
55  */
56 void
57 GST_manipulation_send (const struct GNUNET_PeerIdentity *target,
58                        const void *msg,
59                        size_t msg_size,
60                        struct GNUNET_TIME_Relative timeout,
61                        GST_NeighbourSendContinuation cont,
62                        void *cont_cls);
63
64
65 /**
66  * Adapter function between transport plugins and transport receive function
67  * manipulation delays for next send.
68  *
69  * @param cls the closure for transport
70  * @param address the address and the peer the message was received from
71  * @param message the message received
72  * @param session the session the message was received on
73  * @return manipulated delay for next receive
74  */
75 struct GNUNET_TIME_Relative
76 GST_manipulation_recv (void *cls,
77                        const struct GNUNET_HELLO_Address *address,
78                        struct GNUNET_ATS_Session *session,
79                        const struct GNUNET_MessageHeader *message);
80
81
82 /**
83  * Function that will be called to manipulate ATS information according to
84  * current manipulation settings
85  *
86  * @param address binary address
87  * @param session the session
88  * @param prop[IN|OUT] metrics to modify
89  */
90 void
91 GST_manipulation_manipulate_metrics (const struct GNUNET_HELLO_Address *address,
92                                      struct GNUNET_ATS_Session *session,
93                                      struct GNUNET_ATS_Properties *prop);
94
95
96 /**
97  * Notify manipulation about disconnect so it can discard queued messages
98  *
99  * @param peer the disconnecting peer
100  */
101 void
102 GST_manipulation_peer_disconnect (const struct GNUNET_PeerIdentity *peer);
103
104
105 /**
106  * Initialize traffic manipulation
107  */
108 void
109 GST_manipulation_init (void);
110
111
112 /**
113  * Stop traffic manipulation
114  */
115 void
116 GST_manipulation_stop (void);
117
118 #endif
119 /* end of file gnunet-service-transport_neighbours.h */