aboutsummaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-11-14 13:55:12 +0000
committerBart Polot <bart@net.in.tum.de>2013-11-14 13:55:12 +0000
commitb7366f3d6a56d38d0269a33039f88de967e8c130 (patch)
treee299448a28e358c6549670a094b82f247925f7e2 /src/set
parent6bde5e0c83d1fd344a26de64172ddce37920bb40 (diff)
downloadgnunet-b7366f3d6a56d38d0269a33039f88de967e8c130.tar.gz
gnunet-b7366f3d6a56d38d0269a33039f88de967e8c130.zip
Use encrypted MESH by default
Diffstat (limited to 'src/set')
-rw-r--r--src/set/gnunet-service-set.c108
-rw-r--r--src/set/gnunet-service-set.h2
2 files changed, 55 insertions, 55 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index 1a2b0cc31..d4c347d48 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -316,16 +316,16 @@ _GSS_operation_destroy (struct Operation *op)
316 op->mq = NULL; 316 op->mq = NULL;
317 } 317 }
318 318
319 if (NULL != op->tunnel) 319 if (NULL != op->channel)
320 { 320 {
321 GNUNET_MESH_tunnel_destroy (op->tunnel); 321 GNUNET_MESH_channel_destroy (op->channel);
322 op->tunnel = NULL; 322 op->channel = NULL;
323 } 323 }
324 324
325 collect_generation_garbage (set); 325 collect_generation_garbage (set);
326 326
327 /* We rely on the tunnel end handler to free 'op'. When 'op->tunnel' was NULL, 327 /* We rely on the channel end handler to free 'op'. When 'op->channel' was NULL,
328 * there was a tunnel end handler that will free 'op' on the call stack. */ 328 * there was a channel end handler that will free 'op' on the call stack. */
329} 329}
330 330
331 331
@@ -362,7 +362,7 @@ set_destroy (struct Set *set)
362{ 362{
363 /* If the client is not dead yet, destroy it. 363 /* If the client is not dead yet, destroy it.
364 * The client's destroy callback will destroy the set again. 364 * The client's destroy callback will destroy the set again.
365 * We do this so that the tunnel end handler still has a valid set handle 365 * We do this so that the channel end handler still has a valid set handle
366 * to destroy. */ 366 * to destroy. */
367 if (NULL != set->client) 367 if (NULL != set->client)
368 { 368 {
@@ -532,8 +532,8 @@ incoming_suggest (struct Operation *incoming, struct Listener *listener)
532 * 532 *
533 * @param op the operation state 533 * @param op the operation state
534 * @param mh the received message 534 * @param mh the received message
535 * @return GNUNET_OK if the tunnel should be kept alive, 535 * @return GNUNET_OK if the channel should be kept alive,
536 * GNUNET_SYSERR to destroy the tunnel 536 * GNUNET_SYSERR to destroy the channel
537 */ 537 */
538static int 538static int
539handle_incoming_msg (struct Operation *op, 539handle_incoming_msg (struct Operation *op,
@@ -805,8 +805,8 @@ handle_client_reject (void *cls,
805 } 805 }
806 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer request rejected by client\n"); 806 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer request rejected by client\n");
807 807
808 GNUNET_MESH_tunnel_destroy (incoming->tunnel); 808 GNUNET_MESH_channel_destroy (incoming->channel);
809 //tunnel destruction handler called immediately upon destruction 809 //channel destruction handler called immediately upon destruction
810 GNUNET_SERVER_receive_done (client, GNUNET_OK); 810 GNUNET_SERVER_receive_done (client, GNUNET_OK);
811} 811}
812 812
@@ -935,12 +935,12 @@ handle_client_evaluate (void *cls,
935 op->vt = set->vt; 935 op->vt = set->vt;
936 GNUNET_CONTAINER_DLL_insert (set->ops_head, set->ops_tail, op); 936 GNUNET_CONTAINER_DLL_insert (set->ops_head, set->ops_tail, op);
937 937
938 op->tunnel = GNUNET_MESH_tunnel_create (mesh, op, &msg->target_peer, 938 op->channel = GNUNET_MESH_channel_create (mesh, op, &msg->target_peer,
939 GNUNET_APPLICATION_TYPE_SET, 939 GNUNET_APPLICATION_TYPE_SET,
940 GNUNET_YES, 940 GNUNET_YES,
941 GNUNET_YES); 941 GNUNET_YES);
942 942
943 op->mq = GNUNET_MESH_mq_create (op->tunnel); 943 op->mq = GNUNET_MESH_mq_create (op->channel);
944 944
945 set->vt->evaluate (op); 945 set->vt->evaluate (op);
946 GNUNET_SERVER_receive_done (client, GNUNET_OK); 946 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -1111,7 +1111,7 @@ shutdown_task (void *cls,
1111 while (NULL != sets_head) 1111 while (NULL != sets_head)
1112 set_destroy (sets_head); 1112 set_destroy (sets_head);
1113 1113
1114 /* it's important to destroy mesh at the end, as all tunnels 1114 /* it's important to destroy mesh at the end, as all channels
1115 * must be destroyed before the mesh handle! */ 1115 * must be destroyed before the mesh handle! */
1116 if (NULL != mesh) 1116 if (NULL != mesh)
1117 { 1117 {
@@ -1127,9 +1127,9 @@ shutdown_task (void *cls,
1127 * Timeout happens iff: 1127 * Timeout happens iff:
1128 * - we suggested an operation to our listener, 1128 * - we suggested an operation to our listener,
1129 * but did not receive a response in time 1129 * but did not receive a response in time
1130 * - we got the tunnel from a peer but no GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST 1130 * - we got the channel from a peer but no GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST
1131 * - shutdown (obviously) 1131 * - shutdown (obviously)
1132 * @param cls tunnel context 1132 * @param cls channel context
1133 * @param tc context information (why was this task triggered now) 1133 * @param tc context information (why was this task triggered now)
1134 */ 1134 */
1135static void 1135static void
@@ -1150,16 +1150,16 @@ incoming_timeout_cb (void *cls,
1150 1150
1151/** 1151/**
1152 * Terminates an incoming operation in case we have not yet received an 1152 * Terminates an incoming operation in case we have not yet received an
1153 * operation request. Called by the tunnel destruction handler. 1153 * operation request. Called by the channel destruction handler.
1154 * 1154 *
1155 * @param op the tunnel context 1155 * @param op the channel context
1156 */ 1156 */
1157static void 1157static void
1158handle_incoming_disconnect (struct Operation *op) 1158handle_incoming_disconnect (struct Operation *op)
1159{ 1159{
1160 GNUNET_assert (GNUNET_YES == op->is_incoming); 1160 GNUNET_assert (GNUNET_YES == op->is_incoming);
1161 1161
1162 if (NULL == op->tunnel) 1162 if (NULL == op->channel)
1163 return; 1163 return;
1164 1164
1165 incoming_destroy (op); 1165 incoming_destroy (op);
@@ -1167,25 +1167,25 @@ handle_incoming_disconnect (struct Operation *op)
1167 1167
1168 1168
1169/** 1169/**
1170 * Method called whenever another peer has added us to a tunnel 1170 * Method called whenever another peer has added us to a channel
1171 * the other peer initiated. 1171 * the other peer initiated.
1172 * Only called (once) upon reception of data with a message type which was 1172 * Only called (once) upon reception of data with a message type which was
1173 * subscribed to in GNUNET_MESH_connect. 1173 * subscribed to in GNUNET_MESH_connect.
1174 * 1174 *
1175 * The tunnel context represents the operation itself and gets added to a DLL, 1175 * The channel context represents the operation itself and gets added to a DLL,
1176 * from where it gets looked up when our local listener client responds 1176 * from where it gets looked up when our local listener client responds
1177 * to a proposed/suggested operation or connects and associates with this operation. 1177 * to a proposed/suggested operation or connects and associates with this operation.
1178 * 1178 *
1179 * @param cls closure 1179 * @param cls closure
1180 * @param tunnel new handle to the tunnel 1180 * @param channel new handle to the channel
1181 * @param initiator peer that started the tunnel 1181 * @param initiator peer that started the channel
1182 * @param port Port this tunnel is for. 1182 * @param port Port this channel is for.
1183 * @return initial tunnel context for the tunnel 1183 * @return initial channel context for the channel
1184 * (can be NULL -- that's not an error) 1184 * (can be NULL -- that's not an error)
1185 */ 1185 */
1186static void * 1186static void *
1187tunnel_new_cb (void *cls, 1187channel_new_cb (void *cls,
1188 struct GNUNET_MESH_Tunnel *tunnel, 1188 struct GNUNET_MESH_Channel *channel,
1189 const struct GNUNET_PeerIdentity *initiator, 1189 const struct GNUNET_PeerIdentity *initiator,
1190 uint32_t port) 1190 uint32_t port)
1191{ 1191{
@@ -1195,15 +1195,15 @@ tunnel_new_cb (void *cls,
1195 .peer_disconnect = handle_incoming_disconnect 1195 .peer_disconnect = handle_incoming_disconnect
1196 }; 1196 };
1197 1197
1198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "new incoming tunnel\n"); 1198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "new incoming channel\n");
1199 1199
1200 GNUNET_assert (port == GNUNET_APPLICATION_TYPE_SET); 1200 GNUNET_assert (port == GNUNET_APPLICATION_TYPE_SET);
1201 incoming = GNUNET_new (struct Operation); 1201 incoming = GNUNET_new (struct Operation);
1202 incoming->is_incoming = GNUNET_YES; 1202 incoming->is_incoming = GNUNET_YES;
1203 incoming->state = GNUNET_new (struct OperationState); 1203 incoming->state = GNUNET_new (struct OperationState);
1204 incoming->state->peer = *initiator; 1204 incoming->state->peer = *initiator;
1205 incoming->tunnel = tunnel; 1205 incoming->channel = channel;
1206 incoming->mq = GNUNET_MESH_mq_create (incoming->tunnel); 1206 incoming->mq = GNUNET_MESH_mq_create (incoming->channel);
1207 incoming->vt = &incoming_vt; 1207 incoming->vt = &incoming_vt;
1208 incoming->state->timeout_task = 1208 incoming->state->timeout_task =
1209 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, incoming_timeout_cb, incoming); 1209 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, incoming_timeout_cb, incoming);
@@ -1214,72 +1214,72 @@ tunnel_new_cb (void *cls,
1214 1214
1215 1215
1216/** 1216/**
1217 * Function called whenever a tunnel is destroyed. Should clean up 1217 * Function called whenever a channel is destroyed. Should clean up
1218 * any associated state. 1218 * any associated state.
1219 * GNUNET_MESH_tunnel_destroy. It must NOT call GNUNET_MESH_tunnel_destroy on 1219 * GNUNET_MESH_channel_destroy. It must NOT call GNUNET_MESH_channel_destroy on
1220 * the tunnel. 1220 * the channel.
1221 * 1221 *
1222 * The peer_disconnect function is part of a a virtual table set initially either 1222 * The peer_disconnect function is part of a a virtual table set initially either
1223 * when a peer creates a new tunnel with us (tunnel_new_cb), or once we create 1223 * when a peer creates a new channel with us (channel_new_cb), or once we create
1224 * a new tunnel ourselves (evaluate). 1224 * a new channel ourselves (evaluate).
1225 * 1225 *
1226 * Once we know the exact type of operation (union/intersection), the vt is 1226 * Once we know the exact type of operation (union/intersection), the vt is
1227 * replaced with an operation specific instance (_GSS_[op]_vt). 1227 * replaced with an operation specific instance (_GSS_[op]_vt).
1228 * 1228 *
1229 * @param cls closure (set from GNUNET_MESH_connect) 1229 * @param cls closure (set from GNUNET_MESH_connect)
1230 * @param tunnel connection to the other end (henceforth invalid) 1230 * @param channel connection to the other end (henceforth invalid)
1231 * @param tunnel_ctx place where local state associated 1231 * @param channel_ctx place where local state associated
1232 * with the tunnel is stored 1232 * with the channel is stored
1233 */ 1233 */
1234static void 1234static void
1235tunnel_end_cb (void *cls, 1235channel_end_cb (void *cls,
1236 const struct GNUNET_MESH_Tunnel *tunnel, void *tunnel_ctx) 1236 const struct GNUNET_MESH_Channel *channel, void *channel_ctx)
1237{ 1237{
1238 struct Operation *op = tunnel_ctx; 1238 struct Operation *op = channel_ctx;
1239 1239
1240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tunnel end cb called\n"); 1240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "channel end cb called\n");
1241 1241
1242 op->tunnel = NULL; 1242 op->channel = NULL;
1243 1243
1244 if (NULL != op->vt) 1244 if (NULL != op->vt)
1245 op->vt->peer_disconnect (op); 1245 op->vt->peer_disconnect (op);
1246 /* mesh will never call us with the context again! */ 1246 /* mesh will never call us with the context again! */
1247 GNUNET_free (tunnel_ctx); 1247 GNUNET_free (channel_ctx);
1248} 1248}
1249 1249
1250 1250
1251/** 1251/**
1252 * Functions with this signature are called whenever any message is 1252 * Functions with this signature are called whenever any message is
1253 * received via the mesh tunnel. 1253 * received via the mesh channel.
1254 * 1254 *
1255 * The msg_handler is a virtual table set in initially either when a peer 1255 * The msg_handler is a virtual table set in initially either when a peer
1256 * creates a new tunnel with us (tunnel_new_cb), or once we create a new tunnel 1256 * creates a new channel with us (channel_new_cb), or once we create a new channel
1257 * ourselves (evaluate). 1257 * ourselves (evaluate).
1258 * 1258 *
1259 * Once we know the exact type of operation (union/intersection), the vt is 1259 * Once we know the exact type of operation (union/intersection), the vt is
1260 * replaced with an operation specific instance (_GSS_[op]_vt). 1260 * replaced with an operation specific instance (_GSS_[op]_vt).
1261 * 1261 *
1262 * @param cls Closure (set from GNUNET_MESH_connect). 1262 * @param cls Closure (set from GNUNET_MESH_connect).
1263 * @param tunnel Connection to the other end. 1263 * @param channel Connection to the other end.
1264 * @param tunnel_ctx Place to store local state associated with the tunnel. 1264 * @param channel_ctx Place to store local state associated with the channel.
1265 * @param message The actual message. 1265 * @param message The actual message.
1266 * 1266 *
1267 * @return GNUNET_OK to keep the tunnel open, 1267 * @return GNUNET_OK to keep the channel open,
1268 * GNUNET_SYSERR to close it (signal serious error). 1268 * GNUNET_SYSERR to close it (signal serious error).
1269 */ 1269 */
1270static int 1270static int
1271dispatch_p2p_message (void *cls, 1271dispatch_p2p_message (void *cls,
1272 struct GNUNET_MESH_Tunnel *tunnel, 1272 struct GNUNET_MESH_Channel *channel,
1273 void **tunnel_ctx, 1273 void **channel_ctx,
1274 const struct GNUNET_MessageHeader *message) 1274 const struct GNUNET_MessageHeader *message)
1275{ 1275{
1276 struct Operation *op = *tunnel_ctx; 1276 struct Operation *op = *channel_ctx;
1277 int ret; 1277 int ret;
1278 1278
1279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "dispatching mesh message (type: %u)\n", 1279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "dispatching mesh message (type: %u)\n",
1280 ntohs (message->type)); 1280 ntohs (message->type));
1281 /* do this before the handler, as the handler might kill the tunnel */ 1281 /* do this before the handler, as the handler might kill the channel */
1282 GNUNET_MESH_receive_done (tunnel); 1282 GNUNET_MESH_receive_done (channel);
1283 ret = op->vt->msg_handler (op, message); 1283 ret = op->vt->msg_handler (op, message);
1284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled mesh message (type: %u)\n", 1284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled mesh message (type: %u)\n",
1285 ntohs (message->type)); 1285 ntohs (message->type));
@@ -1336,7 +1336,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1336 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); 1336 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
1337 GNUNET_SERVER_add_handlers (server, server_handlers); 1337 GNUNET_SERVER_add_handlers (server, server_handlers);
1338 1338
1339 mesh = GNUNET_MESH_connect (cfg, NULL, tunnel_new_cb, tunnel_end_cb, 1339 mesh = GNUNET_MESH_connect (cfg, NULL, channel_new_cb, channel_end_cb,
1340 mesh_handlers, mesh_ports); 1340 mesh_handlers, mesh_ports);
1341 if (NULL == mesh) 1341 if (NULL == mesh)
1342 { 1342 {
diff --git a/src/set/gnunet-service-set.h b/src/set/gnunet-service-set.h
index dd6e91da8..62e8cbc87 100644
--- a/src/set/gnunet-service-set.h
+++ b/src/set/gnunet-service-set.h
@@ -296,7 +296,7 @@ struct Operation
296 /** 296 /**
297 * Tunnel to the peer. 297 * Tunnel to the peer.
298 */ 298 */
299 struct GNUNET_MESH_Tunnel *tunnel; 299 struct GNUNET_MESH_Channel *channel;
300 300
301 /** 301 /**
302 * Message queue for the tunnel. 302 * Message queue for the tunnel.