aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_clients.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-12-09 14:29:39 +0000
committerChristian Grothoff <christian@grothoff.org>2013-12-09 14:29:39 +0000
commit8efe79dfadceb61f752a08e2fc8c09f9fbe2ad4e (patch)
tree0c8b1bcd6af51d933dce452e1c1a082def2852b0 /src/transport/gnunet-service-transport_clients.c
parenta3f96148ee0ac38d3a94a136f05285bbfe98db31 (diff)
downloadgnunet-8efe79dfadceb61f752a08e2fc8c09f9fbe2ad4e.tar.gz
gnunet-8efe79dfadceb61f752a08e2fc8c09f9fbe2ad4e.zip
-doxygen, indentation fixes
Diffstat (limited to 'src/transport/gnunet-service-transport_clients.c')
-rw-r--r--src/transport/gnunet-service-transport_clients.c88
1 files changed, 43 insertions, 45 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c
index 93101fc86..c3ef42652 100644
--- a/src/transport/gnunet-service-transport_clients.c
+++ b/src/transport/gnunet-service-transport_clients.c
@@ -201,7 +201,7 @@ static struct MonitoringClient *monitoring_clients_tail;
201 * Notification context, to send updates on changes to active addresses 201 * Notification context, to send updates on changes to active addresses
202 * of our neighbours. 202 * of our neighbours.
203 */ 203 */
204struct GNUNET_SERVER_NotificationContext *nc = NULL; 204static struct GNUNET_SERVER_NotificationContext *nc;
205 205
206 206
207/** 207/**
@@ -215,13 +215,9 @@ lookup_client (struct GNUNET_SERVER_Client *client)
215{ 215{
216 struct TransportClient *tc; 216 struct TransportClient *tc;
217 217
218 tc = clients_head; 218 for (tc = clients_head; NULL != tc; tc = tc->next)
219 while (tc != NULL)
220 {
221 if (tc->client == client) 219 if (tc->client == client)
222 return tc; 220 return tc;
223 tc = tc->next;
224 }
225 return NULL; 221 return NULL;
226} 222}
227 223
@@ -237,10 +233,12 @@ setup_client (struct GNUNET_SERVER_Client *client)
237{ 233{
238 struct TransportClient *tc; 234 struct TransportClient *tc;
239 235
240 GNUNET_assert (lookup_client (client) == NULL); 236 GNUNET_assert (NULL == lookup_client (client));
241 tc = GNUNET_malloc (sizeof (struct TransportClient)); 237 tc = GNUNET_new (struct TransportClient);
242 tc->client = client; 238 tc->client = client;
243 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc); 239 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
240 "Client %p connected\n",
241 tc);
244 return tc; 242 return tc;
245} 243}
246 244
@@ -257,13 +255,9 @@ lookup_monitoring_client (struct GNUNET_SERVER_Client *client)
257{ 255{
258 struct MonitoringClient *mc; 256 struct MonitoringClient *mc;
259 257
260 mc = monitoring_clients_head; 258 for (mc = monitoring_clients_head; NULL != mc; mc = mc->next)
261 while (mc != NULL)
262 {
263 if (mc->client == client) 259 if (mc->client == client)
264 return mc; 260 return mc;
265 mc = mc->next;
266 }
267 return NULL; 261 return NULL;
268} 262}
269 263
@@ -285,7 +279,7 @@ setup_monitoring_client (struct GNUNET_SERVER_Client *client,
285 static struct GNUNET_PeerIdentity all_zeros; 279 static struct GNUNET_PeerIdentity all_zeros;
286 280
287 GNUNET_assert (lookup_monitoring_client (client) == NULL); 281 GNUNET_assert (lookup_monitoring_client (client) == NULL);
288 mc = GNUNET_malloc (sizeof (struct MonitoringClient)); 282 mc = GNUNET_new (struct MonitoringClient);
289 mc->client = client; 283 mc->client = client;
290 mc->peer = *peer; 284 mc->peer = *peer;
291 GNUNET_CONTAINER_DLL_insert (monitoring_clients_head, 285 GNUNET_CONTAINER_DLL_insert (monitoring_clients_head,
@@ -310,9 +304,9 @@ setup_monitoring_client (struct GNUNET_SERVER_Client *client,
310 * was closed for writing in the meantime. 304 * was closed for writing in the meantime.
311 * 305 *
312 * @param cls closure 306 * @param cls closure
313 * @param size number of bytes available in buf 307 * @param size number of bytes available in @a buf
314 * @param buf where the callee should write the message 308 * @param buf where the callee should write the message
315 * @return number of bytes written to buf 309 * @return number of bytes written to @a buf
316 */ 310 */
317static size_t 311static size_t
318transmit_to_client_callback (void *cls, size_t size, void *buf) 312transmit_to_client_callback (void *cls, size_t size, void *buf)
@@ -325,7 +319,7 @@ transmit_to_client_callback (void *cls, size_t size, void *buf)
325 size_t tsize; 319 size_t tsize;
326 320
327 tc->th = NULL; 321 tc->th = NULL;
328 if (buf == NULL) 322 if (NULL == buf)
329 { 323 {
330 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 324 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
331 "Transmission to client failed, closing connection.\n"); 325 "Transmission to client failed, closing connection.\n");
@@ -342,7 +336,8 @@ transmit_to_client_callback (void *cls, size_t size, void *buf)
342 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 336 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
343 "Transmitting message of type %u to client %p.\n", 337 "Transmitting message of type %u to client %p.\n",
344 ntohs (msg->type), tc); 338 ntohs (msg->type), tc);
345 GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, tc->message_queue_tail, 339 GNUNET_CONTAINER_DLL_remove (tc->message_queue_head,
340 tc->message_queue_tail,
346 q); 341 q);
347 tc->message_count--; 342 tc->message_count--;
348 memcpy (&cbuf[tsize], msg, msize); 343 memcpy (&cbuf[tsize], msg, msize);
@@ -356,7 +351,7 @@ transmit_to_client_callback (void *cls, size_t size, void *buf)
356 GNUNET_SERVER_notify_transmit_ready (tc->client, msize, 351 GNUNET_SERVER_notify_transmit_ready (tc->client, msize,
357 GNUNET_TIME_UNIT_FOREVER_REL, 352 GNUNET_TIME_UNIT_FOREVER_REL,
358 &transmit_to_client_callback, tc); 353 &transmit_to_client_callback, tc);
359 GNUNET_assert (tc->th != NULL); 354 GNUNET_assert (NULL != tc->th);
360 } 355 }
361 return tsize; 356 return tsize;
362} 357}
@@ -367,16 +362,17 @@ transmit_to_client_callback (void *cls, size_t size, void *buf)
367 * 362 *
368 * @param tc target of the message 363 * @param tc target of the message
369 * @param msg message to transmit 364 * @param msg message to transmit
370 * @param may_drop GNUNET_YES if the message can be dropped 365 * @param may_drop #GNUNET_YES if the message can be dropped
371 */ 366 */
372static void 367static void
373unicast (struct TransportClient *tc, const struct GNUNET_MessageHeader *msg, 368unicast (struct TransportClient *tc,
369 const struct GNUNET_MessageHeader *msg,
374 int may_drop) 370 int may_drop)
375{ 371{
376 struct ClientMessageQueueEntry *q; 372 struct ClientMessageQueueEntry *q;
377 uint16_t msize; 373 uint16_t msize;
378 374
379 if (msg == NULL) 375 if (NULL == msg)
380 { 376 {
381 GNUNET_break (0); 377 GNUNET_break (0);
382 return; 378 return;
@@ -402,13 +398,13 @@ unicast (struct TransportClient *tc, const struct GNUNET_MessageHeader *msg,
402 GNUNET_CONTAINER_DLL_insert_tail (tc->message_queue_head, 398 GNUNET_CONTAINER_DLL_insert_tail (tc->message_queue_head,
403 tc->message_queue_tail, q); 399 tc->message_queue_tail, q);
404 tc->message_count++; 400 tc->message_count++;
405 if (tc->th != NULL) 401 if (NULL != tc->th)
406 return; 402 return;
407 tc->th = 403 tc->th =
408 GNUNET_SERVER_notify_transmit_ready (tc->client, msize, 404 GNUNET_SERVER_notify_transmit_ready (tc->client, msize,
409 GNUNET_TIME_UNIT_FOREVER_REL, 405 GNUNET_TIME_UNIT_FOREVER_REL,
410 &transmit_to_client_callback, tc); 406 &transmit_to_client_callback, tc);
411 GNUNET_assert (tc->th != NULL); 407 GNUNET_assert (NULL != tc->th);
412} 408}
413 409
414 410
@@ -585,13 +581,14 @@ struct SendTransmitContinuationContext
585 * OK to send the next message. 581 * OK to send the next message.
586 * 582 *
587 * @param cls closure 583 * @param cls closure
588 * @param success GNUNET_OK on success, GNUNET_NO on failure, GNUNET_SYSERR if we're not connected 584 * @param success #GNUNET_OK on success, #GNUNET_NO on failure, #GNUNET_SYSERR if we're not connected
589 * @param bytes_payload bytes payload sent 585 * @param bytes_payload bytes payload sent
590 * @param bytes_on_wire bytes sent on wire 586 * @param bytes_on_wire bytes sent on wire
591 */ 587 */
592static void 588static void
593handle_send_transmit_continuation (void *cls, int success, 589handle_send_transmit_continuation (void *cls, int success,
594 size_t bytes_payload, size_t bytes_on_wire) 590 size_t bytes_payload,
591 size_t bytes_on_wire)
595{ 592{
596 struct SendTransmitContinuationContext *stcc = cls; 593 struct SendTransmitContinuationContext *stcc = cls;
597 struct SendOkMessage send_ok_msg; 594 struct SendOkMessage send_ok_msg;
@@ -621,7 +618,8 @@ handle_send_transmit_continuation (void *cls, int success,
621 * @param message the send message that was sent 618 * @param message the send message that was sent
622 */ 619 */
623static void 620static void
624clients_handle_send (void *cls, struct GNUNET_SERVER_Client *client, 621clients_handle_send (void *cls,
622 struct GNUNET_SERVER_Client *client,
625 const struct GNUNET_MessageHeader *message) 623 const struct GNUNET_MessageHeader *message)
626{ 624{
627 const struct OutboundMessage *obm; 625 const struct OutboundMessage *obm;
@@ -660,7 +658,10 @@ clients_handle_send (void *cls, struct GNUNET_SERVER_Client *client,
660 658
661 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 659 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
662 "Received `%s' request from client with target `%4s' and first message of type %u and total size %u\n", 660 "Received `%s' request from client with target `%4s' and first message of type %u and total size %u\n",
663 "SEND", GNUNET_i2s (&obm->peer), ntohs (obmm->type), msize); 661 "SEND",
662 GNUNET_i2s (&obm->peer),
663 ntohs (obmm->type),
664 msize);
664 if (GNUNET_NO == GST_neighbours_test_connected (&obm->peer)) 665 if (GNUNET_NO == GST_neighbours_test_connected (&obm->peer))
665 { 666 {
666 /* not connected, not allowed to send; can happen due to asynchronous operations */ 667 /* not connected, not allowed to send; can happen due to asynchronous operations */
@@ -691,11 +692,12 @@ clients_handle_send (void *cls, struct GNUNET_SERVER_Client *client,
691 * 692 *
692 * @param cls closure (unused, NULL) 693 * @param cls closure (unused, NULL)
693 * @param peer identity of peer that was tested 694 * @param peer identity of peer that was tested
694 * @param result GNUNET_OK if the connection is allowed, 695 * @param result #GNUNET_OK if the connection is allowed,
695 * GNUNET_NO if not 696 * #GNUNET_NO if not
696 */ 697 */
697static void 698static void
698try_connect_if_allowed (void *cls, const struct GNUNET_PeerIdentity *peer, 699try_connect_if_allowed (void *cls,
700 const struct GNUNET_PeerIdentity *peer,
699 int result) 701 int result)
700{ 702{
701 if (GNUNET_OK != result) 703 if (GNUNET_OK != result)
@@ -832,7 +834,7 @@ clients_handle_address_to_string (void *cls,
832 GNUNET_SERVER_transmit_context_run (tc, rtimeout); 834 GNUNET_SERVER_transmit_context_run (tc, rtimeout);
833 return; 835 return;
834 } 836 }
835 actx = GNUNET_malloc (sizeof (struct AddressToStringContext)); 837 actx = GNUNET_new (struct AddressToStringContext);
836 actx->tc = tc; 838 actx->tc = tc;
837 GNUNET_CONTAINER_DLL_insert (a2s_head, a2s_tail, actx); 839 GNUNET_CONTAINER_DLL_insert (a2s_head, a2s_tail, actx);
838 GNUNET_SERVER_disable_receive_done_warning (client); 840 GNUNET_SERVER_disable_receive_done_warning (client);
@@ -850,10 +852,8 @@ clients_handle_address_to_string (void *cls,
850 * @return composed message 852 * @return composed message
851 */ 853 */
852static struct AddressIterateResponseMessage * 854static struct AddressIterateResponseMessage *
853compose_address_iterate_response_message (const struct GNUNET_PeerIdentity 855compose_address_iterate_response_message (const struct GNUNET_PeerIdentity *peer,
854 *peer, 856 const struct GNUNET_HELLO_Address *address)
855 const struct GNUNET_HELLO_Address
856 *address)
857{ 857{
858 struct AddressIterateResponseMessage *msg; 858 struct AddressIterateResponseMessage *msg;
859 size_t size; 859 size_t size;
@@ -1032,7 +1032,6 @@ GST_clients_stop ()
1032 GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, cur); 1032 GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, cur);
1033 GNUNET_free (cur); 1033 GNUNET_free (cur);
1034 } 1034 }
1035
1036 if (NULL != nc) 1035 if (NULL != nc)
1037 { 1036 {
1038 GNUNET_SERVER_notification_context_destroy (nc); 1037 GNUNET_SERVER_notification_context_destroy (nc);
@@ -1040,18 +1039,19 @@ GST_clients_stop ()
1040 } 1039 }
1041} 1040}
1042 1041
1042
1043/** 1043/**
1044 * Broadcast the given message to all of our clients. 1044 * Broadcast the given message to all of our clients.
1045 * 1045 *
1046 * @param msg message to broadcast 1046 * @param msg message to broadcast
1047 * @param may_drop GNUNET_YES if the message can be dropped / is payload 1047 * @param may_drop #GNUNET_YES if the message can be dropped / is payload
1048 */ 1048 */
1049void 1049void
1050GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop) 1050GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop)
1051{ 1051{
1052 struct TransportClient *tc; 1052 struct TransportClient *tc;
1053 1053
1054 for (tc = clients_head; tc != NULL; tc = tc->next) 1054 for (tc = clients_head; NULL != tc; tc = tc->next)
1055 { 1055 {
1056 if ((GNUNET_YES == may_drop) && (GNUNET_YES != tc->send_payload)) 1056 if ((GNUNET_YES == may_drop) && (GNUNET_YES != tc->send_payload))
1057 continue; /* skip, this client does not care about payload */ 1057 continue; /* skip, this client does not care about payload */
@@ -1065,7 +1065,7 @@ GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop)
1065 * 1065 *
1066 * @param client target of the message 1066 * @param client target of the message
1067 * @param msg message to transmit 1067 * @param msg message to transmit
1068 * @param may_drop GNUNET_YES if the message can be dropped 1068 * @param may_drop #GNUNET_YES if the message can be dropped
1069 */ 1069 */
1070void 1070void
1071GST_clients_unicast (struct GNUNET_SERVER_Client *client, 1071GST_clients_unicast (struct GNUNET_SERVER_Client *client,
@@ -1087,10 +1087,8 @@ GST_clients_unicast (struct GNUNET_SERVER_Client *client,
1087 * @param address address, NULL on disconnect 1087 * @param address address, NULL on disconnect
1088 */ 1088 */
1089void 1089void
1090GST_clients_broadcast_address_notification (const struct GNUNET_PeerIdentity 1090GST_clients_broadcast_address_notification (const struct GNUNET_PeerIdentity *peer,
1091 *peer, 1091 const struct GNUNET_HELLO_Address *address)
1092 const struct GNUNET_HELLO_Address
1093 *address)
1094{ 1092{
1095 struct AddressIterateResponseMessage *msg; 1093 struct AddressIterateResponseMessage *msg;
1096 struct MonitoringClient *mc; 1094 struct MonitoringClient *mc;