diff options
-rw-r--r-- | src/transport/plugin_transport_template.c | 156 | ||||
-rw-r--r-- | src/transport/plugin_transport_unix.c | 109 |
2 files changed, 186 insertions, 79 deletions
diff --git a/src/transport/plugin_transport_template.c b/src/transport/plugin_transport_template.c index a7abca210..b943171b1 100644 --- a/src/transport/plugin_transport_template.c +++ b/src/transport/plugin_transport_template.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2002-2014 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 |
@@ -60,7 +60,7 @@ struct Session | |||
60 | struct GNUNET_PeerIdentity sender; | 60 | struct GNUNET_PeerIdentity sender; |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Stored in a linked list. | 63 | * Stored in a linked list (or a peer map, or ...) |
64 | */ | 64 | */ |
65 | struct Session *next; | 65 | struct Session *next; |
66 | 66 | ||
@@ -82,17 +82,17 @@ struct Session | |||
82 | GNUNET_TRANSPORT_TransmitContinuation transmit_cont; | 82 | GNUNET_TRANSPORT_TransmitContinuation transmit_cont; |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Closure for transmit_cont. | 85 | * Closure for @e transmit_cont. |
86 | */ | 86 | */ |
87 | void *transmit_cont_cls; | 87 | void *transmit_cont_cls; |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * At what time did we reset last_received last? | 90 | * At what time did we reset @e last_received last? |
91 | */ | 91 | */ |
92 | struct GNUNET_TIME_Absolute last_quota_update; | 92 | struct GNUNET_TIME_Absolute last_quota_update; |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * How many bytes have we received since the "last_quota_update" | 95 | * How many bytes have we received since the @e last_quota_update |
96 | * timestamp? | 96 | * timestamp? |
97 | */ | 97 | */ |
98 | uint64_t last_received; | 98 | uint64_t last_received; |
@@ -109,12 +109,12 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
109 | 109 | ||
110 | struct TemplateAddress | 110 | struct TemplateAddress |
111 | { | 111 | { |
112 | /** | 112 | /** |
113 | * Address options in NBO | 113 | * Address options in NBO |
114 | */ | 114 | */ |
115 | uint32_t options GNUNET_PACKED; | 115 | uint32_t options GNUNET_PACKED; |
116 | 116 | ||
117 | /* Add address here */ | 117 | /* Add address here */ |
118 | }; | 118 | }; |
119 | 119 | ||
120 | GNUNET_NETWORK_STRUCT_END | 120 | GNUNET_NETWORK_STRUCT_END |
@@ -130,17 +130,60 @@ struct Plugin | |||
130 | struct GNUNET_TRANSPORT_PluginEnvironment *env; | 130 | struct GNUNET_TRANSPORT_PluginEnvironment *env; |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * List of open sessions. | 133 | * List of open sessions (or peer map, or...) |
134 | */ | 134 | */ |
135 | struct Session *sessions; | 135 | struct Session *sessions; |
136 | 136 | ||
137 | /** | 137 | /** |
138 | * Function to call about session status changes. | ||
139 | */ | ||
140 | GNUNET_TRANSPORT_SessionInfoCallback sic; | ||
141 | |||
142 | /** | ||
143 | * Closure for @e sic. | ||
144 | */ | ||
145 | void *sic_cls; | ||
146 | |||
147 | /** | ||
138 | * Options in HBO to be used with addresses | 148 | * Options in HBO to be used with addresses |
139 | */ | 149 | */ |
140 | 150 | ||
141 | }; | 151 | }; |
142 | 152 | ||
143 | 153 | ||
154 | #if 0 | ||
155 | /** | ||
156 | * If a session monitor is attached, notify it about the new | ||
157 | * session state. | ||
158 | * | ||
159 | * @param plugin our plugin | ||
160 | * @param session session that changed state | ||
161 | * @param state new state of the session | ||
162 | */ | ||
163 | static void | ||
164 | notify_session_monitor (struct Plugin *plugin, | ||
165 | struct Session *session, | ||
166 | enum GNUNET_TRANSPORT_SessionState state) | ||
167 | { | ||
168 | struct GNUNET_TRANSPORT_SessionInfo info; | ||
169 | |||
170 | if (NULL == plugin->sic) | ||
171 | return; | ||
172 | memset (&info, 0, sizeof (info)); | ||
173 | info.state = state; | ||
174 | info.is_inbound = GNUNET_SYSERR; /* FIXME */ | ||
175 | // info.num_msg_pending = | ||
176 | // info.num_bytes_pending = | ||
177 | // info.receive_delay = | ||
178 | // info.session_timeout = session->timeout; | ||
179 | // info.address = session->address; | ||
180 | plugin->sic (plugin->sic_cls, | ||
181 | session, | ||
182 | &info); | ||
183 | } | ||
184 | #endif | ||
185 | |||
186 | |||
144 | /** | 187 | /** |
145 | * Function that can be used by the transport service to transmit | 188 | * Function that can be used by the transport service to transmit |
146 | * a message using the plugin. Note that in the case of a | 189 | * a message using the plugin. Note that in the case of a |
@@ -170,19 +213,17 @@ struct Plugin | |||
170 | */ | 213 | */ |
171 | static ssize_t | 214 | static ssize_t |
172 | template_plugin_send (void *cls, | 215 | template_plugin_send (void *cls, |
173 | struct Session *session, | 216 | struct Session *session, |
174 | const char *msgbuf, size_t msgbuf_size, | 217 | const char *msgbuf, |
175 | unsigned int priority, | 218 | size_t msgbuf_size, |
176 | struct GNUNET_TIME_Relative to, | 219 | unsigned int priority, |
177 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | 220 | struct GNUNET_TIME_Relative to, |
221 | GNUNET_TRANSPORT_TransmitContinuation cont, | ||
222 | void *cont_cls) | ||
178 | { | 223 | { |
179 | struct Plugin *plugin = cls; | ||
180 | int bytes_sent = 0; | ||
181 | |||
182 | GNUNET_assert (plugin != NULL); | ||
183 | GNUNET_assert (session != NULL); | ||
184 | |||
185 | /* struct Plugin *plugin = cls; */ | 224 | /* struct Plugin *plugin = cls; */ |
225 | ssize_t bytes_sent = 0; | ||
226 | |||
186 | return bytes_sent; | 227 | return bytes_sent; |
187 | } | 228 | } |
188 | 229 | ||
@@ -243,7 +284,7 @@ template_plugin_query_keepalive_factor (void *cls) | |||
243 | * | 284 | * |
244 | * @param cls closure ('struct Plugin*') | 285 | * @param cls closure ('struct Plugin*') |
245 | * @param session the session | 286 | * @param session the session |
246 | * @return the network type in HBO or GNUNET_SYSERR | 287 | * @return the network type in HBO or #GNUNET_SYSERR |
247 | */ | 288 | */ |
248 | static enum GNUNET_ATS_Network_Type | 289 | static enum GNUNET_ATS_Network_Type |
249 | template_plugin_get_network (void *cls, | 290 | template_plugin_get_network (void *cls, |
@@ -266,7 +307,7 @@ template_plugin_get_network (void *cls, | |||
266 | * @param numeric should (IP) addresses be displayed in numeric form? | 307 | * @param numeric should (IP) addresses be displayed in numeric form? |
267 | * @param timeout after how long should we give up? | 308 | * @param timeout after how long should we give up? |
268 | * @param asc function to call on each string | 309 | * @param asc function to call on each string |
269 | * @param asc_cls closure for asc | 310 | * @param asc_cls closure for @a asc |
270 | */ | 311 | */ |
271 | static void | 312 | static void |
272 | template_plugin_address_pretty_printer (void *cls, const char *type, | 313 | template_plugin_address_pretty_printer (void *cls, const char *type, |
@@ -375,14 +416,76 @@ template_plugin_get_session (void *cls, | |||
375 | return NULL; | 416 | return NULL; |
376 | } | 417 | } |
377 | 418 | ||
419 | |||
378 | static void | 420 | static void |
379 | template_plugin_update_session_timeout (void *cls, | 421 | template_plugin_update_session_timeout (void *cls, |
380 | const struct GNUNET_PeerIdentity *peer, | 422 | const struct GNUNET_PeerIdentity *peer, |
381 | struct Session *session) | 423 | struct Session *session) |
382 | { | 424 | { |
383 | 425 | ||
384 | } | 426 | } |
385 | 427 | ||
428 | |||
429 | #if 0 | ||
430 | /** | ||
431 | * Return information about the given session to the | ||
432 | * monitor callback. | ||
433 | * | ||
434 | * @param cls the `struct Plugin` with the monitor callback (`sic`) | ||
435 | * @param peer peer we send information about | ||
436 | * @param value our `struct Session` to send information about | ||
437 | * @return #GNUNET_OK (continue to iterate) | ||
438 | */ | ||
439 | static int | ||
440 | send_session_info_iter (void *cls, | ||
441 | const struct GNUNET_PeerIdentity *peer, | ||
442 | void *value) | ||
443 | { | ||
444 | struct Plugin *plugin = cls; | ||
445 | struct Session *session = value; | ||
446 | |||
447 | notify_session_monitor (plugin, | ||
448 | session, | ||
449 | GNUNET_TRANSPORT_SS_UP); | ||
450 | return GNUNET_OK; | ||
451 | } | ||
452 | #endif | ||
453 | |||
454 | |||
455 | /** | ||
456 | * Begin monitoring sessions of a plugin. There can only | ||
457 | * be one active monitor per plugin (i.e. if there are | ||
458 | * multiple monitors, the transport service needs to | ||
459 | * multiplex the generated events over all of them). | ||
460 | * | ||
461 | * @param cls closure of the plugin | ||
462 | * @param sic callback to invoke, NULL to disable monitor; | ||
463 | * plugin will being by iterating over all active | ||
464 | * sessions immediately and then enter monitor mode | ||
465 | * @param sic_cls closure for @a sic | ||
466 | */ | ||
467 | static void | ||
468 | template_plugin_setup_monitor (void *cls, | ||
469 | GNUNET_TRANSPORT_SessionInfoCallback sic, | ||
470 | void *sic_cls) | ||
471 | { | ||
472 | struct Plugin *plugin = cls; | ||
473 | |||
474 | plugin->sic = sic; | ||
475 | plugin->sic_cls = sic_cls; | ||
476 | if (NULL != sic) | ||
477 | { | ||
478 | #if 0 | ||
479 | GNUNET_CONTAINER_multipeermap_iterate (NULL /* FIXME */, | ||
480 | &send_session_info_iter, | ||
481 | plugin); | ||
482 | #endif | ||
483 | /* signal end of first iteration */ | ||
484 | sic (sic_cls, NULL, NULL); | ||
485 | } | ||
486 | } | ||
487 | |||
488 | |||
386 | /** | 489 | /** |
387 | * Entry point for the plugin. | 490 | * Entry point for the plugin. |
388 | */ | 491 | */ |
@@ -420,6 +523,7 @@ libgnunet_plugin_transport_template_init (void *cls) | |||
420 | api->get_session = &template_plugin_get_session; | 523 | api->get_session = &template_plugin_get_session; |
421 | api->get_network = &template_plugin_get_network; | 524 | api->get_network = &template_plugin_get_network; |
422 | api->update_session_timeout = &template_plugin_update_session_timeout; | 525 | api->update_session_timeout = &template_plugin_update_session_timeout; |
526 | api->setup_monitor = &template_plugin_setup_monitor; | ||
423 | LOG (GNUNET_ERROR_TYPE_INFO, "Template plugin successfully loaded\n"); | 527 | LOG (GNUNET_ERROR_TYPE_INFO, "Template plugin successfully loaded\n"); |
424 | return api; | 528 | return api; |
425 | } | 529 | } |
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 7dff9587f..6c0c12065 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c | |||
@@ -382,9 +382,9 @@ notify_session_monitor (struct Plugin *plugin, | |||
382 | * @return string representing the same address | 382 | * @return string representing the same address |
383 | */ | 383 | */ |
384 | static const char * | 384 | static const char * |
385 | unix_address_to_string (void *cls, | 385 | unix_plugin_address_to_string (void *cls, |
386 | const void *addr, | 386 | const void *addr, |
387 | size_t addrlen) | 387 | size_t addrlen) |
388 | { | 388 | { |
389 | static char rbuf[1024]; | 389 | static char rbuf[1024]; |
390 | struct UnixAddress *ua = (struct UnixAddress *) addr; | 390 | struct UnixAddress *ua = (struct UnixAddress *) addr; |
@@ -442,8 +442,8 @@ unix_address_to_string (void *cls, | |||
442 | * @return #GNUNET_OK on success | 442 | * @return #GNUNET_OK on success |
443 | */ | 443 | */ |
444 | static int | 444 | static int |
445 | unix_session_disconnect (void *cls, | 445 | unix_plugin_session_disconnect (void *cls, |
446 | struct Session *session) | 446 | struct Session *session) |
447 | { | 447 | { |
448 | struct Plugin *plugin = cls; | 448 | struct Plugin *plugin = cls; |
449 | struct UNIXMessageWrapper *msgw; | 449 | struct UNIXMessageWrapper *msgw; |
@@ -452,9 +452,9 @@ unix_session_disconnect (void *cls, | |||
452 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 452 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
453 | "Disconnecting session for peer `%s' `%s'\n", | 453 | "Disconnecting session for peer `%s' `%s'\n", |
454 | GNUNET_i2s (&session->target), | 454 | GNUNET_i2s (&session->target), |
455 | unix_address_to_string (NULL, | 455 | unix_plugin_address_to_string (NULL, |
456 | session->address->address, | 456 | session->address->address, |
457 | session->address->address_length)); | 457 | session->address->address_length)); |
458 | plugin->env->session_end (plugin->env->cls, | 458 | plugin->env->session_end (plugin->env->cls, |
459 | session->address, | 459 | session->address, |
460 | session); | 460 | session); |
@@ -538,7 +538,7 @@ session_timeout (void *cls, | |||
538 | session, | 538 | session, |
539 | GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | 539 | GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, |
540 | GNUNET_YES)); | 540 | GNUNET_YES)); |
541 | unix_session_disconnect (session->plugin, session); | 541 | unix_plugin_session_disconnect (session->plugin, session); |
542 | } | 542 | } |
543 | 543 | ||
544 | 544 | ||
@@ -662,7 +662,7 @@ lookup_session (struct Plugin *plugin, | |||
662 | * @return keepalive factor | 662 | * @return keepalive factor |
663 | */ | 663 | */ |
664 | static unsigned int | 664 | static unsigned int |
665 | unix_query_keepalive_factor (void *cls) | 665 | unix_plugin_query_keepalive_factor (void *cls) |
666 | { | 666 | { |
667 | return 3; | 667 | return 3; |
668 | } | 668 | } |
@@ -808,8 +808,8 @@ resend: | |||
808 | * @return the network type in HBO or #GNUNET_SYSERR | 808 | * @return the network type in HBO or #GNUNET_SYSERR |
809 | */ | 809 | */ |
810 | static enum GNUNET_ATS_Network_Type | 810 | static enum GNUNET_ATS_Network_Type |
811 | unix_get_network (void *cls, | 811 | unix_plugin_get_network (void *cls, |
812 | struct Session *session) | 812 | struct Session *session) |
813 | { | 813 | { |
814 | GNUNET_assert (NULL != session); | 814 | GNUNET_assert (NULL != session); |
815 | return GNUNET_ATS_NET_LOOPBACK; | 815 | return GNUNET_ATS_NET_LOOPBACK; |
@@ -875,9 +875,9 @@ unix_plugin_get_session (void *cls, | |||
875 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 875 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
876 | "Found existing session %p for address `%s'\n", | 876 | "Found existing session %p for address `%s'\n", |
877 | session, | 877 | session, |
878 | unix_address_to_string (NULL, | 878 | unix_plugin_address_to_string (NULL, |
879 | address->address, | 879 | address->address, |
880 | address->address_length)); | 880 | address->address_length)); |
881 | return session; | 881 | return session; |
882 | } | 882 | } |
883 | 883 | ||
@@ -892,9 +892,9 @@ unix_plugin_get_session (void *cls, | |||
892 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 892 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
893 | "Creating a new session %p for address `%s'\n", | 893 | "Creating a new session %p for address `%s'\n", |
894 | session, | 894 | session, |
895 | unix_address_to_string (NULL, | 895 | unix_plugin_address_to_string (NULL, |
896 | address->address, | 896 | address->address, |
897 | address->address_length)); | 897 | address->address_length)); |
898 | (void) GNUNET_CONTAINER_multipeermap_put (plugin->session_map, | 898 | (void) GNUNET_CONTAINER_multipeermap_put (plugin->session_map, |
899 | &address->peer, session, | 899 | &address->peer, session, |
900 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 900 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
@@ -959,7 +959,7 @@ unix_demultiplexer (struct Plugin *plugin, | |||
959 | GNUNET_assert (ua_len >= sizeof (struct UnixAddress)); | 959 | GNUNET_assert (ua_len >= sizeof (struct UnixAddress)); |
960 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 960 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
961 | "Received message from %s\n", | 961 | "Received message from %s\n", |
962 | unix_address_to_string (NULL, ua, ua_len)); | 962 | unix_plugin_address_to_string (NULL, ua, ua_len)); |
963 | GNUNET_STATISTICS_update (plugin->env->stats, | 963 | GNUNET_STATISTICS_update (plugin->env->stats, |
964 | "# bytes received via UNIX", | 964 | "# bytes received via UNIX", |
965 | ntohs (currhdr->size), | 965 | ntohs (currhdr->size), |
@@ -1321,9 +1321,9 @@ unix_plugin_send (void *cls, | |||
1321 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1321 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1322 | "Invalid session for peer `%s' `%s'\n", | 1322 | "Invalid session for peer `%s' `%s'\n", |
1323 | GNUNET_i2s (&session->target), | 1323 | GNUNET_i2s (&session->target), |
1324 | unix_address_to_string(NULL, | 1324 | unix_plugin_address_to_string (NULL, |
1325 | session->address->address, | 1325 | session->address->address, |
1326 | session->address->address_length)); | 1326 | session->address->address_length)); |
1327 | GNUNET_break (0); | 1327 | GNUNET_break (0); |
1328 | return GNUNET_SYSERR; | 1328 | return GNUNET_SYSERR; |
1329 | } | 1329 | } |
@@ -1331,9 +1331,9 @@ unix_plugin_send (void *cls, | |||
1331 | "Sending %u bytes with session for peer `%s' `%s'\n", | 1331 | "Sending %u bytes with session for peer `%s' `%s'\n", |
1332 | msgbuf_size, | 1332 | msgbuf_size, |
1333 | GNUNET_i2s (&session->target), | 1333 | GNUNET_i2s (&session->target), |
1334 | unix_address_to_string (NULL, | 1334 | unix_plugin_address_to_string (NULL, |
1335 | session->address->address, | 1335 | session->address->address, |
1336 | session->address->address_length)); | 1336 | session->address->address_length)); |
1337 | ssize = sizeof (struct UNIXMessage) + msgbuf_size; | 1337 | ssize = sizeof (struct UNIXMessage) + msgbuf_size; |
1338 | message = GNUNET_malloc (sizeof (struct UNIXMessage) + msgbuf_size); | 1338 | message = GNUNET_malloc (sizeof (struct UNIXMessage) + msgbuf_size); |
1339 | message->header.size = htons (ssize); | 1339 | message->header.size = htons (ssize); |
@@ -1452,9 +1452,9 @@ unix_transport_server_start (void *cls) | |||
1452 | * | 1452 | * |
1453 | */ | 1453 | */ |
1454 | static int | 1454 | static int |
1455 | unix_check_address (void *cls, | 1455 | unix_plugin_check_address (void *cls, |
1456 | const void *addr, | 1456 | const void *addr, |
1457 | size_t addrlen) | 1457 | size_t addrlen) |
1458 | { | 1458 | { |
1459 | struct Plugin* plugin = cls; | 1459 | struct Plugin* plugin = cls; |
1460 | const struct UnixAddress *ua = addr; | 1460 | const struct UnixAddress *ua = addr; |
@@ -1513,9 +1513,9 @@ unix_plugin_address_pretty_printer (void *cls, const char *type, | |||
1513 | const char *ret; | 1513 | const char *ret; |
1514 | 1514 | ||
1515 | if ( (NULL != addr) && (addrlen > 0)) | 1515 | if ( (NULL != addr) && (addrlen > 0)) |
1516 | ret = unix_address_to_string (NULL, | 1516 | ret = unix_plugin_address_to_string (NULL, |
1517 | addr, | 1517 | addr, |
1518 | addrlen); | 1518 | addrlen); |
1519 | else | 1519 | else |
1520 | ret = NULL; | 1520 | ret = NULL; |
1521 | asc (asc_cls, | 1521 | asc (asc_cls, |
@@ -1538,10 +1538,10 @@ unix_plugin_address_pretty_printer (void *cls, const char *type, | |||
1538 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 1538 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
1539 | */ | 1539 | */ |
1540 | static int | 1540 | static int |
1541 | unix_string_to_address (void *cls, | 1541 | unix_plugin_string_to_address (void *cls, |
1542 | const char *addr, | 1542 | const char *addr, |
1543 | uint16_t addrlen, | 1543 | uint16_t addrlen, |
1544 | void **buf, size_t *added) | 1544 | void **buf, size_t *added) |
1545 | { | 1545 | { |
1546 | struct UnixAddress *ua; | 1546 | struct UnixAddress *ua; |
1547 | char *address; | 1547 | char *address; |
@@ -1661,9 +1661,9 @@ get_session_delete_it (void *cls, | |||
1661 | void *value) | 1661 | void *value) |
1662 | { | 1662 | { |
1663 | struct Plugin *plugin = cls; | 1663 | struct Plugin *plugin = cls; |
1664 | struct Session *s = value; | 1664 | struct Session *session = value; |
1665 | 1665 | ||
1666 | unix_session_disconnect (plugin, s); | 1666 | unix_plugin_session_disconnect (plugin, session); |
1667 | return GNUNET_YES; | 1667 | return GNUNET_YES; |
1668 | } | 1668 | } |
1669 | 1669 | ||
@@ -1676,12 +1676,11 @@ get_session_delete_it (void *cls, | |||
1676 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the operation failed | 1676 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the operation failed |
1677 | */ | 1677 | */ |
1678 | static void | 1678 | static void |
1679 | unix_peer_disconnect (void *cls, | 1679 | unix_plugin_peer_disconnect (void *cls, |
1680 | const struct GNUNET_PeerIdentity *target) | 1680 | const struct GNUNET_PeerIdentity *target) |
1681 | { | 1681 | { |
1682 | struct Plugin *plugin = cls; | 1682 | struct Plugin *plugin = cls; |
1683 | 1683 | ||
1684 | GNUNET_assert (NULL != plugin); | ||
1685 | GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, | 1684 | GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map, |
1686 | target, | 1685 | target, |
1687 | &get_session_delete_it, plugin); | 1686 | &get_session_delete_it, plugin); |
@@ -1725,18 +1724,22 @@ send_session_info_iter (void *cls, | |||
1725 | * @param sic_cls closure for @a sic | 1724 | * @param sic_cls closure for @a sic |
1726 | */ | 1725 | */ |
1727 | static void | 1726 | static void |
1728 | unix_setup_monitor (void *cls, | 1727 | unix_plugin_setup_monitor (void *cls, |
1729 | GNUNET_TRANSPORT_SessionInfoCallback sic, | 1728 | GNUNET_TRANSPORT_SessionInfoCallback sic, |
1730 | void *sic_cls) | 1729 | void *sic_cls) |
1731 | { | 1730 | { |
1732 | struct Plugin *plugin = cls; | 1731 | struct Plugin *plugin = cls; |
1733 | 1732 | ||
1734 | plugin->sic = sic; | 1733 | plugin->sic = sic; |
1735 | plugin->sic_cls = sic_cls; | 1734 | plugin->sic_cls = sic_cls; |
1736 | if (NULL != sic) | 1735 | if (NULL != sic) |
1736 | { | ||
1737 | GNUNET_CONTAINER_multipeermap_iterate (plugin->session_map, | 1737 | GNUNET_CONTAINER_multipeermap_iterate (plugin->session_map, |
1738 | &send_session_info_iter, | 1738 | &send_session_info_iter, |
1739 | plugin); | 1739 | plugin); |
1740 | /* signal end of first iteration */ | ||
1741 | sic (sic_cls, NULL, NULL); | ||
1742 | } | ||
1740 | } | 1743 | } |
1741 | 1744 | ||
1742 | 1745 | ||
@@ -1762,8 +1765,8 @@ libgnunet_plugin_transport_unix_init (void *cls) | |||
1762 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); | 1765 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); |
1763 | api->cls = NULL; | 1766 | api->cls = NULL; |
1764 | api->address_pretty_printer = &unix_plugin_address_pretty_printer; | 1767 | api->address_pretty_printer = &unix_plugin_address_pretty_printer; |
1765 | api->address_to_string = &unix_address_to_string; | 1768 | api->address_to_string = &unix_plugin_address_to_string; |
1766 | api->string_to_address = &unix_string_to_address; | 1769 | api->string_to_address = &unix_plugin_string_to_address; |
1767 | return api; | 1770 | return api; |
1768 | } | 1771 | } |
1769 | 1772 | ||
@@ -1797,16 +1800,16 @@ libgnunet_plugin_transport_unix_init (void *cls) | |||
1797 | api->cls = plugin; | 1800 | api->cls = plugin; |
1798 | api->get_session = &unix_plugin_get_session; | 1801 | api->get_session = &unix_plugin_get_session; |
1799 | api->send = &unix_plugin_send; | 1802 | api->send = &unix_plugin_send; |
1800 | api->disconnect_peer = &unix_peer_disconnect; | 1803 | api->disconnect_peer = &unix_plugin_peer_disconnect; |
1801 | api->disconnect_session = &unix_session_disconnect; | 1804 | api->disconnect_session = &unix_plugin_session_disconnect; |
1802 | api->query_keepalive_factor = &unix_query_keepalive_factor; | 1805 | api->query_keepalive_factor = &unix_plugin_query_keepalive_factor; |
1803 | api->address_pretty_printer = &unix_plugin_address_pretty_printer; | 1806 | api->address_pretty_printer = &unix_plugin_address_pretty_printer; |
1804 | api->address_to_string = &unix_address_to_string; | 1807 | api->address_to_string = &unix_plugin_address_to_string; |
1805 | api->check_address = &unix_check_address; | 1808 | api->check_address = &unix_plugin_check_address; |
1806 | api->string_to_address = &unix_string_to_address; | 1809 | api->string_to_address = &unix_plugin_string_to_address; |
1807 | api->get_network = &unix_get_network; | 1810 | api->get_network = &unix_plugin_get_network; |
1808 | api->update_session_timeout = &unix_plugin_update_session_timeout; | 1811 | api->update_session_timeout = &unix_plugin_update_session_timeout; |
1809 | api->setup_monitor = &unix_setup_monitor; | 1812 | api->setup_monitor = &unix_plugin_setup_monitor; |
1810 | sockets_created = unix_transport_server_start (plugin); | 1813 | sockets_created = unix_transport_server_start (plugin); |
1811 | if ((0 == sockets_created) || (GNUNET_SYSERR == sockets_created)) | 1814 | if ((0 == sockets_created) || (GNUNET_SYSERR == sockets_created)) |
1812 | { | 1815 | { |