aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-08-01 23:57:03 +0000
committerBart Polot <bart@net.in.tum.de>2013-08-01 23:57:03 +0000
commit54fe523287a2b1b9a76a8c19015edd24a855c072 (patch)
treed418c0d6b4d14178e66490afde6a431512e77a41 /src
parent8944e04b566e9b5722a0b3403564224604ed3641 (diff)
downloadgnunet-54fe523287a2b1b9a76a8c19015edd24a855c072.tar.gz
gnunet-54fe523287a2b1b9a76a8c19015edd24a855c072.zip
- channel destroy notification
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh-enc.c111
-rw-r--r--src/mesh/mesh_protocol_enc.h31
2 files changed, 90 insertions, 52 deletions
diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c
index 8f4baf459..c13907550 100644
--- a/src/mesh/gnunet-service-mesh-enc.c
+++ b/src/mesh/gnunet-service-mesh-enc.c
@@ -2080,20 +2080,16 @@ peer_unlock_queue (GNUNET_PEER_Id peer_id)
2080/** 2080/**
2081 * Cancel all transmissions towards a neighbor that belong to a certain tunnel. 2081 * Cancel all transmissions towards a neighbor that belong to a certain tunnel.
2082 * 2082 *
2083 * @param neighbor Short ID of the neighbor to whom cancel the transmissions. 2083 * @param peer Neighbor to whom cancel the transmissions.
2084 * @param t Tunnel which to cancel. 2084 * @param t Tunnel which to cancel.
2085 */ 2085 */
2086static void 2086static void
2087peer_cancel_queues (GNUNET_PEER_Id neighbor, struct MeshTunnel2 *t) 2087peer_cancel_queues (struct MeshPeer *peer, struct MeshTunnel2 *t)
2088{ 2088{
2089 struct MeshPeer *peer;
2090 struct MeshPeerQueue *q; 2089 struct MeshPeerQueue *q;
2091 struct MeshPeerQueue *next; 2090 struct MeshPeerQueue *next;
2092 struct MeshFlowControl *fc; 2091 struct MeshFlowControl *fc;
2093 2092
2094 if (0 == neighbor)
2095 return; /* Was local peer, 0'ed in tunnel_destroy_iterator */
2096 peer = peer_get_short (neighbor);
2097 if (NULL == peer || NULL == peer->fc) 2093 if (NULL == peer || NULL == peer->fc)
2098 { 2094 {
2099 GNUNET_break (0); 2095 GNUNET_break (0);
@@ -2105,13 +2101,9 @@ peer_cancel_queues (GNUNET_PEER_Id neighbor, struct MeshTunnel2 *t)
2105 next = q->next; 2101 next = q->next;
2106 if (q->peer->tunnel == t) 2102 if (q->peer->tunnel == t)
2107 { 2103 {
2108 if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == q->type || 2104 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2109 GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == q->type) 2105 "peer_cancel_queue %s\n",
2110 { 2106 GNUNET_MESH_DEBUG_M2S (q->type));
2111 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2112 "peer_cancel_queue %s\n",
2113 GNUNET_MESH_DEBUG_M2S (q->type));
2114 }
2115 queue_destroy (q, GNUNET_YES); 2107 queue_destroy (q, GNUNET_YES);
2116 } 2108 }
2117 } 2109 }
@@ -3261,7 +3253,7 @@ static void
3261connection_keepalive (struct MeshConnection *c, int fwd) 3253connection_keepalive (struct MeshConnection *c, int fwd)
3262{ 3254{
3263 struct GNUNET_MESH_ConnectionKeepAlive *msg; 3255 struct GNUNET_MESH_ConnectionKeepAlive *msg;
3264 size_t size = sizeof (struct GNUNET_MESH_TunnelKeepAlive); 3256 size_t size = sizeof (struct GNUNET_MESH_ConnectionKeepAlive);
3265 char cbuf[size]; 3257 char cbuf[size];
3266 uint16_t type; 3258 uint16_t type;
3267 3259
@@ -3274,7 +3266,7 @@ connection_keepalive (struct MeshConnection *c, int fwd)
3274 GNUNET_i2s (GNUNET_PEER_resolve2 (c->t->peer->id)), 3266 GNUNET_i2s (GNUNET_PEER_resolve2 (c->t->peer->id)),
3275 c->id); 3267 c->id);
3276 3268
3277 msg = (struct GNUNET_MESH_TunnelKeepAlive *) cbuf; 3269 msg = (struct GNUNET_MESH_ConnectionKeepAlive *) cbuf;
3278 msg->header.size = htons (size); 3270 msg->header.size = htons (size);
3279 msg->header.type = htons (type); 3271 msg->header.type = htons (type);
3280 msg->cid = htonl (c->id); 3272 msg->cid = htonl (c->id);
@@ -3366,56 +3358,71 @@ connection_bck_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *
3366 3358
3367 3359
3368/** 3360/**
3369 * Send a message to all peers and clients in this tunnel that the tunnel 3361 * Send a message to all peers in this connection that the connection
3370 * is no longer valid. If some peer or client should not receive the message, 3362 * is no longer valid.
3363 *
3364 * If some peer should not receive the message, it should be zero'ed out
3365 * before calling this function.
3366 *
3367 * @param c The connection whose peers to notify.
3368 */
3369static void
3370connection_send_destroy (struct MeshConnection *c)
3371{
3372 struct GNUNET_MESH_ConnectionDestroy msg;
3373
3374 msg.header.size = htons (sizeof (msg));
3375 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY);;
3376 msg.cid = htonl (c->id);
3377 msg.tid = c->t->id;
3378 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3379 " sending tunnel destroy for connection %s[%X]\n",
3380 GNUNET_i2s (GNUNET_PEER_resolve2 (c->t->peer->id)),
3381 c->id);
3382
3383 send_prebuilt_message_connection (&msg.header, c, NULL, GNUNET_YES);
3384 send_prebuilt_message_connection (&msg.header, c, NULL, GNUNET_NO);
3385}
3386
3387
3388/**
3389 * Send a message to all clients in this channel that the channel
3390 * is no longer valid.
3391 *
3392 * If some peer or client should not receive the message,
3371 * should be zero'ed out before calling this function. 3393 * should be zero'ed out before calling this function.
3372 * 3394 *
3373 * @param t The tunnel whose peers and clients to notify. 3395 * @param ch The channel whose clients to notify.
3374 */ 3396 */
3375static void 3397static void
3376tunnel_send_destroy (struct MeshTunnel *t) 3398channel_send_destroy (struct MeshChannel *ch)
3377{ 3399{
3378 struct GNUNET_MESH_TunnelDestroy msg; 3400 struct GNUNET_MESH_ChannelDestroy msg;
3379 struct GNUNET_PeerIdentity id;
3380 3401
3381 msg.header.size = htons (sizeof (msg)); 3402 msg.header.size = htons (sizeof (msg));
3382 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY); 3403 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY);
3383 GNUNET_PEER_resolve (t->id.oid, &msg.oid); 3404 msg.chid = htonl (ch->id);
3384 msg.tid = htonl (t->id.tid);
3385 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3405 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3386 " sending tunnel destroy for tunnel: %s [%X]\n", 3406 " sending tunnel destroy for channel %s:%X\n",
3387 GNUNET_i2s (&msg.oid), t->id.tid); 3407 GNUNET_i2s (GNUNET_PEER_resolve2 (ch->t->peer->id)),
3408 ch->id);
3388 3409
3389 if (NULL == t->client && 0 != t->next_hop) 3410 send_prebuilt_message_channel (&msg.header, ch, GNUNET_YES);
3390 { 3411 send_prebuilt_message_channel (&msg.header, ch, GNUNET_NO);
3391 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " child: %u\n", t->next_hop); 3412
3392 GNUNET_PEER_resolve (t->next_hop, &id); 3413 if (NULL != ch->owner)
3393 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3394 " sending forward to %s\n",
3395 GNUNET_i2s (&id));
3396 send_prebuilt_message (&msg.header, t->next_hop, t);
3397 }
3398 if (NULL == t->owner && 0 != t->prev_hop)
3399 {
3400 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " parent: %u\n", t->prev_hop);
3401 GNUNET_PEER_resolve (t->prev_hop, &id);
3402 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3403 " sending back to %s\n",
3404 GNUNET_i2s (&id));
3405 send_prebuilt_message (&msg.header, t->prev_hop, t);
3406 }
3407 if (NULL != t->owner)
3408 { 3414 {
3409 send_local_tunnel_destroy (t, GNUNET_NO); 3415 send_local_channel_destroy (t, GNUNET_NO);
3410 } 3416 }
3411 if (NULL != t->client) 3417 if (NULL != ch->client)
3412 { 3418 {
3413 send_local_tunnel_destroy (t, GNUNET_YES); 3419 send_local_channel_destroy (t, GNUNET_YES);
3414 } 3420 }
3415} 3421}
3416 3422
3423
3417static int 3424static int
3418tunnel_destroy (struct MeshTunnel *t) 3425tunnel_destroy (struct MeshTunnel2 *t)
3419{ 3426{
3420 struct MeshClient *c; 3427 struct MeshClient *c;
3421 struct GNUNET_HashCode hash; 3428 struct GNUNET_HashCode hash;
@@ -3558,8 +3565,8 @@ channel_destroy (struct MeshChannel *ch)
3558 3565
3559 if (GNUNET_YES == ch->reliable) 3566 if (GNUNET_YES == ch->reliable)
3560 { 3567 {
3561 channel_rel_free_all (ch->fwd_rel); 3568 channel_rel_free_all (ch->fwd_rel);
3562 channel_rel_free_all (ch->bck_rel); 3569 channel_rel_free_all (ch->bck_rel);
3563 } 3570 }
3564 3571
3565 GNUNET_free (ch); 3572 GNUNET_free (ch);
@@ -5848,7 +5855,7 @@ static struct GNUNET_SERVER_MessageHandler client_handlers[] = {
5848 GNUNET_MESSAGE_TYPE_MESH_LOCAL_CHANNEL_CREATE, 5855 GNUNET_MESSAGE_TYPE_MESH_LOCAL_CHANNEL_CREATE,
5849 sizeof (struct GNUNET_MESH_ChannelMessage)}, 5856 sizeof (struct GNUNET_MESH_ChannelMessage)},
5850 {&handle_local_channel_destroy, NULL, 5857 {&handle_local_channel_destroy, NULL,
5851 GNUNET_MESSAGE_TYPE_MESH_LOCAL_CHANNEL_DESTROY, 5858 GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY,
5852 sizeof (struct GNUNET_MESH_ChannelMessage)}, 5859 sizeof (struct GNUNET_MESH_ChannelMessage)},
5853 {&handle_local_data, NULL, 5860 {&handle_local_data, NULL,
5854 GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA, 0}, 5861 GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA, 0},
diff --git a/src/mesh/mesh_protocol_enc.h b/src/mesh/mesh_protocol_enc.h
index 9a49cea4a..fef6479e2 100644
--- a/src/mesh/mesh_protocol_enc.h
+++ b/src/mesh/mesh_protocol_enc.h
@@ -140,6 +140,37 @@ struct GNUNET_MESH_Encrypted
140 */ 140 */
141}; 141};
142 142
143struct GNUNET_MESH_ChannelCreate
144{
145 /**
146 * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE
147 */
148 struct GNUNET_MessageHeader header;
149
150 /**
151 * ID of the channel
152 */
153 uint32_t chid GNUNET_PACKED;
154
155 /**
156 * Channel options.
157 */
158 uint32_t opt GNUNET_PACKED;
159};
160
161struct GNUNET_MESH_ChannelDestroy
162{
163 /**
164 * Type: GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY
165 */
166 struct GNUNET_MessageHeader header;
167
168 /**
169 * ID of the channel
170 */
171 uint32_t chid GNUNET_PACKED;
172};
173
143/** 174/**
144 * Message for mesh data traffic. 175 * Message for mesh data traffic.
145 */ 176 */