X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Finclude%2Fgnunet_nat_lib.h;h=93b441849b886abbcd513d2b305bbb86969795a7;hb=6973ade884b8e22e7fcaa51a90d00a8caa2d2fa4;hp=30eb50dd81fe0b8699a801227f2f623fe14f8a66;hpb=6fd3e715cae09fa6e657c96f1c6f9711ee51f42f;p=oweals%2Fgnunet.git diff --git a/src/include/gnunet_nat_lib.h b/src/include/gnunet_nat_lib.h index 30eb50dd8..93b441849 100644 --- a/src/include/gnunet_nat_lib.h +++ b/src/include/gnunet_nat_lib.h @@ -1,6 +1,6 @@ /* 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 @@ -84,19 +84,15 @@ struct GNUNET_NAT_Handle; * @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); +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); /** @@ -109,8 +105,9 @@ struct GNUNET_NAT_Handle *GNUNET_NAT_register (const struct * GNUNET_NO if the address is not plausible, * GNUNET_SYSERR if the address is malformed */ -int GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h, const void *addr, - socklen_t addrlen); +int +GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h, const void *addr, + socklen_t addrlen); /** @@ -120,9 +117,13 @@ int GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h, const void *addr, * * @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 GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h, - const struct sockaddr_in *sa); +int +GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h, + const struct sockaddr_in *sa); @@ -132,7 +133,8 @@ void GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h, * * @param h the handle to stop */ -void GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h); +void +GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h); /** @@ -146,7 +148,7 @@ struct GNUNET_NAT_Test; * * @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); @@ -163,12 +165,10 @@ typedef void (*GNUNET_NAT_TestCallback) (void *cls, int success); * @param report_cls closure for report * @return handle to cancel NAT test */ -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); +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); /** @@ -176,7 +176,8 @@ struct GNUNET_NAT_Test *GNUNET_NAT_test_start (const struct * * @param tst test to stop. */ -void GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst); +void +GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst); /** @@ -203,13 +204,9 @@ struct GNUNET_NAT_ExternalHandle; * @param cb_cls closure for 'cb' * @return handle for cancellation (can only be used until 'cb' is called), NULL on error */ -struct GNUNET_NAT_ExternalHandle *GNUNET_NAT_mini_get_external_ipv4 (struct - GNUNET_TIME_Relative - timeout, - GNUNET_NAT_IPCallback - cb, - void - *cb_cls); +struct GNUNET_NAT_ExternalHandle * +GNUNET_NAT_mini_get_external_ipv4 (struct GNUNET_TIME_Relative timeout, + GNUNET_NAT_IPCallback cb, void *cb_cls); /** @@ -217,8 +214,8 @@ struct GNUNET_NAT_ExternalHandle *GNUNET_NAT_mini_get_external_ipv4 (struct * * @param eh operation to cancel */ -void GNUNET_NAT_mini_get_external_ipv4_cancel (struct GNUNET_NAT_ExternalHandle - *eh); +void +GNUNET_NAT_mini_get_external_ipv4_cancel (struct GNUNET_NAT_ExternalHandle *eh); /** @@ -233,17 +230,16 @@ 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 * @param ac_cls closure for 'ac' * @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); +struct GNUNET_NAT_MiniHandle * +GNUNET_NAT_mini_map_start (uint16_t port, int is_tcp, + GNUNET_NAT_AddressCallback ac, void *ac_cls); /** @@ -251,12 +247,53 @@ struct GNUNET_NAT_MiniHandle *GNUNET_NAT_mini_map_start (uint16_t port, * 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); +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 */