aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gns.h6
-rw-r--r--src/gns/gns_api.c54
-rw-r--r--src/gns/gnunet-dns2gns.c40
-rw-r--r--src/gns/gnunet-gns-helper-service-w32.c10
-rw-r--r--src/gns/gnunet-gns-proxy.c308
-rw-r--r--src/gns/gnunet-gns.c38
-rw-r--r--src/gns/gnunet-service-gns.c88
-rw-r--r--src/gns/gnunet-service-gns_interceptor.c38
-rw-r--r--src/gns/gnunet-service-gns_resolver.c154
-rw-r--r--src/gns/gnunet-service-gns_resolver.h2
-rw-r--r--src/gns/gnunet-service-gns_shorten.c40
-rw-r--r--src/gns/gnunet_w32nsp_lib.h16
-rw-r--r--src/gns/nss/nss_gns.c40
-rw-r--r--src/gns/nss/nss_gns_query.c12
-rw-r--r--src/gns/plugin_block_gns.c4
-rw-r--r--src/gns/test_gns_proxy.c26
-rw-r--r--src/gns/test_gns_pseu_shorten.c36
-rw-r--r--src/gns/test_gns_revocation.c6
-rw-r--r--src/gns/test_gns_simple_shorten.c18
-rw-r--r--src/gns/test_gns_simple_srv_lookup.c6
-rw-r--r--src/gns/test_gns_simple_zkey_lookup.c12
-rw-r--r--src/gns/w32nsp-install.c162
-rw-r--r--src/gns/w32nsp-resolve.c8
-rw-r--r--src/gns/w32nsp-uninstall.c58
24 files changed, 591 insertions, 591 deletions
diff --git a/src/gns/gns.h b/src/gns/gns.h
index 24f543f71..571b62dc7 100644
--- a/src/gns/gns.h
+++ b/src/gns/gns.h
@@ -79,9 +79,9 @@ struct GNUNET_GNS_ClientLookupMessage
79 * the type of record to look up 79 * the type of record to look up
80 */ 80 */
81 int32_t type GNUNET_PACKED; 81 int32_t type GNUNET_PACKED;
82 82
83 /** 83 /**
84 * The key for shorten, if @e have_key is set 84 * The key for shorten, if @e have_key is set
85 */ 85 */
86 struct GNUNET_CRYPTO_EccPrivateKey shorten_key; 86 struct GNUNET_CRYPTO_EccPrivateKey shorten_key;
87 87
@@ -106,7 +106,7 @@ struct GNUNET_GNS_ClientLookupResultMessage
106 106
107 /** 107 /**
108 * The number of records contained in response 108 * The number of records contained in response
109 */ 109 */
110 uint32_t rd_count GNUNET_PACKED; 110 uint32_t rd_count GNUNET_PACKED;
111 111
112 /* followed by rd_count GNUNET_NAMESTORE_RecordData structs*/ 112 /* followed by rd_count GNUNET_NAMESTORE_RecordData structs*/
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c
index 7b97c6df8..75c2f9530 100644
--- a/src/gns/gns_api.c
+++ b/src/gns/gns_api.c
@@ -46,32 +46,32 @@ struct GNUNET_GNS_LookupRequest
46 * DLL 46 * DLL
47 */ 47 */
48 struct GNUNET_GNS_LookupRequest *next; 48 struct GNUNET_GNS_LookupRequest *next;
49 49
50 /** 50 /**
51 * DLL 51 * DLL
52 */ 52 */
53 struct GNUNET_GNS_LookupRequest *prev; 53 struct GNUNET_GNS_LookupRequest *prev;
54 54
55 /** 55 /**
56 * handle to gns 56 * handle to gns
57 */ 57 */
58 struct GNUNET_GNS_Handle *gns_handle; 58 struct GNUNET_GNS_Handle *gns_handle;
59 59
60 /** 60 /**
61 * processor to call on lookup result 61 * processor to call on lookup result
62 */ 62 */
63 GNUNET_GNS_LookupResultProcessor lookup_proc; 63 GNUNET_GNS_LookupResultProcessor lookup_proc;
64 64
65 /** 65 /**
66 * processor closure 66 * processor closure
67 */ 67 */
68 void *proc_cls; 68 void *proc_cls;
69 69
70 /** 70 /**
71 * request id 71 * request id
72 */ 72 */
73 uint32_t r_id; 73 uint32_t r_id;
74 74
75}; 75};
76 76
77 77
@@ -130,7 +130,7 @@ struct GNUNET_GNS_Handle
130 * Currently pending transmission request (or NULL). 130 * Currently pending transmission request (or NULL).
131 */ 131 */
132 struct GNUNET_CLIENT_TransmitHandle *th; 132 struct GNUNET_CLIENT_TransmitHandle *th;
133 133
134 /** 134 /**
135 * Head of linked list of shorten messages we would like to transmit. 135 * Head of linked list of shorten messages we would like to transmit.
136 */ 136 */
@@ -140,7 +140,7 @@ struct GNUNET_GNS_Handle
140 * Tail of linked list of shorten messages we would like to transmit. 140 * Tail of linked list of shorten messages we would like to transmit.
141 */ 141 */
142 struct PendingMessage *pending_tail; 142 struct PendingMessage *pending_tail;
143 143
144 /** 144 /**
145 * Head of linked list of lookup messages we would like to transmit. 145 * Head of linked list of lookup messages we would like to transmit.
146 */ 146 */
@@ -155,7 +155,7 @@ struct GNUNET_GNS_Handle
155 * Reconnect task 155 * Reconnect task
156 */ 156 */
157 GNUNET_SCHEDULER_TaskIdentifier reconnect_task; 157 GNUNET_SCHEDULER_TaskIdentifier reconnect_task;
158 158
159 /** 159 /**
160 * How long do we wait until we try to reconnect? 160 * How long do we wait until we try to reconnect?
161 */ 161 */
@@ -165,7 +165,7 @@ struct GNUNET_GNS_Handle
165 * Request Id generator. Incremented by one for each request. 165 * Request Id generator. Incremented by one for each request.
166 */ 166 */
167 uint32_t r_id_gen; 167 uint32_t r_id_gen;
168 168
169 /** 169 /**
170 * Did we start our receive loop yet? 170 * Did we start our receive loop yet?
171 */ 171 */
@@ -237,7 +237,7 @@ force_reconnect (struct GNUNET_GNS_Handle *handle)
237 p->transmitted = GNUNET_NO; 237 p->transmitted = GNUNET_NO;
238 GNUNET_CONTAINER_DLL_insert (handle->pending_head, 238 GNUNET_CONTAINER_DLL_insert (handle->pending_head,
239 handle->pending_tail, 239 handle->pending_tail,
240 p); 240 p);
241 } 241 }
242 handle->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff); 242 handle->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff);
243 handle->reconnect_task = GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff, 243 handle->reconnect_task = GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff,
@@ -279,17 +279,17 @@ process_pending_messages (struct GNUNET_GNS_Handle *handle)
279 struct PendingMessage *p = handle->pending_head; 279 struct PendingMessage *p = handle->pending_head;
280 280
281 if (NULL == handle->client) 281 if (NULL == handle->client)
282 return; /* wait for reconnect */ 282 return; /* wait for reconnect */
283 if (NULL != handle->th) 283 if (NULL != handle->th)
284 return; /* transmission request already pending */ 284 return; /* transmission request already pending */
285 285
286 while ((NULL != p) && (p->transmitted == GNUNET_YES)) 286 while ((NULL != p) && (p->transmitted == GNUNET_YES))
287 p = p->next; 287 p = p->next;
288 if (NULL == p) 288 if (NULL == p)
289 return; /* no messages pending */ 289 return; /* no messages pending */
290 290
291 LOG (GNUNET_ERROR_TYPE_DEBUG, 291 LOG (GNUNET_ERROR_TYPE_DEBUG,
292 "Trying to transmit %u bytes\n", 292 "Trying to transmit %u bytes\n",
293 (unsigned int) p->size); 293 (unsigned int) p->size);
294 handle->th = 294 handle->th =
295 GNUNET_CLIENT_notify_transmit_ready (handle->client, 295 GNUNET_CLIENT_notify_transmit_ready (handle->client,
@@ -324,7 +324,7 @@ transmit_pending (void *cls, size_t size, void *buf)
324 "Transmission to GNS service failed!\n"); 324 "Transmission to GNS service failed!\n");
325 force_reconnect (handle); 325 force_reconnect (handle);
326 return 0; 326 return 0;
327 } 327 }
328 if (NULL == (p = handle->pending_head)) 328 if (NULL == (p = handle->pending_head))
329 return 0; 329 return 0;
330 330
@@ -388,7 +388,7 @@ process_lookup_reply (struct GNUNET_GNS_LookupRequest *qe,
388 qe->lookup_proc (qe->proc_cls, 0, NULL); 388 qe->lookup_proc (qe->proc_cls, 0, NULL);
389 } 389 }
390 else 390 else
391 { 391 {
392 LOG (GNUNET_ERROR_TYPE_DEBUG, 392 LOG (GNUNET_ERROR_TYPE_DEBUG,
393 "Received lookup reply from GNS service (%u records)\n", 393 "Received lookup reply from GNS service (%u records)\n",
394 (unsigned int) rd_count); 394 (unsigned int) rd_count);
@@ -412,7 +412,7 @@ process_message (void *cls, const struct GNUNET_MessageHeader *msg)
412 struct GNUNET_GNS_LookupRequest *lr; 412 struct GNUNET_GNS_LookupRequest *lr;
413 const struct GNUNET_GNS_ClientLookupResultMessage *lookup_msg; 413 const struct GNUNET_GNS_ClientLookupResultMessage *lookup_msg;
414 uint32_t r_id; 414 uint32_t r_id;
415 415
416 if (NULL == msg) 416 if (NULL == msg)
417 { 417 {
418 force_reconnect (handle); 418 force_reconnect (handle);
@@ -430,11 +430,11 @@ process_message (void *cls, const struct GNUNET_MessageHeader *msg)
430 return; 430 return;
431 } 431 }
432 lookup_msg = (const struct GNUNET_GNS_ClientLookupResultMessage *) msg; 432 lookup_msg = (const struct GNUNET_GNS_ClientLookupResultMessage *) msg;
433 r_id = ntohl (lookup_msg->id); 433 r_id = ntohl (lookup_msg->id);
434 for (lr = handle->lookup_head; NULL != lr; lr = lr->next) 434 for (lr = handle->lookup_head; NULL != lr; lr = lr->next)
435 if (lr->r_id == r_id) 435 if (lr->r_id == r_id)
436 { 436 {
437 process_lookup_reply(lr, lookup_msg); 437 process_lookup_reply(lr, lookup_msg);
438 break; 438 break;
439 } 439 }
440 break; 440 break;
@@ -499,7 +499,7 @@ GNUNET_GNS_lookup_cancel (struct GNUNET_GNS_LookupRequest *lr)
499{ 499{
500 struct PendingMessage *p = (struct PendingMessage*) &lr[1]; 500 struct PendingMessage *p = (struct PendingMessage*) &lr[1];
501 501
502 GNUNET_assert (NULL != lr->gns_handle); 502 GNUNET_assert (NULL != lr->gns_handle);
503 if (GNUNET_NO == p->transmitted) 503 if (GNUNET_NO == p->transmitted)
504 GNUNET_CONTAINER_DLL_remove (lr->gns_handle->pending_head, 504 GNUNET_CONTAINER_DLL_remove (lr->gns_handle->pending_head,
505 lr->gns_handle->pending_tail, 505 lr->gns_handle->pending_tail,
@@ -544,9 +544,9 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
544 { 544 {
545 GNUNET_break (0); 545 GNUNET_break (0);
546 return NULL; 546 return NULL;
547 } 547 }
548 LOG (GNUNET_ERROR_TYPE_DEBUG, 548 LOG (GNUNET_ERROR_TYPE_DEBUG,
549 "Trying to lookup `%s' in GNS\n", 549 "Trying to lookup `%s' in GNS\n",
550 name); 550 name);
551 msize = sizeof (struct GNUNET_GNS_ClientLookupMessage) 551 msize = sizeof (struct GNUNET_GNS_ClientLookupMessage)
552 + strlen (name) + 1; 552 + strlen (name) + 1;
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c
index a6d57f3a9..4dcec6bdc 100644
--- a/src/gns/gnunet-dns2gns.c
+++ b/src/gns/gnunet-dns2gns.c
@@ -65,7 +65,7 @@ struct Request
65 * converted to the DNS response. 65 * converted to the DNS response.
66 */ 66 */
67 struct GNUNET_DNSPARSER_Packet *packet; 67 struct GNUNET_DNSPARSER_Packet *packet;
68 68
69 /** 69 /**
70 * Our GNS request handle. 70 * Our GNS request handle.
71 */ 71 */
@@ -84,7 +84,7 @@ struct Request
84 84
85 /** 85 /**
86 * Number of bytes in 'addr'. 86 * Number of bytes in 'addr'.
87 */ 87 */
88 size_t addr_len; 88 size_t addr_len;
89 89
90}; 90};
@@ -217,7 +217,7 @@ send_response (struct Request *request)
217{ 217{
218 char *buf; 218 char *buf;
219 size_t size; 219 size_t size;
220 220
221 if (GNUNET_SYSERR == 221 if (GNUNET_SYSERR ==
222 GNUNET_DNSPARSER_pack (request->packet, 222 GNUNET_DNSPARSER_pack (request->packet,
223 UINT16_MAX /* is this not too much? */, 223 UINT16_MAX /* is this not too much? */,
@@ -377,7 +377,7 @@ result_processor (void *cls,
377 * @param addr address to use for sending the reply 377 * @param addr address to use for sending the reply
378 * @param addr_len number of bytes in @a addr 378 * @param addr_len number of bytes in @a addr
379 * @param udp_msg DNS request payload 379 * @param udp_msg DNS request payload
380 * @param udp_msg_size number of bytes in @a udp_msg 380 * @param udp_msg_size number of bytes in @a udp_msg
381 */ 381 */
382static void 382static void
383handle_request (struct GNUNET_NETWORK_Handle *lsock, 383handle_request (struct GNUNET_NETWORK_Handle *lsock,
@@ -408,7 +408,7 @@ handle_request (struct GNUNET_NETWORK_Handle *lsock,
408 (int) packet->num_answers, 408 (int) packet->num_answers,
409 (int) packet->num_authority_records, 409 (int) packet->num_authority_records,
410 (int) packet->num_additional_records); 410 (int) packet->num_additional_records);
411 if ( (0 != packet->flags.query_or_response) || 411 if ( (0 != packet->flags.query_or_response) ||
412 (0 != packet->num_answers) || 412 (0 != packet->num_answers) ||
413 (0 != packet->num_authority_records)) 413 (0 != packet->num_authority_records))
414 { 414 {
@@ -439,7 +439,7 @@ handle_request (struct GNUNET_NETWORK_Handle *lsock,
439 name_len = strlen (name); 439 name_len = strlen (name);
440 use_gns = GNUNET_NO; 440 use_gns = GNUNET_NO;
441 441
442 442
443 if ( (name_len > strlen (fcfs_suffix)) && 443 if ( (name_len > strlen (fcfs_suffix)) &&
444 (0 == strcasecmp (fcfs_suffix, 444 (0 == strcasecmp (fcfs_suffix,
445 &name[name_len - strlen (fcfs_suffix)])) ) 445 &name[name_len - strlen (fcfs_suffix)])) )
@@ -481,7 +481,7 @@ handle_request (struct GNUNET_NETWORK_Handle *lsock,
481 else 481 else
482 { 482 {
483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
484 "Using DNS resolver IP `%s' to resolve `%s'\n", 484 "Using DNS resolver IP `%s' to resolve `%s'\n",
485 dns_ip, 485 dns_ip,
486 name); 486 name);
487 GNUNET_DNSPARSER_free_packet (request->packet); 487 GNUNET_DNSPARSER_free_packet (request->packet);
@@ -501,7 +501,7 @@ handle_request (struct GNUNET_NETWORK_Handle *lsock,
501 * 501 *
502 * @param cls the 'listen_socket4' 502 * @param cls the 'listen_socket4'
503 * @param tc scheduler context 503 * @param tc scheduler context
504 */ 504 */
505static void 505static void
506read_dns4 (void *cls, 506read_dns4 (void *cls,
507 const struct GNUNET_SCHEDULER_TaskContext *tc) 507 const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -525,9 +525,9 @@ read_dns4 (void *cls,
525 } 525 }
526 { 526 {
527 char buf[size]; 527 char buf[size];
528 528
529 addrlen = sizeof (v4); 529 addrlen = sizeof (v4);
530 GNUNET_break (size == 530 GNUNET_break (size ==
531 GNUNET_NETWORK_socket_recvfrom (listen_socket4, 531 GNUNET_NETWORK_socket_recvfrom (listen_socket4,
532 buf, 532 buf,
533 size, 533 size,
@@ -544,7 +544,7 @@ read_dns4 (void *cls,
544 * 544 *
545 * @param cls the 'listen_socket6' 545 * @param cls the 'listen_socket6'
546 * @param tc scheduler context 546 * @param tc scheduler context
547 */ 547 */
548static void 548static void
549read_dns6 (void *cls, 549read_dns6 (void *cls,
550 const struct GNUNET_SCHEDULER_TaskContext *tc) 550 const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -568,9 +568,9 @@ read_dns6 (void *cls,
568 } 568 }
569 { 569 {
570 char buf[size]; 570 char buf[size];
571 571
572 addrlen = sizeof (v6); 572 addrlen = sizeof (v6);
573 GNUNET_break (size == 573 GNUNET_break (size ==
574 GNUNET_NETWORK_socket_recvfrom (listen_socket6, 574 GNUNET_NETWORK_socket_recvfrom (listen_socket6,
575 buf, 575 buf,
576 size, 576 size,
@@ -601,7 +601,7 @@ run_dnsd ()
601 return; 601 return;
602 } 602 }
603 listen_socket4 = GNUNET_NETWORK_socket_create (PF_INET, 603 listen_socket4 = GNUNET_NETWORK_socket_create (PF_INET,
604 SOCK_DGRAM, 604 SOCK_DGRAM,
605 IPPROTO_UDP); 605 IPPROTO_UDP);
606 if (NULL != listen_socket4) 606 if (NULL != listen_socket4)
607 { 607 {
@@ -625,7 +625,7 @@ run_dnsd ()
625 } 625 }
626 } 626 }
627 listen_socket6 = GNUNET_NETWORK_socket_create (PF_INET6, 627 listen_socket6 = GNUNET_NETWORK_socket_create (PF_INET6,
628 SOCK_DGRAM, 628 SOCK_DGRAM,
629 IPPROTO_UDP); 629 IPPROTO_UDP);
630 if (NULL != listen_socket6) 630 if (NULL != listen_socket6)
631 { 631 {
@@ -671,7 +671,7 @@ run_dnsd ()
671} 671}
672 672
673 673
674/** 674/**
675 * Method called to inform about the egos of this peer. 675 * Method called to inform about the egos of this peer.
676 * 676 *
677 * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get, 677 * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get,
@@ -679,7 +679,7 @@ run_dnsd ()
679 * @a ego does indicate an error (i.e. name is taken or no default 679 * @a ego does indicate an error (i.e. name is taken or no default
680 * value is known). If @a ego is non-NULL and if '*ctx' 680 * value is known). If @a ego is non-NULL and if '*ctx'
681 * is set in those callbacks, the value WILL be passed to a subsequent 681 * is set in those callbacks, the value WILL be passed to a subsequent
682 * call to the identity callback of #GNUNET_IDENTITY_connect (if 682 * call to the identity callback of #GNUNET_IDENTITY_connect (if
683 * that one was not NULL). 683 * that one was not NULL).
684 * 684 *
685 * @param cls closure, NULL 685 * @param cls closure, NULL
@@ -747,7 +747,7 @@ run (void *cls, char *const *args, const char *cfgfile,
747 strlen (gns_zone_str), 747 strlen (gns_zone_str),
748 &my_zone)) ) 748 &my_zone)) )
749 { 749 {
750 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 750 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
751 _("No valid GNS zone specified!\n")); 751 _("No valid GNS zone specified!\n"));
752 GNUNET_SCHEDULER_shutdown (); 752 GNUNET_SCHEDULER_shutdown ();
753 return; 753 return;
@@ -764,7 +764,7 @@ run (void *cls, char *const *args, const char *cfgfile,
764 * @return 0 ok, 1 on error 764 * @return 0 ok, 1 on error
765 */ 765 */
766int 766int
767main (int argc, 767main (int argc,
768 char *const *argv) 768 char *const *argv)
769{ 769{
770 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 770 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
@@ -794,7 +794,7 @@ main (int argc,
794 ret = 794 ret =
795 (GNUNET_OK == 795 (GNUNET_OK ==
796 GNUNET_PROGRAM_run (argc, argv, "gnunet-dns2gns", 796 GNUNET_PROGRAM_run (argc, argv, "gnunet-dns2gns",
797 _("GNUnet DNS-to-GNS proxy (a DNS server)"), 797 _("GNUnet DNS-to-GNS proxy (a DNS server)"),
798 options, 798 options,
799 &run, NULL)) ? 0 : 1; 799 &run, NULL)) ? 0 : 1;
800 GNUNET_free ((void*) argv); 800 GNUNET_free ((void*) argv);
diff --git a/src/gns/gnunet-gns-helper-service-w32.c b/src/gns/gnunet-gns-helper-service-w32.c
index 4e5aeffc5..26a3f688a 100644
--- a/src/gns/gnunet-gns-helper-service-w32.c
+++ b/src/gns/gnunet-gns-helper-service-w32.c
@@ -172,7 +172,7 @@ transmit_callback (void *cls, size_t size, void *buf)
172 * @param msg message to transmit, will be freed! 172 * @param msg message to transmit, will be freed!
173 */ 173 */
174static void 174static void
175transmit (struct GNUNET_SERVER_Client *client, 175transmit (struct GNUNET_SERVER_Client *client,
176 struct GNUNET_MessageHeader *msg) 176 struct GNUNET_MessageHeader *msg)
177{ 177{
178 struct TransmitCallbackContext *tcc; 178 struct TransmitCallbackContext *tcc;
@@ -188,7 +188,7 @@ transmit (struct GNUNET_SERVER_Client *client,
188 tcc->msg = msg; 188 tcc->msg = msg;
189 if (NULL == 189 if (NULL ==
190 (tcc->th = 190 (tcc->th =
191 GNUNET_SERVER_notify_transmit_ready (client, 191 GNUNET_SERVER_notify_transmit_ready (client,
192 ntohs (msg->size), 192 ntohs (msg->size),
193 GNUNET_TIME_UNIT_FOREVER_REL, 193 GNUNET_TIME_UNIT_FOREVER_REL,
194 &transmit_callback, tcc))) 194 &transmit_callback, tcc)))
@@ -242,7 +242,7 @@ MarshallWSAQUERYSETW (WSAQUERYSETW *qs, GUID *sc)
242 242
243 243
244static void 244static void
245process_ip_lookup_result (void* cls, 245process_ip_lookup_result (void* cls,
246 uint32_t rd_count, 246 uint32_t rd_count,
247 const struct GNUNET_NAMESTORE_RecordData *rd) 247 const struct GNUNET_NAMESTORE_RecordData *rd)
248{ 248{
@@ -547,7 +547,7 @@ get_ip_from_hostname (struct GNUNET_SERVER_Client *client,
547 namelen = 0; 547 namelen = 0;
548 if (namelen > 0) 548 if (namelen > 0)
549 hostname = (char *) u16_to_u8 (name, namelen + 1, NULL, &strl); 549 hostname = (char *) u16_to_u8 (name, namelen + 1, NULL, &strl);
550 550
551 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 551 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
552 "W32 DNS resolver asked to look up %s for `%s'.\n", 552 "W32 DNS resolver asked to look up %s for `%s'.\n",
553 af == AF_INET ? "IPv4" : af == AF_INET6 ? "IPv6" : "anything", 553 af == AF_INET ? "IPv4" : af == AF_INET6 ? "IPv6" : "anything",
@@ -631,7 +631,7 @@ handle_get (void *cls, struct GNUNET_SERVER_Client *client,
631 sc.Data1, sc.Data2, sc.Data3, data4); 631 sc.Data1, sc.Data2, sc.Data3, data4);
632 for (i = 0; i < 8; i++) 632 for (i = 0; i < 8; i++)
633 sc.Data4[i] = 0xFF & (data4 >> ((7 - i) * 8)); 633 sc.Data4[i] = 0xFF & (data4 >> ((7 - i) * 8));
634 634
635 hostname = (const wchar_t *) &msg[1]; 635 hostname = (const wchar_t *) &msg[1];
636 if (hostname[size - 1] != L'\0') 636 if (hostname[size - 1] != L'\0')
637 { 637 {
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index fc28d6565..a67f7356e 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -45,7 +45,7 @@
45 45
46/** 46/**
47 * Default Socks5 listen port. 47 * Default Socks5 listen port.
48 */ 48 */
49#define GNUNET_GNS_PROXY_PORT 7777 49#define GNUNET_GNS_PROXY_PORT 7777
50 50
51/** 51/**
@@ -119,7 +119,7 @@
119 119
120/** 120/**
121 * Commands in Socks5. 121 * Commands in Socks5.
122 */ 122 */
123enum Socks5Commands 123enum Socks5Commands
124{ 124{
125 /** 125 /**
@@ -141,7 +141,7 @@ enum Socks5Commands
141 141
142/** 142/**
143 * Address types in Socks5. 143 * Address types in Socks5.
144 */ 144 */
145enum Socks5AddressType 145enum Socks5AddressType
146{ 146{
147 /** 147 /**
@@ -242,7 +242,7 @@ struct Socks5ClientRequestMessage
242 */ 242 */
243 uint8_t addr_type; 243 uint8_t addr_type;
244 244
245 /* 245 /*
246 * Followed by either an ip4/ipv6 address or a domain name with a 246 * Followed by either an ip4/ipv6 address or a domain name with a
247 * length field (uint8_t) in front (depending on @e addr_type). 247 * length field (uint8_t) in front (depending on @e addr_type).
248 * followed by port number in network byte order (uint16_t). 248 * followed by port number in network byte order (uint16_t).
@@ -275,7 +275,7 @@ struct Socks5ServerResponseMessage
275 */ 275 */
276 uint8_t addr_type; 276 uint8_t addr_type;
277 277
278 /* 278 /*
279 * Followed by either an ip4/ipv6 address or a domain name with a 279 * Followed by either an ip4/ipv6 address or a domain name with a
280 * length field (uint8_t) in front (depending on @e addr_type). 280 * length field (uint8_t) in front (depending on @e addr_type).
281 * followed by port number in network byte order (uint16_t). 281 * followed by port number in network byte order (uint16_t).
@@ -293,12 +293,12 @@ struct Socks5ServerResponseMessage
293struct ProxyCA 293struct ProxyCA
294{ 294{
295 /** 295 /**
296 * The certificate 296 * The certificate
297 */ 297 */
298 gnutls_x509_crt_t cert; 298 gnutls_x509_crt_t cert;
299 299
300 /** 300 /**
301 * The private key 301 * The private key
302 */ 302 */
303 gnutls_x509_privkey_t key; 303 gnutls_x509_privkey_t key;
304}; 304};
@@ -310,12 +310,12 @@ struct ProxyCA
310struct ProxyGNSCertificate 310struct ProxyGNSCertificate
311{ 311{
312 /** 312 /**
313 * The certificate as PEM 313 * The certificate as PEM
314 */ 314 */
315 char cert[MAX_PEM_SIZE]; 315 char cert[MAX_PEM_SIZE];
316 316
317 /** 317 /**
318 * The private key as PEM 318 * The private key as PEM
319 */ 319 */
320 char key[MAX_PEM_SIZE]; 320 char key[MAX_PEM_SIZE];
321}; 321};
@@ -328,22 +328,22 @@ struct ProxyGNSCertificate
328struct MhdHttpList 328struct MhdHttpList
329{ 329{
330 /** 330 /**
331 * DLL for httpds 331 * DLL for httpds
332 */ 332 */
333 struct MhdHttpList *prev; 333 struct MhdHttpList *prev;
334 334
335 /** 335 /**
336 * DLL for httpds 336 * DLL for httpds
337 */ 337 */
338 struct MhdHttpList *next; 338 struct MhdHttpList *next;
339 339
340 /** 340 /**
341 * the domain name to server (only important for SSL) 341 * the domain name to server (only important for SSL)
342 */ 342 */
343 char *domain; 343 char *domain;
344 344
345 /** 345 /**
346 * The daemon handle 346 * The daemon handle
347 */ 347 */
348 struct MHD_Daemon *daemon; 348 struct MHD_Daemon *daemon;
349 349
@@ -353,12 +353,12 @@ struct MhdHttpList
353 struct ProxyGNSCertificate *proxy_cert; 353 struct ProxyGNSCertificate *proxy_cert;
354 354
355 /** 355 /**
356 * The task ID 356 * The task ID
357 */ 357 */
358 GNUNET_SCHEDULER_TaskIdentifier httpd_task; 358 GNUNET_SCHEDULER_TaskIdentifier httpd_task;
359 359
360 /** 360 /**
361 * is this an ssl daemon? 361 * is this an ssl daemon?
362 */ 362 */
363 int is_ssl; 363 int is_ssl;
364 364
@@ -369,7 +369,7 @@ struct MhdHttpList
369 369
370 370
371/** 371/**
372 * The socks phases. 372 * The socks phases.
373 */ 373 */
374enum SocksPhase 374enum SocksPhase
375{ 375{
@@ -443,7 +443,7 @@ struct Socks5Request
443 struct Socks5Request *prev; 443 struct Socks5Request *prev;
444 444
445 /** 445 /**
446 * The client socket 446 * The client socket
447 */ 447 */
448 struct GNUNET_NETWORK_Handle *sock; 448 struct GNUNET_NETWORK_Handle *sock;
449 449
@@ -453,27 +453,27 @@ struct Socks5Request
453 struct GNUNET_GNS_LookupRequest *gns_lookup; 453 struct GNUNET_GNS_LookupRequest *gns_lookup;
454 454
455 /** 455 /**
456 * Client socket read task 456 * Client socket read task
457 */ 457 */
458 GNUNET_SCHEDULER_TaskIdentifier rtask; 458 GNUNET_SCHEDULER_TaskIdentifier rtask;
459 459
460 /** 460 /**
461 * Client socket write task 461 * Client socket write task
462 */ 462 */
463 GNUNET_SCHEDULER_TaskIdentifier wtask; 463 GNUNET_SCHEDULER_TaskIdentifier wtask;
464 464
465 /** 465 /**
466 * Timeout task 466 * Timeout task
467 */ 467 */
468 GNUNET_SCHEDULER_TaskIdentifier timeout_task; 468 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
469 469
470 /** 470 /**
471 * Read buffer 471 * Read buffer
472 */ 472 */
473 char rbuf[SOCKS_BUFFERSIZE]; 473 char rbuf[SOCKS_BUFFERSIZE];
474 474
475 /** 475 /**
476 * Write buffer 476 * Write buffer
477 */ 477 */
478 char wbuf[SOCKS_BUFFERSIZE]; 478 char wbuf[SOCKS_BUFFERSIZE];
479 479
@@ -493,7 +493,7 @@ struct Socks5Request
493 struct MHD_Response *response; 493 struct MHD_Response *response;
494 494
495 /** 495 /**
496 * the domain name to server (only important for SSL) 496 * the domain name to server (only important for SSL)
497 */ 497 */
498 char *domain; 498 char *domain;
499 499
@@ -503,12 +503,12 @@ struct Socks5Request
503 char *leho; 503 char *leho;
504 504
505 /** 505 /**
506 * The URL to fetch 506 * The URL to fetch
507 */ 507 */
508 char *url; 508 char *url;
509 509
510 /** 510 /**
511 * Handle to cURL 511 * Handle to cURL
512 */ 512 */
513 CURL *curl; 513 CURL *curl;
514 514
@@ -516,22 +516,22 @@ struct Socks5Request
516 * HTTP request headers for the curl request. 516 * HTTP request headers for the curl request.
517 */ 517 */
518 struct curl_slist *headers; 518 struct curl_slist *headers;
519 519
520 /** 520 /**
521 * HTTP response code to give to MHD for the response. 521 * HTTP response code to give to MHD for the response.
522 */ 522 */
523 unsigned int response_code; 523 unsigned int response_code;
524 524
525 /** 525 /**
526 * Number of bytes already in read buffer 526 * Number of bytes already in read buffer
527 */ 527 */
528 size_t rbuf_len; 528 size_t rbuf_len;
529 529
530 /** 530 /**
531 * Number of bytes already in write buffer 531 * Number of bytes already in write buffer
532 */ 532 */
533 size_t wbuf_len; 533 size_t wbuf_len;
534 534
535 /** 535 /**
536 * Number of bytes already in the IO buffer. 536 * Number of bytes already in the IO buffer.
537 */ 537 */
@@ -543,7 +543,7 @@ struct Socks5Request
543 struct sockaddr_storage destination_address; 543 struct sockaddr_storage destination_address;
544 544
545 /** 545 /**
546 * The socks state 546 * The socks state
547 */ 547 */
548 enum SocksPhase state; 548 enum SocksPhase state;
549 549
@@ -560,22 +560,22 @@ struct Socks5Request
560 560
561 561
562/** 562/**
563 * The port the proxy is running on (default 7777) 563 * The port the proxy is running on (default 7777)
564 */ 564 */
565static unsigned long port = GNUNET_GNS_PROXY_PORT; 565static unsigned long port = GNUNET_GNS_PROXY_PORT;
566 566
567/** 567/**
568 * The CA file (pem) to use for the proxy CA 568 * The CA file (pem) to use for the proxy CA
569 */ 569 */
570static char *cafile_opt; 570static char *cafile_opt;
571 571
572/** 572/**
573 * The listen socket of the proxy 573 * The listen socket of the proxy
574 */ 574 */
575static struct GNUNET_NETWORK_Handle *lsock; 575static struct GNUNET_NETWORK_Handle *lsock;
576 576
577/** 577/**
578 * The listen task ID 578 * The listen task ID
579 */ 579 */
580static GNUNET_SCHEDULER_TaskIdentifier ltask; 580static GNUNET_SCHEDULER_TaskIdentifier ltask;
581 581
@@ -585,22 +585,22 @@ static GNUNET_SCHEDULER_TaskIdentifier ltask;
585static GNUNET_SCHEDULER_TaskIdentifier curl_download_task; 585static GNUNET_SCHEDULER_TaskIdentifier curl_download_task;
586 586
587/** 587/**
588 * The cURL multi handle 588 * The cURL multi handle
589 */ 589 */
590static CURLM *curl_multi; 590static CURLM *curl_multi;
591 591
592/** 592/**
593 * Handle to the GNS service 593 * Handle to the GNS service
594 */ 594 */
595static struct GNUNET_GNS_Handle *gns_handle; 595static struct GNUNET_GNS_Handle *gns_handle;
596 596
597/** 597/**
598 * DLL for http/https daemons 598 * DLL for http/https daemons
599 */ 599 */
600static struct MhdHttpList *mhd_httpd_head; 600static struct MhdHttpList *mhd_httpd_head;
601 601
602/** 602/**
603 * DLL for http/https daemons 603 * DLL for http/https daemons
604 */ 604 */
605static struct MhdHttpList *mhd_httpd_tail; 605static struct MhdHttpList *mhd_httpd_tail;
606 606
@@ -621,12 +621,12 @@ static struct Socks5Request *s5r_head;
621static struct Socks5Request *s5r_tail; 621static struct Socks5Request *s5r_tail;
622 622
623/** 623/**
624 * The users local GNS master zone 624 * The users local GNS master zone
625 */ 625 */
626static struct GNUNET_CRYPTO_EccPublicSignKey local_gns_zone; 626static struct GNUNET_CRYPTO_EccPublicSignKey local_gns_zone;
627 627
628/** 628/**
629 * The users local shorten zone 629 * The users local shorten zone
630 */ 630 */
631static struct GNUNET_CRYPTO_EccPrivateKey local_shorten_zone; 631static struct GNUNET_CRYPTO_EccPrivateKey local_shorten_zone;
632 632
@@ -636,7 +636,7 @@ static struct GNUNET_CRYPTO_EccPrivateKey local_shorten_zone;
636static int do_shorten; 636static int do_shorten;
637 637
638/** 638/**
639 * The CA for SSL certificate generation 639 * The CA for SSL certificate generation
640 */ 640 */
641static struct ProxyCA proxy_ca; 641static struct ProxyCA proxy_ca;
642 642
@@ -682,11 +682,11 @@ static void
682cleanup_s5r (struct Socks5Request *s5r) 682cleanup_s5r (struct Socks5Request *s5r)
683{ 683{
684 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 684 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
685 "Cleaning up socks request\n"); 685 "Cleaning up socks request\n");
686 if (NULL != s5r->curl) 686 if (NULL != s5r->curl)
687 { 687 {
688 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 688 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
689 "Cleaning up cURL handle\n"); 689 "Cleaning up cURL handle\n");
690 curl_multi_remove_handle (curl_multi, s5r->curl); 690 curl_multi_remove_handle (curl_multi, s5r->curl);
691 curl_easy_cleanup (s5r->curl); 691 curl_easy_cleanup (s5r->curl);
692 s5r->curl = NULL; 692 s5r->curl = NULL;
@@ -703,7 +703,7 @@ cleanup_s5r (struct Socks5Request *s5r)
703 GNUNET_SCHEDULER_cancel (s5r->wtask); 703 GNUNET_SCHEDULER_cancel (s5r->wtask);
704 if (NULL != s5r->gns_lookup) 704 if (NULL != s5r->gns_lookup)
705 GNUNET_GNS_lookup_cancel (s5r->gns_lookup); 705 GNUNET_GNS_lookup_cancel (s5r->gns_lookup);
706 if (NULL != s5r->sock) 706 if (NULL != s5r->sock)
707 { 707 {
708 if (SOCKS5_SOCKET_WITH_MHD <= s5r->state) 708 if (SOCKS5_SOCKET_WITH_MHD <= s5r->state)
709 GNUNET_NETWORK_socket_free_memory_only_ (s5r->sock); 709 GNUNET_NETWORK_socket_free_memory_only_ (s5r->sock);
@@ -796,13 +796,13 @@ check_ssl_certificate (struct Socks5Request *s5r)
796 gnutls_session_t session; 796 gnutls_session_t session;
797 struct curl_slist * to_slist; 797 struct curl_slist * to_slist;
798 } gptr; 798 } gptr;
799 unsigned int cert_list_size; 799 unsigned int cert_list_size;
800 const gnutls_datum_t *chainp; 800 const gnutls_datum_t *chainp;
801 801
802 gptr.to_slist = NULL; 802 gptr.to_slist = NULL;
803 if (CURLE_OK != 803 if (CURLE_OK !=
804 curl_easy_getinfo (s5r->curl, 804 curl_easy_getinfo (s5r->curl,
805 CURLINFO_GNUTLS_SESSION, 805 CURLINFO_GNUTLS_SESSION,
806 &gptr)) 806 &gptr))
807 return GNUNET_SYSERR; 807 return GNUNET_SYSERR;
808 808
@@ -832,7 +832,7 @@ check_ssl_certificate (struct Socks5Request *s5r)
832 return GNUNET_OK; 832 return GNUNET_OK;
833} 833}
834 834
835 835
836/** 836/**
837 * We're getting an HTTP response header from cURL. Convert it to the 837 * We're getting an HTTP response header from cURL. Convert it to the
838 * MHD response headers. Mostly copies the headers, but makes special 838 * MHD response headers. Mostly copies the headers, but makes special
@@ -869,7 +869,7 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls)
869 (GNUNET_OK != check_ssl_certificate (s5r)) ) 869 (GNUNET_OK != check_ssl_certificate (s5r)) )
870 return 0; 870 return 0;
871 871
872 GNUNET_break (CURLE_OK == 872 GNUNET_break (CURLE_OK ==
873 curl_easy_getinfo (s5r->curl, 873 curl_easy_getinfo (s5r->curl,
874 CURLINFO_RESPONSE_CODE, 874 CURLINFO_RESPONSE_CODE,
875 &resp_code)); 875 &resp_code));
@@ -885,27 +885,27 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls)
885 if (NULL != s5r->leho) 885 if (NULL != s5r->leho)
886 { 886 {
887 char *cors_hdr; 887 char *cors_hdr;
888 888
889 GNUNET_asprintf (&cors_hdr, 889 GNUNET_asprintf (&cors_hdr,
890 (HTTPS_PORT == s5r->port) 890 (HTTPS_PORT == s5r->port)
891 ? "https://%s" 891 ? "https://%s"
892 : "http://%s", 892 : "http://%s",
893 s5r->leho); 893 s5r->leho);
894 894
895 GNUNET_break (MHD_YES == 895 GNUNET_break (MHD_YES ==
896 MHD_add_response_header (s5r->response, 896 MHD_add_response_header (s5r->response,
897 MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, 897 MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
898 cors_hdr)); 898 cors_hdr));
899 GNUNET_free (cors_hdr); 899 GNUNET_free (cors_hdr);
900 } 900 }
901 /* force connection to be closed after each request, as we 901 /* force connection to be closed after each request, as we
902 do not support HTTP pipelining */ 902 do not support HTTP pipelining */
903 GNUNET_break (MHD_YES == 903 GNUNET_break (MHD_YES ==
904 MHD_add_response_header (s5r->response, 904 MHD_add_response_header (s5r->response,
905 MHD_HTTP_HEADER_CONNECTION, 905 MHD_HTTP_HEADER_CONNECTION,
906 "close")); 906 "close"));
907 } 907 }
908 908
909 ndup = GNUNET_strndup (buffer, bytes); 909 ndup = GNUNET_strndup (buffer, bytes);
910 hdr_type = strtok (ndup, ":"); 910 hdr_type = strtok (ndup, ":");
911 if (NULL == hdr_type) 911 if (NULL == hdr_type)
@@ -927,9 +927,9 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls)
927 if ( (NULL != s5r->leho) && 927 if ( (NULL != s5r->leho) &&
928 (0 == strcasecmp (hdr_type, 928 (0 == strcasecmp (hdr_type,
929 MHD_HTTP_HEADER_SET_COOKIE)) ) 929 MHD_HTTP_HEADER_SET_COOKIE)) )
930 930
931 { 931 {
932 new_cookie_hdr = GNUNET_malloc (strlen (hdr_val) + 932 new_cookie_hdr = GNUNET_malloc (strlen (hdr_val) +
933 strlen (s5r->domain) + 1); 933 strlen (s5r->domain) + 1);
934 offset = 0; 934 offset = 0;
935 domain_matched = GNUNET_NO; /* make sure we match domain at most once */ 935 domain_matched = GNUNET_NO; /* make sure we match domain at most once */
@@ -946,7 +946,7 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls)
946 if (0 == strcasecmp (cookie_domain, s5r->leho + delta_cdomain)) 946 if (0 == strcasecmp (cookie_domain, s5r->leho + delta_cdomain))
947 { 947 {
948 offset += sprintf (new_cookie_hdr + offset, 948 offset += sprintf (new_cookie_hdr + offset,
949 " domain=%s;", 949 " domain=%s;",
950 s5r->domain); 950 s5r->domain);
951 continue; 951 continue;
952 } 952 }
@@ -954,9 +954,9 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls)
954 else if (0 == strcmp (cookie_domain, s5r->leho)) 954 else if (0 == strcmp (cookie_domain, s5r->leho))
955 { 955 {
956 offset += sprintf (new_cookie_hdr + offset, 956 offset += sprintf (new_cookie_hdr + offset,
957 " domain=%s;", 957 " domain=%s;",
958 s5r->domain); 958 s5r->domain);
959 continue; 959 continue;
960 } 960 }
961 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 961 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
962 _("Cookie domain `%s' supplied by server is invalid\n"), 962 _("Cookie domain `%s' supplied by server is invalid\n"),
@@ -973,14 +973,14 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls)
973 if (0 == strcasecmp (MHD_HTTP_HEADER_LOCATION, hdr_type)) 973 if (0 == strcasecmp (MHD_HTTP_HEADER_LOCATION, hdr_type))
974 { 974 {
975 char *leho_host; 975 char *leho_host;
976 976
977 GNUNET_asprintf (&leho_host, 977 GNUNET_asprintf (&leho_host,
978 (HTTPS_PORT != s5r->port) 978 (HTTPS_PORT != s5r->port)
979 ? "http://%s" 979 ? "http://%s"
980 : "https://%s", 980 : "https://%s",
981 s5r->leho); 981 s5r->leho);
982 if (0 == strncmp (leho_host, 982 if (0 == strncmp (leho_host,
983 hdr_val, 983 hdr_val,
984 strlen (leho_host))) 984 strlen (leho_host)))
985 { 985 {
986 GNUNET_asprintf (&new_location, 986 GNUNET_asprintf (&new_location,
@@ -1051,12 +1051,12 @@ curl_download_cb (void *ptr, size_t size, size_t nmemb, void* ctx)
1051 "Pausing CURL download, not enough space\n"); 1051 "Pausing CURL download, not enough space\n");
1052 return CURL_WRITEFUNC_PAUSE; /* not enough space */ 1052 return CURL_WRITEFUNC_PAUSE; /* not enough space */
1053 } 1053 }
1054 memcpy (&s5r->io_buf[s5r->io_len], 1054 memcpy (&s5r->io_buf[s5r->io_len],
1055 ptr, 1055 ptr,
1056 total); 1056 total);
1057 s5r->io_len += total; 1057 s5r->io_len += total;
1058 if (s5r->io_len == total) 1058 if (s5r->io_len == total)
1059 run_mhd_now (s5r->hd); 1059 run_mhd_now (s5r->hd);
1060 return total; 1060 return total;
1061} 1061}
1062 1062
@@ -1178,7 +1178,7 @@ curl_download_prepare ()
1178 GNUNET_NETWORK_fdset_destroy (gws); 1178 GNUNET_NETWORK_fdset_destroy (gws);
1179 GNUNET_NETWORK_fdset_destroy (grs); 1179 GNUNET_NETWORK_fdset_destroy (grs);
1180 } 1180 }
1181 else 1181 else
1182 { 1182 {
1183 curl_download_task = GNUNET_SCHEDULER_add_delayed (rtime, 1183 curl_download_task = GNUNET_SCHEDULER_add_delayed (rtime,
1184 &curl_task_download, 1184 &curl_task_download,
@@ -1194,7 +1194,7 @@ curl_download_prepare ()
1194 * @param tc task context 1194 * @param tc task context
1195 */ 1195 */
1196static void 1196static void
1197curl_task_download (void *cls, 1197curl_task_download (void *cls,
1198 const struct GNUNET_SCHEDULER_TaskContext *tc) 1198 const struct GNUNET_SCHEDULER_TaskContext *tc)
1199{ 1199{
1200 int running; 1200 int running;
@@ -1206,7 +1206,7 @@ curl_task_download (void *cls,
1206 curl_download_task = GNUNET_SCHEDULER_NO_TASK; 1206 curl_download_task = GNUNET_SCHEDULER_NO_TASK;
1207 do 1207 do
1208 { 1208 {
1209 running = 0; 1209 running = 0;
1210 mret = curl_multi_perform (curl_multi, &running); 1210 mret = curl_multi_perform (curl_multi, &running);
1211 while (NULL != (msg = curl_multi_info_read (curl_multi, &msgnum))) 1211 while (NULL != (msg = curl_multi_info_read (curl_multi, &msgnum)))
1212 { 1212 {
@@ -1232,7 +1232,7 @@ curl_task_download (void *cls,
1232 case CURLE_GOT_NOTHING: 1232 case CURLE_GOT_NOTHING:
1233 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1233 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1234 "CURL download completed.\n"); 1234 "CURL download completed.\n");
1235 s5r->state = SOCKS5_SOCKET_DOWNLOAD_DONE; 1235 s5r->state = SOCKS5_SOCKET_DOWNLOAD_DONE;
1236 run_mhd_now (s5r->hd); 1236 run_mhd_now (s5r->hd);
1237 break; 1237 break;
1238 default: 1238 default:
@@ -1241,7 +1241,7 @@ curl_task_download (void *cls,
1241 curl_easy_strerror (msg->data.result)); 1241 curl_easy_strerror (msg->data.result));
1242 /* FIXME: indicate error somehow? close MHD connection badly as well? */ 1242 /* FIXME: indicate error somehow? close MHD connection badly as well? */
1243 s5r->state = SOCKS5_SOCKET_DOWNLOAD_DONE; 1243 s5r->state = SOCKS5_SOCKET_DOWNLOAD_DONE;
1244 run_mhd_now (s5r->hd); 1244 run_mhd_now (s5r->hd);
1245 break; 1245 break;
1246 } 1246 }
1247 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1247 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1262,12 +1262,12 @@ curl_task_download (void *cls,
1262 break; 1262 break;
1263 } 1263 }
1264 }; 1264 };
1265 } while (mret == CURLM_CALL_MULTI_PERFORM); 1265 } while (mret == CURLM_CALL_MULTI_PERFORM);
1266 if (CURLM_OK != mret) 1266 if (CURLM_OK != mret)
1267 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1267 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1268 "%s failed at %s:%d: `%s'\n", 1268 "%s failed at %s:%d: `%s'\n",
1269 "curl_multi_perform", __FILE__, __LINE__, 1269 "curl_multi_perform", __FILE__, __LINE__,
1270 curl_multi_strerror (mret)); 1270 curl_multi_strerror (mret));
1271 if (0 == running) 1271 if (0 == running)
1272 { 1272 {
1273 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1273 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1418,7 +1418,7 @@ create_response (void *cls,
1418 if (NULL == s5r->curl) 1418 if (NULL == s5r->curl)
1419 return MHD_queue_response (con, 1419 return MHD_queue_response (con,
1420 MHD_HTTP_INTERNAL_SERVER_ERROR, 1420 MHD_HTTP_INTERNAL_SERVER_ERROR,
1421 curl_failure_response); 1421 curl_failure_response);
1422 curl_easy_setopt (s5r->curl, CURLOPT_HEADERFUNCTION, &curl_check_hdr); 1422 curl_easy_setopt (s5r->curl, CURLOPT_HEADERFUNCTION, &curl_check_hdr);
1423 curl_easy_setopt (s5r->curl, CURLOPT_HEADERDATA, s5r); 1423 curl_easy_setopt (s5r->curl, CURLOPT_HEADERDATA, s5r);
1424 curl_easy_setopt (s5r->curl, CURLOPT_FOLLOWLOCATION, 0); 1424 curl_easy_setopt (s5r->curl, CURLOPT_FOLLOWLOCATION, 0);
@@ -1436,11 +1436,11 @@ create_response (void *cls,
1436 ? "http://%s:%d%s" 1436 ? "http://%s:%d%s"
1437 : "https://%s:%d%s", 1437 : "https://%s:%d%s",
1438 ipaddr, 1438 ipaddr,
1439 port, 1439 port,
1440 s5r->url); 1440 s5r->url);
1441 curl_easy_setopt (s5r->curl, 1441 curl_easy_setopt (s5r->curl,
1442 CURLOPT_URL, 1442 CURLOPT_URL,
1443 curlurl); 1443 curlurl);
1444 GNUNET_free (curlurl); 1444 GNUNET_free (curlurl);
1445 1445
1446 if (0 == strcasecmp (meth, MHD_HTTP_METHOD_PUT)) 1446 if (0 == strcasecmp (meth, MHD_HTTP_METHOD_PUT))
@@ -1451,10 +1451,10 @@ create_response (void *cls,
1451 curl_easy_setopt (s5r->curl, CURLOPT_WRITEDATA, s5r); 1451 curl_easy_setopt (s5r->curl, CURLOPT_WRITEDATA, s5r);
1452 curl_easy_setopt (s5r->curl, CURLOPT_READFUNCTION, &curl_upload_cb); 1452 curl_easy_setopt (s5r->curl, CURLOPT_READFUNCTION, &curl_upload_cb);
1453 curl_easy_setopt (s5r->curl, CURLOPT_READDATA, s5r); 1453 curl_easy_setopt (s5r->curl, CURLOPT_READDATA, s5r);
1454 } 1454 }
1455 else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_POST)) 1455 else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_POST))
1456 { 1456 {
1457 s5r->state = SOCKS5_SOCKET_UPLOAD_STARTED; 1457 s5r->state = SOCKS5_SOCKET_UPLOAD_STARTED;
1458 curl_easy_setopt (s5r->curl, CURLOPT_POST, 1); 1458 curl_easy_setopt (s5r->curl, CURLOPT_POST, 1);
1459 curl_easy_setopt (s5r->curl, CURLOPT_WRITEFUNCTION, &curl_download_cb); 1459 curl_easy_setopt (s5r->curl, CURLOPT_WRITEFUNCTION, &curl_download_cb);
1460 curl_easy_setopt (s5r->curl, CURLOPT_WRITEDATA, s5r); 1460 curl_easy_setopt (s5r->curl, CURLOPT_WRITEDATA, s5r);
@@ -1463,12 +1463,12 @@ create_response (void *cls,
1463 } 1463 }
1464 else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_HEAD)) 1464 else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_HEAD))
1465 { 1465 {
1466 s5r->state = SOCKS5_SOCKET_DOWNLOAD_STARTED; 1466 s5r->state = SOCKS5_SOCKET_DOWNLOAD_STARTED;
1467 curl_easy_setopt (s5r->curl, CURLOPT_NOBODY, 1); 1467 curl_easy_setopt (s5r->curl, CURLOPT_NOBODY, 1);
1468 } 1468 }
1469 else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_GET)) 1469 else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_GET))
1470 { 1470 {
1471 s5r->state = SOCKS5_SOCKET_DOWNLOAD_STARTED; 1471 s5r->state = SOCKS5_SOCKET_DOWNLOAD_STARTED;
1472 curl_easy_setopt (s5r->curl, CURLOPT_HTTPGET, 1); 1472 curl_easy_setopt (s5r->curl, CURLOPT_HTTPGET, 1);
1473 curl_easy_setopt (s5r->curl, CURLOPT_WRITEFUNCTION, &curl_download_cb); 1473 curl_easy_setopt (s5r->curl, CURLOPT_WRITEFUNCTION, &curl_download_cb);
1474 curl_easy_setopt (s5r->curl, CURLOPT_WRITEDATA, s5r); 1474 curl_easy_setopt (s5r->curl, CURLOPT_WRITEDATA, s5r);
@@ -1479,10 +1479,10 @@ create_response (void *cls,
1479 _("Unsupported HTTP method `%s'\n"), 1479 _("Unsupported HTTP method `%s'\n"),
1480 meth); 1480 meth);
1481 curl_easy_cleanup (s5r->curl); 1481 curl_easy_cleanup (s5r->curl);
1482 s5r->curl = NULL; 1482 s5r->curl = NULL;
1483 return MHD_NO; 1483 return MHD_NO;
1484 } 1484 }
1485 1485
1486 if (0 == strcasecmp (ver, MHD_HTTP_VERSION_1_0)) 1486 if (0 == strcasecmp (ver, MHD_HTTP_VERSION_1_0))
1487 { 1487 {
1488 curl_easy_setopt (s5r->curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); 1488 curl_easy_setopt (s5r->curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
@@ -1495,26 +1495,26 @@ create_response (void *cls,
1495 { 1495 {
1496 curl_easy_setopt (s5r->curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE); 1496 curl_easy_setopt (s5r->curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE);
1497 } 1497 }
1498 1498
1499 if (HTTPS_PORT == s5r->port) 1499 if (HTTPS_PORT == s5r->port)
1500 { 1500 {
1501 curl_easy_setopt (s5r->curl, CURLOPT_USE_SSL, CURLUSESSL_ALL); 1501 curl_easy_setopt (s5r->curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);
1502 curl_easy_setopt (s5r->curl, CURLOPT_SSL_VERIFYPEER, 1L); 1502 curl_easy_setopt (s5r->curl, CURLOPT_SSL_VERIFYPEER, 1L);
1503 /* Disable cURL checking the hostname, as we will check ourselves 1503 /* Disable cURL checking the hostname, as we will check ourselves
1504 as only we have the domain name or the LEHO or the DANE record */ 1504 as only we have the domain name or the LEHO or the DANE record */
1505 curl_easy_setopt (s5r->curl, CURLOPT_SSL_VERIFYHOST, 0L); 1505 curl_easy_setopt (s5r->curl, CURLOPT_SSL_VERIFYHOST, 0L);
1506 } 1506 }
1507 else 1507 else
1508 { 1508 {
1509 curl_easy_setopt (s5r->curl, CURLOPT_USE_SSL, CURLUSESSL_NONE); 1509 curl_easy_setopt (s5r->curl, CURLOPT_USE_SSL, CURLUSESSL_NONE);
1510 } 1510 }
1511 1511
1512 if (CURLM_OK != curl_multi_add_handle (curl_multi, s5r->curl)) 1512 if (CURLM_OK != curl_multi_add_handle (curl_multi, s5r->curl))
1513 { 1513 {
1514 GNUNET_break (0); 1514 GNUNET_break (0);
1515 curl_easy_cleanup (s5r->curl); 1515 curl_easy_cleanup (s5r->curl);
1516 s5r->curl = NULL; 1516 s5r->curl = NULL;
1517 return MHD_NO; 1517 return MHD_NO;
1518 } 1518 }
1519 MHD_get_connection_values (con, 1519 MHD_get_connection_values (con,
1520 MHD_HEADER_KIND, 1520 MHD_HEADER_KIND,
@@ -1522,18 +1522,18 @@ create_response (void *cls,
1522 curl_easy_setopt (s5r->curl, CURLOPT_HTTPHEADER, s5r->headers); 1522 curl_easy_setopt (s5r->curl, CURLOPT_HTTPHEADER, s5r->headers);
1523 curl_download_prepare (); 1523 curl_download_prepare ();
1524 return MHD_YES; 1524 return MHD_YES;
1525 } 1525 }
1526 1526
1527 /* continuing to process request */ 1527 /* continuing to process request */
1528 if (0 != *upload_data_size) 1528 if (0 != *upload_data_size)
1529 { 1529 {
1530 left = GNUNET_MIN (*upload_data_size, 1530 left = GNUNET_MIN (*upload_data_size,
1531 sizeof (s5r->io_buf) - s5r->io_len); 1531 sizeof (s5r->io_buf) - s5r->io_len);
1532 memcpy (&s5r->io_buf[s5r->io_len], 1532 memcpy (&s5r->io_buf[s5r->io_len],
1533 upload_data, 1533 upload_data,
1534 left); 1534 left);
1535 s5r->io_len += left; 1535 s5r->io_len += left;
1536 *upload_data_size -= left; 1536 *upload_data_size -= left;
1537 GNUNET_assert (NULL != s5r->curl); 1537 GNUNET_assert (NULL != s5r->curl);
1538 curl_easy_pause (s5r->curl, CURLPAUSE_CONT); 1538 curl_easy_pause (s5r->curl, CURLPAUSE_CONT);
1539 curl_download_prepare (); 1539 curl_download_prepare ();
@@ -1545,12 +1545,12 @@ create_response (void *cls,
1545 "Finished processing UPLOAD\n"); 1545 "Finished processing UPLOAD\n");
1546 s5r->state = SOCKS5_SOCKET_UPLOAD_DONE; 1546 s5r->state = SOCKS5_SOCKET_UPLOAD_DONE;
1547 } 1547 }
1548 if (NULL == s5r->response) 1548 if (NULL == s5r->response)
1549 return MHD_YES; /* too early to queue response, did not yet get headers from cURL */ 1549 return MHD_YES; /* too early to queue response, did not yet get headers from cURL */
1550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1551 "Queueing response with MHD\n"); 1551 "Queueing response with MHD\n");
1552 return MHD_queue_response (con, 1552 return MHD_queue_response (con,
1553 s5r->response_code, 1553 s5r->response_code,
1554 s5r->response); 1554 s5r->response);
1555} 1555}
1556 1556
@@ -1582,7 +1582,7 @@ mhd_completed_cb (void *cls,
1582 "MHD encountered error handling request: %d\n", 1582 "MHD encountered error handling request: %d\n",
1583 toe); 1583 toe);
1584 cleanup_s5r (s5r); 1584 cleanup_s5r (s5r);
1585 *con_cls = NULL; 1585 *con_cls = NULL;
1586} 1586}
1587 1587
1588 1588
@@ -1590,7 +1590,7 @@ mhd_completed_cb (void *cls,
1590 * Function called when MHD first processes an incoming connection. 1590 * Function called when MHD first processes an incoming connection.
1591 * Gives us the respective URI information. 1591 * Gives us the respective URI information.
1592 * 1592 *
1593 * We use this to associate the `struct MHD_Connection` with our 1593 * We use this to associate the `struct MHD_Connection` with our
1594 * internal `struct Socks5Request` data structure (by checking 1594 * internal `struct Socks5Request` data structure (by checking
1595 * for matching sockets). 1595 * for matching sockets).
1596 * 1596 *
@@ -1600,7 +1600,7 @@ mhd_completed_cb (void *cls,
1600 * @return the `struct Socks5Request` that this @a connection is for 1600 * @return the `struct Socks5Request` that this @a connection is for
1601 */ 1601 */
1602static void * 1602static void *
1603mhd_log_callback (void *cls, 1603mhd_log_callback (void *cls,
1604 const char *url, 1604 const char *url,
1605 struct MHD_Connection *connection) 1605 struct MHD_Connection *connection)
1606{ 1606{
@@ -1610,7 +1610,7 @@ mhd_log_callback (void *cls,
1610 1610
1611 ci = MHD_get_connection_info (connection, 1611 ci = MHD_get_connection_info (connection,
1612 MHD_CONNECTION_INFO_CONNECTION_FD); 1612 MHD_CONNECTION_INFO_CONNECTION_FD);
1613 if (NULL == ci) 1613 if (NULL == ci)
1614 { 1614 {
1615 GNUNET_break (0); 1615 GNUNET_break (0);
1616 return NULL; 1616 return NULL;
@@ -1770,8 +1770,8 @@ do_httpd (void *cls,
1770 const struct GNUNET_SCHEDULER_TaskContext *tc) 1770 const struct GNUNET_SCHEDULER_TaskContext *tc)
1771{ 1771{
1772 struct MhdHttpList *hd = cls; 1772 struct MhdHttpList *hd = cls;
1773 1773
1774 hd->httpd_task = GNUNET_SCHEDULER_NO_TASK; 1774 hd->httpd_task = GNUNET_SCHEDULER_NO_TASK;
1775 MHD_run (hd->daemon); 1775 MHD_run (hd->daemon);
1776 schedule_httpd (hd); 1776 schedule_httpd (hd);
1777} 1777}
@@ -1785,10 +1785,10 @@ do_httpd (void *cls,
1785static void 1785static void
1786run_mhd_now (struct MhdHttpList *hd) 1786run_mhd_now (struct MhdHttpList *hd)
1787{ 1787{
1788 if (GNUNET_SCHEDULER_NO_TASK != 1788 if (GNUNET_SCHEDULER_NO_TASK !=
1789 hd->httpd_task) 1789 hd->httpd_task)
1790 GNUNET_SCHEDULER_cancel (hd->httpd_task); 1790 GNUNET_SCHEDULER_cancel (hd->httpd_task);
1791 hd->httpd_task = GNUNET_SCHEDULER_add_now (&do_httpd, 1791 hd->httpd_task = GNUNET_SCHEDULER_add_now (&do_httpd,
1792 hd); 1792 hd);
1793} 1793}
1794 1794
@@ -1801,7 +1801,7 @@ run_mhd_now (struct MhdHttpList *hd)
1801 * @return NULL on error 1801 * @return NULL on error
1802 */ 1802 */
1803static void* 1803static void*
1804load_file (const char* filename, 1804load_file (const char* filename,
1805 unsigned int* size) 1805 unsigned int* size)
1806{ 1806{
1807 void *buffer; 1807 void *buffer;
@@ -1832,7 +1832,7 @@ load_file (const char* filename,
1832 * @return #GNUNET_OK on success 1832 * @return #GNUNET_OK on success
1833 */ 1833 */
1834static int 1834static int
1835load_key_from_file (gnutls_x509_privkey_t key, 1835load_key_from_file (gnutls_x509_privkey_t key,
1836 const char* keyfile) 1836 const char* keyfile)
1837{ 1837{
1838 gnutls_datum_t key_data; 1838 gnutls_datum_t key_data;
@@ -1860,7 +1860,7 @@ load_key_from_file (gnutls_x509_privkey_t key,
1860 * @return #GNUNET_OK on success 1860 * @return #GNUNET_OK on success
1861 */ 1861 */
1862static int 1862static int
1863load_cert_from_file (gnutls_x509_crt_t crt, 1863load_cert_from_file (gnutls_x509_crt_t crt,
1864 const char* certfile) 1864 const char* certfile)
1865{ 1865{
1866 gnutls_datum_t cert_data; 1866 gnutls_datum_t cert_data;
@@ -1896,8 +1896,8 @@ generate_gns_certificate (const char *name)
1896 struct tm *tm_data; 1896 struct tm *tm_data;
1897 struct ProxyGNSCertificate *pgc; 1897 struct ProxyGNSCertificate *pgc;
1898 1898
1899 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1899 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1900 "Generating TLS/SSL certificate for `%s'\n", 1900 "Generating TLS/SSL certificate for `%s'\n",
1901 name); 1901 name);
1902 GNUNET_break (GNUTLS_E_SUCCESS == gnutls_x509_crt_init (&request)); 1902 GNUNET_break (GNUTLS_E_SUCCESS == gnutls_x509_crt_init (&request));
1903 GNUNET_break (GNUTLS_E_SUCCESS == gnutls_x509_crt_set_key (request, proxy_ca.key)); 1903 GNUNET_break (GNUTLS_E_SUCCESS == gnutls_x509_crt_set_key (request, proxy_ca.key));
@@ -1914,15 +1914,15 @@ generate_gns_certificate (const char *name)
1914 &serial, 1914 &serial,
1915 sizeof (serial)); 1915 sizeof (serial));
1916 etime = time (NULL); 1916 etime = time (NULL);
1917 tm_data = localtime (&etime); 1917 tm_data = localtime (&etime);
1918 gnutls_x509_crt_set_activation_time (request, 1918 gnutls_x509_crt_set_activation_time (request,
1919 etime); 1919 etime);
1920 tm_data->tm_year++; 1920 tm_data->tm_year++;
1921 etime = mktime (tm_data); 1921 etime = mktime (tm_data);
1922 gnutls_x509_crt_set_expiration_time (request, 1922 gnutls_x509_crt_set_expiration_time (request,
1923 etime); 1923 etime);
1924 gnutls_x509_crt_sign (request, 1924 gnutls_x509_crt_sign (request,
1925 proxy_ca.cert, 1925 proxy_ca.cert,
1926 proxy_ca.key); 1926 proxy_ca.key);
1927 key_buf_size = sizeof (pgc->key); 1927 key_buf_size = sizeof (pgc->key);
1928 cert_buf_size = sizeof (pgc->cert); 1928 cert_buf_size = sizeof (pgc->cert);
@@ -1954,10 +1954,10 @@ lookup_ssl_httpd (const char* domain)
1954 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1954 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1955 "Starting fresh MHD HTTPS instance for domain `%s'\n", 1955 "Starting fresh MHD HTTPS instance for domain `%s'\n",
1956 domain); 1956 domain);
1957 pgc = generate_gns_certificate (domain); 1957 pgc = generate_gns_certificate (domain);
1958 hd = GNUNET_new (struct MhdHttpList); 1958 hd = GNUNET_new (struct MhdHttpList);
1959 hd->is_ssl = GNUNET_YES; 1959 hd->is_ssl = GNUNET_YES;
1960 hd->domain = GNUNET_strdup (domain); 1960 hd->domain = GNUNET_strdup (domain);
1961 hd->proxy_cert = pgc; 1961 hd->proxy_cert = pgc;
1962 hd->daemon = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_SSL | MHD_USE_NO_LISTEN_SOCKET, 1962 hd->daemon = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_SSL | MHD_USE_NO_LISTEN_SOCKET,
1963 0, 1963 0,
@@ -1975,8 +1975,8 @@ lookup_ssl_httpd (const char* domain)
1975 GNUNET_free (hd); 1975 GNUNET_free (hd);
1976 return NULL; 1976 return NULL;
1977 } 1977 }
1978 GNUNET_CONTAINER_DLL_insert (mhd_httpd_head, 1978 GNUNET_CONTAINER_DLL_insert (mhd_httpd_head,
1979 mhd_httpd_tail, 1979 mhd_httpd_tail,
1980 hd); 1980 hd);
1981 return hd; 1981 return hd;
1982} 1982}
@@ -2003,7 +2003,7 @@ timeout_s5r_handshake (void *cls,
2003 2003
2004/** 2004/**
2005 * We're done with the Socks5 protocol, now we need to pass the 2005 * We're done with the Socks5 protocol, now we need to pass the
2006 * connection data through to the final destination, either 2006 * connection data through to the final destination, either
2007 * direct (if the protocol might not be HTTP), or via MHD 2007 * direct (if the protocol might not be HTTP), or via MHD
2008 * (if the port looks like it should be HTTP). 2008 * (if the port looks like it should be HTTP).
2009 * 2009 *
@@ -2078,7 +2078,7 @@ do_write (void *cls,
2078 if (len <= 0) 2078 if (len <= 0)
2079 { 2079 {
2080 /* write error: connection closed, shutdown, etc.; just clean up */ 2080 /* write error: connection closed, shutdown, etc.; just clean up */
2081 cleanup_s5r (s5r); 2081 cleanup_s5r (s5r);
2082 return; 2082 return;
2083 } 2083 }
2084 memmove (s5r->wbuf, 2084 memmove (s5r->wbuf,
@@ -2099,10 +2099,10 @@ do_write (void *cls,
2099 2099
2100 switch (s5r->state) 2100 switch (s5r->state)
2101 { 2101 {
2102 case SOCKS5_INIT: 2102 case SOCKS5_INIT:
2103 GNUNET_assert (0); 2103 GNUNET_assert (0);
2104 break; 2104 break;
2105 case SOCKS5_REQUEST: 2105 case SOCKS5_REQUEST:
2106 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != s5r->rtask); 2106 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != s5r->rtask);
2107 break; 2107 break;
2108 case SOCKS5_DATA_TRANSFER: 2108 case SOCKS5_DATA_TRANSFER:
@@ -2136,7 +2136,7 @@ signal_socks_failure (struct Socks5Request *s5r,
2136 s_resp->reply = sc; 2136 s_resp->reply = sc;
2137 s5r->state = SOCKS5_WRITE_THEN_CLEANUP; 2137 s5r->state = SOCKS5_WRITE_THEN_CLEANUP;
2138 if (GNUNET_SCHEDULER_NO_TASK != s5r->wtask) 2138 if (GNUNET_SCHEDULER_NO_TASK != s5r->wtask)
2139 s5r->wtask = 2139 s5r->wtask =
2140 GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, 2140 GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
2141 s5r->sock, 2141 s5r->sock,
2142 &do_write, s5r); 2142 &do_write, s5r);
@@ -2159,16 +2159,16 @@ signal_socks_success (struct Socks5Request *s5r)
2159 s_resp->reserved = 0; 2159 s_resp->reserved = 0;
2160 s_resp->addr_type = SOCKS5_AT_IPV4; 2160 s_resp->addr_type = SOCKS5_AT_IPV4;
2161 /* zero out IPv4 address and port */ 2161 /* zero out IPv4 address and port */
2162 memset (&s_resp[1], 2162 memset (&s_resp[1],
2163 0, 2163 0,
2164 sizeof (struct in_addr) + sizeof (uint16_t)); 2164 sizeof (struct in_addr) + sizeof (uint16_t));
2165 s5r->wbuf_len += sizeof (struct Socks5ServerResponseMessage) + 2165 s5r->wbuf_len += sizeof (struct Socks5ServerResponseMessage) +
2166 sizeof (struct in_addr) + sizeof (uint16_t); 2166 sizeof (struct in_addr) + sizeof (uint16_t);
2167 if (GNUNET_SCHEDULER_NO_TASK == s5r->wtask) 2167 if (GNUNET_SCHEDULER_NO_TASK == s5r->wtask)
2168 s5r->wtask = 2168 s5r->wtask =
2169 GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, 2169 GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
2170 s5r->sock, 2170 s5r->sock,
2171 &do_write, s5r); 2171 &do_write, s5r);
2172} 2172}
2173 2173
2174 2174
@@ -2207,7 +2207,7 @@ handle_gns_result (void *cls,
2207 } 2207 }
2208 if (GNUNET_YES == got_ip) 2208 if (GNUNET_YES == got_ip)
2209 break; 2209 break;
2210 if (GNUNET_OK != 2210 if (GNUNET_OK !=
2211 GNUNET_NETWORK_test_pf (PF_INET)) 2211 GNUNET_NETWORK_test_pf (PF_INET))
2212 break; 2212 break;
2213 got_ip = GNUNET_YES; 2213 got_ip = GNUNET_YES;
@@ -2222,7 +2222,7 @@ handle_gns_result (void *cls,
2222#endif 2222#endif
2223 } 2223 }
2224 break; 2224 break;
2225 case GNUNET_DNSPARSER_TYPE_AAAA: 2225 case GNUNET_DNSPARSER_TYPE_AAAA:
2226 { 2226 {
2227 struct sockaddr_in6 *in; 2227 struct sockaddr_in6 *in;
2228 2228
@@ -2232,8 +2232,8 @@ handle_gns_result (void *cls,
2232 break; 2232 break;
2233 } 2233 }
2234 if (GNUNET_YES == got_ip) 2234 if (GNUNET_YES == got_ip)
2235 break; 2235 break;
2236 if (GNUNET_OK != 2236 if (GNUNET_OK !=
2237 GNUNET_NETWORK_test_pf (PF_INET)) 2237 GNUNET_NETWORK_test_pf (PF_INET))
2238 break; 2238 break;
2239 /* FIXME: allow user to disable IPv6 per configuration option... */ 2239 /* FIXME: allow user to disable IPv6 per configuration option... */
@@ -2248,7 +2248,7 @@ handle_gns_result (void *cls,
2248 in->sin6_len = sizeof (*in); 2248 in->sin6_len = sizeof (*in);
2249#endif 2249#endif
2250 } 2250 }
2251 break; 2251 break;
2252 case GNUNET_NAMESTORE_TYPE_VPN: 2252 case GNUNET_NAMESTORE_TYPE_VPN:
2253 GNUNET_break (0); /* should have been translated within GNS */ 2253 GNUNET_break (0); /* should have been translated within GNS */
2254 break; 2254 break;
@@ -2264,14 +2264,14 @@ handle_gns_result (void *cls,
2264 } 2264 }
2265 if (GNUNET_YES != got_ip) 2265 if (GNUNET_YES != got_ip)
2266 { 2266 {
2267 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2267 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2268 "Name resolution failed to yield useful IP address.\n"); 2268 "Name resolution failed to yield useful IP address.\n");
2269 signal_socks_failure (s5r, 2269 signal_socks_failure (s5r,
2270 SOCKS5_STATUS_GENERAL_FAILURE); 2270 SOCKS5_STATUS_GENERAL_FAILURE);
2271 return; 2271 return;
2272 } 2272 }
2273 s5r->state = SOCKS5_DATA_TRANSFER; 2273 s5r->state = SOCKS5_DATA_TRANSFER;
2274 signal_socks_success (s5r); 2274 signal_socks_success (s5r);
2275} 2275}
2276 2276
2277 2277
@@ -2314,12 +2314,12 @@ do_s5r_read (void *cls,
2314 if ( (NULL != tc->read_ready) && 2314 if ( (NULL != tc->read_ready) &&
2315 (GNUNET_NETWORK_fdset_isset (tc->read_ready, s5r->sock)) ) 2315 (GNUNET_NETWORK_fdset_isset (tc->read_ready, s5r->sock)) )
2316 { 2316 {
2317 rlen = GNUNET_NETWORK_socket_recv (s5r->sock, 2317 rlen = GNUNET_NETWORK_socket_recv (s5r->sock,
2318 &s5r->rbuf[s5r->rbuf_len], 2318 &s5r->rbuf[s5r->rbuf_len],
2319 sizeof (s5r->rbuf) - s5r->rbuf_len); 2319 sizeof (s5r->rbuf) - s5r->rbuf_len);
2320 if (rlen <= 0) 2320 if (rlen <= 0)
2321 { 2321 {
2322 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2322 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2323 "socks5 client disconnected.\n"); 2323 "socks5 client disconnected.\n");
2324 cleanup_s5r (s5r); 2324 cleanup_s5r (s5r);
2325 return; 2325 return;
@@ -2449,7 +2449,7 @@ do_s5r_read (void *cls,
2449 GNUNET_NO /* only cached */, 2449 GNUNET_NO /* only cached */,
2450 (GNUNET_YES == do_shorten) ? &local_shorten_zone : NULL, 2450 (GNUNET_YES == do_shorten) ? &local_shorten_zone : NULL,
2451 &handle_gns_result, 2451 &handle_gns_result,
2452 s5r); 2452 s5r);
2453 break; 2453 break;
2454 } 2454 }
2455 default: 2455 default:
@@ -2469,7 +2469,7 @@ do_s5r_read (void *cls,
2469 GNUNET_break_op (0); 2469 GNUNET_break_op (0);
2470 signal_socks_failure (s5r, 2470 signal_socks_failure (s5r,
2471 SOCKS5_STATUS_GENERAL_FAILURE); 2471 SOCKS5_STATUS_GENERAL_FAILURE);
2472 return; 2472 return;
2473 } 2473 }
2474 if (SOCKS5_DATA_TRANSFER == s5r->state) 2474 if (SOCKS5_DATA_TRANSFER == s5r->state)
2475 { 2475 {
@@ -2478,7 +2478,7 @@ do_s5r_read (void *cls,
2478 } 2478 }
2479 /* We are done reading right now */ 2479 /* We are done reading right now */
2480 GNUNET_SCHEDULER_cancel (s5r->rtask); 2480 GNUNET_SCHEDULER_cancel (s5r->rtask);
2481 s5r->rtask = GNUNET_SCHEDULER_NO_TASK; 2481 s5r->rtask = GNUNET_SCHEDULER_NO_TASK;
2482 return; 2482 return;
2483 case SOCKS5_RESOLVING: 2483 case SOCKS5_RESOLVING:
2484 GNUNET_assert (0); 2484 GNUNET_assert (0);
@@ -2500,7 +2500,7 @@ do_s5r_read (void *cls,
2500 * @param tc the scheduler context 2500 * @param tc the scheduler context
2501 */ 2501 */
2502static void 2502static void
2503do_accept (void *cls, 2503do_accept (void *cls,
2504 const struct GNUNET_SCHEDULER_TaskContext *tc) 2504 const struct GNUNET_SCHEDULER_TaskContext *tc)
2505{ 2505{
2506 struct GNUNET_NETWORK_Handle *s; 2506 struct GNUNET_NETWORK_Handle *s;
@@ -2595,8 +2595,8 @@ do_shutdown (void *cls,
2595/** 2595/**
2596 * Continue initialization after we have our zone information. 2596 * Continue initialization after we have our zone information.
2597 */ 2597 */
2598static void 2598static void
2599run_cont () 2599run_cont ()
2600{ 2600{
2601 struct MhdHttpList *hd; 2601 struct MhdHttpList *hd;
2602 struct sockaddr_in sa; 2602 struct sockaddr_in sa;
@@ -2612,7 +2612,7 @@ run_cont ()
2612 lsock = GNUNET_NETWORK_socket_create (AF_INET, 2612 lsock = GNUNET_NETWORK_socket_create (AF_INET,
2613 SOCK_STREAM, 2613 SOCK_STREAM,
2614 0); 2614 0);
2615 if (NULL == lsock) 2615 if (NULL == lsock)
2616 { 2616 {
2617 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); 2617 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket");
2618 GNUNET_SCHEDULER_shutdown (); 2618 GNUNET_SCHEDULER_shutdown ();
@@ -2666,7 +2666,7 @@ run_cont ()
2666} 2666}
2667 2667
2668 2668
2669/** 2669/**
2670 * Method called to inform about the egos of the shorten zone of this peer. 2670 * Method called to inform about the egos of the shorten zone of this peer.
2671 * 2671 *
2672 * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get, 2672 * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get,
@@ -2674,7 +2674,7 @@ run_cont ()
2674 * @a ego does indicate an error (i.e. name is taken or no default 2674 * @a ego does indicate an error (i.e. name is taken or no default
2675 * value is known). If @a ego is non-NULL and if '*ctx' 2675 * value is known). If @a ego is non-NULL and if '*ctx'
2676 * is set in those callbacks, the value WILL be passed to a subsequent 2676 * is set in those callbacks, the value WILL be passed to a subsequent
2677 * call to the identity callback of #GNUNET_IDENTITY_connect (if 2677 * call to the identity callback of #GNUNET_IDENTITY_connect (if
2678 * that one was not NULL). 2678 * that one was not NULL).
2679 * 2679 *
2680 * @param cls closure, NULL 2680 * @param cls closure, NULL
@@ -2706,7 +2706,7 @@ identity_shorten_cb (void *cls,
2706} 2706}
2707 2707
2708 2708
2709/** 2709/**
2710 * Method called to inform about the egos of the master zone of this peer. 2710 * Method called to inform about the egos of the master zone of this peer.
2711 * 2711 *
2712 * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get, 2712 * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get,
@@ -2714,7 +2714,7 @@ identity_shorten_cb (void *cls,
2714 * @a ego does indicate an error (i.e. name is taken or no default 2714 * @a ego does indicate an error (i.e. name is taken or no default
2715 * value is known). If @a ego is non-NULL and if '*ctx' 2715 * value is known). If @a ego is non-NULL and if '*ctx'
2716 * is set in those callbacks, the value WILL be passed to a subsequent 2716 * is set in those callbacks, the value WILL be passed to a subsequent
2717 * call to the identity callback of #GNUNET_IDENTITY_connect (if 2717 * call to the identity callback of #GNUNET_IDENTITY_connect (if
2718 * that one was not NULL). 2718 * that one was not NULL).
2719 * 2719 *
2720 * @param cls closure, NULL 2720 * @param cls closure, NULL
@@ -2770,7 +2770,7 @@ run (void *cls, char *const *args, const char *cfgfile,
2770 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2770 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2771 "Failed to create cURL multi handle!\n"); 2771 "Failed to create cURL multi handle!\n");
2772 return; 2772 return;
2773 } 2773 }
2774 cafile = cafile_opt; 2774 cafile = cafile_opt;
2775 if (NULL == cafile) 2775 if (NULL == cafile)
2776 { 2776 {
@@ -2787,11 +2787,11 @@ run (void *cls, char *const *args, const char *cfgfile,
2787 } 2787 }
2788 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2788 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2789 "Using %s as CA\n", cafile); 2789 "Using %s as CA\n", cafile);
2790 2790
2791 gnutls_global_init (); 2791 gnutls_global_init ();
2792 gnutls_x509_crt_init (&proxy_ca.cert); 2792 gnutls_x509_crt_init (&proxy_ca.cert);
2793 gnutls_x509_privkey_init (&proxy_ca.key); 2793 gnutls_x509_privkey_init (&proxy_ca.key);
2794 2794
2795 if ( (GNUNET_OK != load_cert_from_file (proxy_ca.cert, cafile)) || 2795 if ( (GNUNET_OK != load_cert_from_file (proxy_ca.cert, cafile)) ||
2796 (GNUNET_OK != load_key_from_file (proxy_ca.key, cafile)) ) 2796 (GNUNET_OK != load_key_from_file (proxy_ca.key, cafile)) )
2797 { 2797 {
@@ -2801,7 +2801,7 @@ run (void *cls, char *const *args, const char *cfgfile,
2801 gnutls_x509_crt_deinit (proxy_ca.cert); 2801 gnutls_x509_crt_deinit (proxy_ca.cert);
2802 gnutls_x509_privkey_deinit (proxy_ca.key); 2802 gnutls_x509_privkey_deinit (proxy_ca.key);
2803 gnutls_global_deinit (); 2803 gnutls_global_deinit ();
2804 GNUNET_free_non_null (cafile_cfg); 2804 GNUNET_free_non_null (cafile_cfg);
2805 return; 2805 return;
2806 } 2806 }
2807 GNUNET_free_non_null (cafile_cfg); 2807 GNUNET_free_non_null (cafile_cfg);
@@ -2815,11 +2815,11 @@ run (void *cls, char *const *args, const char *cfgfile,
2815 return; 2815 return;
2816 } 2816 }
2817 identity = GNUNET_IDENTITY_connect (cfg, 2817 identity = GNUNET_IDENTITY_connect (cfg,
2818 NULL, NULL); 2818 NULL, NULL);
2819 id_op = GNUNET_IDENTITY_get (identity, 2819 id_op = GNUNET_IDENTITY_get (identity,
2820 "gns-proxy", 2820 "gns-proxy",
2821 &identity_master_cb, 2821 &identity_master_cb,
2822 NULL); 2822 NULL);
2823 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 2823 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
2824 &do_shutdown, NULL); 2824 &do_shutdown, NULL);
2825} 2825}
@@ -2844,7 +2844,7 @@ main (int argc, char *const *argv)
2844 &GNUNET_GETOPT_set_string, &cafile_opt}, 2844 &GNUNET_GETOPT_set_string, &cafile_opt},
2845 GNUNET_GETOPT_OPTION_END 2845 GNUNET_GETOPT_OPTION_END
2846 }; 2846 };
2847 static const char* page = 2847 static const char* page =
2848 "<html><head><title>gnunet-gns-proxy</title>" 2848 "<html><head><title>gnunet-gns-proxy</title>"
2849 "</head><body>cURL fail</body></html>"; 2849 "</head><body>cURL fail</body></html>";
2850 int ret; 2850 int ret;
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index e7e2404f6..713f94b92 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -70,7 +70,7 @@ static int raw;
70static int rtype; 70static int rtype;
71 71
72/** 72/**
73 * Handle to lookup request 73 * Handle to lookup request
74 */ 74 */
75static struct GNUNET_GNS_LookupRequest *lookup_request; 75static struct GNUNET_GNS_LookupRequest *lookup_request;
76 76
@@ -144,13 +144,13 @@ process_lookup_result (void *cls, uint32_t rd_count,
144 const char *typename; 144 const char *typename;
145 char* string_val; 145 char* string_val;
146 146
147 lookup_request = NULL; 147 lookup_request = NULL;
148 if (!raw) 148 if (!raw)
149 { 149 {
150 if (0 == rd_count) 150 if (0 == rd_count)
151 printf ("No results.\n"); 151 printf ("No results.\n");
152 else 152 else
153 printf ("%s:\n", 153 printf ("%s:\n",
154 name); 154 name);
155 } 155 }
156 for (i=0; i<rd_count; i++) 156 for (i=0; i<rd_count; i++)
@@ -171,11 +171,11 @@ process_lookup_result (void *cls, uint32_t rd_count,
171 continue; 171 continue;
172 } 172 }
173 if (raw) 173 if (raw)
174 printf ("%s\n", 174 printf ("%s\n",
175 string_val); 175 string_val);
176 else 176 else
177 printf ("Got `%s' record: %s\n", 177 printf ("Got `%s' record: %s\n",
178 typename, 178 typename,
179 string_val); 179 string_val);
180 GNUNET_free (string_val); 180 GNUNET_free (string_val);
181 } 181 }
@@ -201,13 +201,13 @@ lookup_with_keys (const struct GNUNET_CRYPTO_EccPublicSignKey *pkey,
201 201
202 if (NULL != lookup_name) 202 if (NULL != lookup_name)
203 { 203 {
204 lookup_request = GNUNET_GNS_lookup (gns, 204 lookup_request = GNUNET_GNS_lookup (gns,
205 lookup_name, 205 lookup_name,
206 pkey, 206 pkey,
207 rtype, 207 rtype,
208 GNUNET_NO, /* Use DHT */ 208 GNUNET_NO, /* Use DHT */
209 shorten_key, 209 shorten_key,
210 &process_lookup_result, 210 &process_lookup_result,
211 lookup_name); 211 lookup_name);
212 } 212 }
213 else 213 else
@@ -220,7 +220,7 @@ lookup_with_keys (const struct GNUNET_CRYPTO_EccPublicSignKey *pkey,
220} 220}
221 221
222 222
223/** 223/**
224 * Method called to with the ego we are to use for shortening 224 * Method called to with the ego we are to use for shortening
225 * during the lookup. 225 * during the lookup.
226 * 226 *
@@ -232,7 +232,7 @@ lookup_with_keys (const struct GNUNET_CRYPTO_EccPublicSignKey *pkey,
232 * NULL if the user just deleted the ego and it 232 * NULL if the user just deleted the ego and it
233 * must thus no longer be used 233 * must thus no longer be used
234 */ 234 */
235static void 235static void
236identity_shorten_cb (void *cls, 236identity_shorten_cb (void *cls,
237 struct GNUNET_IDENTITY_Ego *ego, 237 struct GNUNET_IDENTITY_Ego *ego,
238 void **ctx, 238 void **ctx,
@@ -276,21 +276,21 @@ lookup_with_public_key (const struct GNUNET_CRYPTO_EccPublicSignKey *pkey)
276} 276}
277 277
278 278
279/** 279/**
280 * Method called to with the ego we are to use for the lookup, 280 * Method called to with the ego we are to use for the lookup,
281 * when the ego is determined by a name. 281 * when the ego is determined by a name.
282 * 282 *
283 * @param cls closure (NULL, unused) 283 * @param cls closure (NULL, unused)
284 * @param ego ego handle, NULL if not found 284 * @param ego ego handle, NULL if not found
285 */ 285 */
286static void 286static void
287identity_zone_cb (void *cls, 287identity_zone_cb (void *cls,
288 const struct GNUNET_IDENTITY_Ego *ego) 288 const struct GNUNET_IDENTITY_Ego *ego)
289{ 289{
290 struct GNUNET_CRYPTO_EccPublicSignKey pkey; 290 struct GNUNET_CRYPTO_EccPublicSignKey pkey;
291 291
292 el = NULL; 292 el = NULL;
293 if (NULL == ego) 293 if (NULL == ego)
294 { 294 {
295 fprintf (stderr, 295 fprintf (stderr,
296 _("Ego for `%s' not found, cannot perform lookup.\n"), 296 _("Ego for `%s' not found, cannot perform lookup.\n"),
@@ -307,7 +307,7 @@ identity_zone_cb (void *cls,
307} 307}
308 308
309 309
310/** 310/**
311 * Method called to with the ego we are to use for the lookup, 311 * Method called to with the ego we are to use for the lookup,
312 * when the ego is the one for the default master zone. 312 * when the ego is the one for the default master zone.
313 * 313 *
@@ -319,7 +319,7 @@ identity_zone_cb (void *cls,
319 * NULL if the user just deleted the ego and it 319 * NULL if the user just deleted the ego and it
320 * must thus no longer be used 320 * must thus no longer be used
321 */ 321 */
322static void 322static void
323identity_master_cb (void *cls, 323identity_master_cb (void *cls,
324 struct GNUNET_IDENTITY_Ego *ego, 324 struct GNUNET_IDENTITY_Ego *ego,
325 void **ctx, 325 void **ctx,
@@ -328,7 +328,7 @@ identity_master_cb (void *cls,
328 struct GNUNET_CRYPTO_EccPublicSignKey pkey; 328 struct GNUNET_CRYPTO_EccPublicSignKey pkey;
329 329
330 id_op = NULL; 330 id_op = NULL;
331 if (NULL == ego) 331 if (NULL == ego)
332 { 332 {
333 fprintf (stderr, 333 fprintf (stderr,
334 _("Ego for `master-zone' not found, cannot perform lookup. Did you run gnunet-gns-import.sh?\n")); 334 _("Ego for `master-zone' not found, cannot perform lookup. Did you run gnunet-gns-import.sh?\n"));
@@ -372,7 +372,7 @@ run (void *cls, char *const *args, const char *cfgfile,
372 strlen (public_key), 372 strlen (public_key),
373 &pkey)) 373 &pkey))
374 { 374 {
375 fprintf (stderr, 375 fprintf (stderr,
376 _("Public key `%s' is not well-formed\n"), 376 _("Public key `%s' is not well-formed\n"),
377 public_key); 377 public_key);
378 GNUNET_SCHEDULER_shutdown (); 378 GNUNET_SCHEDULER_shutdown ();
@@ -383,7 +383,7 @@ run (void *cls, char *const *args, const char *cfgfile,
383 } 383 }
384 if (NULL != zone_ego_name) 384 if (NULL != zone_ego_name)
385 { 385 {
386 el = GNUNET_IDENTITY_ego_lookup (cfg, 386 el = GNUNET_IDENTITY_ego_lookup (cfg,
387 zone_ego_name, 387 zone_ego_name,
388 &identity_zone_cb, 388 &identity_zone_cb,
389 NULL); 389 NULL);
@@ -447,7 +447,7 @@ main (int argc, char *const *argv)
447 ret = 447 ret =
448 (GNUNET_OK == 448 (GNUNET_OK ==
449 GNUNET_PROGRAM_run (argc, argv, "gnunet-gns", 449 GNUNET_PROGRAM_run (argc, argv, "gnunet-gns",
450 _("GNUnet GNS resolver tool"), 450 _("GNUnet GNS resolver tool"),
451 options, 451 options,
452 &run, NULL)) ? 0 : 1; 452 &run, NULL)) ? 0 : 1;
453 GNUNET_free ((void*) argv); 453 GNUNET_free ((void*) argv);
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 0cf0fca56..8fcd75e7c 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -98,7 +98,7 @@ struct ClientLookupHandle
98 struct GNS_ResolverHandle *lookup; 98 struct GNS_ResolverHandle *lookup;
99 99
100 /** 100 /**
101 * request id 101 * request id
102 */ 102 */
103 uint32_t request_id; 103 uint32_t request_id;
104 104
@@ -199,7 +199,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
199 199
200 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 200 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
201 "Shutting down!\n"); 201 "Shutting down!\n");
202 GNUNET_SERVER_notification_context_destroy (nc); 202 GNUNET_SERVER_notification_context_destroy (nc);
203 while (NULL != (clh = clh_head)) 203 while (NULL != (clh = clh_head))
204 { 204 {
205 GNUNET_SERVER_client_set_user_context (clh->client, NULL); 205 GNUNET_SERVER_client_set_user_context (clh->client, NULL);
@@ -266,7 +266,7 @@ publish_zone_dht_next (void *cls,
266 * @param tc task context 266 * @param tc task context
267 */ 267 */
268static void 268static void
269publish_zone_dht_start (void *cls, 269publish_zone_dht_start (void *cls,
270 const struct GNUNET_SCHEDULER_TaskContext *tc); 270 const struct GNUNET_SCHEDULER_TaskContext *tc);
271 271
272 272
@@ -280,10 +280,10 @@ static void
280dht_put_continuation (void *cls, 280dht_put_continuation (void *cls,
281 int success) 281 int success)
282{ 282{
283 struct GNUNET_TIME_Relative next_put_interval; 283 struct GNUNET_TIME_Relative next_put_interval;
284 284
285 active_put = NULL; 285 active_put = NULL;
286 num_public_records++; 286 num_public_records++;
287 if ( (num_public_records > last_num_public_records) && 287 if ( (num_public_records > last_num_public_records) &&
288 (GNUNET_NO == first_zone_iteration) ) 288 (GNUNET_NO == first_zone_iteration) )
289 { 289 {
@@ -300,7 +300,7 @@ dht_put_continuation (void *cls,
300 GNUNET_STATISTICS_set (statistics, 300 GNUNET_STATISTICS_set (statistics,
301 "Current zone iteration interval (ms)", 301 "Current zone iteration interval (ms)",
302 next_put_interval.rel_value_us / 1000LL, 302 next_put_interval.rel_value_us / 1000LL,
303 GNUNET_NO); 303 GNUNET_NO);
304 zone_publish_task = GNUNET_SCHEDULER_add_delayed (next_put_interval, 304 zone_publish_task = GNUNET_SCHEDULER_add_delayed (next_put_interval,
305 &publish_zone_dht_next, 305 &publish_zone_dht_next,
306 NULL); 306 NULL);
@@ -322,10 +322,10 @@ put_gns_record (void *cls,
322 const char *name, 322 const char *name,
323 unsigned int rd_count, 323 unsigned int rd_count,
324 const struct GNUNET_NAMESTORE_RecordData *rd) 324 const struct GNUNET_NAMESTORE_RecordData *rd)
325{ 325{
326 struct GNUNET_NAMESTORE_Block *block; 326 struct GNUNET_NAMESTORE_Block *block;
327 struct GNUNET_HashCode query; 327 struct GNUNET_HashCode query;
328 struct GNUNET_TIME_Absolute expire; 328 struct GNUNET_TIME_Absolute expire;
329 struct GNUNET_TIME_Absolute now; 329 struct GNUNET_TIME_Absolute now;
330 size_t block_size; 330 size_t block_size;
331 struct GNUNET_NAMESTORE_RecordData rd_public[rd_count]; 331 struct GNUNET_NAMESTORE_RecordData rd_public[rd_count];
@@ -365,8 +365,8 @@ put_gns_record (void *cls,
365 put_interval.rel_value_us / 1000LL, 365 put_interval.rel_value_us / 1000LL,
366 GNUNET_NO); 366 GNUNET_NO);
367 GNUNET_STATISTICS_update (statistics, 367 GNUNET_STATISTICS_update (statistics,
368 "Number of zone iterations", 368 "Number of zone iterations",
369 1, 369 1,
370 GNUNET_NO); 370 GNUNET_NO);
371 GNUNET_STATISTICS_set (statistics, 371 GNUNET_STATISTICS_set (statistics,
372 "Number of public records in DHT", 372 "Number of public records in DHT",
@@ -377,7 +377,7 @@ put_gns_record (void *cls,
377 &publish_zone_dht_start, 377 &publish_zone_dht_start,
378 NULL); 378 NULL);
379 else 379 else
380 zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, 380 zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
381 NULL); 381 NULL);
382 return; 382 return;
383 } 383 }
@@ -413,8 +413,8 @@ put_gns_record (void *cls,
413 name, 413 name,
414 rd_public, 414 rd_public,
415 rd_public_count); 415 rd_public_count);
416 block_size = ntohl (block->purpose.size) 416 block_size = ntohl (block->purpose.size)
417 + sizeof (struct GNUNET_CRYPTO_EccSignature) 417 + sizeof (struct GNUNET_CRYPTO_EccSignature)
418 + sizeof (struct GNUNET_CRYPTO_EccPublicSignKey); 418 + sizeof (struct GNUNET_CRYPTO_EccPublicSignKey);
419 GNUNET_NAMESTORE_query_from_private_key (key, 419 GNUNET_NAMESTORE_query_from_private_key (key,
420 name, 420 name,
@@ -429,7 +429,7 @@ put_gns_record (void *cls,
429 expire, 429 expire,
430 DHT_OPERATION_TIMEOUT, 430 DHT_OPERATION_TIMEOUT,
431 &dht_put_continuation, 431 &dht_put_continuation,
432 NULL); 432 NULL);
433 if (NULL == active_put) 433 if (NULL == active_put)
434 { 434 {
435 GNUNET_break (0); 435 GNUNET_break (0);
@@ -446,13 +446,13 @@ put_gns_record (void *cls,
446 * @param tc task context 446 * @param tc task context
447 */ 447 */
448static void 448static void
449publish_zone_dht_start (void *cls, 449publish_zone_dht_start (void *cls,
450 const struct GNUNET_SCHEDULER_TaskContext *tc) 450 const struct GNUNET_SCHEDULER_TaskContext *tc)
451{ 451{
452 zone_publish_task = GNUNET_SCHEDULER_NO_TASK; 452 zone_publish_task = GNUNET_SCHEDULER_NO_TASK;
453 453
454 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 454 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
455 "Scheduling DHT zone update!\n"); 455 "Scheduling DHT zone update!\n");
456 /* start counting again */ 456 /* start counting again */
457 num_public_records = 0; 457 num_public_records = 0;
458 namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle, 458 namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle,
@@ -480,21 +480,21 @@ send_lookup_response (void* cls,
480 struct ClientLookupHandle *clh = cls; 480 struct ClientLookupHandle *clh = cls;
481 struct GNUNET_GNS_ClientLookupResultMessage *rmsg; 481 struct GNUNET_GNS_ClientLookupResultMessage *rmsg;
482 size_t len; 482 size_t len;
483 483
484 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 484 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
485 "Sending `%s' message with %d results\n", 485 "Sending `%s' message with %d results\n",
486 "LOOKUP_RESULT", 486 "LOOKUP_RESULT",
487 rd_count); 487 rd_count);
488 488
489 len = GNUNET_NAMESTORE_records_get_size (rd_count, rd); 489 len = GNUNET_NAMESTORE_records_get_size (rd_count, rd);
490 rmsg = GNUNET_malloc (len + sizeof (struct GNUNET_GNS_ClientLookupResultMessage)); 490 rmsg = GNUNET_malloc (len + sizeof (struct GNUNET_GNS_ClientLookupResultMessage));
491 rmsg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT); 491 rmsg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT);
492 rmsg->header.size = htons (len + sizeof(struct GNUNET_GNS_ClientLookupResultMessage)); 492 rmsg->header.size = htons (len + sizeof(struct GNUNET_GNS_ClientLookupResultMessage));
493 rmsg->id = clh->request_id; 493 rmsg->id = clh->request_id;
494 rmsg->rd_count = htonl (rd_count); 494 rmsg->rd_count = htonl (rd_count);
495 GNUNET_NAMESTORE_records_serialize (rd_count, rd, len, 495 GNUNET_NAMESTORE_records_serialize (rd_count, rd, len,
496 (char*) &rmsg[1]); 496 (char*) &rmsg[1]);
497 GNUNET_SERVER_notification_context_unicast (nc, 497 GNUNET_SERVER_notification_context_unicast (nc,
498 clh->client, 498 clh->client,
499 &rmsg->header, 499 &rmsg->header,
500 GNUNET_NO); 500 GNUNET_NO);
@@ -503,11 +503,11 @@ send_lookup_response (void* cls,
503 GNUNET_SERVER_client_set_user_context (clh->client, NULL); 503 GNUNET_SERVER_client_set_user_context (clh->client, NULL);
504 GNUNET_free (clh); 504 GNUNET_free (clh);
505 GNUNET_STATISTICS_update (statistics, 505 GNUNET_STATISTICS_update (statistics,
506 "Completed lookups", 1, 506 "Completed lookups", 1,
507 GNUNET_NO); 507 GNUNET_NO);
508 GNUNET_STATISTICS_update (statistics, 508 GNUNET_STATISTICS_update (statistics,
509 "Records resolved", 509 "Records resolved",
510 rd_count, 510 rd_count,
511 GNUNET_NO); 511 GNUNET_NO);
512} 512}
513 513
@@ -531,9 +531,9 @@ handle_lookup (void *cls,
531 const struct GNUNET_CRYPTO_EccPrivateKey *key; 531 const struct GNUNET_CRYPTO_EccPrivateKey *key;
532 uint16_t msg_size; 532 uint16_t msg_size;
533 const struct GNUNET_GNS_ClientLookupMessage *sh_msg; 533 const struct GNUNET_GNS_ClientLookupMessage *sh_msg;
534 534
535 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 535 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
536 "Received `%s' message\n", 536 "Received `%s' message\n",
537 "LOOKUP"); 537 "LOOKUP");
538 msg_size = ntohs (message->size); 538 msg_size = ntohs (message->size);
539 if (msg_size < sizeof (struct GNUNET_GNS_ClientLookupMessage)) 539 if (msg_size < sizeof (struct GNUNET_GNS_ClientLookupMessage))
@@ -557,8 +557,8 @@ handle_lookup (void *cls,
557 return; 557 return;
558 } 558 }
559 GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr); 559 GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr);
560 GNUNET_SERVER_receive_done (client, GNUNET_OK); 560 GNUNET_SERVER_receive_done (client, GNUNET_OK);
561 561
562 clh = GNUNET_new (struct ClientLookupHandle); 562 clh = GNUNET_new (struct ClientLookupHandle);
563 GNUNET_SERVER_client_set_user_context (client, clh); 563 GNUNET_SERVER_client_set_user_context (client, clh);
564 GNUNET_CONTAINER_DLL_insert (clh_head, clh_tail, clh); 564 GNUNET_CONTAINER_DLL_insert (clh_head, clh_tail, clh);
@@ -571,7 +571,7 @@ handle_lookup (void *cls,
571 "LOOKUP: Query for A record but AF_INET not supported!"); 571 "LOOKUP: Query for A record but AF_INET not supported!");
572 send_lookup_response (clh, 0, NULL); 572 send_lookup_response (clh, 0, NULL);
573 return; 573 return;
574 } 574 }
575 if ( (GNUNET_DNSPARSER_TYPE_AAAA == ntohl (sh_msg->type)) && 575 if ( (GNUNET_DNSPARSER_TYPE_AAAA == ntohl (sh_msg->type)) &&
576 (GNUNET_OK != v6_enabled) ) 576 (GNUNET_OK != v6_enabled) )
577 { 577 {
@@ -580,14 +580,14 @@ handle_lookup (void *cls,
580 send_lookup_response (clh, 0, NULL); 580 send_lookup_response (clh, 0, NULL);
581 return; 581 return;
582 } 582 }
583 clh->lookup = GNS_resolver_lookup (&sh_msg->zone, 583 clh->lookup = GNS_resolver_lookup (&sh_msg->zone,
584 ntohl (sh_msg->type), 584 ntohl (sh_msg->type),
585 name, 585 name,
586 key, 586 key,
587 ntohl (sh_msg->only_cached), 587 ntohl (sh_msg->only_cached),
588 &send_lookup_response, clh); 588 &send_lookup_response, clh);
589 GNUNET_STATISTICS_update (statistics, 589 GNUNET_STATISTICS_update (statistics,
590 "Lookup attempts", 590 "Lookup attempts",
591 1, GNUNET_NO); 591 1, GNUNET_NO);
592} 592}
593 593
@@ -645,7 +645,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
645 GNUNET_SCHEDULER_shutdown (); 645 GNUNET_SCHEDULER_shutdown ();
646 return; 646 return;
647 } 647 }
648 648
649 put_interval = INITIAL_PUT_INTERVAL; 649 put_interval = INITIAL_PUT_INTERVAL;
650 zone_publish_time_window = DEFAULT_ZONE_PUBLISH_TIME_WINDOW; 650 zone_publish_time_window = DEFAULT_ZONE_PUBLISH_TIME_WINDOW;
651 651
@@ -677,7 +677,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
677 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); 677 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
678 return; 678 return;
679 } 679 }
680 680
681 if (GNUNET_OK == 681 if (GNUNET_OK ==
682 GNUNET_CONFIGURATION_get_value_string (c, "gns", "DNS_ROOT", 682 GNUNET_CONFIGURATION_get_value_string (c, "gns", "DNS_ROOT",
683 &dns_root_name)) 683 &dns_root_name))
@@ -688,7 +688,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
688 &dns_root)) 688 &dns_root))
689 { 689 {
690 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, 690 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
691 "gns", "DNS_ROOT", 691 "gns", "DNS_ROOT",
692 _("valid public key required")); 692 _("valid public key required"));
693 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); 693 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
694 GNUNET_free (dns_root_name); 694 GNUNET_free (dns_root_name);
@@ -697,7 +697,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
697 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 697 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
698 "DNS hijacking with root `%s' enabled. Connecting to DNS service.\n", 698 "DNS hijacking with root `%s' enabled. Connecting to DNS service.\n",
699 dns_root_name); 699 dns_root_name);
700 GNUNET_free (dns_root_name); 700 GNUNET_free (dns_root_name);
701 if (GNUNET_SYSERR == 701 if (GNUNET_SYSERR ==
702 GNS_interceptor_init (&dns_root, c)) 702 GNS_interceptor_init (&dns_root, c))
703 { 703 {
@@ -705,21 +705,21 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
705 return; 705 return;
706 } 706 }
707 } 707 }
708 GNS_resolver_init (namestore_handle, dht_handle, 708 GNS_resolver_init (namestore_handle, dht_handle,
709 c, 709 c,
710 max_parallel_bg_queries); 710 max_parallel_bg_queries);
711 GNS_shorten_init (namestore_handle, dht_handle); 711 GNS_shorten_init (namestore_handle, dht_handle);
712 GNUNET_SERVER_disconnect_notify (server, 712 GNUNET_SERVER_disconnect_notify (server,
713 &notify_client_disconnect, 713 &notify_client_disconnect,
714 NULL); 714 NULL);
715 /* Schedule periodic put for our records. */ 715 /* Schedule periodic put for our records. */
716 first_zone_iteration = GNUNET_YES; 716 first_zone_iteration = GNUNET_YES;
717 GNUNET_SERVER_add_handlers (server, handlers); 717 GNUNET_SERVER_add_handlers (server, handlers);
718 statistics = GNUNET_STATISTICS_create ("gns", c); 718 statistics = GNUNET_STATISTICS_create ("gns", c);
719 nc = GNUNET_SERVER_notification_context_create (server, 1); 719 nc = GNUNET_SERVER_notification_context_create (server, 1);
720 zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, 720 zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start,
721 NULL); 721 NULL);
722 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 722 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
723 &shutdown_task, NULL); 723 &shutdown_task, NULL);
724} 724}
725 725
diff --git a/src/gns/gnunet-service-gns_interceptor.c b/src/gns/gnunet-service-gns_interceptor.c
index be7a46f51..8cb1951bf 100644
--- a/src/gns/gnunet-service-gns_interceptor.c
+++ b/src/gns/gnunet-service-gns_interceptor.c
@@ -50,12 +50,12 @@ struct InterceptLookupHandle
50 struct InterceptLookupHandle *prev; 50 struct InterceptLookupHandle *prev;
51 51
52 /** 52 /**
53 * the request handle to reply to 53 * the request handle to reply to
54 */ 54 */
55 struct GNUNET_DNS_RequestHandle *request_handle; 55 struct GNUNET_DNS_RequestHandle *request_handle;
56 56
57 /** 57 /**
58 * the dns parser packet received 58 * the dns parser packet received
59 */ 59 */
60 struct GNUNET_DNSPARSER_Packet *packet; 60 struct GNUNET_DNSPARSER_Packet *packet;
61 61
@@ -102,7 +102,7 @@ reply_to_dns (void *cls, uint32_t rd_count,
102 struct InterceptLookupHandle *ilh = cls; 102 struct InterceptLookupHandle *ilh = cls;
103 struct GNUNET_DNSPARSER_Packet *packet = ilh->packet; 103 struct GNUNET_DNSPARSER_Packet *packet = ilh->packet;
104 struct GNUNET_DNSPARSER_Query *query = &packet->queries[0]; 104 struct GNUNET_DNSPARSER_Query *query = &packet->queries[0];
105 uint32_t i; 105 uint32_t i;
106 size_t len; 106 size_t len;
107 int ret; 107 int ret;
108 char *buf; 108 char *buf;
@@ -110,7 +110,7 @@ reply_to_dns (void *cls, uint32_t rd_count,
110 unsigned int skip_answers; 110 unsigned int skip_answers;
111 unsigned int skip_additional; 111 unsigned int skip_additional;
112 size_t off; 112 size_t off;
113 113
114 /* Put records in the DNS packet */ 114 /* Put records in the DNS packet */
115 num_answers = 0; 115 num_answers = 0;
116 for (i=0; i < rd_count; i++) 116 for (i=0; i < rd_count; i++)
@@ -151,7 +151,7 @@ reply_to_dns (void *cls, uint32_t rd_count,
151 } 151 }
152 break; 152 break;
153 case GNUNET_DNSPARSER_TYPE_SOA: 153 case GNUNET_DNSPARSER_TYPE_SOA:
154 answer_records[i - skip_answers].data.soa 154 answer_records[i - skip_answers].data.soa
155 = GNUNET_DNSPARSER_parse_soa (rd[i].data, 155 = GNUNET_DNSPARSER_parse_soa (rd[i].data,
156 rd[i].data_size, 156 rd[i].data_size,
157 &off); 157 &off);
@@ -167,7 +167,7 @@ reply_to_dns (void *cls, uint32_t rd_count,
167 skip_answers++; 167 skip_answers++;
168 break; 168 break;
169 case GNUNET_DNSPARSER_TYPE_MX: 169 case GNUNET_DNSPARSER_TYPE_MX:
170 answer_records[i - skip_answers].data.mx 170 answer_records[i - skip_answers].data.mx
171 = GNUNET_DNSPARSER_parse_mx (rd[i].data, 171 = GNUNET_DNSPARSER_parse_mx (rd[i].data,
172 rd[i].data_size, 172 rd[i].data_size,
173 &off); 173 &off);
@@ -196,7 +196,7 @@ reply_to_dns (void *cls, uint32_t rd_count,
196 case GNUNET_DNSPARSER_TYPE_NS: 196 case GNUNET_DNSPARSER_TYPE_NS:
197 case GNUNET_DNSPARSER_TYPE_CNAME: 197 case GNUNET_DNSPARSER_TYPE_CNAME:
198 case GNUNET_DNSPARSER_TYPE_PTR: 198 case GNUNET_DNSPARSER_TYPE_PTR:
199 additional_records[i - skip_additional].data.hostname 199 additional_records[i - skip_additional].data.hostname
200 = GNUNET_DNSPARSER_parse_name (rd[i].data, 200 = GNUNET_DNSPARSER_parse_name (rd[i].data,
201 rd[i].data_size, 201 rd[i].data_size,
202 &off); 202 &off);
@@ -208,7 +208,7 @@ reply_to_dns (void *cls, uint32_t rd_count,
208 } 208 }
209 break; 209 break;
210 case GNUNET_DNSPARSER_TYPE_SOA: 210 case GNUNET_DNSPARSER_TYPE_SOA:
211 additional_records[i - skip_additional].data.soa 211 additional_records[i - skip_additional].data.soa
212 = GNUNET_DNSPARSER_parse_soa (rd[i].data, 212 = GNUNET_DNSPARSER_parse_soa (rd[i].data,
213 rd[i].data_size, 213 rd[i].data_size,
214 &off); 214 &off);
@@ -220,7 +220,7 @@ reply_to_dns (void *cls, uint32_t rd_count,
220 } 220 }
221 break; 221 break;
222 case GNUNET_DNSPARSER_TYPE_MX: 222 case GNUNET_DNSPARSER_TYPE_MX:
223 additional_records[i - skip_additional].data.mx 223 additional_records[i - skip_additional].data.mx
224 = GNUNET_DNSPARSER_parse_mx (rd[i].data, 224 = GNUNET_DNSPARSER_parse_mx (rd[i].data,
225 rd[i].data_size, 225 rd[i].data_size,
226 &off); 226 &off);
@@ -242,7 +242,7 @@ reply_to_dns (void *cls, uint32_t rd_count,
242 } 242 }
243 GNUNET_break (0 == (rd[i - skip_additional].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)); 243 GNUNET_break (0 == (rd[i - skip_additional].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
244 additional_records[i - skip_additional].expiration_time.abs_value_us = rd[i].expiration_time; 244 additional_records[i - skip_additional].expiration_time.abs_value_us = rd[i].expiration_time;
245 additional_records[i - skip_additional].dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET; 245 additional_records[i - skip_additional].dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
246 } 246 }
247 } 247 }
248 packet->num_answers = num_answers - skip_answers; 248 packet->num_answers = num_answers - skip_answers;
@@ -261,14 +261,14 @@ reply_to_dns (void *cls, uint32_t rd_count,
261 { 261 {
262 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 262 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
263 _("Error converting GNS response to DNS response!\n")); 263 _("Error converting GNS response to DNS response!\n"));
264 } 264 }
265 else 265 else
266 { 266 {
267 GNUNET_DNS_request_answer (ilh->request_handle, 267 GNUNET_DNS_request_answer (ilh->request_handle,
268 len, 268 len,
269 buf); 269 buf);
270 GNUNET_free (buf); 270 GNUNET_free (buf);
271 } 271 }
272 packet->num_answers = 0; 272 packet->num_answers = 0;
273 packet->answers = NULL; 273 packet->answers = NULL;
274 packet->num_additional_records = 0; 274 packet->num_additional_records = 0;
@@ -297,7 +297,7 @@ handle_dns_request (void *cls,
297 struct GNUNET_DNSPARSER_Packet *p; 297 struct GNUNET_DNSPARSER_Packet *p;
298 struct InterceptLookupHandle *ilh; 298 struct InterceptLookupHandle *ilh;
299 299
300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
301 "Hijacked a DNS request. Processing.\n"); 301 "Hijacked a DNS request. Processing.\n");
302 if (NULL == (p = GNUNET_DNSPARSER_parse (request, request_length))) 302 if (NULL == (p = GNUNET_DNSPARSER_parse (request, request_length)))
303 { 303 {
@@ -307,7 +307,7 @@ handle_dns_request (void *cls,
307 GNUNET_DNSPARSER_free_packet (p); 307 GNUNET_DNSPARSER_free_packet (p);
308 return; 308 return;
309 } 309 }
310 310
311 /* Check TLD and decide if we or legacy dns is responsible */ 311 /* Check TLD and decide if we or legacy dns is responsible */
312 if (1 != p->num_queries) 312 if (1 != p->num_queries)
313 { 313 {
@@ -318,7 +318,7 @@ handle_dns_request (void *cls,
318 return; 318 return;
319 } 319 }
320 320
321 /* Check for GNS TLDs. */ 321 /* Check for GNS TLDs. */
322 if ( (GNUNET_YES == is_gnu_tld (p->queries[0].name)) || 322 if ( (GNUNET_YES == is_gnu_tld (p->queries[0].name)) ||
323 (GNUNET_YES == is_zkey_tld (p->queries[0].name)) || 323 (GNUNET_YES == is_zkey_tld (p->queries[0].name)) ||
324 (0 == strcmp (p->queries[0].name, GNUNET_GNS_TLD)) ) 324 (0 == strcmp (p->queries[0].name, GNUNET_GNS_TLD)) )
@@ -328,8 +328,8 @@ handle_dns_request (void *cls,
328 GNUNET_CONTAINER_DLL_insert (ilh_head, ilh_tail, ilh); 328 GNUNET_CONTAINER_DLL_insert (ilh_head, ilh_tail, ilh);
329 ilh->packet = p; 329 ilh->packet = p;
330 ilh->request_handle = rh; 330 ilh->request_handle = rh;
331 ilh->lookup = GNS_resolver_lookup (&zone, 331 ilh->lookup = GNS_resolver_lookup (&zone,
332 p->queries[0].type, 332 p->queries[0].type,
333 p->queries[0].name, 333 p->queries[0].name,
334 NULL /* FIXME: enable shorten for DNS intercepts? */, 334 NULL /* FIXME: enable shorten for DNS intercepts? */,
335 GNUNET_NO, 335 GNUNET_NO,
@@ -338,7 +338,7 @@ handle_dns_request (void *cls,
338 } 338 }
339 /* This request does not concern us. Forward to real DNS. */ 339 /* This request does not concern us. Forward to real DNS. */
340 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 340 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
341 "Request for `%s' is forwarded to DNS untouched.\n", 341 "Request for `%s' is forwarded to DNS untouched.\n",
342 p->queries[0].name); 342 p->queries[0].name);
343 GNUNET_DNS_request_forward (rh); 343 GNUNET_DNS_request_forward (rh);
344 GNUNET_DNSPARSER_free_packet (p); 344 GNUNET_DNSPARSER_free_packet (p);
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 110263eee..7a7c1633e 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -93,10 +93,10 @@ struct AuthorityChain
93 struct GNS_ResolverHandle *rh; 93 struct GNS_ResolverHandle *rh;
94 94
95 /** 95 /**
96 * label/name corresponding to the authority 96 * label/name corresponding to the authority
97 */ 97 */
98 char *label; 98 char *label;
99 99
100 /** 100 /**
101 * #GNUNET_YES if the authority was a GNS authority, 101 * #GNUNET_YES if the authority was a GNS authority,
102 * #GNUNET_NO if the authority was a DNS authority. 102 * #GNUNET_NO if the authority was a DNS authority.
@@ -110,7 +110,7 @@ struct AuthorityChain
110 { 110 {
111 111
112 /** 112 /**
113 * The zone of the GNS authority 113 * The zone of the GNS authority
114 */ 114 */
115 struct GNUNET_CRYPTO_EccPublicSignKey gns_authority; 115 struct GNUNET_CRYPTO_EccPublicSignKey gns_authority;
116 116
@@ -133,7 +133,7 @@ struct AuthorityChain
133 } dns_authority; 133 } dns_authority;
134 134
135 } authority_info; 135 } authority_info;
136 136
137}; 137};
138 138
139 139
@@ -180,10 +180,10 @@ struct DnsResult
180/** 180/**
181 * Closure for #vpn_allocation_cb. 181 * Closure for #vpn_allocation_cb.
182 */ 182 */
183struct VpnContext 183struct VpnContext
184{ 184{
185 185
186 /** 186 /**
187 * Which resolution process are we processing. 187 * Which resolution process are we processing.
188 */ 188 */
189 struct GNS_ResolverHandle *rh; 189 struct GNS_ResolverHandle *rh;
@@ -197,12 +197,12 @@ struct VpnContext
197 * Number of records serialized in 'rd_data'. 197 * Number of records serialized in 'rd_data'.
198 */ 198 */
199 unsigned int rd_count; 199 unsigned int rd_count;
200 200
201 /** 201 /**
202 * Serialized records. 202 * Serialized records.
203 */ 203 */
204 char *rd_data; 204 char *rd_data;
205 205
206 /** 206 /**
207 * Number of bytes in 'rd_data'. 207 * Number of bytes in 'rd_data'.
208 */ 208 */
@@ -212,38 +212,38 @@ struct VpnContext
212 212
213/** 213/**
214 * Handle to a currenty pending resolution. On result (positive or 214 * Handle to a currenty pending resolution. On result (positive or
215 * negative) the #GNS_ResultProcessor is called. 215 * negative) the #GNS_ResultProcessor is called.
216 */ 216 */
217struct GNS_ResolverHandle 217struct GNS_ResolverHandle
218{ 218{
219 219
220 /** 220 /**
221 * DLL 221 * DLL
222 */ 222 */
223 struct GNS_ResolverHandle *next; 223 struct GNS_ResolverHandle *next;
224 224
225 /** 225 /**
226 * DLL 226 * DLL
227 */ 227 */
228 struct GNS_ResolverHandle *prev; 228 struct GNS_ResolverHandle *prev;
229 229
230 /** 230 /**
231 * The top-level GNS authoritative zone to query 231 * The top-level GNS authoritative zone to query
232 */ 232 */
233 struct GNUNET_CRYPTO_EccPublicSignKey authority_zone; 233 struct GNUNET_CRYPTO_EccPublicSignKey authority_zone;
234 234
235 /** 235 /**
236 * called when resolution phase finishes 236 * called when resolution phase finishes
237 */ 237 */
238 GNS_ResultProcessor proc; 238 GNS_ResultProcessor proc;
239 239
240 /** 240 /**
241 * closure passed to proc 241 * closure passed to proc
242 */ 242 */
243 void* proc_cls; 243 void* proc_cls;
244 244
245 /** 245 /**
246 * Handle for DHT lookups. should be NULL if no lookups are in progress 246 * Handle for DHT lookups. should be NULL if no lookups are in progress
247 */ 247 */
248 struct GNUNET_DHT_GetHandle *get_handle; 248 struct GNUNET_DHT_GetHandle *get_handle;
249 249
@@ -274,12 +274,12 @@ struct GNS_ResolverHandle
274 struct GNUNET_CONTAINER_HeapNode *dht_heap_node; 274 struct GNUNET_CONTAINER_HeapNode *dht_heap_node;
275 275
276 /** 276 /**
277 * DLL to store the authority chain 277 * DLL to store the authority chain
278 */ 278 */
279 struct AuthorityChain *ac_head; 279 struct AuthorityChain *ac_head;
280 280
281 /** 281 /**
282 * DLL to store the authority chain 282 * DLL to store the authority chain
283 */ 283 */
284 struct AuthorityChain *ac_tail; 284 struct AuthorityChain *ac_tail;
285 285
@@ -294,7 +294,7 @@ struct GNS_ResolverHandle
294 GNUNET_SCHEDULER_TaskIdentifier task_id; 294 GNUNET_SCHEDULER_TaskIdentifier task_id;
295 295
296 /** 296 /**
297 * The name to resolve 297 * The name to resolve
298 */ 298 */
299 char *name; 299 char *name;
300 300
@@ -314,7 +314,7 @@ struct GNS_ResolverHandle
314 size_t name_resolution_pos; 314 size_t name_resolution_pos;
315 315
316 /** 316 /**
317 * Use only cache 317 * Use only cache
318 */ 318 */
319 int only_cached; 319 int only_cached;
320 320
@@ -325,7 +325,7 @@ struct GNS_ResolverHandle
325 325
326 /** 326 /**
327 * We increment the loop limiter for each step in a recursive 327 * We increment the loop limiter for each step in a recursive
328 * resolution. If it passes our threshold (i.e. due to 328 * resolution. If it passes our threshold (i.e. due to
329 * self-recursion in the resolution, i.e CNAME fun), we stop. 329 * self-recursion in the resolution, i.e CNAME fun), we stop.
330 */ 330 */
331 unsigned int loop_limiter; 331 unsigned int loop_limiter;
@@ -470,7 +470,7 @@ is_canonical (const char *name)
470 if ('_' != name[0]) 470 if ('_' != name[0])
471 return GNUNET_NO; 471 return GNUNET_NO;
472 pos = &name[1]; 472 pos = &name[1];
473 while (NULL != (dot = strchr (pos, '.'))) 473 while (NULL != (dot = strchr (pos, '.')))
474 if ('_' != dot[1]) 474 if ('_' != dot[1])
475 return GNUNET_NO; 475 return GNUNET_NO;
476 else 476 else
@@ -530,8 +530,8 @@ fail_resolution (void *cls,
530/* Don't have this on W32, here's a naive implementation 530/* Don't have this on W32, here's a naive implementation
531 * Was somehow removed on OS X ... */ 531 * Was somehow removed on OS X ... */
532void * 532void *
533memrchr (const void *s, 533memrchr (const void *s,
534 int c, 534 int c,
535 size_t n) 535 size_t n)
536{ 536{
537 const unsigned char *ucs = s; 537 const unsigned char *ucs = s;
@@ -567,7 +567,7 @@ resolver_lookup_get_next_label (struct GNS_ResolverHandle *rh)
567 /* done, this was the last one */ 567 /* done, this was the last one */
568 len = rh->name_resolution_pos; 568 len = rh->name_resolution_pos;
569 rp = rh->name; 569 rp = rh->name;
570 rh->name_resolution_pos = 0; 570 rh->name_resolution_pos = 0;
571 } 571 }
572 else 572 else
573 { 573 {
@@ -575,8 +575,8 @@ resolver_lookup_get_next_label (struct GNS_ResolverHandle *rh)
575 len = rh->name_resolution_pos - (dot - rh->name) - 1; 575 len = rh->name_resolution_pos - (dot - rh->name) - 1;
576 rp = dot + 1; 576 rp = dot + 1;
577 rh->name_resolution_pos = dot - rh->name; 577 rh->name_resolution_pos = dot - rh->name;
578 } 578 }
579 return GNUNET_strndup (rp, len); 579 return GNUNET_strndup (rp, len);
580} 580}
581 581
582 582
@@ -617,7 +617,7 @@ transmit_lookup_dns_result (struct GNS_ResolverHandle *rh)
617 i++; 617 i++;
618 } 618 }
619 GNUNET_assert (i == n); 619 GNUNET_assert (i == n);
620 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 620 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
621 "Transmitting standard DNS result with %u records\n", 621 "Transmitting standard DNS result with %u records\n",
622 n); 622 n);
623 rh->proc (rh->proc_cls, 623 rh->proc (rh->proc_cls,
@@ -754,7 +754,7 @@ dns_result_parser (void *cls,
754 rh->dns_request = NULL; 754 rh->dns_request = NULL;
755 GNUNET_SCHEDULER_cancel (rh->task_id); 755 GNUNET_SCHEDULER_cancel (rh->task_id);
756 rh->task_id = GNUNET_SCHEDULER_NO_TASK; 756 rh->task_id = GNUNET_SCHEDULER_NO_TASK;
757 p = GNUNET_DNSPARSER_parse ((const char *) dns, 757 p = GNUNET_DNSPARSER_parse ((const char *) dns,
758 dns_len); 758 dns_len);
759 if (NULL == p) 759 if (NULL == p)
760 { 760 {
@@ -776,7 +776,7 @@ dns_result_parser (void *cls,
776 rh->name = GNUNET_strdup (p->answers[0].data.hostname); 776 rh->name = GNUNET_strdup (p->answers[0].data.hostname);
777 start_resolver_lookup (rh); 777 start_resolver_lookup (rh);
778 GNUNET_DNSPARSER_free_packet (p); 778 GNUNET_DNSPARSER_free_packet (p);
779 return; 779 return;
780 } 780 }
781 /* FIXME: add DNAME support */ 781 /* FIXME: add DNAME support */
782 782
@@ -798,7 +798,7 @@ dns_result_parser (void *cls,
798 rec = &p->answers[i]; 798 rec = &p->answers[i];
799 else if (i < p->num_answers + p->num_authority_records) 799 else if (i < p->num_answers + p->num_authority_records)
800 rec = &p->authority_records[i - p->num_answers]; 800 rec = &p->authority_records[i - p->num_answers];
801 else 801 else
802 rec = &p->authority_records[i - p->num_answers - p->num_authority_records]; 802 rec = &p->authority_records[i - p->num_answers - p->num_authority_records];
803 /* As we copied the full DNS name to 'rh->ac_tail->label', this 803 /* As we copied the full DNS name to 'rh->ac_tail->label', this
804 should be the correct check to see if this record is actually 804 should be the correct check to see if this record is actually
@@ -909,7 +909,7 @@ dns_result_parser (void *cls,
909 } 909 }
910 rh->proc (rh->proc_cls, rd_count - skip, rd); 910 rh->proc (rh->proc_cls, rd_count - skip, rd);
911 GNS_resolver_lookup_cancel (rh); 911 GNS_resolver_lookup_cancel (rh);
912 } 912 }
913 GNUNET_DNSPARSER_free_packet (p); 913 GNUNET_DNSPARSER_free_packet (p);
914} 914}
915 915
@@ -963,7 +963,7 @@ recursive_dns_resolution (struct GNS_ResolverHandle *rh)
963 UINT16_MAX); 963 UINT16_MAX);
964 p->flags.opcode = GNUNET_TUN_DNS_OPCODE_QUERY; 964 p->flags.opcode = GNUNET_TUN_DNS_OPCODE_QUERY;
965 p->flags.recursion_desired = 1; 965 p->flags.recursion_desired = 1;
966 if (GNUNET_OK != 966 if (GNUNET_OK !=
967 GNUNET_DNSPARSER_pack (p, 1024, &dns_request, &dns_request_length)) 967 GNUNET_DNSPARSER_pack (p, 1024, &dns_request, &dns_request_length))
968 { 968 {
969 GNUNET_break (0); 969 GNUNET_break (0);
@@ -993,7 +993,7 @@ recursive_dns_resolution (struct GNS_ResolverHandle *rh)
993 * Merge it into our chain. 993 * Merge it into our chain.
994 * 994 *
995 * @param rh resolution we are performing 995 * @param rh resolution we are performing
996 * @param cname value of the cname record we got for the current 996 * @param cname value of the cname record we got for the current
997 * authority chain tail 997 * authority chain tail
998 */ 998 */
999static void 999static void
@@ -1030,13 +1030,13 @@ handle_gns_cname_result (struct GNS_ResolverHandle *rh,
1030 ac = GNUNET_new (struct AuthorityChain); 1030 ac = GNUNET_new (struct AuthorityChain);
1031 ac->rh = rh; 1031 ac->rh = rh;
1032 ac->gns_authority = GNUNET_YES; 1032 ac->gns_authority = GNUNET_YES;
1033 ac->authority_info.gns_authority = rh->ac_tail->authority_info.gns_authority; 1033 ac->authority_info.gns_authority = rh->ac_tail->authority_info.gns_authority;
1034 ac->label = resolver_lookup_get_next_label (rh); 1034 ac->label = resolver_lookup_get_next_label (rh);
1035 /* tigger shortening */ 1035 /* tigger shortening */
1036 if (NULL != rh->shorten_key) 1036 if (NULL != rh->shorten_key)
1037 GNS_shorten_start (rh->ac_tail->label, 1037 GNS_shorten_start (rh->ac_tail->label,
1038 &ac->authority_info.gns_authority, 1038 &ac->authority_info.gns_authority,
1039 rh->shorten_key); 1039 rh->shorten_key);
1040 /* add AC to tail */ 1040 /* add AC to tail */
1041 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, 1041 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
1042 rh->ac_tail, 1042 rh->ac_tail,
@@ -1076,7 +1076,7 @@ handle_gns_resolution_result (void *cls,
1076 * will match 'result_af' from the request 1076 * will match 'result_af' from the request
1077 * @param address IP address (struct in_addr or struct in_addr6, depending on 'af') 1077 * @param address IP address (struct in_addr or struct in_addr6, depending on 'af')
1078 * that the VPN allocated for the redirection; 1078 * that the VPN allocated for the redirection;
1079 * traffic to this IP will now be redirected to the 1079 * traffic to this IP will now be redirected to the
1080 * specified target peer; NULL on error 1080 * specified target peer; NULL on error
1081 */ 1081 */
1082static void 1082static void
@@ -1102,7 +1102,7 @@ vpn_allocation_cb (void *cls,
1102 { 1102 {
1103 switch (af) 1103 switch (af)
1104 { 1104 {
1105 case AF_INET: 1105 case AF_INET:
1106 rd[i].record_type = GNUNET_DNSPARSER_TYPE_A; 1106 rd[i].record_type = GNUNET_DNSPARSER_TYPE_A;
1107 rd[i].data_size = sizeof (struct in_addr); 1107 rd[i].data_size = sizeof (struct in_addr);
1108 rd[i].expiration_time = GNUNET_TIME_relative_to_absolute (VPN_TIMEOUT).abs_value_us; 1108 rd[i].expiration_time = GNUNET_TIME_relative_to_absolute (VPN_TIMEOUT).abs_value_us;
@@ -1118,12 +1118,12 @@ vpn_allocation_cb (void *cls,
1118 break; 1118 break;
1119 default: 1119 default:
1120 GNUNET_assert (0); 1120 GNUNET_assert (0);
1121 } 1121 }
1122 break; 1122 break;
1123 } 1123 }
1124 } 1124 }
1125 GNUNET_assert (i < vpn_ctx->rd_count); 1125 GNUNET_assert (i < vpn_ctx->rd_count);
1126 handle_gns_resolution_result (rh, 1126 handle_gns_resolution_result (rh,
1127 vpn_ctx->rd_count, 1127 vpn_ctx->rd_count,
1128 rd); 1128 rd);
1129 GNUNET_free (vpn_ctx->rd_data); 1129 GNUNET_free (vpn_ctx->rd_data);
@@ -1168,7 +1168,7 @@ handle_gns_resolution_result (void *cls,
1168 "Resolution succeeded for `%s' in zone %s, got %u records\n", 1168 "Resolution succeeded for `%s' in zone %s, got %u records\n",
1169 rh->ac_tail->label, 1169 rh->ac_tail->label,
1170 GNUNET_NAMESTORE_z2s (&rh->ac_tail->authority_info.gns_authority), 1170 GNUNET_NAMESTORE_z2s (&rh->ac_tail->authority_info.gns_authority),
1171 rd_count); 1171 rd_count);
1172 if (0 == rh->name_resolution_pos) 1172 if (0 == rh->name_resolution_pos)
1173 { 1173 {
1174 /* top-level match, are we done yet? */ 1174 /* top-level match, are we done yet? */
@@ -1188,10 +1188,10 @@ handle_gns_resolution_result (void *cls,
1188 GNS_resolver_lookup_cancel (rh); 1188 GNS_resolver_lookup_cancel (rh);
1189 return; 1189 return;
1190 } 1190 }
1191 handle_gns_cname_result (rh, 1191 handle_gns_cname_result (rh,
1192 cname); 1192 cname);
1193 GNUNET_free (cname); 1193 GNUNET_free (cname);
1194 return; 1194 return;
1195 } 1195 }
1196 /* If A/AAAA was requested, but we got a VPN 1196 /* If A/AAAA was requested, but we got a VPN
1197 record, we convert it to A/AAAA using GNUnet VPN */ 1197 record, we convert it to A/AAAA using GNUnet VPN */
@@ -1211,7 +1211,7 @@ handle_gns_resolution_result (void *cls,
1211 GNUNET_break_op (0); 1211 GNUNET_break_op (0);
1212 rh->proc (rh->proc_cls, 0, NULL); 1212 rh->proc (rh->proc_cls, 0, NULL);
1213 GNS_resolver_lookup_cancel (rh); 1213 GNS_resolver_lookup_cancel (rh);
1214 return; 1214 return;
1215 } 1215 }
1216 vpn = (const struct GNUNET_TUN_GnsVpnRecord *) rd[i].data; 1216 vpn = (const struct GNUNET_TUN_GnsVpnRecord *) rd[i].data;
1217 vname = (const char *) &vpn[1]; 1217 vname = (const char *) &vpn[1];
@@ -1300,7 +1300,7 @@ handle_gns_resolution_result (void *cls,
1300 rd_off++; 1300 rd_off++;
1301 } 1301 }
1302 } 1302 }
1303 GNUNET_free_non_null (cname); 1303 GNUNET_free_non_null (cname);
1304 } 1304 }
1305 break; 1305 break;
1306 case GNUNET_DNSPARSER_TYPE_SOA: 1306 case GNUNET_DNSPARSER_TYPE_SOA:
@@ -1337,7 +1337,7 @@ handle_gns_resolution_result (void *cls,
1337 } 1337 }
1338 } 1338 }
1339 if (NULL != soa) 1339 if (NULL != soa)
1340 GNUNET_DNSPARSER_free_soa (soa); 1340 GNUNET_DNSPARSER_free_soa (soa);
1341 } 1341 }
1342 break; 1342 break;
1343 case GNUNET_DNSPARSER_TYPE_MX: 1343 case GNUNET_DNSPARSER_TYPE_MX:
@@ -1373,7 +1373,7 @@ handle_gns_resolution_result (void *cls,
1373 } 1373 }
1374 } 1374 }
1375 if (NULL != mx) 1375 if (NULL != mx)
1376 GNUNET_DNSPARSER_free_mx (mx); 1376 GNUNET_DNSPARSER_free_mx (mx);
1377 } 1377 }
1378 break; 1378 break;
1379 case GNUNET_DNSPARSER_TYPE_SRV: 1379 case GNUNET_DNSPARSER_TYPE_SRV:
@@ -1381,7 +1381,7 @@ handle_gns_resolution_result (void *cls,
1381 struct GNUNET_DNSPARSER_SrvRecord *srv; 1381 struct GNUNET_DNSPARSER_SrvRecord *srv;
1382 1382
1383 off = 0; 1383 off = 0;
1384 /* FIXME: passing rh->name here is is not necessarily what we want 1384 /* FIXME: passing rh->name here is is not necessarily what we want
1385 (SRV support not finished) */ 1385 (SRV support not finished) */
1386 srv = GNUNET_DNSPARSER_parse_srv (rh->name, 1386 srv = GNUNET_DNSPARSER_parse_srv (rh->name,
1387 rd[i].data, 1387 rd[i].data,
@@ -1413,7 +1413,7 @@ handle_gns_resolution_result (void *cls,
1413 } 1413 }
1414 } 1414 }
1415 if (NULL != srv) 1415 if (NULL != srv)
1416 GNUNET_DNSPARSER_free_srv (srv); 1416 GNUNET_DNSPARSER_free_srv (srv);
1417 } 1417 }
1418 break; 1418 break;
1419 case GNUNET_NAMESTORE_TYPE_PKEY: 1419 case GNUNET_NAMESTORE_TYPE_PKEY:
@@ -1421,7 +1421,7 @@ handle_gns_resolution_result (void *cls,
1421 if (NULL != rh->shorten_key) 1421 if (NULL != rh->shorten_key)
1422 { 1422 {
1423 struct GNUNET_CRYPTO_EccPublicSignKey pub; 1423 struct GNUNET_CRYPTO_EccPublicSignKey pub;
1424 1424
1425 if (rd[i].data_size != sizeof (struct GNUNET_CRYPTO_EccPublicSignKey)) 1425 if (rd[i].data_size != sizeof (struct GNUNET_CRYPTO_EccPublicSignKey))
1426 { 1426 {
1427 GNUNET_break_op (0); 1427 GNUNET_break_op (0);
@@ -1439,11 +1439,11 @@ handle_gns_resolution_result (void *cls,
1439 break; 1439 break;
1440 } 1440 }
1441 } 1441 }
1442 1442
1443 /* yes, we are done, return result */ 1443 /* yes, we are done, return result */
1444 rh->proc (rh->proc_cls, rd_off, rd_new); 1444 rh->proc (rh->proc_cls, rd_off, rd_new);
1445 GNS_resolver_lookup_cancel (rh); 1445 GNS_resolver_lookup_cancel (rh);
1446 return; 1446 return;
1447 } 1447 }
1448 do_recurse: 1448 do_recurse:
1449 /* need to recurse, check if we can */ 1449 /* need to recurse, check if we can */
@@ -1459,7 +1459,7 @@ handle_gns_resolution_result (void *cls,
1459 GNUNET_break_op (0); 1459 GNUNET_break_op (0);
1460 rh->proc (rh->proc_cls, 0, NULL); 1460 rh->proc (rh->proc_cls, 0, NULL);
1461 GNS_resolver_lookup_cancel (rh); 1461 GNS_resolver_lookup_cancel (rh);
1462 return; 1462 return;
1463 } 1463 }
1464 /* expand authority chain */ 1464 /* expand authority chain */
1465 ac = GNUNET_new (struct AuthorityChain); 1465 ac = GNUNET_new (struct AuthorityChain);
@@ -1470,10 +1470,10 @@ handle_gns_resolution_result (void *cls,
1470 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey)); 1470 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey));
1471 ac->label = resolver_lookup_get_next_label (rh); 1471 ac->label = resolver_lookup_get_next_label (rh);
1472 /* tigger shortening */ 1472 /* tigger shortening */
1473 if (NULL != rh->shorten_key) 1473 if (NULL != rh->shorten_key)
1474 GNS_shorten_start (rh->ac_tail->label, 1474 GNS_shorten_start (rh->ac_tail->label,
1475 &ac->authority_info.gns_authority, 1475 &ac->authority_info.gns_authority,
1476 rh->shorten_key); 1476 rh->shorten_key);
1477 /* add AC to tail */ 1477 /* add AC to tail */
1478 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head, 1478 GNUNET_CONTAINER_DLL_insert_tail (rh->ac_head,
1479 rh->ac_tail, 1479 rh->ac_tail,
@@ -1491,7 +1491,7 @@ handle_gns_resolution_result (void *cls,
1491 GNUNET_break_op (0); 1491 GNUNET_break_op (0);
1492 rh->proc (rh->proc_cls, 0, NULL); 1492 rh->proc (rh->proc_cls, 0, NULL);
1493 GNS_resolver_lookup_cancel (rh); 1493 GNS_resolver_lookup_cancel (rh);
1494 return; 1494 return;
1495 } 1495 }
1496 /* find associated A/AAAA record */ 1496 /* find associated A/AAAA record */
1497 sa = NULL; 1497 sa = NULL;
@@ -1506,7 +1506,7 @@ handle_gns_resolution_result (void *cls,
1506 GNUNET_break_op (0); 1506 GNUNET_break_op (0);
1507 rh->proc (rh->proc_cls, 0, NULL); 1507 rh->proc (rh->proc_cls, 0, NULL);
1508 GNS_resolver_lookup_cancel (rh); 1508 GNS_resolver_lookup_cancel (rh);
1509 return; 1509 return;
1510 } 1510 }
1511 /* FIXME: might want to check if we support IPv4 here, 1511 /* FIXME: might want to check if we support IPv4 here,
1512 and otherwise skip this one and hope we find another */ 1512 and otherwise skip this one and hope we find another */
@@ -1528,7 +1528,7 @@ handle_gns_resolution_result (void *cls,
1528 GNUNET_break_op (0); 1528 GNUNET_break_op (0);
1529 rh->proc (rh->proc_cls, 0, NULL); 1529 rh->proc (rh->proc_cls, 0, NULL);
1530 GNS_resolver_lookup_cancel (rh); 1530 GNS_resolver_lookup_cancel (rh);
1531 return; 1531 return;
1532 } 1532 }
1533 /* FIXME: might want to check if we support IPv6 here, 1533 /* FIXME: might want to check if we support IPv6 here,
1534 and otherwise skip this one and hope we find another */ 1534 and otherwise skip this one and hope we find another */
@@ -1620,7 +1620,7 @@ handle_gns_resolution_result (void *cls,
1620 GNS_resolver_lookup_cancel (rh); 1620 GNS_resolver_lookup_cancel (rh);
1621 return; 1621 return;
1622 } 1622 }
1623 handle_gns_cname_result (rh, 1623 handle_gns_cname_result (rh,
1624 cname); 1624 cname);
1625 GNUNET_free (cname); 1625 GNUNET_free (cname);
1626 return; 1626 return;
@@ -1688,7 +1688,7 @@ handle_dht_response (void *cls,
1688 const struct GNUNET_HashCode *key, 1688 const struct GNUNET_HashCode *key,
1689 const struct GNUNET_PeerIdentity *get_path, 1689 const struct GNUNET_PeerIdentity *get_path,
1690 unsigned int get_path_length, 1690 unsigned int get_path_length,
1691 const struct GNUNET_PeerIdentity *put_path, 1691 const struct GNUNET_PeerIdentity *put_path,
1692 unsigned int put_path_length, 1692 unsigned int put_path_length,
1693 enum GNUNET_BLOCK_Type type, 1693 enum GNUNET_BLOCK_Type type,
1694 size_t size, const void *data) 1694 size_t size, const void *data)
@@ -1697,11 +1697,11 @@ handle_dht_response (void *cls,
1697 struct AuthorityChain *ac = rh->ac_tail; 1697 struct AuthorityChain *ac = rh->ac_tail;
1698 const struct GNUNET_NAMESTORE_Block *block; 1698 const struct GNUNET_NAMESTORE_Block *block;
1699 struct CacheOps *co; 1699 struct CacheOps *co;
1700 1700
1701 GNUNET_DHT_get_stop (rh->get_handle); 1701 GNUNET_DHT_get_stop (rh->get_handle);
1702 rh->get_handle = NULL; 1702 rh->get_handle = NULL;
1703 GNUNET_CONTAINER_heap_remove_node (rh->dht_heap_node); 1703 GNUNET_CONTAINER_heap_remove_node (rh->dht_heap_node);
1704 rh->dht_heap_node = NULL; 1704 rh->dht_heap_node = NULL;
1705 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1705 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1706 "Handling response from the DHT\n"); 1706 "Handling response from the DHT\n");
1707 if (size < sizeof (struct GNUNET_NAMESTORE_Block)) 1707 if (size < sizeof (struct GNUNET_NAMESTORE_Block))
@@ -1710,11 +1710,11 @@ handle_dht_response (void *cls,
1710 GNUNET_break (0); 1710 GNUNET_break (0);
1711 rh->proc (rh->proc_cls, 0, NULL); 1711 rh->proc (rh->proc_cls, 0, NULL);
1712 GNS_resolver_lookup_cancel (rh); 1712 GNS_resolver_lookup_cancel (rh);
1713 return; 1713 return;
1714 } 1714 }
1715 block = data; 1715 block = data;
1716 if (size != 1716 if (size !=
1717 ntohl (block->purpose.size) + 1717 ntohl (block->purpose.size) +
1718 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) + 1718 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) +
1719 sizeof (struct GNUNET_CRYPTO_EccSignature)) 1719 sizeof (struct GNUNET_CRYPTO_EccSignature))
1720 { 1720 {
@@ -1722,7 +1722,7 @@ handle_dht_response (void *cls,
1722 GNUNET_break (0); 1722 GNUNET_break (0);
1723 rh->proc (rh->proc_cls, 0, NULL); 1723 rh->proc (rh->proc_cls, 0, NULL);
1724 GNS_resolver_lookup_cancel (rh); 1724 GNS_resolver_lookup_cancel (rh);
1725 return; 1725 return;
1726 } 1726 }
1727 if (GNUNET_OK != 1727 if (GNUNET_OK !=
1728 GNUNET_NAMESTORE_block_decrypt (block, 1728 GNUNET_NAMESTORE_block_decrypt (block,
@@ -1756,7 +1756,7 @@ handle_dht_response (void *cls,
1756 * @param cls closure with the `struct GNS_ResolverHandle` 1756 * @param cls closure with the `struct GNS_ResolverHandle`
1757 * @param block block that was stored in the namestore 1757 * @param block block that was stored in the namestore
1758 */ 1758 */
1759static void 1759static void
1760handle_namestore_block_response (void *cls, 1760handle_namestore_block_response (void *cls,
1761 const struct GNUNET_NAMESTORE_Block *block) 1761 const struct GNUNET_NAMESTORE_Block *block)
1762{ 1762{
@@ -1879,10 +1879,10 @@ recursive_resolution (void *cls,
1879 GNS_resolver_lookup_cancel (rh); 1879 GNS_resolver_lookup_cancel (rh);
1880 return; 1880 return;
1881 } 1881 }
1882 if (GNUNET_YES == rh->ac_tail->gns_authority) 1882 if (GNUNET_YES == rh->ac_tail->gns_authority)
1883 recursive_gns_resolution_namestore (rh); 1883 recursive_gns_resolution_namestore (rh);
1884 else 1884 else
1885 recursive_dns_resolution (rh); 1885 recursive_dns_resolution (rh);
1886} 1886}
1887 1887
1888 1888
@@ -1919,11 +1919,11 @@ start_resolver_lookup (struct GNS_ResolverHandle *rh)
1919 default: 1919 default:
1920 af = AF_UNSPEC; 1920 af = AF_UNSPEC;
1921 break; 1921 break;
1922 } 1922 }
1923 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1923 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1924 "Doing standard DNS lookup for `%s'\n", 1924 "Doing standard DNS lookup for `%s'\n",
1925 rh->name); 1925 rh->name);
1926 rh->std_resolve = GNUNET_RESOLVER_ip_get (rh->name, 1926 rh->std_resolve = GNUNET_RESOLVER_ip_get (rh->name,
1927 af, 1927 af,
1928 DNS_LOOKUP_TIMEOUT, 1928 DNS_LOOKUP_TIMEOUT,
1929 &handle_dns_result, 1929 &handle_dns_result,
@@ -2002,7 +2002,7 @@ GNS_resolver_lookup (const struct GNUNET_CRYPTO_EccPublicSignKey *zone,
2002 2002
2003 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2003 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2004 (NULL == shorten_key) 2004 (NULL == shorten_key)
2005 ? "Starting lookup for `%s' with shortening disabled\n" 2005 ? "Starting lookup for `%s' with shortening disabled\n"
2006 : "Starting lookup for `%s' with shortening enabled\n", 2006 : "Starting lookup for `%s' with shortening enabled\n",
2007 name); 2007 name);
2008 rh = GNUNET_new (struct GNS_ResolverHandle); 2008 rh = GNUNET_new (struct GNS_ResolverHandle);
@@ -2153,7 +2153,7 @@ GNS_resolver_done ()
2153 while (NULL != (rh = rlh_head)) 2153 while (NULL != (rh = rlh_head))
2154 { 2154 {
2155 rh->proc (rh->proc_cls, 0, NULL); 2155 rh->proc (rh->proc_cls, 0, NULL);
2156 GNS_resolver_lookup_cancel (rh); 2156 GNS_resolver_lookup_cancel (rh);
2157 } 2157 }
2158 while (NULL != (co = co_head)) 2158 while (NULL != (co = co_head))
2159 { 2159 {
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h
index 84d4c2bd7..e9916c778 100644
--- a/src/gns/gnunet-service-gns_resolver.h
+++ b/src/gns/gnunet-service-gns_resolver.h
@@ -111,7 +111,7 @@ GNS_resolver_lookup_cancel (struct GNS_ResolverHandle *rh);
111 * @return #GNUNET_YES or #GNUNET_NO 111 * @return #GNUNET_YES or #GNUNET_NO
112 */ 112 */
113int 113int
114is_tld (const char *name, 114is_tld (const char *name,
115 const char *tld); 115 const char *tld);
116 116
117 117
diff --git a/src/gns/gnunet-service-gns_shorten.c b/src/gns/gnunet-service-gns_shorten.c
index 8b69e670c..ff2cab097 100644
--- a/src/gns/gnunet-service-gns_shorten.c
+++ b/src/gns/gnunet-service-gns_shorten.c
@@ -83,12 +83,12 @@ struct GetPseuAuthorityHandle
83 struct GNUNET_CRYPTO_EccPublicSignKey target_zone; 83 struct GNUNET_CRYPTO_EccPublicSignKey target_zone;
84 84
85 /** 85 /**
86 * Handle for DHT lookups. Should be NULL if no lookups are in progress 86 * Handle for DHT lookups. Should be NULL if no lookups are in progress
87 */ 87 */
88 struct GNUNET_DHT_GetHandle *get_handle; 88 struct GNUNET_DHT_GetHandle *get_handle;
89 89
90 /** 90 /**
91 * Handle to namestore request 91 * Handle to namestore request
92 */ 92 */
93 struct GNUNET_NAMESTORE_QueueEntry *namestore_task; 93 struct GNUNET_NAMESTORE_QueueEntry *namestore_task;
94 94
@@ -158,8 +158,8 @@ free_get_pseu_authority_handle (struct GetPseuAuthorityHandle *gph)
158 * @param emsg unused 158 * @param emsg unused
159 */ 159 */
160static void 160static void
161create_pkey_cont (void* cls, 161create_pkey_cont (void* cls,
162 int32_t success, 162 int32_t success,
163 const char *emsg) 163 const char *emsg)
164{ 164{
165 struct GetPseuAuthorityHandle* gph = cls; 165 struct GetPseuAuthorityHandle* gph = cls;
@@ -205,7 +205,7 @@ process_pseu_block_ns (void *cls,
205 } 205 }
206 GNUNET_CRYPTO_ecc_key_get_public_for_signature (&gph->shorten_zone_key, 206 GNUNET_CRYPTO_ecc_key_get_public_for_signature (&gph->shorten_zone_key,
207 &pub); 207 &pub);
208 if (GNUNET_OK != 208 if (GNUNET_OK !=
209 GNUNET_NAMESTORE_block_decrypt (block, 209 GNUNET_NAMESTORE_block_decrypt (block,
210 &pub, 210 &pub,
211 gph->current_label, 211 gph->current_label,
@@ -225,10 +225,10 @@ process_pseu_block_ns (void *cls,
225 * @param gph the handle to our shorten operation 225 * @param gph the handle to our shorten operation
226 * @param label the label to lookup 226 * @param label the label to lookup
227 */ 227 */
228static void 228static void
229perform_pseu_lookup (struct GetPseuAuthorityHandle *gph, 229perform_pseu_lookup (struct GetPseuAuthorityHandle *gph,
230 const char *label) 230 const char *label)
231{ 231{
232 struct GNUNET_CRYPTO_EccPublicSignKey pub; 232 struct GNUNET_CRYPTO_EccPublicSignKey pub;
233 struct GNUNET_HashCode query; 233 struct GNUNET_HashCode query;
234 234
@@ -266,7 +266,7 @@ process_pseu_lookup_ns (void *cls,
266 if (rd_count > 0) 266 if (rd_count > 0)
267 { 267 {
268 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 268 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
269 "Name `%s' already taken, cannot shorten.\n", 269 "Name `%s' already taken, cannot shorten.\n",
270 gph->current_label); 270 gph->current_label);
271 /* if this was not yet the original label, try one more 271 /* if this was not yet the original label, try one more
272 time, this time not using PSEU but the original label */ 272 time, this time not using PSEU but the original label */
@@ -283,7 +283,7 @@ process_pseu_lookup_ns (void *cls,
283 } 283 }
284 /* name is available */ 284 /* name is available */
285 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 285 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
286 "Shortening `%s' to `%s'\n", 286 "Shortening `%s' to `%s'\n",
287 GNUNET_NAMESTORE_z2s (&gph->target_zone), 287 GNUNET_NAMESTORE_z2s (&gph->target_zone),
288 gph->current_label); 288 gph->current_label);
289 new_pkey.expiration_time = UINT64_MAX; 289 new_pkey.expiration_time = UINT64_MAX;
@@ -293,7 +293,7 @@ process_pseu_lookup_ns (void *cls,
293 new_pkey.flags = GNUNET_NAMESTORE_RF_NONE 293 new_pkey.flags = GNUNET_NAMESTORE_RF_NONE
294 | GNUNET_NAMESTORE_RF_PRIVATE 294 | GNUNET_NAMESTORE_RF_PRIVATE
295 | GNUNET_NAMESTORE_RF_PENDING; 295 | GNUNET_NAMESTORE_RF_PENDING;
296 gph->namestore_task 296 gph->namestore_task
297 = GNUNET_NAMESTORE_records_store (namestore_handle, 297 = GNUNET_NAMESTORE_records_store (namestore_handle,
298 &gph->shorten_zone_key, 298 &gph->shorten_zone_key,
299 gph->current_label, 299 gph->current_label,
@@ -309,7 +309,7 @@ process_pseu_lookup_ns (void *cls,
309 * @param pseu the pseu result or NULL 309 * @param pseu the pseu result or NULL
310 */ 310 */
311static void 311static void
312process_pseu_result (struct GetPseuAuthorityHandle* gph, 312process_pseu_result (struct GetPseuAuthorityHandle* gph,
313 const char *pseu) 313 const char *pseu)
314{ 314{
315 if (NULL == pseu) 315 if (NULL == pseu)
@@ -320,7 +320,7 @@ process_pseu_result (struct GetPseuAuthorityHandle* gph,
320 gph->label); 320 gph->label);
321 perform_pseu_lookup (gph, gph->label); 321 perform_pseu_lookup (gph, gph->label);
322 return; 322 return;
323 } 323 }
324 /* check if 'pseu' is taken */ 324 /* check if 'pseu' is taken */
325 perform_pseu_lookup (gph, pseu); 325 perform_pseu_lookup (gph, pseu);
326} 326}
@@ -373,7 +373,7 @@ process_auth_records (void *cls,
373 rd[i].data, 373 rd[i].data,
374 rd[i].data_size); 374 rd[i].data_size);
375 pseu[rd[i].data_size] = '\0'; 375 pseu[rd[i].data_size] = '\0';
376 process_pseu_result (gph, 376 process_pseu_result (gph,
377 pseu); 377 pseu);
378 return; 378 return;
379 } 379 }
@@ -432,18 +432,18 @@ process_auth_discovery_dht_result (void* cls,
432 /* how did this pass DHT block validation!? */ 432 /* how did this pass DHT block validation!? */
433 GNUNET_break (0); 433 GNUNET_break (0);
434 process_pseu_result (gph, NULL); 434 process_pseu_result (gph, NULL);
435 return; 435 return;
436 } 436 }
437 block = data; 437 block = data;
438 if (size != 438 if (size !=
439 ntohl (block->purpose.size) + 439 ntohl (block->purpose.size) +
440 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) + 440 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) +
441 sizeof (struct GNUNET_CRYPTO_EccSignature)) 441 sizeof (struct GNUNET_CRYPTO_EccSignature))
442 { 442 {
443 /* how did this pass DHT block validation!? */ 443 /* how did this pass DHT block validation!? */
444 GNUNET_break (0); 444 GNUNET_break (0);
445 process_pseu_result (gph, NULL); 445 process_pseu_result (gph, NULL);
446 return; 446 return;
447 } 447 }
448 if (GNUNET_OK != 448 if (GNUNET_OK !=
449 GNUNET_NAMESTORE_block_decrypt (block, 449 GNUNET_NAMESTORE_block_decrypt (block,
@@ -455,7 +455,7 @@ process_auth_discovery_dht_result (void* cls,
455 /* other peer encrypted invalid block, complain */ 455 /* other peer encrypted invalid block, complain */
456 GNUNET_break_op (0); 456 GNUNET_break_op (0);
457 process_pseu_result (gph, NULL); 457 process_pseu_result (gph, NULL);
458 return; 458 return;
459 } 459 }
460} 460}
461 461
@@ -479,7 +479,7 @@ process_zone_to_name_discover (void *cls,
479{ 479{
480 struct GetPseuAuthorityHandle* gph = cls; 480 struct GetPseuAuthorityHandle* gph = cls;
481 struct GNUNET_HashCode lookup_key; 481 struct GNUNET_HashCode lookup_key;
482 482
483 gph->namestore_task = NULL; 483 gph->namestore_task = NULL;
484 if (0 != rd_len) 484 if (0 != rd_len)
485 { 485 {
@@ -492,10 +492,10 @@ process_zone_to_name_discover (void *cls,
492 } 492 }
493 /* record does not yet exist, go into DHT to find PSEU record */ 493 /* record does not yet exist, go into DHT to find PSEU record */
494 GNUNET_NAMESTORE_query_from_public_key (&gph->target_zone, 494 GNUNET_NAMESTORE_query_from_public_key (&gph->target_zone,
495 GNUNET_GNS_TLD_PLUS, 495 GNUNET_GNS_TLD_PLUS,
496 &lookup_key); 496 &lookup_key);
497 gph->timeout_task = GNUNET_SCHEDULER_add_delayed (DHT_LOOKUP_TIMEOUT, 497 gph->timeout_task = GNUNET_SCHEDULER_add_delayed (DHT_LOOKUP_TIMEOUT,
498 &handle_auth_discovery_timeout, 498 &handle_auth_discovery_timeout,
499 gph); 499 gph);
500 gph->get_handle = GNUNET_DHT_get_start (dht_handle, 500 gph->get_handle = GNUNET_DHT_get_start (dht_handle,
501 GNUNET_BLOCK_TYPE_GNS_NAMERECORD, 501 GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
diff --git a/src/gns/gnunet_w32nsp_lib.h b/src/gns/gnunet_w32nsp_lib.h
index f20859c7c..bd1360acd 100644
--- a/src/gns/gnunet_w32nsp_lib.h
+++ b/src/gns/gnunet_w32nsp_lib.h
@@ -1,9 +1,9 @@
1#if !defined(GNUENT_W32NSP_LIB_H) 1#if !defined(GNUENT_W32NSP_LIB_H)
2#define GNUENT_W32NSP_LIB_H 2#define GNUENT_W32NSP_LIB_H
3 3
4#include <basetyps.h> 4#include <basetyps.h>
5 5
6/* E0D24085-622C-4A93-9A0018-034469DE28DA */ 6/* E0D24085-622C-4A93-9A0018-034469DE28DA */
7DEFINE_GUID (GNUNET_NAMESPACE_PROVIDER_DNS, 0xE0D24085L, 0x622C, 0x4A93, 0x9A, 0x18, 0x03, 0x44, 0x69, 0xDE, 0x28, 0xDA); 7DEFINE_GUID (GNUNET_NAMESPACE_PROVIDER_DNS, 0xE0D24085L, 0x622C, 0x4A93, 0x9A, 0x18, 0x03, 0x44, 0x69, 0xDE, 0x28, 0xDA);
8 8
9#endif /* GNUENT_W32NSP_LIB_H */ \ No newline at end of file 9#endif /* GNUENT_W32NSP_LIB_H */ \ No newline at end of file
diff --git a/src/gns/nss/nss_gns.c b/src/gns/nss/nss_gns.c
index 29dbfd87b..5991c5a0f 100644
--- a/src/gns/nss/nss_gns.c
+++ b/src/gns/nss/nss_gns.c
@@ -7,12 +7,12 @@
7 it under the terms of the GNU General Public License as published 7 it under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 3 of the License, 8 by the Free Software Foundation; either version 3 of the License,
9 or (at your option) any later version. 9 or (at your option) any later version.
10 10
11 nss-mdns is distributed in the hope that it will be useful, but1 11 nss-mdns is distributed in the hope that it will be useful, but1
12 WITHOUT ANY WARRANTY; without even the implied warranty of 12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 General Public License for more details.
15 15
16 You should have received a copy of the GNU Lesser General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with nss-mdns; if not, write to the Free Software 17 along with nss-mdns; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -67,7 +67,7 @@ static int ends_with(const char *name, const char* suffix) {
67 * @return 1 if true 67 * @return 1 if true
68 */ 68 */
69static int verify_name_allowed (const char *name) { 69static int verify_name_allowed (const char *name) {
70 return ends_with(name, ".gnu") || ends_with(name, ".zkey"); 70 return ends_with(name, ".gnu") || ends_with(name, ".zkey");
71} 71}
72 72
73/** 73/**
@@ -96,7 +96,7 @@ enum nss_status _nss_gns_gethostbyname2_r(
96 int i; 96 int i;
97 size_t address_length, l, idx, astart; 97 size_t address_length, l, idx, astart;
98 int name_allowed; 98 int name_allowed;
99 99
100 if (af == AF_UNSPEC) 100 if (af == AF_UNSPEC)
101#ifdef NSS_IPV6_ONLY 101#ifdef NSS_IPV6_ONLY
102 af = AF_INET6; 102 af = AF_INET6;
@@ -105,13 +105,13 @@ enum nss_status _nss_gns_gethostbyname2_r(
105#endif 105#endif
106 106
107#ifdef NSS_IPV4_ONLY 107#ifdef NSS_IPV4_ONLY
108 if (af != AF_INET) 108 if (af != AF_INET)
109#elif NSS_IPV6_ONLY 109#elif NSS_IPV6_ONLY
110 if (af != AF_INET6) 110 if (af != AF_INET6)
111#else 111#else
112 if (af != AF_INET && af != AF_INET6) 112 if (af != AF_INET && af != AF_INET6)
113#endif 113#endif
114 { 114 {
115 *errnop = EINVAL; 115 *errnop = EINVAL;
116 *h_errnop = NO_RECOVERY; 116 *h_errnop = NO_RECOVERY;
117 117
@@ -122,19 +122,19 @@ enum nss_status _nss_gns_gethostbyname2_r(
122 if (buflen < 122 if (buflen <
123 sizeof(char*)+ /* alias names */ 123 sizeof(char*)+ /* alias names */
124 strlen(name)+1) { /* official name */ 124 strlen(name)+1) { /* official name */
125 125
126 *errnop = ERANGE; 126 *errnop = ERANGE;
127 *h_errnop = NO_RECOVERY; 127 *h_errnop = NO_RECOVERY;
128 status = NSS_STATUS_TRYAGAIN; 128 status = NSS_STATUS_TRYAGAIN;
129 129
130 goto finish; 130 goto finish;
131 } 131 }
132 132
133 u.count = 0; 133 u.count = 0;
134 u.data_len = 0; 134 u.data_len = 0;
135 135
136 name_allowed = verify_name_allowed(name); 136 name_allowed = verify_name_allowed(name);
137 137
138 if (name_allowed) { 138 if (name_allowed) {
139 139
140 if (!gns_resolve_name(af, name, &u) == 0) 140 if (!gns_resolve_name(af, name, &u) == 0)
@@ -156,22 +156,22 @@ enum nss_status _nss_gns_gethostbyname2_r(
156 goto finish; 156 goto finish;
157 } 157 }
158 158
159 159
160 /* Alias names */ 160 /* Alias names */
161 *((char**) buffer) = NULL; 161 *((char**) buffer) = NULL;
162 result->h_aliases = (char**) buffer; 162 result->h_aliases = (char**) buffer;
163 idx = sizeof(char*); 163 idx = sizeof(char*);
164 164
165 /* Official name */ 165 /* Official name */
166 strcpy(buffer+idx, name); 166 strcpy(buffer+idx, name);
167 result->h_name = buffer+idx; 167 result->h_name = buffer+idx;
168 idx += strlen(name)+1; 168 idx += strlen(name)+1;
169 169
170 ALIGN(idx); 170 ALIGN(idx);
171 171
172 result->h_addrtype = af; 172 result->h_addrtype = af;
173 result->h_length = address_length; 173 result->h_length = address_length;
174 174
175 /* Check if there's enough space for the addresses */ 175 /* Check if there's enough space for the addresses */
176 if (buflen < idx+u.data_len+sizeof(char*)*(u.count+1)) { 176 if (buflen < idx+u.data_len+sizeof(char*)*(u.count+1)) {
177 *errnop = ERANGE; 177 *errnop = ERANGE;
@@ -195,7 +195,7 @@ enum nss_status _nss_gns_gethostbyname2_r(
195 result->h_addr_list = (char**) (buffer+idx); 195 result->h_addr_list = (char**) (buffer+idx);
196 196
197 status = NSS_STATUS_SUCCESS; 197 status = NSS_STATUS_SUCCESS;
198 198
199finish: 199finish:
200 return status; 200 return status;
201} 201}
@@ -254,9 +254,9 @@ enum nss_status _nss_gns_gethostbyaddr_r(
254 int *h_errnop) { 254 int *h_errnop) {
255 255
256 /* we dont do this */ 256 /* we dont do this */
257 257
258 enum nss_status status = NSS_STATUS_UNAVAIL; 258 enum nss_status status = NSS_STATUS_UNAVAIL;
259 259
260 *errnop = EINVAL; 260 *errnop = EINVAL;
261 *h_errnop = NO_RECOVERY; 261 *h_errnop = NO_RECOVERY;
262 262
diff --git a/src/gns/nss/nss_gns_query.c b/src/gns/nss/nss_gns_query.c
index 359b6aa20..b90fd6d05 100644
--- a/src/gns/nss/nss_gns_query.c
+++ b/src/gns/nss/nss_gns_query.c
@@ -36,9 +36,9 @@
36 * @param u the userdata (result struct) 36 * @param u the userdata (result struct)
37 * @return -1 on error else 0 37 * @return -1 on error else 0
38 */ 38 */
39int 39int
40gns_resolve_name (int af, 40gns_resolve_name (int af,
41 const char *name, 41 const char *name,
42 struct userdata *u) 42 struct userdata *u)
43{ 43{
44 FILE *p; 44 FILE *p;
@@ -47,15 +47,15 @@ gns_resolve_name (int af,
47 47
48 if (AF_INET6 == af) 48 if (AF_INET6 == af)
49 { 49 {
50 if (-1 == asprintf (&cmd, 50 if (-1 == asprintf (&cmd,
51 "%s -t AAAA -u %s\n", 51 "%s -t AAAA -u %s\n",
52 "gnunet-gns -r", name)) 52 "gnunet-gns -r", name))
53 return -1; 53 return -1;
54 } 54 }
55 else 55 else
56 { 56 {
57 if (-1 == asprintf (&cmd, 57 if (-1 == asprintf (&cmd,
58 "%s %s\n", 58 "%s %s\n",
59 "gnunet-gns -r -u", name)) 59 "gnunet-gns -r -u", name))
60 return -1; 60 return -1;
61 } 61 }
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c
index d28d1ab0b..932900910 100644
--- a/src/gns/plugin_block_gns.c
+++ b/src/gns/plugin_block_gns.c
@@ -77,7 +77,7 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
77 } 77 }
78 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; 78 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
79 } 79 }
80 80
81 /* this is a reply */ 81 /* this is a reply */
82 if (reply_block_size < sizeof (struct GNUNET_NAMESTORE_Block)) 82 if (reply_block_size < sizeof (struct GNUNET_NAMESTORE_Block))
83 { 83 {
@@ -99,7 +99,7 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
99 GNUNET_break_op (0); 99 GNUNET_break_op (0);
100 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 100 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
101 } 101 }
102 if (GNUNET_OK != 102 if (GNUNET_OK !=
103 GNUNET_NAMESTORE_block_verify (block)) 103 GNUNET_NAMESTORE_block_verify (block))
104 { 104 {
105 GNUNET_break_op (0); 105 GNUNET_break_op (0);
diff --git a/src/gns/test_gns_proxy.c b/src/gns/test_gns_proxy.c
index 16c94eced..8563eda2f 100644
--- a/src/gns/test_gns_proxy.c
+++ b/src/gns/test_gns_proxy.c
@@ -220,9 +220,9 @@ curl_main ()
220 } 220 }
221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download complete, shutting down!\n"); 221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download complete, shutting down!\n");
222 do_shutdown (); 222 do_shutdown ();
223 return; 223 return;
224 } 224 }
225 GNUNET_assert (CURLM_OK == curl_multi_fdset (multi, &rs, &ws, &es, &max)); 225 GNUNET_assert (CURLM_OK == curl_multi_fdset (multi, &rs, &ws, &es, &max));
226 if ( (CURLM_OK != curl_multi_timeout (multi, &timeout)) || 226 if ( (CURLM_OK != curl_multi_timeout (multi, &timeout)) ||
227 (-1 == timeout) ) 227 (-1 == timeout) )
228 delay = GNUNET_TIME_UNIT_SECONDS; 228 delay = GNUNET_TIME_UNIT_SECONDS;
@@ -239,13 +239,13 @@ curl_main ()
239 &nrs, 239 &nrs,
240 &nws, 240 &nws,
241 &curl_task, 241 &curl_task,
242 NULL); 242 NULL);
243} 243}
244 244
245static void 245static void
246start_curl (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 246start_curl (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
247{ 247{
248 GNUNET_asprintf (&url, 248 GNUNET_asprintf (&url,
249 "http://%s:%d/hello_world", 249 "http://%s:%d/hello_world",
250 TEST_DOMAIN, PORT); 250 TEST_DOMAIN, PORT);
251 curl = curl_easy_init (); 251 curl = curl_easy_init ();
@@ -280,7 +280,7 @@ disco_ns (void* cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
280 * will match 'result_af' from the request 280 * will match 'result_af' from the request
281 * @param address IP address (struct in_addr or struct in_addr6, depending on 'af') 281 * @param address IP address (struct in_addr or struct in_addr6, depending on 'af')
282 * that the VPN allocated for the redirection; 282 * that the VPN allocated for the redirection;
283 * traffic to this IP will now be redirected to the 283 * traffic to this IP will now be redirected to the
284 * specified target peer; NULL on error 284 * specified target peer; NULL on error
285 */ 285 */
286static void 286static void
@@ -290,12 +290,12 @@ commence_testing (void *cls, int32_t success, const char *emsg)
290 290
291 if ((emsg != NULL) && (GNUNET_YES != success)) 291 if ((emsg != NULL) && (GNUNET_YES != success))
292 { 292 {
293 fprintf (stderr, 293 fprintf (stderr,
294 "NS failed to create record %s\n", emsg); 294 "NS failed to create record %s\n", emsg);
295 GNUNET_SCHEDULER_shutdown (); 295 GNUNET_SCHEDULER_shutdown ();
296 return; 296 return;
297 } 297 }
298 298
299 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), start_curl, NULL); 299 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), start_curl, NULL);
300 300
301} 301}
@@ -306,7 +306,7 @@ commence_testing (void *cls, int32_t success, const char *emsg)
306/** 306/**
307 * Function to keep the HTTP server running. 307 * Function to keep the HTTP server running.
308 */ 308 */
309static void 309static void
310mhd_main (void); 310mhd_main (void);
311 311
312 312
@@ -320,7 +320,7 @@ mhd_task (void *cls,
320} 320}
321 321
322 322
323static void 323static void
324mhd_main () 324mhd_main ()
325{ 325{
326 struct GNUNET_NETWORK_FDSet nrs; 326 struct GNUNET_NETWORK_FDSet nrs;
@@ -355,7 +355,7 @@ mhd_main ()
355 &nrs, 355 &nrs,
356 &nws, 356 &nws,
357 &mhd_task, 357 &mhd_task,
358 NULL); 358 NULL);
359} 359}
360 360
361static void 361static void
@@ -367,7 +367,7 @@ run (void *cls,
367 struct GNUNET_CRYPTO_EccPrivateKey *host_key; 367 struct GNUNET_CRYPTO_EccPrivateKey *host_key;
368 struct GNUNET_NAMESTORE_RecordData rd; 368 struct GNUNET_NAMESTORE_RecordData rd;
369 char *zone_keyfile; 369 char *zone_keyfile;
370 370
371 namestore = GNUNET_NAMESTORE_connect (cfg); 371 namestore = GNUNET_NAMESTORE_connect (cfg);
372 GNUNET_assert (NULL != namestore); 372 GNUNET_assert (NULL != namestore);
373 flags = MHD_USE_DEBUG; 373 flags = MHD_USE_DEBUG;
@@ -396,7 +396,7 @@ run (void *cls,
396 do_shutdown (); 396 do_shutdown ();
397 return; 397 return;
398 } 398 }
399 399
400 proxy_proc = GNUNET_OS_start_process (GNUNET_NO, 400 proxy_proc = GNUNET_OS_start_process (GNUNET_NO,
401 GNUNET_OS_INHERIT_STD_ALL, 401 GNUNET_OS_INHERIT_STD_ALL,
402 NULL, 402 NULL,
@@ -412,7 +412,7 @@ run (void *cls,
412 do_shutdown (); 412 do_shutdown ();
413 return; 413 return;
414 } 414 }
415 415
416 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 416 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
417 "ZONEKEY", 417 "ZONEKEY",
418 &zone_keyfile)) 418 &zone_keyfile))
diff --git a/src/gns/test_gns_pseu_shorten.c b/src/gns/test_gns_pseu_shorten.c
index 8610179b2..a4c337067 100644
--- a/src/gns/test_gns_pseu_shorten.c
+++ b/src/gns/test_gns_pseu_shorten.c
@@ -127,7 +127,7 @@ end_badly_now ()
127} 127}
128 128
129 129
130static void 130static void
131shutdown_task (void *cls, 131shutdown_task (void *cls,
132 const struct GNUNET_SCHEDULER_TaskContext *tc) 132 const struct GNUNET_SCHEDULER_TaskContext *tc)
133{ 133{
@@ -186,7 +186,7 @@ on_lookup_result (void *cls, uint32_t rd_count,
186 struct in_addr a; 186 struct in_addr a;
187 int i; 187 int i;
188 char* addr; 188 char* addr;
189 189
190 if (rd_count == 0) 190 if (rd_count == 0)
191 { 191 {
192 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 192 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -267,7 +267,7 @@ put_pseu_dht (void *cls, int success)
267 char* nrb_data = NULL; 267 char* nrb_data = NULL;
268 struct GNUNET_CRYPTO_EccSignature *sig; 268 struct GNUNET_CRYPTO_EccSignature *sig;
269 struct GNUNET_NAMESTORE_RecordData rd; 269 struct GNUNET_NAMESTORE_RecordData rd;
270 270
271 memset (&rd, 0, sizeof (struct GNUNET_NAMESTORE_RecordData)); 271 memset (&rd, 0, sizeof (struct GNUNET_NAMESTORE_RecordData));
272 rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; 272 rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
273 rd.data_size = strlen(TEST_PSEU_ALICE)+1; 273 rd.data_size = strlen(TEST_PSEU_ALICE)+1;
@@ -336,7 +336,7 @@ put_pseu_dht (void *cls, int success)
336 DHT_OPERATION_TIMEOUT, 336 DHT_OPERATION_TIMEOUT,
337 &commence_testing, 337 &commence_testing,
338 NULL); 338 NULL);
339 339
340 GNUNET_free(sig); 340 GNUNET_free(sig);
341 GNUNET_free (nrb); 341 GNUNET_free (nrb);
342} 342}
@@ -357,19 +357,19 @@ put_www_dht (void *cls, int success)
357 struct GNUNET_NAMESTORE_RecordData rd; 357 struct GNUNET_NAMESTORE_RecordData rd;
358 char* ip = TEST_IP; 358 char* ip = TEST_IP;
359 struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); 359 struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr));
360 360
361 rd.expiration_time = UINT64_MAX; 361 rd.expiration_time = UINT64_MAX;
362 GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); 362 GNUNET_assert(1 == inet_pton (AF_INET, ip, web));
363 rd.data_size = sizeof(struct in_addr); 363 rd.data_size = sizeof(struct in_addr);
364 rd.data = web; 364 rd.data = web;
365 rd.record_type = GNUNET_DNSPARSER_TYPE_A; 365 rd.record_type = GNUNET_DNSPARSER_TYPE_A;
366 rd.flags = GNUNET_NAMESTORE_RF_NONE; 366 rd.flags = GNUNET_NAMESTORE_RF_NONE;
367 367
368 sig = GNUNET_NAMESTORE_create_signature(alice_key, 368 sig = GNUNET_NAMESTORE_create_signature(alice_key,
369 GNUNET_TIME_UNIT_FOREVER_ABS, 369 GNUNET_TIME_UNIT_FOREVER_ABS,
370 TEST_RECORD_NAME, 370 TEST_RECORD_NAME,
371 &rd, 1); 371 &rd, 1);
372 372
373 GNUNET_break (GNUNET_OK == GNUNET_NAMESTORE_verify_signature (&alice_pkey, 373 GNUNET_break (GNUNET_OK == GNUNET_NAMESTORE_verify_signature (&alice_pkey,
374 GNUNET_TIME_UNIT_FOREVER_ABS, 374 GNUNET_TIME_UNIT_FOREVER_ABS,
375 TEST_RECORD_NAME, 375 TEST_RECORD_NAME,
@@ -443,13 +443,13 @@ put_pkey_dht (void *cls, int32_t success, const char *emsg)
443 char* nrb_data = NULL; 443 char* nrb_data = NULL;
444 struct GNUNET_CRYPTO_EccSignature *sig; 444 struct GNUNET_CRYPTO_EccSignature *sig;
445 struct GNUNET_NAMESTORE_RecordData rd; 445 struct GNUNET_NAMESTORE_RecordData rd;
446 446
447 rd.expiration_time = UINT64_MAX; 447 rd.expiration_time = UINT64_MAX;
448 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); 448 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
449 rd.data = &alice_hash; 449 rd.data = &alice_hash;
450 rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY; 450 rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY;
451 rd.flags = GNUNET_NAMESTORE_RF_NONE; 451 rd.flags = GNUNET_NAMESTORE_RF_NONE;
452 452
453 sig = GNUNET_NAMESTORE_create_signature (bob_key, 453 sig = GNUNET_NAMESTORE_create_signature (bob_key,
454 GNUNET_TIME_UNIT_FOREVER_ABS, 454 GNUNET_TIME_UNIT_FOREVER_ABS,
455 TEST_AUTHORITY_ALICE, 455 TEST_AUTHORITY_ALICE,
@@ -474,7 +474,7 @@ put_pkey_dht (void *cls, int32_t success, const char *emsg)
474 { 474 {
475 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Record serialization failed!\n"); 475 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Record serialization failed!\n");
476 ok = 3; 476 ok = 3;
477 477
478 GNUNET_free (our_key); 478 GNUNET_free (our_key);
479 GNUNET_free (bob_key); 479 GNUNET_free (bob_key);
480 GNUNET_free (alice_key); 480 GNUNET_free (alice_key);
@@ -492,7 +492,7 @@ put_pkey_dht (void *cls, int32_t success, const char *emsg)
492 &zone_hash); 492 &zone_hash);
493 GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double); 493 GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double);
494 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double); 494 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
495 GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash); 495 GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash);
496 496
497 rd_payload_length += sizeof(struct GNSNameRecordBlock) + 497 rd_payload_length += sizeof(struct GNSNameRecordBlock) +
498 strlen(TEST_AUTHORITY_ALICE) + 1; 498 strlen(TEST_AUTHORITY_ALICE) + 1;
@@ -520,7 +520,7 @@ fin_init_zone (void *cls, int32_t success, const char *emsg)
520 rd.data = &bob_hash; 520 rd.data = &bob_hash;
521 rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY; 521 rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY;
522 rd.flags = GNUNET_NAMESTORE_RF_NONE; 522 rd.flags = GNUNET_NAMESTORE_RF_NONE;
523 523
524 GNUNET_NAMESTORE_record_put_by_authority (namestore_handle, 524 GNUNET_NAMESTORE_record_put_by_authority (namestore_handle,
525 our_key, 525 our_key,
526 TEST_AUTHORITY_BOB, 526 TEST_AUTHORITY_BOB,
@@ -560,7 +560,7 @@ do_check (void *cls,
560 char *shorten_keyfile; 560 char *shorten_keyfile;
561 char *our_keyfile; 561 char *our_keyfile;
562 struct GNUNET_NAMESTORE_RecordData rd; 562 struct GNUNET_NAMESTORE_RecordData rd;
563 563
564 cfg = ccfg; 564 cfg = ccfg;
565 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 565 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
566 566
@@ -572,7 +572,7 @@ do_check (void *cls,
572 end_badly_now(); 572 end_badly_now();
573 return; 573 return;
574 } 574 }
575 575
576 /* dht */ 576 /* dht */
577 dht_handle = GNUNET_DHT_connect(cfg, 1); 577 dht_handle = GNUNET_DHT_connect(cfg, 1);
578 if (NULL == dht_handle) 578 if (NULL == dht_handle)
@@ -591,7 +591,7 @@ do_check (void *cls,
591 GNUNET_free (our_keyfile); 591 GNUNET_free (our_keyfile);
592 return; 592 return;
593 } 593 }
594 594
595 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 595 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
596 "SHORTEN_ZONEKEY", 596 "SHORTEN_ZONEKEY",
597 &shorten_keyfile)) 597 &shorten_keyfile))
@@ -603,7 +603,7 @@ do_check (void *cls,
603 GNUNET_free (shorten_keyfile); 603 GNUNET_free (shorten_keyfile);
604 return; 604 return;
605 } 605 }
606 606
607 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 607 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
608 "PRIVATE_ZONEKEY", 608 "PRIVATE_ZONEKEY",
609 &private_keyfile)) 609 &private_keyfile))
@@ -621,7 +621,7 @@ do_check (void *cls,
621 short_key = GNUNET_CRYPTO_ecc_key_create_from_file (shorten_keyfile); 621 short_key = GNUNET_CRYPTO_ecc_key_create_from_file (shorten_keyfile);
622 bob_key = GNUNET_CRYPTO_ecc_key_create (); 622 bob_key = GNUNET_CRYPTO_ecc_key_create ();
623 alice_key = GNUNET_CRYPTO_ecc_key_create (); 623 alice_key = GNUNET_CRYPTO_ecc_key_create ();
624 624
625 GNUNET_free (our_keyfile); 625 GNUNET_free (our_keyfile);
626 GNUNET_free (shorten_keyfile); 626 GNUNET_free (shorten_keyfile);
627 GNUNET_free (private_keyfile); 627 GNUNET_free (private_keyfile);
@@ -636,7 +636,7 @@ do_check (void *cls,
636 GNUNET_CRYPTO_short_hash (&our_pkey, sizeof(our_pkey), &our_zone); 636 GNUNET_CRYPTO_short_hash (&our_pkey, sizeof(our_pkey), &our_zone);
637 GNUNET_CRYPTO_short_hash (&priv_pkey, sizeof(priv_pkey), &priv_zone); 637 GNUNET_CRYPTO_short_hash (&priv_pkey, sizeof(priv_pkey), &priv_zone);
638 GNUNET_CRYPTO_short_hash (&short_pkey, sizeof(short_pkey), &short_zone); 638 GNUNET_CRYPTO_short_hash (&short_pkey, sizeof(short_pkey), &short_zone);
639 639
640 rd.expiration_time = UINT64_MAX; 640 rd.expiration_time = UINT64_MAX;
641 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); 641 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
642 rd.data = &priv_zone; 642 rd.data = &priv_zone;
diff --git a/src/gns/test_gns_revocation.c b/src/gns/test_gns_revocation.c
index 459a40c97..30fe5eb66 100644
--- a/src/gns/test_gns_revocation.c
+++ b/src/gns/test_gns_revocation.c
@@ -92,7 +92,7 @@ end_badly_now ()
92} 92}
93 93
94 94
95static void 95static void
96shutdown_task (void *cls, 96shutdown_task (void *cls,
97 const struct GNUNET_SCHEDULER_TaskContext *tc) 97 const struct GNUNET_SCHEDULER_TaskContext *tc)
98{ 98{
@@ -109,7 +109,7 @@ on_lookup_result(void *cls, uint32_t rd_count,
109 struct in_addr a; 109 struct in_addr a;
110 int i; 110 int i;
111 char* addr; 111 char* addr;
112 112
113 if (GNUNET_SCHEDULER_NO_TASK != die_task) 113 if (GNUNET_SCHEDULER_NO_TASK != die_task)
114 { 114 {
115 GNUNET_SCHEDULER_cancel (die_task); 115 GNUNET_SCHEDULER_cancel (die_task);
@@ -221,7 +221,7 @@ do_check (void *cls,
221 struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); 221 struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr));
222 rd.expiration_time = UINT64_MAX; 222 rd.expiration_time = UINT64_MAX;
223 GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); 223 GNUNET_assert(1 == inet_pton (AF_INET, ip, web));
224 224
225 GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); 225 GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
226 226
227 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); 227 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
diff --git a/src/gns/test_gns_simple_shorten.c b/src/gns/test_gns_simple_shorten.c
index 8cab0dbb2..1b383a0bd 100644
--- a/src/gns/test_gns_simple_shorten.c
+++ b/src/gns/test_gns_simple_shorten.c
@@ -135,7 +135,7 @@ process_shorten_result(void* cls, const char* sname)
135 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shorten test succeeded!\n"); 135 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shorten test succeeded!\n");
136 ok = 0; 136 ok = 0;
137 } 137 }
138 138
139 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); 139 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
140} 140}
141 141
@@ -205,7 +205,7 @@ void do_check (void *cls,
205 end_badly_now (); 205 end_badly_now ();
206 return; 206 return;
207 } 207 }
208 208
209 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 209 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
210 "SHORTEN_ZONEKEY", 210 "SHORTEN_ZONEKEY",
211 &shorten_keyfile)) 211 &shorten_keyfile))
@@ -215,7 +215,7 @@ void do_check (void *cls,
215 end_badly_now (); 215 end_badly_now ();
216 return; 216 return;
217 } 217 }
218 218
219 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 219 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
220 "PRIVATE_ZONEKEY", 220 "PRIVATE_ZONEKEY",
221 &private_keyfile)) 221 &private_keyfile))
@@ -236,7 +236,7 @@ void do_check (void *cls,
236 236
237 GNUNET_free(shorten_keyfile); 237 GNUNET_free(shorten_keyfile);
238 GNUNET_free(private_keyfile); 238 GNUNET_free(private_keyfile);
239 239
240 GNUNET_CRYPTO_ecc_key_get_public_for_signature (our_key, &our_pkey); 240 GNUNET_CRYPTO_ecc_key_get_public_for_signature (our_key, &our_pkey);
241 GNUNET_CRYPTO_ecc_key_get_public_for_signature (alice_key, &alice_pkey); 241 GNUNET_CRYPTO_ecc_key_get_public_for_signature (alice_key, &alice_pkey);
242 GNUNET_CRYPTO_ecc_key_get_public_for_signature (bob_key, &bob_pkey); 242 GNUNET_CRYPTO_ecc_key_get_public_for_signature (bob_key, &bob_pkey);
@@ -251,14 +251,14 @@ void do_check (void *cls,
251 struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); 251 struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr));
252 rd.expiration_time = UINT64_MAX; 252 rd.expiration_time = UINT64_MAX;
253 GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); 253 GNUNET_assert(1 == inet_pton (AF_INET, ip, web));
254 254
255 GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); 255 GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
256 256
257 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); 257 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
258 rd.data = &bob_hash; 258 rd.data = &bob_hash;
259 rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY; 259 rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY;
260 rd.flags = GNUNET_NAMESTORE_RF_NONE; 260 rd.flags = GNUNET_NAMESTORE_RF_NONE;
261 261
262 /* put bob into our zone */ 262 /* put bob into our zone */
263 GNUNET_NAMESTORE_record_put_by_authority (namestore_handle, 263 GNUNET_NAMESTORE_record_put_by_authority (namestore_handle,
264 our_key, 264 our_key,
@@ -267,7 +267,7 @@ void do_check (void *cls,
267 &rd, 267 &rd,
268 NULL, 268 NULL,
269 NULL); 269 NULL);
270 270
271 /* put alice into bobs zone */ 271 /* put alice into bobs zone */
272 GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash); 272 GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash);
273 rd.data = &alice_hash; 273 rd.data = &alice_hash;
@@ -305,7 +305,7 @@ void do_check (void *cls,
305 sig, 305 sig,
306 NULL, 306 NULL,
307 NULL); 307 NULL);
308 308
309 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); 309 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
310 rd.data = &alice_hash; 310 rd.data = &alice_hash;
311 rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY; 311 rd.record_type = GNUNET_NAMESTORE_TYPE_PKEY;
@@ -336,7 +336,7 @@ main (int argc, char *argv[])
336 "WARNING", 336 "WARNING",
337 NULL); 337 NULL);
338 GNUNET_TESTING_peer_run ("test-gns-simple-shorten", 338 GNUNET_TESTING_peer_run ("test-gns-simple-shorten",
339 "test_gns_simple_lookup.conf", 339 "test_gns_simple_lookup.conf",
340 &do_check, NULL); 340 &do_check, NULL);
341 return ok; 341 return ok;
342} 342}
diff --git a/src/gns/test_gns_simple_srv_lookup.c b/src/gns/test_gns_simple_srv_lookup.c
index 7efa57803..76e564f41 100644
--- a/src/gns/test_gns_simple_srv_lookup.c
+++ b/src/gns/test_gns_simple_srv_lookup.c
@@ -109,7 +109,7 @@ on_lookup_result(void *cls, uint32_t rd_count,
109 int i; 109 int i;
110 uint16_t *srv_data; 110 uint16_t *srv_data;
111 char* srv; 111 char* srv;
112 112
113 if (GNUNET_SCHEDULER_NO_TASK != die_task) 113 if (GNUNET_SCHEDULER_NO_TASK != die_task)
114 { 114 {
115 GNUNET_SCHEDULER_cancel (die_task); 115 GNUNET_SCHEDULER_cancel (die_task);
@@ -229,7 +229,7 @@ do_check (void *cls,
229 229
230 rd.expiration_time = UINT64_MAX; 230 rd.expiration_time = UINT64_MAX;
231 GNUNET_assert(1 == inet_pton (AF_INET, ip, sipserver)); 231 GNUNET_assert(1 == inet_pton (AF_INET, ip, sipserver));
232 232
233 GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); 233 GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
234 234
235 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode); 235 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
@@ -262,7 +262,7 @@ do_check (void *cls,
262 NULL, 262 NULL,
263 NULL); 263 NULL);
264 GNUNET_free (sig); 264 GNUNET_free (sig);
265 265
266 rd.data_size = sizeof (struct GNUNET_TUN_DnsSrvRecord)+strlen(TEST_SRV_NAME)+1; 266 rd.data_size = sizeof (struct GNUNET_TUN_DnsSrvRecord)+strlen(TEST_SRV_NAME)+1;
267 srv_data->port = srv_port; 267 srv_data->port = srv_port;
268 srv_data->prio = srv_prio; 268 srv_data->prio = srv_prio;
diff --git a/src/gns/test_gns_simple_zkey_lookup.c b/src/gns/test_gns_simple_zkey_lookup.c
index 798fa5b5d..52a550ebf 100644
--- a/src/gns/test_gns_simple_zkey_lookup.c
+++ b/src/gns/test_gns_simple_zkey_lookup.c
@@ -93,7 +93,7 @@ end_badly_now ()
93} 93}
94 94
95 95
96static void 96static void
97shutdown_task (void *cls, 97shutdown_task (void *cls,
98 const struct GNUNET_SCHEDULER_TaskContext *tc) 98 const struct GNUNET_SCHEDULER_TaskContext *tc)
99{ 99{
@@ -110,7 +110,7 @@ on_lookup_result(void *cls, uint32_t rd_count,
110 struct in_addr a; 110 struct in_addr a;
111 int i; 111 int i;
112 char* addr; 112 char* addr;
113 113
114 if (GNUNET_SCHEDULER_NO_TASK != die_task) 114 if (GNUNET_SCHEDULER_NO_TASK != die_task)
115 { 115 {
116 GNUNET_SCHEDULER_cancel (die_task); 116 GNUNET_SCHEDULER_cancel (die_task);
@@ -150,7 +150,7 @@ on_lookup_result(void *cls, uint32_t rd_count,
150 } 150 }
151 } 151 }
152 } 152 }
153 153
154 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); 154 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
155} 155}
156 156
@@ -165,7 +165,7 @@ commence_testing (void *cls, int32_t success, const char *emsg)
165 char name[GNUNET_DNSPARSER_MAX_NAME_LENGTH]; 165 char name[GNUNET_DNSPARSER_MAX_NAME_LENGTH];
166 char* pos; 166 char* pos;
167 struct GNUNET_CRYPTO_ShortHashAsciiEncoded hash_str; 167 struct GNUNET_CRYPTO_ShortHashAsciiEncoded hash_str;
168 168
169 gns_handle = GNUNET_GNS_connect(cfg); 169 gns_handle = GNUNET_GNS_connect(cfg);
170 if (NULL == gns_handle) 170 if (NULL == gns_handle)
171 { 171 {
@@ -286,8 +286,8 @@ main (int argc, char *argv[])
286 GNUNET_log_setup ("test-gns-simple-zkey-lookup", 286 GNUNET_log_setup ("test-gns-simple-zkey-lookup",
287 "WARNING", 287 "WARNING",
288 NULL); 288 NULL);
289 GNUNET_TESTING_peer_run ("test-gns-simple-zkey-lookup", 289 GNUNET_TESTING_peer_run ("test-gns-simple-zkey-lookup",
290 "test_gns_simple_lookup.conf", 290 "test_gns_simple_lookup.conf",
291 &do_check, NULL); 291 &do_check, NULL);
292 return ok; 292 return ok;
293} 293}
diff --git a/src/gns/w32nsp-install.c b/src/gns/w32nsp-install.c
index dcdd16a86..5c2ccf23e 100644
--- a/src/gns/w32nsp-install.c
+++ b/src/gns/w32nsp-install.c
@@ -1,81 +1,81 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2012 Christian Grothoff (and other contributing authors) 3 (C) 2012 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20/** 20/**
21 * @file gns/w32nsp-install.c 21 * @file gns/w32nsp-install.c
22 * @brief W32 integration installer for GNS 22 * @brief W32 integration installer for GNS
23 * @author LRN 23 * @author LRN
24 */ 24 */
25 25
26#define INITGUID 26#define INITGUID
27#include <windows.h> 27#include <windows.h>
28#include <nspapi.h> 28#include <nspapi.h>
29#include <ws2spi.h> 29#include <ws2spi.h>
30#include "gnunet_w32nsp_lib.h" 30#include "gnunet_w32nsp_lib.h"
31#include <stdio.h> 31#include <stdio.h>
32 32
33int 33int
34main (int argc, char **argv) 34main (int argc, char **argv)
35{ 35{
36 int ret; 36 int ret;
37 int r = 1; 37 int r = 1;
38 WSADATA wsd; 38 WSADATA wsd;
39 GUID id = GNUNET_NAMESPACE_PROVIDER_DNS; 39 GUID id = GNUNET_NAMESPACE_PROVIDER_DNS;
40 wchar_t *cmdl; 40 wchar_t *cmdl;
41 int wargc; 41 int wargc;
42 wchar_t **wargv; 42 wchar_t **wargv;
43 43
44 if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) 44 if (WSAStartup(MAKEWORD(2,2), &wsd) != 0)
45 { 45 {
46 fprintf (stderr, "WSAStartup() failed: %lu\n", GetLastError()); 46 fprintf (stderr, "WSAStartup() failed: %lu\n", GetLastError());
47 return 5; 47 return 5;
48 } 48 }
49 49
50 cmdl = GetCommandLineW (); 50 cmdl = GetCommandLineW ();
51 if (cmdl == NULL) 51 if (cmdl == NULL)
52 { 52 {
53 WSACleanup(); 53 WSACleanup();
54 return 2; 54 return 2;
55 } 55 }
56 wargv = CommandLineToArgvW (cmdl, &wargc); 56 wargv = CommandLineToArgvW (cmdl, &wargc);
57 if (wargv == NULL) 57 if (wargv == NULL)
58 { 58 {
59 WSACleanup(); 59 WSACleanup();
60 return 3; 60 return 3;
61 } 61 }
62 r = 4; 62 r = 4;
63 63
64 if (wargc == 2) 64 if (wargc == 2)
65 { 65 {
66 ret = WSCInstallNameSpace (L"GNUnet DNS provider", wargv[1], NS_DNS, 1, &id); 66 ret = WSCInstallNameSpace (L"GNUnet DNS provider", wargv[1], NS_DNS, 1, &id);
67 if (ret == NO_ERROR) 67 if (ret == NO_ERROR)
68 { 68 {
69 r = 0; 69 r = 0;
70 } 70 }
71 else 71 else
72 { 72 {
73 r = 1; 73 r = 1;
74 fprintf (stderr, 74 fprintf (stderr,
75 "WSCInstallNameSpace(L\"GNUnet DNS provider\", \"%S\", %d, 0, %p) failed: %lu\n", 75 "WSCInstallNameSpace(L\"GNUnet DNS provider\", \"%S\", %d, 0, %p) failed: %lu\n",
76 wargv[1], NS_DNS, &id, GetLastError ()); 76 wargv[1], NS_DNS, &id, GetLastError ());
77 } 77 }
78 } 78 }
79 WSACleanup(); 79 WSACleanup();
80 return r; 80 return r;
81} 81}
diff --git a/src/gns/w32nsp-resolve.c b/src/gns/w32nsp-resolve.c
index 8e08d0717..2bbe45021 100644
--- a/src/gns/w32nsp-resolve.c
+++ b/src/gns/w32nsp-resolve.c
@@ -34,7 +34,7 @@
34typedef int (WSPAPI *LPNSPSTARTUP) (LPGUID lpProviderId, LPNSP_ROUTINE lpnspRoutines); 34typedef int (WSPAPI *LPNSPSTARTUP) (LPGUID lpProviderId, LPNSP_ROUTINE lpnspRoutines);
35 35
36GUID host = {0x0002a800,0,0,{ 0xC0,0,0,0,0,0,0,0x46 }}; 36GUID host = {0x0002a800,0,0,{ 0xC0,0,0,0,0,0,0,0x46 }};
37GUID ip4 = {0x00090035,0,1,{ 0xc0,0,0,0,0,0,0,0x046}}; 37GUID ip4 = {0x00090035,0,1,{ 0xc0,0,0,0,0,0,0,0x046}};
38GUID ip6 = {0x00090035,0,0x001c, { 0xc0,0,0,0,0,0,0,0x046}}; 38GUID ip6 = {0x00090035,0,0x001c, { 0xc0,0,0,0,0,0,0,0x046}};
39 39
40DEFINE_GUID(W32_DNS, 0x22059D40, 0x7E9E, 0x11CF, 0xAE, 0x5A, 0x00, 0xAA, 0x00, 0xA7, 0x11, 0x2B); 40DEFINE_GUID(W32_DNS, 0x22059D40, 0x7E9E, 0x11CF, 0xAE, 0x5A, 0x00, 0xAA, 0x00, 0xA7, 0x11, 0x2B);
@@ -57,7 +57,7 @@ DEFINE_GUID(SVCID_INET_HOSTADDRBYNAME, 0x0002a803, 0x0000, 0x0000, 0xc0, 0x00, 0
57// to convert structures returned as BLOBs. 57// to convert structures returned as BLOBs.
58// 58//
59 59
60VOID 60VOID
61FixList(PCHAR ** List, PCHAR Base) 61FixList(PCHAR ** List, PCHAR Base)
62{ 62{
63 if(*List) 63 if(*List)
@@ -78,7 +78,7 @@ FixList(PCHAR ** List, PCHAR Base)
78// Routine to convert a hostent returned in a BLOB to one with 78// Routine to convert a hostent returned in a BLOB to one with
79// usable pointers. The structure is converted in-place. 79// usable pointers. The structure is converted in-place.
80// 80//
81VOID 81VOID
82UnpackHostEnt(struct hostent * hostent) 82UnpackHostEnt(struct hostent * hostent)
83{ 83{
84 PCHAR pch; 84 PCHAR pch;
@@ -210,7 +210,7 @@ main (int argc, char **argv)
210 if (wargc == 5) 210 if (wargc == 5)
211 { 211 {
212 HMODULE nsp; 212 HMODULE nsp;
213 213
214 nsp = LoadLibraryW (wargv[3]); 214 nsp = LoadLibraryW (wargv[3]);
215 if (nsp == NULL) 215 if (nsp == NULL)
216 { 216 {
diff --git a/src/gns/w32nsp-uninstall.c b/src/gns/w32nsp-uninstall.c
index bb8db668b..ac5aafe2d 100644
--- a/src/gns/w32nsp-uninstall.c
+++ b/src/gns/w32nsp-uninstall.c
@@ -1,30 +1,30 @@
1#define INITGUID 1#define INITGUID
2#include <windows.h> 2#include <windows.h>
3#include <nspapi.h> 3#include <nspapi.h>
4#include <ws2spi.h> 4#include <ws2spi.h>
5#include "gnunet_w32nsp_lib.h" 5#include "gnunet_w32nsp_lib.h"
6#include <stdio.h> 6#include <stdio.h>
7 7
8int 8int
9main (int argc, char **argv) 9main (int argc, char **argv)
10{ 10{
11 int ret; 11 int ret;
12 GUID id = GNUNET_NAMESPACE_PROVIDER_DNS; 12 GUID id = GNUNET_NAMESPACE_PROVIDER_DNS;
13 WSADATA wsd; 13 WSADATA wsd;
14 14
15 if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) 15 if (WSAStartup(MAKEWORD(2,2), &wsd) != 0)
16 { 16 {
17 fprintf (stderr, "WSAStartup() failed: %lu\n", GetLastError()); 17 fprintf (stderr, "WSAStartup() failed: %lu\n", GetLastError());
18 return 5; 18 return 5;
19 } 19 }
20 20
21 ret = WSCUnInstallNameSpace (&id); 21 ret = WSCUnInstallNameSpace (&id);
22 if (ret == NO_ERROR) 22 if (ret == NO_ERROR)
23 { 23 {
24 WSACleanup (); 24 WSACleanup ();
25 return 0; 25 return 0;
26 } 26 }
27 fprintf (stderr, "WSCUnInstallNameSpace() failed: %lu\n", GetLastError ()); 27 fprintf (stderr, "WSCUnInstallNameSpace() failed: %lu\n", GetLastError ());
28 WSACleanup (); 28 WSACleanup ();
29 return 1; 29 return 1;
30} \ No newline at end of file 30} \ No newline at end of file