aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_nat_lib.h13
-rw-r--r--src/nat/nat.c11
-rw-r--r--src/nat/nat_stun.c10
3 files changed, 24 insertions, 10 deletions
diff --git a/src/include/gnunet_nat_lib.h b/src/include/gnunet_nat_lib.h
index 6c4362c90..5692dc294 100644
--- a/src/include/gnunet_nat_lib.h
+++ b/src/include/gnunet_nat_lib.h
@@ -220,7 +220,7 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
220 GNUNET_NAT_AddressCallback address_callback, 220 GNUNET_NAT_AddressCallback address_callback,
221 GNUNET_NAT_ReversalCallback reversal_callback, 221 GNUNET_NAT_ReversalCallback reversal_callback,
222 void *callback_cls, 222 void *callback_cls,
223 struct GNUNET_NETWORK_Handle* sock ); 223 struct GNUNET_NETWORK_Handle* sock);
224 224
225 225
226/** 226/**
@@ -492,7 +492,8 @@ typedef void
492 * @return GNUNET_NAT_STUN_Handle on success, NULL on error. 492 * @return GNUNET_NAT_STUN_Handle on success, NULL on error.
493 */ 493 */
494struct GNUNET_NAT_STUN_Handle * 494struct GNUNET_NAT_STUN_Handle *
495GNUNET_NAT_stun_make_request(char * server, int port, 495GNUNET_NAT_stun_make_request(char * server,
496 int port,
496 struct GNUNET_NETWORK_Handle * sock, GNUNET_NAT_stun_RequestCallback cb, 497 struct GNUNET_NETWORK_Handle * sock, GNUNET_NAT_stun_RequestCallback cb,
497 void *cb_cls); 498 void *cb_cls);
498 499
@@ -511,7 +512,9 @@ GNUNET_NAT_stun_make_request(char * server, int port,
511 * @return, 0 on IGNORE, -1 if the packet is invalid ( not a stun packet) 512 * @return, 0 on IGNORE, -1 if the packet is invalid ( not a stun packet)
512 */ 513 */
513int 514int
514GNUNET_NAT_stun_handle_packet(const uint8_t *data, size_t len,struct sockaddr_in *arg); 515GNUNET_NAT_stun_handle_packet(const void *data,
516 size_t len,
517 struct sockaddr_in *arg);
515 518
516/** 519/**
517 * CHECK if is a valid STUN packet sending to GNUNET_NAT_stun_handle_packet 520 * CHECK if is a valid STUN packet sending to GNUNET_NAT_stun_handle_packet
@@ -524,7 +527,9 @@ GNUNET_NAT_stun_handle_packet(const uint8_t *data, size_t len,struct sockaddr_in
524 * @return, 0 on IGNORE, -1 if the packet is invalid ( not a stun packet) 527 * @return, 0 on IGNORE, -1 if the packet is invalid ( not a stun packet)
525 */ 528 */
526int 529int
527GNUNET_NAT_try_decode_stun_packet(void *cls, const uint8_t *data, size_t len); 530GNUNET_NAT_try_decode_stun_packet(void *cls,
531 const void *data,
532 size_t len);
528 533
529 534
530 535
diff --git a/src/nat/nat.c b/src/nat/nat.c
index 270365425..42fe843e3 100644
--- a/src/nat/nat.c
+++ b/src/nat/nat.c
@@ -1115,9 +1115,16 @@ static void stun_request_callback(void *cls,
1115 1115
1116 struct GNUNET_NAT_Handle *h = cls; 1116 struct GNUNET_NAT_Handle *h = cls;
1117 1117
1118 if(NULL == cls)
1119 return;
1120
1118 h->waiting_stun = GNUNET_NO; 1121 h->waiting_stun = GNUNET_NO;
1119 LOG (GNUNET_ERROR_TYPE_WARNING, 1122
1123 if(result != GNUNET_OK)
1124 {
1125 LOG (GNUNET_ERROR_TYPE_WARNING,
1120 "Error processing a STUN request"); 1126 "Error processing a STUN request");
1127 }
1121 1128
1122}; 1129};
1123 1130
@@ -1131,7 +1138,7 @@ static void stun_request_callback(void *cls,
1131 * @return GNUNET_NO if it can't decode, GNUNET_YES if is a packet 1138 * @return GNUNET_NO if it can't decode, GNUNET_YES if is a packet
1132 */ 1139 */
1133int 1140int
1134GNUNET_NAT_try_decode_stun_packet(void *cls, const uint8_t *data, size_t len) 1141GNUNET_NAT_try_decode_stun_packet(void *cls, const void *data, size_t len)
1135{ 1142{
1136 struct GNUNET_NAT_Handle *h = cls; 1143 struct GNUNET_NAT_Handle *h = cls;
1137 struct sockaddr_in answer; 1144 struct sockaddr_in answer;
diff --git a/src/nat/nat_stun.c b/src/nat/nat_stun.c
index 5e502c29e..5fff40656 100644
--- a/src/nat/nat_stun.c
+++ b/src/nat/nat_stun.c
@@ -334,7 +334,7 @@ stun_get_mapped(struct StunState *st, struct stun_attr *attr,struct sockaddr_in
334 * @return, GNUNET_OK on OK, GNUNET_NO if the packet is invalid ( not a stun packet) 334 * @return, GNUNET_OK on OK, GNUNET_NO if the packet is invalid ( not a stun packet)
335 */ 335 */
336int 336int
337GNUNET_NAT_stun_handle_packet(const uint8_t *data, size_t len,struct sockaddr_in *arg) 337GNUNET_NAT_stun_handle_packet(const void *data, size_t len, struct sockaddr_in *arg)
338{ 338{
339 struct stun_header *hdr = (struct stun_header *)data; 339 struct stun_header *hdr = (struct stun_header *)data;
340 struct stun_attr *attr; 340 struct stun_attr *attr;
@@ -463,8 +463,9 @@ stun_dns_callback (void *cls,
463 463
464 if( GNUNET_NO == request->dns_success){ 464 if( GNUNET_NO == request->dns_success){
465 LOG (GNUNET_ERROR_TYPE_INFO, "Empty request\n"); 465 LOG (GNUNET_ERROR_TYPE_INFO, "Empty request\n");
466 clean(request);
467 request->cb(request->cb_cls, GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR); 466 request->cb(request->cb_cls, GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR);
467 clean(request);
468
468 } 469 }
469 return; 470 return;
470 } 471 }
@@ -474,8 +475,9 @@ stun_dns_callback (void *cls,
474 475
475 if( GNUNET_NO == request->dns_success){ 476 if( GNUNET_NO == request->dns_success){
476 LOG (GNUNET_ERROR_TYPE_INFO, "Error resolving host %s\n", request->stun_server); 477 LOG (GNUNET_ERROR_TYPE_INFO, "Error resolving host %s\n", request->stun_server);
477 clean(request);
478 request->cb(request->cb_cls, GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR); 478 request->cb(request->cb_cls, GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR);
479 clean(request);
480
479 } 481 }
480 482
481 return; 483 return;
@@ -503,8 +505,8 @@ stun_dns_callback (void *cls,
503 (const struct sockaddr *) &server, sizeof (server))) 505 (const struct sockaddr *) &server, sizeof (server)))
504 { 506 {
505 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "Fail to sendto"); 507 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "Fail to sendto");
506 clean(request);
507 request->cb(request->cb_cls, GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR); 508 request->cb(request->cb_cls, GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR);
509 clean(request);
508 return; 510 return;
509 } 511 }
510 512