gnunet_nat_auto_service.h (3925B)
1 /* 2 This file is part of GNUnet. 3 Copyright (C) 2007-2017 GNUnet e.V. 4 5 GNUnet is free software: you can redistribute it and/or modify it 6 under the terms of the GNU Affero General Public License as published 7 by the Free Software Foundation, either version 3 of the License, 8 or (at your option) any later version. 9 10 GNUnet is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Affero General Public License for more details. 14 15 You should have received a copy of the GNU Affero General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 SPDX-License-Identifier: AGPL3.0-or-later 19 */ 20 21 /** 22 * @author Christian Grothoff 23 * @author Milan Bouchet-Valat 24 * 25 * @file 26 * Service for testing and autoconfiguration of 27 * NAT traversal functionality 28 * 29 * @defgroup nat NAT library 30 * 31 * @{ 32 */ 33 34 #ifndef GNUNET_NAT_AUTO_SERVICE_H 35 #define GNUNET_NAT_AUTO_SERVICE_H 36 37 38 #include "gnunet_util_lib.h" 39 #include "gnunet_nat_service.h" 40 41 42 /** 43 * Handle to a NAT test. 44 */ 45 struct GNUNET_NAT_AUTO_Test; 46 47 48 /** 49 * Start testing if NAT traversal works using the given configuration. 50 * The transport adapters should be down while using this function. 51 * 52 * @param cfg configuration for the NAT traversal 53 * @param proto protocol to test, i.e. IPPROTO_TCP or IPPROTO_UDP 54 * @param section_name configuration section to use for configuration 55 * @param report function to call with the result of the test 56 * @param report_cls closure for @a report 57 * @return handle to cancel NAT test 58 */ 59 struct GNUNET_NAT_AUTO_Test * 60 GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, 61 uint8_t proto, 62 const char *section_name, 63 GNUNET_NAT_TestCallback report, 64 void *report_cls); 65 66 67 /** 68 * Stop an active NAT test. 69 * 70 * @param tst test to stop. 71 */ 72 void 73 GNUNET_NAT_AUTO_test_stop (struct GNUNET_NAT_AUTO_Test *tst); 74 75 76 /** 77 * Handle to auto-configuration in progress. 78 */ 79 struct GNUNET_NAT_AUTO_AutoHandle; 80 81 82 /** 83 * Converts `enum GNUNET_NAT_StatusCode` to string 84 * 85 * @param err error code to resolve to a string 86 * @return point to a static string containing the error code 87 */ 88 const char * 89 GNUNET_NAT_AUTO_status2string (enum GNUNET_NAT_StatusCode err); 90 91 92 /** 93 * Function called with the result from the autoconfiguration. 94 * 95 * @param cls closure 96 * @param diff minimal suggested changes to the original configuration 97 * to make it work (as best as we can) 98 * @param result #GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code 99 * @param type what the situation of the NAT 100 */ 101 typedef void 102 (*GNUNET_NAT_AUTO_AutoResultCallback)(void *cls, 103 const struct 104 GNUNET_CONFIGURATION_Handle *diff, 105 enum GNUNET_NAT_StatusCode result, 106 enum GNUNET_NAT_Type type); 107 108 109 /** 110 * Start auto-configuration routine. The transport adapters should 111 * be stopped while this function is called. 112 * 113 * @param cfg initial configuration 114 * @param cb function to call with autoconfiguration result 115 * @param cb_cls closure for @a cb 116 * @return handle to cancel operation 117 */ 118 struct GNUNET_NAT_AUTO_AutoHandle * 119 GNUNET_NAT_AUTO_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg, 120 GNUNET_NAT_AUTO_AutoResultCallback cb, 121 void *cb_cls); 122 123 124 /** 125 * Abort autoconfiguration. 126 * 127 * @param ah handle for operation to abort 128 */ 129 void 130 GNUNET_NAT_AUTO_autoconfig_cancel (struct GNUNET_NAT_AUTO_AutoHandle *ah); 131 132 133 #endif 134 135 /** @} */ /* end of group */ 136 137 /* end of gnunet_nat_auto_service.h */