aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Tölke <toelke@in.tum.de>2011-06-15 07:15:43 +0000
committerPhilipp Tölke <toelke@in.tum.de>2011-06-15 07:15:43 +0000
commit79d95cd1caea9746161eb4273862ebcd6b649499 (patch)
treec2ea9b3a3485f8ead971b7f3aa0c829d77ddc050
parentd1194307cff31ecc9b3c8a01ebfa154dbf85b58e (diff)
downloadgnunet-79d95cd1caea9746161eb4273862ebcd6b649499.tar.gz
gnunet-79d95cd1caea9746161eb4273862ebcd6b649499.zip
make the exit configurable;
-rw-r--r--src/vpn/gnunet-daemon-exit.c68
1 files changed, 52 insertions, 16 deletions
diff --git a/src/vpn/gnunet-daemon-exit.c b/src/vpn/gnunet-daemon-exit.c
index eaa50d2e1..76d653b06 100644
--- a/src/vpn/gnunet-daemon-exit.c
+++ b/src/vpn/gnunet-daemon-exit.c
@@ -1174,6 +1174,56 @@ receive_udp_service (void *cls __attribute__((unused)),
1174 return GNUNET_YES; 1174 return GNUNET_YES;
1175} 1175}
1176 1176
1177static void
1178connect_to_mesh()
1179{
1180 int udp, tcp;
1181 int handler_idx, app_idx;
1182
1183 udp = GNUNET_CONFIGURATION_get_value_yesno(cfg, "exit", "ENABLE_UDP");
1184 tcp = GNUNET_CONFIGURATION_get_value_yesno(cfg, "exit", "ENABLE_TCP");
1185
1186 static struct GNUNET_MESH_MessageHandler handlers[] = {
1187 {receive_udp_service, GNUNET_MESSAGE_TYPE_SERVICE_UDP, 0},
1188 {receive_tcp_service, GNUNET_MESSAGE_TYPE_SERVICE_TCP, 0},
1189 {NULL, 0, 0},
1190 {NULL, 0, 0},
1191 {NULL, 0, 0}
1192 };
1193
1194 static GNUNET_MESH_ApplicationType apptypes[] =
1195 {
1196 GNUNET_APPLICATION_TYPE_END,
1197 GNUNET_APPLICATION_TYPE_END,
1198 GNUNET_APPLICATION_TYPE_END
1199 };
1200
1201 app_idx = 0;
1202 handler_idx = 2;
1203
1204 if (GNUNET_YES == udp)
1205 {
1206 handlers[handler_idx].callback = receive_udp_remote;
1207 handlers[handler_idx].expected_size = 0;
1208 handlers[handler_idx].type = GNUNET_MESSAGE_TYPE_REMOTE_UDP;
1209 apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY;
1210 handler_idx++;
1211 app_idx++;
1212 }
1213
1214 if (GNUNET_YES == tcp)
1215 {
1216 handlers[handler_idx].callback = receive_tcp_remote;
1217 handlers[handler_idx].expected_size = 0;
1218 handlers[handler_idx].type = GNUNET_MESSAGE_TYPE_REMOTE_TCP;
1219 apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY;
1220 handler_idx++;
1221 app_idx++;
1222 }
1223
1224 mesh_handle = GNUNET_MESH_connect (cfg, NULL, NULL, handlers, apptypes);
1225}
1226
1177/** 1227/**
1178 * @brief Main function that will be run by the scheduler. 1228 * @brief Main function that will be run by the scheduler.
1179 * 1229 *
@@ -1187,24 +1237,10 @@ run (void *cls,
1187 char *const *args __attribute__((unused)), 1237 char *const *args __attribute__((unused)),
1188 const char *cfgfile __attribute__((unused)), const struct GNUNET_CONFIGURATION_Handle *cfg_) 1238 const char *cfgfile __attribute__((unused)), const struct GNUNET_CONFIGURATION_Handle *cfg_)
1189{ 1239{
1190 static const struct GNUNET_MESH_MessageHandler handlers[] = { 1240 cfg = cfg_;
1191 {receive_udp_service, GNUNET_MESSAGE_TYPE_SERVICE_UDP, 0},
1192 {receive_tcp_service, GNUNET_MESSAGE_TYPE_SERVICE_TCP, 0},
1193 {receive_udp_remote, GNUNET_MESSAGE_TYPE_REMOTE_UDP, 0},
1194 {receive_tcp_remote, GNUNET_MESSAGE_TYPE_REMOTE_TCP, 0},
1195 {NULL, 0, 0}
1196 };
1197
1198 static const GNUNET_MESH_ApplicationType apptypes[] =
1199 {
1200 GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY,
1201 GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY,
1202 GNUNET_APPLICATION_TYPE_END
1203 };
1204 1241
1205 mesh_handle = GNUNET_MESH_connect (cfg_, NULL, NULL, handlers, apptypes); 1242 connect_to_mesh();
1206 1243
1207 cfg = cfg_;
1208 udp_connections = GNUNET_CONTAINER_multihashmap_create (65536); 1244 udp_connections = GNUNET_CONTAINER_multihashmap_create (65536);
1209 udp_connections_heap = 1245 udp_connections_heap =
1210 GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 1246 GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);