diff options
Diffstat (limited to 'src/transport/transport.h')
-rw-r--r-- | src/transport/transport.h | 238 |
1 files changed, 238 insertions, 0 deletions
diff --git a/src/transport/transport.h b/src/transport/transport.h new file mode 100644 index 000000000..8e1291005 --- /dev/null +++ b/src/transport/transport.h | |||
@@ -0,0 +1,238 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2009 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 2, 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 | /** | ||
22 | * @file transport/transport.h | ||
23 | * @brief common internal definitions for transport service | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "gnunet_crypto_lib.h" | ||
27 | #include "gnunet_time_lib.h" | ||
28 | #include "gnunet_transport_service.h" | ||
29 | |||
30 | #define DEBUG_TRANSPORT GNUNET_NO | ||
31 | |||
32 | /** | ||
33 | * For how long do we allow unused bandwidth | ||
34 | * from the past to carry over into the future? (in ms) | ||
35 | */ | ||
36 | #define MAX_BANDWIDTH_CARRY 5000 | ||
37 | |||
38 | /** | ||
39 | * How often do we (at most) do a full quota | ||
40 | * recalculation? (in ms) | ||
41 | */ | ||
42 | #define MIN_QUOTA_REFRESH_TIME 2000 | ||
43 | |||
44 | /** | ||
45 | * Message from the transport service to the library | ||
46 | * informing about neighbors. | ||
47 | */ | ||
48 | struct ConnectInfoMessage | ||
49 | { | ||
50 | |||
51 | /** | ||
52 | * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT | ||
53 | */ | ||
54 | struct GNUNET_MessageHeader header; | ||
55 | |||
56 | /** | ||
57 | * Current quota for outbound traffic in bytes/ms. | ||
58 | * (should be equal to system default) | ||
59 | */ | ||
60 | uint32_t quota_out GNUNET_PACKED; | ||
61 | |||
62 | /** | ||
63 | * Latency estimate. | ||
64 | */ | ||
65 | struct GNUNET_TIME_RelativeNBO latency; | ||
66 | |||
67 | /** | ||
68 | * Identity of the new neighbour. | ||
69 | */ | ||
70 | struct GNUNET_PeerIdentity id; | ||
71 | |||
72 | }; | ||
73 | |||
74 | |||
75 | /** | ||
76 | * Message from the transport service to the library | ||
77 | * informing about disconnects. | ||
78 | */ | ||
79 | struct DisconnectInfoMessage | ||
80 | { | ||
81 | |||
82 | /** | ||
83 | * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT | ||
84 | */ | ||
85 | struct GNUNET_MessageHeader header; | ||
86 | |||
87 | /** | ||
88 | * Reserved, always zero. | ||
89 | */ | ||
90 | uint32_t reserved GNUNET_PACKED; | ||
91 | |||
92 | /** | ||
93 | * Who got disconnected? | ||
94 | */ | ||
95 | struct GNUNET_PeerIdentity peer; | ||
96 | |||
97 | }; | ||
98 | |||
99 | |||
100 | /** | ||
101 | * Message used to set a particular bandwidth quota. Send | ||
102 | * TO the service to set an incoming quota, send FROM the | ||
103 | * service to update an outgoing quota. | ||
104 | */ | ||
105 | struct QuotaSetMessage | ||
106 | { | ||
107 | |||
108 | /** | ||
109 | * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_NEIGHBOUR_INFO | ||
110 | */ | ||
111 | struct GNUNET_MessageHeader header; | ||
112 | |||
113 | /** | ||
114 | * Quota in bytes per ms, 0 to drop everything; | ||
115 | * in network byte order. | ||
116 | */ | ||
117 | uint32_t quota_in GNUNET_PACKED; | ||
118 | |||
119 | /** | ||
120 | * About which peer are we talking here? | ||
121 | */ | ||
122 | struct GNUNET_PeerIdentity peer; | ||
123 | |||
124 | }; | ||
125 | |||
126 | |||
127 | /** | ||
128 | * Message used to ask the transport service to connect | ||
129 | * to a particular peer. | ||
130 | */ | ||
131 | struct TryConnectMessage | ||
132 | { | ||
133 | |||
134 | /** | ||
135 | * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_TRY_CONNECT. | ||
136 | */ | ||
137 | struct GNUNET_MessageHeader header; | ||
138 | |||
139 | /** | ||
140 | * Always zero. | ||
141 | */ | ||
142 | uint32_t reserved GNUNET_PACKED; | ||
143 | |||
144 | /** | ||
145 | * About which peer are we talking here? | ||
146 | */ | ||
147 | struct GNUNET_PeerIdentity peer; | ||
148 | |||
149 | }; | ||
150 | |||
151 | /** | ||
152 | * Message used to notify the transport API about a message | ||
153 | * received from the network. The actual message follows. | ||
154 | */ | ||
155 | struct InboundMessage | ||
156 | { | ||
157 | |||
158 | /** | ||
159 | * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_RECV | ||
160 | */ | ||
161 | struct GNUNET_MessageHeader header; | ||
162 | |||
163 | /** | ||
164 | * Always zero. | ||
165 | */ | ||
166 | uint32_t reserved GNUNET_PACKED; | ||
167 | |||
168 | /** | ||
169 | * Latency estimate. | ||
170 | */ | ||
171 | struct GNUNET_TIME_RelativeNBO latency; | ||
172 | |||
173 | /** | ||
174 | * Which peer sent the message? | ||
175 | */ | ||
176 | struct GNUNET_PeerIdentity peer; | ||
177 | |||
178 | }; | ||
179 | |||
180 | |||
181 | /** | ||
182 | * Message used to notify the transport API that it can | ||
183 | * send another message to the transport service. | ||
184 | */ | ||
185 | struct SendOkMessage | ||
186 | { | ||
187 | |||
188 | /** | ||
189 | * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK | ||
190 | */ | ||
191 | struct GNUNET_MessageHeader header; | ||
192 | |||
193 | /** | ||
194 | * GNUNET_OK if the transmission succeeded, | ||
195 | * GNUNET_SYSERR if it failed (i.e. network disconnect); | ||
196 | * in either case, it is now OK for this client to | ||
197 | * send us another message for the given peer. | ||
198 | */ | ||
199 | uint32_t success GNUNET_PACKED; | ||
200 | |||
201 | /** | ||
202 | * Which peer can send more now? | ||
203 | */ | ||
204 | struct GNUNET_PeerIdentity peer; | ||
205 | |||
206 | }; | ||
207 | |||
208 | |||
209 | /** | ||
210 | * Message used to notify the transport service about a message | ||
211 | * to be transmitted to another peer. The actual message follows. | ||
212 | */ | ||
213 | struct OutboundMessage | ||
214 | { | ||
215 | |||
216 | /** | ||
217 | * Type will be GNUNET_MESSAGE_TYPE_TRANSPORT_SEND | ||
218 | */ | ||
219 | struct GNUNET_MessageHeader header; | ||
220 | |||
221 | /** | ||
222 | * Always zero. | ||
223 | */ | ||
224 | uint32_t reserved GNUNET_PACKED; | ||
225 | |||
226 | /** | ||
227 | * Which peer should receive the message? | ||
228 | */ | ||
229 | struct GNUNET_PeerIdentity peer; | ||
230 | |||
231 | }; | ||
232 | |||
233 | |||
234 | |||
235 | |||
236 | |||
237 | |||
238 | /* end of transport.h */ | ||