2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff
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
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
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
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file vpn/gnunet-daemon-vpn.c
24 * @author Philipp Toelke
27 #include "gnunet_getopt_lib.h"
28 #include "gnunet_program_lib.h"
29 #include "gnunet-vpn-packet.h"
30 #include "gnunet_common.h"
31 #include "gnunet_protocols.h"
32 #include <gnunet_mesh_service.h>
33 #include "gnunet_client_lib.h"
34 #include "gnunet_container_lib.h"
35 #include "gnunet_constants.h"
36 #include <block_dns.h>
37 #include "gnunet-daemon-vpn-helper.h"
38 #include "gnunet-daemon-vpn-dns.h"
39 #include "gnunet-daemon-vpn.h"
40 #include "gnunet-vpn-checksum.h"
42 const struct GNUNET_CONFIGURATION_Handle *cfg;
43 struct GNUNET_MESH_Handle *mesh_handle;
44 struct GNUNET_CONTAINER_MultiHashMap* hashmap;
45 static struct GNUNET_CONTAINER_Heap *heap;
48 * If there are at least this many address-mappings, old ones will be removed
50 static long long unsigned int max_mappings = 200;
58 * This hashmap contains the mapping from peer, service-descriptor,
59 * source-port and destination-port to a socket
61 static struct GNUNET_CONTAINER_MultiHashMap *udp_connections;
64 * Function scheduled as very last function, cleans up after us
68 cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) {
69 GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN));
72 cleanup_helper(helper_handle);
74 /* close the connection to the service-dns */
75 if (dns_connection != NULL)
77 GNUNET_CLIENT_disconnect (dns_connection, GNUNET_NO);
78 dns_connection = NULL;
81 if (mesh_handle != NULL)
83 GNUNET_MESH_disconnect(mesh_handle);
90 * @return the hash of the IP-Address if a mapping exists, NULL otherwise
93 address_mapping_exists(unsigned char addr[]) {
94 GNUNET_HashCode* key = GNUNET_malloc(sizeof(GNUNET_HashCode));
95 unsigned char* k = (unsigned char*)key;
96 memset(key, 0, sizeof(GNUNET_HashCode));
98 for (i = 0; i < 16; i++)
101 if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(hashmap, key))
111 collect_mappings(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tc) {
112 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
115 struct map_entry* me = GNUNET_CONTAINER_heap_remove_root(heap);
117 /* This is free()ed memory! */
118 me->heap_node = NULL;
120 /* FIXME! GNUNET_MESH_close_tunnel(me->tunnel); */
122 GNUNET_CONTAINER_multihashmap_remove(hashmap, &me->hash, me);
128 send_icmp_response(void* cls, const struct GNUNET_SCHEDULER_TaskContext *tc) {
129 struct ip6_icmp* request = cls;
131 struct ip6_icmp* response = alloca(ntohs(request->shdr.size));
132 GNUNET_assert(response != NULL);
133 memset(response, 0, ntohs(request->shdr.size));
135 response->shdr.size = request->shdr.size;
136 response->shdr.type = htons(GNUNET_MESSAGE_TYPE_VPN_HELPER);
138 response->tun.flags = 0;
139 response->tun.type = htons(0x86dd);
141 response->ip6_hdr.hoplmt = 255;
142 response->ip6_hdr.paylgth = request->ip6_hdr.paylgth;
143 response->ip6_hdr.nxthdr = 0x3a;
144 response->ip6_hdr.version = 6;
145 memcpy(&response->ip6_hdr.sadr, &request->ip6_hdr.dadr, 16);
146 memcpy(&response->ip6_hdr.dadr, &request->ip6_hdr.sadr, 16);
148 response->icmp_hdr.code = 0;
149 response->icmp_hdr.type = 0x81;
151 /* Magic, more Magic! */
152 response->icmp_hdr.chks = request->icmp_hdr.chks - 0x1;
154 /* Copy the rest of the packet */
155 memcpy(response+1, request+1, ntohs(request->shdr.size) - sizeof(struct ip6_icmp));
157 write_to_helper(response, ntohs(response->shdr.size));
159 GNUNET_free(request);
163 * cls is the pointer to a GNUNET_MessageHeader that is
164 * followed by the service-descriptor and the packet that should be sent;
167 send_pkt_to_peer_notify_callback (void *cls, size_t size, void *buf)
169 struct GNUNET_MESH_Tunnel **tunnel = cls;
170 struct GNUNET_MessageHeader *hdr =
171 (struct GNUNET_MessageHeader *) (tunnel + 1);
172 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "send_pkt_to_peer_notify_callback: buf = %x; size = %u;\n", buf, size);
173 GNUNET_assert (size >= ntohs (hdr->size));
174 memcpy (buf, hdr, ntohs (hdr->size));
175 size = ntohs(hdr->size);
177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent!\n");
182 port_in_ports (uint64_t ports, uint16_t port)
184 uint16_t *ps = (uint16_t *) & ports;
185 return ps[0] == port || ps[1] == port || ps[2] == port || ps[3] == port;
189 send_pkt_to_peer (void *cls,
190 const struct GNUNET_PeerIdentity *peer,
191 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
193 if (peer == NULL) return;
194 struct GNUNET_MESH_Tunnel **tunnel = cls;
195 struct GNUNET_MessageHeader *hdr =
196 (struct GNUNET_MessageHeader *) (tunnel + 1);
198 GNUNET_assert(NULL != tunnel);
199 GNUNET_assert(NULL != *tunnel);
201 GNUNET_MESH_notify_transmit_ready (*tunnel,
204 GNUNET_TIME_relative_divide(GNUNET_CONSTANTS_MAX_CORK_DELAY, 2),
205 (const struct GNUNET_PeerIdentity *)NULL,
207 send_pkt_to_peer_notify_callback,
212 * Create a new Address from an answer-packet
215 new_ip6addr(unsigned char* buf, const GNUNET_HashCode *peer, const GNUNET_HashCode *service_desc) { /* {{{ */
217 unsigned long long ipv6prefix;
218 GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "vpn", "IPV6ADDR", &ipv6addr));
219 GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "vpn", "IPV6PREFIX", &ipv6prefix));
220 GNUNET_assert(ipv6prefix < 127);
221 ipv6prefix = (ipv6prefix + 7)/8;
223 inet_pton (AF_INET6, ipv6addr, buf);
224 GNUNET_free(ipv6addr);
226 int peer_length = 16 - ipv6prefix - 6;
227 if (peer_length <= 0)
230 int service_length = 16 - ipv6prefix - peer_length;
231 if (service_length <= 0)
234 memcpy(buf+ipv6prefix, service_desc, service_length);
235 memcpy(buf+ipv6prefix+service_length, peer, peer_length);
242 return a > b ? a : b;
246 * Create a new Address from an answer-packet
249 new_ip6addr_remote (unsigned char *buf, unsigned char *addr, char addrlen)
252 unsigned long long ipv6prefix;
253 GNUNET_assert (GNUNET_OK ==
254 GNUNET_CONFIGURATION_get_value_string (cfg, "vpn",
257 GNUNET_assert (GNUNET_OK ==
258 GNUNET_CONFIGURATION_get_value_number (cfg, "vpn",
261 GNUNET_assert (ipv6prefix < 127);
262 ipv6prefix = (ipv6prefix + 7) / 8;
264 inet_pton (AF_INET6, ipv6addr, buf);
265 GNUNET_free (ipv6addr);
267 int local_length = 16 - ipv6prefix;
269 memcpy (buf + ipv6prefix, addr, max (addrlen, local_length));
274 * This gets scheduled with cls pointing to an answer_packet and does everything
275 * needed in order to send it to the helper.
277 * At the moment this means "inventing" and IPv6-Address for .gnunet-services and
278 * doing nothing for "real" services.
281 process_answer(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tc) {
282 struct answer_packet* pkt = cls;
283 struct answer_packet_list* list;
285 /* This answer is about a .gnunet-service
287 * It contains an almost complete DNS-Response, we have to fill in the ip
288 * at the offset pkt->addroffset
290 if (pkt->subtype == GNUNET_DNS_ANSWER_TYPE_SERVICE)
292 pkt->subtype = GNUNET_DNS_ANSWER_TYPE_IP;
295 memset(&key, 0, sizeof(GNUNET_HashCode));
297 unsigned char* c = ((unsigned char*)pkt)+ntohs(pkt->addroffset);
298 unsigned char* k = (unsigned char*)&key;
299 new_ip6addr(c, &pkt->service_descr.peer, &pkt->service_descr.service_descriptor);
301 * Copy the newly generated ip-address to the key backwarts (as only the first part is hashed)
304 for (i = 0; i < 16; i++)
307 uint16_t namelen = strlen((char*)pkt->data+12)+1;
309 struct map_entry* value = GNUNET_malloc(sizeof(struct map_entry) + namelen);
310 char* name = (char*)(value +1);
312 value->namelen = namelen;
313 memcpy(name, pkt->data+12, namelen);
315 memcpy(&value->desc, &pkt->service_descr, sizeof(struct GNUNET_vpn_service_descriptor));
317 memset(value->additional_ports, 0, 8192);
319 memcpy(&value->hash, &key, sizeof(GNUNET_HashCode));
322 GNUNET_CONTAINER_multihashmap_contains (hashmap, &key))
324 GNUNET_CONTAINER_multihashmap_put (hashmap, &key, value,
325 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
327 value->heap_node = GNUNET_CONTAINER_heap_insert (heap, value,
328 GNUNET_TIME_absolute_get ().abs_value);
329 if (GNUNET_CONTAINER_heap_get_size(heap) > max_mappings)
330 GNUNET_SCHEDULER_add_now(collect_mappings, NULL);
336 list = GNUNET_malloc(htons(pkt->hdr.size) + 2*sizeof(struct answer_packet_list*));
338 memcpy(&list->pkt, pkt, htons(pkt->hdr.size));
341 else if (pkt->subtype == GNUNET_DNS_ANSWER_TYPE_REV)
344 memset(&key, 0, sizeof key);
345 unsigned char* k = (unsigned char*)&key;
346 unsigned char* s = pkt->data+12;
348 /* Whoever designed the reverse IPv6-lookup is batshit insane */
349 for (i = 0; i < 16; i++)
351 unsigned char c1 = s[(4*i)+1];
352 unsigned char c2 = s[(4*i)+3];
356 k[i] = c1 - 87; /* 87 is the difference between 'a' and 10 */
358 k[i] += 16*(c2 - '0');
360 k[i] += 16*(c2 - 87);
363 struct map_entry* map_entry = GNUNET_CONTAINER_multihashmap_get(hashmap, &key);
364 GNUNET_CONTAINER_heap_update_cost (heap, map_entry->heap_node,
365 GNUNET_TIME_absolute_get ().abs_value);
367 uint16_t offset = ntohs(pkt->addroffset);
369 if (map_entry == NULL)
375 unsigned short namelen = htons(map_entry->namelen);
376 char* name = (char*)(map_entry + 1);
378 list = GNUNET_malloc(2*sizeof(struct answer_packet_list*) + offset + 2 + ntohs(namelen));
380 struct answer_packet* rpkt = &list->pkt;
382 /* The offset points to the first byte belonging to the address */
383 memcpy(rpkt, pkt, offset - 1);
385 rpkt->subtype = GNUNET_DNS_ANSWER_TYPE_IP;
386 rpkt->hdr.size = ntohs(offset + 2 + ntohs(namelen));
388 memcpy(((char*)rpkt)+offset, &namelen, 2);
389 memcpy(((char*)rpkt)+offset+2, name, ntohs(namelen));
392 else if (pkt->subtype == GNUNET_DNS_ANSWER_TYPE_IP)
394 list = GNUNET_malloc(htons(pkt->hdr.size) + 2*sizeof(struct answer_packet_list*));
395 memcpy(&list->pkt, pkt, htons(pkt->hdr.size));
397 else if (pkt->subtype == GNUNET_DNS_ANSWER_TYPE_REMOTE)
399 pkt->subtype = GNUNET_DNS_ANSWER_TYPE_IP;
402 memset(&key, 0, sizeof(GNUNET_HashCode));
404 unsigned char* c = ((unsigned char*)pkt)+ntohs(pkt->addroffset);
405 new_ip6addr_remote(c, pkt->addr, pkt->addrsize);
406 unsigned char* k = (unsigned char*)&key;
408 * Copy the newly generated ip-address to the key backwards (as only the first part is used in the hash-table)
411 for (i = 0; i < 16; i++)
414 uint16_t namelen = strlen((char*)pkt->data+12)+1;
416 struct map_entry* value = GNUNET_malloc(sizeof(struct map_entry) + namelen);
417 char* name = (char*)(value +1);
419 value->namelen = namelen;
420 memcpy(name, pkt->data+12, namelen);
422 value->addrlen = pkt->addrsize;
423 memcpy(&value->addr, &pkt->addr, pkt->addrsize);
424 memset(value->additional_ports, 0, 8192);
426 memcpy(&value->hash, &key, sizeof(GNUNET_HashCode));
429 GNUNET_CONTAINER_multihashmap_contains (hashmap, &key))
431 GNUNET_CONTAINER_multihashmap_put (hashmap, &key, value,
432 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
433 value->heap_node = GNUNET_CONTAINER_heap_insert (heap, value,
434 GNUNET_TIME_absolute_get ().abs_value);
435 if (GNUNET_CONTAINER_heap_get_size(heap) > max_mappings)
436 GNUNET_SCHEDULER_add_now(collect_mappings, NULL);
441 list = GNUNET_malloc(htons(pkt->hdr.size) + 2*sizeof(struct answer_packet_list*));
443 memcpy(&list->pkt, pkt, htons(pkt->hdr.size));
454 GNUNET_CONTAINER_DLL_insert_after(answer_proc_head, answer_proc_tail, answer_proc_tail, list);
456 schedule_helper_write(GNUNET_TIME_UNIT_FOREVER_REL, NULL);
462 * Sets a bit active in a bitArray.
464 * @param bitArray memory area to set the bit in
465 * @param bitIdx which bit to set
468 setBit (char *bitArray, unsigned int bitIdx)
471 unsigned int targetBit;
473 arraySlot = bitIdx / 8;
474 targetBit = (1L << (bitIdx % 8));
475 bitArray[arraySlot] |= targetBit;
479 * Clears a bit from bitArray.
481 * @param bitArray memory area to set the bit in
482 * @param bitIdx which bit to unset
485 clearBit (char *bitArray, unsigned int bitIdx)
488 unsigned int targetBit;
491 targetBit = (1L << (bitIdx % 8));
492 bitArray[slot] = bitArray[slot] & (~targetBit);
496 * Checks if a bit is active in the bitArray
498 * @param bitArray memory area to set the bit in
499 * @param bitIdx which bit to test
500 * @return GNUNET_YES if the bit is set, GNUNET_NO if not.
503 testBit (char *bitArray, unsigned int bitIdx)
506 unsigned int targetBit;
509 targetBit = (1L << (bitIdx % 8));
510 if (bitArray[slot] & targetBit)
517 * @brief Add the port to the list of additional ports in the map_entry
519 * @param me the map_entry
520 * @param port the port in host-byte-order
523 add_additional_port (struct map_entry *me, uint16_t port)
525 setBit(me->additional_ports, port);
529 receive_udp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel,
531 const struct GNUNET_PeerIdentity *sender,
532 const struct GNUNET_MessageHeader *message,
533 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
535 GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
536 struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1);
537 const struct GNUNET_PeerIdentity* other = GNUNET_MESH_get_peer(tunnel);
539 size_t size = sizeof(struct ip6_udp) + ntohs(pkt->len) - 1 - sizeof(struct udp_pkt);
541 struct ip6_udp* pkt6 = alloca(size);
543 GNUNET_assert(pkt6 != NULL);
545 new_ip6addr(pkt6->ip6_hdr.sadr, &other->hashPubKey, desc);
547 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Relaying calc:%d gnu:%d udp:%d bytes!\n", size, ntohs(message->size), ntohs(pkt->len));
549 pkt6->shdr.type = htons(GNUNET_MESSAGE_TYPE_VPN_HELPER);
550 pkt6->shdr.size = htons(size);
553 pkt6->tun.type = htons(0x86dd);
555 pkt6->ip6_hdr.version = 6;
556 pkt6->ip6_hdr.tclass_h = 0;
557 pkt6->ip6_hdr.tclass_l = 0;
558 pkt6->ip6_hdr.flowlbl = 0;
559 pkt6->ip6_hdr.paylgth = pkt->len;
560 pkt6->ip6_hdr.nxthdr = 0x11;
561 pkt6->ip6_hdr.hoplmt = 0xff;
565 GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "vpn", "IPV6ADDR", &ipv6addr));
566 inet_pton (AF_INET6, ipv6addr, pkt6->ip6_hdr.dadr);
567 GNUNET_free(ipv6addr);
569 memcpy(&pkt6->udp_hdr, pkt, ntohs(pkt->len));
571 GNUNET_HashCode* key = address_mapping_exists(pkt6->ip6_hdr.sadr);
572 GNUNET_assert (key != NULL);
574 struct map_entry *me = GNUNET_CONTAINER_multihashmap_get(hashmap, key);
575 GNUNET_CONTAINER_heap_update_cost (heap, me->heap_node,
576 GNUNET_TIME_absolute_get ().abs_value);
580 GNUNET_assert (me != NULL);
581 GNUNET_assert (me->desc.service_type & htonl(GNUNET_DNS_SERVICE_TYPE_UDP));
582 if (!port_in_ports(me->desc.ports, pkt6->udp_hdr.spt) &&
583 !testBit(me->additional_ports, ntohs(pkt6->udp_hdr.spt))) {
584 add_additional_port(me, ntohs(pkt6->udp_hdr.spt));
587 pkt6->udp_hdr.crc = 0;
589 sum = calculate_checksum_update(sum, (uint16_t*)&pkt6->ip6_hdr.sadr, 16);
590 sum = calculate_checksum_update(sum, (uint16_t*)&pkt6->ip6_hdr.dadr, 16);
591 uint32_t tmp = (pkt6->udp_hdr.len & 0xffff);
592 sum = calculate_checksum_update(sum, (uint16_t*)&tmp, 4);
593 tmp = htons(((pkt6->ip6_hdr.nxthdr & 0x00ff)));
594 sum = calculate_checksum_update(sum, (uint16_t*)&tmp, 4);
596 sum = calculate_checksum_update(sum, (uint16_t*)&pkt6->udp_hdr, ntohs(pkt->len));
597 pkt6->udp_hdr.crc = calculate_checksum_end(sum);
599 write_to_helper(pkt6, size);
605 receive_tcp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel,
607 const struct GNUNET_PeerIdentity *sender,
608 const struct GNUNET_MessageHeader *message,
609 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
611 GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1);
612 struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1);
613 const struct GNUNET_PeerIdentity* other = GNUNET_MESH_get_peer(tunnel);
615 size_t pktlen = ntohs(message->size) - sizeof(struct GNUNET_MessageHeader) - sizeof(GNUNET_HashCode);
616 size_t size = pktlen + sizeof(struct ip6_tcp) - 1;
618 struct ip6_tcp* pkt6 = alloca(size);
620 GNUNET_assert(pkt6 != NULL);
622 new_ip6addr(pkt6->ip6_hdr.sadr, &other->hashPubKey, desc);
624 pkt6->shdr.type = htons(GNUNET_MESSAGE_TYPE_VPN_HELPER);
625 pkt6->shdr.size = htons(size);
628 pkt6->tun.type = htons(0x86dd);
630 pkt6->ip6_hdr.version = 6;
631 pkt6->ip6_hdr.tclass_h = 0;
632 pkt6->ip6_hdr.tclass_l = 0;
633 pkt6->ip6_hdr.flowlbl = 0;
634 pkt6->ip6_hdr.paylgth = htons(pktlen);
635 pkt6->ip6_hdr.nxthdr = 0x06;
636 pkt6->ip6_hdr.hoplmt = 0xff;
640 GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "vpn", "IPV6ADDR", &ipv6addr));
641 inet_pton (AF_INET6, ipv6addr, pkt6->ip6_hdr.dadr);
642 GNUNET_free(ipv6addr);
644 memcpy(&pkt6->tcp_hdr, pkt, pktlen);
646 GNUNET_HashCode* key = address_mapping_exists(pkt6->ip6_hdr.sadr);
647 GNUNET_assert (key != NULL);
649 struct map_entry *me = GNUNET_CONTAINER_multihashmap_get(hashmap, key);
650 GNUNET_CONTAINER_heap_update_cost (heap, me->heap_node,
651 GNUNET_TIME_absolute_get ().abs_value);
655 GNUNET_assert (me != NULL);
656 GNUNET_assert (me->desc.service_type & htonl(GNUNET_DNS_SERVICE_TYPE_TCP));
658 pkt6->tcp_hdr.crc = 0;
662 calculate_checksum_update (sum, (uint16_t *) & pkt6->ip6_hdr.sadr, 16);
664 calculate_checksum_update (sum, (uint16_t *) & pkt6->ip6_hdr.dadr, 16);
666 sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
667 tmp = htonl (((pkt6->ip6_hdr.nxthdr & 0x000000ff)));
668 sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
671 calculate_checksum_update (sum, (uint16_t *) & pkt6->tcp_hdr,
672 ntohs (pkt6->ip6_hdr.paylgth));
673 pkt6->tcp_hdr.crc = calculate_checksum_end (sum);
675 write_to_helper(pkt6, size);
681 * Main function that will be run by the scheduler.
684 * @param args remaining command-line arguments
685 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
686 * @param cfg_ configuration
692 const struct GNUNET_CONFIGURATION_Handle *cfg_)
694 const static struct GNUNET_MESH_MessageHandler handlers[] = {
695 {receive_udp_back, GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK, 0},
696 {receive_tcp_back, GNUNET_MESSAGE_TYPE_SERVICE_TCP_BACK, 0},
699 mesh_handle = GNUNET_MESH_connect(cfg_,
706 hashmap = GNUNET_CONTAINER_multihashmap_create(65536);
707 heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
708 GNUNET_CONFIGURATION_get_value_number (cfg, "vpn", "MAX_MAPPINGg",
710 udp_connections = GNUNET_CONTAINER_multihashmap_create(65536);
711 GNUNET_SCHEDULER_TaskIdentifier conn_task = GNUNET_SCHEDULER_add_now (connect_to_service_dns, NULL);
712 GNUNET_SCHEDULER_add_after (conn_task, start_helper_and_schedule, NULL);
713 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls);
717 * The main function to obtain template from gnunetd.
719 * @param argc number of arguments from the command line
720 * @param argv command line arguments
721 * @return 0 ok, 1 on error
724 main (int argc, char *const *argv) {
725 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
726 GNUNET_GETOPT_OPTION_END
730 GNUNET_PROGRAM_run (argc,
733 gettext_noop ("help text"),
734 options, &run, NULL)) ? ret : 1;
737 /* end of gnunet-daemon-vpn.c */