aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_unix.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/transport/plugin_transport_unix.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/transport/plugin_transport_unix.c')
-rw-r--r--src/transport/plugin_transport_unix.c103
1 files changed, 40 insertions, 63 deletions
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index 22dda8e8b..7193e2e8b 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -419,18 +419,16 @@ find_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *peer)
419} 419}
420 420
421/* Forward Declaration */ 421/* Forward Declaration */
422static ssize_t 422static ssize_t unix_real_send (void *cls,
423unix_real_send (void *cls, 423 struct RetrySendContext *incoming_retry_context,
424 struct RetrySendContext *incoming_retry_context, 424 struct GNUNET_NETWORK_Handle *send_handle,
425 struct GNUNET_NETWORK_Handle *send_handle, 425 const struct GNUNET_PeerIdentity *target,
426 const struct GNUNET_PeerIdentity *target, 426 const char *msgbuf, size_t msgbuf_size,
427 const char *msgbuf, 427 unsigned int priority,
428 size_t msgbuf_size, 428 struct GNUNET_TIME_Relative timeout,
429 unsigned int priority, 429 const void *addr, size_t addrlen,
430 struct GNUNET_TIME_Relative timeout, 430 GNUNET_TRANSPORT_TransmitContinuation cont,
431 const void *addr, 431 void *cont_cls);
432 size_t addrlen,
433 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls);
434 432
435/** 433/**
436 * Retry sending a message. 434 * Retry sending a message.
@@ -451,16 +449,12 @@ retry_send_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
451 return; 449 return;
452 } 450 }
453 451
454 unix_real_send (retry_ctx->plugin, 452 unix_real_send (retry_ctx->plugin, retry_ctx, retry_ctx->send_handle,
455 retry_ctx, 453 &retry_ctx->target, retry_ctx->msg, retry_ctx->msg_size,
456 retry_ctx->send_handle,
457 &retry_ctx->target,
458 retry_ctx->msg,
459 retry_ctx->msg_size,
460 retry_ctx->priority, 454 retry_ctx->priority,
461 GNUNET_TIME_absolute_get_remaining (retry_ctx->timeout), 455 GNUNET_TIME_absolute_get_remaining (retry_ctx->timeout),
462 retry_ctx->addr, 456 retry_ctx->addr, retry_ctx->addrlen, retry_ctx->cont,
463 retry_ctx->addrlen, retry_ctx->cont, retry_ctx->cont_cls); 457 retry_ctx->cont_cls);
464 return; 458 return;
465} 459}
466 460
@@ -487,17 +481,13 @@ retry_send_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
487 * @return the number of bytes written, -1 on errors 481 * @return the number of bytes written, -1 on errors
488 */ 482 */
489static ssize_t 483static ssize_t
490unix_real_send (void *cls, 484unix_real_send (void *cls, struct RetrySendContext *incoming_retry_context,
491 struct RetrySendContext *incoming_retry_context,
492 struct GNUNET_NETWORK_Handle *send_handle, 485 struct GNUNET_NETWORK_Handle *send_handle,
493 const struct GNUNET_PeerIdentity *target, 486 const struct GNUNET_PeerIdentity *target, const char *msgbuf,
494 const char *msgbuf, 487 size_t msgbuf_size, unsigned int priority,
495 size_t msgbuf_size, 488 struct GNUNET_TIME_Relative timeout, const void *addr,
496 unsigned int priority, 489 size_t addrlen, GNUNET_TRANSPORT_TransmitContinuation cont,
497 struct GNUNET_TIME_Relative timeout, 490 void *cont_cls)
498 const void *addr,
499 size_t addrlen,
500 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
501{ 491{
502 struct Plugin *plugin = cls; 492 struct Plugin *plugin = cls;
503 struct UNIXMessage *message; 493 struct UNIXMessage *message;
@@ -635,9 +625,8 @@ unix_real_send (void *cls,
635#if DEBUG_UNIX 625#if DEBUG_UNIX
636 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 626 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
637 "UNIX transmit %u-byte message to %s (%d: %s)\n", 627 "UNIX transmit %u-byte message to %s (%d: %s)\n",
638 (unsigned int) ssize, 628 (unsigned int) ssize, GNUNET_a2s (sb, sbs), (int) sent,
639 GNUNET_a2s (sb, sbs), 629 (sent < 0) ? STRERROR (errno) : "ok");
640 (int) sent, (sent < 0) ? STRERROR (errno) : "ok");
641#endif 630#endif
642 if (cont != NULL) 631 if (cont != NULL)
643 { 632 {
@@ -689,16 +678,10 @@ unix_real_send (void *cls,
689 * still be transmitted later!) 678 * still be transmitted later!)
690 */ 679 */
691static ssize_t 680static ssize_t
692unix_plugin_send (void *cls, 681unix_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
693 const struct GNUNET_PeerIdentity *target, 682 const char *msgbuf, size_t msgbuf_size, unsigned int priority,
694 const char *msgbuf, 683 struct GNUNET_TIME_Relative timeout, struct Session *session,
695 size_t msgbuf_size, 684 const void *addr, size_t addrlen, int force_address,
696 unsigned int priority,
697 struct GNUNET_TIME_Relative timeout,
698 struct Session *session,
699 const void *addr,
700 size_t addrlen,
701 int force_address,
702 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) 685 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
703{ 686{
704 struct Plugin *plugin = cls; 687 struct Plugin *plugin = cls;
@@ -712,12 +695,10 @@ unix_plugin_send (void *cls,
712 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to send message to `%s'\n", 695 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to send message to `%s'\n",
713 (char *) addr); 696 (char *) addr);
714#endif 697#endif
715 sent = unix_real_send (cls, 698 sent =
716 NULL, 699 unix_real_send (cls, NULL, plugin->unix_sock.desc, target, msgbuf,
717 plugin->unix_sock.desc, 700 msgbuf_size, priority, timeout, addr, addrlen, cont,
718 target, 701 cont_cls);
719 msgbuf, msgbuf_size,
720 priority, timeout, addr, addrlen, cont, cont_cls);
721#if DEBUG_UNIX 702#if DEBUG_UNIX
722 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %d bytes to `%s'\n", sent, 703 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %d bytes to `%s'\n", sent,
723 (char *) addr); 704 (char *) addr);
@@ -738,8 +719,7 @@ unix_plugin_send (void *cls,
738 * @param fromlen the length of the address 719 * @param fromlen the length of the address
739 */ 720 */
740static void 721static void
741unix_demultiplexer (struct Plugin *plugin, 722unix_demultiplexer (struct Plugin *plugin, struct GNUNET_PeerIdentity *sender,
742 struct GNUNET_PeerIdentity *sender,
743 const struct GNUNET_MessageHeader *currhdr, 723 const struct GNUNET_MessageHeader *currhdr,
744 const struct sockaddr_un *un, size_t fromlen) 724 const struct sockaddr_un *un, size_t fromlen)
745{ 725{
@@ -909,8 +889,8 @@ unix_transport_server_start (void *cls)
909 return GNUNET_SYSERR; 889 return GNUNET_SYSERR;
910 } 890 }
911#if DEBUG_UNIX 891#if DEBUG_UNIX
912 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, 892 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "unix", "Bound to `%s'\n",
913 "unix", "Bound to `%s'\n", &un.sun_path[0]); 893 &un.sun_path[0]);
914#endif 894#endif
915 plugin->rs = GNUNET_NETWORK_fdset_create (); 895 plugin->rs = GNUNET_NETWORK_fdset_create ();
916 GNUNET_NETWORK_fdset_zero (plugin->rs); 896 GNUNET_NETWORK_fdset_zero (plugin->rs);
@@ -990,10 +970,8 @@ append_port (void *cls, const char *hostname)
990 * @param asc_cls closure for asc 970 * @param asc_cls closure for asc
991 */ 971 */
992static void 972static void
993unix_plugin_address_pretty_printer (void *cls, 973unix_plugin_address_pretty_printer (void *cls, const char *type,
994 const char *type, 974 const void *addr, size_t addrlen,
995 const void *addr,
996 size_t addrlen,
997 int numeric, 975 int numeric,
998 struct GNUNET_TIME_Relative timeout, 976 struct GNUNET_TIME_Relative timeout,
999 GNUNET_TRANSPORT_AddressStringCallback asc, 977 GNUNET_TRANSPORT_AddressStringCallback asc,
@@ -1075,8 +1053,7 @@ address_notification (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1075{ 1053{
1076 struct Plugin *plugin = cls; 1054 struct Plugin *plugin = cls;
1077 1055
1078 plugin->env->notify_address (plugin->env->cls, 1056 plugin->env->notify_address (plugin->env->cls, GNUNET_YES,
1079 GNUNET_YES,
1080 plugin->unix_socket_path, 1057 plugin->unix_socket_path,
1081 strlen (plugin->unix_socket_path) + 1); 1058 strlen (plugin->unix_socket_path) + 1);
1082} 1059}
@@ -1095,14 +1072,14 @@ libgnunet_plugin_transport_unix_init (void *cls)
1095 int sockets_created; 1072 int sockets_created;
1096 1073
1097 if (GNUNET_OK != 1074 if (GNUNET_OK !=
1098 GNUNET_CONFIGURATION_get_value_number (env->cfg, 1075 GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-unix", "PORT",
1099 "transport-unix", "PORT", &port)) 1076 &port))
1100 port = UNIX_NAT_DEFAULT_PORT; 1077 port = UNIX_NAT_DEFAULT_PORT;
1101 plugin = GNUNET_malloc (sizeof (struct Plugin)); 1078 plugin = GNUNET_malloc (sizeof (struct Plugin));
1102 plugin->port = port; 1079 plugin->port = port;
1103 plugin->env = env; 1080 plugin->env = env;
1104 GNUNET_asprintf (&plugin->unix_socket_path, 1081 GNUNET_asprintf (&plugin->unix_socket_path, "/tmp/unix-plugin-sock.%d",
1105 "/tmp/unix-plugin-sock.%d", plugin->port); 1082 plugin->port);
1106 1083
1107 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); 1084 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
1108 api->cls = plugin; 1085 api->cls = plugin;