-fix NPE
[oweals/gnunet.git] / src / transport / gnunet-service-transport_manipulation.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2010-2015 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., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file transport/gnunet-service-transport_neighbours.h
23  * @brief neighbour manipulation API, allows manipulation of
24  *        performance metrics (delay and towards ATS)
25  * @author Christian Grothoff
26  */
27 #ifndef GNUNET_SERVICE_TRANSPORT_MANIPULATION_H
28 #define GNUNET_SERVICE_TRANSPORT_MANIPULATION_H
29
30 #include "platform.h"
31 #include "gnunet-service-transport_blacklist.h"
32 #include "gnunet-service-transport_clients.h"
33 #include "gnunet-service-transport_hello.h"
34 #include "gnunet-service-transport_neighbours.h"
35 #include "gnunet-service-transport_plugins.h"
36 #include "gnunet-service-transport_validation.h"
37 #include "gnunet-service-transport.h"
38 #include "transport.h"
39
40
41 /**
42  * Set traffic metric to manipulate
43  *
44  * @param cls closure
45  * @param client client sending message
46  * @param message containing information
47  */
48 void
49 GST_manipulation_set_metric (void *cls,
50                              struct GNUNET_SERVER_Client *client,
51                              const struct GNUNET_MessageHeader *message);
52
53
54 /**
55  * Adapter function between transport's send function and transport plugins
56  *
57  * @param target the peer the message to send to
58  * @param msg the message received
59  * @param msg_size message size
60  * @param timeout timeout
61  * @param cont the continuation to call after sending
62  * @param cont_cls cls for continuation
63  */
64 void
65 GST_manipulation_send (const struct GNUNET_PeerIdentity *target,
66                        const void *msg,
67                        size_t msg_size,
68                        struct GNUNET_TIME_Relative timeout,
69                        GST_NeighbourSendContinuation cont,
70                        void *cont_cls);
71
72
73 /**
74  * Adapter function between transport plugins and transport receive function
75  * manipulation delays for next send.
76  *
77  * @param cls the closure for transport
78  * @param address the address and the peer the message was received from
79  * @param message the message received
80  * @param session the session the message was received on
81  * @return manipulated delay for next receive
82  */
83 struct GNUNET_TIME_Relative
84 GST_manipulation_recv (void *cls,
85                        const struct GNUNET_HELLO_Address *address,
86                        struct GNUNET_ATS_Session *session,
87                        const struct GNUNET_MessageHeader *message);
88
89
90 /**
91  * Function that will be called to manipulate ATS information according to
92  * current manipulation settings
93  *
94  * @param address binary address
95  * @param session the session
96  * @param prop[IN|OUT] metrics to modify
97  */
98 void
99 GST_manipulation_manipulate_metrics (const struct GNUNET_HELLO_Address *address,
100                                      struct GNUNET_ATS_Session *session,
101                                      struct GNUNET_ATS_Properties *prop);
102
103
104 /**
105  * Notify manipulation about disconnect so it can discard queued messages
106  *
107  * @param peer the disconnecting peer
108  */
109 void
110 GST_manipulation_peer_disconnect (const struct GNUNET_PeerIdentity *peer);
111
112
113 /**
114  * Initialize traffic manipulation
115  */
116 void
117 GST_manipulation_init (void);
118
119
120 /**
121  * Stop traffic manipulation
122  */
123 void
124 GST_manipulation_stop (void);
125
126 #endif
127 /* end of file gnunet-service-transport_neighbours.h */