-enable peer API to return pointer to interned peer hash code
[oweals/gnunet.git] / src / include / gnunet_network_lib.h
index 65b2042d54bcb76cca10d3cf10851d8ced63704f..06a5ce9038021667978c95ba56ab569535317cfb 100644 (file)
@@ -68,11 +68,23 @@ struct GNUNET_NETWORK_FDSet
 };
 
 
-
 #include "gnunet_disk_lib.h"
 #include "gnunet_time_lib.h"
 
 
+/**
+ * Given a unixpath that is too long (larger than UNIX_PATH_MAX),
+ * shorten it to an acceptable length while keeping it unique
+ * and making sure it remains a valid filename (if possible).
+ *
+ * @param unixpath long path, will be freed (or same pointer returned
+ *        with moved 0-termination).
+ * @return shortened unixpath, NULL on error
+ */
+char *
+GNUNET_NETWORK_shorten_unixpath (char *unixpath);
+
+
 /**
  * Accept a new connection on a socket.  Configure it for non-blocking
  * IO and mark it as non-inheritable to child processes (set the
@@ -96,7 +108,7 @@ GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc,
  * @return NULL on error (including not supported on target platform)
  */
 struct GNUNET_NETWORK_Handle *
-GNUNET_NETWORK_socket_box_native (int fd);
+GNUNET_NETWORK_socket_box_native (SOCKTYPE fd);
 
 
 /**
@@ -185,7 +197,7 @@ GNUNET_NETWORK_socket_recvfrom_amount (const struct GNUNET_NETWORK_Handle
 ssize_t
 GNUNET_NETWORK_socket_recvfrom (const struct GNUNET_NETWORK_Handle *desc,
                                 void *buffer, size_t length,
-                                struct sockaddr *src_addr, socklen_t * addrlen);
+                                struct sockaddr *src_addr, socklen_t *addrlen);
 
 
 /**
@@ -320,8 +332,7 @@ GNUNET_NETWORK_fdset_set (struct GNUNET_NETWORK_FDSet *fds,
                           const struct GNUNET_NETWORK_Handle *desc);
 
 
-#ifdef __MINGW32__
-/* TODO: maybe #ifdef WINDOWS? -ndurner */
+#if WINDOWS
 /**
  * Add a W32 file handle to the fd set
  * @param fds fd set
@@ -374,6 +385,26 @@ int
 GNUNET_NETWORK_get_fd (struct GNUNET_NETWORK_Handle *desc);
 
 
+/**
+ * Return the sockaddr for this network handle
+ *
+ * @param desc wrapper to process
+ * @return POSIX file descriptor
+ */
+struct sockaddr*
+GNUNET_NETWORK_get_addr (struct GNUNET_NETWORK_Handle *desc);
+
+
+/**
+ * Return sockaddr length for this network handle
+ *
+ * @param desc wrapper to process
+ * @return socklen_t for sockaddr
+ */
+socklen_t
+GNUNET_NETWORK_get_addrlen (struct GNUNET_NETWORK_Handle *desc);
+
+
 /**
  * Copy a native fd set
  * @param to destination