aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-05-02 10:51:57 +0000
committerBart Polot <bart@net.in.tum.de>2011-05-02 10:51:57 +0000
commitc48a63ae7892a19ff7c7a06b04ef5400858cea76 (patch)
tree87644a1ab69439d5902dc4715c3d4579a575986d
parentcf184a3abff916a1935fcc9c501060da59d2ef66 (diff)
downloadgnunet-c48a63ae7892a19ff7c7a06b04ef5400858cea76.tar.gz
gnunet-c48a63ae7892a19ff7c7a06b04ef5400858cea76.zip
WiP
-rw-r--r--src/mesh/gnunet-service-mesh.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index b60b54279..dcd7de9ff 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -294,6 +294,7 @@ struct Path
294 * List of all the peers that form the path from origin to target 294 * List of all the peers that form the path from origin to target
295 */ 295 */
296 GNUNET_PEER_Id *peers; 296 GNUNET_PEER_Id *peers;
297 int length;
297}; 298};
298 299
299struct MESH_queue 300struct MESH_queue
@@ -854,12 +855,77 @@ handle_local_connect_del (void *cls,
854 struct GNUNET_SERVER_Client *client, 855 struct GNUNET_SERVER_Client *client,
855 const struct GNUNET_MessageHeader *message) 856 const struct GNUNET_MessageHeader *message)
856{ 857{
858 struct GNUNET_MESH_PeerControl *peer_msg;
859 struct Client *c;
860 struct MESH_tunnel *t;
861 struct Path *p;
862 struct Path *aux;
863 MESH_TunnelID tid;
864 GNUNET_PEER_Id peer_id;
865 struct PeerInfo *peer_info;
866 int i;
867
857 /* Sanity check for client registration */ 868 /* Sanity check for client registration */
858 if(NULL == client_retrieve(client)) { 869 if(NULL == (c = client_retrieve(client))) {
859 GNUNET_break(0); 870 GNUNET_break(0);
860 GNUNET_SERVER_receive_done(client, GNUNET_SYSERR); 871 GNUNET_SERVER_receive_done(client, GNUNET_SYSERR);
861 return; 872 return;
862 } 873 }
874 peer_msg = (struct GNUNET_MESH_PeerControl *)message;
875 /* Sanity check for message size */
876 if(sizeof(struct GNUNET_MESH_PeerControl) != ntohs(peer_msg->header.size)) {
877 GNUNET_break(0);
878 GNUNET_SERVER_receive_done(client, GNUNET_SYSERR);
879 return;
880 }
881
882 /* Tunnel exists? */
883 tid = ntohl(peer_msg->tunnel_id);
884 if(NULL == (t = c->tunnels_head)) {
885 GNUNET_break(0);
886 GNUNET_SERVER_receive_done(client, GNUNET_SYSERR);
887 return;
888 }
889 while(NULL != t) {
890 if(t->tid == tid) {
891 break;
892 }
893 if(t == c->tunnels_tail) {
894 GNUNET_break(0);
895 GNUNET_SERVER_receive_done(client, GNUNET_SYSERR);
896 return;
897 }
898 t = t->next;
899 }
900
901 /* Does client own tunnel? */
902 if(t->client->handle != client) {
903 GNUNET_break(0);
904 GNUNET_SERVER_receive_done(client, GNUNET_SYSERR);
905 return;
906 }
907
908 /* Ok, delete peer from tunnel */
909 p = t->paths_head;
910 peer_id = GNUNET_PEER_intern(&peer_msg->peer);
911 while(p != NULL) {
912 if(p->peers[p->length-1] == peer_id) {
913 GNUNET_CONTAINER_DLL_remove(t->paths_head, t->paths_tail, p);
914 for(i = 0; i < p->length; i++) {
915 GNUNET_PEER_change_rc(p->peers[i], -1);
916 }
917 aux = p;
918 p = p->next;
919 GNUNET_free(aux);
920 } else {
921 p = p->next;
922 }
923 if(p == t->paths_head) {
924 break;
925 }
926 }
927 GNUNET_PEER_change_rc(peer_id, -1);
928
863 GNUNET_SERVER_receive_done(client, GNUNET_OK); 929 GNUNET_SERVER_receive_done(client, GNUNET_OK);
864 return; 930 return;
865} 931}