aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-11-13 15:01:03 +0000
committerChristian Grothoff <christian@grothoff.org>2009-11-13 15:01:03 +0000
commite8520aa3dad18bc174ea37256c66932062838253 (patch)
tree559750351b39e14b1fa263a25a5ff233ee6f95ab /src
parent10ee738c0a3b74b72ef55cdae37b4d622aff3146 (diff)
downloadgnunet-e8520aa3dad18bc174ea37256c66932062838253.tar.gz
gnunet-e8520aa3dad18bc174ea37256c66932062838253.zip
fixing doxygen and style issues in NAT code
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_nat_lib.h66
-rw-r--r--src/nat/nat.c12
2 files changed, 46 insertions, 32 deletions
diff --git a/src/include/gnunet_nat_lib.h b/src/include/gnunet_nat_lib.h
index f637bbd48..f03dc3dda 100644
--- a/src/include/gnunet_nat_lib.h
+++ b/src/include/gnunet_nat_lib.h
@@ -36,31 +36,37 @@
36 36
37#include <inttypes.h> 37#include <inttypes.h>
38 38
39/* Used to communicate with the UPnP and NAT-PMP plugins */ 39/**
40typedef enum 40 * Used to communicate with the UPnP and NAT-PMP plugins
41{ 41 * FIXME: move to src/nat/common.h
42 GNUNET_NAT_PORT_ERROR, 42 */
43 GNUNET_NAT_PORT_UNMAPPED, 43enum GNUNET_NAT_port_forwarding
44 GNUNET_NAT_PORT_UNMAPPING, 44 {
45 GNUNET_NAT_PORT_MAPPING, 45 GNUNET_NAT_PORT_ERROR,
46 GNUNET_NAT_PORT_MAPPED 46 GNUNET_NAT_PORT_UNMAPPED,
47} 47 GNUNET_NAT_PORT_UNMAPPING,
48GNUNET_NAT_port_forwarding; 48 GNUNET_NAT_PORT_MAPPING,
49 GNUNET_NAT_PORT_MAPPED
50 };
51
49 52
50/** 53/**
51 * Signature of the callback passed to GNUNET_NAT_register. 54 * Signature of the callback passed to GNUNET_NAT_register.
52 * 55 *
53 * @cls closure 56 * @param cls closure
54 * @add_remove GNUNET_YES to mean the new public IP address, GNUNET_NO to mean 57 * @param add_remove GNUNET_YES to mean the new public IP address, GNUNET_NO to mean
55 * the previous (now invalid) one 58 * the previous (now invalid) one
56 * @addr either the previous or the new public IP address 59 * @param addr either the previous or the new public IP address
57 * @addrlen actual lenght of the address 60 * @param addrlen actual lenght of the address
58 */ 61 */
59typedef void (*GNUNET_NAT_AddressCallback) (void *cls, int add_remove, 62typedef void (*GNUNET_NAT_AddressCallback) (void *cls, int add_remove,
60 const struct sockaddr * addr, 63 const struct sockaddr * addr,
61 socklen_t addrlen); 64 socklen_t addrlen);
62 65
63typedef struct GNUNET_NAT_Handle GNUNET_NAT_Handle; 66/**
67 * Handle for active NAT registrations.
68 */
69struct GNUNET_NAT_Handle;
64 70
65/** 71/**
66 * Attempt to enable port redirection and detect public IP address contacting 72 * Attempt to enable port redirection and detect public IP address contacting
@@ -68,11 +74,12 @@ typedef struct GNUNET_NAT_Handle GNUNET_NAT_Handle;
68 * of the local host's addresses should the external port be mapped. The port 74 * of the local host's addresses should the external port be mapped. The port
69 * is taken from the corresponding sockaddr_in[6] field. 75 * is taken from the corresponding sockaddr_in[6] field.
70 * 76 *
71 * @sched the sheduler used in the program 77 * @param sched the sheduler used in the program
72 * @addr the local address packets should be redirected to 78 * @param addr the local address packets should be redirected to
73 * @addrlen actual lenght of the address 79 * @param addrlen actual lenght of the address
74 * @callback function to call everytime the public IP address changes 80 * @param callback function to call everytime the public IP address changes
75 * @callback_cls closure for @callback 81 * @param callback_cls closure for callback
82 * @return NULL on error, otherwise handle that can be used to unregister
76 */ 83 */
77struct GNUNET_NAT_Handle *GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle 84struct GNUNET_NAT_Handle *GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle
78 *sched, 85 *sched,
@@ -85,15 +92,22 @@ struct GNUNET_NAT_Handle *GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle
85 * Stop port redirection and public IP address detection for the given handle. 92 * Stop port redirection and public IP address detection for the given handle.
86 * This frees the handle, after having sent the needed commands to close open ports. 93 * This frees the handle, after having sent the needed commands to close open ports.
87 * 94 *
88 * @h the handle to stop 95 * @param h the handle to stop
89 */ 96 */
90void GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h); 97void GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h);
91 98
92/** 99/**
93 * Compare the sin(6)_addr fields of AF_INET or AF_INET(6) sockaddr. 100 * Compare the sin(6)_addr fields of AF_INET or AF_INET(6) sockaddr.
94 * @param a first sockaddr 101 * FIXME: move to src/nat/common.h or so.
95 * @param second sockaddr 102 *
96 * @returns 0 if addresses are equal, non-null value otherwise */ 103 * @param param a first sockaddr
97int GNUNET_NAT_cmp_addr (const struct sockaddr *a, const struct sockaddr *b); 104 * @param param b second sockaddr
105 * @return 0 if addresses are equal, non-null value otherwise
106 */
107int GNUNET_NAT_cmp_addr (const struct sockaddr *a,
108 const struct sockaddr *b);
109
110
111#endif
98 112
99#endif /* GNUNET_NAT_LIB_H */ 113/* end of gnunet_nat_lib.h */
diff --git a/src/nat/nat.c b/src/nat/nat.c
index 151c526d4..5f69a515a 100644
--- a/src/nat/nat.c
+++ b/src/nat/nat.c
@@ -52,8 +52,8 @@ struct GNUNET_NAT_Handle
52{ 52{
53 int is_enabled; 53 int is_enabled;
54 54
55 GNUNET_NAT_port_forwarding natpmp_status; 55 enum GNUNET_NAT_port_forwarding natpmp_status;
56 GNUNET_NAT_port_forwarding upnp_status; 56 enum GNUNET_NAT_port_forwarding upnp_status;
57 57
58 int should_change; 58 int should_change;
59 u_short public_port; 59 u_short public_port;
@@ -102,7 +102,7 @@ get_nat_state_str (int state)
102#endif 102#endif
103 103
104static int 104static int
105get_traversal_status (const GNUNET_NAT_Handle * s) 105get_traversal_status (const struct GNUNET_NAT_Handle * s)
106{ 106{
107 return MAX (s->natpmp_status, s->upnp_status); 107 return MAX (s->natpmp_status, s->upnp_status);
108} 108}
@@ -135,7 +135,7 @@ GNUNET_NAT_cmp_addr (const struct sockaddr *a, const struct sockaddr *b)
135 * or nullify the previous sockaddr. Change the port if needed. 135 * or nullify the previous sockaddr. Change the port if needed.
136 */ 136 */
137static void 137static void
138notify_change (GNUNET_NAT_Handle *nat, struct sockaddr *addr, int new_port_mapped) 138notify_change (struct GNUNET_NAT_Handle *nat, struct sockaddr *addr, int new_port_mapped)
139{ 139{
140 static int port_mapped = GNUNET_NO; 140 static int port_mapped = GNUNET_NO;
141 141
@@ -209,7 +209,7 @@ notify_change (GNUNET_NAT_Handle *nat, struct sockaddr *addr, int new_port_mappe
209static void 209static void
210nat_pulse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 210nat_pulse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
211{ 211{
212 GNUNET_NAT_Handle *nat = cls; 212 struct GNUNET_NAT_Handle *nat = cls;
213 static int first_warning = GNUNET_YES; 213 static int first_warning = GNUNET_YES;
214 int old_status; 214 int old_status;
215 int new_status; 215 int new_status;
@@ -295,7 +295,7 @@ GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle *sched,
295 const struct sockaddr *addr, socklen_t addrlen, 295 const struct sockaddr *addr, socklen_t addrlen,
296 GNUNET_NAT_AddressCallback callback, void *callback_cls) 296 GNUNET_NAT_AddressCallback callback, void *callback_cls)
297{ 297{
298 GNUNET_NAT_Handle *nat = GNUNET_malloc (sizeof (GNUNET_NAT_Handle)); 298 struct GNUNET_NAT_Handle *nat = GNUNET_malloc (sizeof (struct GNUNET_NAT_Handle));
299 299
300 if (addr) 300 if (addr)
301 { 301 {