diff options
Diffstat (limited to 'src/ats/gnunet-service-ats_scheduling.c')
-rw-r--r-- | src/ats/gnunet-service-ats_scheduling.c | 146 |
1 files changed, 73 insertions, 73 deletions
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c index 870912dc7..d50df9b2e 100644 --- a/src/ats/gnunet-service-ats_scheduling.c +++ b/src/ats/gnunet-service-ats_scheduling.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file ats/gnunet-service-ats_scheduling.c | 22 | * @file ats/gnunet-service-ats_scheduling.c |
@@ -42,14 +42,14 @@ static struct GNUNET_SERVICE_Client *my_client; | |||
42 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 42 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
43 | */ | 43 | */ |
44 | int | 44 | int |
45 | GAS_scheduling_add_client (struct GNUNET_SERVICE_Client *client) | 45 | GAS_scheduling_add_client(struct GNUNET_SERVICE_Client *client) |
46 | { | 46 | { |
47 | if (NULL != my_client) | 47 | if (NULL != my_client) |
48 | { | 48 | { |
49 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 49 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
50 | "This ATS already has a scheduling client, refusing new scheduling client for now.\n"); | 50 | "This ATS already has a scheduling client, refusing new scheduling client for now.\n"); |
51 | return GNUNET_SYSERR; | 51 | return GNUNET_SYSERR; |
52 | } | 52 | } |
53 | my_client = client; | 53 | my_client = client; |
54 | return GNUNET_OK; | 54 | return GNUNET_OK; |
55 | } | 55 | } |
@@ -62,11 +62,11 @@ GAS_scheduling_add_client (struct GNUNET_SERVICE_Client *client) | |||
62 | * @param client handle of the (now dead) client | 62 | * @param client handle of the (now dead) client |
63 | */ | 63 | */ |
64 | void | 64 | void |
65 | GAS_scheduling_remove_client (struct GNUNET_SERVICE_Client *client) | 65 | GAS_scheduling_remove_client(struct GNUNET_SERVICE_Client *client) |
66 | { | 66 | { |
67 | if (my_client != client) | 67 | if (my_client != client) |
68 | return; | 68 | return; |
69 | GAS_addresses_destroy_all (); | 69 | GAS_addresses_destroy_all(); |
70 | my_client = NULL; | 70 | my_client = NULL; |
71 | } | 71 | } |
72 | 72 | ||
@@ -81,33 +81,33 @@ GAS_scheduling_remove_client (struct GNUNET_SERVICE_Client *client) | |||
81 | * @param bandwidth_in assigned inbound bandwidth | 81 | * @param bandwidth_in assigned inbound bandwidth |
82 | */ | 82 | */ |
83 | void | 83 | void |
84 | GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *peer, | 84 | GAS_scheduling_transmit_address_suggestion(const struct GNUNET_PeerIdentity *peer, |
85 | uint32_t session_id, | 85 | uint32_t session_id, |
86 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 86 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
87 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | 87 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) |
88 | { | 88 | { |
89 | struct GNUNET_MQ_Envelope *env; | 89 | struct GNUNET_MQ_Envelope *env; |
90 | struct AddressSuggestionMessage *msg; | 90 | struct AddressSuggestionMessage *msg; |
91 | 91 | ||
92 | if (NULL == my_client) | 92 | if (NULL == my_client) |
93 | return; | 93 | return; |
94 | GNUNET_STATISTICS_update (GSA_stats, | 94 | GNUNET_STATISTICS_update(GSA_stats, |
95 | "# address suggestions made", | 95 | "# address suggestions made", |
96 | 1, | 96 | 1, |
97 | GNUNET_NO); | 97 | GNUNET_NO); |
98 | env = GNUNET_MQ_msg (msg, | 98 | env = GNUNET_MQ_msg(msg, |
99 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION); | 99 | GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION); |
100 | msg->peer = *peer; | 100 | msg->peer = *peer; |
101 | msg->session_id = htonl (session_id); | 101 | msg->session_id = htonl(session_id); |
102 | msg->bandwidth_out = bandwidth_out; | 102 | msg->bandwidth_out = bandwidth_out; |
103 | msg->bandwidth_in = bandwidth_in; | 103 | msg->bandwidth_in = bandwidth_in; |
104 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 104 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
105 | "ATS sends quota for peer `%s': (in/out) %u/%u\n", | 105 | "ATS sends quota for peer `%s': (in/out) %u/%u\n", |
106 | GNUNET_i2s (peer), | 106 | GNUNET_i2s(peer), |
107 | (unsigned int) ntohl (bandwidth_in.value__), | 107 | (unsigned int)ntohl(bandwidth_in.value__), |
108 | (unsigned int) ntohl (bandwidth_out.value__)); | 108 | (unsigned int)ntohl(bandwidth_out.value__)); |
109 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (my_client), | 109 | GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(my_client), |
110 | env); | 110 | env); |
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
@@ -117,7 +117,7 @@ GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *pe | |||
117 | * @param m the request message | 117 | * @param m the request message |
118 | */ | 118 | */ |
119 | void | 119 | void |
120 | GAS_handle_address_add (const struct AddressAddMessage *m) | 120 | GAS_handle_address_add(const struct AddressAddMessage *m) |
121 | { | 121 | { |
122 | const char *address; | 122 | const char *address; |
123 | const char *plugin_name; | 123 | const char *plugin_name; |
@@ -125,30 +125,30 @@ GAS_handle_address_add (const struct AddressAddMessage *m) | |||
125 | uint16_t plugin_name_length; | 125 | uint16_t plugin_name_length; |
126 | struct GNUNET_ATS_Properties prop; | 126 | struct GNUNET_ATS_Properties prop; |
127 | 127 | ||
128 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 128 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
129 | "Received `%s' message\n", | 129 | "Received `%s' message\n", |
130 | "ADDRESS_ADD"); | 130 | "ADDRESS_ADD"); |
131 | address_length = ntohs (m->address_length); | 131 | address_length = ntohs(m->address_length); |
132 | plugin_name_length = ntohs (m->plugin_name_length); | 132 | plugin_name_length = ntohs(m->plugin_name_length); |
133 | address = (const char *) &m[1]; | 133 | address = (const char *)&m[1]; |
134 | if (plugin_name_length != 0) | 134 | if (plugin_name_length != 0) |
135 | plugin_name = &address[address_length]; | 135 | plugin_name = &address[address_length]; |
136 | else | 136 | else |
137 | plugin_name = ""; | 137 | plugin_name = ""; |
138 | GNUNET_STATISTICS_update (GSA_stats, | 138 | GNUNET_STATISTICS_update(GSA_stats, |
139 | "# addresses created", | 139 | "# addresses created", |
140 | 1, | 140 | 1, |
141 | GNUNET_NO); | 141 | GNUNET_NO); |
142 | GNUNET_ATS_properties_ntoh (&prop, | 142 | GNUNET_ATS_properties_ntoh(&prop, |
143 | &m->properties); | 143 | &m->properties); |
144 | GNUNET_break (GNUNET_NT_UNSPECIFIED != prop.scope); | 144 | GNUNET_break(GNUNET_NT_UNSPECIFIED != prop.scope); |
145 | GAS_addresses_add (&m->peer, | 145 | GAS_addresses_add(&m->peer, |
146 | plugin_name, | 146 | plugin_name, |
147 | address, | 147 | address, |
148 | address_length, | 148 | address_length, |
149 | ntohl (m->address_local_info), | 149 | ntohl(m->address_local_info), |
150 | ntohl (m->session_id), | 150 | ntohl(m->session_id), |
151 | &prop); | 151 | &prop); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
@@ -158,19 +158,19 @@ GAS_handle_address_add (const struct AddressAddMessage *m) | |||
158 | * @param m the request message | 158 | * @param m the request message |
159 | */ | 159 | */ |
160 | void | 160 | void |
161 | GAS_handle_address_update (const struct AddressUpdateMessage *m) | 161 | GAS_handle_address_update(const struct AddressUpdateMessage *m) |
162 | { | 162 | { |
163 | struct GNUNET_ATS_Properties prop; | 163 | struct GNUNET_ATS_Properties prop; |
164 | 164 | ||
165 | GNUNET_STATISTICS_update (GSA_stats, | 165 | GNUNET_STATISTICS_update(GSA_stats, |
166 | "# address updates received", | 166 | "# address updates received", |
167 | 1, | 167 | 1, |
168 | GNUNET_NO); | 168 | GNUNET_NO); |
169 | GNUNET_ATS_properties_ntoh (&prop, | 169 | GNUNET_ATS_properties_ntoh(&prop, |
170 | &m->properties); | 170 | &m->properties); |
171 | GAS_addresses_update (&m->peer, | 171 | GAS_addresses_update(&m->peer, |
172 | ntohl (m->session_id), | 172 | ntohl(m->session_id), |
173 | &prop); | 173 | &prop); |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
@@ -180,26 +180,26 @@ GAS_handle_address_update (const struct AddressUpdateMessage *m) | |||
180 | * @param m the request message | 180 | * @param m the request message |
181 | */ | 181 | */ |
182 | void | 182 | void |
183 | GAS_handle_address_destroyed (const struct AddressDestroyedMessage *m) | 183 | GAS_handle_address_destroyed(const struct AddressDestroyedMessage *m) |
184 | { | 184 | { |
185 | struct GNUNET_MQ_Envelope *env; | 185 | struct GNUNET_MQ_Envelope *env; |
186 | struct GNUNET_ATS_SessionReleaseMessage *srm; | 186 | struct GNUNET_ATS_SessionReleaseMessage *srm; |
187 | 187 | ||
188 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 188 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
189 | "Received `%s' message\n", | 189 | "Received `%s' message\n", |
190 | "ADDRESS_DESTROYED"); | 190 | "ADDRESS_DESTROYED"); |
191 | GNUNET_STATISTICS_update (GSA_stats, | 191 | GNUNET_STATISTICS_update(GSA_stats, |
192 | "# addresses destroyed", | 192 | "# addresses destroyed", |
193 | 1, | 193 | 1, |
194 | GNUNET_NO); | 194 | GNUNET_NO); |
195 | GAS_addresses_destroy (&m->peer, | 195 | GAS_addresses_destroy(&m->peer, |
196 | ntohl (m->session_id)); | 196 | ntohl(m->session_id)); |
197 | env = GNUNET_MQ_msg (srm, | 197 | env = GNUNET_MQ_msg(srm, |
198 | GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE); | 198 | GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE); |
199 | srm->session_id = m->session_id; | 199 | srm->session_id = m->session_id; |
200 | srm->peer = m->peer; | 200 | srm->peer = m->peer; |
201 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (my_client), | 201 | GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(my_client), |
202 | env); | 202 | env); |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||