* @param addr either the previous or the new public IP address
* @param addrlen actual lenght of the address
*/
-typedef void (*GNUNET_NAT_AddressCallback) (void *cls,
- int add_remove,
- const struct sockaddr *addr,
+typedef void (*GNUNET_NAT_AddressCallback) (void *cls, int add_remove,
+ const struct sockaddr * addr,
socklen_t addrlen);
* @param addr public IP address of the other peer
* @param addrlen actual lenght of the address
*/
-typedef void (*GNUNET_NAT_ReversalCallback) (void *cls,
- const struct sockaddr *addr,
- socklen_t addrlen);
+typedef void (*GNUNET_NAT_ReversalCallback) (void *cls,
+ const struct sockaddr * addr,
+ socklen_t addrlen);
/**
* @param reversal_callback function to call if someone wants connection reversal from us,
* NULL if connection reversal is not supported
* @param callback_cls closure for callback
- * @return NULL on error, otherwise handle that can be used to unregister
+ * @return NULL on error, otherwise handle that can be used to unregister
*/
struct GNUNET_NAT_Handle *
-GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
- int is_tcp,
- uint16_t adv_port,
- unsigned int num_addrs,
- const struct sockaddr **addrs,
- const socklen_t *addrlens,
- GNUNET_NAT_AddressCallback address_callback,
- GNUNET_NAT_ReversalCallback reversal_callback,
- void *callback_cls);
+GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, int is_tcp,
+ uint16_t adv_port, unsigned int num_addrs,
+ const struct sockaddr **addrs, const socklen_t * addrlens,
+ GNUNET_NAT_AddressCallback address_callback,
+ GNUNET_NAT_ReversalCallback reversal_callback,
+ void *callback_cls);
/**
* GNUNET_SYSERR if the address is malformed
*/
int
-GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h,
- const void *addr,
- socklen_t addrlen);
+GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h, const void *addr,
+ socklen_t addrlen);
/**
*
* @param h handle (used for configuration)
* @param sa the address of the peer (IPv4-only)
+ *
+ * @return GNUNET_SYSERR on error, GNUNET_NO if nat client is disabled,
+ * GNUNET_OK otherwise
*/
-void
+int
GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h,
- const struct sockaddr_in *sa);
+ const struct sockaddr_in *sa);
*
* @param h the handle to stop
*/
-void
+void
GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h);
*
* @param cls closure
* @param success GNUNET_OK on success, GNUNET_NO on failure,
- * GNUNET_SYSERR if the test could not be
+ * GNUNET_SYSERR if the test could not be
* properly started (internal failure)
*/
-typedef void (*GNUNET_NAT_TestCallback)(void *cls,
- int success);
+typedef void (*GNUNET_NAT_TestCallback) (void *cls, int success);
/**
* Start testing if NAT traversal works using the
*/
struct GNUNET_NAT_Test *
GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
- int is_tcp,
- uint16_t bnd_port,
- uint16_t adv_port,
- GNUNET_NAT_TestCallback report,
- void *report_cls);
+ int is_tcp, uint16_t bnd_port, uint16_t adv_port,
+ GNUNET_NAT_TestCallback report, void *report_cls);
/**
GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst);
+/**
+ * Signature of a callback that is given an IP address.
+ *
+ * @param cls closure
+ * @param addr the address, NULL on errors
+ */
+typedef void (*GNUNET_NAT_IPCallback) (void *cls, const struct in_addr * addr);
+
+
+
+/**
+ * Opaque handle to cancel "GNUNET_NAT_mini_get_external_ipv4" operation.
+ */
+struct GNUNET_NAT_ExternalHandle;
+
/**
* Try to get the external IPv4 address of this peer.
- * Note: calling this function may block this process
- * for a few seconds (!).
*
- * @param addr address to set
- * @return GNUNET_OK on success,
- * GNUNET_NO if the result is questionable,
- * GNUNET_SYSERR on error
+ * @param timeout when to fail
+ * @param cb function to call with result
+ * @param cb_cls closure for 'cb'
+ * @return handle for cancellation (can only be used until 'cb' is called), NULL on error
*/
-int
-GNUNET_NAT_mini_get_external_ipv4 (struct in_addr *addr);
+struct GNUNET_NAT_ExternalHandle *
+GNUNET_NAT_mini_get_external_ipv4 (struct GNUNET_TIME_Relative timeout,
+ GNUNET_NAT_IPCallback cb, void *cb_cls);
+
+
+/**
+ * Cancel operation.
+ *
+ * @param eh operation to cancel
+ */
+void
+GNUNET_NAT_mini_get_external_ipv4_cancel (struct GNUNET_NAT_ExternalHandle *eh);
/**
* Handle to a mapping created with upnpc.
- */
+ */
struct GNUNET_NAT_MiniHandle;
* general-purpose 'GNUNET_NAT_register' code). However, it can be
* used if specifically UPnP-based NAT traversal is to be used or
* tested.
- *
+ *
* @param port port to map
* @param is_tcp GNUNET_YES to map TCP, GNUNET_NO for UDP
* @param ac function to call with mapping result
* @return NULL on error
*/
struct GNUNET_NAT_MiniHandle *
-GNUNET_NAT_mini_map_start (uint16_t port,
- int is_tcp,
- GNUNET_NAT_AddressCallback ac,
- void *ac_cls);
+GNUNET_NAT_mini_map_start (uint16_t port, int is_tcp,
+ GNUNET_NAT_AddressCallback ac, void *ac_cls);
/**
* this function will give 'upnpc' 1s to remove tha mapping,
* so while this function is non-blocking, a task will be
* left with the scheduler for up to 1s past this call.
- *
+ *
* @param mini the handle
*/
void
GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini);
-#endif
+#endif
/* end of gnunet_nat_lib.h */