indentation
[oweals/gnunet.git] / src / vpn / gnunet-daemon-vpn.h
1 /*
2      This file is part of GNUnet.
3      (C) 2010 Christian Grothoff
4
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.
9
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.
14
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.
19 */
20
21 /**
22  * @file vpn/gnunet-daemon-vpn.h
23  * @brief
24  * @author Philipp Toelke
25  */
26 #ifndef GNUNET_DAEMON_VPN_H
27 #define GNUNET_DAEMON_VPN_H
28
29 #include "gnunet-service-dns-p.h"
30
31 /**
32  * This gets scheduled with cls pointing to an answer_packet and does everything
33  * needed in order to send it to the helper.
34  *
35  * At the moment this means "inventing" and IPv6-Address for .gnunet-services and
36  * doing nothing for "real" services.
37  */
38 void process_answer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
39
40 void send_icmp6_response (void *cls,
41                           const struct GNUNET_SCHEDULER_TaskContext *tc);
42 void send_icmp4_response (void *cls,
43                           const struct GNUNET_SCHEDULER_TaskContext *tc);
44
45 size_t
46                       send_udp_service (void *cls, size_t size, void *buf);
47
48 GNUNET_HashCode *address6_mapping_exists (unsigned char addr[]);
49 GNUNET_HashCode *address4_mapping_exists (uint32_t addr);
50
51 unsigned int port_in_ports (uint64_t ports, uint16_t port);
52
53 void
54 send_pkt_to_peer (void *cls,
55                   const struct GNUNET_PeerIdentity *peer,
56                   const struct GNUNET_TRANSPORT_ATS_Information *atsi);
57
58 /**
59  * The configuration to use
60  */
61 extern const struct GNUNET_CONFIGURATION_Handle *cfg;
62
63 /**
64  * The handle to mesh
65  */
66 extern struct GNUNET_MESH_Handle *mesh_handle;
67
68 /**
69  * The hashmap containing the mappings from ipv6-addresses to gnunet-descriptors
70  */
71 extern struct GNUNET_CONTAINER_MultiHashMap *hashmap;
72
73 struct map_entry
74 {
75     /** The description of the service (used for service) */
76   struct GNUNET_vpn_service_descriptor desc;
77
78     /** The real address of the service (used for remote) */
79   char addrlen;
80   char addr[16];
81
82   struct GNUNET_MESH_Tunnel *tunnel;
83   uint16_t namelen;
84   char additional_ports[8192];
85
86   struct GNUNET_CONTAINER_HeapNode *heap_node;
87   GNUNET_HashCode hash;
88     /**
89      * After this struct the name is located in DNS-Format!
90      */
91 };
92
93 /**
94  * Sets a bit active in a bitArray.
95  *
96  * @param bitArray memory area to set the bit in
97  * @param bitIdx which bit to set
98  */
99 void setBit (char *bitArray, unsigned int bitIdx);
100
101 /**
102  * Clears a bit from bitArray.
103  *
104  * @param bitArray memory area to set the bit in
105  * @param bitIdx which bit to unset
106  */
107 void clearBit (char *bitArray, unsigned int bitIdx);
108
109 /**
110  * Checks if a bit is active in the bitArray
111  *
112  * @param bitArray memory area to set the bit in
113  * @param bitIdx which bit to test
114  * @return GNUNET_YES if the bit is set, GNUNET_NO if not.
115  */
116 int testBit (char *bitArray, unsigned int bitIdx);
117
118 struct remote_addr
119 {
120   char addrlen;
121   unsigned char addr[16];
122   char proto;
123 };
124
125 #endif /* end of include guard: GNUNET-DAEMON-VPN_H */