From: Matthias Wachs Date: Thu, 29 Mar 2012 13:18:50 +0000 (+0000) Subject: - mantis 2207 + docu X-Git-Tag: initial-import-from-subversion-38251~14060 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a8c8084c4930be5ffd458f2fdda98f98b501e3df;p=oweals%2Fgnunet.git - mantis 2207 + docu --- 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, * @param cls closure ('struct Plugin*') * @param addr string address * @param addrlen length of the address - * @param buf location to store a buffer pointer - * If the function returns GNUNET_SYSERR, its contents are undefined. - * @param max size of the buffer - * @param buf_len location to store buffer size. + * @param buf location to store the buffer * If the function returns GNUNET_SYSERR, its contents are undefined. + * @param added length of created address * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ typedef 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 @@ -978,6 +978,42 @@ unix_plugin_address_pretty_printer (void *cls, const char *type, } +/** + * Function called to convert a string address to + * a binary address. + * + * @param cls closure ('struct Plugin*') + * @param addr string address + * @param addrlen length of the address + * @param buf location to store the buffer + * If the function returns GNUNET_SYSERR, its contents are undefined. + * @param added length of created address + * @return GNUNET_OK on success, GNUNET_SYSERR on failure + */ +int +unix_string_to_address (void *cls, const char *addr, uint16_t addrlen, + void **buf, size_t *added) +{ + if ((NULL == addr) || (addrlen == 0)) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + + if ((strlen (addr) + 1) != addrlen) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + + (*buf) = strdup (addr); + (*added) = strlen (addr) + 1; + return GNUNET_OK; +} + + + + /** * Function called for a quick conversion of the binary address to * a numeric address. Note that the caller must not free the @@ -1058,10 +1094,13 @@ libgnunet_plugin_transport_unix_init (void *cls) api->address_pretty_printer = &unix_plugin_address_pretty_printer; api->address_to_string = &unix_address_to_string; api->check_address = &unix_check_address; + api->string_to_address = &unix_string_to_address; sockets_created = unix_transport_server_start (plugin); if (sockets_created == 0) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to open UNIX sockets\n")); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("UNIX\n")); + plugin->session_map = GNUNET_CONTAINER_multihashmap_create(10); GNUNET_SCHEDULER_add_now (address_notification, plugin);