diff options
Diffstat (limited to 'src/transport/plugin_transport_template.c')
-rw-r--r-- | src/transport/plugin_transport_template.c | 83 |
1 files changed, 51 insertions, 32 deletions
diff --git a/src/transport/plugin_transport_template.c b/src/transport/plugin_transport_template.c index dedc8e857..feb0802d9 100644 --- a/src/transport/plugin_transport_template.c +++ b/src/transport/plugin_transport_template.c | |||
@@ -152,7 +152,7 @@ struct Plugin | |||
152 | * @param cls closure | 152 | * @param cls closure |
153 | * @param session which session must be used | 153 | * @param session which session must be used |
154 | * @param msgbuf the message to transmit | 154 | * @param msgbuf the message to transmit |
155 | * @param msgbuf_size number of bytes in 'msgbuf' | 155 | * @param msgbuf_size number of bytes in @a msgbuf |
156 | * @param priority how important is the message (most plugins will | 156 | * @param priority how important is the message (most plugins will |
157 | * ignore message priority and just FIFO) | 157 | * ignore message priority and just FIFO) |
158 | * @param to how long to wait at most for the transmission (does not | 158 | * @param to how long to wait at most for the transmission (does not |
@@ -163,7 +163,7 @@ struct Plugin | |||
163 | * been transmitted (or if the transport is ready | 163 | * been transmitted (or if the transport is ready |
164 | * for the next transmission call; or if the | 164 | * for the next transmission call; or if the |
165 | * peer disconnected...); can be NULL | 165 | * peer disconnected...); can be NULL |
166 | * @param cont_cls closure for cont | 166 | * @param cont_cls closure for @a cont |
167 | * @return number of bytes used (on the physical network, with overheads); | 167 | * @return number of bytes used (on the physical network, with overheads); |
168 | * -1 on hard errors (i.e. address invalid); 0 is a legal value | 168 | * -1 on hard errors (i.e. address invalid); 0 is a legal value |
169 | * and does NOT mean that the message was not transmitted (DV) | 169 | * and does NOT mean that the message was not transmitted (DV) |
@@ -187,7 +187,6 @@ template_plugin_send (void *cls, | |||
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
190 | |||
191 | /** | 190 | /** |
192 | * Function that can be used to force the plugin to disconnect | 191 | * Function that can be used to force the plugin to disconnect |
193 | * from the given peer and cancel all previous transmissions | 192 | * from the given peer and cancel all previous transmissions |
@@ -197,10 +196,30 @@ template_plugin_send (void *cls, | |||
197 | * @param target peer from which to disconnect | 196 | * @param target peer from which to disconnect |
198 | */ | 197 | */ |
199 | static void | 198 | static void |
200 | template_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) | 199 | template_plugin_disconnect_peer (void *cls, |
200 | const struct GNUNET_PeerIdentity *target) | ||
201 | { | ||
202 | // struct Plugin *plugin = cls; | ||
203 | // FIXME | ||
204 | } | ||
205 | |||
206 | |||
207 | /** | ||
208 | * Function that can be used to force the plugin to disconnect | ||
209 | * from the given peer and cancel all previous transmissions | ||
210 | * (and their continuationc). | ||
211 | * | ||
212 | * @param cls closure | ||
213 | * @param session session from which to disconnect | ||
214 | * @return #GNUNET_OK on success | ||
215 | */ | ||
216 | static int | ||
217 | template_plugin_disconnect_session (void *cls, | ||
218 | struct Session *session) | ||
201 | { | 219 | { |
202 | // struct Plugin *plugin = cls; | 220 | // struct Plugin *plugin = cls; |
203 | // FIXME | 221 | // FIXME |
222 | return GNUNET_SYSERR; | ||
204 | } | 223 | } |
205 | 224 | ||
206 | 225 | ||
@@ -242,11 +261,10 @@ template_plugin_address_pretty_printer (void *cls, const char *type, | |||
242 | GNUNET_TRANSPORT_AddressStringCallback | 261 | GNUNET_TRANSPORT_AddressStringCallback |
243 | asc, void *asc_cls) | 262 | asc, void *asc_cls) |
244 | { | 263 | { |
245 | if (0 == addrlen) | 264 | if (0 == addrlen) |
246 | { | 265 | { |
247 | asc (asc_cls, TRANSPORT_SESSION_INBOUND_STRING); | 266 | asc (asc_cls, TRANSPORT_SESSION_INBOUND_STRING); |
248 | } | 267 | } |
249 | |||
250 | asc (asc_cls, NULL); | 268 | asc (asc_cls, NULL); |
251 | } | 269 | } |
252 | 270 | ||
@@ -261,7 +279,7 @@ template_plugin_address_pretty_printer (void *cls, const char *type, | |||
261 | * @param cls closure | 279 | * @param cls closure |
262 | * @param addr pointer to the address | 280 | * @param addr pointer to the address |
263 | * @param addrlen length of addr | 281 | * @param addrlen length of addr |
264 | * @return GNUNET_OK if this is a plausible address for this peer | 282 | * @return #GNUNET_OK if this is a plausible address for this peer |
265 | * and transport | 283 | * and transport |
266 | */ | 284 | */ |
267 | static int | 285 | static int |
@@ -288,14 +306,14 @@ template_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | |||
288 | static const char * | 306 | static const char * |
289 | template_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | 307 | template_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) |
290 | { | 308 | { |
291 | /* | 309 | /* |
292 | * Print address in format template.options.address | 310 | * Print address in format template.options.address |
293 | */ | 311 | */ |
294 | 312 | ||
295 | if (0 == addrlen) | 313 | if (0 == addrlen) |
296 | { | 314 | { |
297 | return TRANSPORT_SESSION_INBOUND_STRING; | 315 | return TRANSPORT_SESSION_INBOUND_STRING; |
298 | } | 316 | } |
299 | 317 | ||
300 | GNUNET_break (0); | 318 | GNUNET_break (0); |
301 | return NULL; | 319 | return NULL; |
@@ -308,22 +326,21 @@ template_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
308 | * | 326 | * |
309 | * @param cls closure ('struct Plugin*') | 327 | * @param cls closure ('struct Plugin*') |
310 | * @param addr string address | 328 | * @param addr string address |
311 | * @param addrlen length of the address | 329 | * @param addrlen length of the @a addr |
312 | * @param buf location to store the buffer | 330 | * @param buf location to store the buffer |
313 | * @param added location to store the number of bytes in the buffer. | 331 | * @param added location to store the number of bytes in the buffer. |
314 | * If the function returns GNUNET_SYSERR, its contents are undefined. | 332 | * If the function returns #GNUNET_SYSERR, its contents are undefined. |
315 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 333 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
316 | */ | 334 | */ |
317 | static int | 335 | static int |
318 | template_plugin_string_to_address (void *cls, const char *addr, uint16_t addrlen, | 336 | template_plugin_string_to_address (void *cls, |
319 | void **buf, size_t *added) | 337 | const char *addr, |
338 | uint16_t addrlen, | ||
339 | void **buf, size_t *added) | ||
320 | { | 340 | { |
321 | 341 | /* | |
322 | /* | 342 | * Parse string in format template.options.address |
323 | * Parse string in format template.options.address | 343 | */ |
324 | */ | ||
325 | |||
326 | |||
327 | GNUNET_break (0); | 344 | GNUNET_break (0); |
328 | return GNUNET_SYSERR; | 345 | return GNUNET_SYSERR; |
329 | } | 346 | } |
@@ -346,6 +363,7 @@ template_plugin_get_session (void *cls, | |||
346 | return NULL; | 363 | return NULL; |
347 | } | 364 | } |
348 | 365 | ||
366 | |||
349 | /** | 367 | /** |
350 | * Entry point for the plugin. | 368 | * Entry point for the plugin. |
351 | */ | 369 | */ |
@@ -360,7 +378,7 @@ libgnunet_plugin_transport_template_init (void *cls) | |||
360 | { | 378 | { |
361 | /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully | 379 | /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully |
362 | initialze the plugin or the API */ | 380 | initialze the plugin or the API */ |
363 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | 381 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); |
364 | api->cls = NULL; | 382 | api->cls = NULL; |
365 | api->address_to_string = &template_plugin_address_to_string; | 383 | api->address_to_string = &template_plugin_address_to_string; |
366 | api->string_to_address = &template_plugin_string_to_address; | 384 | api->string_to_address = &template_plugin_string_to_address; |
@@ -368,12 +386,13 @@ libgnunet_plugin_transport_template_init (void *cls) | |||
368 | return api; | 386 | return api; |
369 | } | 387 | } |
370 | 388 | ||
371 | plugin = GNUNET_malloc (sizeof (struct Plugin)); | 389 | plugin = GNUNET_new (struct Plugin); |
372 | plugin->env = env; | 390 | plugin->env = env; |
373 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | 391 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); |
374 | api->cls = plugin; | 392 | api->cls = plugin; |
375 | api->send = &template_plugin_send; | 393 | api->send = &template_plugin_send; |
376 | api->disconnect = &template_plugin_disconnect; | 394 | api->disconnect_peer = &template_plugin_disconnect_peer; |
395 | api->disconnect_session = &template_plugin_disconnect_session; | ||
377 | api->address_pretty_printer = &template_plugin_address_pretty_printer; | 396 | api->address_pretty_printer = &template_plugin_address_pretty_printer; |
378 | api->check_address = &template_plugin_address_suggested; | 397 | api->check_address = &template_plugin_address_suggested; |
379 | api->address_to_string = &template_plugin_address_to_string; | 398 | api->address_to_string = &template_plugin_address_to_string; |