aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-27 21:06:11 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-27 21:06:11 +0000
commit65b243be0941da4896afd842deda48cd0ce488e2 (patch)
tree019901e73101b13f9602fa8118aa7503e9ee7d32 /src/mesh
parent94f1bfcb5f933ea09b9e4d066685709eba423951 (diff)
downloadgnunet-65b243be0941da4896afd842deda48cd0ce488e2.tar.gz
gnunet-65b243be0941da4896afd842deda48cd0ce488e2.zip
DHT api switch adjustments
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c90
1 files changed, 37 insertions, 53 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index c90cada1b..e26cf666e 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -577,10 +577,6 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
577 * @param cls closure 577 * @param cls closure
578 * @param exp when will this value expire 578 * @param exp when will this value expire
579 * @param key key of the result 579 * @param key key of the result
580 * @param get_path NULL-terminated array of pointers
581 * to the peers on reverse GET path (or NULL if not recorded)
582 * @param put_path NULL-terminated array of pointers
583 * to the peers on the PUT path (or NULL if not recorded)
584 * @param type type of the result 580 * @param type type of the result
585 * @param size number of bytes in data 581 * @param size number of bytes in data
586 * @param data pointer to the result data 582 * @param data pointer to the result data
@@ -588,8 +584,10 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
588static void 584static void
589dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, 585dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
590 const GNUNET_HashCode * key, 586 const GNUNET_HashCode * key,
591 const struct GNUNET_PeerIdentity *const *get_path, 587 const struct GNUNET_PeerIdentity *get_path,
592 const struct GNUNET_PeerIdentity *const *put_path, 588 unsigned int get_path_length,
589 const struct GNUNET_PeerIdentity *put_path,
590 unsigned int put_path_length,
593 enum GNUNET_BLOCK_Type type, size_t size, const void *data); 591 enum GNUNET_BLOCK_Type type, size_t size, const void *data);
594 592
595 593
@@ -759,11 +757,9 @@ path_remove_from_peer (struct MeshPeerInfo *peer,
759 &id.hashPubKey, /*key to search */ 757 &id.hashPubKey, /*key to search */
760 4, /* replication level */ 758 4, /* replication level */
761 GNUNET_DHT_RO_RECORD_ROUTE, 759 GNUNET_DHT_RO_RECORD_ROUTE,
762 NULL, /* bloom filter */
763 0, /* mutator */
764 NULL, /* xquery */ 760 NULL, /* xquery */
765 0, /* xquery bits */ 761 0, /* xquery bits */
766 dht_get_id_handler, 762 &dht_get_id_handler,
767 (void *) path_info); 763 (void *) path_info);
768 } 764 }
769 } 765 }
@@ -839,27 +835,24 @@ path_add_to_origin (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path)
839 * Build a PeerPath from the paths returned from the DHT, reversing the paths 835 * Build a PeerPath from the paths returned from the DHT, reversing the paths
840 * to obtain a local peer -> destination path and interning the peer ids. 836 * to obtain a local peer -> destination path and interning the peer ids.
841 * 837 *
842 * @param get_path NULL-terminated array of pointers
843 * to the peers on reverse GET path (or NULL if not recorded)
844 * @param put_path NULL-terminated array of pointers
845 * to the peers on the PUT path (or NULL if not recorded)
846 *
847 * @return Newly allocated and created path 838 * @return Newly allocated and created path
848 */ 839 */
849static struct MeshPeerPath * 840static struct MeshPeerPath *
850path_build_from_dht (const struct GNUNET_PeerIdentity *const *get_path, 841path_build_from_dht (const struct GNUNET_PeerIdentity *get_path,
851 const struct GNUNET_PeerIdentity *const *put_path) 842 unsigned int get_path_length,
843 const struct GNUNET_PeerIdentity *put_path,
844 unsigned int put_path_length)
852{ 845{
853 struct MeshPeerPath *p; 846 struct MeshPeerPath *p;
854 GNUNET_PEER_Id id; 847 GNUNET_PEER_Id id;
855 int i; 848 int i;
856 849
857 p = path_new (0); 850 p = path_new (0);
858 for (i = 0; get_path[i] != NULL; i++) ; 851 i = get_path_length;
859 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "MESH: GET has %d hops.\n", i); 852 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "MESH: GET has %d hops.\n", i);
860 for (i--; i >= 0; i--) 853 for (i--; i >= 0; i--)
861 { 854 {
862 id = GNUNET_PEER_intern (get_path[i]); 855 id = GNUNET_PEER_intern (&get_path[i]);
863 if (p->length > 0 && id == p->peers[p->length - 1]) 856 if (p->length > 0 && id == p->peers[p->length - 1])
864 { 857 {
865 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "MESH: Optimizing 1 hop out.\n"); 858 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "MESH: Optimizing 1 hop out.\n");
@@ -873,11 +866,11 @@ path_build_from_dht (const struct GNUNET_PeerIdentity *const *get_path,
873 p->length++; 866 p->length++;
874 } 867 }
875 } 868 }
876 for (i = 0; put_path[i] != NULL; i++) ; 869 i = put_path_length;
877 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "MESH: PUT has %d hops.\n", i); 870 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "MESH: PUT has %d hops.\n", i);
878 for (i--; i >= 0; i--) 871 for (i--; i >= 0; i--)
879 { 872 {
880 id = GNUNET_PEER_intern (put_path[i]); 873 id = GNUNET_PEER_intern (&put_path[i]);
881 if (p->length > 0 && id == p->peers[p->length - 1]) 874 if (p->length > 0 && id == p->peers[p->length - 1])
882 { 875 {
883 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "MESH: Optimizing 1 hop out.\n"); 876 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "MESH: Optimizing 1 hop out.\n");
@@ -894,10 +887,10 @@ path_build_from_dht (const struct GNUNET_PeerIdentity *const *get_path,
894#if MESH_DEBUG 887#if MESH_DEBUG
895 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
896 "MESH: (first of GET: %s)\n", 889 "MESH: (first of GET: %s)\n",
897 GNUNET_h2s_full(&get_path[0]->hashPubKey)); 890 GNUNET_h2s_full(&get_path[0].hashPubKey));
898 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 891 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
899 "MESH: (first of PUT: %s)\n", 892 "MESH: (first of PUT: %s)\n",
900 GNUNET_h2s_full(&put_path[0]->hashPubKey)); 893 GNUNET_h2s_full(&put_path[0].hashPubKey));
901 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 894 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
902 "MESH: In total: %d hops\n", 895 "MESH: In total: %d hops\n",
903 p->length); 896 p->length);
@@ -2046,10 +2039,6 @@ notify_client_connection_failure (void *cls, size_t size, void *buf)
2046 * @param cls closure 2039 * @param cls closure
2047 * @param exp when will this value expire 2040 * @param exp when will this value expire
2048 * @param key key of the result 2041 * @param key key of the result
2049 * @param get_path NULL-terminated array of pointers
2050 * to the peers on reverse GET path (or NULL if not recorded)
2051 * @param put_path NULL-terminated array of pointers
2052 * to the peers on the PUT path (or NULL if not recorded)
2053 * @param type type of the result 2042 * @param type type of the result
2054 * @param size number of bytes in data 2043 * @param size number of bytes in data
2055 * @param data pointer to the result data 2044 * @param data pointer to the result data
@@ -2059,8 +2048,10 @@ notify_client_connection_failure (void *cls, size_t size, void *buf)
2059static void 2048static void
2060dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, 2049dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
2061 const GNUNET_HashCode * key, 2050 const GNUNET_HashCode * key,
2062 const struct GNUNET_PeerIdentity *const *get_path, 2051 const struct GNUNET_PeerIdentity *get_path,
2063 const struct GNUNET_PeerIdentity *const *put_path, 2052 unsigned int get_path_length,
2053 const struct GNUNET_PeerIdentity *put_path,
2054 unsigned int put_path_length,
2064 enum GNUNET_BLOCK_Type type, size_t size, const void *data) 2055 enum GNUNET_BLOCK_Type type, size_t size, const void *data)
2065{ 2056{
2066 struct MeshPathInfo *path_info = cls; 2057 struct MeshPathInfo *path_info = cls;
@@ -2080,17 +2071,16 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
2080 GNUNET_BLOCK_TYPE_TEST, /* type */ 2071 GNUNET_BLOCK_TYPE_TEST, /* type */
2081 &pi.hashPubKey, /*key to search */ 2072 &pi.hashPubKey, /*key to search */
2082 4, /* replication level */ 2073 4, /* replication level */
2083 GNUNET_DHT_RO_RECORD_ROUTE, NULL, /* bloom filter */ 2074 GNUNET_DHT_RO_RECORD_ROUTE,
2084 0, /* mutator */
2085 NULL, /* xquery */ 2075 NULL, /* xquery */
2086 0, /* xquery bits */ 2076 0, /* xquery bits */
2087 dht_get_id_handler, 2077 &dht_get_id_handler,
2088 (void *) path_info); 2078 (void *) path_info);
2089 return; 2079 return;
2090 } 2080 }
2091 } 2081 }
2092 2082
2093 p = path_build_from_dht (get_path, put_path); 2083 p = path_build_from_dht (get_path, get_path_length, put_path, put_path_length);
2094 path_add_to_peer (path_info->peer, p); 2084 path_add_to_peer (path_info->peer, p);
2095 for (i = 0; i < path_info->peer->ntunnels; i++) 2085 for (i = 0; i < path_info->peer->ntunnels; i++)
2096 { 2086 {
@@ -2110,10 +2100,6 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
2110 * @param cls closure 2100 * @param cls closure
2111 * @param exp when will this value expire 2101 * @param exp when will this value expire
2112 * @param key key of the result 2102 * @param key key of the result
2113 * @param get_path NULL-terminated array of pointers
2114 * to the peers on reverse GET path (or NULL if not recorded)
2115 * @param put_path NULL-terminated array of pointers
2116 * to the peers on the PUT path (or NULL if not recorded)
2117 * @param type type of the result 2103 * @param type type of the result
2118 * @param size number of bytes in data 2104 * @param size number of bytes in data
2119 * @param data pointer to the result data 2105 * @param data pointer to the result data
@@ -2121,8 +2107,10 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
2121static void 2107static void
2122dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, 2108dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp,
2123 const GNUNET_HashCode * key, 2109 const GNUNET_HashCode * key,
2124 const struct GNUNET_PeerIdentity *const *get_path, 2110 const struct GNUNET_PeerIdentity *get_path,
2125 const struct GNUNET_PeerIdentity *const *put_path, 2111 unsigned int get_path_length,
2112 const struct GNUNET_PeerIdentity *put_path,
2113 unsigned int put_path_length,
2126 enum GNUNET_BLOCK_Type type, size_t size, 2114 enum GNUNET_BLOCK_Type type, size_t size,
2127 const void *data) 2115 const void *data)
2128{ 2116{
@@ -2162,8 +2150,6 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp,
2162 /* replication level */ 2150 /* replication level */
2163 GNUNET_DHT_RO_RECORD_ROUTE, 2151 GNUNET_DHT_RO_RECORD_ROUTE,
2164 /* option to dht: record route */ 2152 /* option to dht: record route */
2165 NULL, /* bloom filter */
2166 0, /* mutator */
2167 NULL, /* xquery */ 2153 NULL, /* xquery */
2168 0, /* xquery bits */ 2154 0, /* xquery bits */
2169 dht_get_id_handler, 2155 dht_get_id_handler,
@@ -2171,7 +2157,7 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp,
2171 peer_info); /* closure */ 2157 peer_info); /* closure */
2172 } 2158 }
2173 2159
2174 p = path_build_from_dht (get_path, put_path); 2160 p = path_build_from_dht (get_path, get_path_length, put_path, put_path_length);
2175 path_add_to_peer (peer_info, p); 2161 path_add_to_peer (peer_info, p);
2176 tunnel_add_peer(t, peer_info); 2162 tunnel_add_peer(t, peer_info);
2177 p = tree_get_path_to_peer(t->tree, peer_info->id); 2163 p = tree_get_path_to_peer(t->tree, peer_info->id);
@@ -2595,17 +2581,15 @@ handle_local_connect_add (void *cls, struct GNUNET_SERVER_Client *client,
2595 path_info->peer = peer_info; 2581 path_info->peer = peer_info;
2596 path_info->t = t; 2582 path_info->t = t;
2597 peer_info->dhtget = GNUNET_DHT_get_start(dht_handle, /* handle */ 2583 peer_info->dhtget = GNUNET_DHT_get_start(dht_handle, /* handle */
2598 GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ 2584 GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
2599 GNUNET_BLOCK_TYPE_TEST, /* type */ 2585 GNUNET_BLOCK_TYPE_TEST, /* type */
2600 &peer_msg->peer.hashPubKey, /*key to search */ 2586 &peer_msg->peer.hashPubKey, /*key to search */
2601 4, /* replication level */ 2587 4, /* replication level */
2602 GNUNET_DHT_RO_RECORD_ROUTE, 2588 GNUNET_DHT_RO_RECORD_ROUTE,
2603 NULL, /* bloom filter */ 2589 NULL, /* xquery */
2604 0, /* mutator */ 2590 0, /* xquery bits */
2605 NULL, /* xquery */ 2591 &dht_get_id_handler,
2606 0, /* xquery bits */ 2592 (void *) path_info);
2607 dht_get_id_handler,
2608 (void *) path_info);
2609 } 2593 }
2610 if (NULL != peer_info->path_head) 2594 if (NULL != peer_info->path_head)
2611 { 2595 {
@@ -2761,7 +2745,7 @@ handle_local_connect_by_type (void *cls, struct GNUNET_SERVER_Client *client,
2761 c->dht_get_type = 2745 c->dht_get_type =
2762 GNUNET_DHT_get_start (dht_handle, GNUNET_TIME_UNIT_FOREVER_REL, 2746 GNUNET_DHT_get_start (dht_handle, GNUNET_TIME_UNIT_FOREVER_REL,
2763 GNUNET_BLOCK_TYPE_TEST, &hash, 10U, 2747 GNUNET_BLOCK_TYPE_TEST, &hash, 10U,
2764 GNUNET_DHT_RO_RECORD_ROUTE, NULL, 0, NULL, 0, 2748 GNUNET_DHT_RO_RECORD_ROUTE, NULL, 0,
2765 &dht_get_type_handler, t); 2749 &dht_get_type_handler, t);
2766 2750
2767 GNUNET_SERVER_receive_done (client, GNUNET_OK); 2751 GNUNET_SERVER_receive_done (client, GNUNET_OK);