diff options
Diffstat (limited to 'src/vpn/gnunet-daemon-exit.c')
-rw-r--r-- | src/vpn/gnunet-daemon-exit.c | 121 |
1 files changed, 58 insertions, 63 deletions
diff --git a/src/vpn/gnunet-daemon-exit.c b/src/vpn/gnunet-daemon-exit.c index de906af3b..324c136b0 100644 --- a/src/vpn/gnunet-daemon-exit.c +++ b/src/vpn/gnunet-daemon-exit.c | |||
@@ -522,8 +522,7 @@ tcp_from_helper (struct tcp_pkt *tcp, unsigned char *dadr, size_t addrlen, | |||
522 | * Receive packets from the helper-process | 522 | * Receive packets from the helper-process |
523 | */ | 523 | */ |
524 | static void | 524 | static void |
525 | message_token (void *cls __attribute__ ((unused)), | 525 | message_token (void *cls __attribute__ ((unused)), void *client |
526 | void *client | ||
527 | __attribute__ ((unused)), | 526 | __attribute__ ((unused)), |
528 | const struct GNUNET_MessageHeader *message) | 527 | const struct GNUNET_MessageHeader *message) |
529 | { | 528 | { |
@@ -612,8 +611,8 @@ read_service_conf (void *cls __attribute__ ((unused)), const char *section) | |||
612 | "TCP_REDIRECTS", &cpy))) | 611 | "TCP_REDIRECTS", &cpy))) |
613 | goto next; | 612 | goto next; |
614 | 613 | ||
615 | for (redirect = strtok (cpy, " "); redirect != NULL; redirect = strtok | 614 | for (redirect = strtok (cpy, " "); redirect != NULL; |
616 | (NULL, " ")) | 615 | redirect = strtok (NULL, " ")) |
617 | { | 616 | { |
618 | if (NULL == (hostname = strstr (redirect, ":"))) | 617 | if (NULL == (hostname = strstr (redirect, ":"))) |
619 | { | 618 | { |
@@ -654,8 +653,7 @@ read_service_conf (void *cls __attribute__ ((unused)), const char *section) | |||
654 | char *ip4addr; | 653 | char *ip4addr; |
655 | 654 | ||
656 | GNUNET_assert (GNUNET_OK == | 655 | GNUNET_assert (GNUNET_OK == |
657 | GNUNET_CONFIGURATION_get_value_string (cfg, | 656 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", |
658 | "exit", | ||
659 | "IPV4ADDR", | 657 | "IPV4ADDR", |
660 | &ip4addr)); | 658 | &ip4addr)); |
661 | GNUNET_assert (1 == inet_pton (AF_INET, ip4addr, serv->v4.ip4address)); | 659 | GNUNET_assert (1 == inet_pton (AF_INET, ip4addr, serv->v4.ip4address)); |
@@ -668,8 +666,7 @@ read_service_conf (void *cls __attribute__ ((unused)), const char *section) | |||
668 | char *ip6addr; | 666 | char *ip6addr; |
669 | 667 | ||
670 | GNUNET_assert (GNUNET_OK == | 668 | GNUNET_assert (GNUNET_OK == |
671 | GNUNET_CONFIGURATION_get_value_string (cfg, | 669 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", |
672 | "exit", | ||
673 | "IPV6ADDR", | 670 | "IPV6ADDR", |
674 | &ip6addr)); | 671 | &ip6addr)); |
675 | GNUNET_assert (1 == inet_pton (AF_INET6, ip6addr, serv->v6.ip6address)); | 672 | GNUNET_assert (1 == inet_pton (AF_INET6, ip6addr, serv->v6.ip6address)); |
@@ -774,13 +771,10 @@ start_helper_and_schedule (void *cls, | |||
774 | * When the helper dies, this function will be called again with the | 771 | * When the helper dies, this function will be called again with the |
775 | * helper_handle as cls. | 772 | * helper_handle as cls. |
776 | */ | 773 | */ |
777 | helper_handle = start_helper (ifname, | 774 | helper_handle = |
778 | ipv6addr, | 775 | start_helper (ifname, ipv6addr, ipv6prefix, ipv4addr, ipv4mask, |
779 | ipv6prefix, | 776 | "exit-gnunet", start_helper_and_schedule, message_token, |
780 | ipv4addr, | 777 | NULL); |
781 | ipv4mask, | ||
782 | "exit-gnunet", | ||
783 | start_helper_and_schedule, message_token, NULL); | ||
784 | 778 | ||
785 | GNUNET_free (ipv6addr); | 779 | GNUNET_free (ipv6addr); |
786 | GNUNET_free (ipv6prefix); | 780 | GNUNET_free (ipv6prefix); |
@@ -822,11 +816,11 @@ prepare_ipv4_packet (ssize_t len, ssize_t pktlen, void *payload, | |||
822 | char *ipv4mask; | 816 | char *ipv4mask; |
823 | 817 | ||
824 | GNUNET_assert (GNUNET_OK == | 818 | GNUNET_assert (GNUNET_OK == |
825 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", | 819 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4ADDR", |
826 | "IPV4ADDR", &ipv4addr)); | 820 | &ipv4addr)); |
827 | GNUNET_assert (GNUNET_OK == | 821 | GNUNET_assert (GNUNET_OK == |
828 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", | 822 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4MASK", |
829 | "IPV4MASK", &ipv4mask)); | 823 | &ipv4mask)); |
830 | inet_pton (AF_INET, ipv4addr, &tmp); | 824 | inet_pton (AF_INET, ipv4addr, &tmp); |
831 | inet_pton (AF_INET, ipv4mask, &tmp2); | 825 | inet_pton (AF_INET, ipv4mask, &tmp2); |
832 | GNUNET_free (ipv4addr); | 826 | GNUNET_free (ipv4addr); |
@@ -910,8 +904,8 @@ prepare_ipv6_packet (ssize_t len, ssize_t pktlen, void *payload, | |||
910 | unsigned long long ipv6prefix; | 904 | unsigned long long ipv6prefix; |
911 | 905 | ||
912 | GNUNET_assert (GNUNET_OK == | 906 | GNUNET_assert (GNUNET_OK == |
913 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", | 907 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV6ADDR", |
914 | "IPV6ADDR", &ipv6addr)); | 908 | &ipv6addr)); |
915 | GNUNET_assert (GNUNET_OK == | 909 | GNUNET_assert (GNUNET_OK == |
916 | GNUNET_CONFIGURATION_get_value_number (cfg, "exit", | 910 | GNUNET_CONFIGURATION_get_value_number (cfg, "exit", |
917 | "IPV6PREFIX", | 911 | "IPV6PREFIX", |
@@ -987,9 +981,10 @@ prepare_ipv6_packet (ssize_t len, ssize_t pktlen, void *payload, | |||
987 | * The messages are one GNUNET_HashCode for the service followed by a struct tcp_pkt | 981 | * The messages are one GNUNET_HashCode for the service followed by a struct tcp_pkt |
988 | */ | 982 | */ |
989 | static int | 983 | static int |
990 | receive_tcp_service (void *cls __attribute__ ((unused)), | 984 | receive_tcp_service (void *cls |
991 | struct GNUNET_MESH_Tunnel *tunnel, | 985 | __attribute__ ((unused)), |
992 | void **tunnel_ctx __attribute__ ((unused)), | 986 | struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx |
987 | __attribute__ ((unused)), | ||
993 | const struct GNUNET_PeerIdentity *sender | 988 | const struct GNUNET_PeerIdentity *sender |
994 | __attribute__ ((unused)), | 989 | __attribute__ ((unused)), |
995 | const struct GNUNET_MessageHeader *message, | 990 | const struct GNUNET_MessageHeader *message, |
@@ -999,9 +994,9 @@ receive_tcp_service (void *cls __attribute__ ((unused)), | |||
999 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received TCP-Packet\n"); | 994 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received TCP-Packet\n"); |
1000 | GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); | 995 | GNUNET_HashCode *desc = (GNUNET_HashCode *) (message + 1); |
1001 | struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1); | 996 | struct tcp_pkt *pkt = (struct tcp_pkt *) (desc + 1); |
1002 | unsigned int pkt_len = ntohs (message->size) - sizeof (struct | 997 | unsigned int pkt_len = |
1003 | GNUNET_MessageHeader) | 998 | ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) - |
1004 | - sizeof (GNUNET_HashCode); | 999 | sizeof (GNUNET_HashCode); |
1005 | 1000 | ||
1006 | /** Get the configuration from the services-hashmap. | 1001 | /** Get the configuration from the services-hashmap. |
1007 | * | 1002 | * |
@@ -1018,8 +1013,8 @@ receive_tcp_service (void *cls __attribute__ ((unused)), | |||
1018 | 1013 | ||
1019 | if (NULL == serv) | 1014 | if (NULL == serv) |
1020 | { | 1015 | { |
1021 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1016 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "No service found for TCP dpt %d!\n", |
1022 | "No service found for TCP dpt %d!\n", *tcp_desc); | 1017 | *tcp_desc); |
1023 | return GNUNET_YES; | 1018 | return GNUNET_YES; |
1024 | } | 1019 | } |
1025 | 1020 | ||
@@ -1045,7 +1040,8 @@ receive_tcp_service (void *cls __attribute__ ((unused)), | |||
1045 | state->hashmap = tcp_connections; | 1040 | state->hashmap = tcp_connections; |
1046 | memcpy (&state->desc, desc, sizeof (GNUNET_HashCode)); | 1041 | memcpy (&state->desc, desc, sizeof (GNUNET_HashCode)); |
1047 | 1042 | ||
1048 | len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + | 1043 | len = |
1044 | sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + | ||
1049 | sizeof (struct ip6_hdr) + pkt_len; | 1045 | sizeof (struct ip6_hdr) + pkt_len; |
1050 | buf = alloca (len); | 1046 | buf = alloca (len); |
1051 | 1047 | ||
@@ -1055,13 +1051,13 @@ receive_tcp_service (void *cls __attribute__ ((unused)), | |||
1055 | { | 1051 | { |
1056 | case 4: | 1052 | case 4: |
1057 | prepare_ipv4_packet (len, pkt_len, pkt, 0x06, /* TCP */ | 1053 | prepare_ipv4_packet (len, pkt_len, pkt, 0x06, /* TCP */ |
1058 | &serv->v4.ip4address, | 1054 | &serv->v4.ip4address, tunnel, state, |
1059 | tunnel, state, (struct ip_pkt *) buf); | 1055 | (struct ip_pkt *) buf); |
1060 | break; | 1056 | break; |
1061 | case 6: | 1057 | case 6: |
1062 | prepare_ipv6_packet (len, pkt_len, pkt, 0x06, /* TCP */ | 1058 | prepare_ipv6_packet (len, pkt_len, pkt, 0x06, /* TCP */ |
1063 | &serv->v6.ip6address, | 1059 | &serv->v6.ip6address, tunnel, state, |
1064 | tunnel, state, (struct ip6_pkt *) buf); | 1060 | (struct ip6_pkt *) buf); |
1065 | 1061 | ||
1066 | break; | 1062 | break; |
1067 | default: | 1063 | default: |
@@ -1094,9 +1090,10 @@ receive_tcp_service (void *cls __attribute__ ((unused)), | |||
1094 | } | 1090 | } |
1095 | 1091 | ||
1096 | static int | 1092 | static int |
1097 | receive_tcp_remote (void *cls __attribute__ ((unused)), | 1093 | receive_tcp_remote (void *cls |
1098 | struct GNUNET_MESH_Tunnel *tunnel, | 1094 | __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel, |
1099 | void **tunnel_ctx __attribute__ ((unused)), | 1095 | void **tunnel_ctx |
1096 | __attribute__ ((unused)), | ||
1100 | const struct GNUNET_PeerIdentity *sender | 1097 | const struct GNUNET_PeerIdentity *sender |
1101 | __attribute__ ((unused)), | 1098 | __attribute__ ((unused)), |
1102 | const struct GNUNET_MessageHeader *message, | 1099 | const struct GNUNET_MessageHeader *message, |
@@ -1120,7 +1117,8 @@ receive_tcp_remote (void *cls __attribute__ ((unused)), | |||
1120 | state->hashmap = tcp_connections; | 1117 | state->hashmap = tcp_connections; |
1121 | memcpy (&state->remote, s, sizeof (struct remote_addr)); | 1118 | memcpy (&state->remote, s, sizeof (struct remote_addr)); |
1122 | 1119 | ||
1123 | len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + | 1120 | len = |
1121 | sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + | ||
1124 | sizeof (struct ip6_hdr) + pkt_len; | 1122 | sizeof (struct ip6_hdr) + pkt_len; |
1125 | buf = alloca (len); | 1123 | buf = alloca (len); |
1126 | 1124 | ||
@@ -1169,9 +1167,10 @@ receive_tcp_remote (void *cls __attribute__ ((unused)), | |||
1169 | } | 1167 | } |
1170 | 1168 | ||
1171 | static int | 1169 | static int |
1172 | receive_udp_remote (void *cls __attribute__ ((unused)), | 1170 | receive_udp_remote (void *cls |
1173 | struct GNUNET_MESH_Tunnel *tunnel, | 1171 | __attribute__ ((unused)), struct GNUNET_MESH_Tunnel *tunnel, |
1174 | void **tunnel_ctx __attribute__ ((unused)), | 1172 | void **tunnel_ctx |
1173 | __attribute__ ((unused)), | ||
1175 | const struct GNUNET_PeerIdentity *sender | 1174 | const struct GNUNET_PeerIdentity *sender |
1176 | __attribute__ ((unused)), | 1175 | __attribute__ ((unused)), |
1177 | const struct GNUNET_MessageHeader *message, | 1176 | const struct GNUNET_MessageHeader *message, |
@@ -1185,8 +1184,7 @@ receive_udp_remote (void *cls __attribute__ ((unused)), | |||
1185 | size_t len; | 1184 | size_t len; |
1186 | 1185 | ||
1187 | GNUNET_assert (ntohs (pkt->len) == | 1186 | GNUNET_assert (ntohs (pkt->len) == |
1188 | ntohs (message->size) - | 1187 | ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) - |
1189 | sizeof (struct GNUNET_MessageHeader) - | ||
1190 | sizeof (GNUNET_HashCode)); | 1188 | sizeof (GNUNET_HashCode)); |
1191 | 1189 | ||
1192 | /* Prepare the state. | 1190 | /* Prepare the state. |
@@ -1201,7 +1199,8 @@ receive_udp_remote (void *cls __attribute__ ((unused)), | |||
1201 | state->type = REMOTE; | 1199 | state->type = REMOTE; |
1202 | memcpy (&state->remote, s, sizeof (struct remote_addr)); | 1200 | memcpy (&state->remote, s, sizeof (struct remote_addr)); |
1203 | 1201 | ||
1204 | len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + | 1202 | len = |
1203 | sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + | ||
1205 | sizeof (struct ip6_hdr) + ntohs (pkt->len); | 1204 | sizeof (struct ip6_hdr) + ntohs (pkt->len); |
1206 | buf = alloca (len); | 1205 | buf = alloca (len); |
1207 | 1206 | ||
@@ -1249,9 +1248,10 @@ receive_udp_remote (void *cls __attribute__ ((unused)), | |||
1249 | * The messages are one GNUNET_HashCode for the service, followed by a struct udp_pkt | 1248 | * The messages are one GNUNET_HashCode for the service, followed by a struct udp_pkt |
1250 | */ | 1249 | */ |
1251 | static int | 1250 | static int |
1252 | receive_udp_service (void *cls __attribute__ ((unused)), | 1251 | receive_udp_service (void *cls |
1253 | struct GNUNET_MESH_Tunnel *tunnel, | 1252 | __attribute__ ((unused)), |
1254 | void **tunnel_ctx __attribute__ ((unused)), | 1253 | struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx |
1254 | __attribute__ ((unused)), | ||
1255 | const struct GNUNET_PeerIdentity *sender | 1255 | const struct GNUNET_PeerIdentity *sender |
1256 | __attribute__ ((unused)), | 1256 | __attribute__ ((unused)), |
1257 | const struct GNUNET_MessageHeader *message, | 1257 | const struct GNUNET_MessageHeader *message, |
@@ -1262,8 +1262,7 @@ receive_udp_service (void *cls __attribute__ ((unused)), | |||
1262 | struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1); | 1262 | struct udp_pkt *pkt = (struct udp_pkt *) (desc + 1); |
1263 | 1263 | ||
1264 | GNUNET_assert (ntohs (pkt->len) == | 1264 | GNUNET_assert (ntohs (pkt->len) == |
1265 | ntohs (message->size) - | 1265 | ntohs (message->size) - sizeof (struct GNUNET_MessageHeader) - |
1266 | sizeof (struct GNUNET_MessageHeader) - | ||
1267 | sizeof (GNUNET_HashCode)); | 1266 | sizeof (GNUNET_HashCode)); |
1268 | 1267 | ||
1269 | /* Get the configuration from the hashmap */ | 1268 | /* Get the configuration from the hashmap */ |
@@ -1277,8 +1276,8 @@ receive_udp_service (void *cls __attribute__ ((unused)), | |||
1277 | 1276 | ||
1278 | if (NULL == serv) | 1277 | if (NULL == serv) |
1279 | { | 1278 | { |
1280 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1279 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "No service found for UDP dpt %d!\n", |
1281 | "No service found for UDP dpt %d!\n", *udp_desc); | 1280 | *udp_desc); |
1282 | return GNUNET_YES; | 1281 | return GNUNET_YES; |
1283 | } | 1282 | } |
1284 | 1283 | ||
@@ -1304,7 +1303,8 @@ receive_udp_service (void *cls __attribute__ ((unused)), | |||
1304 | state->hashmap = udp_connections; | 1303 | state->hashmap = udp_connections; |
1305 | memcpy (&state->desc, desc, sizeof (GNUNET_HashCode)); | 1304 | memcpy (&state->desc, desc, sizeof (GNUNET_HashCode)); |
1306 | 1305 | ||
1307 | len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + | 1306 | len = |
1307 | sizeof (struct GNUNET_MessageHeader) + sizeof (struct pkt_tun) + | ||
1308 | sizeof (struct ip6_hdr) + ntohs (pkt->len); | 1308 | sizeof (struct ip6_hdr) + ntohs (pkt->len); |
1309 | buf = alloca (len); | 1309 | buf = alloca (len); |
1310 | 1310 | ||
@@ -1314,13 +1314,13 @@ receive_udp_service (void *cls __attribute__ ((unused)), | |||
1314 | { | 1314 | { |
1315 | case 4: | 1315 | case 4: |
1316 | prepare_ipv4_packet (len, ntohs (pkt->len), pkt, 0x11, /* UDP */ | 1316 | prepare_ipv4_packet (len, ntohs (pkt->len), pkt, 0x11, /* UDP */ |
1317 | &serv->v4.ip4address, | 1317 | &serv->v4.ip4address, tunnel, state, |
1318 | tunnel, state, (struct ip_pkt *) buf); | 1318 | (struct ip_pkt *) buf); |
1319 | break; | 1319 | break; |
1320 | case 6: | 1320 | case 6: |
1321 | prepare_ipv6_packet (len, ntohs (pkt->len), pkt, 0x11, /* UDP */ | 1321 | prepare_ipv6_packet (len, ntohs (pkt->len), pkt, 0x11, /* UDP */ |
1322 | &serv->v6.ip6address, | 1322 | &serv->v6.ip6address, tunnel, state, |
1323 | tunnel, state, (struct ip6_pkt *) buf); | 1323 | (struct ip6_pkt *) buf); |
1324 | 1324 | ||
1325 | break; | 1325 | break; |
1326 | default: | 1326 | default: |
@@ -1410,9 +1410,7 @@ connect_to_mesh () | |||
1410 | * @param cfg_ configuration | 1410 | * @param cfg_ configuration |
1411 | */ | 1411 | */ |
1412 | static void | 1412 | static void |
1413 | run (void *cls, | 1413 | run (void *cls, char *const *args __attribute__ ((unused)), const char *cfgfile |
1414 | char *const *args __attribute__ ((unused)), | ||
1415 | const char *cfgfile | ||
1416 | __attribute__ ((unused)), const struct GNUNET_CONFIGURATION_Handle *cfg_) | 1414 | __attribute__ ((unused)), const struct GNUNET_CONFIGURATION_Handle *cfg_) |
1417 | { | 1415 | { |
1418 | cfg = cfg_; | 1416 | cfg = cfg_; |
@@ -1454,10 +1452,7 @@ main (int argc, char *const *argv) | |||
1454 | }; | 1452 | }; |
1455 | 1453 | ||
1456 | return (GNUNET_OK == | 1454 | return (GNUNET_OK == |
1457 | GNUNET_PROGRAM_run (argc, | 1455 | GNUNET_PROGRAM_run (argc, argv, "exit", gettext_noop ("help text"), |
1458 | argv, | ||
1459 | "exit", | ||
1460 | gettext_noop ("help text"), | ||
1461 | options, &run, NULL)) ? ret : 1; | 1456 | options, &run, NULL)) ? ret : 1; |
1462 | } | 1457 | } |
1463 | 1458 | ||