aboutsummaryrefslogtreecommitdiff
path: root/src/vpn/gnunet-service-dns.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/vpn/gnunet-service-dns.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/vpn/gnunet-service-dns.c')
-rw-r--r--src/vpn/gnunet-service-dns.c174
1 files changed, 78 insertions, 96 deletions
diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c
index 9959e9564..a267cab0d 100644
--- a/src/vpn/gnunet-service-dns.c
+++ b/src/vpn/gnunet-service-dns.c
@@ -146,11 +146,10 @@ hijack (void *cls
146 146
147 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hijacking, port is %d\n", dnsoutport); 147 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hijacking, port is %d\n", dnsoutport);
148 snprintf (port_s, 6, "%d", dnsoutport); 148 snprintf (port_s, 6, "%d", dnsoutport);
149 if (NULL != (proc = GNUNET_OS_start_process (NULL, 149 if (NULL !=
150 NULL, 150 (proc =
151 "gnunet-helper-hijack-dns", 151 GNUNET_OS_start_process (NULL, NULL, "gnunet-helper-hijack-dns",
152 "gnunet-hijack-dns", 152 "gnunet-hijack-dns", port_s, virt_dns, NULL)))
153 port_s, virt_dns, NULL)))
154 GNUNET_OS_process_close (proc); 153 GNUNET_OS_process_close (proc);
155 GNUNET_free (virt_dns); 154 GNUNET_free (virt_dns);
156} 155}
@@ -175,11 +174,11 @@ unhijack (unsigned short port)
175 174
176 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "unHijacking, port is %d\n", port); 175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "unHijacking, port is %d\n", port);
177 snprintf (port_s, 6, "%d", port); 176 snprintf (port_s, 6, "%d", port);
178 if (NULL != (proc = GNUNET_OS_start_process (NULL, 177 if (NULL !=
179 NULL, 178 (proc =
180 "gnunet-helper-hijack-dns", 179 GNUNET_OS_start_process (NULL, NULL, "gnunet-helper-hijack-dns",
181 "gnunet-hijack-dns", 180 "gnunet-hijack-dns", "-d", port_s, virt_dns,
182 "-d", port_s, virt_dns, NULL))) 181 NULL)))
183 GNUNET_OS_process_close (proc); 182 GNUNET_OS_process_close (proc);
184 GNUNET_free (virt_dns); 183 GNUNET_free (virt_dns);
185} 184}
@@ -204,8 +203,7 @@ send_answer (void *cls, size_t size, void *buf)
204 203
205 /* When more data is to be sent, reschedule */ 204 /* When more data is to be sent, reschedule */
206 if (head != NULL) 205 if (head != NULL)
207 GNUNET_SERVER_notify_transmit_ready (cls, 206 GNUNET_SERVER_notify_transmit_ready (cls, ntohs (head->pkt.hdr.size),
208 ntohs (head->pkt.hdr.size),
209 GNUNET_TIME_UNIT_FOREVER_REL, 207 GNUNET_TIME_UNIT_FOREVER_REL,
210 &send_answer, cls); 208 &send_answer, cls);
211 209
@@ -371,19 +369,20 @@ send_mesh_query (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
371 369
372 struct tunnel_cls *cls_ = (struct tunnel_cls *) cls; 370 struct tunnel_cls *cls_ = (struct tunnel_cls *) cls;
373 371
374 cls_->tunnel = GNUNET_MESH_peer_request_connect_by_type (mesh_handle, 372 cls_->tunnel =
375 GNUNET_TIME_UNIT_HOURS, 373 GNUNET_MESH_peer_request_connect_by_type (mesh_handle,
376 GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER, 374 GNUNET_TIME_UNIT_HOURS,
377 mesh_connect, 375 GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER,
378 NULL, cls_); 376 mesh_connect, NULL, cls_);
379 377
380 remote_pending[cls_->dns.s.id] = cls_; 378 remote_pending[cls_->dns.s.id] = cls_;
381} 379}
382 380
383static int 381static int
384receive_mesh_query (void *cls __attribute__ ((unused)), 382receive_mesh_query (void *cls
385 struct GNUNET_MESH_Tunnel *tunnel, 383 __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel,
386 void **ctx __attribute__ ((unused)), 384 void **ctx
385 __attribute__ ((unused)),
387 const struct GNUNET_PeerIdentity *sender 386 const struct GNUNET_PeerIdentity *sender
388 __attribute__ ((unused)), 387 __attribute__ ((unused)),
389 const struct GNUNET_MessageHeader *message, 388 const struct GNUNET_MessageHeader *message,
@@ -404,8 +403,7 @@ receive_mesh_query (void *cls __attribute__ ((unused)),
404 query_states[dns->s.id].tunnel = tunnel; 403 query_states[dns->s.id].tunnel = tunnel;
405 query_states[dns->s.id].valid = GNUNET_YES; 404 query_states[dns->s.id].valid = GNUNET_YES;
406 405
407 GNUNET_NETWORK_socket_sendto (dnsout, 406 GNUNET_NETWORK_socket_sendto (dnsout, dns,
408 dns,
409 ntohs (message->size) - 407 ntohs (message->size) -
410 sizeof (struct GNUNET_MessageHeader), 408 sizeof (struct GNUNET_MessageHeader),
411 (struct sockaddr *) &dest, sizeof dest); 409 (struct sockaddr *) &dest, sizeof dest);
@@ -414,9 +412,10 @@ receive_mesh_query (void *cls __attribute__ ((unused)),
414} 412}
415 413
416static int 414static int
417receive_mesh_answer (void *cls __attribute__ ((unused)), 415receive_mesh_answer (void *cls
418 struct GNUNET_MESH_Tunnel *tunnel, 416 __attribute__ ((unused)),
419 void **ctx __attribute__ ((unused)), 417 struct GNUNET_MESH_Tunnel *tunnel, void **ctx
418 __attribute__ ((unused)),
420 const struct GNUNET_PeerIdentity *sender, 419 const struct GNUNET_PeerIdentity *sender,
421 const struct GNUNET_MessageHeader *message, 420 const struct GNUNET_MessageHeader *message,
422 const struct GNUNET_TRANSPORT_ATS_Information *atsi 421 const struct GNUNET_TRANSPORT_ATS_Information *atsi
@@ -426,8 +425,8 @@ receive_mesh_answer (void *cls __attribute__ ((unused)),
426 struct dns_pkt *dns = (struct dns_pkt *) (message + 1); 425 struct dns_pkt *dns = (struct dns_pkt *) (message + 1);
427 426
428 /* They sent us a packet we were not waiting for */ 427 /* They sent us a packet we were not waiting for */
429 if (remote_pending[dns->s.id] == NULL 428 if (remote_pending[dns->s.id] == NULL ||
430 || remote_pending[dns->s.id]->tunnel != tunnel) 429 remote_pending[dns->s.id]->tunnel != tunnel)
431 return GNUNET_OK; 430 return GNUNET_OK;
432 431
433 GNUNET_free (remote_pending[dns->s.id]); 432 GNUNET_free (remote_pending[dns->s.id]);
@@ -526,8 +525,7 @@ receive_mesh_answer (void *cls __attribute__ ((unused)),
526 525
527 GNUNET_CONTAINER_DLL_insert_after (head, tail, tail, answer); 526 GNUNET_CONTAINER_DLL_insert_after (head, tail, tail, answer);
528 527
529 GNUNET_SERVER_notify_transmit_ready (query_states[dns->s.id].client, 528 GNUNET_SERVER_notify_transmit_ready (query_states[dns->s.id].client, len,
530 len,
531 GNUNET_TIME_UNIT_FOREVER_REL, 529 GNUNET_TIME_UNIT_FOREVER_REL,
532 &send_answer, 530 &send_answer,
533 query_states[dns->s.id].client); 531 query_states[dns->s.id].client);
@@ -561,8 +559,8 @@ send_rev_query (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
561 559
562 size_t len = sizeof (struct answer_packet) - 1 + sizeof (struct dns_static) + 74 /* this is the length of a reverse ipv6-lookup */ 560 size_t len = sizeof (struct answer_packet) - 1 + sizeof (struct dns_static) + 74 /* this is the length of a reverse ipv6-lookup */
563 + sizeof (struct dns_query_line) + 2 /* To hold the pointer (as defined in RFC1035) to the name */ 561 + sizeof (struct dns_query_line) + 2 /* To hold the pointer (as defined in RFC1035) to the name */
564 + sizeof (struct dns_record_line) - 1 562 + sizeof (struct dns_record_line) - 1 -
565 - 2 /* We do not know the lenght of the answer yet */ ; 563 2 /* We do not know the lenght of the answer yet */ ;
566 564
567 struct answer_packet_list *answer = 565 struct answer_packet_list *answer =
568 GNUNET_malloc (len + 2 * sizeof (struct answer_packet_list *)); 566 GNUNET_malloc (len + 2 * sizeof (struct answer_packet_list *));
@@ -619,8 +617,7 @@ send_rev_query (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
619 617
620 GNUNET_CONTAINER_DLL_insert_after (head, tail, tail, answer); 618 GNUNET_CONTAINER_DLL_insert_after (head, tail, tail, answer);
621 619
622 GNUNET_SERVER_notify_transmit_ready (query_states[id].client, 620 GNUNET_SERVER_notify_transmit_ready (query_states[id].client, len,
623 len,
624 GNUNET_TIME_UNIT_FOREVER_REL, 621 GNUNET_TIME_UNIT_FOREVER_REL,
625 &send_answer, query_states[id].client); 622 &send_answer, query_states[id].client);
626} 623}
@@ -629,9 +626,9 @@ send_rev_query (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
629 * Receive a block from the dht. 626 * Receive a block from the dht.
630 */ 627 */
631static void 628static void
632receive_dht (void *cls, 629receive_dht (void *cls, struct GNUNET_TIME_Absolute exp
633 struct GNUNET_TIME_Absolute exp __attribute__ ((unused)), 630 __attribute__ ((unused)), const GNUNET_HashCode * key
634 const GNUNET_HashCode * key __attribute__ ((unused)), 631 __attribute__ ((unused)),
635 const struct GNUNET_PeerIdentity *const *get_path 632 const struct GNUNET_PeerIdentity *const *get_path
636 __attribute__ ((unused)), 633 __attribute__ ((unused)),
637 const struct GNUNET_PeerIdentity *const *put_path 634 const struct GNUNET_PeerIdentity *const *put_path
@@ -654,8 +651,7 @@ receive_dht (void *cls,
654 const struct GNUNET_DNS_Record *rec = data; 651 const struct GNUNET_DNS_Record *rec = data;
655 652
656 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 653 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
657 "Got block of size %d, peer: %08x, desc: %08x\n", 654 "Got block of size %d, peer: %08x, desc: %08x\n", size,
658 size,
659 *((unsigned int *) &rec->peer), 655 *((unsigned int *) &rec->peer),
660 *((unsigned int *) &rec->service_descriptor)); 656 *((unsigned int *) &rec->service_descriptor));
661 657
@@ -676,8 +672,8 @@ receive_dht (void *cls,
676 672
677 memcpy (&answer->pkt.service_descr.service_descriptor, 673 memcpy (&answer->pkt.service_descr.service_descriptor,
678 &rec->service_descriptor, sizeof (GNUNET_HashCode)); 674 &rec->service_descriptor, sizeof (GNUNET_HashCode));
679 memcpy (&answer->pkt.service_descr.service_type, 675 memcpy (&answer->pkt.service_descr.service_type, &rec->service_type,
680 &rec->service_type, sizeof (answer->pkt.service_descr.service_type)); 676 sizeof (answer->pkt.service_descr.service_type));
681 memcpy (&answer->pkt.service_descr.ports, &rec->ports, 677 memcpy (&answer->pkt.service_descr.ports, &rec->ports,
682 sizeof (answer->pkt.service_descr.ports)); 678 sizeof (answer->pkt.service_descr.ports));
683 679
@@ -730,8 +726,7 @@ receive_dht (void *cls,
730 726
731 GNUNET_CONTAINER_DLL_insert_after (head, tail, tail, answer); 727 GNUNET_CONTAINER_DLL_insert_after (head, tail, tail, answer);
732 728
733 GNUNET_SERVER_notify_transmit_ready (query_states[id].client, 729 GNUNET_SERVER_notify_transmit_ready (query_states[id].client, len,
734 len,
735 GNUNET_TIME_UNIT_FOREVER_REL, 730 GNUNET_TIME_UNIT_FOREVER_REL,
736 &send_answer, query_states[id].client); 731 &send_answer, query_states[id].client);
737 732
@@ -742,8 +737,8 @@ receive_dht (void *cls,
742 * This receives a GNUNET_MESSAGE_TYPE_REHIJACK and rehijacks the DNS 737 * This receives a GNUNET_MESSAGE_TYPE_REHIJACK and rehijacks the DNS
743 */ 738 */
744static void 739static void
745rehijack (void *cls __attribute__ ((unused)), 740rehijack (void *cls
746 struct GNUNET_SERVER_Client *client, 741 __attribute__ ((unused)), struct GNUNET_SERVER_Client *client,
747 const struct GNUNET_MessageHeader *message __attribute__ ((unused))) 742 const struct GNUNET_MessageHeader *message __attribute__ ((unused)))
748{ 743{
749 unhijack (dnsoutport); 744 unhijack (dnsoutport);
@@ -756,8 +751,8 @@ rehijack (void *cls __attribute__ ((unused)),
756 * This receives the dns-payload from the daemon-vpn and sends it on over the udp-socket 751 * This receives the dns-payload from the daemon-vpn and sends it on over the udp-socket
757 */ 752 */
758static void 753static void
759receive_query (void *cls __attribute__ ((unused)), 754receive_query (void *cls
760 struct GNUNET_SERVER_Client *client, 755 __attribute__ ((unused)), struct GNUNET_SERVER_Client *client,
761 const struct GNUNET_MessageHeader *message) 756 const struct GNUNET_MessageHeader *message)
762{ 757{
763 struct query_packet *pkt = (struct query_packet *) message; 758 struct query_packet *pkt = (struct query_packet *) message;
@@ -788,21 +783,18 @@ receive_query (void *cls __attribute__ ((unused)),
788 GNUNET_CRYPTO_hash (pdns->queries[0]->name, pdns->queries[0]->namelen, 783 GNUNET_CRYPTO_hash (pdns->queries[0]->name, pdns->queries[0]->namelen,
789 &key); 784 &key);
790 785
791 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 786 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting with key %08x, len is %d\n",
792 "Getting with key %08x, len is %d\n",
793 *((unsigned int *) &key), pdns->queries[0]->namelen); 787 *((unsigned int *) &key), pdns->queries[0]->namelen);
794 788
795 struct receive_dht_cls *cls = 789 struct receive_dht_cls *cls =
796 GNUNET_malloc (sizeof (struct receive_dht_cls)); 790 GNUNET_malloc (sizeof (struct receive_dht_cls));
797 cls->id = dns->s.id; 791 cls->id = dns->s.id;
798 792
799 cls->handle = GNUNET_DHT_get_start (dht, 793 cls->handle =
800 GNUNET_TIME_UNIT_MINUTES, 794 GNUNET_DHT_get_start (dht, GNUNET_TIME_UNIT_MINUTES,
801 GNUNET_BLOCK_TYPE_DNS, 795 GNUNET_BLOCK_TYPE_DNS, &key,
802 &key, 796 DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL,
803 DEFAULT_GET_REPLICATION, 797 0, NULL, 0, receive_dht, cls);
804 GNUNET_DHT_RO_NONE,
805 NULL, 0, NULL, 0, receive_dht, cls);
806 798
807 goto outfree; 799 goto outfree;
808 } 800 }
@@ -881,8 +873,8 @@ receive_query (void *cls __attribute__ ((unused)),
881 873
882 if (1 != inet_pton (AF_INET, virt_dns, &virt_dns_bytes)) 874 if (1 != inet_pton (AF_INET, virt_dns, &virt_dns_bytes))
883 { 875 {
884 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 876 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error parsing 'VIRTDNS': %s; %m!\n",
885 "Error parsing 'VIRTDNS': %s; %m!\n", virt_dns); 877 virt_dns);
886 exit (1); 878 exit (1);
887 } 879 }
888 880
@@ -923,8 +915,7 @@ receive_query (void *cls __attribute__ ((unused)),
923 dest.sin_port = htons (53); 915 dest.sin_port = htons (53);
924 dest.sin_addr.s_addr = pkt->orig_to; 916 dest.sin_addr.s_addr = pkt->orig_to;
925 917
926 GNUNET_NETWORK_socket_sendto (dnsout, 918 GNUNET_NETWORK_socket_sendto (dnsout, dns,
927 dns,
928 ntohs (pkt->hdr.size) - 919 ntohs (pkt->hdr.size) -
929 sizeof (struct query_packet) + 1, 920 sizeof (struct query_packet) + 1,
930 (struct sockaddr *) &dest, sizeof dest); 921 (struct sockaddr *) &dest, sizeof dest);
@@ -963,8 +954,9 @@ open_port ()
963 /* Read the port we bound to */ 954 /* Read the port we bound to */
964 socklen_t addrlen = sizeof (struct sockaddr_in); 955 socklen_t addrlen = sizeof (struct sockaddr_in);
965 956
966 err = getsockname (GNUNET_NETWORK_get_fd (dnsout), 957 err =
967 (struct sockaddr *) &addr, &addrlen); 958 getsockname (GNUNET_NETWORK_get_fd (dnsout), (struct sockaddr *) &addr,
959 &addrlen);
968 960
969 dnsoutport = htons (addr.sin_port); 961 dnsoutport = htons (addr.sin_port);
970 962
@@ -1010,9 +1002,7 @@ read_response (void *cls
1010 unsigned char buf[len]; 1002 unsigned char buf[len];
1011 struct dns_pkt *dns = (struct dns_pkt *) buf; 1003 struct dns_pkt *dns = (struct dns_pkt *) buf;
1012 1004
1013 r = GNUNET_NETWORK_socket_recvfrom (dnsout, 1005 r = GNUNET_NETWORK_socket_recvfrom (dnsout, buf, sizeof (buf),
1014 buf,
1015 sizeof (buf),
1016 (struct sockaddr *) &addr, &addrlen); 1006 (struct sockaddr *) &addr, &addrlen);
1017 1007
1018 if (r < 0) 1008 if (r < 0)
@@ -1093,16 +1083,15 @@ read_response (void *cls
1093 1083
1094 GNUNET_CONTAINER_DLL_insert_after (head, tail, tail, answer); 1084 GNUNET_CONTAINER_DLL_insert_after (head, tail, tail, answer);
1095 1085
1096 GNUNET_SERVER_notify_transmit_ready (query_states 1086 GNUNET_SERVER_notify_transmit_ready (query_states[dns->s.id].client,
1097 [dns->s.id].client, len, 1087 len, GNUNET_TIME_UNIT_FOREVER_REL,
1098 GNUNET_TIME_UNIT_FOREVER_REL,
1099 &send_answer, 1088 &send_answer,
1100 query_states[dns->s.id].client); 1089 query_states[dns->s.id].client);
1101 } 1090 }
1102 } 1091 }
1103 } 1092 }
1104 GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, 1093 GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, dnsout,
1105 dnsout, &read_response, NULL); 1094 &read_response, NULL);
1106} 1095}
1107 1096
1108 1097
@@ -1113,7 +1102,8 @@ read_response (void *cls
1113 * @param tc unused 1102 * @param tc unused
1114 */ 1103 */
1115static void 1104static void
1116cleanup_task (void *cls __attribute__ ((unused)), 1105cleanup_task (void *cls
1106 __attribute__ ((unused)),
1117 const struct GNUNET_SCHEDULER_TaskContext *tc) 1107 const struct GNUNET_SCHEDULER_TaskContext *tc)
1118{ 1108{
1119 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)); 1109 GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN));
@@ -1236,23 +1226,18 @@ publish_name (const char *name, uint64_t ports, uint32_t service_type,
1236 (GNUNET_TIME_UNIT_HOURS, 2)); 1226 (GNUNET_TIME_UNIT_HOURS, 2));
1237 1227
1238 /* Sign the block */ 1228 /* Sign the block */
1239 if (GNUNET_OK != GNUNET_CRYPTO_rsa_sign (my_private_key, 1229 if (GNUNET_OK !=
1240 &data.purpose, &data.signature)) 1230 GNUNET_CRYPTO_rsa_sign (my_private_key, &data.purpose, &data.signature))
1241 { 1231 {
1242 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not sign DNS_Record\n"); 1232 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not sign DNS_Record\n");
1243 return; 1233 return;
1244 } 1234 }
1245 1235
1246 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1236 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Putting with key %08x, size = %d\n",
1247 "Putting with key %08x, size = %d\n",
1248 *((unsigned int *) &data.service_descriptor), size); 1237 *((unsigned int *) &data.service_descriptor), size);
1249 1238
1250 GNUNET_DHT_put (dht, 1239 GNUNET_DHT_put (dht, &data.service_descriptor, DEFAULT_PUT_REPLICATION,
1251 &data.service_descriptor, 1240 GNUNET_DHT_RO_NONE, GNUNET_BLOCK_TYPE_DNS, size,
1252 DEFAULT_PUT_REPLICATION,
1253 GNUNET_DHT_RO_NONE,
1254 GNUNET_BLOCK_TYPE_DNS,
1255 size,
1256 (char *) &data, 1241 (char *) &data,
1257 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS), 1242 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS),
1258 GNUNET_TIME_UNIT_MINUTES, NULL, NULL); 1243 GNUNET_TIME_UNIT_MINUTES, NULL, NULL);
@@ -1276,14 +1261,14 @@ publish_iterate (void *cls __attribute__ ((unused)), const char *section)
1276 char *udp_redirects, *tcp_redirects, *alternative_names, *alternative_name, 1261 char *udp_redirects, *tcp_redirects, *alternative_names, *alternative_name,
1277 *keyfile; 1262 *keyfile;
1278 1263
1279 GNUNET_CONFIGURATION_get_value_string (cfg, section, 1264 GNUNET_CONFIGURATION_get_value_string (cfg, section, "UDP_REDIRECTS",
1280 "UDP_REDIRECTS", &udp_redirects); 1265 &udp_redirects);
1281 GNUNET_CONFIGURATION_get_value_string (cfg, section, "TCP_REDIRECTS", 1266 GNUNET_CONFIGURATION_get_value_string (cfg, section, "TCP_REDIRECTS",
1282 &tcp_redirects); 1267 &tcp_redirects);
1283 1268
1284 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD", 1269 if (GNUNET_OK !=
1285 "HOSTKEY", 1270 GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD", "HOSTKEY",
1286 &keyfile)) 1271 &keyfile))
1287 { 1272 {
1288 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not read keyfile-value\n"); 1273 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not read keyfile-value\n");
1289 if (keyfile != NULL) 1274 if (keyfile != NULL)
@@ -1310,8 +1295,7 @@ publish_iterate (void *cls __attribute__ ((unused)), const char *section)
1310 1295
1311 publish_name (section, ports, service_type, my_private_key); 1296 publish_name (section, ports, service_type, my_private_key);
1312 1297
1313 GNUNET_CONFIGURATION_get_value_string (cfg, section, 1298 GNUNET_CONFIGURATION_get_value_string (cfg, section, "ALTERNATIVE_NAMES",
1314 "ALTERNATIVE_NAMES",
1315 &alternative_names); 1299 &alternative_names);
1316 for (alternative_name = strtok (alternative_names, " "); 1300 for (alternative_name = strtok (alternative_names, " ");
1317 alternative_name != NULL; alternative_name = strtok (NULL, " ")) 1301 alternative_name != NULL; alternative_name = strtok (NULL, " "))
@@ -1335,7 +1319,8 @@ publish_iterate (void *cls __attribute__ ((unused)), const char *section)
1335 * Publish a DNS-record in the DHT. 1319 * Publish a DNS-record in the DHT.
1336 */ 1320 */
1337static void 1321static void
1338publish_names (void *cls __attribute__ ((unused)), 1322publish_names (void *cls
1323 __attribute__ ((unused)),
1339 const struct GNUNET_SCHEDULER_TaskContext *tc) 1324 const struct GNUNET_SCHEDULER_TaskContext *tc)
1340{ 1325{
1341 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1326 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
@@ -1352,8 +1337,7 @@ publish_names (void *cls __attribute__ ((unused)),
1352 * @param cfg_ configuration to use 1337 * @param cfg_ configuration to use
1353 */ 1338 */
1354static void 1339static void
1355run (void *cls, 1340run (void *cls, struct GNUNET_SERVER_Handle *server,
1356 struct GNUNET_SERVER_Handle *server,
1357 const struct GNUNET_CONFIGURATION_Handle *cfg_) 1341 const struct GNUNET_CONFIGURATION_Handle *cfg_)
1358{ 1342{
1359 static const struct GNUNET_SERVER_MessageHandler handlers[] = { 1343 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
@@ -1401,8 +1385,8 @@ run (void *cls,
1401 GNUNET_SCHEDULER_add_now (publish_names, NULL); 1385 GNUNET_SCHEDULER_add_now (publish_names, NULL);
1402 1386
1403 GNUNET_SERVER_add_handlers (server, handlers); 1387 GNUNET_SERVER_add_handlers (server, handlers);
1404 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 1388 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task,
1405 &cleanup_task, cls); 1389 cls);
1406} 1390}
1407 1391
1408/** 1392/**
@@ -1416,8 +1400,6 @@ int
1416main (int argc, char *const *argv) 1400main (int argc, char *const *argv)
1417{ 1401{
1418 return (GNUNET_OK == 1402 return (GNUNET_OK ==
1419 GNUNET_SERVICE_run (argc, 1403 GNUNET_SERVICE_run (argc, argv, "dns", GNUNET_SERVICE_OPTION_NONE,
1420 argv, 1404 &run, NULL)) ? 0 : 1;
1421 "dns",
1422 GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1;
1423} 1405}