aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_transport_plugin.h6
-rw-r--r--src/transport/plugin_transport_unix.c39
2 files changed, 41 insertions, 4 deletions
diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h
index d5d587922..1e46c92f8 100644
--- a/src/include/gnunet_transport_plugin.h
+++ b/src/include/gnunet_transport_plugin.h
@@ -434,11 +434,9 @@ typedef const char *(*GNUNET_TRANSPORT_AddressToString) (void *cls,
434 * @param cls closure ('struct Plugin*') 434 * @param cls closure ('struct Plugin*')
435 * @param addr string address 435 * @param addr string address
436 * @param addrlen length of the address 436 * @param addrlen length of the address
437 * @param buf location to store a buffer pointer 437 * @param buf location to store the buffer
438 * If the function returns GNUNET_SYSERR, its contents are undefined.
439 * @param max size of the buffer
440 * @param buf_len location to store buffer size.
441 * If the function returns GNUNET_SYSERR, its contents are undefined. 438 * If the function returns GNUNET_SYSERR, its contents are undefined.
439 * @param added length of created address
442 * @return GNUNET_OK on success, GNUNET_SYSERR on failure 440 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
443 */ 441 */
444typedef int (*GNUNET_TRANSPORT_StringToAddress) (void *cls, 442typedef int (*GNUNET_TRANSPORT_StringToAddress) (void *cls,
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index 51fbcd081..fa7783b9e 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -979,6 +979,42 @@ unix_plugin_address_pretty_printer (void *cls, const char *type,
979} 979}
980 980
981/** 981/**
982 * Function called to convert a string address to
983 * a binary address.
984 *
985 * @param cls closure ('struct Plugin*')
986 * @param addr string address
987 * @param addrlen length of the address
988 * @param buf location to store the buffer
989 * If the function returns GNUNET_SYSERR, its contents are undefined.
990 * @param added length of created address
991 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
992 */
993int
994unix_string_to_address (void *cls, const char *addr, uint16_t addrlen,
995 void **buf, size_t *added)
996{
997 if ((NULL == addr) || (addrlen == 0))
998 {
999 GNUNET_break (0);
1000 return GNUNET_SYSERR;
1001 }
1002
1003 if ((strlen (addr) + 1) != addrlen)
1004 {
1005 GNUNET_break (0);
1006 return GNUNET_SYSERR;
1007 }
1008
1009 (*buf) = strdup (addr);
1010 (*added) = strlen (addr) + 1;
1011 return GNUNET_OK;
1012}
1013
1014
1015
1016
1017/**
982 * Function called for a quick conversion of the binary address to 1018 * Function called for a quick conversion of the binary address to
983 * a numeric address. Note that the caller must not free the 1019 * a numeric address. Note that the caller must not free the
984 * address and that the next call to this function is allowed 1020 * address and that the next call to this function is allowed
@@ -1058,10 +1094,13 @@ libgnunet_plugin_transport_unix_init (void *cls)
1058 api->address_pretty_printer = &unix_plugin_address_pretty_printer; 1094 api->address_pretty_printer = &unix_plugin_address_pretty_printer;
1059 api->address_to_string = &unix_address_to_string; 1095 api->address_to_string = &unix_address_to_string;
1060 api->check_address = &unix_check_address; 1096 api->check_address = &unix_check_address;
1097 api->string_to_address = &unix_string_to_address;
1061 sockets_created = unix_transport_server_start (plugin); 1098 sockets_created = unix_transport_server_start (plugin);
1062 if (sockets_created == 0) 1099 if (sockets_created == 0)
1063 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to open UNIX sockets\n")); 1100 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to open UNIX sockets\n"));
1064 1101
1102 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("UNIX\n"));
1103
1065 plugin->session_map = GNUNET_CONTAINER_multihashmap_create(10); 1104 plugin->session_map = GNUNET_CONTAINER_multihashmap_create(10);
1066 1105
1067 GNUNET_SCHEDULER_add_now (address_notification, plugin); 1106 GNUNET_SCHEDULER_add_now (address_notification, plugin);