- mantis 2207 + docu
authorMatthias Wachs <wachs@net.in.tum.de>
Thu, 29 Mar 2012 13:18:50 +0000 (13:18 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Thu, 29 Mar 2012 13:18:50 +0000 (13:18 +0000)
src/include/gnunet_transport_plugin.h
src/transport/plugin_transport_unix.c

index d5d587922a7c976629fcbca317b91c2394d15fc8..1e46c92f8c65648aa88536fd27669eeda6db4e57 100644 (file)
@@ -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,
index 51fbcd081df0d77832ed0b1915505a6c9d737f60..fa7783b9eebeb21b19bb64dbe7eb9fafaa43131c 100644 (file)
@@ -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);