aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-06-25 06:24:01 +0000
committerChristian Grothoff <christian@grothoff.org>2011-06-25 06:24:01 +0000
commit8a3016481ba6aeb36de3950a56e641dda53ca544 (patch)
tree0c5468ec6e5d2165ad5931940e0b8439d09398de /src/include
parentb6d4eeb39fd0cd41df164bd0959f58b08aa45e83 (diff)
downloadgnunet-8a3016481ba6aeb36de3950a56e641dda53ca544.tar.gz
gnunet-8a3016481ba6aeb36de3950a56e641dda53ca544.zip
the big NAT change
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_nat_lib.h76
-rw-r--r--src/include/gnunet_transport_plugin.h14
-rw-r--r--src/include/gnunet_transport_service.h4
3 files changed, 75 insertions, 19 deletions
diff --git a/src/include/gnunet_nat_lib.h b/src/include/gnunet_nat_lib.h
index 14da4e684..9550bb1e3 100644
--- a/src/include/gnunet_nat_lib.h
+++ b/src/include/gnunet_nat_lib.h
@@ -32,7 +32,8 @@
32#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
33 33
34/** 34/**
35 * Signature of the callback passed to GNUNET_NAT_register. 35 * Signature of the callback passed to GNUNET_NAT_register for
36 * a function to call whenever our set of 'valid' addresses changes.
36 * 37 *
37 * @param cls closure 38 * @param cls closure
38 * @param add_remove GNUNET_YES to mean the new public IP address, GNUNET_NO to mean 39 * @param add_remove GNUNET_YES to mean the new public IP address, GNUNET_NO to mean
@@ -47,38 +48,95 @@ typedef void (*GNUNET_NAT_AddressCallback) (void *cls,
47 48
48 49
49/** 50/**
51 * Signature of the callback passed to GNUNET_NAT_register
52 * for a function to call whenever someone asks us to do connection
53 * reversal.
54 *
55 * @param cls closure
56 * @param addr public IP address of the other peer
57 * @param addrlen actual lenght of the address
58 */
59typedef void (*GNUNET_NAT_ReversalCallback) (void *cls,
60 const struct sockaddr *addr,
61 socklen_t addrlen);
62
63
64/**
50 * Handle for active NAT registrations. 65 * Handle for active NAT registrations.
51 */ 66 */
52struct GNUNET_NAT_Handle; 67struct GNUNET_NAT_Handle;
53 68
69
54/** 70/**
55 * Attempt to enable port redirection and detect public IP address contacting 71 * Attempt to enable port redirection and detect public IP address contacting
56 * UPnP or NAT-PMP routers on the local network. Use addr to specify to which 72 * UPnP or NAT-PMP routers on the local network. Use addr to specify to which
57 * of the local host's addresses should the external port be mapped. The port 73 * of the local host's addresses should the external port be mapped. The port
58 * is taken from the corresponding sockaddr_in[6] field. 74 * is taken from the corresponding sockaddr_in[6] field. The NAT module
75 * should call the given callback for any 'plausible' external address.
59 * 76 *
60 * @param cfg configuration to use 77 * @param cfg configuration to use
61 * @param addr the local address packets should be redirected to 78 * @param is_tcp GNUNET_YES for TCP, GNUNET_NO for UDP
62 * @param addrlen actual lenght of the address 79 * @param adv_port advertised port (port we are either bound to or that our OS
63 * @param callback function to call everytime the public IP address changes 80 * locally performs redirection from to our bound port).
81 * @param num_addrs number of addresses in 'addrs'
82 * @param addrs list of local addresses packets should be redirected to
83 * @param addrlens actual lengths of the addresses
84 * @param address_callback function to call everytime the public IP address changes
85 * @param reversal_callback function to call if someone wants connection reversal from us,
86 * NULL if connection reversal is not supported
64 * @param callback_cls closure for callback 87 * @param callback_cls closure for callback
65 * @return NULL on error, otherwise handle that can be used to unregister 88 * @return NULL on error, otherwise handle that can be used to unregister
66 */ 89 */
67struct GNUNET_NAT_Handle * 90struct GNUNET_NAT_Handle *
68GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, 91GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
69 const struct sockaddr *addr, 92 int is_tcp,
70 socklen_t addrlen, 93 uint16_t adv_port,
71 GNUNET_NAT_AddressCallback callback, 94 unsigned int num_addrs,
95 const struct sockaddr **addrs,
96 const socklen_t *addrlens,
97 GNUNET_NAT_AddressCallback address_callback,
98 GNUNET_NAT_ReversalCallback reversal_callback,
72 void *callback_cls); 99 void *callback_cls);
73 100
74 101
75/** 102/**
103 * Test if the given address is (currently) a plausible IP address for this peer.
104 *
105 * @param h the handle returned by register
106 * @param addr IP address to test (IPv4 or IPv6)
107 * @param addrlen number of bytes in addr
108 * @return GNUNET_YES if the address is plausible,
109 * GNUNET_NO if the address is not plausible,
110 * GNUNET_SYSERR if the address is malformed
111 */
112int
113GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h,
114 const void *addr,
115 socklen_t addrlen);
116
117
118/**
119 * We learned about a peer (possibly behind NAT) so run the
120 * gnunet-nat-client to send dummy ICMP responses to cause
121 * that peer to connect to us (connection reversal).
122 *
123 * @param h handle (used for configuration)
124 * @param sa the address of the peer (IPv4-only)
125 */
126void
127GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h,
128 const struct sockaddr_in *sa);
129
130
131
132/**
76 * Stop port redirection and public IP address detection for the given handle. 133 * Stop port redirection and public IP address detection for the given handle.
77 * This frees the handle, after having sent the needed commands to close open ports. 134 * This frees the handle, after having sent the needed commands to close open ports.
78 * 135 *
79 * @param h the handle to stop 136 * @param h the handle to stop
80 */ 137 */
81void GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h); 138void
139GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h);
82 140
83#endif 141#endif
84 142
diff --git a/src/include/gnunet_transport_plugin.h b/src/include/gnunet_transport_plugin.h
index 507d95abe..40f134db0 100644
--- a/src/include/gnunet_transport_plugin.h
+++ b/src/include/gnunet_transport_plugin.h
@@ -123,19 +123,17 @@ typedef struct GNUNET_TIME_Relative (*GNUNET_TRANSPORT_PluginReceiveCallback) (v
123 * is aware that it might be reachable under. 123 * is aware that it might be reachable under.
124 * 124 *
125 * @param cls closure 125 * @param cls closure
126 * @param name name of the transport that generated the address 126 * @param add_remove should the address added (YES) or removed (NO) from the
127 * @param addr one of the addresses of the host, NULL for the last address 127 * set of valid addresses?
128 * @param addr one of the addresses of the host
128 * the specific address format depends on the transport 129 * the specific address format depends on the transport
129 * @param addrlen length of the address 130 * @param addrlen length of the address
130 * @param expires when should this address automatically expire?
131 */ 131 */
132typedef void (*GNUNET_TRANSPORT_AddressNotification) (void *cls, 132typedef void (*GNUNET_TRANSPORT_AddressNotification) (void *cls,
133 const char *name, 133 int add_remove,
134 const void *addr, 134 const void *addr,
135 uint16_t addrlen, 135 size_t addrlen);
136 struct 136
137 GNUNET_TIME_Relative
138 expires);
139 137
140/** 138/**
141 * Function that will be called whenever the plugin receives data over 139 * Function that will be called whenever the plugin receives data over
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index 98ef8c229..9a7093a10 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -558,12 +558,12 @@ struct GNUNET_TRANSPORT_TransmitHandle
558/** 558/**
559 * Cancel the specified transmission-ready notification. 559 * Cancel the specified transmission-ready notification.
560 * 560 *
561 * @param h handle of the transmission notification request to cancel 561 * @param th handle of the transmission notification request to cancel
562 */ 562 */
563void 563void
564GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct 564GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct
565 GNUNET_TRANSPORT_TransmitHandle 565 GNUNET_TRANSPORT_TransmitHandle
566 *h); 566 *th);
567 567
568 568
569 569