aboutsummaryrefslogtreecommitdiff
path: root/src/nat
diff options
context:
space:
mode:
authorBruno Cabral <bcabral@uw.edu>2015-08-21 04:15:24 +0000
committerBruno Cabral <bcabral@uw.edu>2015-08-21 04:15:24 +0000
commitecc90530eb2b3f4d0d5037d8d8b69722dda2a2cb (patch)
treee43497b563f2d7ee7856fb8f2f57bb8f2598b371 /src/nat
parent946e39d3696847334b5316902c1eeb84d4c34cb0 (diff)
downloadgnunet-ecc90530eb2b3f4d0d5037d8d8b69722dda2a2cb.tar.gz
gnunet-ecc90530eb2b3f4d0d5037d8d8b69722dda2a2cb.zip
Fix crashes and memory leaks.
Diffstat (limited to 'src/nat')
-rw-r--r--src/nat/nat.c46
-rw-r--r--src/nat/nat.conf4
-rw-r--r--src/nat/nat_stun.c65
-rw-r--r--src/nat/test_stun.c13
4 files changed, 75 insertions, 53 deletions
diff --git a/src/nat/nat.c b/src/nat/nat.c
index 42fe843e3..e51c001f2 100644
--- a/src/nat/nat.c
+++ b/src/nat/nat.c
@@ -407,7 +407,7 @@ struct GNUNET_NAT_Handle
407 int use_stun; 407 int use_stun;
408 408
409 /** 409 /**
410 * How often should se check STUN ? 410 * How often should we check STUN ?
411 */ 411 */
412 struct GNUNET_TIME_Relative stun_frequency; 412 struct GNUNET_TIME_Relative stun_frequency;
413 413
@@ -1109,7 +1109,8 @@ list_interfaces (void *cls,
1109 * @param cls the NAT handle 1109 * @param cls the NAT handle
1110 * @param result , the status 1110 * @param result , the status
1111 */ 1111 */
1112static void stun_request_callback(void *cls, 1112static void
1113stun_request_callback(void *cls,
1113 enum GNUNET_NAT_StatusCode result) 1114 enum GNUNET_NAT_StatusCode result)
1114{ 1115{
1115 1116
@@ -1129,16 +1130,18 @@ static void stun_request_callback(void *cls,
1129}; 1130};
1130 1131
1131/** 1132/**
1132 * Check if STUN can decode the packet 1133 * CHECK if is a valid STUN packet sending to GNUNET_NAT_stun_handle_packet.
1134 * It also check if it can handle the packet based on the NAT handler.
1135 * You don't need to call anything else to check if the packet is valid,
1133 * 1136 *
1134 * @param cls the NAT handle 1137 * @param cls the NAT handle
1135 * @param data, packet 1138 * @param data, packet
1136 * @param len, packet lenght 1139 * @param len, packet length
1137 * 1140 *
1138 * @return GNUNET_NO if it can't decode, GNUNET_YES if is a packet 1141 * @return #GNUNET_NO if it can't decode, #GNUNET_YES if is a packet
1139 */ 1142 */
1140int 1143int
1141GNUNET_NAT_try_decode_stun_packet(void *cls, const void *data, size_t len) 1144GNUNET_NAT_is_valid_stun_packet(void *cls, const void *data, size_t len)
1142{ 1145{
1143 struct GNUNET_NAT_Handle *h = cls; 1146 struct GNUNET_NAT_Handle *h = cls;
1144 struct sockaddr_in answer; 1147 struct sockaddr_in answer;
@@ -1147,6 +1150,10 @@ GNUNET_NAT_try_decode_stun_packet(void *cls, const void *data, size_t len)
1147 if(!h->waiting_stun) 1150 if(!h->waiting_stun)
1148 return GNUNET_NO; 1151 return GNUNET_NO;
1149 1152
1153 /*We dont have STUN installed*/
1154 if(!h->use_stun)
1155 return GNUNET_NO;
1156
1150 /* Empty the answer structure */ 1157 /* Empty the answer structure */
1151 memset(&answer, 0, sizeof(struct sockaddr_in)); 1158 memset(&answer, 0, sizeof(struct sockaddr_in));
1152 1159
@@ -1154,7 +1161,7 @@ GNUNET_NAT_try_decode_stun_packet(void *cls, const void *data, size_t len)
1154 int valid = GNUNET_NAT_stun_handle_packet(data,len, &answer); 1161 int valid = GNUNET_NAT_stun_handle_packet(data,len, &answer);
1155 if(valid) 1162 if(valid)
1156 { 1163 {
1157 LOG (GNUNET_ERROR_TYPE_DEBUG, 1164 LOG (GNUNET_ERROR_TYPE_INFO,
1158 "Stun server returned IP %s , with port %d \n", inet_ntoa(answer.sin_addr), ntohs(answer.sin_port)); 1165 "Stun server returned IP %s , with port %d \n", inet_ntoa(answer.sin_addr), ntohs(answer.sin_port));
1159 /* ADD IP AS VALID*/ 1166 /* ADD IP AS VALID*/
1160 add_to_address_list (h, LAL_EXTERNAL_IP, (const struct sockaddr *) &answer, 1167 add_to_address_list (h, LAL_EXTERNAL_IP, (const struct sockaddr *) &answer,
@@ -1183,20 +1190,25 @@ process_stun (void *cls,
1183{ 1190{
1184 struct GNUNET_NAT_Handle *h = cls; 1191 struct GNUNET_NAT_Handle *h = cls;
1185 1192
1186 LOG (GNUNET_ERROR_TYPE_DEBUG, 1193 h->stun_task = NULL;
1187 "I will do a STUN request\n");
1188 1194
1189 1195
1190 h->stun_task = NULL;
1191 h->waiting_stun = GNUNET_YES;
1192 1196
1193 struct StunServerList* elem = h->actual_stun_server; 1197 struct StunServerList* elem = h->actual_stun_server;
1194 1198
1195 /* Make the request */ 1199 /* Make the request */
1196 LOG (GNUNET_ERROR_TYPE_DEBUG, 1200 LOG (GNUNET_ERROR_TYPE_INFO,
1197 "I will request the stun server %s:%i !\n", elem->address, elem->port); 1201 "I will request the stun server %s:%i !\n", elem->address, elem->port);
1198 1202
1199 GNUNET_NAT_stun_make_request(elem->address, elem->port, h->socket, &stun_request_callback, NULL); 1203 if(GNUNET_OK == GNUNET_NAT_stun_make_request(elem->address, elem->port, h->socket, &stun_request_callback, NULL))
1204 {
1205 h->waiting_stun = GNUNET_YES;
1206 }
1207 else
1208 {
1209 LOG (GNUNET_ERROR_TYPE_ERROR,
1210 "STUN request failed %s:%i !\n", elem->address, elem->port);
1211 }
1200 1212
1201 h->stun_task = 1213 h->stun_task =
1202 GNUNET_SCHEDULER_add_delayed (h->stun_frequency, 1214 GNUNET_SCHEDULER_add_delayed (h->stun_frequency,
@@ -1588,7 +1600,8 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg,
1588 } 1600 }
1589 1601
1590 /* ENABLE STUN ONLY ON UDP*/ 1602 /* ENABLE STUN ONLY ON UDP*/
1591 if(!is_tcp && (NULL != sock) && h->use_stun ) { 1603 if(!is_tcp && (NULL != sock) && h->use_stun )
1604 {
1592 h->socket = sock; 1605 h->socket = sock;
1593 h->actual_stun_server = NULL; 1606 h->actual_stun_server = NULL;
1594 1607
@@ -1772,6 +1785,11 @@ GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h)
1772 GNUNET_SCHEDULER_cancel (h->dns_task); 1785 GNUNET_SCHEDULER_cancel (h->dns_task);
1773 h->dns_task = NULL; 1786 h->dns_task = NULL;
1774 } 1787 }
1788 if (NULL != h->stun_task)
1789 {
1790 GNUNET_SCHEDULER_cancel (h->stun_task);
1791 h->stun_task = NULL;
1792 }
1775 if (NULL != h->server_proc) 1793 if (NULL != h->server_proc)
1776 { 1794 {
1777 if (0 != GNUNET_OS_process_kill (h->server_proc, GNUNET_TERM_SIG)) 1795 if (0 != GNUNET_OS_process_kill (h->server_proc, GNUNET_TERM_SIG))
diff --git a/src/nat/nat.conf b/src/nat/nat.conf
index 63f24530e..04cecf70b 100644
--- a/src/nat/nat.conf
+++ b/src/nat/nat.conf
@@ -49,10 +49,10 @@ IFC_SCAN_FREQUENCY = 15 min
49DYNDNS_FREQUENCY = 7 min 49DYNDNS_FREQUENCY = 7 min
50 50
51# SHOULD USE STUN ? 51# SHOULD USE STUN ?
52USE_STUN = NO 52USE_STUN = YES
53STUN_FREQUENCY = 5 min 53STUN_FREQUENCY = 5 min
54# Default list of stun servers 54# Default list of stun servers
55STUN_SERVERS = stun.services.mozilla.com:3478 stun2.l.google.com:19302 55STUN_SERVERS = stun.services.mozilla.com:3478 stun.ekiga.net:3478
56 56
57 57
58[gnunet-nat-server] 58[gnunet-nat-server]
diff --git a/src/nat/nat_stun.c b/src/nat/nat_stun.c
index 5fff40656..4d1afb3bb 100644
--- a/src/nat/nat_stun.c
+++ b/src/nat/nat_stun.c
@@ -111,8 +111,10 @@ struct StunState {
111 * @param msg the received message 111 * @param msg the received message
112 * @return the converted StunClass 112 * @return the converted StunClass
113 */ 113 */
114static int decode_class(int msg) 114static int
115decode_class(int msg)
115{ 116{
117 /* Sorry for the magic, but this maps the class according to rfc5245 */
116 return ((msg & 0x0010) >> 4) | ((msg & 0x0100) >> 7); 118 return ((msg & 0x0010) >> 4) | ((msg & 0x0100) >> 7);
117} 119}
118 120
@@ -122,7 +124,8 @@ static int decode_class(int msg)
122 * @param msg the received message 124 * @param msg the received message
123 * @return the converted StunMethod 125 * @return the converted StunMethod
124 */ 126 */
125static int decode_method(int msg) 127static int
128decode_method(int msg)
126{ 129{
127 return (msg & 0x000f) | ((msg & 0x00e0) >> 1) | ((msg & 0x3e00) >> 2); 130 return (msg & 0x000f) | ((msg & 0x00e0) >> 1) | ((msg & 0x3e00) >> 2);
128} 131}
@@ -134,7 +137,8 @@ static int decode_method(int msg)
134 * @param method method to be converted 137 * @param method method to be converted
135 * @return message in a STUN compatible format 138 * @return message in a STUN compatible format
136 */ 139 */
137static int encode_message(StunClasses msg_class, StunMethods method) 140static int
141encode_message(StunClasses msg_class, StunMethods method)
138{ 142{
139 return ((msg_class & 1) << 4) | ((msg_class & 2) << 7) | 143 return ((msg_class & 1) << 4) | ((msg_class & 2) << 7) |
140 (method & 0x000f) | ((method & 0x0070) << 1) | ((method & 0x0f800) << 2); 144 (method & 0x000f) | ((method & 0x0070) << 1) | ((method & 0x0f800) << 2);
@@ -146,7 +150,8 @@ static int encode_message(StunClasses msg_class, StunMethods method)
146 * @param msg 150 * @param msg
147 * @return string with the message class and method 151 * @return string with the message class and method
148 */ 152 */
149static const char *stun_msg2str(int msg) 153static const char *
154stun_msg2str(int msg)
150{ 155{
151 156
152 const struct { enum StunClasses value; const char *name; } classes[] = { 157 const struct { enum StunClasses value; const char *name; } classes[] = {
@@ -180,7 +185,7 @@ static const char *stun_msg2str(int msg)
180 if (methods[i].value == value) 185 if (methods[i].value == value)
181 break; 186 break;
182 } 187 }
183 snprintf(result, sizeof(result), "%s %s", 188 GNUNET_snprintf(result, sizeof(result), "%s %s",
184 method ? : "Unknown Method", 189 method ? : "Unknown Method",
185 msg_class ? : "Unknown Class Message"); 190 msg_class ? : "Unknown Class Message");
186 return result; 191 return result;
@@ -192,7 +197,8 @@ static const char *stun_msg2str(int msg)
192 * @param msg with a attribute type 197 * @param msg with a attribute type
193 * @return string with the attribute name 198 * @return string with the attribute name
194 */ 199 */
195static const char *stun_attr2str(int msg) 200static const char *
201stun_attr2str(int msg)
196{ 202{
197 const struct { enum StunAttributes value; const char *name; } attrs[] = { 203 const struct { enum StunAttributes value; const char *name; } attrs[] = {
198 { STUN_MAPPED_ADDRESS, "Mapped Address" }, 204 { STUN_MAPPED_ADDRESS, "Mapped Address" },
@@ -234,7 +240,8 @@ static const char *stun_attr2str(int msg)
234 * 240 *
235 * @param req, stun header to be filled 241 * @param req, stun header to be filled
236 */ 242 */
237static int stun_process_attr(struct StunState *state, struct stun_attr *attr) 243static int
244stun_process_attr(struct StunState *state, struct stun_attr *attr)
238{ 245{
239 LOG (GNUNET_ERROR_TYPE_INFO, 246 LOG (GNUNET_ERROR_TYPE_INFO,
240 "Found STUN Attribute %s (%04x), length %d\n", 247 "Found STUN Attribute %s (%04x), length %d\n",
@@ -264,7 +271,7 @@ static int stun_process_attr(struct StunState *state, struct stun_attr *attr)
264static void 271static void
265generate_request_id(struct stun_header *req) 272generate_request_id(struct stun_header *req)
266{ 273{
267 int x; 274 unsigned int x;
268 req->magic = htonl(STUN_MAGIC_COOKIE); 275 req->magic = htonl(STUN_MAGIC_COOKIE);
269 for (x = 0; x < 3; x++) 276 for (x = 0; x < 3; x++)
270 req->id.id[x] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 277 req->id.id[x] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
@@ -282,7 +289,7 @@ generate_request_id(struct stun_header *req)
282 * @param arg , pointer to a sockaddr_in where we will set the reported IP and port 289 * @param arg , pointer to a sockaddr_in where we will set the reported IP and port
283 * @param magic , Magic cookie 290 * @param magic , Magic cookie
284 * 291 *
285 * @return 0 on sucess, other value otherwise 292 * @return 0 on success, other value otherwise
286 */ 293 */
287static int 294static int
288stun_get_mapped(struct StunState *st, struct stun_attr *attr,struct sockaddr_in *arg, unsigned int magic) 295stun_get_mapped(struct StunState *st, struct stun_attr *attr,struct sockaddr_in *arg, unsigned int magic)
@@ -312,7 +319,7 @@ stun_get_mapped(struct StunState *st, struct stun_attr *attr,struct sockaddr_in
312 } 319 }
313 320
314 st->attr = type; 321 st->attr = type;
315 /*TODO: Detect Family*/ 322
316 sa->sin_family = AF_INET; 323 sa->sin_family = AF_INET;
317 sa->sin_port = returned_addr->port ^ htons(ntohl(magic) >> 16); 324 sa->sin_port = returned_addr->port ^ htons(ntohl(magic) >> 16);
318 sa->sin_addr.s_addr = returned_addr->addr ^ magic; 325 sa->sin_addr.s_addr = returned_addr->addr ^ magic;
@@ -331,12 +338,12 @@ stun_get_mapped(struct StunState *st, struct stun_attr *attr,struct sockaddr_in
331 * @param len, the length of the packet 338 * @param len, the length of the packet
332 * @param arg, sockaddr_in where we will set our discovered packet 339 * @param arg, sockaddr_in where we will set our discovered packet
333 * 340 *
334 * @return, GNUNET_OK on OK, GNUNET_NO if the packet is invalid ( not a stun packet) 341 * @return, #GNUNET_OK on OK, #GNUNET_NO if the packet is invalid ( not a stun packet)
335 */ 342 */
336int 343int
337GNUNET_NAT_stun_handle_packet(const void *data, size_t len, struct sockaddr_in *arg) 344GNUNET_NAT_stun_handle_packet(const void *data, size_t len, struct sockaddr_in *arg)
338{ 345{
339 struct stun_header *hdr = (struct stun_header *)data; 346 const struct stun_header *hdr = (const struct stun_header *)data;
340 struct stun_attr *attr; 347 struct stun_attr *attr;
341 struct StunState st; 348 struct StunState st;
342 int ret = GNUNET_OK; 349 int ret = GNUNET_OK;
@@ -367,28 +374,29 @@ GNUNET_NAT_stun_handle_packet(const void *data, size_t len, struct sockaddr_in *
367 if(STUN_MAGIC_COOKIE != message_magic_cookie){ 374 if(STUN_MAGIC_COOKIE != message_magic_cookie){
368 LOG (GNUNET_ERROR_TYPE_INFO, 375 LOG (GNUNET_ERROR_TYPE_INFO,
369 "Invalid magic cookie \n"); 376 "Invalid magic cookie \n");
370 GNUNET_break_op (0);
371 return GNUNET_NO; 377 return GNUNET_NO;
372 } 378 }
373 379
374 380
375 LOG (GNUNET_ERROR_TYPE_INFO, "STUN Packet, msg %s (%04x), length: %d\n", stun_msg2str(ntohs(hdr->msgtype)), ntohs(hdr->msgtype), advertised_message_size); 381 LOG (GNUNET_ERROR_TYPE_INFO, "STUN Packet, msg %s (%04x), length: %d\n", stun_msg2str(ntohs(hdr->msgtype)),
382 ntohs(hdr->msgtype),
383 advertised_message_size);
376 384
377 385
378 if (advertised_message_size > len) { 386 if (advertised_message_size > len) {
379 LOG (GNUNET_ERROR_TYPE_INFO, "Scrambled STUN packet length (got %d, expecting %d)\n", advertised_message_size, (int)len); 387 LOG (GNUNET_ERROR_TYPE_INFO, "Scrambled STUN packet length (got %d, expecting %d)\n", advertised_message_size,
380 GNUNET_break_op (0); 388 (int)len);
381 return GNUNET_NO; 389 return GNUNET_NO;
382 } else { 390 } else {
383 len = advertised_message_size; 391 len = advertised_message_size;
384 } 392 }
385 /* Zero the struct */ 393
386 memset(&st,0, sizeof(st)); 394 memset(&st,0, sizeof(st));
387 395
388 while (len > 0) { 396 while (len > 0) {
389 if (len < sizeof(struct stun_attr)) { 397 if (len < sizeof(struct stun_attr)) {
390 LOG (GNUNET_ERROR_TYPE_INFO, "Attribute too short (got %d, expecting %d)\n", (int)len, (int) sizeof(struct stun_attr)); 398 LOG (GNUNET_ERROR_TYPE_INFO, "Attribute too short (got %d, expecting %d)\n", (int)len,
391 GNUNET_break_op (0); 399 (int) sizeof(struct stun_attr));
392 break; 400 break;
393 } 401 }
394 attr = (struct stun_attr *)data; 402 attr = (struct stun_attr *)data;
@@ -398,8 +406,8 @@ GNUNET_NAT_stun_handle_packet(const void *data, size_t len, struct sockaddr_in *
398 406
399 /* Check if we still have space in our buffer */ 407 /* Check if we still have space in our buffer */
400 if (advertised_message_size > len ) { 408 if (advertised_message_size > len ) {
401 LOG (GNUNET_ERROR_TYPE_INFO, "Inconsistent Attribute (length %d exceeds remaining msg len %d)\n", advertised_message_size, (int)len); 409 LOG (GNUNET_ERROR_TYPE_INFO, "Inconsistent Attribute (length %d exceeds remaining msg len %d)\n", advertised_message_size,
402 GNUNET_break_op (0); 410 (int)len);
403 break; 411 break;
404 } 412 }
405 413
@@ -407,7 +415,8 @@ GNUNET_NAT_stun_handle_packet(const void *data, size_t len, struct sockaddr_in *
407 stun_get_mapped(&st, attr, arg, hdr->magic); 415 stun_get_mapped(&st, attr, arg, hdr->magic);
408 416
409 if (stun_process_attr(&st, attr)) { 417 if (stun_process_attr(&st, attr)) {
410 LOG (GNUNET_ERROR_TYPE_INFO, "Failed to handle attribute %s (%04x)\n", stun_attr2str(ntohs(attr->attr)), ntohs(attr->attr)); 418 LOG (GNUNET_ERROR_TYPE_INFO, "Failed to handle attribute %s (%04x)\n", stun_attr2str(ntohs(attr->attr)),
419 ntohs(attr->attr));
411 break; 420 break;
412 } 421 }
413 /** Clear attribute id: in case previous entry was a string, 422 /** Clear attribute id: in case previous entry was a string,
@@ -429,7 +438,8 @@ GNUNET_NAT_stun_handle_packet(const void *data, size_t len, struct sockaddr_in *
429 * 438 *
430 * @param cls our `struct GNUNET_NAT_STUN_Handle *` 439 * @param cls our `struct GNUNET_NAT_STUN_Handle *`
431 */ 440 */
432void clean(struct GNUNET_NAT_STUN_Handle * handle) 441static void
442clean(struct GNUNET_NAT_STUN_Handle * handle)
433{ 443{
434 GNUNET_free(handle->stun_server); 444 GNUNET_free(handle->stun_server);
435 GNUNET_free(handle); 445 GNUNET_free(handle);
@@ -526,9 +536,9 @@ stun_dns_callback (void *cls,
526 * @param server, the address of the stun server 536 * @param server, the address of the stun server
527 * @param port, port of the stun server 537 * @param port, port of the stun server
528 * @param sock the socket used to send the request 538 * @param sock the socket used to send the request
529 * @return GNUNET_NAT_STUN_Handle on success, NULL on error. 539 * @return #GNUNET_OK success, #GNUNET_NO on error.
530 */ 540 */
531struct GNUNET_NAT_STUN_Handle * 541int
532GNUNET_NAT_stun_make_request(char * server, int port, 542GNUNET_NAT_stun_make_request(char * server, int port,
533 struct GNUNET_NETWORK_Handle * sock,GNUNET_NAT_stun_RequestCallback cb, 543 struct GNUNET_NETWORK_Handle * sock,GNUNET_NAT_stun_RequestCallback cb,
534 void *cb_cls) 544 void *cb_cls)
@@ -554,9 +564,10 @@ GNUNET_NAT_stun_make_request(char * server, int port,
554 if(rh->dns_active == NULL) 564 if(rh->dns_active == NULL)
555 { 565 {
556 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "Failed DNS"); 566 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "Failed DNS");
557 return NULL; 567 GNUNET_free(rh);
568 return GNUNET_NO;
558 } 569 }
559 570
560 571
561 return rh; 572 return GNUNET_OK;
562} 573}
diff --git a/src/nat/test_stun.c b/src/nat/test_stun.c
index e75d55bd0..3988dc053 100644
--- a/src/nat/test_stun.c
+++ b/src/nat/test_stun.c
@@ -51,8 +51,8 @@
51static unsigned long port = 7895; 51static unsigned long port = 7895;
52static int ret = 1; 52static int ret = 1;
53 53
54static char *stun_server = "stun2.l.google.com"; 54static char *stun_server = "stun.ekiga.net";
55static int stun_port = 19302; 55static int stun_port = 3478;
56 56
57/** 57/**
58 * The listen socket of the service for IPv4 58 * The listen socket of the service for IPv4
@@ -71,7 +71,7 @@ static struct GNUNET_SCHEDULER_Task * ltask4;
71static void 71static void
72print_answer(struct sockaddr_in* answer) 72print_answer(struct sockaddr_in* answer)
73{ 73{
74 printf("External IP is: %s , with port %d\n", inet_ntoa(answer->sin_addr), ntohs(answer->sin_port)); 74 GNUNET_log (GNUNET_ERROR_TYPE_INFO,"External IP is: %s , with port %d\n", inet_ntoa(answer->sin_addr), ntohs(answer->sin_port));
75} 75}
76 76
77 77
@@ -91,9 +91,6 @@ do_udp_read (void *cls,
91 ssize_t rlen; 91 ssize_t rlen;
92 struct sockaddr_in answer; 92 struct sockaddr_in answer;
93 93
94 printf("UDP READ\n");
95
96
97 if ((0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) && 94 if ((0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
98 (GNUNET_NETWORK_fdset_isset (tc->read_ready, 95 (GNUNET_NETWORK_fdset_isset (tc->read_ready,
99 lsock4))) 96 lsock4)))
@@ -161,7 +158,6 @@ stop ()
161{ 158{
162 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stopping NAT and quitting...\n"); 159 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stopping NAT and quitting...\n");
163 160
164 printf("Stopped !!\n");
165 //Clean task 161 //Clean task
166 if(NULL != ltask4) 162 if(NULL != ltask4)
167 GNUNET_SCHEDULER_cancel (ltask4); 163 GNUNET_SCHEDULER_cancel (ltask4);
@@ -178,7 +174,6 @@ enum GNUNET_NAT_StatusCode result)
178{ 174{
179 ret = result; 175 ret = result;
180 stop(); 176 stop();
181 printf("Called back\n");
182}; 177};
183 178
184 179
@@ -211,9 +206,7 @@ run (void *cls, char *const *args, const char *cfgfile,
211 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 206 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
212 "Service listens on port %u\n", 207 "Service listens on port %u\n",
213 port); 208 port);
214 printf("Start main event\n");
215 GNUNET_NAT_stun_make_request(stun_server, stun_port, lsock4, &request_callback, NULL); 209 GNUNET_NAT_stun_make_request(stun_server, stun_port, lsock4, &request_callback, NULL);
216 printf("Made the requeest\n");
217 210
218 //GNUNET_SCHEDULER_add_delayed (TIMEOUT, &stop, NULL); 211 //GNUNET_SCHEDULER_add_delayed (TIMEOUT, &stop, NULL);
219 212