gnunet_testbed_lib.h (4626B)
1 #ifndef GNUNET_TESTBED_LIB_H 2 #define GNUNET_TESTBED_LIB_H 3 4 /** 5 * FIXME. 6 */ 7 struct GNUNET_TESTBED_System; 8 9 #define GNUNET_TESTBED_PREFIX "GNUNET_TESTBED_PREFIX" 10 11 /** 12 * Create a system handle. There must only be one system 13 * handle per operating system. 14 * 15 * @param testdir only the directory name without any path. This is used for 16 * all service homes; the directory will be created in a temporary 17 * location depending on the underlying OS. This variable will be 18 * overridden with the value of the environmental variable 19 * GNUNET_TESTBED_PREFIX, if it exists. 20 * @param trusted_ip the ip address which will be set as TRUSTED HOST in all 21 * service configurations generated to allow control connections from 22 * this ip. This can either be a single ip address or a network address 23 * in CIDR notation. 24 * @param hostname the hostname of the system we are using for testing; NULL for 25 * localhost 26 * @param lowport lowest port number this system is allowed to allocate (inclusive) 27 * @param highport highest port number this system is allowed to allocate (exclusive) 28 * @return handle to this system, NULL on error 29 */ 30 struct GNUNET_TESTBED_System * 31 GNUNET_TESTBED_system_create_with_portrange ( 32 const char *testdir, 33 const char *trusted_ip, 34 const char *hostname, 35 uint16_t lowport, 36 uint16_t highport); 37 38 39 /** 40 * Create a system handle. There must only be one system handle per operating 41 * system. Uses a default range for allowed ports. Ports are still tested for 42 * availability. 43 * 44 * @param testdir only the directory name without any path. This is used for all 45 * service homes; the directory will be created in a temporary location 46 * depending on the underlying OS. This variable will be 47 * overridden with the value of the environmental variable 48 * GNUNET_TESTBED_PREFIX, if it exists. 49 * @param trusted_ip the ip address which will be set as TRUSTED HOST in all 50 * service configurations generated to allow control connections from 51 * this ip. This can either be a single ip address or a network address 52 * in CIDR notation. 53 * @param hostname the hostname of the system we are using for testing; NULL for 54 * localhost 55 * @param shared_services NULL terminated array describing services that are to 56 * be shared among peers 57 * @return handle to this system, NULL on error 58 */ 59 struct GNUNET_TESTBED_System * 60 GNUNET_TESTBED_system_create ( 61 const char *testdir, 62 const char *trusted_ip, 63 const char *hostname); 64 65 66 /** 67 * Free system resources. 68 * 69 * @param system system to be freed 70 * @param remove_paths should the 'testdir' and all subdirectories 71 * be removed (clean up on shutdown)? 72 */ 73 void 74 GNUNET_TESTBED_system_destroy ( 75 struct GNUNET_TESTBED_System *system, 76 bool remove_paths); 77 78 79 /** 80 * Reserve a TCP or UDP port for a peer. 81 * 82 * @param system system to use for reservation tracking 83 * @return 0 if no free port was available 84 */ 85 uint16_t 86 GNUNET_TESTBED_reserve_port ( 87 struct GNUNET_TESTBED_System *system); 88 89 90 /** 91 * Release reservation of a TCP or UDP port for a peer 92 * (used during #GNUNET_TESTBED_peer_destroy()). 93 * 94 * @param system system to use for reservation tracking 95 * @param port reserved port to release 96 */ 97 void 98 GNUNET_TESTBED_release_port ( 99 struct GNUNET_TESTBED_System *system, 100 uint16_t port); 101 102 103 /** 104 * Create a new configuration using the given configuration as a template; 105 * ports and paths will be modified to select available ports on the local 106 * system. The default configuration will be available in PATHS section under 107 * the option DEFAULTCONFIG after the call. GNUNET_HOME is also set in PATHS 108 * section to the temporary directory specific to this configuration. If we run 109 * out of "*port" numbers, return #GNUNET_SYSERR. 110 * 111 * This is primarily a helper function used internally 112 * by 'GNUNET_TESTBED_peer_configure'. 113 * 114 * @param system system to use to coordinate resource usage 115 * @param cfg template configuration to update 116 * @param ports array with port numbers used in the created configuration. 117 * Will be updated upon successful return. Can be NULL 118 * @param nports the size of the `ports' array. Will be updated. 119 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - the configuration will 120 * be incomplete and should not be used there upon 121 */ 122 enum GNUNET_GenericReturnValue 123 GNUNET_TESTBED_configuration_create ( 124 struct GNUNET_TESTBED_System *system, 125 struct GNUNET_CONFIGURATION_Handle *cfg, 126 uint16_t **ports, 127 unsigned int *nports); 128 129 130 #endif