X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Finclude%2Fgnunet_nat_auto_service.h;h=a369c49e05d3988ecd7ea26aba79d4d8596e750a;hb=7a7ec54a324da4820202582126795a8ac6bbe94d;hp=90115ff8caaf5f2db36aaf91b47ba87b87d66bdc;hpb=c859283e8ccc3a2aa89655698ef5f66793531e16;p=oweals%2Fgnunet.git diff --git a/src/include/gnunet_nat_auto_service.h b/src/include/gnunet_nat_auto_service.h index 90115ff8c..a369c49e0 100644 --- a/src/include/gnunet_nat_auto_service.h +++ b/src/include/gnunet_nat_auto_service.h @@ -35,121 +35,32 @@ #define GNUNET_NAT_AUTO_SERVICE_H #include "gnunet_util_lib.h" +#include "gnunet_nat_service.h" /** * Handle to a NAT test. */ -struct GNUNET_NAT_Test; +struct GNUNET_NAT_AUTO_Test; /** - * Function called to report success or failure for - * NAT configuration test. - * - * @param cls closure - * @param result #GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code - */ -typedef void -(*GNUNET_NAT_TestCallback) (void *cls, - enum GNUNET_NAT_StatusCode result); - - -/** - * Handle an incoming STUN message. This function is useful as - * some GNUnet service may be listening on a UDP port and might - * thus receive STUN messages while trying to receive other data. - * In this case, this function can be used to process replies - * to STUN requests. - * - * The function does some basic sanity checks on packet size and - * content, try to extract a bit of information. - * - * At the moment this only processes BIND requests, and returns the - * externally visible address of the request to the rest of the - * NAT logic. - * - * @param nh handle to the NAT service - * @param sender_addr address from which we got @a data - * @param sender_addr_len number of bytes in @a sender_addr - * @param data the packet - * @param data_size number of bytes in @a data - * @return #GNUNET_OK on success - * #GNUNET_NO if the packet is not a STUN packet - * #GNUNET_SYSERR on internal error handling the packet - */ -int -GNUNET_NAT_stun_handle_packet (struct GNUNET_NAT_Handle *nh, - const struct sockaddr *sender_addr, - size_t sender_addr_len, - const void *data, - size_t data_size); - - -/** - * Handle to a request given to the resolver. Can be used to cancel - * the request prior to the timeout or successful execution. Also - * used to track our internal state for the request. - */ -struct GNUNET_NAT_STUN_Handle; - - -/** - * Make Generic STUN request. Sends a generic stun request to the - * server specified using the specified socket. If we do this, - * we need to watch for possible responses and call - * #GNUNET_NAT_stun_handle_packet() on incoming packets. - * - * @param server the address of the stun server - * @param port port of the stun server, in host byte order - * @param sock the socket used to send the request, must be a - * UDP socket - * @param cb callback in case of error - * @param cb_cls closure for @a cb - * @return NULL on error - */ -struct GNUNET_NAT_STUN_Handle * -GNUNET_NAT_stun_make_request (const char *server, - uint16_t port, - struct GNUNET_NETWORK_Handle *sock, - GNUNET_NAT_TestCallback cb, - void *cb_cls); - - -/** - * Cancel active STUN request. Frees associated resources - * and ensures that the callback is no longer invoked. - * - * @param rh request to cancel - */ -void -GNUNET_NAT_stun_make_request_cancel (struct GNUNET_NAT_STUN_Handle *rh); - - -/** - * Start testing if NAT traversal works using the given configuration - * (IPv4-only). The transport adapters should be down while using - * this function. + * Start testing if NAT traversal works using the given configuration. + * The transport adapters should be down while using this function. * * @param cfg configuration for the NAT traversal * @param proto protocol to test, i.e. IPPROTO_TCP or IPPROTO_UDP - * @param bind_ip IPv4 address to bind to - * @param bnd_port port to bind to, 0 to test connection reversal - * @param extern_ip IPv4 address to externally advertise - * @param extern_port externally advertised port to use + * @param section_name configuration section to use for configuration * @param report function to call with the result of the test * @param report_cls closure for @a report * @return handle to cancel NAT test */ -struct GNUNET_NAT_Test * -GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, - uint8_t proto, - struct in_addr bind_ip, - uint16_t bnd_port, - struct in_addr extern_ip, - uint16_t extern_port, - GNUNET_NAT_TestCallback report, - void *report_cls); +struct GNUNET_NAT_AUTO_Test * +GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, + uint8_t proto, + const char *section_name, + GNUNET_NAT_TestCallback report, + void *report_cls); /** @@ -158,13 +69,13 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, * @param tst test to stop. */ void -GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst); +GNUNET_NAT_AUTO_test_stop (struct GNUNET_NAT_AUTO_Test *tst); /** * Handle to auto-configuration in progress. */ -struct GNUNET_NAT_AutoHandle; +struct GNUNET_NAT_AUTO_AutoHandle; /** @@ -174,7 +85,7 @@ struct GNUNET_NAT_AutoHandle; * @return point to a static string containing the error code */ const char * -GNUNET_NAT_status2string (enum GNUNET_NAT_StatusCode err); +GNUNET_NAT_AUTO_status2string (enum GNUNET_NAT_StatusCode err); /** @@ -187,10 +98,10 @@ GNUNET_NAT_status2string (enum GNUNET_NAT_StatusCode err); * @param type what the situation of the NAT */ typedef void -(*GNUNET_NAT_AutoResultCallback)(void *cls, - const struct GNUNET_CONFIGURATION_Handle *diff, - enum GNUNET_NAT_StatusCode result, - enum GNUNET_NAT_Type type); +(*GNUNET_NAT_AUTO_AutoResultCallback)(void *cls, + const struct GNUNET_CONFIGURATION_Handle *diff, + enum GNUNET_NAT_StatusCode result, + enum GNUNET_NAT_Type type); /** @@ -202,10 +113,10 @@ typedef void * @param cb_cls closure for @a 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); +struct GNUNET_NAT_AUTO_AutoHandle * +GNUNET_NAT_AUTO_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg, + GNUNET_NAT_AUTO_AutoResultCallback cb, + void *cb_cls); /** @@ -214,7 +125,7 @@ GNUNET_NAT_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg, * @param ah handle for operation to abort */ void -GNUNET_NAT_autoconfig_cancel (struct GNUNET_NAT_AutoHandle *ah); +GNUNET_NAT_AUTO_autoconfig_cancel (struct GNUNET_NAT_AUTO_AutoHandle *ah); #endif