/*
This file is part of GNUnet.
- (C) 2007, 2008, 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
+ (C) 2007, 2008, 2009, 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
* @param addrlen actual lenght of the address
*/
typedef void (*GNUNET_NAT_AddressCallback) (void *cls, int add_remove,
- const struct sockaddr * addr,
+ const struct sockaddr *addr,
socklen_t addrlen);
* @param addrlen actual lenght of the address
*/
typedef void (*GNUNET_NAT_ReversalCallback) (void *cls,
- const struct sockaddr * addr,
+ 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,
+ const struct sockaddr **addrs, const socklen_t *addrlens,
GNUNET_NAT_AddressCallback address_callback,
GNUNET_NAT_ReversalCallback reversal_callback,
void *callback_cls);
*
* @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);
*
* @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);
* 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
* 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);
+/**
+ * Handle to auto-configuration in progress.
+ */
+struct GNUNET_NAT_AutoHandle;
+
+
+/**
+ * Function called with the result from the autoconfiguration.
+ *
+ * @param cls closure
+ * @param diff minimal suggested changes to the original configuration
+ * to make it work (as best as we can)
+ */
+typedef void (*GNUNET_NAT_AutoResultCallback)(void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *diff);
+
+
+/**
+ * Start auto-configuration routine. The resolver service should
+ * be available when this function is called.
+ *
+ * @param cfg initial configuration
+ * @param cb function to call with autoconfiguration result
+ * @param cb_cls closure for cb
+ * @return handle to cancel operation
+ */
+struct GNUNET_NAT_AutoHandle *
+GNUNET_NAT_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ GNUNET_NAT_AutoResultCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Abort autoconfiguration.
+ *
+ * @param ah handle for operation to abort
+ */
+void
+GNUNET_NAT_autoconfig_cancel (struct GNUNET_NAT_AutoHandle *ah);
+
#endif
/* end of gnunet_nat_lib.h */