diff options
author | Philipp Tölke <toelke@in.tum.de> | 2011-10-30 19:35:13 +0000 |
---|---|---|
committer | Philipp Tölke <toelke@in.tum.de> | 2011-10-30 19:35:13 +0000 |
commit | 6813281cd9f9eac5e6d285fb87725d5d71b76ebb (patch) | |
tree | 96e754f810fc4b0b7c7735b38b81b95864920983 /src/vpn/gnunet-daemon-vpn.c | |
parent | c1e5a964f324a33a131b27e681ac8e354f8f0624 (diff) | |
download | gnunet-6813281cd9f9eac5e6d285fb87725d5d71b76ebb.tar.gz gnunet-6813281cd9f9eac5e6d285fb87725d5d71b76ebb.zip |
gnunet-daemon-vpn uses the new mesh
Diffstat (limited to 'src/vpn/gnunet-daemon-vpn.c')
-rw-r--r-- | src/vpn/gnunet-daemon-vpn.c | 83 |
1 files changed, 41 insertions, 42 deletions
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index bd5938604..5b96f201e 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "gnunet_common.h" | 30 | #include "gnunet_common.h" |
31 | #include "gnunet_protocols.h" | 31 | #include "gnunet_protocols.h" |
32 | #include "gnunet_applications.h" | 32 | #include "gnunet_applications.h" |
33 | #include <gnunet_mesh_service.h> | 33 | #include <gnunet_mesh_service_new.h> |
34 | #include "gnunet_client_lib.h" | 34 | #include "gnunet_client_lib.h" |
35 | #include "gnunet_container_lib.h" | 35 | #include "gnunet_container_lib.h" |
36 | #include "gnunet_constants.h" | 36 | #include "gnunet_constants.h" |
@@ -300,17 +300,14 @@ send_pkt_to_peer_notify_callback (void *cls, size_t size, void *buf) | |||
300 | else | 300 | else |
301 | size = 0; | 301 | size = 0; |
302 | 302 | ||
303 | if (NULL != GNUNET_MESH_tunnel_get_head (*tunnel)) | 303 | if (NULL != ts->head) |
304 | { | 304 | { |
305 | struct tunnel_notify_queue *element = GNUNET_MESH_tunnel_get_head (*tunnel); | 305 | struct tunnel_notify_queue *element = ts->head; |
306 | struct tunnel_notify_queue *head = GNUNET_MESH_tunnel_get_head (*tunnel); | 306 | struct tunnel_notify_queue *head = ts->head; |
307 | struct tunnel_notify_queue *tail = GNUNET_MESH_tunnel_get_tail (*tunnel); | 307 | struct tunnel_notify_queue *tail = ts->tail; |
308 | 308 | ||
309 | GNUNET_CONTAINER_DLL_remove (head, tail, element); | 309 | GNUNET_CONTAINER_DLL_remove (head, tail, element); |
310 | 310 | ||
311 | GNUNET_MESH_tunnel_set_head (*tunnel, head); | ||
312 | GNUNET_MESH_tunnel_set_tail (*tunnel, tail); | ||
313 | |||
314 | ts->th = | 311 | ts->th = |
315 | GNUNET_MESH_notify_transmit_ready (*tunnel, | 312 | GNUNET_MESH_notify_transmit_ready (*tunnel, |
316 | GNUNET_NO, | 313 | GNUNET_NO, |
@@ -340,10 +337,7 @@ port_in_ports (uint64_t ports, uint16_t port) | |||
340 | 337 | ||
341 | void | 338 | void |
342 | send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer, | 339 | send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer, |
343 | const struct GNUNET_ATS_Information *atsi | 340 | const struct GNUNET_ATS_Information *atsi __attribute__ ((unused))) |
344 | __attribute__ ((unused)), | ||
345 | unsigned int atsi_count | ||
346 | __attribute__ ((unused))) | ||
347 | { | 341 | { |
348 | /* peer == NULL means that all peers in this request are connected */ | 342 | /* peer == NULL means that all peers in this request are connected */ |
349 | if (peer == NULL) | 343 | if (peer == NULL) |
@@ -372,17 +366,14 @@ send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
372 | } | 366 | } |
373 | else | 367 | else |
374 | { | 368 | { |
375 | struct tunnel_notify_queue *head = GNUNET_MESH_tunnel_get_head (*tunnel); | 369 | struct tunnel_notify_queue *head = ts->head; |
376 | struct tunnel_notify_queue *tail = GNUNET_MESH_tunnel_get_tail (*tunnel); | 370 | struct tunnel_notify_queue *tail = ts->tail; |
377 | struct tunnel_notify_queue *element = GNUNET_malloc (sizeof *element); | 371 | struct tunnel_notify_queue *element = GNUNET_malloc (sizeof *element); |
378 | 372 | ||
379 | element->cls = cls; | 373 | element->cls = cls; |
380 | element->len = ntohs (hdr->size); | 374 | element->len = ntohs (hdr->size); |
381 | 375 | ||
382 | GNUNET_CONTAINER_DLL_insert_tail (head, tail, element); | 376 | GNUNET_CONTAINER_DLL_insert_tail (head, tail, element); |
383 | |||
384 | GNUNET_MESH_tunnel_set_head (*tunnel, head); | ||
385 | GNUNET_MESH_tunnel_set_tail (*tunnel, tail); | ||
386 | } | 377 | } |
387 | } | 378 | } |
388 | 379 | ||
@@ -865,23 +856,18 @@ add_additional_port (struct map_entry *me, uint16_t port) | |||
865 | } | 856 | } |
866 | 857 | ||
867 | static int | 858 | static int |
868 | receive_udp_back (void *cls | 859 | receive_udp_back (void *cls __attribute__ ((unused)), |
869 | __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel, | 860 | struct GNUNET_MESH_Tunnel *tunnel, |
870 | void **tunnel_ctx | 861 | void **tunnel_ctx, |
871 | __attribute__ ((unused)), | 862 | const struct GNUNET_PeerIdentity *sender, |
872 | const struct GNUNET_PeerIdentity *sender | ||
873 | __attribute__ ((unused)), | ||
874 | const struct GNUNET_MessageHeader *message, | 863 | const struct GNUNET_MessageHeader *message, |
875 | const struct GNUNET_ATS_Information *atsi | 864 | const struct GNUNET_ATS_Information *atsi __attribute__ ((unused))) |
876 | __attribute__ ((unused)), | ||
877 | unsigned int atsi_count | ||
878 | __attribute__ ((unused))) | ||
879 | { | 865 | { |
880 | GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); | 866 | GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); |
881 | struct remote_addr *s = (struct remote_addr *) desc; | 867 | struct remote_addr *s = (struct remote_addr *) desc; |
882 | struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1); | 868 | struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1); |
883 | const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel); | 869 | const struct GNUNET_PeerIdentity *other = sender; |
884 | struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(tunnel); | 870 | struct tunnel_state *ts = *tunnel_ctx; |
885 | 871 | ||
886 | if (16 == ts->addrlen) | 872 | if (16 == ts->addrlen) |
887 | { | 873 | { |
@@ -1047,23 +1033,18 @@ receive_udp_back (void *cls | |||
1047 | } | 1033 | } |
1048 | 1034 | ||
1049 | static int | 1035 | static int |
1050 | receive_tcp_back (void *cls | 1036 | receive_tcp_back (void *cls __attribute__ ((unused)), |
1051 | __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel, | 1037 | struct GNUNET_MESH_Tunnel *tunnel, |
1052 | void **tunnel_ctx | 1038 | void **tunnel_ctx, |
1053 | __attribute__ ((unused)), | 1039 | const struct GNUNET_PeerIdentity *sender __attribute__ ((unused)), |
1054 | const struct GNUNET_PeerIdentity *sender | ||
1055 | __attribute__ ((unused)), | ||
1056 | const struct GNUNET_MessageHeader *message, | 1040 | const struct GNUNET_MessageHeader *message, |
1057 | const struct GNUNET_ATS_Information *atsi | 1041 | const struct GNUNET_ATS_Information *atsi __attribute__ ((unused))) |
1058 | __attribute__ ((unused)), | ||
1059 | unsigned int atsi_count | ||
1060 | __attribute__ ((unused))) | ||
1061 | { | 1042 | { |
1062 | GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); | 1043 | GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); |
1063 | struct remote_addr *s = (struct remote_addr *) desc; | 1044 | struct remote_addr *s = (struct remote_addr *) desc; |
1064 | struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1); | 1045 | struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1); |
1065 | const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel); | 1046 | const struct GNUNET_PeerIdentity *other = sender; |
1066 | struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(tunnel); | 1047 | struct tunnel_state *ts = *tunnel_ctx; |
1067 | 1048 | ||
1068 | size_t pktlen = | 1049 | size_t pktlen = |
1069 | ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) - | 1050 | ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) - |
@@ -1236,6 +1217,24 @@ receive_tcp_back (void *cls | |||
1236 | return GNUNET_OK; | 1217 | return GNUNET_OK; |
1237 | } | 1218 | } |
1238 | 1219 | ||
1220 | static void* new_tunnel(void* cls, | ||
1221 | struct GNUNET_MESH_Tunnel *tunnel, | ||
1222 | const struct GNUNET_PeerIdentity *initiator, | ||
1223 | const struct GNUNET_ATS_Information *atsi) | ||
1224 | { | ||
1225 | /* Why should anyone open an inbound tunnel to vpn? */ | ||
1226 | GNUNET_break(0); | ||
1227 | return NULL; | ||
1228 | } | ||
1229 | |||
1230 | static void cleaner(void *cls, | ||
1231 | const struct GNUNET_MESH_Tunnel *tunnel, | ||
1232 | void *tunnel_ctx) | ||
1233 | { | ||
1234 | /* Why should anyone open an inbound tunnel to vpn? */ | ||
1235 | GNUNET_break(0); | ||
1236 | } | ||
1237 | |||
1239 | /** | 1238 | /** |
1240 | * Main function that will be run by the scheduler. | 1239 | * Main function that will be run by the scheduler. |
1241 | * | 1240 | * |
@@ -1260,7 +1259,7 @@ run (void *cls, char *const *args __attribute__ ((unused)), const char *cfgfilep | |||
1260 | GNUNET_APPLICATION_TYPE_END | 1259 | GNUNET_APPLICATION_TYPE_END |
1261 | }; | 1260 | }; |
1262 | 1261 | ||
1263 | mesh_handle = GNUNET_MESH_connect (cfg_, NULL, NULL, handlers, types); | 1262 | mesh_handle = GNUNET_MESH_connect (cfg_, 42, NULL, new_tunnel, cleaner, handlers, types); |
1264 | cfg = cfg_; | 1263 | cfg = cfg_; |
1265 | restart_hijack = 0; | 1264 | restart_hijack = 0; |
1266 | hashmap = GNUNET_CONTAINER_multihashmap_create (65536); | 1265 | hashmap = GNUNET_CONTAINER_multihashmap_create (65536); |