diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-01-07 05:14:12 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-01-07 05:14:12 +0000 |
commit | 9e0744da3a82cc7b68a9043272044584be98db44 (patch) | |
tree | 0d66dcff21faddda56c57f6768f7fee49649366a /src/nat/nat_test.c | |
parent | 1ab001d527da02fbf9a7212497c162a979aa8f6b (diff) | |
download | gnunet-9e0744da3a82cc7b68a9043272044584be98db44.tar.gz gnunet-9e0744da3a82cc7b68a9043272044584be98db44.zip |
-modify NAT API to return error messages about problems detected
Diffstat (limited to 'src/nat/nat_test.c')
-rw-r--r-- | src/nat/nat_test.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/nat/nat_test.c b/src/nat/nat_test.c index c7de96d2f..f3b2b41ef 100644 --- a/src/nat/nat_test.c +++ b/src/nat/nat_test.c | |||
@@ -177,7 +177,7 @@ reversal_cb (void *cls, | |||
177 | struct GNUNET_NAT_Test *h = cls; | 177 | struct GNUNET_NAT_Test *h = cls; |
178 | const struct sockaddr_in *sa; | 178 | const struct sockaddr_in *sa; |
179 | 179 | ||
180 | if (addrlen != sizeof (struct sockaddr_in)) | 180 | if (sizeof (struct sockaddr_in) != addrlen) |
181 | return; | 181 | return; |
182 | sa = (const struct sockaddr_in *) addr; | 182 | sa = (const struct sockaddr_in *) addr; |
183 | if (h->data != sa->sin_port) | 183 | if (h->data != sa->sin_port) |
@@ -187,7 +187,7 @@ reversal_cb (void *cls, | |||
187 | return; /* wrong port */ | 187 | return; /* wrong port */ |
188 | } | 188 | } |
189 | /* report success */ | 189 | /* report success */ |
190 | h->report (h->report_cls, GNUNET_OK); | 190 | h->report (h->report_cls, GNUNET_OK, NULL); |
191 | } | 191 | } |
192 | 192 | ||
193 | 193 | ||
@@ -199,7 +199,8 @@ reversal_cb (void *cls, | |||
199 | * @param tc scheduler context | 199 | * @param tc scheduler context |
200 | */ | 200 | */ |
201 | static void | 201 | static void |
202 | do_udp_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 202 | do_udp_read (void *cls, |
203 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
203 | { | 204 | { |
204 | struct GNUNET_NAT_Test *tst = cls; | 205 | struct GNUNET_NAT_Test *tst = cls; |
205 | uint16_t data; | 206 | uint16_t data; |
@@ -214,7 +215,7 @@ do_udp_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
214 | GNUNET_NETWORK_socket_recv (tst->lsock, &data, sizeof (data)))) | 215 | GNUNET_NETWORK_socket_recv (tst->lsock, &data, sizeof (data)))) |
215 | { | 216 | { |
216 | if (data == tst->data) | 217 | if (data == tst->data) |
217 | tst->report (tst->report_cls, GNUNET_OK); | 218 | tst->report (tst->report_cls, GNUNET_OK, NULL); |
218 | else | 219 | else |
219 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 220 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
220 | "Received data mismatches expected value\n"); | 221 | "Received data mismatches expected value\n"); |
@@ -249,10 +250,10 @@ do_read (void *cls, | |||
249 | GNUNET_NETWORK_socket_recv (na->sock, &data, sizeof (data)))) | 250 | GNUNET_NETWORK_socket_recv (na->sock, &data, sizeof (data)))) |
250 | { | 251 | { |
251 | if (data == tst->data) | 252 | if (data == tst->data) |
252 | tst->report (tst->report_cls, GNUNET_OK); | 253 | tst->report (tst->report_cls, GNUNET_OK, NULL); |
253 | else | 254 | else |
254 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 255 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
255 | "Received data mismatches expected value\n"); | 256 | "Received data does not match expected value\n"); |
256 | } | 257 | } |
257 | else | 258 | else |
258 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 259 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -295,8 +296,9 @@ do_accept (void *cls, | |||
295 | wl->sock = s; | 296 | wl->sock = s; |
296 | wl->h = tst; | 297 | wl->h = tst; |
297 | wl->rtask = | 298 | wl->rtask = |
298 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, wl->sock, | 299 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
299 | &do_read, wl); | 300 | wl->sock, |
301 | &do_read, wl); | ||
300 | GNUNET_CONTAINER_DLL_insert (tst->na_head, tst->na_tail, wl); | 302 | GNUNET_CONTAINER_DLL_insert (tst->na_head, tst->na_tail, wl); |
301 | } | 303 | } |
302 | 304 | ||
@@ -331,7 +333,8 @@ addr_cb (void *cls, | |||
331 | GNUNET_a2s (addr, addrlen)); | 333 | GNUNET_a2s (addr, addrlen)); |
332 | return; /* ignore IPv6 here */ | 334 | return; /* ignore IPv6 here */ |
333 | } | 335 | } |
334 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Asking gnunet-nat-server to connect to `%s'\n", | 336 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
337 | "Asking gnunet-nat-server to connect to `%s'\n", | ||
335 | GNUNET_a2s (addr, addrlen)); | 338 | GNUNET_a2s (addr, addrlen)); |
336 | sa = (const struct sockaddr_in *) addr; | 339 | sa = (const struct sockaddr_in *) addr; |
337 | msg.header.size = htons (sizeof (struct GNUNET_NAT_TestMessage)); | 340 | msg.header.size = htons (sizeof (struct GNUNET_NAT_TestMessage)); |
@@ -398,7 +401,7 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
398 | ret->adv_port = adv_port; | 401 | ret->adv_port = adv_port; |
399 | ret->report = report; | 402 | ret->report = report; |
400 | ret->report_cls = report_cls; | 403 | ret->report_cls = report_cls; |
401 | if (bnd_port == 0) | 404 | if (0 == bnd_port) |
402 | { | 405 | { |
403 | ret->nat = | 406 | ret->nat = |
404 | GNUNET_NAT_register (cfg, is_tcp, 0, 0, NULL, NULL, &addr_cb, | 407 | GNUNET_NAT_register (cfg, is_tcp, 0, 0, NULL, NULL, &addr_cb, |