diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-11-23 19:05:11 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-11-23 19:05:11 +0000 |
commit | cb6408fefbf6b0a834ca5ae3be7458d9bf82e8cc (patch) | |
tree | 55ec9c77d4c3ce516d0de48ed9cddeee9dc6f4b9 /src/transport/gnunet-service-transport.c | |
parent | 426b733481c21704bc2fb080f7c8e1d4150d11f4 (diff) | |
download | gnunet-cb6408fefbf6b0a834ca5ae3be7458d9bf82e8cc.tar.gz gnunet-cb6408fefbf6b0a834ca5ae3be7458d9bf82e8cc.zip |
-indentation, doxygen
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 124 |
1 files changed, 72 insertions, 52 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index ba9eb38d8..63f8f9f68 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -732,8 +732,10 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address, | |||
732 | */ | 732 | */ |
733 | void | 733 | void |
734 | GST_ats_update_metrics (const struct GNUNET_PeerIdentity *peer, | 734 | GST_ats_update_metrics (const struct GNUNET_PeerIdentity *peer, |
735 | const struct GNUNET_HELLO_Address *address, struct Session *session, | 735 | const struct GNUNET_HELLO_Address *address, |
736 | const struct GNUNET_ATS_Information *ats, uint32_t ats_count) | 736 | struct Session *session, |
737 | const struct GNUNET_ATS_Information *ats, | ||
738 | uint32_t ats_count) | ||
737 | { | 739 | { |
738 | struct GNUNET_ATS_Information *ats_new; | 740 | struct GNUNET_ATS_Information *ats_new; |
739 | 741 | ||
@@ -770,21 +772,27 @@ GST_ats_update_metrics (const struct GNUNET_PeerIdentity *peer, | |||
770 | */ | 772 | */ |
771 | static void | 773 | static void |
772 | plugin_env_update_metrics (void *cls, | 774 | plugin_env_update_metrics (void *cls, |
773 | const struct GNUNET_HELLO_Address *address, | 775 | const struct GNUNET_HELLO_Address *address, |
774 | struct Session *session, | 776 | struct Session *session, |
775 | const struct GNUNET_ATS_Information *ats, | 777 | const struct GNUNET_ATS_Information *ats, |
776 | uint32_t ats_count) | 778 | uint32_t ats_count) |
777 | { | 779 | { |
778 | if ((NULL == ats) || (0 == ats_count)) | 780 | if ((NULL == ats) || (0 == ats_count)) |
779 | return; | 781 | return; |
780 | GNUNET_assert(NULL != GST_ats); | 782 | GNUNET_assert(NULL != GST_ats); |
781 | 783 | ||
782 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 784 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
783 | "Updating metrics for peer `%s' address %s session %p\n", | 785 | "Updating metrics for peer `%s' address %s session %p\n", |
784 | GNUNET_i2s (&address->peer), GST_plugins_a2s (address), session); | 786 | GNUNET_i2s (&address->peer), |
785 | GST_ats_update_metrics (&address->peer, address, session, ats, ats_count); | 787 | GST_plugins_a2s (address), |
788 | session); | ||
789 | GST_ats_update_metrics (&address->peer, | ||
790 | address, | ||
791 | session, | ||
792 | ats, ats_count); | ||
786 | } | 793 | } |
787 | 794 | ||
795 | |||
788 | /** | 796 | /** |
789 | * Black list check result for try_connect call | 797 | * Black list check result for try_connect call |
790 | * If connection to the peer is allowed request adddress and | 798 | * If connection to the peer is allowed request adddress and |
@@ -829,9 +837,11 @@ plugin_env_session_start_bl_check_cont (void *cls, | |||
829 | * @param ats_count number of @a ats information | 837 | * @param ats_count number of @a ats information |
830 | */ | 838 | */ |
831 | static void | 839 | static void |
832 | plugin_env_session_start (void *cls, struct GNUNET_HELLO_Address *address, | 840 | plugin_env_session_start (void *cls, |
833 | struct Session *session, const struct GNUNET_ATS_Information *ats, | 841 | struct GNUNET_HELLO_Address *address, |
834 | uint32_t ats_count) | 842 | struct Session *session, |
843 | const struct GNUNET_ATS_Information *ats, | ||
844 | uint32_t ats_count) | ||
835 | { | 845 | { |
836 | struct BlacklistCheckContext *blctx; | 846 | struct BlacklistCheckContext *blctx; |
837 | struct GST_BlacklistCheck *blc; | 847 | struct GST_BlacklistCheck *blc; |
@@ -876,6 +886,7 @@ plugin_env_session_start (void *cls, struct GNUNET_HELLO_Address *address, | |||
876 | } | 886 | } |
877 | } | 887 | } |
878 | 888 | ||
889 | |||
879 | /** | 890 | /** |
880 | * Function called by ATS to notify the callee that the | 891 | * Function called by ATS to notify the callee that the |
881 | * assigned bandwidth or address for a given peer was changed. If the | 892 | * assigned bandwidth or address for a given peer was changed. If the |
@@ -896,13 +907,13 @@ plugin_env_session_start (void *cls, struct GNUNET_HELLO_Address *address, | |||
896 | */ | 907 | */ |
897 | static void | 908 | static void |
898 | ats_request_address_change (void *cls, | 909 | ats_request_address_change (void *cls, |
899 | const struct GNUNET_PeerIdentity *peer, | 910 | const struct GNUNET_PeerIdentity *peer, |
900 | const struct GNUNET_HELLO_Address *address, | 911 | const struct GNUNET_HELLO_Address *address, |
901 | struct Session *session, | 912 | struct Session *session, |
902 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 913 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
903 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 914 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
904 | const struct GNUNET_ATS_Information *ats, | 915 | const struct GNUNET_ATS_Information *ats, |
905 | uint32_t ats_count) | 916 | uint32_t ats_count) |
906 | { | 917 | { |
907 | uint32_t bw_in = ntohl (bandwidth_in.value__); | 918 | uint32_t bw_in = ntohl (bandwidth_in.value__); |
908 | uint32_t bw_out = ntohl (bandwidth_out.value__); | 919 | uint32_t bw_out = ntohl (bandwidth_out.value__); |
@@ -952,6 +963,7 @@ neighbours_connect_notification (void *cls, | |||
952 | GST_clients_broadcast (&connect_msg->header, GNUNET_NO); | 963 | GST_clients_broadcast (&connect_msg->header, GNUNET_NO); |
953 | } | 964 | } |
954 | 965 | ||
966 | |||
955 | /** | 967 | /** |
956 | * Function called to notify transport users that another | 968 | * Function called to notify transport users that another |
957 | * peer disconnected from us. | 969 | * peer disconnected from us. |
@@ -961,7 +973,7 @@ neighbours_connect_notification (void *cls, | |||
961 | */ | 973 | */ |
962 | static void | 974 | static void |
963 | neighbours_disconnect_notification (void *cls, | 975 | neighbours_disconnect_notification (void *cls, |
964 | const struct GNUNET_PeerIdentity *peer) | 976 | const struct GNUNET_PeerIdentity *peer) |
965 | { | 977 | { |
966 | struct DisconnectInfoMessage disconnect_msg; | 978 | struct DisconnectInfoMessage disconnect_msg; |
967 | 979 | ||
@@ -978,6 +990,7 @@ neighbours_disconnect_notification (void *cls, | |||
978 | GST_clients_broadcast (&disconnect_msg.header, GNUNET_NO); | 990 | GST_clients_broadcast (&disconnect_msg.header, GNUNET_NO); |
979 | } | 991 | } |
980 | 992 | ||
993 | |||
981 | /** | 994 | /** |
982 | * Function called to notify transport users that a neighbour peer changed its | 995 | * Function called to notify transport users that a neighbour peer changed its |
983 | * active address. | 996 | * active address. |
@@ -992,21 +1005,24 @@ neighbours_disconnect_notification (void *cls, | |||
992 | */ | 1005 | */ |
993 | static void | 1006 | static void |
994 | neighbours_changed_notification (void *cls, | 1007 | neighbours_changed_notification (void *cls, |
995 | const struct GNUNET_PeerIdentity *peer, | 1008 | const struct GNUNET_PeerIdentity *peer, |
996 | const struct GNUNET_HELLO_Address *address, | 1009 | const struct GNUNET_HELLO_Address *address, |
997 | enum GNUNET_TRANSPORT_PeerState state, | 1010 | enum GNUNET_TRANSPORT_PeerState state, |
998 | struct GNUNET_TIME_Absolute state_timeout, | 1011 | struct GNUNET_TIME_Absolute state_timeout, |
999 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 1012 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
1000 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | 1013 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
1001 | { | 1014 | { |
1002 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1015 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1003 | "Notifying about change for peer `%s' with address `%s' in state `%s' timing out at %s\n", | 1016 | "Notifying about change for peer `%s' with address `%s' in state `%s' timing out at %s\n", |
1004 | GNUNET_i2s (peer), | 1017 | GNUNET_i2s (peer), |
1005 | (NULL != address) ? GST_plugins_a2s (address) : "<none>", | 1018 | (NULL != address) ? GST_plugins_a2s (address) : "<none>", |
1006 | GNUNET_TRANSPORT_ps2s (state), | 1019 | GNUNET_TRANSPORT_ps2s (state), |
1007 | GNUNET_STRINGS_absolute_time_to_string (state_timeout)); | 1020 | GNUNET_STRINGS_absolute_time_to_string (state_timeout)); |
1008 | 1021 | ||
1009 | GST_clients_broadcast_peer_notification (peer, address, state, state_timeout); | 1022 | GST_clients_broadcast_peer_notification (peer, |
1023 | address, | ||
1024 | state, | ||
1025 | state_timeout); | ||
1010 | } | 1026 | } |
1011 | 1027 | ||
1012 | 1028 | ||
@@ -1049,6 +1065,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1049 | GST_server = NULL; | 1065 | GST_server = NULL; |
1050 | } | 1066 | } |
1051 | 1067 | ||
1068 | |||
1052 | /** | 1069 | /** |
1053 | * Initiate transport service. | 1070 | * Initiate transport service. |
1054 | * | 1071 | * |
@@ -1078,16 +1095,18 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1078 | GNUNET_SCHEDULER_shutdown (); | 1095 | GNUNET_SCHEDULER_shutdown (); |
1079 | return; | 1096 | return; |
1080 | } | 1097 | } |
1081 | if (GNUNET_OK | 1098 | if (GNUNET_OK != |
1082 | != GNUNET_CONFIGURATION_get_value_time (c, "transport", | 1099 | GNUNET_CONFIGURATION_get_value_time (c, |
1083 | "HELLO_EXPIRATION", &hello_expiration)) | 1100 | "transport", |
1101 | "HELLO_EXPIRATION", | ||
1102 | &hello_expiration)) | ||
1084 | { | 1103 | { |
1085 | hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION; | 1104 | hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION; |
1086 | } | 1105 | } |
1087 | GST_server = server; | 1106 | GST_server = server; |
1088 | pk = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile); | 1107 | pk = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile); |
1089 | GNUNET_free(keyfile); | 1108 | GNUNET_free (keyfile); |
1090 | GNUNET_assert(NULL != pk); | 1109 | GNUNET_assert (NULL != pk); |
1091 | GST_my_private_key = pk; | 1110 | GST_my_private_key = pk; |
1092 | 1111 | ||
1093 | GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg); | 1112 | GST_stats = GNUNET_STATISTICS_create ("transport", GST_cfg); |
@@ -1096,8 +1115,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1096 | &GST_my_identity.public_key); | 1115 | &GST_my_identity.public_key); |
1097 | GNUNET_assert(NULL != GST_my_private_key); | 1116 | GNUNET_assert(NULL != GST_my_private_key); |
1098 | 1117 | ||
1099 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "My identity is `%4s'\n", | 1118 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1100 | GNUNET_i2s_full (&GST_my_identity)); | 1119 | "My identity is `%4s'\n", |
1120 | GNUNET_i2s_full (&GST_my_identity)); | ||
1101 | 1121 | ||
1102 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 1122 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
1103 | NULL ); | 1123 | NULL ); |
@@ -1149,18 +1169,18 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1149 | NULL ); | 1169 | NULL ); |
1150 | GST_manipulation_init (GST_cfg); | 1170 | GST_manipulation_init (GST_cfg); |
1151 | GST_plugins_load (&GST_manipulation_recv, | 1171 | GST_plugins_load (&GST_manipulation_recv, |
1152 | &GST_neighbours_register_quota_notification, | 1172 | &GST_neighbours_register_quota_notification, |
1153 | &GST_neighbours_unregister_quota_notification, | 1173 | &GST_neighbours_unregister_quota_notification, |
1154 | &plugin_env_address_change_notification, | 1174 | &plugin_env_address_change_notification, |
1155 | &plugin_env_session_start, | 1175 | &plugin_env_session_start, |
1156 | &plugin_env_session_end, | 1176 | &plugin_env_session_end, |
1157 | &plugin_env_address_to_type, | 1177 | &plugin_env_address_to_type, |
1158 | &plugin_env_update_metrics); | 1178 | &plugin_env_update_metrics); |
1159 | GST_neighbours_start (NULL, | 1179 | GST_neighbours_start (NULL, |
1160 | &neighbours_connect_notification, | 1180 | &neighbours_connect_notification, |
1161 | &neighbours_disconnect_notification, | 1181 | &neighbours_disconnect_notification, |
1162 | &neighbours_changed_notification, | 1182 | &neighbours_changed_notification, |
1163 | (max_fd / 3) * 2); | 1183 | (max_fd / 3) * 2); |
1164 | GST_clients_start (GST_server); | 1184 | GST_clients_start (GST_server); |
1165 | GST_validation_start ((max_fd / 3)); | 1185 | GST_validation_start ((max_fd / 3)); |
1166 | } | 1186 | } |