aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-04 14:56:51 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-04 14:56:51 +0000
commitdae44779ebc12613acf1ca50db8d3dee05a5cd54 (patch)
tree8cbec48fd7de4ab75b29ed3cc125685f15b51948 /src/mesh
parent28a0d701d3bbfa6c53b6ff93598403b372016d72 (diff)
downloadgnunet-dae44779ebc12613acf1ca50db8d3dee05a5cd54.tar.gz
gnunet-dae44779ebc12613acf1ca50db8d3dee05a5cd54.zip
Added local tunnel service numeration handling, added incoming tunnel client notification, fixed peer_id rc bug on core peer connect
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index cf78528f1..1d8d2786e 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -447,6 +447,11 @@ static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded my_public_key;
447static MESH_TunnelNumber next_tid; 447static MESH_TunnelNumber next_tid;
448 448
449/** 449/**
450 * Tunnel ID for the next incoming tunnel (local tunnel number)
451 */
452static MESH_TunnelNumber next_local_tid;
453
454/**
450 * All application types provided by this peer 455 * All application types provided by this peer
451 */ 456 */
452static struct GNUNET_CONTAINER_MultiHashMap *applications; 457static struct GNUNET_CONTAINER_MultiHashMap *applications;
@@ -1583,7 +1588,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1583 pi = (struct GNUNET_PeerIdentity *) &msg[1]; 1588 pi = (struct GNUNET_PeerIdentity *) &msg[1];
1584 t = tunnel_get (pi, tid); 1589 t = tunnel_get (pi, tid);
1585 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1590 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1586 "MESH: path as for tunnel %s [%X].\n", 1591 "MESH: path is for tunnel %s [%X].\n",
1587 GNUNET_i2s(pi), 1592 GNUNET_i2s(pi),
1588 tid); 1593 tid);
1589 if (NULL == t) 1594 if (NULL == t)
@@ -1593,6 +1598,8 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1593 t->id.oid = GNUNET_PEER_intern (pi); 1598 t->id.oid = GNUNET_PEER_intern (pi);
1594 t->id.tid = tid; 1599 t->id.tid = tid;
1595 t->peers = GNUNET_CONTAINER_multihashmap_create (32); 1600 t->peers = GNUNET_CONTAINER_multihashmap_create (32);
1601 t->local_tid = next_local_tid++;
1602 next_local_tid |= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV;
1596 1603
1597 GNUNET_CRYPTO_hash (&t->id, sizeof (struct MESH_TunnelID), &hash); 1604 GNUNET_CRYPTO_hash (&t->id, sizeof (struct MESH_TunnelID), &hash);
1598 if (GNUNET_OK != 1605 if (GNUNET_OK !=
@@ -1641,6 +1648,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1641 if (own_pos == size - 1) 1648 if (own_pos == size - 1)
1642 { 1649 {
1643 /* It is for us! Send ack. */ 1650 /* It is for us! Send ack. */
1651 struct GNUNET_MESH_TunnelNotification cmsg;
1644 struct MeshDataDescriptor *info; 1652 struct MeshDataDescriptor *info;
1645 unsigned int j; 1653 unsigned int j;
1646 1654
@@ -1663,6 +1671,11 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1663 GNUNET_TIME_UNIT_FOREVER_REL, peer, 1671 GNUNET_TIME_UNIT_FOREVER_REL, peer,
1664 sizeof (struct GNUNET_MESH_PathACK), 1672 sizeof (struct GNUNET_MESH_PathACK),
1665 &send_core_path_ack, info); 1673 &send_core_path_ack, info);
1674 cmsg.header.size = htons(sizeof(cmsg));
1675 cmsg.header.type = htons(GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE);
1676 GNUNET_PEER_resolve(t->id.oid, &cmsg.peer);
1677 cmsg.tunnel_id = htonl(t->local_tid);
1678 GNUNET_SERVER_notification_context_broadcast(nc, &cmsg.header, GNUNET_NO);
1666 } 1679 }
1667 else 1680 else
1668 { 1681 {
@@ -3129,6 +3142,8 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
3129 path = path_new (2); 3142 path = path_new (2);
3130 path->peers[0] = myid; 3143 path->peers[0] = myid;
3131 path->peers[1] = peer_info->id; 3144 path->peers[1] = peer_info->id;
3145 GNUNET_PEER_change_rc(myid, 1);
3146 GNUNET_PEER_change_rc(peer_info->id, 1);
3132 path_add_to_peer (peer_info, path); 3147 path_add_to_peer (peer_info, path);
3133 return; 3148 return;
3134} 3149}
@@ -3147,7 +3162,7 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
3147 3162
3148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer disconnected\n"); 3163 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer disconnected\n");
3149 pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); 3164 pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey);
3150 if (!pi) 3165 if (NULL == pi)
3151 { 3166 {
3152 GNUNET_break (0); 3167 GNUNET_break (0);
3153 return; 3168 return;
@@ -3160,11 +3175,13 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
3160 struct MeshPathInfo *path_info; 3175 struct MeshPathInfo *path_info;
3161 GNUNET_CORE_notify_transmit_ready_cancel (pi->core_transmit[i]); 3176 GNUNET_CORE_notify_transmit_ready_cancel (pi->core_transmit[i]);
3162 /* TODO: notify that tranmission has failed */ 3177 /* TODO: notify that tranmission has failed */
3178 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: data at %u\n", i);
3163 switch (pi->types[i]) 3179 switch (pi->types[i])
3164 { 3180 {
3165 case GNUNET_MESSAGE_TYPE_MESH_MULTICAST: 3181 case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
3166 case GNUNET_MESSAGE_TYPE_MESH_UNICAST: 3182 case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
3167 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: 3183 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
3184 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type payload\n");
3168 dd = pi->infos[i]; 3185 dd = pi->infos[i];
3169 if (0 == --(*dd->copies)) 3186 if (0 == --(*dd->copies))
3170 { 3187 {
@@ -3173,6 +3190,7 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
3173 } 3190 }
3174 break; 3191 break;
3175 case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE: 3192 case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE:
3193 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type create path\n");
3176 path_info = pi->infos[i]; 3194 path_info = pi->infos[i];
3177 path_destroy(path_info->path); 3195 path_destroy(path_info->path);
3178 break; 3196 break;
@@ -3298,6 +3316,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
3298// } 3316// }
3299 3317
3300 next_tid = 0; 3318 next_tid = 0;
3319 next_local_tid = GNUNET_MESH_LOCAL_TUNNEL_ID_SERV;
3301 3320
3302 tunnels = GNUNET_CONTAINER_multihashmap_create (32); 3321 tunnels = GNUNET_CONTAINER_multihashmap_create (32);
3303 peers = GNUNET_CONTAINER_multihashmap_create (32); 3322 peers = GNUNET_CONTAINER_multihashmap_create (32);