aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Tölke <toelke@in.tum.de>2011-10-26 15:40:02 +0000
committerPhilipp Tölke <toelke@in.tum.de>2011-10-26 15:40:02 +0000
commit4077ba3bd186016d46db0421e67b509cf9733024 (patch)
tree981ef89a8c2823976b3693cb01ee8aa312349f13 /src
parent4a26bf8d9186f7e79076cbe6228d7b73258ec7b2 (diff)
downloadgnunet-4077ba3bd186016d46db0421e67b509cf9733024.tar.gz
gnunet-4077ba3bd186016d46db0421e67b509cf9733024.zip
save at the tunnel whether this is an ipv4 or ipv6 connection
Diffstat (limited to 'src')
-rw-r--r--src/vpn/gnunet-daemon-vpn-helper.c13
-rw-r--r--src/vpn/gnunet-daemon-vpn.c19
-rw-r--r--src/vpn/gnunet-daemon-vpn.h6
3 files changed, 29 insertions, 9 deletions
diff --git a/src/vpn/gnunet-daemon-vpn-helper.c b/src/vpn/gnunet-daemon-vpn-helper.c
index c3cc4bc91..a91a0591f 100644
--- a/src/vpn/gnunet-daemon-vpn-helper.c
+++ b/src/vpn/gnunet-daemon-vpn-helper.c
@@ -152,6 +152,15 @@ start_helper_and_schedule (void *cls,
152 152
153/*}}}*/ 153/*}}}*/
154 154
155void
156initialize_tunnel_state(struct GNUNET_MESH_Tunnel* tunnel, int addrlen, struct GNUNET_MESH_TransmitHandle* th)
157{
158 struct tunnel_state* ts = GNUNET_malloc(sizeof *ts);
159 ts->addrlen = addrlen;
160 ts->th = th;
161 GNUNET_MESH_tunnel_set_data(tunnel, ts);
162}
163
155/** 164/**
156 * Send an dns-answer-packet to the helper 165 * Send an dns-answer-packet to the helper
157 */ 166 */
@@ -424,6 +433,7 @@ message_token (void *cls __attribute__ ((unused)), void *client
424 send_pkt_to_peer, NULL, 433 send_pkt_to_peer, NULL,
425 cls); 434 cls);
426 me->tunnel = *cls; 435 me->tunnel = *cls;
436 initialize_tunnel_state(me->tunnel, 16, NULL);
427 } 437 }
428 else if (NULL != cls) 438 else if (NULL != cls)
429 { 439 {
@@ -471,6 +481,7 @@ message_token (void *cls __attribute__ ((unused)), void *client
471 send_pkt_to_peer, 481 send_pkt_to_peer,
472 NULL, cls); 482 NULL, cls);
473 me->tunnel = *cls; 483 me->tunnel = *cls;
484 initialize_tunnel_state(me->tunnel, 16, NULL);
474 if (GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY == app_type) 485 if (GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY == app_type)
475 udp_tunnel = *cls; 486 udp_tunnel = *cls;
476 else if (GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY == app_type) 487 else if (GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY == app_type)
@@ -627,6 +638,7 @@ message_token (void *cls __attribute__ ((unused)), void *client
627 send_pkt_to_peer, NULL, 638 send_pkt_to_peer, NULL,
628 cls); 639 cls);
629 me->tunnel = *cls; 640 me->tunnel = *cls;
641 initialize_tunnel_state(me->tunnel, 4, NULL);
630 } 642 }
631 else if (NULL != cls) 643 else if (NULL != cls)
632 { 644 {
@@ -670,6 +682,7 @@ message_token (void *cls __attribute__ ((unused)), void *client
670 send_pkt_to_peer, 682 send_pkt_to_peer,
671 NULL, cls); 683 NULL, cls);
672 me->tunnel = *cls; 684 me->tunnel = *cls;
685 initialize_tunnel_state(me->tunnel, 4, NULL);
673 } 686 }
674 else if (NULL != cls) 687 else if (NULL != cls)
675 { 688 {
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c
index a6d051e9c..bd5938604 100644
--- a/src/vpn/gnunet-daemon-vpn.c
+++ b/src/vpn/gnunet-daemon-vpn.c
@@ -282,7 +282,8 @@ send_pkt_to_peer_notify_callback (void *cls, size_t size, void *buf)
282{ 282{
283 struct GNUNET_MESH_Tunnel **tunnel = cls; 283 struct GNUNET_MESH_Tunnel **tunnel = cls;
284 284
285 GNUNET_MESH_tunnel_set_data (*tunnel, NULL); 285 struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(*tunnel);
286 ts->th = NULL;
286 287
287 if (NULL != buf) 288 if (NULL != buf)
288 { 289 {
@@ -310,7 +311,7 @@ send_pkt_to_peer_notify_callback (void *cls, size_t size, void *buf)
310 GNUNET_MESH_tunnel_set_head (*tunnel, head); 311 GNUNET_MESH_tunnel_set_head (*tunnel, head);
311 GNUNET_MESH_tunnel_set_tail (*tunnel, tail); 312 GNUNET_MESH_tunnel_set_tail (*tunnel, tail);
312 313
313 struct GNUNET_MESH_TransmitHandle *th = 314 ts->th =
314 GNUNET_MESH_notify_transmit_ready (*tunnel, 315 GNUNET_MESH_notify_transmit_ready (*tunnel,
315 GNUNET_NO, 316 GNUNET_NO,
316 42, 317 42,
@@ -322,7 +323,6 @@ send_pkt_to_peer_notify_callback (void *cls, size_t size, void *buf)
322 element->cls); 323 element->cls);
323 324
324 /* save the handle */ 325 /* save the handle */
325 GNUNET_MESH_tunnel_set_data (*tunnel, th);
326 GNUNET_free (element); 326 GNUNET_free (element);
327 } 327 }
328 GNUNET_free (cls); 328 GNUNET_free (cls);
@@ -355,9 +355,10 @@ send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer,
355 GNUNET_assert (NULL != tunnel); 355 GNUNET_assert (NULL != tunnel);
356 GNUNET_assert (NULL != *tunnel); 356 GNUNET_assert (NULL != *tunnel);
357 357
358 if (NULL == GNUNET_MESH_tunnel_get_data (*tunnel)) 358 struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(*tunnel);
359 if (NULL == ts->th)
359 { 360 {
360 struct GNUNET_MESH_TransmitHandle *th = 361 ts->th =
361 GNUNET_MESH_notify_transmit_ready (*tunnel, 362 GNUNET_MESH_notify_transmit_ready (*tunnel,
362 GNUNET_NO, 363 GNUNET_NO,
363 42, 364 42,
@@ -368,8 +369,6 @@ send_pkt_to_peer (void *cls, const struct GNUNET_PeerIdentity *peer,
368 ntohs (hdr->size), 369 ntohs (hdr->size),
369 send_pkt_to_peer_notify_callback, 370 send_pkt_to_peer_notify_callback,
370 cls); 371 cls);
371
372 GNUNET_MESH_tunnel_set_data (*tunnel, th);
373 } 372 }
374 else 373 else
375 { 374 {
@@ -882,8 +881,9 @@ receive_udp_back (void *cls
882 struct remote_addr *s = (struct remote_addr *) desc; 881 struct remote_addr *s = (struct remote_addr *) desc;
883 struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1); 882 struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1);
884 const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel); 883 const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel);
884 struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(tunnel);
885 885
886 if (16 == s->addrlen) 886 if (16 == ts->addrlen)
887 { 887 {
888 size_t size = 888 size_t size =
889 sizeof (struct ip6_udp) + ntohs (pkt->len) - 1 - 889 sizeof (struct ip6_udp) + ntohs (pkt->len) - 1 -
@@ -1063,6 +1063,7 @@ receive_tcp_back (void *cls
1063 struct remote_addr *s = (struct remote_addr *) desc; 1063 struct remote_addr *s = (struct remote_addr *) desc;
1064 struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1); 1064 struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1);
1065 const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel); 1065 const struct GNUNET_PeerIdentity *other = GNUNET_MESH_get_peer (tunnel);
1066 struct tunnel_state *ts = GNUNET_MESH_tunnel_get_data(tunnel);
1066 1067
1067 size_t pktlen = 1068 size_t pktlen =
1068 ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) - 1069 ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) -
@@ -1071,7 +1072,7 @@ receive_tcp_back (void *cls
1071 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received TCP-Packet back, addrlen = %d\n", s->addrlen); 1072 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received TCP-Packet back, addrlen = %d\n", s->addrlen);
1072 1073
1073 if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_VPN_SERVICE_TCP_BACK || 1074 if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_VPN_SERVICE_TCP_BACK ||
1074 s->addrlen == 16) 1075 ts->addrlen == 16)
1075 { 1076 {
1076 size_t size = pktlen + sizeof (struct ip6_tcp) - 1; 1077 size_t size = pktlen + sizeof (struct ip6_tcp) - 1;
1077 1078
diff --git a/src/vpn/gnunet-daemon-vpn.h b/src/vpn/gnunet-daemon-vpn.h
index 7d3b0e68a..641be914d 100644
--- a/src/vpn/gnunet-daemon-vpn.h
+++ b/src/vpn/gnunet-daemon-vpn.h
@@ -129,4 +129,10 @@ struct remote_addr
129 char proto; 129 char proto;
130}; 130};
131 131
132struct tunnel_state
133{
134 struct GNUNET_MESH_TransmitHandle *th;
135 int addrlen;
136};
137
132#endif /* end of include guard: GNUNET-DAEMON-VPN_H */ 138#endif /* end of include guard: GNUNET-DAEMON-VPN_H */