aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-service-ats_scheduling.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/ats/gnunet-service-ats_scheduling.c
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/ats/gnunet-service-ats_scheduling.c')
-rw-r--r--src/ats/gnunet-service-ats_scheduling.c145
1 files changed, 74 insertions, 71 deletions
diff --git a/src/ats/gnunet-service-ats_scheduling.c b/src/ats/gnunet-service-ats_scheduling.c
index d50df9b2e..456c222a9 100644
--- a/src/ats/gnunet-service-ats_scheduling.c
+++ b/src/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 */
44int 44int
45GAS_scheduling_add_client(struct GNUNET_SERVICE_Client *client) 45GAS_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 */
64void 64void
65GAS_scheduling_remove_client(struct GNUNET_SERVICE_Client *client) 65GAS_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,36 @@ 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 */
83void 83void
84GAS_scheduling_transmit_address_suggestion(const struct GNUNET_PeerIdentity *peer, 84GAS_scheduling_transmit_address_suggestion (const struct
85 uint32_t session_id, 85 GNUNET_PeerIdentity *peer,
86 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 86 uint32_t session_id,
87 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) 87 struct GNUNET_BANDWIDTH_Value32NBO
88 bandwidth_out,
89 struct GNUNET_BANDWIDTH_Value32NBO
90 bandwidth_in)
88{ 91{
89 struct GNUNET_MQ_Envelope *env; 92 struct GNUNET_MQ_Envelope *env;
90 struct AddressSuggestionMessage *msg; 93 struct AddressSuggestionMessage *msg;
91 94
92 if (NULL == my_client) 95 if (NULL == my_client)
93 return; 96 return;
94 GNUNET_STATISTICS_update(GSA_stats, 97 GNUNET_STATISTICS_update (GSA_stats,
95 "# address suggestions made", 98 "# address suggestions made",
96 1, 99 1,
97 GNUNET_NO); 100 GNUNET_NO);
98 env = GNUNET_MQ_msg(msg, 101 env = GNUNET_MQ_msg (msg,
99 GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION); 102 GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION);
100 msg->peer = *peer; 103 msg->peer = *peer;
101 msg->session_id = htonl(session_id); 104 msg->session_id = htonl (session_id);
102 msg->bandwidth_out = bandwidth_out; 105 msg->bandwidth_out = bandwidth_out;
103 msg->bandwidth_in = bandwidth_in; 106 msg->bandwidth_in = bandwidth_in;
104 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
105 "ATS sends quota for peer `%s': (in/out) %u/%u\n", 108 "ATS sends quota for peer `%s': (in/out) %u/%u\n",
106 GNUNET_i2s(peer), 109 GNUNET_i2s (peer),
107 (unsigned int)ntohl(bandwidth_in.value__), 110 (unsigned int) ntohl (bandwidth_in.value__),
108 (unsigned int)ntohl(bandwidth_out.value__)); 111 (unsigned int) ntohl (bandwidth_out.value__));
109 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(my_client), 112 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (my_client),
110 env); 113 env);
111} 114}
112 115
113 116
@@ -117,7 +120,7 @@ GAS_scheduling_transmit_address_suggestion(const struct GNUNET_PeerIdentity *pee
117 * @param m the request message 120 * @param m the request message
118 */ 121 */
119void 122void
120GAS_handle_address_add(const struct AddressAddMessage *m) 123GAS_handle_address_add (const struct AddressAddMessage *m)
121{ 124{
122 const char *address; 125 const char *address;
123 const char *plugin_name; 126 const char *plugin_name;
@@ -125,30 +128,30 @@ GAS_handle_address_add(const struct AddressAddMessage *m)
125 uint16_t plugin_name_length; 128 uint16_t plugin_name_length;
126 struct GNUNET_ATS_Properties prop; 129 struct GNUNET_ATS_Properties prop;
127 130
128 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 131 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
129 "Received `%s' message\n", 132 "Received `%s' message\n",
130 "ADDRESS_ADD"); 133 "ADDRESS_ADD");
131 address_length = ntohs(m->address_length); 134 address_length = ntohs (m->address_length);
132 plugin_name_length = ntohs(m->plugin_name_length); 135 plugin_name_length = ntohs (m->plugin_name_length);
133 address = (const char *)&m[1]; 136 address = (const char *) &m[1];
134 if (plugin_name_length != 0) 137 if (plugin_name_length != 0)
135 plugin_name = &address[address_length]; 138 plugin_name = &address[address_length];
136 else 139 else
137 plugin_name = ""; 140 plugin_name = "";
138 GNUNET_STATISTICS_update(GSA_stats, 141 GNUNET_STATISTICS_update (GSA_stats,
139 "# addresses created", 142 "# addresses created",
140 1, 143 1,
141 GNUNET_NO); 144 GNUNET_NO);
142 GNUNET_ATS_properties_ntoh(&prop, 145 GNUNET_ATS_properties_ntoh (&prop,
143 &m->properties); 146 &m->properties);
144 GNUNET_break(GNUNET_NT_UNSPECIFIED != prop.scope); 147 GNUNET_break (GNUNET_NT_UNSPECIFIED != prop.scope);
145 GAS_addresses_add(&m->peer, 148 GAS_addresses_add (&m->peer,
146 plugin_name, 149 plugin_name,
147 address, 150 address,
148 address_length, 151 address_length,
149 ntohl(m->address_local_info), 152 ntohl (m->address_local_info),
150 ntohl(m->session_id), 153 ntohl (m->session_id),
151 &prop); 154 &prop);
152} 155}
153 156
154 157
@@ -158,19 +161,19 @@ GAS_handle_address_add(const struct AddressAddMessage *m)
158 * @param m the request message 161 * @param m the request message
159 */ 162 */
160void 163void
161GAS_handle_address_update(const struct AddressUpdateMessage *m) 164GAS_handle_address_update (const struct AddressUpdateMessage *m)
162{ 165{
163 struct GNUNET_ATS_Properties prop; 166 struct GNUNET_ATS_Properties prop;
164 167
165 GNUNET_STATISTICS_update(GSA_stats, 168 GNUNET_STATISTICS_update (GSA_stats,
166 "# address updates received", 169 "# address updates received",
167 1, 170 1,
168 GNUNET_NO); 171 GNUNET_NO);
169 GNUNET_ATS_properties_ntoh(&prop, 172 GNUNET_ATS_properties_ntoh (&prop,
170 &m->properties); 173 &m->properties);
171 GAS_addresses_update(&m->peer, 174 GAS_addresses_update (&m->peer,
172 ntohl(m->session_id), 175 ntohl (m->session_id),
173 &prop); 176 &prop);
174} 177}
175 178
176 179
@@ -180,26 +183,26 @@ GAS_handle_address_update(const struct AddressUpdateMessage *m)
180 * @param m the request message 183 * @param m the request message
181 */ 184 */
182void 185void
183GAS_handle_address_destroyed(const struct AddressDestroyedMessage *m) 186GAS_handle_address_destroyed (const struct AddressDestroyedMessage *m)
184{ 187{
185 struct GNUNET_MQ_Envelope *env; 188 struct GNUNET_MQ_Envelope *env;
186 struct GNUNET_ATS_SessionReleaseMessage *srm; 189 struct GNUNET_ATS_SessionReleaseMessage *srm;
187 190
188 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
189 "Received `%s' message\n", 192 "Received `%s' message\n",
190 "ADDRESS_DESTROYED"); 193 "ADDRESS_DESTROYED");
191 GNUNET_STATISTICS_update(GSA_stats, 194 GNUNET_STATISTICS_update (GSA_stats,
192 "# addresses destroyed", 195 "# addresses destroyed",
193 1, 196 1,
194 GNUNET_NO); 197 GNUNET_NO);
195 GAS_addresses_destroy(&m->peer, 198 GAS_addresses_destroy (&m->peer,
196 ntohl(m->session_id)); 199 ntohl (m->session_id));
197 env = GNUNET_MQ_msg(srm, 200 env = GNUNET_MQ_msg (srm,
198 GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE); 201 GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE);
199 srm->session_id = m->session_id; 202 srm->session_id = m->session_id;
200 srm->peer = m->peer; 203 srm->peer = m->peer;
201 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(my_client), 204 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (my_client),
202 env); 205 env);
203} 206}
204 207
205 208