aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-communicator-unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-communicator-unix.c')
-rw-r--r--src/transport/gnunet-communicator-unix.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/transport/gnunet-communicator-unix.c b/src/transport/gnunet-communicator-unix.c
index 2879b1738..cd3ae5dce 100644
--- a/src/transport/gnunet-communicator-unix.c
+++ b/src/transport/gnunet-communicator-unix.c
@@ -41,9 +41,14 @@
41#define DEFAULT_MAX_QUEUE_LENGTH 8 41#define DEFAULT_MAX_QUEUE_LENGTH 8
42 42
43/** 43/**
44 * Name of the communicator. 44 * Address prefix used by the communicator.
45 */ 45 */
46#define COMMUNICATOR_NAME "unix" 46#define COMMUNICATOR_ADDRESS_PREFIX "unix"
47
48/**
49 * Configuration section used by the communicator.
50 */
51#define COMMUNICATOR_CONFIG_SECTION "communicator-unix"
47 52
48 53
49GNUNET_NETWORK_STRUCT_BEGIN 54GNUNET_NETWORK_STRUCT_BEGIN
@@ -656,12 +661,12 @@ setup_queue (const struct GNUNET_PeerIdentity *target,
656 if ('\0' == un->sun_path[0]) 661 if ('\0' == un->sun_path[0])
657 GNUNET_asprintf (&foreign_addr, 662 GNUNET_asprintf (&foreign_addr,
658 "%s-@%s", 663 "%s-@%s",
659 COMMUNICATOR_NAME, 664 COMMUNICATOR_ADDRESS_PREFIX,
660 &un->sun_path[1]); 665 &un->sun_path[1]);
661 else 666 else
662 GNUNET_asprintf (&foreign_addr, 667 GNUNET_asprintf (&foreign_addr,
663 "%s-%s", 668 "%s-%s",
664 COMMUNICATOR_NAME, 669 COMMUNICATOR_ADDRESS_PREFIX,
665 un->sun_path); 670 un->sun_path);
666 queue->qh 671 queue->qh
667 = GNUNET_TRANSPORT_communicator_mq_add (ch, 672 = GNUNET_TRANSPORT_communicator_mq_add (ch,
@@ -855,13 +860,13 @@ mq_init (void *cls,
855 socklen_t un_len; 860 socklen_t un_len;
856 861
857 if (0 != strncmp (address, 862 if (0 != strncmp (address,
858 COMMUNICATOR_NAME "-", 863 COMMUNICATOR_ADDRESS_PREFIX "-",
859 strlen (COMMUNICATOR_NAME "-"))) 864 strlen (COMMUNICATOR_ADDRESS_PREFIX "-")))
860 { 865 {
861 GNUNET_break_op (0); 866 GNUNET_break_op (0);
862 return GNUNET_SYSERR; 867 return GNUNET_SYSERR;
863 } 868 }
864 path = &address[strlen (COMMUNICATOR_NAME "-")]; 869 path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")];
865 un = unix_address_to_sockaddr (path, 870 un = unix_address_to_sockaddr (path,
866 &un_len); 871 &un_len);
867 queue = lookup_queue (peer, 872 queue = lookup_queue (peer,
@@ -983,18 +988,18 @@ run (void *cls,
983 988
984 if (GNUNET_OK != 989 if (GNUNET_OK !=
985 GNUNET_CONFIGURATION_get_value_filename (cfg, 990 GNUNET_CONFIGURATION_get_value_filename (cfg,
986 "communicator-unix", 991 COMMUNICATOR_CONFIG_SECTION,
987 "UNIXPATH", 992 "UNIXPATH",
988 &unix_socket_path)) 993 &unix_socket_path))
989 { 994 {
990 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 995 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
991 "communicator-unix", 996 COMMUNICATOR_CONFIG_SECTION,
992 "UNIXPATH"); 997 "UNIXPATH");
993 return; 998 return;
994 } 999 }
995 if (GNUNET_OK != 1000 if (GNUNET_OK !=
996 GNUNET_CONFIGURATION_get_value_number (cfg, 1001 GNUNET_CONFIGURATION_get_value_number (cfg,
997 "communicator-unix", 1002 COMMUNICATOR_CONFIG_SECTION,
998 "MAX_QUEUE_LENGTH", 1003 "MAX_QUEUE_LENGTH",
999 &max_queue_length)) 1004 &max_queue_length))
1000 max_queue_length = DEFAULT_MAX_QUEUE_LENGTH; 1005 max_queue_length = DEFAULT_MAX_QUEUE_LENGTH;
@@ -1062,7 +1067,8 @@ run (void *cls,
1062 queue_map = GNUNET_CONTAINER_multipeermap_create (10, 1067 queue_map = GNUNET_CONTAINER_multipeermap_create (10,
1063 GNUNET_NO); 1068 GNUNET_NO);
1064 ch = GNUNET_TRANSPORT_communicator_connect (cfg, 1069 ch = GNUNET_TRANSPORT_communicator_connect (cfg,
1065 COMMUNICATOR_NAME, 1070 COMMUNICATOR_CONFIG_SECTION,
1071 COMMUNICATOR_ADDRESS_PREFIX,
1066 65535, 1072 65535,
1067 &mq_init, 1073 &mq_init,
1068 NULL); 1074 NULL);
@@ -1075,7 +1081,7 @@ run (void *cls,
1075 } 1081 }
1076 GNUNET_asprintf (&my_addr, 1082 GNUNET_asprintf (&my_addr,
1077 "%s-%s", 1083 "%s-%s",
1078 COMMUNICATOR_NAME, 1084 COMMUNICATOR_ADDRESS_PREFIX,
1079 unix_socket_path); 1085 unix_socket_path);
1080 ai = GNUNET_TRANSPORT_communicator_address_add (ch, 1086 ai = GNUNET_TRANSPORT_communicator_address_add (ch,
1081 my_addr, 1087 my_addr,