diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-06 23:09:59 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-06 23:09:59 +0000 |
commit | aeece360025012e270a30d4cd174a60fca30af38 (patch) | |
tree | c011ee6f932d36971feaf1b70ea9313129bcd987 | |
parent | f8de70cbb50e5821fcbb5f2303ca8e1eae12a348 (diff) | |
download | gnunet-aeece360025012e270a30d4cd174a60fca30af38.tar.gz gnunet-aeece360025012e270a30d4cd174a60fca30af38.zip |
-skeletons for transport-ng
-rw-r--r-- | src/include/gnunet_transport_communication_service.h | 228 | ||||
-rw-r--r-- | src/include/gnunet_transport_core_service.h | 177 | ||||
-rw-r--r-- | src/include/gnunet_transport_hello_service.h | 142 | ||||
-rw-r--r-- | src/include/gnunet_transport_monitor_service.h | 192 |
4 files changed, 739 insertions, 0 deletions
diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h new file mode 100644 index 000000000..aa8cc1ba1 --- /dev/null +++ b/src/include/gnunet_transport_communication_service.h | |||
@@ -0,0 +1,228 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2009-2016 GNUnet e.V. | ||
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 | * @author Christian Grothoff | ||
23 | * | ||
24 | * @file | ||
25 | * API of the transport service towards the communicator processes. | ||
26 | * | ||
27 | * @defgroup transport TRANSPORT service | ||
28 | * Low-level communication with other peers | ||
29 | * | ||
30 | * @see [Documentation](https://gnunet.org/transport-service) | ||
31 | * | ||
32 | * @{ | ||
33 | */ | ||
34 | |||
35 | #ifndef GNUNET_TRANSPORT_COMMUNICATION_SERVICE_H | ||
36 | #define GNUNET_TRANSPORT_COMMUNICATION_SERVICE_H | ||
37 | |||
38 | #ifdef __cplusplus | ||
39 | extern "C" | ||
40 | { | ||
41 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
42 | } | ||
43 | #endif | ||
44 | #endif | ||
45 | |||
46 | #include "gnunet_util_lib.h" | ||
47 | |||
48 | /** | ||
49 | * Version number of the transport communication API. | ||
50 | */ | ||
51 | #define GNUNET_TRANSPORT_COMMUNICATION_VERSION 0x00000000 | ||
52 | |||
53 | |||
54 | /** | ||
55 | * Function called by the transport service to initialize a | ||
56 | * message queue given address information about another peer. | ||
57 | * | ||
58 | * @param cls closure | ||
59 | * @param peer identity of the other peer | ||
60 | * @param address where to send the message, human-readable | ||
61 | * communicator-specific format, 0-terminated, UTF-8 | ||
62 | * @return NULL if the provided address is invalid, otherwise an MQ to | ||
63 | * send messages to that peer | ||
64 | */ | ||
65 | typedef struct GNUNET_MQ_Handle * | ||
66 | (*GNUNET_TRANSPORT_CommunicatorMqInit) (void *cls, | ||
67 | const struct GNUNET_PeerIdentity *peer, | ||
68 | const void *address); | ||
69 | |||
70 | |||
71 | /** | ||
72 | * Opaque handle to the transport service for communicators. | ||
73 | */ | ||
74 | struct GNUNET_TRANSPORT_CommunicatorHandle; | ||
75 | |||
76 | |||
77 | /** | ||
78 | * Connect to the transport service. | ||
79 | * | ||
80 | * @param cfg configuration to use | ||
81 | * @param name name of the communicator that is connecting | ||
82 | * @param mtu maximum message size supported by communicator, 0 if | ||
83 | * sending is not supported | ||
84 | * @param mq_init function to call to initialize a message queue given | ||
85 | * the address of another peer, can be NULL if the | ||
86 | * communicator only supports receiving messages | ||
87 | * @param mq_init_cls closure for @a mq_init | ||
88 | * @return NULL on error | ||
89 | */ | ||
90 | struct GNUNET_TRANSPORT_CommunicatorHandle * | ||
91 | GNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
92 | const char *name, | ||
93 | size_t mtu, | ||
94 | GNUNET_TRANSPORT_CommunicatorMqInit mq_init, | ||
95 | void *mq_init_cls); | ||
96 | |||
97 | |||
98 | /** | ||
99 | * Disconnect from the transport service. | ||
100 | * | ||
101 | * @param ch handle returned from connect | ||
102 | */ | ||
103 | void | ||
104 | GNUNET_TRANSPORT_communicator_disconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch); | ||
105 | |||
106 | |||
107 | /* ************************* Receiving *************************** */ | ||
108 | |||
109 | /** | ||
110 | * Function called to notify communicator that we have received | ||
111 | * and processed the message. | ||
112 | * | ||
113 | * @param cls closure | ||
114 | * @param success #GNUNET_SYSERR on failure (try to disconnect/reset connection) | ||
115 | * #GNUNET_OK on success | ||
116 | */ | ||
117 | typedef void | ||
118 | (*GNUNET_TRANSPORT_MessageCompletedCallback) (void *cls, | ||
119 | int success); | ||
120 | |||
121 | |||
122 | /** | ||
123 | * Notify transport service that the communicator has received | ||
124 | * a message. | ||
125 | * | ||
126 | * @param handle connection to transport service | ||
127 | * @param sender presumed sender of the message (details to be checked | ||
128 | * by higher layers) | ||
129 | * @param msg the message | ||
130 | * @param cb function to call once handling the message is done, NULL if | ||
131 | * flow control is not supported by this communicator | ||
132 | * @param cb_cls closure for @a cb | ||
133 | * @return #GNUNET_OK if all is well, #GNUNET_NO if the message was | ||
134 | * immediately dropped due to memory limitations (communicator | ||
135 | * should try to apply back pressure), | ||
136 | * #GNUNET_SYSERR if the message is ill formed and communicator | ||
137 | * should try to reset stream | ||
138 | */ | ||
139 | int | ||
140 | GNUNET_TRANSPORT_communicator_receive (struct GNUNET_TRANSPORT_CommunicatorHandle *handle, | ||
141 | const struct GNUNET_PeerIdentity *sender, | ||
142 | const struct GNUNET_MessageHeader *msg, | ||
143 | GNUNET_TRANSPORT_MessageCompletedCallback cb, | ||
144 | void *cb_cls); | ||
145 | |||
146 | |||
147 | /* ************************* Discovery *************************** */ | ||
148 | |||
149 | |||
150 | /** | ||
151 | * Notify transport service that an MQ became available due to an | ||
152 | * "inbound" connection or because the communicator discovered the | ||
153 | * presence of another peer. | ||
154 | * | ||
155 | * @param handle connection to transport service | ||
156 | * @param peer peer with which we can now communicate | ||
157 | * @param address address in human-readable format, 0-terminated, UTF-8 | ||
158 | * @param nt which network type does the @a address belong to? | ||
159 | * @param mq message queue of the @a peer | ||
160 | */ | ||
161 | void | ||
162 | GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle *handle, | ||
163 | const struct GNUNET_PeerIdentity *peer, | ||
164 | const char *address, | ||
165 | enum GNUNET_ATS_Network_Type nt, | ||
166 | struct GNUNET_MQ_Handle *mq); | ||
167 | |||
168 | |||
169 | /** | ||
170 | * Notify transport service that an MQ became unavailable due to a | ||
171 | * disconnect or timeout. | ||
172 | * | ||
173 | * @param handle connection to transport service | ||
174 | * @param peer peer with which we can no longer communicate via the given mq | ||
175 | * @param address address in human-readable format, 0-terminated, UTF-8 | ||
176 | * @param nt which network type does the @a address belong to? | ||
177 | * @param mq message queue of the @a peer | ||
178 | */ | ||
179 | void | ||
180 | GNUNET_TRANSPORT_communicator_mq_remove (struct GNUNET_TRANSPORT_CommunicatorHandle *handle, | ||
181 | const struct GNUNET_PeerIdentity *peer, | ||
182 | const char *address, | ||
183 | enum GNUNET_ATS_Network_Type nt, | ||
184 | struct GNUNET_MQ_Handle *mq); | ||
185 | |||
186 | |||
187 | /** | ||
188 | * Notify transport service about an address that this communicator | ||
189 | * provides for this peer. | ||
190 | * | ||
191 | * @param handle connection to transport service | ||
192 | * @param address our address in human-readable format, 0-terminated, UTF-8 | ||
193 | * @param nt which network type does the address belong to? | ||
194 | * @param expiration when does the communicator forsee this address expiring? | ||
195 | */ | ||
196 | void | ||
197 | GNUNET_TRANSPORT_communicator_address_add (struct GNUNET_TRANSPORT_CommunicatorHandle *handle, | ||
198 | const char *address, | ||
199 | enum GNUNET_ATS_Network_Type nt, | ||
200 | struct GNUNET_TIME_Absolute expiration); | ||
201 | |||
202 | |||
203 | /** | ||
204 | * Notify transport service about an address that this communicator | ||
205 | * no longer provides for this peer. | ||
206 | * | ||
207 | * @param handle connection to transport service | ||
208 | * @param address our former address in human-readable format, | ||
209 | * 0-terminated, in UTF-8 | ||
210 | */ | ||
211 | void | ||
212 | GNUNET_TRANSPORT_communicator_address_remove (struct GNUNET_TRANSPORT_CommunicatorHandle *handle, | ||
213 | const char *address); | ||
214 | |||
215 | |||
216 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
217 | { | ||
218 | #endif | ||
219 | #ifdef __cplusplus | ||
220 | } | ||
221 | #endif | ||
222 | |||
223 | /* ifndef GNUNET_TRANSPORT_COMMUNICATOR_SERVICE_H */ | ||
224 | #endif | ||
225 | |||
226 | /** @} */ /* end of group */ | ||
227 | |||
228 | /* end of gnunet_transport_communicator_service.h */ | ||
diff --git a/src/include/gnunet_transport_core_service.h b/src/include/gnunet_transport_core_service.h new file mode 100644 index 000000000..816d5efaa --- /dev/null +++ b/src/include/gnunet_transport_core_service.h | |||
@@ -0,0 +1,177 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2009-2016 GNUnet e.V. | ||
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 | * @author Christian Grothoff | ||
22 | * | ||
23 | * @file | ||
24 | * API of the transport service towards the CORE service. | ||
25 | * | ||
26 | * @defgroup transport TRANSPORT service | ||
27 | * Communication with other peers | ||
28 | * | ||
29 | * @see [Documentation](https://gnunet.org/transport-service) | ||
30 | * | ||
31 | * @{ | ||
32 | */ | ||
33 | #ifndef GNUNET_TRANSPORT_CORE_SERVICE_H | ||
34 | #define GNUNET_TRANSPORT_CORE_SERVICE_H | ||
35 | |||
36 | #ifdef __cplusplus | ||
37 | extern "C" | ||
38 | { | ||
39 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
40 | } | ||
41 | #endif | ||
42 | #endif | ||
43 | |||
44 | #include "gnunet_util_lib.h" | ||
45 | |||
46 | /** | ||
47 | * Version number of the transport API. | ||
48 | */ | ||
49 | #define GNUNET_TRANSPORT_CORE_VERSION 0x00000000 | ||
50 | |||
51 | |||
52 | /** | ||
53 | * Function called by the transport for each received message. | ||
54 | * | ||
55 | * @param cls closure | ||
56 | * @param peer (claimed) identity of the other peer | ||
57 | * @param message the message | ||
58 | */ | ||
59 | typedef void | ||
60 | (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls, | ||
61 | const struct GNUNET_PeerIdentity *peer, | ||
62 | const struct GNUNET_MessageHeader *message); | ||
63 | |||
64 | |||
65 | /** | ||
66 | * Opaque handle to the service. | ||
67 | */ | ||
68 | struct GNUNET_TRANSPORT_Handle; | ||
69 | |||
70 | |||
71 | /** | ||
72 | * Function called to notify CORE service that another | ||
73 | * @a peer connected to us. | ||
74 | * | ||
75 | * @param cls closure | ||
76 | * @param peer the peer that connected, never NULL | ||
77 | * @param mq message queue for sending messages to this peer | ||
78 | */ | ||
79 | typedef void | ||
80 | (*GNUNET_TRANSPORT_NotifyConnect) (void *cls, | ||
81 | const struct GNUNET_PeerIdentity *peer, | ||
82 | struct GNUNET_MQ_Handle *mq); | ||
83 | |||
84 | |||
85 | /** | ||
86 | * Function called to notify CORE service that another | ||
87 | * @a peer disconnected from us. The associated message | ||
88 | * queue must not be used henceforth. | ||
89 | * | ||
90 | * @param cls closure | ||
91 | * @param peer the peer that disconnected, never NULL | ||
92 | */ | ||
93 | typedef void | ||
94 | (*GNUNET_TRANSPORT_NotifyDisconnect) (void *cls, | ||
95 | const struct GNUNET_PeerIdentity *peer); | ||
96 | |||
97 | |||
98 | /** | ||
99 | * Function called if we have "excess" bandwidth to a peer. | ||
100 | * The notification will happen the first time we have excess | ||
101 | * bandwidth, and then only again after the client has performed | ||
102 | * some transmission to the peer. | ||
103 | * | ||
104 | * Excess bandwidth is defined as being allowed (by ATS) to send | ||
105 | * more data, and us reaching the limit of the capacity build-up | ||
106 | * (which, if we go past it, means we don't use available bandwidth). | ||
107 | * See also the "max carry" in `struct GNUNET_BANDWIDTH_Tracker`. | ||
108 | * | ||
109 | * @param cls the closure | ||
110 | * @param neighbour peer that we have excess bandwidth to | ||
111 | */ | ||
112 | typedef void | ||
113 | (*GNUNET_TRANSPORT_NotifyExcessBandwidth)(void *cls, | ||
114 | const struct GNUNET_PeerIdentity *neighbour); | ||
115 | |||
116 | |||
117 | /** | ||
118 | * Connect to the transport service. | ||
119 | * | ||
120 | * @param cfg configuration to use | ||
121 | * @param self our own identity (if API should check that it matches | ||
122 | * the identity found by transport), or NULL (no check) | ||
123 | * @param cls closure for the callbacks | ||
124 | * @param rec_handlers NULL-terminated array of handlers for incoming | ||
125 | * messages, or NULL | ||
126 | * @param nc function to call on connect events, or NULL | ||
127 | * @param nd function to call on disconnect events, or NULL | ||
128 | * @param neb function to call if we have excess bandwidth to a peer | ||
129 | * @return NULL on error | ||
130 | */ | ||
131 | struct GNUNET_TRANSPORT_Handle * | ||
132 | GNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
133 | const struct GNUNET_PeerIdentity *self, | ||
134 | void *cls, | ||
135 | GNUNET_MQ_MessageHandler *rec_handlers, | ||
136 | GNUNET_TRANSPORT_NotifyConnect nc, | ||
137 | GNUNET_TRANSPORT_NotifyDisconnect nd, | ||
138 | GNUNET_TRANSPORT_NotifyExcessBandwidth neb); | ||
139 | |||
140 | |||
141 | /** | ||
142 | * Disconnect from the transport service. | ||
143 | * | ||
144 | * @param handle handle returned from connect | ||
145 | */ | ||
146 | void | ||
147 | GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle); | ||
148 | |||
149 | |||
150 | /** | ||
151 | * Checks if a given peer is connected to us. Convenience | ||
152 | * API in case a client does not track connect/disconnect | ||
153 | * events internally. | ||
154 | * | ||
155 | * @param handle connection to transport service | ||
156 | * @param peer the peer to check | ||
157 | * @return #GNUNET_YES (connected) or #GNUNET_NO (disconnected) | ||
158 | */ | ||
159 | int | ||
160 | GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *handle, | ||
161 | const struct GNUNET_PeerIdentity *peer); | ||
162 | |||
163 | |||
164 | |||
165 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
166 | { | ||
167 | #endif | ||
168 | #ifdef __cplusplus | ||
169 | } | ||
170 | #endif | ||
171 | |||
172 | /* ifndef GNUNET_TRANSPORT_CORE_SERVICE_H */ | ||
173 | #endif | ||
174 | |||
175 | /** @} */ /* end of group */ | ||
176 | |||
177 | /* end of gnunet_transport_core_service.h */ | ||
diff --git a/src/include/gnunet_transport_hello_service.h b/src/include/gnunet_transport_hello_service.h new file mode 100644 index 000000000..8fc558d3f --- /dev/null +++ b/src/include/gnunet_transport_hello_service.h | |||
@@ -0,0 +1,142 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2009-2016 GNUnet e.V. | ||
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 | * @author Christian Grothoff | ||
23 | * | ||
24 | * @file | ||
25 | * obtain information about our current address | ||
26 | * | ||
27 | * @defgroup transport Transport service | ||
28 | * address information | ||
29 | * | ||
30 | * @see [Documentation](https://gnunet.org/transport-service) | ||
31 | * | ||
32 | * @{ | ||
33 | */ | ||
34 | #ifndef GNUNET_TRANSPORT_HELLO_SERVICE_H | ||
35 | #define GNUNET_TRANSPORT_HELLO_SERVICE_H | ||
36 | |||
37 | #ifdef __cplusplus | ||
38 | extern "C" | ||
39 | { | ||
40 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
41 | } | ||
42 | #endif | ||
43 | #endif | ||
44 | |||
45 | #include "gnunet_util_lib.h" | ||
46 | #include "gnunet_ats_service.h" | ||
47 | |||
48 | /** | ||
49 | * Version number of the transport API. | ||
50 | */ | ||
51 | #define GNUNET_TRANSPORT_HELLO_VERSION 0x00000000 | ||
52 | |||
53 | |||
54 | /** | ||
55 | * Function called whenever there is an update to the | ||
56 | * HELLO of this peer. | ||
57 | * | ||
58 | * @param cls closure | ||
59 | * @param hello our updated HELLO | ||
60 | */ | ||
61 | typedef void | ||
62 | (*GNUNET_TRANSPORT_HelloUpdateCallback) (void *cls, | ||
63 | const struct GNUNET_MessageHeader *hello); | ||
64 | |||
65 | |||
66 | /** | ||
67 | * Handle to cancel a #GNUNET_TRANSPORT_hello_get() operation. | ||
68 | */ | ||
69 | struct GNUNET_TRANSPORT_GetHelloHandle; | ||
70 | |||
71 | |||
72 | /** | ||
73 | * Obtain updates on changes to the HELLO message for this peer. The callback | ||
74 | * given in this function is never called synchronously. | ||
75 | * | ||
76 | * @param cfg configuration to use | ||
77 | * @param nt which network type should the addresses from the HELLO belong to? | ||
78 | * @param rec function to call with the HELLO | ||
79 | * @param rec_cls closure for @a rec | ||
80 | * @return handle to cancel the operation | ||
81 | */ | ||
82 | struct GNUNET_TRANSPORT_GetHelloHandle * | ||
83 | GNUNET_TRANSPORT_hello_get (struct GNUNET_CONFIGURATION_Handle *cfg, | ||
84 | enum GNUNET_ATS_Network_Type nt, | ||
85 | GNUNET_TRANSPORT_HelloUpdateCallback rec, | ||
86 | void *rec_cls); | ||
87 | |||
88 | |||
89 | /** | ||
90 | * Stop receiving updates about changes to our HELLO message. | ||
91 | * | ||
92 | * @param ghh handle to cancel | ||
93 | */ | ||
94 | void | ||
95 | GNUNET_TRANSPORT_hello_get_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh); | ||
96 | |||
97 | |||
98 | /** | ||
99 | * Function with addresses found in a HELLO. | ||
100 | * | ||
101 | * @param cls closure | ||
102 | * @param peer identity of the peer | ||
103 | * @param address the address (UTF-8, 0-terminated) | ||
104 | * @param nt network type of the address | ||
105 | * @param expiration when does this address expire? | ||
106 | */ | ||
107 | typedef void | ||
108 | (*GNUNET_TRANSPORT_AddressCallback) (void *cls, | ||
109 | const struct GNUNET_PeerIdentity *peer, | ||
110 | const char *address, | ||
111 | enum GNUNET_ATS_Network_Type nt, | ||
112 | struct GNUNET_TIME_Absolute expiration); | ||
113 | |||
114 | |||
115 | /** | ||
116 | * Parse a HELLO message that we have received into its | ||
117 | * constituent addresses. | ||
118 | * | ||
119 | * @param hello message to parse | ||
120 | * @param cb function to call on each address found | ||
121 | * @param cb_cls closure for @a cb | ||
122 | * @return #GNUNET_OK if hello was well-formed, #GNUNET_SYSERR if not | ||
123 | */ | ||
124 | int | ||
125 | GNUNET_TRANSPORT_hello_parse (const struct GNUNET_MessageHeader *hello, | ||
126 | GNUNET_TRANSPORT_AddressCallback cb, | ||
127 | void *cb_cls); | ||
128 | |||
129 | |||
130 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
131 | { | ||
132 | #endif | ||
133 | #ifdef __cplusplus | ||
134 | } | ||
135 | #endif | ||
136 | |||
137 | /* ifndef GNUNET_TRANSPORT_HELLO_SERVICE_H */ | ||
138 | #endif | ||
139 | |||
140 | /** @} */ /* end of group */ | ||
141 | |||
142 | /* end of gnunet_transport_hello_service.h */ | ||
diff --git a/src/include/gnunet_transport_monitor_service.h b/src/include/gnunet_transport_monitor_service.h new file mode 100644 index 000000000..a12cc4ed7 --- /dev/null +++ b/src/include/gnunet_transport_monitor_service.h | |||
@@ -0,0 +1,192 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2009-2016 GNUnet e.V. | ||
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 | * @author Christian Grothoff | ||
23 | * | ||
24 | * @file | ||
25 | * Monitoring / diagnostics API for the transport service | ||
26 | * | ||
27 | * @defgroup transport TRANSPORT service | ||
28 | * Communication with other peers | ||
29 | * | ||
30 | * @see [Documentation](https://gnunet.org/transport-service) | ||
31 | * | ||
32 | * @{ | ||
33 | */ | ||
34 | |||
35 | #ifndef GNUNET_TRANSPORT_MONITOR_SERVICE_H | ||
36 | #define GNUNET_TRANSPORT_MONITOR_SERVICE_H | ||
37 | |||
38 | #ifdef __cplusplus | ||
39 | extern "C" | ||
40 | { | ||
41 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
42 | } | ||
43 | #endif | ||
44 | #endif | ||
45 | |||
46 | #include "gnunet_util_lib.h" | ||
47 | |||
48 | /** | ||
49 | * Version number of the transport API. | ||
50 | */ | ||
51 | #define GNUNET_TRANSPORT_MONITOR_VERSION 0x00000000 | ||
52 | |||
53 | |||
54 | /** | ||
55 | * Information about another peer's address. | ||
56 | */ | ||
57 | struct GNUNET_TRANSPORT_MonitorInformation | ||
58 | { | ||
59 | |||
60 | /** | ||
61 | * Address we have for the peer, human-readable, 0-terminated, in UTF-8. | ||
62 | */ | ||
63 | const char *address; | ||
64 | |||
65 | /** | ||
66 | * Network type of the address. | ||
67 | */ | ||
68 | enum GNUNET_ATS_Network_Type nt; | ||
69 | |||
70 | /** | ||
71 | * #GNUNET_YES if this is an inbound connection (communicator initiated) | ||
72 | * #GNUNET_NO if this is an outbound connection (transport initiated) | ||
73 | */ | ||
74 | int is_inbound; | ||
75 | |||
76 | /** | ||
77 | * Number of messages pending transmission for this @e address. | ||
78 | */ | ||
79 | uint32_t num_msg_pending; | ||
80 | |||
81 | /** | ||
82 | * Number of bytes pending transmission for this @e address. | ||
83 | */ | ||
84 | uint32_t num_bytes_pending; | ||
85 | |||
86 | /** | ||
87 | * When was this address last validated. | ||
88 | */ | ||
89 | struct GNUNET_TIME_Absolute last_validation; | ||
90 | |||
91 | /** | ||
92 | * When does this address expire. | ||
93 | */ | ||
94 | struct GNUNET_TIME_Absolute valid_until; | ||
95 | |||
96 | /** | ||
97 | * Time of the next validation operation. | ||
98 | */ | ||
99 | struct GNUNET_TIME_Absolute next_validation; | ||
100 | |||
101 | /** | ||
102 | * Current estimate of the RTT. | ||
103 | */ | ||
104 | struct GNUNET_TIME_Relative rtt; | ||
105 | |||
106 | }; | ||
107 | |||
108 | |||
109 | /** | ||
110 | * Function to call with information about a peer. | ||
111 | * | ||
112 | * If one_shot was set to #GNUNET_YES to iterate over all peers once, | ||
113 | * a final call with NULL for peer and address will follow when done. | ||
114 | * In this case state and timeout do not contain valid values. | ||
115 | * | ||
116 | * The #GNUNET_TRANSPORT_monitor_peers_cancel() call MUST not be called from | ||
117 | * within this function! | ||
118 | * | ||
119 | * | ||
120 | * @param cls closure | ||
121 | * @param peer peer this update is about, | ||
122 | * NULL if this is the final last callback for a iteration operation | ||
123 | * @param mi monitoring data on the peer | ||
124 | */ | ||
125 | typedef void | ||
126 | (*GNUNET_TRANSPORT_MontiorCallback) (void *cls, | ||
127 | const struct GNUNET_PeerIdentity *peer, | ||
128 | const struct GNUNET_TRANSPORT_MonitorInformation *mi); | ||
129 | |||
130 | |||
131 | /** | ||
132 | * Handle for a #GNUNET_TRANSPORT_monitor() operation. | ||
133 | */ | ||
134 | struct GNUNET_TRANSPORT_MonitorContext; | ||
135 | |||
136 | |||
137 | /** | ||
138 | * Return information about a specific peer or all peers currently known to | ||
139 | * transport service once or in monitoring mode. To obtain information about | ||
140 | * a specific peer, a peer identity can be passed. To obtain information about | ||
141 | * all peers currently known to transport service, NULL can be passed as peer | ||
142 | * identity. | ||
143 | * | ||
144 | * For each peer, the callback is called with information about the address used | ||
145 | * to communicate with this peer, the state this peer is currently in and the | ||
146 | * the current timeout for this state. | ||
147 | * | ||
148 | * Upon completion, the #GNUNET_TRANSPORT_PeerIterateCallback is called one | ||
149 | * more time with `NULL`. After this, the operation must no longer be | ||
150 | * explicitly canceled. | ||
151 | * | ||
152 | * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in the | ||
153 | * the peer_callback! | ||
154 | * | ||
155 | * @param cfg configuration to use | ||
156 | * @param peer a specific peer identity to obtain information for, | ||
157 | * NULL for all peers | ||
158 | * @param one_shot #GNUNET_YES to return the current state and then end (with NULL+NULL), | ||
159 | * #GNUNET_NO to monitor peers continuously | ||
160 | * @param mc function to call with the results | ||
161 | * @param mc_cls closure for @a mc | ||
162 | */ | ||
163 | struct GNUNET_TRANSPORT_MonitorContext * | ||
164 | GNUNET_TRANSPORT_monitor (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
165 | const struct GNUNET_PeerIdentity *peer, | ||
166 | int one_shot, | ||
167 | GNUNET_TRANSPORT_MonitorCallback mc, | ||
168 | void *mc_cls); | ||
169 | |||
170 | |||
171 | /** | ||
172 | * Cancel request to monitor peers | ||
173 | * | ||
174 | * @param pmc handle for the request to cancel | ||
175 | */ | ||
176 | void | ||
177 | GNUNET_TRANSPORT_monitor_cancel (struct GNUNET_TRANSPORT_MonitorContext *pmc); | ||
178 | |||
179 | |||
180 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
181 | { | ||
182 | #endif | ||
183 | #ifdef __cplusplus | ||
184 | } | ||
185 | #endif | ||
186 | |||
187 | /* ifndef GNUNET_TRANSPORT_MONITOR_SERVICE_H */ | ||
188 | #endif | ||
189 | |||
190 | /** @} */ /* end of group */ | ||
191 | |||
192 | /* end of gnunet_transport_monitor_service.h */ | ||