diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-09-16 18:14:09 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-09-16 18:14:09 +0000 |
commit | 0e0b717e63900a72227232cb0d3ff296c63881d2 (patch) | |
tree | d2174a83509078707dda2235a7dad3c1322bf9df /src | |
parent | e9e80a356bb806fe65d759bdc744f088884461b9 (diff) | |
download | gnunet-0e0b717e63900a72227232cb0d3ff296c63881d2.tar.gz gnunet-0e0b717e63900a72227232cb0d3ff296c63881d2.zip |
Ran indent script
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 306 | ||||
-rw-r--r-- | src/mesh/mesh_api.c | 2 | ||||
-rw-r--r-- | src/mesh/test_mesh_small.c | 3 |
3 files changed, 143 insertions, 168 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 51f002a78..a01217b38 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -598,8 +598,7 @@ announce_application (void *cls, const GNUNET_HashCode * key, void *value) | |||
598 | #else | 598 | #else |
599 | GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), | 599 | GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), |
600 | APP_ANNOUNCE_TIME), | 600 | APP_ANNOUNCE_TIME), |
601 | APP_ANNOUNCE_TIME, | 601 | APP_ANNOUNCE_TIME, NULL, NULL); |
602 | NULL, NULL); | ||
603 | #endif | 602 | #endif |
604 | return GNUNET_OK; | 603 | return GNUNET_OK; |
605 | } | 604 | } |
@@ -680,6 +679,7 @@ static void | |||
680 | path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 679 | path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
681 | { | 680 | { |
682 | struct MeshTunnel *t = cls; | 681 | struct MeshTunnel *t = cls; |
682 | |||
683 | // struct GNUNET_PeerIdentity id; | 683 | // struct GNUNET_PeerIdentity id; |
684 | 684 | ||
685 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) | 685 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) |
@@ -697,8 +697,7 @@ path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
697 | // &send_core_create_path, | 697 | // &send_core_create_path, |
698 | // t); | 698 | // t); |
699 | t->path_refresh_task = | 699 | t->path_refresh_task = |
700 | GNUNET_SCHEDULER_add_delayed (REFRESH_PATH_TIME, &path_refresh, | 700 | GNUNET_SCHEDULER_add_delayed (REFRESH_PATH_TIME, &path_refresh, t); |
701 | t); | ||
702 | return; | 701 | return; |
703 | } | 702 | } |
704 | 703 | ||
@@ -710,9 +709,9 @@ path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
710 | /** | 709 | /** |
711 | * Retrieve the MeshPeerInfo stucture associated with the peer, create one | 710 | * Retrieve the MeshPeerInfo stucture associated with the peer, create one |
712 | * and insert it in the appropiate structures if the peer is not known yet. | 711 | * and insert it in the appropiate structures if the peer is not known yet. |
713 | * | 712 | * |
714 | * @param peer Identity of the peer | 713 | * @param peer Identity of the peer |
715 | * | 714 | * |
716 | * @return Existing or newly created peer info | 715 | * @return Existing or newly created peer info |
717 | */ | 716 | */ |
718 | static struct MeshPeerInfo * | 717 | static struct MeshPeerInfo * |
@@ -778,10 +777,10 @@ path_destroy (struct MeshPeerPath *p) | |||
778 | 777 | ||
779 | /** | 778 | /** |
780 | * Find the first peer whom to send a packet to go down this path | 779 | * Find the first peer whom to send a packet to go down this path |
781 | * | 780 | * |
782 | * @param t The tunnel to use | 781 | * @param t The tunnel to use |
783 | * @param peer The peerinfo of the peer we are trying to reach | 782 | * @param peer The peerinfo of the peer we are trying to reach |
784 | * | 783 | * |
785 | * @return peerinfo of the peer who is the first hop in the tunnel | 784 | * @return peerinfo of the peer who is the first hop in the tunnel |
786 | * NULL on error | 785 | * NULL on error |
787 | */ | 786 | */ |
@@ -790,17 +789,17 @@ path_get_first_hop (struct MeshTunnel *t, struct MeshPeerInfo *peer) | |||
790 | { | 789 | { |
791 | struct GNUNET_PeerIdentity id; | 790 | struct GNUNET_PeerIdentity id; |
792 | 791 | ||
793 | GNUNET_PEER_resolve(peer->id, &id); | 792 | GNUNET_PEER_resolve (peer->id, &id); |
794 | return GNUNET_CONTAINER_multihashmap_get(t->paths->first_hops, | 793 | return GNUNET_CONTAINER_multihashmap_get (t->paths->first_hops, |
795 | &id.hashPubKey); | 794 | &id.hashPubKey); |
796 | } | 795 | } |
797 | 796 | ||
798 | 797 | ||
799 | /** | 798 | /** |
800 | * Get the length of a path | 799 | * Get the length of a path |
801 | * | 800 | * |
802 | * @param path The path to measure, with the local peer at any point of it | 801 | * @param path The path to measure, with the local peer at any point of it |
803 | * | 802 | * |
804 | * @return Number of hops to reach destination | 803 | * @return Number of hops to reach destination |
805 | * UINT_MAX in case the peer is not in the path | 804 | * UINT_MAX in case the peer is not in the path |
806 | */ | 805 | */ |
@@ -836,14 +835,14 @@ path_get_length (struct MeshPeerPath *path) | |||
836 | static unsigned int | 835 | static unsigned int |
837 | path_get_cost (struct MeshTunnel *t, struct MeshPeerPath *path) | 836 | path_get_cost (struct MeshTunnel *t, struct MeshPeerPath *path) |
838 | { | 837 | { |
839 | return path_get_length(path); | 838 | return path_get_length (path); |
840 | } | 839 | } |
841 | 840 | ||
842 | 841 | ||
843 | /** | 842 | /** |
844 | * Add the path to the peer and update the path used to reach it in case this | 843 | * Add the path to the peer and update the path used to reach it in case this |
845 | * is the shortest. | 844 | * is the shortest. |
846 | * | 845 | * |
847 | * @param peer_info Destination peer to add the path to. | 846 | * @param peer_info Destination peer to add the path to. |
848 | * @param path New path to add. Last peer must be the peer in arg 1. | 847 | * @param path New path to add. Last peer must be the peer in arg 1. |
849 | * | 848 | * |
@@ -868,13 +867,10 @@ path_add_to_peer (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path) | |||
868 | if (path_get_length (aux) > l) | 867 | if (path_get_length (aux) > l) |
869 | { | 868 | { |
870 | GNUNET_CONTAINER_DLL_insert_before (peer_info->path_head, | 869 | GNUNET_CONTAINER_DLL_insert_before (peer_info->path_head, |
871 | peer_info->path_tail, | 870 | peer_info->path_tail, aux, path); |
872 | aux, | ||
873 | path); | ||
874 | } | 871 | } |
875 | } | 872 | } |
876 | GNUNET_CONTAINER_DLL_insert_tail (peer_info->path_head, | 873 | GNUNET_CONTAINER_DLL_insert_tail (peer_info->path_head, peer_info->path_tail, |
877 | peer_info->path_tail, | ||
878 | path); | 874 | path); |
879 | return; | 875 | return; |
880 | } | 876 | } |
@@ -890,10 +886,9 @@ path_add_to_peer (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path) | |||
890 | * @param p2 Peer that got disconnected from p1 | 886 | * @param p2 Peer that got disconnected from p1 |
891 | */ | 887 | */ |
892 | static void | 888 | static void |
893 | tunnel_notify_connection_broken(struct MeshTunnel *t, | 889 | tunnel_notify_connection_broken (struct MeshTunnel *t, |
894 | struct MeshPeerInfo *peer, | 890 | struct MeshPeerInfo *peer, GNUNET_PEER_Id p1, |
895 | GNUNET_PEER_Id p1, | 891 | GNUNET_PEER_Id p2); |
896 | GNUNET_PEER_Id p2); | ||
897 | 892 | ||
898 | 893 | ||
899 | /** | 894 | /** |
@@ -906,8 +901,7 @@ tunnel_notify_connection_broken(struct MeshTunnel *t, | |||
906 | * no longer is. | 901 | * no longer is. |
907 | */ | 902 | */ |
908 | static void | 903 | static void |
909 | path_remove_from_peer (struct MeshPeerInfo *peer, | 904 | path_remove_from_peer (struct MeshPeerInfo *peer, GNUNET_PEER_Id p1, |
910 | GNUNET_PEER_Id p1, | ||
911 | GNUNET_PEER_Id p2) | 905 | GNUNET_PEER_Id p2) |
912 | { | 906 | { |
913 | struct MeshPeerPath *p; | 907 | struct MeshPeerPath *p; |
@@ -925,7 +919,7 @@ path_remove_from_peer (struct MeshPeerInfo *peer, | |||
925 | if ((p->peers[i] == p1 && p->peers[i + 1] == p2) || | 919 | if ((p->peers[i] == p1 && p->peers[i + 1] == p2) || |
926 | (p->peers[i] == p2 && p->peers[i + 1] == p1)) | 920 | (p->peers[i] == p2 && p->peers[i + 1] == p1)) |
927 | { | 921 | { |
928 | path_destroy(p); | 922 | path_destroy (p); |
929 | destroyed++; | 923 | destroyed++; |
930 | break; | 924 | break; |
931 | } | 925 | } |
@@ -937,7 +931,7 @@ path_remove_from_peer (struct MeshPeerInfo *peer, | |||
937 | 931 | ||
938 | for (i = 0; i < peer->ntunnels; i++) | 932 | for (i = 0; i < peer->ntunnels; i++) |
939 | { | 933 | { |
940 | tunnel_notify_connection_broken(peer->tunnels[i], peer, p1, p2); | 934 | tunnel_notify_connection_broken (peer->tunnels[i], peer, p1, p2); |
941 | } | 935 | } |
942 | } | 936 | } |
943 | 937 | ||
@@ -947,9 +941,9 @@ path_remove_from_peer (struct MeshPeerInfo *peer, | |||
947 | * this is the shortest. | 941 | * this is the shortest. |
948 | * The path is given in peer_info -> destination, therefore we turn the path | 942 | * The path is given in peer_info -> destination, therefore we turn the path |
949 | * upside down first. | 943 | * upside down first. |
950 | * | 944 | * |
951 | * @param peer_info Peer to add the path to, being the origin of the path. | 945 | * @param peer_info Peer to add the path to, being the origin of the path. |
952 | * @param path New path to add after being inversed. | 946 | * @param path New path to add after being inversed. |
953 | */ | 947 | */ |
954 | static void | 948 | static void |
955 | path_add_to_origin (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path) | 949 | path_add_to_origin (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path) |
@@ -979,8 +973,8 @@ path_add_to_origin (struct MeshPeerInfo *peer_info, struct MeshPeerPath *path) | |||
979 | * @return Newly allocated and created path | 973 | * @return Newly allocated and created path |
980 | */ | 974 | */ |
981 | static struct MeshPeerPath * | 975 | static struct MeshPeerPath * |
982 | path_build_from_dht(const struct GNUNET_PeerIdentity *const *get_path, | 976 | path_build_from_dht (const struct GNUNET_PeerIdentity *const *get_path, |
983 | const struct GNUNET_PeerIdentity *const *put_path) | 977 | const struct GNUNET_PeerIdentity *const *put_path) |
984 | { | 978 | { |
985 | struct MeshPeerPath *p; | 979 | struct MeshPeerPath *p; |
986 | int i; | 980 | int i; |
@@ -1008,9 +1002,9 @@ path_build_from_dht(const struct GNUNET_PeerIdentity *const *get_path, | |||
1008 | 1002 | ||
1009 | /** | 1003 | /** |
1010 | * Check if client has registered with the service and has not disconnected | 1004 | * Check if client has registered with the service and has not disconnected |
1011 | * | 1005 | * |
1012 | * @param client the client to check | 1006 | * @param client the client to check |
1013 | * | 1007 | * |
1014 | * @return non-NULL if client exists in the global DLL | 1008 | * @return non-NULL if client exists in the global DLL |
1015 | */ | 1009 | */ |
1016 | static struct MeshClient * | 1010 | static struct MeshClient * |
@@ -1031,10 +1025,10 @@ client_get (struct GNUNET_SERVER_Client *client) | |||
1031 | 1025 | ||
1032 | /** | 1026 | /** |
1033 | * Checks if a given client has subscribed to certain message type | 1027 | * Checks if a given client has subscribed to certain message type |
1034 | * | 1028 | * |
1035 | * @param message_type Type of message to check | 1029 | * @param message_type Type of message to check |
1036 | * @param c Client to check | 1030 | * @param c Client to check |
1037 | * | 1031 | * |
1038 | * @return GNUNET_YES or GNUNET_NO, depending on subscription status | 1032 | * @return GNUNET_YES or GNUNET_NO, depending on subscription status |
1039 | * | 1033 | * |
1040 | * TODO inline? | 1034 | * TODO inline? |
@@ -1051,10 +1045,10 @@ client_is_subscribed (uint16_t message_type, struct MeshClient *c) | |||
1051 | 1045 | ||
1052 | /** | 1046 | /** |
1053 | * Search for a tunnel among the tunnels for a client | 1047 | * Search for a tunnel among the tunnels for a client |
1054 | * | 1048 | * |
1055 | * @param c the client whose tunnels to search in | 1049 | * @param c the client whose tunnels to search in |
1056 | * @param tid the local id of the tunnel | 1050 | * @param tid the local id of the tunnel |
1057 | * | 1051 | * |
1058 | * @return tunnel handler, NULL if doesn't exist | 1052 | * @return tunnel handler, NULL if doesn't exist |
1059 | */ | 1053 | */ |
1060 | static struct MeshTunnel * | 1054 | static struct MeshTunnel * |
@@ -1069,10 +1063,10 @@ tunnel_get_by_local_id (struct MeshClient *c, MESH_TunnelNumber tid) | |||
1069 | 1063 | ||
1070 | /** | 1064 | /** |
1071 | * Search for a tunnel by global ID using PEER_ID | 1065 | * Search for a tunnel by global ID using PEER_ID |
1072 | * | 1066 | * |
1073 | * @param pi owner of the tunnel | 1067 | * @param pi owner of the tunnel |
1074 | * @param tid global tunnel number | 1068 | * @param tid global tunnel number |
1075 | * | 1069 | * |
1076 | * @return tunnel handler, NULL if doesn't exist | 1070 | * @return tunnel handler, NULL if doesn't exist |
1077 | */ | 1071 | */ |
1078 | static struct MeshTunnel * | 1072 | static struct MeshTunnel * |
@@ -1092,10 +1086,10 @@ tunnel_get_by_pi (GNUNET_PEER_Id pi, MESH_TunnelNumber tid) | |||
1092 | 1086 | ||
1093 | /** | 1087 | /** |
1094 | * Search for a tunnel by global ID using full PeerIdentities | 1088 | * Search for a tunnel by global ID using full PeerIdentities |
1095 | * | 1089 | * |
1096 | * @param oid owner of the tunnel | 1090 | * @param oid owner of the tunnel |
1097 | * @param tid global tunnel number | 1091 | * @param tid global tunnel number |
1098 | * | 1092 | * |
1099 | * @return tunnel handler, NULL if doesn't exist | 1093 | * @return tunnel handler, NULL if doesn't exist |
1100 | */ | 1094 | */ |
1101 | static struct MeshTunnel * | 1095 | static struct MeshTunnel * |
@@ -1114,7 +1108,7 @@ tunnel_get (struct GNUNET_PeerIdentity *oid, MESH_TunnelNumber tid) | |||
1114 | * @return Pointer to the node of the peer. NULL if not found. | 1108 | * @return Pointer to the node of the peer. NULL if not found. |
1115 | */ | 1109 | */ |
1116 | static struct MeshTunnelPathNode * | 1110 | static struct MeshTunnelPathNode * |
1117 | tunnel_find_peer(struct MeshTunnelPathNode *root, struct MeshPeerInfo *peer) | 1111 | tunnel_find_peer (struct MeshTunnelPathNode *root, struct MeshPeerInfo *peer) |
1118 | { | 1112 | { |
1119 | struct MeshTunnelPathNode *n; | 1113 | struct MeshTunnelPathNode *n; |
1120 | unsigned int i; | 1114 | unsigned int i; |
@@ -1123,7 +1117,7 @@ tunnel_find_peer(struct MeshTunnelPathNode *root, struct MeshPeerInfo *peer) | |||
1123 | return root; | 1117 | return root; |
1124 | for (i = 0; i < root->nchildren; i++) | 1118 | for (i = 0; i < root->nchildren; i++) |
1125 | { | 1119 | { |
1126 | n = tunnel_find_peer(&root->children[i], peer); | 1120 | n = tunnel_find_peer (&root->children[i], peer); |
1127 | if (NULL != n) | 1121 | if (NULL != n) |
1128 | return n; | 1122 | return n; |
1129 | } | 1123 | } |
@@ -1133,7 +1127,7 @@ tunnel_find_peer(struct MeshTunnelPathNode *root, struct MeshPeerInfo *peer) | |||
1133 | 1127 | ||
1134 | /** | 1128 | /** |
1135 | * Recusively mark peer and children as disconnected, notify client | 1129 | * Recusively mark peer and children as disconnected, notify client |
1136 | * | 1130 | * |
1137 | * @param parent Node to be clean, potentially with children | 1131 | * @param parent Node to be clean, potentially with children |
1138 | */ | 1132 | */ |
1139 | static void | 1133 | static void |
@@ -1149,10 +1143,10 @@ tunnel_mark_peers_disconnected (struct MeshTunnelPathNode *parent) | |||
1149 | } | 1143 | } |
1150 | if (NULL == parent->t->client) | 1144 | if (NULL == parent->t->client) |
1151 | return; | 1145 | return; |
1152 | msg.header.size = htons(sizeof(msg)); | 1146 | msg.header.size = htons (sizeof (msg)); |
1153 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_DEL); | 1147 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_DEL); |
1154 | msg.tunnel_id = htonl(parent->t->local_tid); | 1148 | msg.tunnel_id = htonl (parent->t->local_tid); |
1155 | GNUNET_PEER_resolve(parent->peer->id, &msg.peer); | 1149 | GNUNET_PEER_resolve (parent->peer->id, &msg.peer); |
1156 | GNUNET_SERVER_notification_context_unicast (nc, parent->t->client->handle, | 1150 | GNUNET_SERVER_notification_context_unicast (nc, parent->t->client->handle, |
1157 | &msg.header, GNUNET_NO); | 1151 | &msg.header, GNUNET_NO); |
1158 | } | 1152 | } |
@@ -1164,27 +1158,26 @@ tunnel_mark_peers_disconnected (struct MeshTunnelPathNode *parent) | |||
1164 | * @param p Path to be integrated. | 1158 | * @param p Path to be integrated. |
1165 | * | 1159 | * |
1166 | * @return pointer to the pathless node, NULL on error | 1160 | * @return pointer to the pathless node, NULL on error |
1167 | * | 1161 | * |
1168 | * TODO: notify peers of deletion | 1162 | * TODO: notify peers of deletion |
1169 | */ | 1163 | */ |
1170 | static struct MeshTunnelPathNode * | 1164 | static struct MeshTunnelPathNode * |
1171 | tunnel_del_path(struct MeshTunnel *t, struct MeshPeerInfo *peer) | 1165 | tunnel_del_path (struct MeshTunnel *t, struct MeshPeerInfo *peer) |
1172 | { | 1166 | { |
1173 | struct MeshTunnelPathNode *parent; | 1167 | struct MeshTunnelPathNode *parent; |
1174 | struct MeshTunnelPathNode *node; | 1168 | struct MeshTunnelPathNode *node; |
1175 | struct MeshTunnelPathNode *n; | 1169 | struct MeshTunnelPathNode *n; |
1176 | 1170 | ||
1177 | node = n = tunnel_find_peer(t->paths->me, peer); | 1171 | node = n = tunnel_find_peer (t->paths->me, peer); |
1178 | if (NULL == n) | 1172 | if (NULL == n) |
1179 | return NULL; | 1173 | return NULL; |
1180 | parent = n->parent; | 1174 | parent = n->parent; |
1181 | n->parent = NULL; | 1175 | n->parent = NULL; |
1182 | while (NULL != parent && | 1176 | while (NULL != parent && MESH_PEER_RELAY == parent->status && |
1183 | MESH_PEER_RELAY == parent->status && | 1177 | 1 == parent->nchildren) |
1184 | 1 == parent->nchildren) | ||
1185 | { | 1178 | { |
1186 | n = parent; | 1179 | n = parent; |
1187 | GNUNET_free(parent->children); | 1180 | GNUNET_free (parent->children); |
1188 | parent = parent->parent; | 1181 | parent = parent->parent; |
1189 | } | 1182 | } |
1190 | if (NULL == parent) | 1183 | if (NULL == parent) |
@@ -1193,7 +1186,7 @@ tunnel_del_path(struct MeshTunnel *t, struct MeshPeerInfo *peer) | |||
1193 | parent->nchildren--; | 1186 | parent->nchildren--; |
1194 | parent->children = GNUNET_realloc (parent->children, parent->nchildren); | 1187 | parent->children = GNUNET_realloc (parent->children, parent->nchildren); |
1195 | 1188 | ||
1196 | tunnel_mark_peers_disconnected(node); | 1189 | tunnel_mark_peers_disconnected (node); |
1197 | 1190 | ||
1198 | return node; | 1191 | return node; |
1199 | } | 1192 | } |
@@ -1207,12 +1200,12 @@ tunnel_del_path(struct MeshTunnel *t, struct MeshPeerInfo *peer) | |||
1207 | * | 1200 | * |
1208 | * @return GNUNET_OK in case of success. | 1201 | * @return GNUNET_OK in case of success. |
1209 | * GNUNET_SYSERR in case of error. | 1202 | * GNUNET_SYSERR in case of error. |
1210 | * | 1203 | * |
1211 | * TODO: optimize | 1204 | * TODO: optimize |
1212 | * - go backwards on path looking for each peer in the present tree | 1205 | * - go backwards on path looking for each peer in the present tree |
1213 | */ | 1206 | */ |
1214 | static int | 1207 | static int |
1215 | tunnel_add_path(struct MeshTunnel *t, struct MeshPeerPath *p) | 1208 | tunnel_add_path (struct MeshTunnel *t, struct MeshPeerPath *p) |
1216 | { | 1209 | { |
1217 | struct MeshTunnelPathNode *parent; | 1210 | struct MeshTunnelPathNode *parent; |
1218 | struct MeshTunnelPathNode *oldnode; | 1211 | struct MeshTunnelPathNode *oldnode; |
@@ -1230,10 +1223,10 @@ tunnel_add_path(struct MeshTunnel *t, struct MeshPeerPath *p) | |||
1230 | return GNUNET_SYSERR; | 1223 | return GNUNET_SYSERR; |
1231 | } | 1224 | } |
1232 | /* Ignore return value, if not found it's ok. */ | 1225 | /* Ignore return value, if not found it's ok. */ |
1233 | GNUNET_PEER_resolve(p->peers[p->length - 1], &id); | 1226 | GNUNET_PEER_resolve (p->peers[p->length - 1], &id); |
1234 | oldnode = tunnel_del_path(t, peer_info_get(&id)); | 1227 | oldnode = tunnel_del_path (t, peer_info_get (&id)); |
1235 | /* Look for the first node that is not already present in the tree | 1228 | /* Look for the first node that is not already present in the tree |
1236 | * | 1229 | * |
1237 | * Assuming that the tree is somewhat balanced, O(log n * log N). | 1230 | * Assuming that the tree is somewhat balanced, O(log n * log N). |
1238 | * - Length of the path is expected to be log N (size of whole network). | 1231 | * - Length of the path is expected to be log N (size of whole network). |
1239 | * - Each level of the tree is expected to have log n children (size of tree). | 1232 | * - Each level of the tree is expected to have log n children (size of tree). |
@@ -1266,14 +1259,14 @@ tunnel_add_path(struct MeshTunnel *t, struct MeshPeerPath *p) | |||
1266 | while (i < p->length) | 1259 | while (i < p->length) |
1267 | { | 1260 | { |
1268 | parent->nchildren++; | 1261 | parent->nchildren++; |
1269 | parent->children = GNUNET_realloc(parent->children, parent->nchildren); | 1262 | parent->children = GNUNET_realloc (parent->children, parent->nchildren); |
1270 | n = &parent->children[parent->nchildren - 1]; | 1263 | n = &parent->children[parent->nchildren - 1]; |
1271 | if (i == p->length - 1) | 1264 | if (i == p->length - 1) |
1272 | { | 1265 | { |
1273 | if (NULL != oldnode) | 1266 | if (NULL != oldnode) |
1274 | { | 1267 | { |
1275 | /* Assignation and free can be misleading, using explicit mempcy */ | 1268 | /* Assignation and free can be misleading, using explicit mempcy */ |
1276 | memcpy (n, oldnode, sizeof(struct MeshTunnelPathNode)); | 1269 | memcpy (n, oldnode, sizeof (struct MeshTunnelPathNode)); |
1277 | GNUNET_free (oldnode); | 1270 | GNUNET_free (oldnode); |
1278 | } | 1271 | } |
1279 | } | 1272 | } |
@@ -1281,8 +1274,8 @@ tunnel_add_path(struct MeshTunnel *t, struct MeshPeerPath *p) | |||
1281 | { | 1274 | { |
1282 | n->t = t; | 1275 | n->t = t; |
1283 | n->status = MESH_PEER_RELAY; | 1276 | n->status = MESH_PEER_RELAY; |
1284 | GNUNET_PEER_resolve(p->peers[i], &id); | 1277 | GNUNET_PEER_resolve (p->peers[i], &id); |
1285 | n->peer = peer_info_get(&id); | 1278 | n->peer = peer_info_get (&id); |
1286 | } | 1279 | } |
1287 | n->parent = parent; | 1280 | n->parent = parent; |
1288 | i++; | 1281 | i++; |
@@ -1292,13 +1285,11 @@ tunnel_add_path(struct MeshTunnel *t, struct MeshPeerPath *p) | |||
1292 | /* Add info about first hop into hashmap. */ | 1285 | /* Add info about first hop into hashmap. */ |
1293 | if (me < p->length - 1) | 1286 | if (me < p->length - 1) |
1294 | { | 1287 | { |
1295 | GNUNET_PEER_resolve(p->peers[p->length - 1], &id); | 1288 | GNUNET_PEER_resolve (p->peers[p->length - 1], &id); |
1296 | GNUNET_PEER_resolve(p->peers[me + 1], &hop); | 1289 | GNUNET_PEER_resolve (p->peers[me + 1], &hop); |
1297 | GNUNET_CONTAINER_multihashmap_put( | 1290 | GNUNET_CONTAINER_multihashmap_put (t->paths->first_hops, &id.hashPubKey, |
1298 | t->paths->first_hops, | 1291 | peer_info_get (&hop), |
1299 | &id.hashPubKey, | 1292 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
1300 | peer_info_get(&hop), | ||
1301 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | ||
1302 | } | 1293 | } |
1303 | return GNUNET_OK; | 1294 | return GNUNET_OK; |
1304 | } | 1295 | } |
@@ -1313,14 +1304,14 @@ tunnel_add_path(struct MeshTunnel *t, struct MeshPeerPath *p) | |||
1313 | * | 1304 | * |
1314 | */ | 1305 | */ |
1315 | static void | 1306 | static void |
1316 | tunnel_add_peer(struct MeshTunnel *t, struct MeshPeerInfo *peer) | 1307 | tunnel_add_peer (struct MeshTunnel *t, struct MeshPeerInfo *peer) |
1317 | { | 1308 | { |
1318 | struct MeshPeerPath *p; | 1309 | struct MeshPeerPath *p; |
1319 | struct MeshPeerPath *best_p; | 1310 | struct MeshPeerPath *best_p; |
1320 | unsigned int best_cost; | 1311 | unsigned int best_cost; |
1321 | unsigned int cost; | 1312 | unsigned int cost; |
1322 | 1313 | ||
1323 | GNUNET_array_append(peer->tunnels, peer->ntunnels, t); | 1314 | GNUNET_array_append (peer->tunnels, peer->ntunnels, t); |
1324 | if (NULL == (p = peer->path_head)) | 1315 | if (NULL == (p = peer->path_head)) |
1325 | return; | 1316 | return; |
1326 | 1317 | ||
@@ -1328,17 +1319,17 @@ tunnel_add_peer(struct MeshTunnel *t, struct MeshPeerInfo *peer) | |||
1328 | best_cost = UINT_MAX; | 1319 | best_cost = UINT_MAX; |
1329 | while (NULL != p) | 1320 | while (NULL != p) |
1330 | { | 1321 | { |
1331 | if ((cost = path_get_cost(t, p)) < best_cost) | 1322 | if ((cost = path_get_cost (t, p)) < best_cost) |
1332 | { | 1323 | { |
1333 | best_cost = cost; | 1324 | best_cost = cost; |
1334 | best_p = p; | 1325 | best_p = p; |
1335 | } | 1326 | } |
1336 | p = p->next; | 1327 | p = p->next; |
1337 | } | 1328 | } |
1338 | tunnel_add_path(t, best_p); | 1329 | tunnel_add_path (t, best_p); |
1339 | if (GNUNET_SCHEDULER_NO_TASK == t->path_refresh_task) | 1330 | if (GNUNET_SCHEDULER_NO_TASK == t->path_refresh_task) |
1340 | t->path_refresh_task = GNUNET_SCHEDULER_add_delayed (REFRESH_PATH_TIME, | 1331 | t->path_refresh_task = |
1341 | &path_refresh, t); | 1332 | GNUNET_SCHEDULER_add_delayed (REFRESH_PATH_TIME, &path_refresh, t); |
1342 | } | 1333 | } |
1343 | 1334 | ||
1344 | 1335 | ||
@@ -1352,19 +1343,18 @@ tunnel_add_peer(struct MeshTunnel *t, struct MeshPeerInfo *peer) | |||
1352 | * @param p2 Peer that got disconnected from p1 | 1343 | * @param p2 Peer that got disconnected from p1 |
1353 | */ | 1344 | */ |
1354 | static void | 1345 | static void |
1355 | tunnel_notify_connection_broken(struct MeshTunnel *t, | 1346 | tunnel_notify_connection_broken (struct MeshTunnel *t, |
1356 | struct MeshPeerInfo *peer, | 1347 | struct MeshPeerInfo *peer, GNUNET_PEER_Id p1, |
1357 | GNUNET_PEER_Id p1, | 1348 | GNUNET_PEER_Id p2) |
1358 | GNUNET_PEER_Id p2) | ||
1359 | { | 1349 | { |
1360 | } | 1350 | } |
1361 | 1351 | ||
1362 | 1352 | ||
1363 | /** | 1353 | /** |
1364 | * Destroy the tunnel and free any allocated resources linked to it | 1354 | * Destroy the tunnel and free any allocated resources linked to it |
1365 | * | 1355 | * |
1366 | * @param t the tunnel to destroy | 1356 | * @param t the tunnel to destroy |
1367 | * | 1357 | * |
1368 | * @return GNUNET_OK on success | 1358 | * @return GNUNET_OK on success |
1369 | */ | 1359 | */ |
1370 | static int | 1360 | static int |
@@ -1455,7 +1445,7 @@ send_core_create_path (void *cls, size_t size, void *buf) | |||
1455 | msg = (struct GNUNET_MESH_ManipulatePath *) buf; | 1445 | msg = (struct GNUNET_MESH_ManipulatePath *) buf; |
1456 | msg->header.size = htons (size_needed); | 1446 | msg->header.size = htons (size_needed); |
1457 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE); | 1447 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE); |
1458 | msg->tid = ntohl(t->id.tid); | 1448 | msg->tid = ntohl (t->id.tid); |
1459 | 1449 | ||
1460 | peer_ptr = (struct GNUNET_PeerIdentity *) &msg[1]; | 1450 | peer_ptr = (struct GNUNET_PeerIdentity *) &msg[1]; |
1461 | for (i = 0; i < p->length; i++) | 1451 | for (i = 0; i < p->length; i++) |
@@ -1463,7 +1453,7 @@ send_core_create_path (void *cls, size_t size, void *buf) | |||
1463 | GNUNET_PEER_resolve (p->peers[i], peer_ptr++); | 1453 | GNUNET_PEER_resolve (p->peers[i], peer_ptr++); |
1464 | } | 1454 | } |
1465 | 1455 | ||
1466 | path_destroy(p); | 1456 | path_destroy (p); |
1467 | GNUNET_free (info); | 1457 | GNUNET_free (info); |
1468 | 1458 | ||
1469 | return size_needed; | 1459 | return size_needed; |
@@ -1643,7 +1633,7 @@ send_core_path_ack (void *cls, size_t size, void *buf) | |||
1643 | GNUNET_PEER_resolve (info->origin->oid, &msg->oid); | 1633 | GNUNET_PEER_resolve (info->origin->oid, &msg->oid); |
1644 | msg->tid = htonl (info->origin->tid); | 1634 | msg->tid = htonl (info->origin->tid); |
1645 | msg->peer_id = my_full_id; | 1635 | msg->peer_id = my_full_id; |
1646 | GNUNET_free(info); | 1636 | GNUNET_free (info); |
1647 | /* TODO add signature */ | 1637 | /* TODO add signature */ |
1648 | 1638 | ||
1649 | return sizeof (struct GNUNET_MESH_PathACK); | 1639 | return sizeof (struct GNUNET_MESH_PathACK); |
@@ -1762,9 +1752,8 @@ iterate_collect_neighbors (void *cls, const GNUNET_HashCode * key, void *value) | |||
1762 | if (neighbors->path->peers[i] == peer_info->id) | 1752 | if (neighbors->path->peers[i] == peer_info->id) |
1763 | return GNUNET_YES; | 1753 | return GNUNET_YES; |
1764 | } | 1754 | } |
1765 | GNUNET_array_append(neighbors->path->peers, | 1755 | GNUNET_array_append (neighbors->path->peers, neighbors->path->length, |
1766 | neighbors->path->length, | 1756 | peer_info->id); |
1767 | peer_info->id); | ||
1768 | 1757 | ||
1769 | return GNUNET_YES; | 1758 | return GNUNET_YES; |
1770 | } | 1759 | } |
@@ -1842,9 +1831,8 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1842 | 1831 | ||
1843 | GNUNET_CRYPTO_hash (&t->id, sizeof (struct MESH_TunnelID), &hash); | 1832 | GNUNET_CRYPTO_hash (&t->id, sizeof (struct MESH_TunnelID), &hash); |
1844 | if (GNUNET_OK != | 1833 | if (GNUNET_OK != |
1845 | GNUNET_CONTAINER_multihashmap_put ( | 1834 | GNUNET_CONTAINER_multihashmap_put (tunnels, &hash, t, |
1846 | tunnels, &hash, t, | 1835 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) |
1847 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | ||
1848 | { | 1836 | { |
1849 | GNUNET_break (0); | 1837 | GNUNET_break (0); |
1850 | return GNUNET_OK; | 1838 | return GNUNET_OK; |
@@ -1857,22 +1845,17 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1857 | { | 1845 | { |
1858 | dest_peer_info = GNUNET_malloc (sizeof (struct MeshPeerInfo)); | 1846 | dest_peer_info = GNUNET_malloc (sizeof (struct MeshPeerInfo)); |
1859 | dest_peer_info->id = GNUNET_PEER_intern (&pi[size - 1]); | 1847 | dest_peer_info->id = GNUNET_PEER_intern (&pi[size - 1]); |
1860 | GNUNET_CONTAINER_multihashmap_put ( | 1848 | GNUNET_CONTAINER_multihashmap_put (peers, &pi[size - 1].hashPubKey, |
1861 | peers, | 1849 | dest_peer_info, |
1862 | &pi[size - 1].hashPubKey, | 1850 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
1863 | dest_peer_info, | ||
1864 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | ||
1865 | } | 1851 | } |
1866 | orig_peer_info = GNUNET_CONTAINER_multihashmap_get (peers, &pi->hashPubKey); | 1852 | orig_peer_info = GNUNET_CONTAINER_multihashmap_get (peers, &pi->hashPubKey); |
1867 | if (NULL == orig_peer_info) | 1853 | if (NULL == orig_peer_info) |
1868 | { | 1854 | { |
1869 | orig_peer_info = GNUNET_malloc (sizeof (struct MeshPeerInfo)); | 1855 | orig_peer_info = GNUNET_malloc (sizeof (struct MeshPeerInfo)); |
1870 | orig_peer_info->id = GNUNET_PEER_intern (pi); | 1856 | orig_peer_info->id = GNUNET_PEER_intern (pi); |
1871 | GNUNET_CONTAINER_multihashmap_put ( | 1857 | GNUNET_CONTAINER_multihashmap_put (peers, &pi->hashPubKey, orig_peer_info, |
1872 | peers, | 1858 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
1873 | &pi->hashPubKey, | ||
1874 | orig_peer_info, | ||
1875 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | ||
1876 | } | 1859 | } |
1877 | 1860 | ||
1878 | path = GNUNET_malloc (sizeof (struct MeshPeerPath)); | 1861 | path = GNUNET_malloc (sizeof (struct MeshPeerPath)); |
@@ -1924,7 +1907,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1924 | /* It's for somebody else! Retransmit. */ | 1907 | /* It's for somebody else! Retransmit. */ |
1925 | struct MeshPathInfo *path_info; | 1908 | struct MeshPathInfo *path_info; |
1926 | 1909 | ||
1927 | path_info = GNUNET_malloc (sizeof(struct MeshPathInfo)); | 1910 | path_info = GNUNET_malloc (sizeof (struct MeshPathInfo)); |
1928 | path_info->t = t; | 1911 | path_info->t = t; |
1929 | path_info->path = path; | 1912 | path_info->path = path; |
1930 | path_info->peer = dest_peer_info; | 1913 | path_info->peer = dest_peer_info; |
@@ -1934,8 +1917,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1934 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, | 1917 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
1935 | GNUNET_TIME_UNIT_FOREVER_REL, &id, | 1918 | GNUNET_TIME_UNIT_FOREVER_REL, &id, |
1936 | sizeof (struct GNUNET_MessageHeader), | 1919 | sizeof (struct GNUNET_MessageHeader), |
1937 | &send_core_create_path, | 1920 | &send_core_create_path, path_info); |
1938 | path_info); | ||
1939 | } | 1921 | } |
1940 | return GNUNET_OK; | 1922 | return GNUNET_OK; |
1941 | } | 1923 | } |
@@ -2051,12 +2033,12 @@ handle_mesh_data_multicast (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2051 | * Using path here as just a collection of peers, not a path per se. | 2033 | * Using path here as just a collection of peers, not a path per se. |
2052 | */ | 2034 | */ |
2053 | neighbors.t = t; | 2035 | neighbors.t = t; |
2054 | neighbors.path = GNUNET_malloc (sizeof(struct MeshPeerPath)); | 2036 | neighbors.path = GNUNET_malloc (sizeof (struct MeshPeerPath)); |
2055 | GNUNET_CONTAINER_multihashmap_iterate (t->peers, &iterate_collect_neighbors, | 2037 | GNUNET_CONTAINER_multihashmap_iterate (t->peers, &iterate_collect_neighbors, |
2056 | &neighbors); | 2038 | &neighbors); |
2057 | if (0 == neighbors.path->length) | 2039 | if (0 == neighbors.path->length) |
2058 | { | 2040 | { |
2059 | GNUNET_free(neighbors.path); | 2041 | GNUNET_free (neighbors.path); |
2060 | return GNUNET_OK; | 2042 | return GNUNET_OK; |
2061 | } | 2043 | } |
2062 | size -= sizeof (struct GNUNET_MESH_Multicast); | 2044 | size -= sizeof (struct GNUNET_MESH_Multicast); |
@@ -2084,8 +2066,8 @@ handle_mesh_data_multicast (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2084 | ntohs (msg->header.size), | 2066 | ntohs (msg->header.size), |
2085 | &send_core_data_multicast, info); | 2067 | &send_core_data_multicast, info); |
2086 | } | 2068 | } |
2087 | GNUNET_free(neighbors.path->peers); | 2069 | GNUNET_free (neighbors.path->peers); |
2088 | GNUNET_free(neighbors.path); | 2070 | GNUNET_free (neighbors.path); |
2089 | return GNUNET_OK; | 2071 | return GNUNET_OK; |
2090 | } | 2072 | } |
2091 | 2073 | ||
@@ -2097,6 +2079,7 @@ handle_mesh_data_multicast (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2097 | * @param message message | 2079 | * @param message message |
2098 | * @param peer peer identity this notification is about | 2080 | * @param peer peer identity this notification is about |
2099 | * @param atsi performance data | 2081 | * @param atsi performance data |
2082 | * | ||
2100 | * @return GNUNET_OK to keep the connection open, | 2083 | * @return GNUNET_OK to keep the connection open, |
2101 | * GNUNET_SYSERR to close it (signal serious error) | 2084 | * GNUNET_SYSERR to close it (signal serious error) |
2102 | */ | 2085 | */ |
@@ -2104,7 +2087,7 @@ static int | |||
2104 | handle_mesh_data_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer, | 2087 | handle_mesh_data_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer, |
2105 | const struct GNUNET_MessageHeader *message, | 2088 | const struct GNUNET_MessageHeader *message, |
2106 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 2089 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
2107 | { | 2090 | { |
2108 | struct GNUNET_MESH_ToOrigin *msg; | 2091 | struct GNUNET_MESH_ToOrigin *msg; |
2109 | struct GNUNET_PeerIdentity id; | 2092 | struct GNUNET_PeerIdentity id; |
2110 | struct MeshPeerInfo *peer_info; | 2093 | struct MeshPeerInfo *peer_info; |
@@ -2112,9 +2095,8 @@ handle_mesh_data_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2112 | size_t size; | 2095 | size_t size; |
2113 | 2096 | ||
2114 | size = ntohs (message->size); | 2097 | size = ntohs (message->size); |
2115 | if (size < | 2098 | if (size < sizeof (struct GNUNET_MESH_ToOrigin) + /* Payload must be */ |
2116 | sizeof (struct GNUNET_MESH_ToOrigin) + | 2099 | sizeof (struct GNUNET_MessageHeader)) /* at least a header */ |
2117 | sizeof (struct GNUNET_MessageHeader)) /* Payload >= header */ | ||
2118 | { | 2100 | { |
2119 | GNUNET_break_op (0); | 2101 | GNUNET_break_op (0); |
2120 | return GNUNET_OK; | 2102 | return GNUNET_OK; |
@@ -2362,29 +2344,28 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
2362 | // Find ourselves some alternate initial path to the destination: retry | 2344 | // Find ourselves some alternate initial path to the destination: retry |
2363 | GNUNET_DHT_get_stop (path_info->peer->dhtget); | 2345 | GNUNET_DHT_get_stop (path_info->peer->dhtget); |
2364 | GNUNET_PEER_resolve (path_info->peer->id, &pi); | 2346 | GNUNET_PEER_resolve (path_info->peer->id, &pi); |
2365 | path_info->peer->dhtget = GNUNET_DHT_get_start ( | 2347 | path_info->peer->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */ |
2366 | dht_handle, /* handle */ | 2348 | GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ |
2367 | GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ | 2349 | GNUNET_BLOCK_TYPE_TEST, /* type */ |
2368 | GNUNET_BLOCK_TYPE_TEST, /* type */ | 2350 | &pi.hashPubKey, /*key to search */ |
2369 | &pi.hashPubKey, /*key to search */ | 2351 | 4, /* replication level */ |
2370 | 4, /* replication level */ | 2352 | GNUNET_DHT_RO_RECORD_ROUTE, NULL, /* bloom filter */ |
2371 | GNUNET_DHT_RO_RECORD_ROUTE, NULL, /* bloom filter */ | 2353 | 0, /* mutator */ |
2372 | 0, /* mutator */ | 2354 | NULL, /* xquery */ |
2373 | NULL, /* xquery */ | 2355 | 0, /* xquery bits */ |
2374 | 0, /* xquery bits */ | 2356 | dht_get_id_handler, |
2375 | dht_get_id_handler, | 2357 | (void *) path_info); |
2376 | (void *) path_info); | ||
2377 | return; | 2358 | return; |
2378 | } | 2359 | } |
2379 | } | 2360 | } |
2380 | 2361 | ||
2381 | p = path_build_from_dht(get_path, put_path); | 2362 | p = path_build_from_dht (get_path, put_path); |
2382 | path_add_to_peer (path_info->peer, p); | 2363 | path_add_to_peer (path_info->peer, p); |
2383 | for (i = 0; i < path_info->peer->ntunnels; i++) | 2364 | for (i = 0; i < path_info->peer->ntunnels; i++) |
2384 | { | 2365 | { |
2385 | tunnel_add_peer(path_info->peer->tunnels[i], path_info->peer); | 2366 | tunnel_add_peer (path_info->peer->tunnels[i], path_info->peer); |
2386 | } | 2367 | } |
2387 | GNUNET_free(path_info); | 2368 | GNUNET_free (path_info); |
2388 | 2369 | ||
2389 | return; | 2370 | return; |
2390 | } | 2371 | } |
@@ -2433,54 +2414,47 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
2433 | GNUNET_CONTAINER_multihashmap_put (t->peers, &pi->hashPubKey, peer_info, | 2414 | GNUNET_CONTAINER_multihashmap_put (t->peers, &pi->hashPubKey, peer_info, |
2434 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 2415 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
2435 | 2416 | ||
2436 | if ((NULL == get_path || NULL == put_path) && | 2417 | if ((NULL == get_path || NULL == put_path) && NULL == peer_info->path_head && |
2437 | NULL == peer_info->path_head && | 2418 | NULL == peer_info->dhtget) |
2438 | NULL == peer_info->dhtget) | ||
2439 | { | 2419 | { |
2440 | /* we don't have a route to the peer, let's try a direct lookup */ | 2420 | /* we don't have a route to the peer, let's try a direct lookup */ |
2441 | peer_info->dhtget = GNUNET_DHT_get_start ( | 2421 | peer_info->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */ |
2442 | dht_handle, /* handle */ | 2422 | GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ |
2443 | GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ | 2423 | GNUNET_BLOCK_TYPE_TEST, /* block type */ |
2444 | GNUNET_BLOCK_TYPE_TEST, /* block type */ | 2424 | &pi->hashPubKey, /* key to look up */ |
2445 | &pi->hashPubKey, /* key to look up */ | 2425 | 10U, /* replication level */ |
2446 | 10U, /* replication level */ | 2426 | GNUNET_DHT_RO_RECORD_ROUTE, /* option to dht: record route */ |
2447 | GNUNET_DHT_RO_RECORD_ROUTE, /* option to dht: record route */ | 2427 | NULL, /* bloom filter */ |
2448 | NULL, /* bloom filter */ | 2428 | 0, /* mutator */ |
2449 | 0, /* mutator */ | 2429 | NULL, /* xquery */ |
2450 | NULL, /* xquery */ | 2430 | 0, /* xquery bits */ |
2451 | 0, /* xquery bits */ | 2431 | dht_get_id_handler, /* callback */ |
2452 | dht_get_id_handler, /* callback */ | 2432 | peer_info); /* closure */ |
2453 | peer_info); /* closure */ | 2433 | } |
2454 | } | 2434 | |
2455 | 2435 | p = path_build_from_dht (get_path, put_path); | |
2456 | p = path_build_from_dht(get_path, put_path); | ||
2457 | path_add_to_peer (peer_info, p); | 2436 | path_add_to_peer (peer_info, p); |
2458 | #if MESH_DEBUG | 2437 | #if MESH_DEBUG |
2459 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2438 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2460 | "MESH: new route for tunnel 0x%x found, has %u hops\n", | 2439 | "MESH: new route for tunnel 0x%x found, has %u hops\n", |
2461 | t->local_tid, | 2440 | t->local_tid, p->length); |
2462 | p->length); | ||
2463 | for (i = 0; i < p->length; i++) | 2441 | for (i = 0; i < p->length; i++) |
2464 | { | 2442 | { |
2465 | GNUNET_PEER_resolve(p->peers[0], &id); | 2443 | GNUNET_PEER_resolve (p->peers[0], &id); |
2466 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2444 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH:\t%d\t%s\n", i, |
2467 | "MESH:\t%d\t%s\n", | 2445 | GNUNET_h2s_full (&id.hashPubKey)); |
2468 | i, | ||
2469 | GNUNET_h2s_full(&id.hashPubKey)); | ||
2470 | } | 2446 | } |
2471 | #endif | 2447 | #endif |
2472 | 2448 | ||
2473 | GNUNET_PEER_resolve (p->peers[1], &id); | 2449 | GNUNET_PEER_resolve (p->peers[1], &id); |
2474 | GNUNET_CORE_notify_transmit_ready ( | 2450 | GNUNET_CORE_notify_transmit_ready (core_handle, /* handle */ |
2475 | core_handle, /* handle */ | 2451 | 0, /* cork */ |
2476 | 0, /* cork */ | 2452 | 0, /* priority */ |
2477 | 0, /* priority*/ | 2453 | GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ |
2478 | GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ | 2454 | &id, /* target */ |
2479 | &id, /* target */ | 2455 | sizeof (struct GNUNET_MESH_ManipulatePath) + (p->length * sizeof (struct GNUNET_PeerIdentity)), /*size */ |
2480 | sizeof (struct GNUNET_MESH_ManipulatePath) + | 2456 | &send_core_create_path, /* callback */ |
2481 | (p->length * sizeof (struct GNUNET_PeerIdentity)), /*size */ | 2457 | peer_info); /* cls */ |
2482 | &send_core_create_path, /* callback */ | ||
2483 | peer_info); /* cls */ | ||
2484 | } | 2458 | } |
2485 | 2459 | ||
2486 | /******************************************************************************/ | 2460 | /******************************************************************************/ |
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 8476be396..615593621 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c | |||
@@ -921,4 +921,4 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) | |||
921 | GNUNET_free (handle); | 921 | GNUNET_free (handle); |
922 | } | 922 | } |
923 | 923 | ||
924 | /* end of mesh_api.c */ | 924 | /* end of mesh_api.c */ \ No newline at end of file |
diff --git a/src/mesh/test_mesh_small.c b/src/mesh/test_mesh_small.c index ab78278a8..97edbf731 100644 --- a/src/mesh/test_mesh_small.c +++ b/src/mesh/test_mesh_small.c | |||
@@ -582,7 +582,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
582 | "num_peers", &num_peers)) | 582 | "num_peers", &num_peers)) |
583 | { | 583 | { |
584 | GNUNET_assert (GNUNET_OK == | 584 | GNUNET_assert (GNUNET_OK == |
585 | GNUNET_CONFIGURATION_load (testing_cfg, "test_mesh_small.conf")); | 585 | GNUNET_CONFIGURATION_load (testing_cfg, |
586 | "test_mesh_small.conf")); | ||
586 | if (GNUNET_OK != | 587 | if (GNUNET_OK != |
587 | GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing", | 588 | GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing", |
588 | "num_peers", &num_peers)) | 589 | "num_peers", &num_peers)) |