diff options
Diffstat (limited to 'src/include/gnunet_nat_auto_service.h')
-rw-r--r-- | src/include/gnunet_nat_auto_service.h | 128 |
1 files changed, 23 insertions, 105 deletions
diff --git a/src/include/gnunet_nat_auto_service.h b/src/include/gnunet_nat_auto_service.h index 90115ff8c..c458dc81a 100644 --- a/src/include/gnunet_nat_auto_service.h +++ b/src/include/gnunet_nat_auto_service.h | |||
@@ -35,95 +35,13 @@ | |||
35 | #define GNUNET_NAT_AUTO_SERVICE_H | 35 | #define GNUNET_NAT_AUTO_SERVICE_H |
36 | 36 | ||
37 | #include "gnunet_util_lib.h" | 37 | #include "gnunet_util_lib.h" |
38 | #include "gnunet_nat_service.h" | ||
38 | 39 | ||
39 | 40 | ||
40 | /** | 41 | /** |
41 | * Handle to a NAT test. | 42 | * Handle to a NAT test. |
42 | */ | 43 | */ |
43 | struct GNUNET_NAT_Test; | 44 | struct GNUNET_NAT_AUTO_Test; |
44 | |||
45 | |||
46 | /** | ||
47 | * Function called to report success or failure for | ||
48 | * NAT configuration test. | ||
49 | * | ||
50 | * @param cls closure | ||
51 | * @param result #GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code | ||
52 | */ | ||
53 | typedef void | ||
54 | (*GNUNET_NAT_TestCallback) (void *cls, | ||
55 | enum GNUNET_NAT_StatusCode result); | ||
56 | |||
57 | |||
58 | /** | ||
59 | * Handle an incoming STUN message. This function is useful as | ||
60 | * some GNUnet service may be listening on a UDP port and might | ||
61 | * thus receive STUN messages while trying to receive other data. | ||
62 | * In this case, this function can be used to process replies | ||
63 | * to STUN requests. | ||
64 | * | ||
65 | * The function does some basic sanity checks on packet size and | ||
66 | * content, try to extract a bit of information. | ||
67 | * | ||
68 | * At the moment this only processes BIND requests, and returns the | ||
69 | * externally visible address of the request to the rest of the | ||
70 | * NAT logic. | ||
71 | * | ||
72 | * @param nh handle to the NAT service | ||
73 | * @param sender_addr address from which we got @a data | ||
74 | * @param sender_addr_len number of bytes in @a sender_addr | ||
75 | * @param data the packet | ||
76 | * @param data_size number of bytes in @a data | ||
77 | * @return #GNUNET_OK on success | ||
78 | * #GNUNET_NO if the packet is not a STUN packet | ||
79 | * #GNUNET_SYSERR on internal error handling the packet | ||
80 | */ | ||
81 | int | ||
82 | GNUNET_NAT_stun_handle_packet (struct GNUNET_NAT_Handle *nh, | ||
83 | const struct sockaddr *sender_addr, | ||
84 | size_t sender_addr_len, | ||
85 | const void *data, | ||
86 | size_t data_size); | ||
87 | |||
88 | |||
89 | /** | ||
90 | * Handle to a request given to the resolver. Can be used to cancel | ||
91 | * the request prior to the timeout or successful execution. Also | ||
92 | * used to track our internal state for the request. | ||
93 | */ | ||
94 | struct GNUNET_NAT_STUN_Handle; | ||
95 | |||
96 | |||
97 | /** | ||
98 | * Make Generic STUN request. Sends a generic stun request to the | ||
99 | * server specified using the specified socket. If we do this, | ||
100 | * we need to watch for possible responses and call | ||
101 | * #GNUNET_NAT_stun_handle_packet() on incoming packets. | ||
102 | * | ||
103 | * @param server the address of the stun server | ||
104 | * @param port port of the stun server, in host byte order | ||
105 | * @param sock the socket used to send the request, must be a | ||
106 | * UDP socket | ||
107 | * @param cb callback in case of error | ||
108 | * @param cb_cls closure for @a cb | ||
109 | * @return NULL on error | ||
110 | */ | ||
111 | struct GNUNET_NAT_STUN_Handle * | ||
112 | GNUNET_NAT_stun_make_request (const char *server, | ||
113 | uint16_t port, | ||
114 | struct GNUNET_NETWORK_Handle *sock, | ||
115 | GNUNET_NAT_TestCallback cb, | ||
116 | void *cb_cls); | ||
117 | |||
118 | |||
119 | /** | ||
120 | * Cancel active STUN request. Frees associated resources | ||
121 | * and ensures that the callback is no longer invoked. | ||
122 | * | ||
123 | * @param rh request to cancel | ||
124 | */ | ||
125 | void | ||
126 | GNUNET_NAT_stun_make_request_cancel (struct GNUNET_NAT_STUN_Handle *rh); | ||
127 | 45 | ||
128 | 46 | ||
129 | /** | 47 | /** |
@@ -141,15 +59,15 @@ GNUNET_NAT_stun_make_request_cancel (struct GNUNET_NAT_STUN_Handle *rh); | |||
141 | * @param report_cls closure for @a report | 59 | * @param report_cls closure for @a report |
142 | * @return handle to cancel NAT test | 60 | * @return handle to cancel NAT test |
143 | */ | 61 | */ |
144 | struct GNUNET_NAT_Test * | 62 | struct GNUNET_NAT_AUTO_Test * |
145 | GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 63 | GNUNET_NAT_AUTO_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
146 | uint8_t proto, | 64 | uint8_t proto, |
147 | struct in_addr bind_ip, | 65 | struct in_addr bind_ip, |
148 | uint16_t bnd_port, | 66 | uint16_t bnd_port, |
149 | struct in_addr extern_ip, | 67 | struct in_addr extern_ip, |
150 | uint16_t extern_port, | 68 | uint16_t extern_port, |
151 | GNUNET_NAT_TestCallback report, | 69 | GNUNET_NAT_TestCallback report, |
152 | void *report_cls); | 70 | void *report_cls); |
153 | 71 | ||
154 | 72 | ||
155 | /** | 73 | /** |
@@ -158,13 +76,13 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
158 | * @param tst test to stop. | 76 | * @param tst test to stop. |
159 | */ | 77 | */ |
160 | void | 78 | void |
161 | GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst); | 79 | GNUNET_NAT_AUTO_test_stop (struct GNUNET_NAT_AUTO_Test *tst); |
162 | 80 | ||
163 | 81 | ||
164 | /** | 82 | /** |
165 | * Handle to auto-configuration in progress. | 83 | * Handle to auto-configuration in progress. |
166 | */ | 84 | */ |
167 | struct GNUNET_NAT_AutoHandle; | 85 | struct GNUNET_NAT_AUTO_AutoHandle; |
168 | 86 | ||
169 | 87 | ||
170 | /** | 88 | /** |
@@ -174,7 +92,7 @@ struct GNUNET_NAT_AutoHandle; | |||
174 | * @return point to a static string containing the error code | 92 | * @return point to a static string containing the error code |
175 | */ | 93 | */ |
176 | const char * | 94 | const char * |
177 | GNUNET_NAT_status2string (enum GNUNET_NAT_StatusCode err); | 95 | GNUNET_NAT_AUTO_status2string (enum GNUNET_NAT_StatusCode err); |
178 | 96 | ||
179 | 97 | ||
180 | /** | 98 | /** |
@@ -187,10 +105,10 @@ GNUNET_NAT_status2string (enum GNUNET_NAT_StatusCode err); | |||
187 | * @param type what the situation of the NAT | 105 | * @param type what the situation of the NAT |
188 | */ | 106 | */ |
189 | typedef void | 107 | typedef void |
190 | (*GNUNET_NAT_AutoResultCallback)(void *cls, | 108 | (*GNUNET_NAT_AUTO_AutoResultCallback)(void *cls, |
191 | const struct GNUNET_CONFIGURATION_Handle *diff, | 109 | const struct GNUNET_CONFIGURATION_Handle *diff, |
192 | enum GNUNET_NAT_StatusCode result, | 110 | enum GNUNET_NAT_StatusCode result, |
193 | enum GNUNET_NAT_Type type); | 111 | enum GNUNET_NAT_Type type); |
194 | 112 | ||
195 | 113 | ||
196 | /** | 114 | /** |
@@ -202,10 +120,10 @@ typedef void | |||
202 | * @param cb_cls closure for @a cb | 120 | * @param cb_cls closure for @a cb |
203 | * @return handle to cancel operation | 121 | * @return handle to cancel operation |
204 | */ | 122 | */ |
205 | struct GNUNET_NAT_AutoHandle * | 123 | struct GNUNET_NAT_AUTO_AutoHandle * |
206 | GNUNET_NAT_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 124 | GNUNET_NAT_AUTO_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
207 | GNUNET_NAT_AutoResultCallback cb, | 125 | GNUNET_NAT_AUTO_AutoResultCallback cb, |
208 | void *cb_cls); | 126 | void *cb_cls); |
209 | 127 | ||
210 | 128 | ||
211 | /** | 129 | /** |
@@ -214,7 +132,7 @@ GNUNET_NAT_autoconfig_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
214 | * @param ah handle for operation to abort | 132 | * @param ah handle for operation to abort |
215 | */ | 133 | */ |
216 | void | 134 | void |
217 | GNUNET_NAT_autoconfig_cancel (struct GNUNET_NAT_AutoHandle *ah); | 135 | GNUNET_NAT_AUTO_autoconfig_cancel (struct GNUNET_NAT_AUTO_AutoHandle *ah); |
218 | 136 | ||
219 | 137 | ||
220 | #endif | 138 | #endif |