diff options
Diffstat (limited to 'src/dv/dv.h')
-rw-r--r-- | src/dv/dv.h | 215 |
1 files changed, 50 insertions, 165 deletions
diff --git a/src/dv/dv.h b/src/dv/dv.h index 948845bf7..cfa09409e 100644 --- a/src/dv/dv.h +++ b/src/dv/dv.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2001, 2002, 2003, 2004, 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -20,125 +20,98 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @author Christian Grothoff | 22 | * @author Christian Grothoff |
23 | * @author NOT Nathan Evans | ||
24 | * @file dv/dv.h | 23 | * @file dv/dv.h |
24 | * @brief IPC messages between DV service and DV plugin | ||
25 | */ | 25 | */ |
26 | #ifndef DV_H | 26 | #ifndef DV_H |
27 | #define DV_H | 27 | #define DV_H |
28 | 28 | ||
29 | #include "gnunet_common.h" | 29 | #include "gnunet_common.h" |
30 | 30 | ||
31 | #define DEBUG_DV_GOSSIP GNUNET_EXTRA_LOGGING | ||
32 | #define DEBUG_DV_GOSSIP_SEND GNUNET_EXTRA_LOGGING | ||
33 | #define DEBUG_DV_GOSSIP_RECEIPT GNUNET_EXTRA_LOGGING | ||
34 | #define DEBUG_DV_MESSAGES GNUNET_EXTRA_LOGGING | ||
35 | #define DEBUG_DV GNUNET_EXTRA_LOGGING | ||
36 | #define DEBUG_DV_PEER_NUMBERS GNUNET_EXTRA_LOGGING | ||
37 | #define DEBUG_MESSAGE_DROP GNUNET_EXTRA_LOGGING | ||
38 | |||
39 | typedef void (*GNUNET_DV_MessageReceivedHandler) (void *cls, | ||
40 | struct GNUNET_PeerIdentity * | ||
41 | sender, char *msg, | ||
42 | size_t msg_len, | ||
43 | uint32_t distance, | ||
44 | char *sender_address, | ||
45 | size_t sender_address_len); | ||
46 | |||
47 | GNUNET_NETWORK_STRUCT_BEGIN | 31 | GNUNET_NETWORK_STRUCT_BEGIN |
48 | 32 | ||
49 | /** | 33 | /** |
50 | * DV Message, contains a message that was received | 34 | * DV service tells plugin about a DV-connection being |
51 | * via DV for this peer! Internal. | 35 | * now available. |
52 | * | ||
53 | * Sender address is copied to the end of this struct, | ||
54 | * followed by the actual message received. | ||
55 | */ | 36 | */ |
56 | struct GNUNET_DV_MessageReceived | 37 | struct GNUNET_DV_ConnectMessage |
57 | { | 38 | { |
58 | /** | 39 | /** |
59 | * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_MESSAGE | 40 | * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_CONNECT |
60 | */ | 41 | */ |
61 | struct GNUNET_MessageHeader header; | 42 | struct GNUNET_MessageHeader header; |
62 | 43 | ||
63 | /** | 44 | /** |
64 | * The sender of the message | 45 | * The distance to the peer that we are now connected to |
65 | */ | 46 | */ |
66 | struct GNUNET_PeerIdentity sender; | 47 | uint32_t distance GNUNET_PACKED; |
67 | 48 | ||
68 | /** | 49 | /** |
69 | * The length of the message that was sent (appended to this end of struct) | 50 | * The other peer (at the given distance). |
70 | */ | ||
71 | uint32_t msg_len; | ||
72 | |||
73 | /** | ||
74 | * The distance to the peer that we received the message from | ||
75 | */ | 51 | */ |
76 | uint32_t distance; | 52 | struct GNUNET_PeerIdentity peer; |
77 | 53 | ||
78 | }; | 54 | }; |
79 | 55 | ||
80 | 56 | ||
81 | /** | 57 | /** |
82 | * DV Message, indicates that we have learned of a new DV level peer. | 58 | * DV service tells plugin about a DV-connection being |
83 | * Internal. | 59 | * no longer available. |
84 | * | 60 | * |
85 | * Sender address is copied to the end of this struct. | 61 | * Sender address is copied to the end of this struct, |
62 | * followed by the actual message received. | ||
86 | */ | 63 | */ |
87 | struct GNUNET_DV_ConnectMessage | 64 | struct GNUNET_DV_DisconnectMessage |
88 | { | 65 | { |
89 | /** | 66 | /** |
90 | * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_MESSAGE | 67 | * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_DISCONNECT |
91 | */ | 68 | */ |
92 | struct GNUNET_MessageHeader header; | 69 | struct GNUNET_MessageHeader header; |
93 | 70 | ||
94 | /** | 71 | /** |
95 | * The sender of the message | 72 | * The distance to the peer that we used to have |
96 | */ | ||
97 | struct GNUNET_PeerIdentity *sender; | ||
98 | |||
99 | /** | ||
100 | * The message that was sent | ||
101 | */ | ||
102 | struct GNUNET_MessageHeader *msg; | ||
103 | |||
104 | /** | ||
105 | * The distance to the peer that we received the message from | ||
106 | */ | 73 | */ |
107 | uint32_t distance; | 74 | uint32_t distance GNUNET_PACKED; |
108 | 75 | ||
109 | /** | 76 | /** |
110 | * Length of the sender address, appended to end of this message | 77 | * The peer that is no longer available. |
111 | */ | 78 | */ |
112 | uint32_t sender_address_len; | 79 | struct GNUNET_PeerIdentity peer; |
113 | 80 | ||
114 | }; | 81 | }; |
115 | 82 | ||
83 | |||
116 | /** | 84 | /** |
117 | * Message to return result from a send attempt. | 85 | * DV Message, contains a message that was received via DV for this |
118 | * Internal. | 86 | * peer. Send from the DV service to the DV plugin. |
87 | * | ||
88 | * Sender address is copied to the end of this struct, | ||
89 | * followed by the actual message received. | ||
119 | */ | 90 | */ |
120 | struct GNUNET_DV_SendResultMessage | 91 | struct GNUNET_DV_ReceivedMessage |
121 | { | 92 | { |
122 | /** | 93 | /** |
123 | * Type: GNUNET_MESSAGE_TYPE_DV_SEND_RESULT | 94 | * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_RECV |
124 | */ | 95 | */ |
125 | struct GNUNET_MessageHeader header; | 96 | struct GNUNET_MessageHeader header; |
126 | 97 | ||
127 | /** | 98 | /** |
128 | * Unique ID for attempted sent message. | 99 | * The distance to the peer that we received the message from |
129 | */ | 100 | */ |
130 | uint32_t uid; | 101 | uint32_t distance GNUNET_PACKED; |
131 | 102 | ||
132 | /** | 103 | /** |
133 | * Result of attempted send, 0 for send okay, | 104 | * The (actual) sender of the message |
134 | * 1 for failure of any reason. | ||
135 | */ | 105 | */ |
136 | uint32_t result; | 106 | struct GNUNET_PeerIdentity sender; |
107 | |||
108 | /* payload follows */ | ||
137 | }; | 109 | }; |
138 | 110 | ||
111 | |||
139 | /** | 112 | /** |
140 | * Message to send a message over DV via a specific peer. | 113 | * Message from plugin to DV service, requesting a |
141 | * Internal. | 114 | * message to be routed. |
142 | */ | 115 | */ |
143 | struct GNUNET_DV_SendMessage | 116 | struct GNUNET_DV_SendMessage |
144 | { | 117 | { |
@@ -148,128 +121,40 @@ struct GNUNET_DV_SendMessage | |||
148 | struct GNUNET_MessageHeader header; | 121 | struct GNUNET_MessageHeader header; |
149 | 122 | ||
150 | /** | 123 | /** |
151 | * Intended final recipient of this message | ||
152 | */ | ||
153 | struct GNUNET_PeerIdentity target; | ||
154 | |||
155 | /** | ||
156 | * Message priority | ||
157 | */ | ||
158 | uint32_t priority; | ||
159 | |||
160 | /** | ||
161 | * Unique ID for this message, for confirm callback. | 124 | * Unique ID for this message, for confirm callback. |
162 | */ | 125 | */ |
163 | uint32_t uid; | 126 | uint32_t uid GNUNET_PACKED; |
164 | |||
165 | /** | ||
166 | * How long can we delay sending? | ||
167 | */ | ||
168 | struct GNUNET_TIME_Relative timeout; | ||
169 | |||
170 | /** | ||
171 | * Size of the address (appended to end of struct) | ||
172 | */ | ||
173 | uint32_t addrlen; | ||
174 | 127 | ||
175 | /** | 128 | /** |
176 | * The message(s) to be sent. | 129 | * The (actual) target of the message |
177 | */ | ||
178 | char *msgbuf; | ||
179 | |||
180 | /* | ||
181 | * Sender, appended to end of struct tells via whom | ||
182 | * to send this message. | ||
183 | */ | 130 | */ |
131 | struct GNUNET_PeerIdentity target; | ||
184 | 132 | ||
185 | }; | 133 | }; |
186 | 134 | ||
187 | /** | ||
188 | * Message that gets sent between nodes updating dv infos | ||
189 | */ | ||
190 | typedef struct | ||
191 | { | ||
192 | /* Message Header */ | ||
193 | struct GNUNET_MessageHeader header; | ||
194 | |||
195 | /** | ||
196 | * Cost from received from node to neighbor node, takes distance into account | ||
197 | */ | ||
198 | uint32_t cost GNUNET_PACKED; | ||
199 | |||
200 | /** | ||
201 | * Identity of neighbor we learned information about | ||
202 | */ | ||
203 | struct GNUNET_PeerIdentity neighbor; | ||
204 | |||
205 | /** | ||
206 | * PublicKey of neighbor. | ||
207 | */ | ||
208 | struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; | ||
209 | |||
210 | /** | ||
211 | * Neighbor ID to use when sending to this peer | ||
212 | */ | ||
213 | uint32_t neighbor_id GNUNET_PACKED; | ||
214 | |||
215 | } p2p_dv_MESSAGE_NeighborInfo; | ||
216 | 135 | ||
217 | /** | 136 | /** |
218 | * Message that gets sent between nodes carrying information | 137 | * Message from service to DV plugin, saying that a |
138 | * SEND request was handled. | ||
219 | */ | 139 | */ |
220 | typedef struct | 140 | struct GNUNET_DV_AckMessage |
221 | { | 141 | { |
142 | /** | ||
143 | * Type: GNUNET_MESSAGE_TYPE_DV_SEND_ACK | ||
144 | */ | ||
222 | struct GNUNET_MessageHeader header; | 145 | struct GNUNET_MessageHeader header; |
223 | 146 | ||
224 | /** | 147 | /** |
225 | * Unique ID for this message. Will be zero unless | 148 | * Which message is being acknowledged? |
226 | * message tracking is desired. | ||
227 | */ | 149 | */ |
228 | uint32_t uid GNUNET_PACKED; | 150 | uint32_t uid GNUNET_PACKED; |
229 | 151 | ||
230 | /** | 152 | /** |
231 | * Identity of peer that ultimately sent the message. | 153 | * The (actual) target of the message |
232 | * Should be looked up in the set of 'neighbor_id's of | ||
233 | * the referring peer. | ||
234 | */ | ||
235 | uint32_t sender GNUNET_PACKED; | ||
236 | |||
237 | /** | ||
238 | * Identity of neighbor this message is going to. Should | ||
239 | * be looked up in the set of our own identifiers for | ||
240 | * neighbors! | ||
241 | */ | ||
242 | uint32_t recipient GNUNET_PACKED; | ||
243 | |||
244 | } p2p_dv_MESSAGE_Data; | ||
245 | |||
246 | /** | ||
247 | * Message that gets sent between nodes indicating a peer | ||
248 | * was disconnected. | ||
249 | */ | ||
250 | typedef struct | ||
251 | { | ||
252 | struct GNUNET_MessageHeader header; | ||
253 | |||
254 | /** | ||
255 | * Identity of neighbor that was disconnected. | ||
256 | */ | 154 | */ |
257 | uint32_t peer_id GNUNET_PACKED; | 155 | struct GNUNET_PeerIdentity target; |
258 | 156 | ||
259 | } p2p_dv_MESSAGE_Disconnect; | 157 | }; |
260 | GNUNET_NETWORK_STRUCT_END | 158 | GNUNET_NETWORK_STRUCT_END |
261 | 159 | ||
262 | struct GNUNET_DV_Handle * | ||
263 | GNUNET_DV_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
264 | GNUNET_DV_MessageReceivedHandler receive_handler, | ||
265 | void *receive_handler_cls); | ||
266 | |||
267 | /** | ||
268 | * Disconnect from the DV service | ||
269 | * | ||
270 | * @param handle the current handle to the service to disconnect | ||
271 | */ | ||
272 | void | ||
273 | GNUNET_DV_disconnect (struct GNUNET_DV_Handle *handle); | ||
274 | |||
275 | #endif | 160 | #endif |