diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_transport_plugin.h | 73 | ||||
-rw-r--r-- | src/include/gnunet_transport_service.h | 149 |
2 files changed, 149 insertions, 73 deletions
diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h index 4bed48de5..17333551c 100644 --- a/src/include/gnunet_transport_plugin.h +++ b/src/include/gnunet_transport_plugin.h | |||
@@ -597,79 +597,6 @@ typedef enum GNUNET_ATS_Network_Type | |||
597 | 597 | ||
598 | 598 | ||
599 | /** | 599 | /** |
600 | * Possible states of a session in a plugin. | ||
601 | */ | ||
602 | enum GNUNET_TRANSPORT_SessionState | ||
603 | { | ||
604 | /** | ||
605 | * Session is being torn down and about to disappear. | ||
606 | */ | ||
607 | GNUNET_TRANSPORT_SS_DOWN, | ||
608 | |||
609 | /** | ||
610 | * Initial session handshake is in progress. | ||
611 | */ | ||
612 | GNUNET_TRANSPORT_SS_HANDSHAKE, | ||
613 | |||
614 | /** | ||
615 | * Session is fully UP. | ||
616 | */ | ||
617 | GNUNET_TRANSPORT_SS_UP | ||
618 | |||
619 | }; | ||
620 | |||
621 | |||
622 | /** | ||
623 | * Information about a plugin's session. | ||
624 | */ | ||
625 | struct GNUNET_TRANSPORT_SessionInfo | ||
626 | { | ||
627 | |||
628 | /** | ||
629 | * New state of the session. | ||
630 | */ | ||
631 | enum GNUNET_TRANSPORT_SessionState state; | ||
632 | |||
633 | /** | ||
634 | * #GNUNET_YES if this is an inbound connection, | ||
635 | * #GNUNET_NO if this is an outbound connection, | ||
636 | * #GNUNET_SYSERR if connections of this plugin | ||
637 | * are so fundamentally bidirectional | ||
638 | * that they have no 'initiator' | ||
639 | */ | ||
640 | int is_inbound; | ||
641 | |||
642 | /** | ||
643 | * Number of messages pending transmission for this session. | ||
644 | */ | ||
645 | unsigned int num_msg_pending; | ||
646 | |||
647 | /** | ||
648 | * Number of bytes pending transmission for this session. | ||
649 | */ | ||
650 | unsigned int num_bytes_pending; | ||
651 | |||
652 | /** | ||
653 | * Until when does this plugin refuse to receive to manage | ||
654 | * staying within the inbound quota? ZERO if receive is | ||
655 | * active. | ||
656 | */ | ||
657 | struct GNUNET_TIME_Absolute receive_delay; | ||
658 | |||
659 | /** | ||
660 | * At what time will this session timeout (unless activity | ||
661 | * happens)? | ||
662 | */ | ||
663 | struct GNUNET_TIME_Absolute session_timeout; | ||
664 | |||
665 | /** | ||
666 | * Address used by the session. Can be NULL if none is available. | ||
667 | */ | ||
668 | const struct GNUNET_HELLO_Address *address; | ||
669 | }; | ||
670 | |||
671 | |||
672 | /** | ||
673 | * Function called by the plugin with information about the | 600 | * Function called by the plugin with information about the |
674 | * current sessions managed by the plugin (for monitoring). | 601 | * current sessions managed by the plugin (for monitoring). |
675 | * | 602 | * |
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h index e18f7c360..b3ab4d01e 100644 --- a/src/include/gnunet_transport_service.h +++ b/src/include/gnunet_transport_service.h | |||
@@ -885,6 +885,155 @@ void | |||
885 | GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br); | 885 | GNUNET_TRANSPORT_blacklist_cancel (struct GNUNET_TRANSPORT_Blacklist *br); |
886 | 886 | ||
887 | 887 | ||
888 | /** | ||
889 | * Handle for a plugin session state monitor. | ||
890 | */ | ||
891 | struct GNUNET_TRANSPORT_PluginMonitor; | ||
892 | |||
893 | /** | ||
894 | * Abstract representation of a plugin's session. | ||
895 | * Corresponds to the `struct Session` within the TRANSPORT service. | ||
896 | */ | ||
897 | struct GNUNET_TRANSPORT_PluginSession; | ||
898 | |||
899 | |||
900 | /** | ||
901 | * Possible states of a session in a plugin. | ||
902 | */ | ||
903 | enum GNUNET_TRANSPORT_SessionState | ||
904 | { | ||
905 | |||
906 | /** | ||
907 | * The session was created (first call for each session object). | ||
908 | */ | ||
909 | GNUNET_TRANSPORT_SS_INIT, | ||
910 | |||
911 | /** | ||
912 | * Initial session handshake is in progress. | ||
913 | */ | ||
914 | GNUNET_TRANSPORT_SS_HANDSHAKE, | ||
915 | |||
916 | /** | ||
917 | * Session is fully UP. | ||
918 | */ | ||
919 | GNUNET_TRANSPORT_SS_UP, | ||
920 | |||
921 | /** | ||
922 | * This is just an update about the session, | ||
923 | * the state did not change. | ||
924 | */ | ||
925 | GNUNET_TRANSPORT_SS_UPDATE, | ||
926 | |||
927 | /** | ||
928 | * Session is being torn down and about to disappear. | ||
929 | * Last call for each session object. | ||
930 | */ | ||
931 | GNUNET_TRANSPORT_SS_DONE | ||
932 | |||
933 | }; | ||
934 | |||
935 | |||
936 | /** | ||
937 | * Information about a plugin's session. | ||
938 | */ | ||
939 | struct GNUNET_TRANSPORT_SessionInfo | ||
940 | { | ||
941 | |||
942 | /** | ||
943 | * New state of the session. | ||
944 | */ | ||
945 | enum GNUNET_TRANSPORT_SessionState state; | ||
946 | |||
947 | /** | ||
948 | * #GNUNET_YES if this is an inbound connection, | ||
949 | * #GNUNET_NO if this is an outbound connection, | ||
950 | * #GNUNET_SYSERR if connections of this plugin | ||
951 | * are so fundamentally bidirectional | ||
952 | * that they have no 'initiator' | ||
953 | */ | ||
954 | int is_inbound; | ||
955 | |||
956 | /** | ||
957 | * Number of messages pending transmission for this session. | ||
958 | */ | ||
959 | uint32_t num_msg_pending; | ||
960 | |||
961 | /** | ||
962 | * Number of bytes pending transmission for this session. | ||
963 | */ | ||
964 | uint32_t num_bytes_pending; | ||
965 | |||
966 | /** | ||
967 | * Until when does this plugin refuse to receive to manage | ||
968 | * staying within the inbound quota? ZERO if receive is | ||
969 | * active. | ||
970 | */ | ||
971 | struct GNUNET_TIME_Absolute receive_delay; | ||
972 | |||
973 | /** | ||
974 | * At what time will this session timeout (unless activity | ||
975 | * happens)? | ||
976 | */ | ||
977 | struct GNUNET_TIME_Absolute session_timeout; | ||
978 | |||
979 | /** | ||
980 | * Address used by the session. Can be NULL if none is available. | ||
981 | */ | ||
982 | const struct GNUNET_HELLO_Address *address; | ||
983 | }; | ||
984 | |||
985 | |||
986 | /** | ||
987 | * Function called by the plugin with information about the | ||
988 | * current sessions managed by the plugin (for monitoring). | ||
989 | * | ||
990 | * @param cls closure | ||
991 | * @param session session handle this information is about, | ||
992 | * NULL to indicate that we are "in sync" (initial | ||
993 | * iteration complete) | ||
994 | * @param session_ctx storage location where the application | ||
995 | * can store data; will point to NULL on #GNUNET_TRANSPORT_SS_INIT, | ||
996 | * and must be reset to NULL on #GNUNET_TRANSPORT_SS_DONE | ||
997 | * @param info information about the state of the session, | ||
998 | * NULL if @a session is also NULL and we are | ||
999 | * merely signalling that the initial iteration is over; | ||
1000 | * NULL with @a session being non-NULL if the monitor | ||
1001 | * was being cancelled while sessions were active | ||
1002 | */ | ||
1003 | typedef void | ||
1004 | (*GNUNET_TRANSPORT_SessionMonitorCallback) (void *cls, | ||
1005 | struct GNUNET_TRANSPORT_PluginSession *session, | ||
1006 | void **session_ctx, | ||
1007 | const struct GNUNET_TRANSPORT_SessionInfo *info); | ||
1008 | |||
1009 | |||
1010 | |||
1011 | /** | ||
1012 | * Install a plugin session state monitor callback. The callback | ||
1013 | * will be notified whenever the session changes. | ||
1014 | * | ||
1015 | * @param cfg configuration to use | ||
1016 | * @param cb callback to invoke on events | ||
1017 | * @param cb_cls closure for @a cb | ||
1018 | * @return NULL on error, otherwise handle for cancellation | ||
1019 | */ | ||
1020 | struct GNUNET_TRANSPORT_PluginMonitor * | ||
1021 | GNUNET_TRANSPORT_monitor_plugins (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
1022 | GNUNET_TRANSPORT_SessionMonitorCallback cb, | ||
1023 | void *cb_cls); | ||
1024 | |||
1025 | |||
1026 | /** | ||
1027 | * Cancel monitoring the plugin session state. The callback will be | ||
1028 | * called once for each session that is up with the "info" argument | ||
1029 | * being NULL (this is just to enable client-side cleanup). | ||
1030 | * | ||
1031 | * @param pm handle of the request that is to be cancelled | ||
1032 | */ | ||
1033 | void | ||
1034 | GNUNET_TRANSPORT_monitor_plugins_cancel (struct GNUNET_TRANSPORT_PluginMonitor *pm); | ||
1035 | |||
1036 | |||
888 | 1037 | ||
889 | #if 0 /* keep Emacsens' auto-indent happy */ | 1038 | #if 0 /* keep Emacsens' auto-indent happy */ |
890 | { | 1039 | { |