aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorPhilipp Tölke <toelke@in.tum.de>2011-06-15 07:15:39 +0000
committerPhilipp Tölke <toelke@in.tum.de>2011-06-15 07:15:39 +0000
commit238b4ac9407e047a7a2d6f0c951e70ef6e400d82 (patch)
tree6ed40257e05d95ea3c8003e727101f035169bb11 /src/vpn
parent36ae035929059eccda334bdecdcc774d7e0f3496 (diff)
downloadgnunet-238b4ac9407e047a7a2d6f0c951e70ef6e400d82.tar.gz
gnunet-238b4ac9407e047a7a2d6f0c951e70ef6e400d82.zip
fix bugs found by compiling with -Wextra
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/gnunet-daemon-exit.c18
-rw-r--r--src/vpn/gnunet-daemon-vpn-helper.c1
-rw-r--r--src/vpn/gnunet-daemon-vpn.c5
-rw-r--r--src/vpn/gnunet-helper-vpn-api.c3
-rw-r--r--src/vpn/gnunet-helper-vpn-api.h4
-rw-r--r--src/vpn/gnunet-service-dns.c13
6 files changed, 23 insertions, 21 deletions
diff --git a/src/vpn/gnunet-daemon-exit.c b/src/vpn/gnunet-daemon-exit.c
index 87b795edd..0ee07fead 100644
--- a/src/vpn/gnunet-daemon-exit.c
+++ b/src/vpn/gnunet-daemon-exit.c
@@ -243,8 +243,7 @@ send_udp_to_peer_notify_callback (void *cls, size_t size, void *buf)
243 * @param version 4 or 6 243 * @param version 4 or 6
244 */ 244 */
245static void 245static void
246udp_from_helper (struct udp_pkt *udp, unsigned char *dadr, size_t addrlen, 246udp_from_helper (struct udp_pkt *udp, unsigned char *dadr, size_t addrlen)
247 unsigned int version)
248{ 247{
249 struct redirect_info u_i; 248 struct redirect_info u_i;
250 struct GNUNET_MESH_Tunnel *tunnel; 249 struct GNUNET_MESH_Tunnel *tunnel;
@@ -337,7 +336,7 @@ udp_from_helper (struct udp_pkt *udp, unsigned char *dadr, size_t addrlen,
337 */ 336 */
338static void 337static void
339tcp_from_helper (struct tcp_pkt *tcp, unsigned char *dadr, size_t addrlen, 338tcp_from_helper (struct tcp_pkt *tcp, unsigned char *dadr, size_t addrlen,
340 unsigned int version, size_t pktlen) 339 size_t pktlen)
341{ 340{
342 struct redirect_info u_i; 341 struct redirect_info u_i;
343 struct GNUNET_MESH_Tunnel *tunnel; 342 struct GNUNET_MESH_Tunnel *tunnel;
@@ -421,10 +420,10 @@ message_token (void *cls,
421 struct ip6_pkt *pkt6 = (struct ip6_pkt *) pkt_tun; 420 struct ip6_pkt *pkt6 = (struct ip6_pkt *) pkt_tun;
422 if (0x11 == pkt6->ip6_hdr.nxthdr) 421 if (0x11 == pkt6->ip6_hdr.nxthdr)
423 udp_from_helper (&((struct ip6_udp *) pkt6)->udp_hdr, 422 udp_from_helper (&((struct ip6_udp *) pkt6)->udp_hdr,
424 (unsigned char *) &pkt6->ip6_hdr.dadr, 16, 6); 423 (unsigned char *) &pkt6->ip6_hdr.dadr, 16);
425 else if (0x06 == pkt6->ip6_hdr.nxthdr) 424 else if (0x06 == pkt6->ip6_hdr.nxthdr)
426 tcp_from_helper (&((struct ip6_tcp *) pkt6)->tcp_hdr, 425 tcp_from_helper (&((struct ip6_tcp *) pkt6)->tcp_hdr,
427 (unsigned char *) &pkt6->ip6_hdr.dadr, 16, 6, 426 (unsigned char *) &pkt6->ip6_hdr.dadr, 16,
428 ntohs (pkt6->ip6_hdr.paylgth)); 427 ntohs (pkt6->ip6_hdr.paylgth));
429 } 428 }
430 else if (ntohs (pkt_tun->tun.type) == 0x0800) 429 else if (ntohs (pkt_tun->tun.type) == 0x0800)
@@ -433,7 +432,7 @@ message_token (void *cls,
433 uint32_t tmp = pkt4->ip_hdr.dadr; 432 uint32_t tmp = pkt4->ip_hdr.dadr;
434 if (0x11 == pkt4->ip_hdr.proto) 433 if (0x11 == pkt4->ip_hdr.proto)
435 udp_from_helper (&((struct ip_udp *) pkt4)->udp_hdr, 434 udp_from_helper (&((struct ip_udp *) pkt4)->udp_hdr,
436 (unsigned char *) &tmp, 4, 4); 435 (unsigned char *) &tmp, 4);
437 else if (0x06 == pkt4->ip_hdr.proto) 436 else if (0x06 == pkt4->ip_hdr.proto)
438 { 437 {
439 size_t pktlen = ntohs(pkt4->ip_hdr.tot_lngth); 438 size_t pktlen = ntohs(pkt4->ip_hdr.tot_lngth);
@@ -441,7 +440,7 @@ message_token (void *cls,
441 pktlen -= 4*pkt4->ip_hdr.hdr_lngth; 440 pktlen -= 4*pkt4->ip_hdr.hdr_lngth;
442 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "-hdr: %d\n", pktlen); 441 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "-hdr: %d\n", pktlen);
443 tcp_from_helper (&((struct ip_tcp *) pkt4)->tcp_hdr, 442 tcp_from_helper (&((struct ip_tcp *) pkt4)->tcp_hdr,
444 (unsigned char *) &tmp, 4, 4, pktlen); 443 (unsigned char *) &tmp, 4, pktlen);
445 } 444 }
446 } 445 }
447 else 446 else
@@ -634,7 +633,6 @@ start_helper_and_schedule(void *cls,
634 "exit-gnunet", 633 "exit-gnunet",
635 start_helper_and_schedule, 634 start_helper_and_schedule,
636 message_token, 635 message_token,
637 NULL,
638 NULL); 636 NULL);
639 637
640 GNUNET_free(ipv6addr); 638 GNUNET_free(ipv6addr);
@@ -1189,7 +1187,7 @@ run (void *cls,
1189 char *const *args, 1187 char *const *args,
1190 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg_) 1188 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg_)
1191{ 1189{
1192 const static struct GNUNET_MESH_MessageHandler handlers[] = { 1190 static const struct GNUNET_MESH_MessageHandler handlers[] = {
1193 {receive_udp_service, GNUNET_MESSAGE_TYPE_SERVICE_UDP, 0}, 1191 {receive_udp_service, GNUNET_MESSAGE_TYPE_SERVICE_UDP, 0},
1194 {receive_tcp_service, GNUNET_MESSAGE_TYPE_SERVICE_TCP, 0}, 1192 {receive_tcp_service, GNUNET_MESSAGE_TYPE_SERVICE_TCP, 0},
1195 {receive_udp_remote, GNUNET_MESSAGE_TYPE_REMOTE_UDP, 0}, 1193 {receive_udp_remote, GNUNET_MESSAGE_TYPE_REMOTE_UDP, 0},
@@ -1197,7 +1195,7 @@ run (void *cls,
1197 {NULL, 0, 0} 1195 {NULL, 0, 0}
1198 }; 1196 };
1199 1197
1200 const static GNUNET_MESH_ApplicationType apptypes[] = 1198 static const GNUNET_MESH_ApplicationType apptypes[] =
1201 { 1199 {
1202 GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY, 1200 GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY,
1203 GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY, 1201 GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY,
diff --git a/src/vpn/gnunet-daemon-vpn-helper.c b/src/vpn/gnunet-daemon-vpn-helper.c
index 1c7ee7987..100f08c97 100644
--- a/src/vpn/gnunet-daemon-vpn-helper.c
+++ b/src/vpn/gnunet-daemon-vpn-helper.c
@@ -111,7 +111,6 @@ start_helper_and_schedule(void *cls,
111 "vpn-gnunet", 111 "vpn-gnunet",
112 start_helper_and_schedule, 112 start_helper_and_schedule,
113 message_token, 113 message_token,
114 NULL,
115 NULL); 114 NULL);
116 115
117 GNUNET_free(ipv6addr); 116 GNUNET_free(ipv6addr);
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c
index 49a33a7bb..1be010685 100644
--- a/src/vpn/gnunet-daemon-vpn.c
+++ b/src/vpn/gnunet-daemon-vpn.c
@@ -275,6 +275,9 @@ new_ip6addr_remote (unsigned char *buf, unsigned char *addr, char addrlen)
275 */ 275 */
276void 276void
277process_answer(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tc) { 277process_answer(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tc) {
278 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
279 return;
280
278 struct answer_packet* pkt = cls; 281 struct answer_packet* pkt = cls;
279 struct answer_packet_list* list; 282 struct answer_packet_list* list;
280 283
@@ -701,7 +704,7 @@ run (void *cls,
701 const char *cfgfile, 704 const char *cfgfile,
702 const struct GNUNET_CONFIGURATION_Handle *cfg_) 705 const struct GNUNET_CONFIGURATION_Handle *cfg_)
703{ 706{
704 const static struct GNUNET_MESH_MessageHandler handlers[] = { 707 static const struct GNUNET_MESH_MessageHandler handlers[] = {
705 {receive_udp_back, GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK, 0}, 708 {receive_udp_back, GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK, 0},
706 {receive_tcp_back, GNUNET_MESSAGE_TYPE_SERVICE_TCP_BACK, 0}, 709 {receive_tcp_back, GNUNET_MESSAGE_TYPE_SERVICE_TCP_BACK, 0},
707 {receive_udp_back, GNUNET_MESSAGE_TYPE_REMOTE_UDP_BACK, 0}, 710 {receive_udp_back, GNUNET_MESSAGE_TYPE_REMOTE_UDP_BACK, 0},
diff --git a/src/vpn/gnunet-helper-vpn-api.c b/src/vpn/gnunet-helper-vpn-api.c
index 5736df2b1..195a79217 100644
--- a/src/vpn/gnunet-helper-vpn-api.c
+++ b/src/vpn/gnunet-helper-vpn-api.c
@@ -109,8 +109,7 @@ start_helper (const char *ifname,
109 const char *ipv4addr, 109 const char *ipv4addr,
110 const char *ipv4mask, const char *process_name, 110 const char *ipv4mask, const char *process_name,
111 GNUNET_SCHEDULER_Task restart_task, 111 GNUNET_SCHEDULER_Task restart_task,
112 GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls, 112 GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls)
113 void *client)
114{ 113{
115 struct GNUNET_VPN_HELPER_Handle *handle = 114 struct GNUNET_VPN_HELPER_Handle *handle =
116 GNUNET_malloc (sizeof (struct GNUNET_VPN_HELPER_Handle)); 115 GNUNET_malloc (sizeof (struct GNUNET_VPN_HELPER_Handle));
diff --git a/src/vpn/gnunet-helper-vpn-api.h b/src/vpn/gnunet-helper-vpn-api.h
index 00eb7db62..4e8f76611 100644
--- a/src/vpn/gnunet-helper-vpn-api.h
+++ b/src/vpn/gnunet-helper-vpn-api.h
@@ -92,7 +92,6 @@ struct GNUNET_VPN_HELPER_Handle
92 * @param restart_task The task called when the helper dies. Will be called with the handle as cls 92 * @param restart_task The task called when the helper dies. Will be called with the handle as cls
93 * @param cb A callback for messages from the helper 93 * @param cb A callback for messages from the helper
94 * @param cb_cls Closure for the callback 94 * @param cb_cls Closure for the callback
95 * @param client client_name for the callback
96 * 95 *
97 * @return A pointer to the new Handle, NULL on error 96 * @return A pointer to the new Handle, NULL on error
98 */ 97 */
@@ -105,8 +104,7 @@ struct GNUNET_VPN_HELPER_Handle *start_helper (const char *ifname,
105 GNUNET_SCHEDULER_Task 104 GNUNET_SCHEDULER_Task
106 restart_task, 105 restart_task,
107 GNUNET_SERVER_MessageTokenizerCallback 106 GNUNET_SERVER_MessageTokenizerCallback
108 cb, void *cb_cls, 107 cb, void *cb_cls);
109 void *client);
110 108
111/** 109/**
112 * @brief Kills the helper, closes the pipe and free()s the handle 110 * @brief Kills the helper, closes the pipe and free()s the handle
diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c
index 9ee63bbda..7b96a180d 100644
--- a/src/vpn/gnunet-service-dns.c
+++ b/src/vpn/gnunet-service-dns.c
@@ -113,6 +113,9 @@ struct receive_dht_cls {
113static void 113static void
114hijack (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 114hijack (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
115{ 115{
116 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
117 return;
118
116 char port_s[6]; 119 char port_s[6];
117 char *virt_dns; 120 char *virt_dns;
118 struct GNUNET_OS_Process *proc; 121 struct GNUNET_OS_Process *proc;
@@ -197,8 +200,8 @@ send_answer(void* cls, size_t size, void* buf) {
197 200
198struct tunnel_cls { 201struct tunnel_cls {
199 struct GNUNET_MESH_Tunnel *tunnel GNUNET_PACKED; 202 struct GNUNET_MESH_Tunnel *tunnel GNUNET_PACKED;
200 struct GNUNET_MessageHeader hdr GNUNET_PACKED; 203 struct GNUNET_MessageHeader hdr;
201 struct dns_pkt dns GNUNET_PACKED; 204 struct dns_pkt dns;
202}; 205};
203 206
204struct tunnel_cls *remote_pending[UINT16_MAX]; 207struct tunnel_cls *remote_pending[UINT16_MAX];
@@ -704,7 +707,7 @@ receive_query(void *cls,
704 } 707 }
705 708
706 char* virt_dns; 709 char* virt_dns;
707 int virt_dns_bytes; 710 unsigned int virt_dns_bytes;
708 if (GNUNET_SYSERR == 711 if (GNUNET_SYSERR ==
709 GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "VIRTDNS", 712 GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "VIRTDNS",
710 &virt_dns)) 713 &virt_dns))
@@ -899,6 +902,8 @@ static void
899cleanup_task (void *cls, 902cleanup_task (void *cls,
900 const struct GNUNET_SCHEDULER_TaskContext *tc) 903 const struct GNUNET_SCHEDULER_TaskContext *tc)
901{ 904{
905 GNUNET_assert(0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN));
906
902 unhijack(dnsoutport); 907 unhijack(dnsoutport);
903 GNUNET_DHT_disconnect(dht); 908 GNUNET_DHT_disconnect(dht);
904} 909}
@@ -1156,7 +1161,7 @@ run (void *cls,
1156 {NULL, 0, 0} 1161 {NULL, 0, 0}
1157 }; 1162 };
1158 1163
1159 const static GNUNET_MESH_ApplicationType apptypes[] = 1164 static const GNUNET_MESH_ApplicationType apptypes[] =
1160 { GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER, 1165 { GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER,
1161 GNUNET_APPLICATION_TYPE_END 1166 GNUNET_APPLICATION_TYPE_END
1162 }; 1167 };