aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_nat_service.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-11-30 07:31:09 +0100
committerChristian Grothoff <christian@grothoff.org>2016-11-30 07:31:09 +0100
commit1b4333f3a6a4f76aa76fc3abc21e8476ea0a92e3 (patch)
tree86bbecfcd30d250ab5a123c793595f8ff6ff33b1 /src/include/gnunet_nat_service.h
parent27068700bceca89cd940816a7b5cd03933d3cc0b (diff)
downloadgnunet-1b4333f3a6a4f76aa76fc3abc21e8476ea0a92e3.tar.gz
gnunet-1b4333f3a6a4f76aa76fc3abc21e8476ea0a92e3.zip
towards moving STUN logic into new NAT service
Diffstat (limited to 'src/include/gnunet_nat_service.h')
-rw-r--r--src/include/gnunet_nat_service.h102
1 files changed, 71 insertions, 31 deletions
diff --git a/src/include/gnunet_nat_service.h b/src/include/gnunet_nat_service.h
index a59069545..378f5a8cb 100644
--- a/src/include/gnunet_nat_service.h
+++ b/src/include/gnunet_nat_service.h
@@ -198,37 +198,6 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
198 198
199 199
200/** 200/**
201 * Handle an incoming STUN message. This function is useful as
202 * some GNUnet service may be listening on a UDP port and might
203 * thus receive STUN messages while trying to receive other data.
204 * In this case, this function can be used to act as a proper
205 * STUN server (if desired).
206 *
207 * The function does some basic sanity checks on packet size and
208 * content, try to extract a bit of information, and possibly replies
209 * if this is an actual STUN message.
210 *
211 * At the moment this only processes BIND requests, and returns the
212 * externally visible address of the request.
213 *
214 * @param nh handle to the NAT service
215 * @param sender_addr address from which we got @a data
216 * @param sender_addr_len number of bytes in @a sender_addr
217 * @param data the packet
218 * @param data_size number of bytes in @a data
219 * @return #GNUNET_OK on success
220 * #GNUNET_NO if the packet is not a STUN packet
221 * #GNUNET_SYSERR on internal error handling the packet
222 */
223int
224GNUNET_NAT_stun_handle_packet (struct GNUNET_NAT_Handle *nh,
225 const struct sockaddr *sender_addr,
226 size_t sender_addr_len,
227 const void *data,
228 size_t data_size);
229
230
231/**
232 * Test if the given address is (currently) a plausible IP address for 201 * Test if the given address is (currently) a plausible IP address for
233 * this peer. Mostly a convenience function so that clients do not 202 * this peer. Mostly a convenience function so that clients do not
234 * have to explicitly track all IPs that the #GNUNET_NAT_AddressCallback 203 * have to explicitly track all IPs that the #GNUNET_NAT_AddressCallback
@@ -398,6 +367,77 @@ typedef void
398 367
399 368
400/** 369/**
370 * Handle an incoming STUN message. This function is useful as
371 * some GNUnet service may be listening on a UDP port and might
372 * thus receive STUN messages while trying to receive other data.
373 * In this case, this function can be used to process replies
374 * to STUN requests.
375 *
376 * The function does some basic sanity checks on packet size and
377 * content, try to extract a bit of information.
378 *
379 * At the moment this only processes BIND requests, and returns the
380 * externally visible address of the request to the rest of the
381 * NAT logic.
382 *
383 * @param nh handle to the NAT service
384 * @param sender_addr address from which we got @a data
385 * @param sender_addr_len number of bytes in @a sender_addr
386 * @param data the packet
387 * @param data_size number of bytes in @a data
388 * @return #GNUNET_OK on success
389 * #GNUNET_NO if the packet is not a STUN packet
390 * #GNUNET_SYSERR on internal error handling the packet
391 */
392int
393GNUNET_NAT_stun_handle_packet (struct GNUNET_NAT_Handle *nh,
394 const struct sockaddr *sender_addr,
395 size_t sender_addr_len,
396 const void *data,
397 size_t data_size);
398
399
400/**
401 * Handle to a request given to the resolver. Can be used to cancel
402 * the request prior to the timeout or successful execution. Also
403 * used to track our internal state for the request.
404 */
405struct GNUNET_NAT_STUN_Handle;
406
407
408/**
409 * Make Generic STUN request. Sends a generic stun request to the
410 * server specified using the specified socket. If we do this,
411 * we need to watch for possible responses and call
412 * #GNUNET_NAT_stun_handle_packet() on incoming packets.
413 *
414 * @param server the address of the stun server
415 * @param port port of the stun server, in host byte order
416 * @param sock the socket used to send the request, must be a
417 * UDP socket
418 * @param cb callback in case of error
419 * @param cb_cls closure for @a cb
420 * @return NULL on error
421 */
422struct GNUNET_NAT_STUN_Handle *
423GNUNET_NAT_stun_make_request (const char *server,
424 uint16_t port,
425 struct GNUNET_NETWORK_Handle *sock,
426 GNUNET_NAT_TestCallback cb,
427 void *cb_cls);
428
429
430/**
431 * Cancel active STUN request. Frees associated resources
432 * and ensures that the callback is no longer invoked.
433 *
434 * @param rh request to cancel
435 */
436void
437GNUNET_NAT_stun_make_request_cancel (struct GNUNET_NAT_STUN_Handle *rh);
438
439
440/**
401 * Start testing if NAT traversal works using the given configuration 441 * Start testing if NAT traversal works using the given configuration
402 * (IPv4-only). The transport adapters should be down while using 442 * (IPv4-only). The transport adapters should be down while using
403 * this function. 443 * this function.