wip
[oweals/gnunet.git] / src / include / gnunet_network_lib.h
index 1c90b6bfdde403eadc19f886db1ceed04683c0cb..34cb7bc32374a37c67976d994555bbd3c718cbc1 100644 (file)
@@ -71,6 +71,16 @@ struct GNUNET_NETWORK_Handle *GNUNET_NETWORK_socket_accept (const struct
                                                             address_len);
 
 
+/**
+ * Box a native socket (and check that it is a socket).
+ *
+ * @param fd socket to box
+ * @return NULL on error (including not supported on target platform)
+ */
+struct GNUNET_NETWORK_Handle *
+GNUNET_NETWORK_socket_box_native (int fd);
+
+
 /**
  * Bind to a connected socket
  *
@@ -189,6 +199,7 @@ int GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
 ssize_t GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle *desc,
                                     const void *buffer, size_t length);
 
+
 /**
  * Send data to a particular destination (always non-blocking).
  * This function only works for UDP sockets.
@@ -260,10 +271,24 @@ void GNUNET_NETWORK_fdset_set (struct GNUNET_NETWORK_FDSet *fds,
                                const struct GNUNET_NETWORK_Handle *desc);
 
 
+#ifdef __MINGW32__
+/* TODO: maybe #ifdef WINDOWS? -ndurner */
+/**
+ * Add a W32 file handle to the fd set
+ * @param fds fd set
+ * @param h the file handle to add
+ */
+void
+GNUNET_NETWORK_fdset_handle_set_native_w32_handle (struct GNUNET_NETWORK_FDSet *fds,
+                                                  HANDLE h);
+#endif
+
+
 /**
  * Check whether a socket is part of the fd set
  * @param fds fd set
  * @param desc socket
+ * @return GNUNET_YES if the socket is in the set
  */
 int GNUNET_NETWORK_fdset_isset (const struct GNUNET_NETWORK_FDSet *fds,
                                 const struct GNUNET_NETWORK_Handle *desc);
@@ -284,10 +309,15 @@ void GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst,
 void GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to,
                                 const struct GNUNET_NETWORK_FDSet *from);
 
-/*
+
+/**
  * Return file descriptor for this network handle
+ *
+ * @param desc wrapper to process
+ * @return POSIX file descriptor
  */
 int GNUNET_NETWORK_get_fd (struct GNUNET_NETWORK_Handle *desc);
+
 /**
  * Copy a native fd set
  * @param to destination
@@ -297,6 +327,29 @@ int GNUNET_NETWORK_get_fd (struct GNUNET_NETWORK_Handle *desc);
 void GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to,
                                        const fd_set * from, int nfds);
 
+
+/**
+ * Set a native fd in a set
+ *
+ * @param to destination
+ * @param nfd native FD to set
+ */
+void GNUNET_NETWORK_fdset_set_native (struct GNUNET_NETWORK_FDSet *to,
+                                     int nfd);
+
+
+/**
+ * Test native fd in a set
+ *
+ * @param to set to test, NULL for empty set
+ * @param nfd native FD to test, -1 for none
+ * @return GNUNET_YES if to contains nfd
+ */
+int 
+GNUNET_NETWORK_fdset_test_native (const struct GNUNET_NETWORK_FDSet *to,
+                                 int nfd);
+
+
 /**
  * Add a file handle to the fd set
  * @param fds fd set