diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-07-24 13:14:47 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-07-24 13:14:47 +0000 |
commit | 0426f17a30173471a98ed951899016c632cda942 (patch) | |
tree | b86409d8dabc0d6ec61e89462f1f4a73ef925074 /src/mesh | |
parent | f012334bce44cd551002318afe469d1b50e49bfc (diff) | |
download | gnunet-0426f17a30173471a98ed951899016c632cda942.tar.gz gnunet-0426f17a30173471a98ed951899016c632cda942.zip |
- change function declarations to new data structures
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh-enc.c | 208 |
1 files changed, 96 insertions, 112 deletions
diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c index 08e1bb41a..5b17ba1f7 100644 --- a/src/mesh/gnunet-service-mesh-enc.c +++ b/src/mesh/gnunet-service-mesh-enc.c | |||
@@ -265,7 +265,7 @@ struct MeshPeer | |||
265 | struct MeshPeerPath *path_tail; | 265 | struct MeshPeerPath *path_tail; |
266 | 266 | ||
267 | /** | 267 | /** |
268 | * Handle to stop the DHT search for a path to this peer | 268 | * Handle to stop the DHT search for paths to this peer |
269 | */ | 269 | */ |
270 | struct GNUNET_DHT_GetHandle *dhtget; | 270 | struct GNUNET_DHT_GetHandle *dhtget; |
271 | 271 | ||
@@ -562,6 +562,16 @@ struct MeshTunnel2 | |||
562 | */ | 562 | */ |
563 | struct MeshChannel *channel_head; | 563 | struct MeshChannel *channel_head; |
564 | struct MeshChannel *channel_tail; | 564 | struct MeshChannel *channel_tail; |
565 | |||
566 | /** | ||
567 | * Tunnel ID for the next created tunnel (global tunnel number). | ||
568 | */ | ||
569 | static MESH_ChannelNumber next_chid; | ||
570 | |||
571 | /** | ||
572 | * Tunnel ID for the next incoming tunnel (local tunnel number). | ||
573 | */ | ||
574 | static MESH_ChannelNumber next_local_chid; | ||
565 | }; | 575 | }; |
566 | 576 | ||
567 | 577 | ||
@@ -651,7 +661,7 @@ mesh_debug (void *cls, int success) | |||
651 | /************************** Configuration parameters **************************/ | 661 | /************************** Configuration parameters **************************/ |
652 | 662 | ||
653 | /** | 663 | /** |
654 | * How often to send tunnel keepalives. Tunnels timeout after 4 missed. | 664 | * How often to send path keepalives. Paths timeout after 4 missed. |
655 | */ | 665 | */ |
656 | static struct GNUNET_TIME_Relative refresh_path_time; | 666 | static struct GNUNET_TIME_Relative refresh_path_time; |
657 | 667 | ||
@@ -715,26 +725,10 @@ static struct MeshClient *clients_tail; | |||
715 | static struct GNUNET_CONTAINER_MultiHashMap *tunnels; | 725 | static struct GNUNET_CONTAINER_MultiHashMap *tunnels; |
716 | 726 | ||
717 | /** | 727 | /** |
718 | * Number of tunnels known. | ||
719 | */ | ||
720 | static unsigned long long n_tunnels; | ||
721 | |||
722 | /** | ||
723 | * Tunnels incoming, indexed by MESH_ChannelNumber | ||
724 | * (which is greater than GNUNET_MESH_LOCAL_CHANNEL_ID_SERV). | ||
725 | */ | ||
726 | static struct GNUNET_CONTAINER_MultiHashMap32 *incoming_tunnels; | ||
727 | |||
728 | /** | ||
729 | * Peers known, indexed by PeerIdentity (MeshPeer). | 728 | * Peers known, indexed by PeerIdentity (MeshPeer). |
730 | */ | 729 | */ |
731 | static struct GNUNET_CONTAINER_MultiHashMap *peers; | 730 | static struct GNUNET_CONTAINER_MultiHashMap *peers; |
732 | 731 | ||
733 | /* | ||
734 | * Handle to communicate with transport | ||
735 | */ | ||
736 | // static struct GNUNET_TRANSPORT_Handle *transport_handle; | ||
737 | |||
738 | /** | 732 | /** |
739 | * Handle to communicate with core. | 733 | * Handle to communicate with core. |
740 | */ | 734 | */ |
@@ -746,7 +740,7 @@ static struct GNUNET_CORE_Handle *core_handle; | |||
746 | static struct GNUNET_DHT_Handle *dht_handle; | 740 | static struct GNUNET_DHT_Handle *dht_handle; |
747 | 741 | ||
748 | /** | 742 | /** |
749 | * Handle to server. | 743 | * Handle to server lib. |
750 | */ | 744 | */ |
751 | static struct GNUNET_SERVER_Handle *server_handle; | 745 | static struct GNUNET_SERVER_Handle *server_handle; |
752 | 746 | ||
@@ -781,16 +775,6 @@ static struct GNUNET_CRYPTO_EccPrivateKey *my_private_key; | |||
781 | static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; | 775 | static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; |
782 | 776 | ||
783 | /** | 777 | /** |
784 | * Tunnel ID for the next created tunnel (global tunnel number). | ||
785 | */ | ||
786 | static MESH_ChannelNumber next_tid; | ||
787 | |||
788 | /** | ||
789 | * Tunnel ID for the next incoming tunnel (local tunnel number). | ||
790 | */ | ||
791 | static MESH_ChannelNumber next_local_tid; | ||
792 | |||
793 | /** | ||
794 | * All ports clients of this peer have opened. | 778 | * All ports clients of this peer have opened. |
795 | */ | 779 | */ |
796 | static struct GNUNET_CONTAINER_MultiHashMap32 *ports; | 780 | static struct GNUNET_CONTAINER_MultiHashMap32 *ports; |
@@ -870,7 +854,7 @@ path_build_from_dht (const struct GNUNET_PeerIdentity *get_path, | |||
870 | 854 | ||
871 | 855 | ||
872 | /** | 856 | /** |
873 | * Adds a path to the peer_infos of all the peers in the path | 857 | * Adds a path to the data structs of all the peers in the path |
874 | * | 858 | * |
875 | * @param p Path to process. | 859 | * @param p Path to process. |
876 | * @param confirmed Whether we know if the path works or not. | 860 | * @param confirmed Whether we know if the path works or not. |
@@ -879,17 +863,16 @@ static void | |||
879 | path_add_to_peers (struct MeshPeerPath *p, int confirmed); | 863 | path_add_to_peers (struct MeshPeerPath *p, int confirmed); |
880 | 864 | ||
881 | 865 | ||
882 | |||
883 | /** | 866 | /** |
884 | * Search for a tunnel by global ID using full PeerIdentities. | 867 | * Search for a channel by global ID using full PeerIdentities. |
885 | * | 868 | * |
886 | * @param oid owner of the tunnel. | 869 | * @param oid owner of the tunnel. |
887 | * @param tid global tunnel number. | 870 | * @param tid global tunnel number. |
888 | * | 871 | * |
889 | * @return tunnel handler, NULL if doesn't exist. | 872 | * @return tunnel handler, NULL if doesn't exist. |
890 | */ | 873 | */ |
891 | static struct MeshTunnel * | 874 | static struct MeshChannel * |
892 | tunnel_get (const struct GNUNET_PeerIdentity *oid, MESH_ChannelNumber tid); | 875 | channel_get (const struct GNUNET_PeerIdentity *oid, MESH_ChannelNumber tid); |
893 | 876 | ||
894 | 877 | ||
895 | /** | 878 | /** |
@@ -899,7 +882,7 @@ tunnel_get (const struct GNUNET_PeerIdentity *oid, MESH_ChannelNumber tid); | |||
899 | * @param state New state. | 882 | * @param state New state. |
900 | */ | 883 | */ |
901 | static void | 884 | static void |
902 | tunnel_change_state (struct MeshTunnel *t, enum MeshTunnelState state); | 885 | tunnel_change_state (struct MeshTunnel2 *t, enum MeshTunnelState state); |
903 | 886 | ||
904 | 887 | ||
905 | /** | 888 | /** |
@@ -914,27 +897,8 @@ tunnel_change_state (struct MeshTunnel *t, enum MeshTunnelState state); | |||
914 | * 0 if the tunnel remained unaffected. | 897 | * 0 if the tunnel remained unaffected. |
915 | */ | 898 | */ |
916 | static GNUNET_PEER_Id | 899 | static GNUNET_PEER_Id |
917 | tunnel_notify_connection_broken (struct MeshTunnel *t, GNUNET_PEER_Id p1, | 900 | tunnel_notify_connection_broken (struct MeshTunnel2 *t, |
918 | GNUNET_PEER_Id p2); | 901 | GNUNET_PEER_Id p1, GNUNET_PEER_Id p2); |
919 | |||
920 | |||
921 | /** | ||
922 | * Send FWD keepalive packets for a tunnel. | ||
923 | * | ||
924 | * @param cls Closure (tunnel for which to send the keepalive). | ||
925 | * @param tc Notification context. | ||
926 | */ | ||
927 | static void | ||
928 | tunnel_fwd_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
929 | |||
930 | /** | ||
931 | * Send BCK keepalive packets for a tunnel. | ||
932 | * | ||
933 | * @param cls Closure (tunnel for which to send the keepalive). | ||
934 | * @param tc Notification context. | ||
935 | */ | ||
936 | static void | ||
937 | tunnel_bck_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
938 | 902 | ||
939 | /** | 903 | /** |
940 | * @brief Use the given path for the tunnel. | 904 | * @brief Use the given path for the tunnel. |
@@ -945,7 +909,7 @@ tunnel_bck_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | |||
945 | * @param p Path to use. | 909 | * @param p Path to use. |
946 | */ | 910 | */ |
947 | static void | 911 | static void |
948 | tunnel_use_path (struct MeshTunnel *t, struct MeshPeerPath *p); | 912 | tunnel_use_path (struct MeshTunnel2 *t, struct MeshPeerPath *p); |
949 | 913 | ||
950 | /** | 914 | /** |
951 | * Tunnel is empty: destroy it. | 915 | * Tunnel is empty: destroy it. |
@@ -955,7 +919,7 @@ tunnel_use_path (struct MeshTunnel *t, struct MeshPeerPath *p); | |||
955 | * @param t Tunnel to destroy. | 919 | * @param t Tunnel to destroy. |
956 | */ | 920 | */ |
957 | static void | 921 | static void |
958 | tunnel_destroy_empty (struct MeshTunnel *t); | 922 | tunnel_destroy_empty (struct MeshTunnel2 *t); |
959 | 923 | ||
960 | /** | 924 | /** |
961 | * Destroy the tunnel. | 925 | * Destroy the tunnel. |
@@ -972,17 +936,37 @@ tunnel_destroy_empty (struct MeshTunnel *t); | |||
972 | * @return GNUNET_OK on success | 936 | * @return GNUNET_OK on success |
973 | */ | 937 | */ |
974 | static int | 938 | static int |
975 | tunnel_destroy (struct MeshTunnel *t); | 939 | tunnel_destroy (struct MeshTunnel2 *t); |
940 | |||
941 | /** | ||
942 | * Send FWD keepalive packets for a connection. | ||
943 | * | ||
944 | * @param cls Closure (connection for which to send the keepalive). | ||
945 | * @param tc Notification context. | ||
946 | */ | ||
947 | static void | ||
948 | connection_fwd_keepalive (void *cls, | ||
949 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
950 | |||
951 | /** | ||
952 | * Send BCK keepalive packets for a connection. | ||
953 | * | ||
954 | * @param cls Closure (connection for which to send the keepalive). | ||
955 | * @param tc Notification context. | ||
956 | */ | ||
957 | static void | ||
958 | connection_bck_keepalive (void *cls, | ||
959 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
976 | 960 | ||
977 | /** | 961 | /** |
978 | * @brief Queue and pass message to core when possible. | 962 | * @brief Queue and pass message to core when possible. |
979 | * | 963 | * |
980 | * If type is payload (UNICAST, TO_ORIGIN, MULTICAST) checks for queue status | 964 | * If type is payload (UNICAST, TO_ORIGIN) checks for queue status |
981 | * and accounts for it. In case the queue is full, the message is dropped and | 965 | * and accounts for it. In case the queue is full, the message is dropped and |
982 | * a break issued. | 966 | * a break issued. |
983 | * | 967 | * |
984 | * Otherwise, message is treated as internal and allowed to go regardless of | 968 | * Otherwise, the message is treated as internal and allowed to go, |
985 | * queue status. | 969 | * regardless of queue status. |
986 | * | 970 | * |
987 | * @param cls Closure (@c type dependant). It will be used by queue_send to | 971 | * @param cls Closure (@c type dependant). It will be used by queue_send to |
988 | * build the message to be sent if not already prebuilt. | 972 | * build the message to be sent if not already prebuilt. |
@@ -993,7 +977,7 @@ tunnel_destroy (struct MeshTunnel *t); | |||
993 | */ | 977 | */ |
994 | static void | 978 | static void |
995 | queue_add (void *cls, uint16_t type, size_t size, | 979 | queue_add (void *cls, uint16_t type, size_t size, |
996 | struct MeshPeer *dst, struct MeshTunnel *t); | 980 | struct MeshPeer *dst, struct MeshTunnel2 *t); |
997 | 981 | ||
998 | 982 | ||
999 | /** | 983 | /** |
@@ -1148,24 +1132,24 @@ client_get (struct GNUNET_SERVER_Client *client) | |||
1148 | * tunnel destroy. | 1132 | * tunnel destroy. |
1149 | * | 1133 | * |
1150 | * @param c Client whose tunnel to delete. | 1134 | * @param c Client whose tunnel to delete. |
1151 | * @param t Tunnel which should be deleted. | 1135 | * @param ch Channel which should be deleted. |
1152 | */ | 1136 | */ |
1153 | static void | 1137 | static void |
1154 | client_delete_tunnel (struct MeshClient *c, struct MeshTunnel *t) | 1138 | client_delete_channel (struct MeshClient *c, struct MeshChannel *ch) |
1155 | { | 1139 | { |
1156 | int res; | 1140 | int res; |
1157 | 1141 | ||
1158 | if (c == t->owner) | 1142 | if (c == ch->owner) |
1159 | { | 1143 | { |
1160 | res = GNUNET_CONTAINER_multihashmap32_remove (c->own_tunnels, | 1144 | res = GNUNET_CONTAINER_multihashmap32_remove (c->own_channels, |
1161 | t->local_tid, t); | 1145 | ch->local_tid, ch); |
1162 | if (GNUNET_YES != res) | 1146 | if (GNUNET_YES != res) |
1163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "client_delete_tunnel owner KO\n"); | 1147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "client_delete_channel owner KO\n"); |
1164 | } | 1148 | } |
1165 | if (c == t->client) | 1149 | if (c == ch->client) |
1166 | { | 1150 | { |
1167 | res = GNUNET_CONTAINER_multihashmap32_remove (c->incoming_tunnels, | 1151 | res = GNUNET_CONTAINER_multihashmap32_remove (c->incoming_channels, |
1168 | t->local_tid_dest, t); | 1152 | ch->local_tid_dest, ch); |
1169 | if (GNUNET_YES != res) | 1153 | if (GNUNET_YES != res) |
1170 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "client_delete_tunnel client KO\n"); | 1154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "client_delete_tunnel client KO\n"); |
1171 | } | 1155 | } |
@@ -1173,27 +1157,27 @@ client_delete_tunnel (struct MeshClient *c, struct MeshTunnel *t) | |||
1173 | 1157 | ||
1174 | 1158 | ||
1175 | /** | 1159 | /** |
1176 | * Notify the appropriate client that a new incoming tunnel was created. | 1160 | * Notify the appropriate client that a new incoming channel was created. |
1177 | * | 1161 | * |
1178 | * @param t Tunnel that was created. | 1162 | * @param ch Channel that was created. |
1179 | */ | 1163 | */ |
1180 | static void | 1164 | static void |
1181 | send_local_tunnel_create (struct MeshTunnel *t) | 1165 | send_local_channel_create (struct MeshChannel *ch) |
1182 | { | 1166 | { |
1183 | struct GNUNET_MESH_ChannelMessage msg; | 1167 | struct GNUNET_MESH_ChannelMessage msg; |
1184 | 1168 | ||
1185 | if (NULL == t->client) | 1169 | if (NULL == ch->client) |
1186 | return; | 1170 | return; |
1187 | msg.header.size = htons (sizeof (msg)); | 1171 | msg.header.size = htons (sizeof (msg)); |
1188 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE); | 1172 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE); |
1189 | msg.tunnel_id = htonl (t->local_tid_dest); | 1173 | msg.channel_id = htonl (ch->local_tid_dest); |
1190 | msg.port = htonl (t->port); | 1174 | msg.port = htonl (ch->port); |
1191 | msg.opt = 0; | 1175 | msg.opt = 0; |
1192 | msg.opt |= GNUNET_YES == t->reliable ? GNUNET_MESH_OPTION_RELIABLE : 0; | 1176 | msg.opt |= GNUNET_YES == ch->reliable ? GNUNET_MESH_OPTION_RELIABLE : 0; |
1193 | msg.opt |= GNUNET_YES == t->nobuffer ? GNUNET_MESH_OPTION_NOBUFFER : 0; | 1177 | msg.opt |= GNUNET_YES == ch->nobuffer ? GNUNET_MESH_OPTION_NOBUFFER : 0; |
1194 | msg.opt = htonl (msg.opt); | 1178 | msg.opt = htonl (msg.opt); |
1195 | GNUNET_PEER_resolve (t->id.oid, &msg.peer); | 1179 | GNUNET_PEER_resolve (ch->id.oid, &msg.peer); |
1196 | GNUNET_SERVER_notification_context_unicast (nc, t->client->handle, | 1180 | GNUNET_SERVER_notification_context_unicast (nc, ch->client->handle, |
1197 | &msg.header, GNUNET_NO); | 1181 | &msg.header, GNUNET_NO); |
1198 | } | 1182 | } |
1199 | 1183 | ||
@@ -1201,16 +1185,16 @@ send_local_tunnel_create (struct MeshTunnel *t) | |||
1201 | /** | 1185 | /** |
1202 | * Notify a client that the incoming tunnel is no longer valid. | 1186 | * Notify a client that the incoming tunnel is no longer valid. |
1203 | * | 1187 | * |
1204 | * @param t Tunnel that is destroyed. | 1188 | * @param ch Channel that is destroyed. |
1205 | * @param fwd Forward notification (owner->dest)? | 1189 | * @param fwd Forward notification (owner->dest)? |
1206 | */ | 1190 | */ |
1207 | static void | 1191 | static void |
1208 | send_local_tunnel_destroy (struct MeshTunnel *t, int fwd) | 1192 | send_local_channel_destroy (struct MeshChannel *ch, int fwd) |
1209 | { | 1193 | { |
1210 | struct GNUNET_MESH_ChannelMessage msg; | 1194 | struct GNUNET_MESH_ChannelMessage msg; |
1211 | struct MeshClient *c; | 1195 | struct MeshClient *c; |
1212 | 1196 | ||
1213 | c = fwd ? t->client : t->owner; | 1197 | c = fwd ? ch->client : ch->owner; |
1214 | if (NULL == c) | 1198 | if (NULL == c) |
1215 | { | 1199 | { |
1216 | GNUNET_break (0); | 1200 | GNUNET_break (0); |
@@ -1218,7 +1202,7 @@ send_local_tunnel_destroy (struct MeshTunnel *t, int fwd) | |||
1218 | } | 1202 | } |
1219 | msg.header.size = htons (sizeof (msg)); | 1203 | msg.header.size = htons (sizeof (msg)); |
1220 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY); | 1204 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY); |
1221 | msg.tunnel_id = htonl (fwd ? t->local_tid_dest : t->local_tid); | 1205 | msg.channel_id = htonl (fwd ? ch->local_tid_dest : ch->local_tid); |
1222 | msg.port = htonl (0); | 1206 | msg.port = htonl (0); |
1223 | memset (&msg.peer, 0, sizeof (msg.peer)); | 1207 | memset (&msg.peer, 0, sizeof (msg.peer)); |
1224 | msg.opt = htonl (0); | 1208 | msg.opt = htonl (0); |
@@ -2235,7 +2219,7 @@ path_add_to_peers (struct MeshPeerPath *p, int confirmed) | |||
2235 | * @return tunnel handler, NULL if doesn't exist | 2219 | * @return tunnel handler, NULL if doesn't exist |
2236 | */ | 2220 | */ |
2237 | static struct MeshTunnel * | 2221 | static struct MeshTunnel * |
2238 | tunnel_get_incoming (MESH_ChannelNumber tid) | 2222 | channel_get_incoming (MESH_ChannelNumber tid) |
2239 | { | 2223 | { |
2240 | GNUNET_assert (tid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV); | 2224 | GNUNET_assert (tid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV); |
2241 | return GNUNET_CONTAINER_multihashmap32_get (incoming_tunnels, tid); | 2225 | return GNUNET_CONTAINER_multihashmap32_get (incoming_tunnels, tid); |
@@ -2251,7 +2235,7 @@ tunnel_get_incoming (MESH_ChannelNumber tid) | |||
2251 | * @return tunnel handler, NULL if doesn't exist | 2235 | * @return tunnel handler, NULL if doesn't exist |
2252 | */ | 2236 | */ |
2253 | static struct MeshTunnel * | 2237 | static struct MeshTunnel * |
2254 | tunnel_get_by_local_id (struct MeshClient *c, MESH_ChannelNumber tid) | 2238 | channel_get_by_local_id (struct MeshClient *c, MESH_ChannelNumber tid) |
2255 | { | 2239 | { |
2256 | if (0 == (tid & GNUNET_MESH_LOCAL_CHANNEL_ID_CLI)) | 2240 | if (0 == (tid & GNUNET_MESH_LOCAL_CHANNEL_ID_CLI)) |
2257 | { | 2241 | { |
@@ -2261,7 +2245,7 @@ tunnel_get_by_local_id (struct MeshClient *c, MESH_ChannelNumber tid) | |||
2261 | } | 2245 | } |
2262 | if (tid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV) | 2246 | if (tid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV) |
2263 | { | 2247 | { |
2264 | return tunnel_get_incoming (tid); | 2248 | return channel_get_incoming (tid); |
2265 | } | 2249 | } |
2266 | else | 2250 | else |
2267 | { | 2251 | { |
@@ -2279,7 +2263,7 @@ tunnel_get_by_local_id (struct MeshClient *c, MESH_ChannelNumber tid) | |||
2279 | * @return tunnel handler, NULL if doesn't exist | 2263 | * @return tunnel handler, NULL if doesn't exist |
2280 | */ | 2264 | */ |
2281 | static struct MeshTunnel * | 2265 | static struct MeshTunnel * |
2282 | tunnel_get_by_pi (GNUNET_PEER_Id pi, MESH_ChannelNumber tid) | 2266 | channel_get_by_pi (GNUNET_PEER_Id pi, MESH_ChannelNumber tid) |
2283 | { | 2267 | { |
2284 | struct MESH_TunnelID id; | 2268 | struct MESH_TunnelID id; |
2285 | struct GNUNET_HashCode hash; | 2269 | struct GNUNET_HashCode hash; |
@@ -2301,9 +2285,9 @@ tunnel_get_by_pi (GNUNET_PEER_Id pi, MESH_ChannelNumber tid) | |||
2301 | * @return tunnel handler, NULL if doesn't exist | 2285 | * @return tunnel handler, NULL if doesn't exist |
2302 | */ | 2286 | */ |
2303 | static struct MeshTunnel * | 2287 | static struct MeshTunnel * |
2304 | tunnel_get (const struct GNUNET_PeerIdentity *oid, MESH_ChannelNumber tid) | 2288 | channel_get (const struct GNUNET_PeerIdentity *oid, MESH_ChannelNumber tid) |
2305 | { | 2289 | { |
2306 | return tunnel_get_by_pi (GNUNET_PEER_search (oid), tid); | 2290 | return channel_get_by_pi (GNUNET_PEER_search (oid), tid); |
2307 | } | 2291 | } |
2308 | 2292 | ||
2309 | 2293 | ||
@@ -2314,7 +2298,7 @@ tunnel_get (const struct GNUNET_PeerIdentity *oid, MESH_ChannelNumber tid) | |||
2314 | * @param state New state. | 2298 | * @param state New state. |
2315 | */ | 2299 | */ |
2316 | static void | 2300 | static void |
2317 | tunnel_change_state (struct MeshTunnel *t, enum MeshTunnelState state) | 2301 | tunnel_change_state (MeshTunnel2* t, MeshTunnelState state) |
2318 | { | 2302 | { |
2319 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2303 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2320 | "Tunnel %s[%X] state was %s\n", | 2304 | "Tunnel %s[%X] state was %s\n", |
@@ -2418,8 +2402,8 @@ tunnel_use_path (struct MeshTunnel *t, struct MeshPeerPath *p) | |||
2418 | * 0 if the tunnel remained unaffected. | 2402 | * 0 if the tunnel remained unaffected. |
2419 | */ | 2403 | */ |
2420 | static GNUNET_PEER_Id | 2404 | static GNUNET_PEER_Id |
2421 | tunnel_notify_connection_broken (struct MeshTunnel *t, GNUNET_PEER_Id p1, | 2405 | tunnel_notify_connection_broken (MeshTunnel2* t, |
2422 | GNUNET_PEER_Id p2) | 2406 | GNUNET_PEER_Id p1, GNUNET_PEER_Id p2) |
2423 | { | 2407 | { |
2424 | // if (myid != p1 && myid != p2) FIXME | 2408 | // if (myid != p1 && myid != p2) FIXME |
2425 | // { | 2409 | // { |
@@ -4009,7 +3993,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4009 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3993 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4010 | " path is for tunnel %s[%X]:%u.\n", | 3994 | " path is for tunnel %s[%X]:%u.\n", |
4011 | GNUNET_i2s (pi), tid, ntohl (msg->port)); | 3995 | GNUNET_i2s (pi), tid, ntohl (msg->port)); |
4012 | t = tunnel_get (pi, tid); | 3996 | t = channel_get (pi, tid); |
4013 | if (NULL == t) /* might be a local tunnel */ | 3997 | if (NULL == t) /* might be a local tunnel */ |
4014 | { | 3998 | { |
4015 | uint32_t opt; | 3999 | uint32_t opt; |
@@ -4102,7 +4086,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4102 | if (t->client != c) | 4086 | if (t->client != c) |
4103 | { | 4087 | { |
4104 | /* Assign local tid */ | 4088 | /* Assign local tid */ |
4105 | while (NULL != tunnel_get_incoming (next_local_tid)) | 4089 | while (NULL != channel_get_incoming (next_local_tid)) |
4106 | next_local_tid = (next_local_tid + 1) | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV; | 4090 | next_local_tid = (next_local_tid + 1) | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV; |
4107 | t->local_tid_dest = next_local_tid++; | 4091 | t->local_tid_dest = next_local_tid++; |
4108 | next_local_tid = next_local_tid | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV; | 4092 | next_local_tid = next_local_tid | GNUNET_MESH_LOCAL_CHANNEL_ID_SERV; |
@@ -4165,7 +4149,7 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4165 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received a path ACK msg [%s]\n", | 4149 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received a path ACK msg [%s]\n", |
4166 | GNUNET_i2s (&my_full_id)); | 4150 | GNUNET_i2s (&my_full_id)); |
4167 | msg = (struct GNUNET_MESH_PathACK *) message; | 4151 | msg = (struct GNUNET_MESH_PathACK *) message; |
4168 | t = tunnel_get (&msg->oid, ntohl(msg->tid)); | 4152 | t = channel_get (&msg->oid, ntohl(msg->tid)); |
4169 | if (NULL == t) | 4153 | if (NULL == t) |
4170 | { | 4154 | { |
4171 | /* TODO notify that we don't know the tunnel */ | 4155 | /* TODO notify that we don't know the tunnel */ |
@@ -4248,7 +4232,7 @@ handle_mesh_path_broken (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4248 | GNUNET_i2s (&msg->peer1)); | 4232 | GNUNET_i2s (&msg->peer1)); |
4249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " regarding %s\n", | 4233 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " regarding %s\n", |
4250 | GNUNET_i2s (&msg->peer2)); | 4234 | GNUNET_i2s (&msg->peer2)); |
4251 | t = tunnel_get (&msg->oid, ntohl (msg->tid)); | 4235 | t = channel_get (&msg->oid, ntohl (msg->tid)); |
4252 | if (NULL == t) | 4236 | if (NULL == t) |
4253 | { | 4237 | { |
4254 | GNUNET_break_op (0); | 4238 | GNUNET_break_op (0); |
@@ -4285,7 +4269,7 @@ handle_mesh_tunnel_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4285 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4269 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4286 | " for tunnel %s [%u]\n", | 4270 | " for tunnel %s [%u]\n", |
4287 | GNUNET_i2s (&msg->oid), ntohl (msg->tid)); | 4271 | GNUNET_i2s (&msg->oid), ntohl (msg->tid)); |
4288 | t = tunnel_get (&msg->oid, ntohl (msg->tid)); | 4272 | t = channel_get (&msg->oid, ntohl (msg->tid)); |
4289 | if (NULL == t) | 4273 | if (NULL == t) |
4290 | { | 4274 | { |
4291 | /* Probably already got the message from another path, | 4275 | /* Probably already got the message from another path, |
@@ -4373,7 +4357,7 @@ handle_mesh_data (const struct GNUNET_PeerIdentity *peer, | |||
4373 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " payload of type %s\n", | 4357 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " payload of type %s\n", |
4374 | GNUNET_MESH_DEBUG_M2S (ntohs (msg[1].header.type))); | 4358 | GNUNET_MESH_DEBUG_M2S (ntohs (msg[1].header.type))); |
4375 | /* Check tunnel */ | 4359 | /* Check tunnel */ |
4376 | t = tunnel_get (&msg->oid, ntohl (msg->tid)); | 4360 | t = channel_get (&msg->oid, ntohl (msg->tid)); |
4377 | if (NULL == t) | 4361 | if (NULL == t) |
4378 | { | 4362 | { |
4379 | /* TODO notify back: we don't know this tunnel */ | 4363 | /* TODO notify back: we don't know this tunnel */ |
@@ -4549,7 +4533,7 @@ handle_mesh_data_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4549 | GNUNET_MESH_DEBUG_M2S (type), GNUNET_i2s (peer)); | 4533 | GNUNET_MESH_DEBUG_M2S (type), GNUNET_i2s (peer)); |
4550 | msg = (struct GNUNET_MESH_DataACK *) message; | 4534 | msg = (struct GNUNET_MESH_DataACK *) message; |
4551 | 4535 | ||
4552 | t = tunnel_get (&msg->oid, ntohl (msg->tid)); | 4536 | t = channel_get (&msg->oid, ntohl (msg->tid)); |
4553 | if (NULL == t) | 4537 | if (NULL == t) |
4554 | { | 4538 | { |
4555 | /* TODO notify that we dont know this tunnel (whom)? */ | 4539 | /* TODO notify that we dont know this tunnel (whom)? */ |
@@ -4660,7 +4644,7 @@ handle_mesh_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4660 | GNUNET_i2s (peer)); | 4644 | GNUNET_i2s (peer)); |
4661 | msg = (struct GNUNET_MESH_ACK *) message; | 4645 | msg = (struct GNUNET_MESH_ACK *) message; |
4662 | 4646 | ||
4663 | t = tunnel_get (&msg->oid, ntohl (msg->tid)); | 4647 | t = channel_get (&msg->oid, ntohl (msg->tid)); |
4664 | 4648 | ||
4665 | if (NULL == t) | 4649 | if (NULL == t) |
4666 | { | 4650 | { |
@@ -4733,7 +4717,7 @@ handle_mesh_poll (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4733 | 4717 | ||
4734 | msg = (struct GNUNET_MESH_Poll *) message; | 4718 | msg = (struct GNUNET_MESH_Poll *) message; |
4735 | 4719 | ||
4736 | t = tunnel_get (&msg->oid, ntohl (msg->tid)); | 4720 | t = channel_get (&msg->oid, ntohl (msg->tid)); |
4737 | 4721 | ||
4738 | if (NULL == t) | 4722 | if (NULL == t) |
4739 | { | 4723 | { |
@@ -4801,7 +4785,7 @@ handle_mesh_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4801 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got a keepalive packet from %s\n", | 4785 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got a keepalive packet from %s\n", |
4802 | GNUNET_i2s (peer)); | 4786 | GNUNET_i2s (peer)); |
4803 | 4787 | ||
4804 | t = tunnel_get (&msg->oid, ntohl (msg->tid)); | 4788 | t = channel_get (&msg->oid, ntohl (msg->tid)); |
4805 | if (NULL == t) | 4789 | if (NULL == t) |
4806 | { | 4790 | { |
4807 | /* TODO notify that we dont know that tunnel */ | 4791 | /* TODO notify that we dont know that tunnel */ |
@@ -5112,7 +5096,7 @@ handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client, | |||
5112 | GNUNET_i2s (&t_msg->peer), ntohl (t_msg->port)); | 5096 | GNUNET_i2s (&t_msg->peer), ntohl (t_msg->port)); |
5113 | tid = ntohl (t_msg->channel_id); | 5097 | tid = ntohl (t_msg->channel_id); |
5114 | /* Sanity check for duplicate tunnel IDs */ | 5098 | /* Sanity check for duplicate tunnel IDs */ |
5115 | if (NULL != tunnel_get_by_local_id (c, tid)) | 5099 | if (NULL != channel_get_by_local_id (c, tid)) |
5116 | { | 5100 | { |
5117 | GNUNET_break (0); | 5101 | GNUNET_break (0); |
5118 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 5102 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -5120,7 +5104,7 @@ handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client, | |||
5120 | } | 5104 | } |
5121 | 5105 | ||
5122 | /* Create tunnel */ | 5106 | /* Create tunnel */ |
5123 | while (NULL != tunnel_get_by_pi (myid, next_tid)) | 5107 | while (NULL != channel_get_by_pi (myid, next_tid)) |
5124 | next_tid = (next_tid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI; | 5108 | next_tid = (next_tid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI; |
5125 | t = tunnel_new (myid, next_tid, c, tid); | 5109 | t = tunnel_new (myid, next_tid, c, tid); |
5126 | next_tid = (next_tid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI; | 5110 | next_tid = (next_tid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI; |
@@ -5192,7 +5176,7 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client, | |||
5192 | 5176 | ||
5193 | /* Retrieve tunnel */ | 5177 | /* Retrieve tunnel */ |
5194 | tid = ntohl (tunnel_msg->channel_id); | 5178 | tid = ntohl (tunnel_msg->channel_id); |
5195 | t = tunnel_get_by_local_id (c, tid); | 5179 | t = channel_get_by_local_id (c, tid); |
5196 | if (NULL == t) | 5180 | if (NULL == t) |
5197 | { | 5181 | { |
5198 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " tunnel %X not found\n", tid); | 5182 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " tunnel %X not found\n", tid); |
@@ -5271,7 +5255,7 @@ handle_local_data (void *cls, struct GNUNET_SERVER_Client *client, | |||
5271 | 5255 | ||
5272 | /* Tunnel exists? */ | 5256 | /* Tunnel exists? */ |
5273 | tid = ntohl (data_msg->tid); | 5257 | tid = ntohl (data_msg->tid); |
5274 | t = tunnel_get_by_local_id (c, tid); | 5258 | t = channel_get_by_local_id (c, tid); |
5275 | if (NULL == t) | 5259 | if (NULL == t) |
5276 | { | 5260 | { |
5277 | GNUNET_break (0); | 5261 | GNUNET_break (0); |
@@ -5389,7 +5373,7 @@ handle_local_ack (void *cls, struct GNUNET_SERVER_Client *client, | |||
5389 | /* Tunnel exists? */ | 5373 | /* Tunnel exists? */ |
5390 | tid = ntohl (msg->channel_id); | 5374 | tid = ntohl (msg->channel_id); |
5391 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " on tunnel %X\n", tid); | 5375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " on tunnel %X\n", tid); |
5392 | t = tunnel_get_by_local_id (c, tid); | 5376 | t = channel_get_by_local_id (c, tid); |
5393 | if (NULL == t) | 5377 | if (NULL == t) |
5394 | { | 5378 | { |
5395 | GNUNET_break (0); | 5379 | GNUNET_break (0); |
@@ -5519,7 +5503,7 @@ handle_local_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client, | |||
5519 | c->id, | 5503 | c->id, |
5520 | &msg->owner, | 5504 | &msg->owner, |
5521 | ntohl (msg->channel_id)); | 5505 | ntohl (msg->channel_id)); |
5522 | t = tunnel_get (&msg->owner, ntohl (msg->channel_id)); | 5506 | t = channel_get (&msg->owner, ntohl (msg->channel_id)); |
5523 | if (NULL == t) | 5507 | if (NULL == t) |
5524 | { | 5508 | { |
5525 | /* We don't know the tunnel FIXME */ | 5509 | /* We don't know the tunnel FIXME */ |