diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-10-07 13:25:31 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-10-07 13:25:31 +0000 |
commit | 127cddf66adb99459a5d0ad2f7cafc5c18c27879 (patch) | |
tree | 916940ae81c121bc9029beb347685561de16f830 /src/mesh | |
parent | d362ce610be73a50342ea0b5245622e048f56d2e (diff) | |
download | gnunet-127cddf66adb99459a5d0ad2f7cafc5c18c27879.tar.gz gnunet-127cddf66adb99459a5d0ad2f7cafc5c18c27879.zip |
Use new functions for CREATE PATH instead of explicit calling core
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 116 |
1 files changed, 12 insertions, 104 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 0dd729ec6..8d6780493 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -1530,12 +1530,13 @@ send_core_create_path (void *cls, size_t size, void *buf) | |||
1530 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: buf: %p\n", buf); | 1530 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: buf: %p\n", buf); |
1531 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: size: (%u/%u)\n", | 1531 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: size: (%u/%u)\n", |
1532 | size, size_needed); | 1532 | size, size_needed); |
1533 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, | 1533 | info->peer->core_transmit[info->pos] = |
1534 | GNUNET_TIME_UNIT_FOREVER_REL, | 1534 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
1535 | path_get_first_hop (t->tree, peer->id), | 1535 | GNUNET_TIME_UNIT_FOREVER_REL, |
1536 | size_needed, | 1536 | path_get_first_hop (t->tree, peer->id), |
1537 | &send_core_create_path, | 1537 | size_needed, |
1538 | info); | 1538 | &send_core_create_path, |
1539 | info); | ||
1539 | return 0; | 1540 | return 0; |
1540 | } | 1541 | } |
1541 | 1542 | ||
@@ -1803,7 +1804,6 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1803 | MESH_TunnelNumber tid; | 1804 | MESH_TunnelNumber tid; |
1804 | struct GNUNET_MESH_ManipulatePath *msg; | 1805 | struct GNUNET_MESH_ManipulatePath *msg; |
1805 | struct GNUNET_PeerIdentity *pi; | 1806 | struct GNUNET_PeerIdentity *pi; |
1806 | struct GNUNET_PeerIdentity id; | ||
1807 | GNUNET_HashCode hash; | 1807 | GNUNET_HashCode hash; |
1808 | struct MeshPeerPath *path; | 1808 | struct MeshPeerPath *path; |
1809 | struct MeshPeerInfo *dest_peer_info; | 1809 | struct MeshPeerInfo *dest_peer_info; |
@@ -1932,25 +1932,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1932 | else | 1932 | else |
1933 | { | 1933 | { |
1934 | /* It's for somebody else! Retransmit. */ | 1934 | /* It's for somebody else! Retransmit. */ |
1935 | struct MeshPathInfo *path_info; | 1935 | send_create_path(dest_peer_info, path, t); |
1936 | |||
1937 | path_info = GNUNET_malloc (sizeof (struct MeshPathInfo)); | ||
1938 | path_info->t = t; | ||
1939 | path_info->path = path; | ||
1940 | path_info->peer = dest_peer_info; | ||
1941 | |||
1942 | path_add_to_peer (dest_peer_info, path); | ||
1943 | GNUNET_PEER_resolve (path->peers[own_pos + 1], &id); | ||
1944 | GNUNET_CORE_notify_transmit_ready ( | ||
1945 | core_handle, | ||
1946 | 0, | ||
1947 | 0, | ||
1948 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1949 | &id, | ||
1950 | sizeof (struct GNUNET_MESH_ManipulatePath) + | ||
1951 | path->length * sizeof(struct GNUNET_PeerIdentity), | ||
1952 | &send_core_create_path, | ||
1953 | path_info); | ||
1954 | } | 1936 | } |
1955 | return GNUNET_OK; | 1937 | return GNUNET_OK; |
1956 | } | 1938 | } |
@@ -2501,29 +2483,7 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
2501 | 2483 | ||
2502 | if (p->length > 1) | 2484 | if (p->length > 1) |
2503 | { | 2485 | { |
2504 | path_info = GNUNET_malloc(sizeof(struct MeshPathInfo)); | 2486 | send_create_path(peer_info, p, t); |
2505 | path_info->t = t; | ||
2506 | path_info->peer = peer_info; | ||
2507 | path_info->path = p; | ||
2508 | GNUNET_PEER_resolve (p->peers[1], &id); | ||
2509 | GNUNET_CORE_notify_transmit_ready (core_handle, | ||
2510 | /* handle */ | ||
2511 | 0, | ||
2512 | /* cork */ | ||
2513 | 0, | ||
2514 | /* priority */ | ||
2515 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
2516 | /* timeout */ | ||
2517 | &id, | ||
2518 | /* target */ | ||
2519 | sizeof (struct GNUNET_MESH_ManipulatePath) | ||
2520 | + | ||
2521 | (p->length * | ||
2522 | sizeof (struct GNUNET_PeerIdentity)), | ||
2523 | /*size */ | ||
2524 | &send_core_create_path, | ||
2525 | /* callback */ | ||
2526 | path_info); /* cls */ | ||
2527 | return; | 2487 | return; |
2528 | } | 2488 | } |
2529 | path_destroy(p); | 2489 | path_destroy(p); |
@@ -2854,7 +2814,6 @@ handle_local_connect_add (void *cls, struct GNUNET_SERVER_Client *client, | |||
2854 | const struct GNUNET_MessageHeader *message) | 2814 | const struct GNUNET_MessageHeader *message) |
2855 | { | 2815 | { |
2856 | struct GNUNET_MESH_PeerControl *peer_msg; | 2816 | struct GNUNET_MESH_PeerControl *peer_msg; |
2857 | struct MeshPathInfo *path_info; | ||
2858 | struct MeshPeerInfo *peer_info; | 2817 | struct MeshPeerInfo *peer_info; |
2859 | struct MeshClient *c; | 2818 | struct MeshClient *c; |
2860 | struct MeshTunnel *t; | 2819 | struct MeshTunnel *t; |
@@ -2899,60 +2858,9 @@ handle_local_connect_add (void *cls, struct GNUNET_SERVER_Client *client, | |||
2899 | GNUNET_h2s_full(&peer_msg->peer.hashPubKey)); | 2858 | GNUNET_h2s_full(&peer_msg->peer.hashPubKey)); |
2900 | peer_info = peer_info_get (&peer_msg->peer); | 2859 | peer_info = peer_info_get (&peer_msg->peer); |
2901 | 2860 | ||
2902 | /* Start DHT search if needed, otherwise just add peer to tunnel. */ | 2861 | tunnel_add_peer(t, peer_info); |
2903 | if (NULL == peer_info->dhtget && NULL == peer_info->path_head) | 2862 | peer_info_connect(peer_info, t); |
2904 | { | 2863 | |
2905 | path_info = GNUNET_malloc(sizeof(struct MeshPathInfo)); | ||
2906 | path_info->peer = peer_info; | ||
2907 | path_info->t = t; | ||
2908 | peer_info->dhtget = | ||
2909 | GNUNET_DHT_get_start(dht_handle, /* handle */ | ||
2910 | GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ | ||
2911 | GNUNET_BLOCK_TYPE_TEST, /* type */ | ||
2912 | &peer_msg->peer.hashPubKey, /*key to search */ | ||
2913 | 4, /* replication level */ | ||
2914 | GNUNET_DHT_RO_RECORD_ROUTE | | ||
2915 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, | ||
2916 | NULL, /* xquery */ | ||
2917 | 0, /* xquery bits */ | ||
2918 | &dht_get_id_handler, | ||
2919 | (void *) path_info); | ||
2920 | } | ||
2921 | else if (NULL != peer_info->path_head) | ||
2922 | { | ||
2923 | unsigned int i; | ||
2924 | for (i = 0; i < CORE_QUEUE_SIZE; i++) | ||
2925 | { | ||
2926 | if (NULL == peer_info->core_transmit[i]) | ||
2927 | break; | ||
2928 | } | ||
2929 | if (CORE_QUEUE_SIZE == i) | ||
2930 | { | ||
2931 | GNUNET_break (0); | ||
2932 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
2933 | return; | ||
2934 | } | ||
2935 | path_info = GNUNET_malloc(sizeof(struct MeshPathInfo)); | ||
2936 | path_info->peer = peer_info; | ||
2937 | path_info->t = t; | ||
2938 | tunnel_add_peer(t, peer_info); | ||
2939 | path_info->path = tree_get_path_to_peer(t->tree, peer_info->id); | ||
2940 | peer_info = peer_info_get(path_get_first_hop(t->tree, path_info->peer->id)); | ||
2941 | peer_info->infos[i] = path_info; | ||
2942 | peer_info->types[i] = GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE; | ||
2943 | peer_info->core_transmit[i] = | ||
2944 | GNUNET_CORE_notify_transmit_ready ( | ||
2945 | core_handle, | ||
2946 | 0, | ||
2947 | 0, | ||
2948 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
2949 | path_get_first_hop(t->tree, path_info->peer->id), | ||
2950 | sizeof (struct GNUNET_MESH_ManipulatePath) | ||
2951 | + path_info->path->length * sizeof(struct GNUNET_PeerIdentity), | ||
2952 | &send_core_create_path, | ||
2953 | path_info); | ||
2954 | } | ||
2955 | /* Otherwise: there is no path yet, but there is a DHT_get active already. */ | ||
2956 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 2864 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
2957 | return; | 2865 | return; |
2958 | } | 2866 | } |