diff options
Diffstat (limited to 'src/include/gnunet_transport_plugin.h')
-rw-r--r-- | src/include/gnunet_transport_plugin.h | 164 |
1 files changed, 145 insertions, 19 deletions
diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h index b32b94004..0139ca2b0 100644 --- a/src/include/gnunet_transport_plugin.h +++ b/src/include/gnunet_transport_plugin.h | |||
@@ -55,7 +55,7 @@ | |||
55 | struct Session; | 55 | struct Session; |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Every 'struct Session' must begin with this header. | 58 | * Every `struct Session` must begin with this header. |
59 | */ | 59 | */ |
60 | struct SessionHeader | 60 | struct SessionHeader |
61 | { | 61 | { |
@@ -121,9 +121,9 @@ typedef void | |||
121 | */ | 121 | */ |
122 | typedef struct GNUNET_TIME_Relative | 122 | typedef struct GNUNET_TIME_Relative |
123 | (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls, | 123 | (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls, |
124 | const struct GNUNET_HELLO_Address *address, | 124 | const struct GNUNET_HELLO_Address *address, |
125 | struct Session *session, | 125 | struct Session *session, |
126 | const struct GNUNET_MessageHeader *message); | 126 | const struct GNUNET_MessageHeader *message); |
127 | 127 | ||
128 | 128 | ||
129 | /** | 129 | /** |
@@ -169,8 +169,9 @@ typedef void | |||
169 | * @param address the address to add or remove | 169 | * @param address the address to add or remove |
170 | */ | 170 | */ |
171 | typedef void | 171 | typedef void |
172 | (*GNUNET_TRANSPORT_AddressNotification) (void *cls, int add_remove, | 172 | (*GNUNET_TRANSPORT_AddressNotification) (void *cls, |
173 | const struct GNUNET_HELLO_Address *address); | 173 | int add_remove, |
174 | const struct GNUNET_HELLO_Address *address); | ||
174 | 175 | ||
175 | 176 | ||
176 | /** | 177 | /** |
@@ -194,14 +195,16 @@ typedef struct GNUNET_TIME_Relative | |||
194 | const struct GNUNET_PeerIdentity *peer, | 195 | const struct GNUNET_PeerIdentity *peer, |
195 | size_t amount_recved); | 196 | size_t amount_recved); |
196 | 197 | ||
198 | |||
197 | /** | 199 | /** |
198 | * FIXME: document! | 200 | * FIXME: document! |
199 | */ | 201 | */ |
200 | typedef void | 202 | typedef void |
201 | (*GNUNET_TRANSPORT_RegisterQuotaNotification) (void *cls, | 203 | (*GNUNET_TRANSPORT_RegisterQuotaNotification) (void *cls, |
202 | const struct GNUNET_PeerIdentity *peer, | 204 | const struct GNUNET_PeerIdentity *peer, |
203 | const char *plugin, | 205 | const char *plugin, |
204 | struct Session *session); | 206 | struct Session *session); |
207 | |||
205 | 208 | ||
206 | /** | 209 | /** |
207 | * FIXME: document! | 210 | * FIXME: document! |
@@ -253,8 +256,8 @@ struct GNUNET_TRANSPORT_PluginEnvironment | |||
253 | * whenever a message is received. If this field is "NULL", | 256 | * whenever a message is received. If this field is "NULL", |
254 | * the plugin should load in 'stub' mode and NOT fully | 257 | * the plugin should load in 'stub' mode and NOT fully |
255 | * initialize and instead only return an API with the | 258 | * initialize and instead only return an API with the |
256 | * 'address_pretty_printer', 'address_to_string' and | 259 | * @e address_pretty_printer, @e address_to_string and |
257 | * 'string_to_address' functions. | 260 | * @e string_to_address functions. |
258 | */ | 261 | */ |
259 | GNUNET_TRANSPORT_PluginReceiveCallback receive; | 262 | GNUNET_TRANSPORT_PluginReceiveCallback receive; |
260 | 263 | ||
@@ -397,9 +400,10 @@ typedef int | |||
397 | (*GNUNET_TRANSPORT_DisconnectSessionFunction) (void *cls, | 400 | (*GNUNET_TRANSPORT_DisconnectSessionFunction) (void *cls, |
398 | struct Session *session); | 401 | struct Session *session); |
399 | 402 | ||
403 | |||
400 | /** | 404 | /** |
401 | * Function that is called to get the keepalive factor. | 405 | * Function that is called to get the keepalive factor. |
402 | * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to | 406 | * #GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to |
403 | * calculate the interval between keepalive packets. | 407 | * calculate the interval between keepalive packets. |
404 | * | 408 | * |
405 | * @param cls closure with the `struct Plugin` | 409 | * @param cls closure with the `struct Plugin` |
@@ -521,11 +525,21 @@ typedef void | |||
521 | 525 | ||
522 | 526 | ||
523 | 527 | ||
528 | /** | ||
529 | * Function that will be called whenever the transport service wants to | ||
530 | * notify the plugin that the inbound quota changed and that the plugin | ||
531 | * should update it's delay for the next receive value | ||
532 | * | ||
533 | * @param cls closure | ||
534 | * @param peer which peer was the session for | ||
535 | * @param session which session is being updated | ||
536 | * @param delay new delay to use for receiving | ||
537 | */ | ||
524 | typedef void | 538 | typedef void |
525 | (*GNUNET_TRANSPORT_UpdateInboundDelay) (void *cls, | 539 | (*GNUNET_TRANSPORT_UpdateInboundDelay) (void *cls, |
526 | const struct GNUNET_PeerIdentity *peer, | 540 | const struct GNUNET_PeerIdentity *peer, |
527 | struct Session *session, | 541 | struct Session *session, |
528 | struct GNUNET_TIME_Relative delay); | 542 | struct GNUNET_TIME_Relative delay); |
529 | 543 | ||
530 | /** | 544 | /** |
531 | * Function called for a quick conversion of the binary address to | 545 | * Function called for a quick conversion of the binary address to |
@@ -577,6 +591,115 @@ typedef enum GNUNET_ATS_Network_Type | |||
577 | 591 | ||
578 | 592 | ||
579 | /** | 593 | /** |
594 | * Possible states of a session in a plugin. | ||
595 | */ | ||
596 | enum GNUNET_TRANSPORT_SessionState | ||
597 | { | ||
598 | /** | ||
599 | * Session is being torn down and about to disappear. | ||
600 | */ | ||
601 | GNUNET_TRANSPORT_SS_DOWN, | ||
602 | |||
603 | /** | ||
604 | * Initial session handshake is in progress. | ||
605 | */ | ||
606 | GNUNET_TRANSPORT_SS_HANDSHAKE, | ||
607 | |||
608 | /** | ||
609 | * Session is fully UP. | ||
610 | */ | ||
611 | GNUNET_TRANSPORT_SS_UP | ||
612 | |||
613 | }; | ||
614 | |||
615 | |||
616 | /** | ||
617 | * Information about a plugin's session. | ||
618 | */ | ||
619 | struct GNUNET_TRANSPORT_SessionInfo | ||
620 | { | ||
621 | |||
622 | /** | ||
623 | * New state of the session. | ||
624 | */ | ||
625 | enum GNUNET_TRANSPORT_SessionState state; | ||
626 | |||
627 | /** | ||
628 | * #GNUNET_YES if this is an inbound connection, | ||
629 | * #GNUNET_NO if this is an outbound connection, | ||
630 | * #GNUNET_SYSERR if connections of this plugin | ||
631 | * are so fundamentally bidirectional | ||
632 | * that they have no 'initiator' | ||
633 | */ | ||
634 | int is_inbound; | ||
635 | |||
636 | /** | ||
637 | * Number of messages pending transmission for this session. | ||
638 | */ | ||
639 | unsigned int num_msg_pending; | ||
640 | |||
641 | /** | ||
642 | * Number of bytes pending transmission for this session. | ||
643 | */ | ||
644 | unsigned int num_bytes_pending; | ||
645 | |||
646 | /** | ||
647 | * Until when does this plugin refuse to receive to manage | ||
648 | * staying within the inbound quota? ZERO if receive is | ||
649 | * active. | ||
650 | */ | ||
651 | struct GNUNET_TIME_Absolute receive_delay; | ||
652 | |||
653 | /** | ||
654 | * At what time will this session timeout (unless activity | ||
655 | * happens)? | ||
656 | */ | ||
657 | struct GNUNET_TIME_Absolute session_timeout; | ||
658 | |||
659 | /** | ||
660 | * Address used by the session. Can be NULL if none is available. | ||
661 | */ | ||
662 | const struct GNUNET_HELLO_Address *address; | ||
663 | }; | ||
664 | |||
665 | |||
666 | /** | ||
667 | * Function called by the plugin with information about the | ||
668 | * current sessions managed by the plugin (for monitoring). | ||
669 | * | ||
670 | * @param cls closure | ||
671 | * @param session session handle this information is about, | ||
672 | * NULL to indicate that we are "in sync" (initial | ||
673 | * iteration complete) | ||
674 | * @param info information about the state of the session, | ||
675 | * NULL if @a session is also NULL and we are | ||
676 | * merely signalling that the initial iteration is over | ||
677 | */ | ||
678 | typedef void | ||
679 | (*GNUNET_TRANSPORT_SessionInfoCallback) (void *cls, | ||
680 | struct Session *session, | ||
681 | const struct GNUNET_TRANSPORT_SessionInfo *info); | ||
682 | |||
683 | |||
684 | /** | ||
685 | * Begin monitoring sessions of a plugin. There can only | ||
686 | * be one active monitor per plugin (i.e. if there are | ||
687 | * multiple monitors, the transport service needs to | ||
688 | * multiplex the generated events over all of them). | ||
689 | * | ||
690 | * @param cls closure of the plugin | ||
691 | * @param sic callback to invoke, NULL to disable monitor; | ||
692 | * plugin will being by iterating over all active | ||
693 | * sessions immediately and then enter monitor mode | ||
694 | * @param sic_cls closure for @a sic | ||
695 | */ | ||
696 | typedef void | ||
697 | (*GNUNET_TRANSPORT_SessionMonitorSetup) (void *cls, | ||
698 | GNUNET_TRANSPORT_SessionInfoCallback sic, | ||
699 | void *sic_cls); | ||
700 | |||
701 | |||
702 | /** | ||
580 | * Each plugin is required to return a pointer to a struct of this | 703 | * Each plugin is required to return a pointer to a struct of this |
581 | * type as the return value from its entry point. | 704 | * type as the return value from its entry point. |
582 | */ | 705 | */ |
@@ -618,18 +741,16 @@ struct GNUNET_TRANSPORT_PluginFunctions | |||
618 | */ | 741 | */ |
619 | GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout; | 742 | GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout; |
620 | 743 | ||
621 | GNUNET_TRANSPORT_UpdateInboundDelay update_inbound_delay; | ||
622 | |||
623 | /** | 744 | /** |
624 | * Function that will be called whenever the transport service wants to | 745 | * Function that will be called whenever the transport service wants to |
625 | * notify the plugin that the inbound quota changed and that the plugin | 746 | * notify the plugin that the inbound quota changed and that the plugin |
626 | * should update it's delay for the next receive value | 747 | * should update it's delay for the next receive value |
627 | */ | 748 | */ |
628 | //GNUNET_TRANSPORT_UpdateNextReceiveTimeout update_next_receive_timeout; | 749 | GNUNET_TRANSPORT_UpdateInboundDelay update_inbound_delay; |
629 | 750 | ||
630 | /** | 751 | /** |
631 | * Function that is used to query keepalive factor. | 752 | * Function that is used to query keepalive factor. |
632 | * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to | 753 | * #GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to |
633 | * calculate the interval between keepalive packets. | 754 | * calculate the interval between keepalive packets. |
634 | */ | 755 | */ |
635 | GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor; | 756 | GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor; |
@@ -672,6 +793,11 @@ struct GNUNET_TRANSPORT_PluginFunctions | |||
672 | * Function to obtain the network type for a session | 793 | * Function to obtain the network type for a session |
673 | */ | 794 | */ |
674 | GNUNET_TRANSPORT_GetNetworkType get_network; | 795 | GNUNET_TRANSPORT_GetNetworkType get_network; |
796 | |||
797 | /** | ||
798 | * Function to monitor the sessions managed by the plugin. | ||
799 | */ | ||
800 | GNUNET_TRANSPORT_SessionMonitorSetup setup_monitor; | ||
675 | }; | 801 | }; |
676 | 802 | ||
677 | 803 | ||