diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-09 22:38:49 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-09 22:38:49 +0000 |
commit | d2c214f97316f90f0242a0921fb4f060313c6c18 (patch) | |
tree | 9062233053a29b0689e039c1619b4d3c77f5b679 /src | |
parent | 428ea7205a76b37863e7d987512aaae45029f37b (diff) | |
download | gnunet-d2c214f97316f90f0242a0921fb4f060313c6c18.tar.gz gnunet-d2c214f97316f90f0242a0921fb4f060313c6c18.zip |
-defining proper structs for vpn-exit mesh communication
Diffstat (limited to 'src')
-rw-r--r-- | src/exit/Makefile.am | 2 | ||||
-rw-r--r-- | src/exit/exit.h | 195 | ||||
-rw-r--r-- | src/exit/gnunet-daemon-exit.c | 129 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 32 |
4 files changed, 315 insertions, 43 deletions
diff --git a/src/exit/Makefile.am b/src/exit/Makefile.am index 9d1e8b413..736bb5fd3 100644 --- a/src/exit/Makefile.am +++ b/src/exit/Makefile.am | |||
@@ -33,7 +33,7 @@ gnunet_helper_exit_SOURCES = \ | |||
33 | gnunet-helper-exit.c | 33 | gnunet-helper-exit.c |
34 | 34 | ||
35 | gnunet_daemon_exit_SOURCES = \ | 35 | gnunet_daemon_exit_SOURCES = \ |
36 | gnunet-daemon-exit.c | 36 | gnunet-daemon-exit.c exit.h |
37 | gnunet_daemon_exit_LDADD = \ | 37 | gnunet_daemon_exit_LDADD = \ |
38 | $(top_builddir)/src/core/libgnunetcore.la \ | 38 | $(top_builddir)/src/core/libgnunetcore.la \ |
39 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 39 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
diff --git a/src/exit/exit.h b/src/exit/exit.h new file mode 100644 index 000000000..1e92cc501 --- /dev/null +++ b/src/exit/exit.h | |||
@@ -0,0 +1,195 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2012 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 exit/exit.h | ||
23 | * @brief format for mesh messages exchanged between VPN service and exit daemon | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef EXIT_H | ||
27 | #define EXIT_H | ||
28 | |||
29 | #include "gnunet_util_lib.h" | ||
30 | |||
31 | /** | ||
32 | * Message send via mesh to an exit daemon to initiate forwarding of | ||
33 | * TCP data to a local service. | ||
34 | */ | ||
35 | struct GNUNET_EXIT_TcpServiceStartMessage | ||
36 | { | ||
37 | /** | ||
38 | * Type is GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START | ||
39 | */ | ||
40 | struct GNUNET_MessageHeader header; | ||
41 | |||
42 | /** | ||
43 | * Always 0. | ||
44 | */ | ||
45 | uint32_t reserved; | ||
46 | |||
47 | /** | ||
48 | * Identification for the desired service. | ||
49 | */ | ||
50 | GNUNET_HashCode service_descriptor; | ||
51 | |||
52 | /** | ||
53 | * Skeleton of the TCP header to send. Port numbers are to | ||
54 | * be replaced and the checksum may be updated as necessary. | ||
55 | */ | ||
56 | struct tcp_packet tcp_header; | ||
57 | |||
58 | /* followed by TCP payload */ | ||
59 | }; | ||
60 | |||
61 | |||
62 | /** | ||
63 | * Message send via mesh to an exit daemon to initiate forwarding of | ||
64 | * TCP data to the Internet. | ||
65 | */ | ||
66 | struct GNUNET_EXIT_TcpInternetStartMessage | ||
67 | { | ||
68 | /** | ||
69 | * Type is GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START | ||
70 | */ | ||
71 | struct GNUNET_MessageHeader header; | ||
72 | |||
73 | /** | ||
74 | * Address family, AF_INET or AF_INET6, in network byte order. | ||
75 | */ | ||
76 | int32_t af; | ||
77 | |||
78 | /** | ||
79 | * Skeleton of the TCP header to send. Port numbers are to | ||
80 | * be replaced and the checksum may be updated as necessary. | ||
81 | */ | ||
82 | struct tcp_packet tcp_header; | ||
83 | |||
84 | /* followed by IP address of the destination; either | ||
85 | 'struct in_addr' or 'struct in6_addr', depending on af */ | ||
86 | |||
87 | /* followed by TCP payload */ | ||
88 | }; | ||
89 | |||
90 | |||
91 | /** | ||
92 | * Message send via mesh between VPN and entry and an exit daemon to | ||
93 | * transmit TCP data between the VPN entry and an exit session. This | ||
94 | * format is used for both Internet-exits and service-exits and | ||
95 | * in both directions (VPN to exit and exit to VPN). | ||
96 | */ | ||
97 | struct GNUNET_EXIT_TcpDataMessage | ||
98 | { | ||
99 | /** | ||
100 | * Type is GNUNET_MESSAGE_TYPE_VPN_TCP_DATA | ||
101 | */ | ||
102 | struct GNUNET_MessageHeader header; | ||
103 | |||
104 | /** | ||
105 | * Always 0. | ||
106 | */ | ||
107 | uint32_t reserved; | ||
108 | |||
109 | /** | ||
110 | * Skeleton of the TCP header to send. Port numbers are to | ||
111 | * be replaced and the checksum may be updated as necessary. | ||
112 | */ | ||
113 | struct tcp_packet tcp_header; | ||
114 | |||
115 | /* followed by TCP payload */ | ||
116 | }; | ||
117 | |||
118 | |||
119 | /** | ||
120 | * Message send via mesh to an exit daemon to send | ||
121 | * UDP data to a local service. | ||
122 | */ | ||
123 | struct GNUNET_EXIT_UdpServiceMessage | ||
124 | { | ||
125 | /** | ||
126 | * Type is GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE | ||
127 | */ | ||
128 | struct GNUNET_MessageHeader header; | ||
129 | |||
130 | /** | ||
131 | * Always 0. | ||
132 | */ | ||
133 | uint32_t reserved; | ||
134 | |||
135 | /** | ||
136 | * Identification for the desired service. | ||
137 | */ | ||
138 | GNUNET_HashCode service_descriptor; | ||
139 | |||
140 | /* followed by UDP payload */ | ||
141 | }; | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Message send via mesh to an exit daemon to forward | ||
146 | * UDP data to the Internet. | ||
147 | */ | ||
148 | struct GNUNET_EXIT_UdpInternetMessage | ||
149 | { | ||
150 | /** | ||
151 | * Type is GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET | ||
152 | */ | ||
153 | struct GNUNET_MessageHeader header; | ||
154 | |||
155 | /** | ||
156 | * Address family, AF_INET or AF_INET6, in network byte order. | ||
157 | */ | ||
158 | int32_t af; | ||
159 | |||
160 | |||
161 | /* followed by IP address of the destination; either | ||
162 | 'struct in_addr' or 'struct in6_addr', depending on af */ | ||
163 | |||
164 | /* followed by UDP payload */ | ||
165 | }; | ||
166 | |||
167 | |||
168 | /** | ||
169 | * Message send from exit daemon back to the UDP entry point | ||
170 | * (used for both Internet and Service exit replies). | ||
171 | */ | ||
172 | struct GNUNET_EXIT_UdpReplyMessage | ||
173 | { | ||
174 | /** | ||
175 | * Type is GNUNET_MESSAGE_TYPE_VPN_UDP_REPLY | ||
176 | */ | ||
177 | struct GNUNET_MessageHeader header; | ||
178 | |||
179 | /** | ||
180 | * Source port to use for the UDP reply (0 to use the same | ||
181 | * port as for the original request). In NBO. | ||
182 | */ | ||
183 | uint16_t source_port; | ||
184 | |||
185 | /** | ||
186 | * Destination port to use for the UDP reply (0 to use the same | ||
187 | * port as for the original request). In NBO. | ||
188 | */ | ||
189 | uint16_t destination_port; | ||
190 | |||
191 | /* followed by UDP payload */ | ||
192 | }; | ||
193 | |||
194 | |||
195 | #endif | ||
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c index 4ce0f634f..eecc26aeb 100644 --- a/src/exit/gnunet-daemon-exit.c +++ b/src/exit/gnunet-daemon-exit.c | |||
@@ -25,8 +25,8 @@ | |||
25 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
26 | * | 26 | * |
27 | * TODO: | 27 | * TODO: |
28 | * - need proper message headers for mesh P2P messages | 28 | * - use new proper message headers for mesh P2P messages |
29 | * - factor out crc computations from DNS/EXIT into shared library? | 29 | * - factor out crc computations from DNS/EXIT/VPN into shared library? |
30 | * - which code should advertise services? the service model is right | 30 | * - which code should advertise services? the service model is right |
31 | * now a bit odd, especially as this code DOES the exit and knows | 31 | * now a bit odd, especially as this code DOES the exit and knows |
32 | * the DNS "name", but OTOH this is clearly NOT the place to advertise | 32 | * the DNS "name", but OTOH this is clearly NOT the place to advertise |
@@ -40,6 +40,7 @@ | |||
40 | #include "gnunet_mesh_service.h" | 40 | #include "gnunet_mesh_service.h" |
41 | #include "gnunet_constants.h" | 41 | #include "gnunet_constants.h" |
42 | #include "tcpip_tun.h" | 42 | #include "tcpip_tun.h" |
43 | #include "exit.h" | ||
43 | 44 | ||
44 | /** | 45 | /** |
45 | * Information about an address. | 46 | * Information about an address. |
@@ -267,6 +268,15 @@ static struct GNUNET_CONTAINER_MultiHashMap *udp_services; | |||
267 | */ | 268 | */ |
268 | static struct GNUNET_CONTAINER_MultiHashMap *tcp_services; | 269 | static struct GNUNET_CONTAINER_MultiHashMap *tcp_services; |
269 | 270 | ||
271 | /** | ||
272 | * Are we an IPv4-exit? | ||
273 | */ | ||
274 | static int ipv4_exit; | ||
275 | |||
276 | /** | ||
277 | * Are we an IPv6-exit? | ||
278 | */ | ||
279 | static int ipv6_exit; | ||
270 | 280 | ||
271 | /** | 281 | /** |
272 | * Given IP information about a connection, calculate the respective | 282 | * Given IP information about a connection, calculate the respective |
@@ -1265,7 +1275,7 @@ receive_tcp_service (void *unused GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunn | |||
1265 | if (pkt_len < sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode) + sizeof (struct tcp_packet)) | 1275 | if (pkt_len < sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode) + sizeof (struct tcp_packet)) |
1266 | { | 1276 | { |
1267 | GNUNET_break_op (0); | 1277 | GNUNET_break_op (0); |
1268 | return GNUNET_YES; | 1278 | return GNUNET_SYSERR; |
1269 | } | 1279 | } |
1270 | pkt_len -= (sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode)); | 1280 | pkt_len -= (sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode)); |
1271 | 1281 | ||
@@ -1279,8 +1289,7 @@ receive_tcp_service (void *unused GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunn | |||
1279 | _("No service found for %s on port %d!\n"), | 1289 | _("No service found for %s on port %d!\n"), |
1280 | "TCP", | 1290 | "TCP", |
1281 | ntohs (pkt->dpt)); | 1291 | ntohs (pkt->dpt)); |
1282 | GNUNET_MESH_tunnel_destroy (state->tunnel); | 1292 | return GNUNET_SYSERR; |
1283 | return GNUNET_YES; | ||
1284 | } | 1293 | } |
1285 | state->ri.remote_address = state->serv->address; | 1294 | state->ri.remote_address = state->serv->address; |
1286 | setup_state_record (state); | 1295 | setup_state_record (state); |
@@ -1321,7 +1330,7 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1321 | if (pkt_len < sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode) + sizeof (struct tcp_packet)) | 1330 | if (pkt_len < sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode) + sizeof (struct tcp_packet)) |
1322 | { | 1331 | { |
1323 | GNUNET_break_op (0); | 1332 | GNUNET_break_op (0); |
1324 | return GNUNET_YES; | 1333 | return GNUNET_SYSERR; |
1325 | } | 1334 | } |
1326 | pkt_len -= (sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode)); | 1335 | pkt_len -= (sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode)); |
1327 | 1336 | ||
@@ -1340,6 +1349,54 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1340 | 1349 | ||
1341 | 1350 | ||
1342 | /** | 1351 | /** |
1352 | * Process a request to forward TCP data on an established | ||
1353 | * connection via this peer. | ||
1354 | * | ||
1355 | * @param cls closure, NULL | ||
1356 | * @param tunnel connection to the other end | ||
1357 | * @param tunnel_ctx pointer to our 'struct TunnelState *' | ||
1358 | * @param sender who sent the message | ||
1359 | * @param message the actual message | ||
1360 | * @param atsi performance data for the connection | ||
1361 | * @return GNUNET_OK to keep the connection open, | ||
1362 | * GNUNET_SYSERR to close it (signal serious error) | ||
1363 | */ | ||
1364 | static int | ||
1365 | receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | ||
1366 | void **tunnel_ctx GNUNET_UNUSED, | ||
1367 | const struct GNUNET_PeerIdentity *sender GNUNET_UNUSED, | ||
1368 | const struct GNUNET_MessageHeader *message, | ||
1369 | const struct GNUNET_ATS_Information *atsi GNUNET_UNUSED) | ||
1370 | { | ||
1371 | struct TunnelState *state = *tunnel_ctx; | ||
1372 | // FIXME: write proper request struct (!) | ||
1373 | const GNUNET_HashCode *desc = (const GNUNET_HashCode *) &message[1]; | ||
1374 | const struct tcp_packet *pkt = (const struct tcp_packet *) &desc[1]; | ||
1375 | uint16_t pkt_len = ntohs (message->size); | ||
1376 | |||
1377 | if (NULL == state) | ||
1378 | { | ||
1379 | /* connection should have been up! */ | ||
1380 | /* FIXME: call statistics */ | ||
1381 | return GNUNET_SYSERR; | ||
1382 | } | ||
1383 | |||
1384 | if (pkt_len < sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode) + sizeof (struct tcp_packet)) | ||
1385 | { | ||
1386 | GNUNET_break_op (0); | ||
1387 | return GNUNET_SYSERR; | ||
1388 | } | ||
1389 | pkt_len -= (sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode)); | ||
1390 | |||
1391 | |||
1392 | send_tcp_packet_via_tun (&state->ri.remote_address, | ||
1393 | &state->ri.local_address, | ||
1394 | pkt, pkt_len); | ||
1395 | return GNUNET_YES; | ||
1396 | } | ||
1397 | |||
1398 | |||
1399 | /** | ||
1343 | * Send a UDP packet via the TUN interface. | 1400 | * Send a UDP packet via the TUN interface. |
1344 | * | 1401 | * |
1345 | * @param destination_address IP and port to use for the UDP packet's destination | 1402 | * @param destination_address IP and port to use for the UDP packet's destination |
@@ -1449,7 +1506,7 @@ receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1449 | if (pkt_len < sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode) + sizeof (struct udp_packet)) | 1506 | if (pkt_len < sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode) + sizeof (struct udp_packet)) |
1450 | { | 1507 | { |
1451 | GNUNET_break_op (0); | 1508 | GNUNET_break_op (0); |
1452 | return GNUNET_YES; | 1509 | return GNUNET_SYSERR; |
1453 | } | 1510 | } |
1454 | pkt_len -= (sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode)); | 1511 | pkt_len -= (sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode)); |
1455 | 1512 | ||
@@ -1498,7 +1555,7 @@ receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1498 | if (pkt_len < sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode) + sizeof (struct udp_packet)) | 1555 | if (pkt_len < sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode) + sizeof (struct udp_packet)) |
1499 | { | 1556 | { |
1500 | GNUNET_break_op (0); | 1557 | GNUNET_break_op (0); |
1501 | return GNUNET_YES; | 1558 | return GNUNET_SYSERR; |
1502 | } | 1559 | } |
1503 | pkt_len -= (sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode)); | 1560 | pkt_len -= (sizeof (struct GNUNET_MessageHeader) + sizeof (GNUNET_HashCode)); |
1504 | 1561 | ||
@@ -1517,7 +1574,7 @@ receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1517 | "UDP", | 1574 | "UDP", |
1518 | ntohs (pkt->dpt)); | 1575 | ntohs (pkt->dpt)); |
1519 | GNUNET_MESH_tunnel_destroy (state->tunnel); | 1576 | GNUNET_MESH_tunnel_destroy (state->tunnel); |
1520 | return GNUNET_YES; | 1577 | return GNUNET_SYSERR; |
1521 | } | 1578 | } |
1522 | state->ri.remote_address = state->serv->address; | 1579 | state->ri.remote_address = state->serv->address; |
1523 | setup_state_record (state); | 1580 | setup_state_record (state); |
@@ -1819,10 +1876,11 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
1819 | const struct GNUNET_CONFIGURATION_Handle *cfg_) | 1876 | const struct GNUNET_CONFIGURATION_Handle *cfg_) |
1820 | { | 1877 | { |
1821 | static struct GNUNET_MESH_MessageHandler handlers[] = { | 1878 | static struct GNUNET_MESH_MessageHandler handlers[] = { |
1822 | {&receive_udp_service, GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP, 0}, | 1879 | {&receive_udp_service, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE, 0}, |
1823 | {&receive_tcp_service, GNUNET_MESSAGE_TYPE_VPN_SERVICE_TCP, 0}, | 1880 | {&receive_udp_remote, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET, 0}, |
1824 | {NULL, 0, 0}, | 1881 | {&receive_tcp_service, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START, 0}, |
1825 | {NULL, 0, 0}, | 1882 | {&receive_tcp_remote, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START, 0}, |
1883 | {&receive_tcp_data, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA, 0}, | ||
1826 | {NULL, 0, 0} | 1884 | {NULL, 0, 0} |
1827 | }; | 1885 | }; |
1828 | 1886 | ||
@@ -1831,10 +1889,7 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
1831 | GNUNET_APPLICATION_TYPE_END, | 1889 | GNUNET_APPLICATION_TYPE_END, |
1832 | GNUNET_APPLICATION_TYPE_END | 1890 | GNUNET_APPLICATION_TYPE_END |
1833 | }; | 1891 | }; |
1834 | unsigned int handler_idx; | ||
1835 | unsigned int app_idx; | 1892 | unsigned int app_idx; |
1836 | int udp; | ||
1837 | int tcp; | ||
1838 | char *ifname; | 1893 | char *ifname; |
1839 | char *ipv6addr; | 1894 | char *ipv6addr; |
1840 | char *ipv6prefix_s; | 1895 | char *ipv6prefix_s; |
@@ -1844,7 +1899,22 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
1844 | struct in6_addr v6; | 1899 | struct in6_addr v6; |
1845 | 1900 | ||
1846 | cfg = cfg_; | 1901 | cfg = cfg_; |
1902 | ipv4_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV4"); | ||
1903 | ipv6_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV6"); | ||
1904 | app_idx = 0; | ||
1905 | if (GNUNET_YES == ipv4_exit) | ||
1906 | { | ||
1907 | apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY; | ||
1908 | app_idx++; | ||
1909 | } | ||
1910 | if (GNUNET_YES == ipv6_exit) | ||
1911 | { | ||
1912 | apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY; | ||
1913 | app_idx++; | ||
1914 | } | ||
1915 | |||
1847 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); | 1916 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); |
1917 | |||
1848 | if (GNUNET_OK != | 1918 | if (GNUNET_OK != |
1849 | GNUNET_CONFIGURATION_get_value_number (cfg, "exit", "MAX_CONNECTIONS", | 1919 | GNUNET_CONFIGURATION_get_value_number (cfg, "exit", "MAX_CONNECTIONS", |
1850 | &max_connections)) | 1920 | &max_connections)) |
@@ -1914,31 +1984,6 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
1914 | exit_argv[5] = ipv4mask; | 1984 | exit_argv[5] = ipv4mask; |
1915 | exit_argv[6] = NULL; | 1985 | exit_argv[6] = NULL; |
1916 | 1986 | ||
1917 | app_idx = 0; | ||
1918 | handler_idx = 2; | ||
1919 | // FIXME: new 'vpn' has other apptypes (IPv4/IPv6, no longer TCP vs. UDP)! | ||
1920 | // The new 'exit' should reflect that! | ||
1921 | udp = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_UDP"); | ||
1922 | tcp = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_TCP"); | ||
1923 | if (GNUNET_YES == udp) | ||
1924 | { | ||
1925 | handlers[handler_idx].callback = &receive_udp_remote; | ||
1926 | handlers[handler_idx].expected_size = 0; | ||
1927 | handlers[handler_idx].type = GNUNET_MESSAGE_TYPE_VPN_REMOTE_UDP; | ||
1928 | apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY; | ||
1929 | handler_idx++; | ||
1930 | app_idx++; | ||
1931 | } | ||
1932 | |||
1933 | if (GNUNET_YES == tcp) | ||
1934 | { | ||
1935 | handlers[handler_idx].callback = &receive_tcp_remote; | ||
1936 | handlers[handler_idx].expected_size = 0; | ||
1937 | handlers[handler_idx].type = GNUNET_MESSAGE_TYPE_VPN_REMOTE_TCP; | ||
1938 | apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY; | ||
1939 | handler_idx++; | ||
1940 | app_idx++; | ||
1941 | } | ||
1942 | udp_services = GNUNET_CONTAINER_multihashmap_create (65536); | 1987 | udp_services = GNUNET_CONTAINER_multihashmap_create (65536); |
1943 | tcp_services = GNUNET_CONTAINER_multihashmap_create (65536); | 1988 | tcp_services = GNUNET_CONTAINER_multihashmap_create (65536); |
1944 | GNUNET_CONFIGURATION_iterate_sections (cfg, &read_service_conf, NULL); | 1989 | GNUNET_CONFIGURATION_iterate_sections (cfg, &read_service_conf, NULL); |
@@ -1955,7 +2000,7 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
1955 | GNUNET_SCHEDULER_shutdown (); | 2000 | GNUNET_SCHEDULER_shutdown (); |
1956 | return; | 2001 | return; |
1957 | } | 2002 | } |
1958 | helper_handle = GNUNET_HELPER_start ("gnunet-helper-vpn", | 2003 | helper_handle = GNUNET_HELPER_start ("gnunet-helper-exit", |
1959 | exit_argv, | 2004 | exit_argv, |
1960 | &message_token, NULL); | 2005 | &message_token, NULL); |
1961 | } | 2006 | } |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 164534d06..5257e2587 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -634,6 +634,38 @@ extern "C" | |||
634 | #define GNUNET_MESSAGE_TYPE_VPN_REMOTE_TCP_BACK 193 | 634 | #define GNUNET_MESSAGE_TYPE_VPN_REMOTE_TCP_BACK 193 |
635 | 635 | ||
636 | 636 | ||
637 | |||
638 | /** | ||
639 | * Type of messages containing an TCP packet for a service. | ||
640 | */ | ||
641 | #define GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START 196 | ||
642 | |||
643 | /** | ||
644 | * Type of messages containing an TCP packet for the Internet. | ||
645 | */ | ||
646 | #define GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START 197 | ||
647 | |||
648 | /** | ||
649 | * Type of messages containing an TCP packet of an established connection. | ||
650 | */ | ||
651 | #define GNUNET_MESSAGE_TYPE_VPN_TCP_DATA 198 | ||
652 | |||
653 | /** | ||
654 | * Type of messages containing an UDP packet for a service. | ||
655 | */ | ||
656 | #define GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE 199 | ||
657 | |||
658 | /** | ||
659 | * Type of messages containing an UDP packet for the Internet. | ||
660 | */ | ||
661 | #define GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET 200 | ||
662 | |||
663 | /** | ||
664 | * Type of messages containing an UDP packet from a remote host | ||
665 | */ | ||
666 | #define GNUNET_MESSAGE_TYPE_VPN_UDP_REPLY 201 | ||
667 | |||
668 | |||
637 | /** | 669 | /** |
638 | * Client asks VPN service to setup an IP to redirect traffic | 670 | * Client asks VPN service to setup an IP to redirect traffic |
639 | * via an exit node to some global IP address. | 671 | * via an exit node to some global IP address. |