diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-10-08 10:30:26 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-10-08 10:30:26 +0000 |
commit | d83640d04d57f6388b37d19a814eb6770ea4c485 (patch) | |
tree | 09bcf5d5702aced1c504031dbfbaf787f84a0890 | |
parent | 45072973ee81ffa01a2fc3450a5a7dcbf57c0464 (diff) | |
download | gnunet-d83640d04d57f6388b37d19a814eb6770ea4c485.tar.gz gnunet-d83640d04d57f6388b37d19a814eb6770ea4c485.zip |
- move all core/PeerIdentity interacting code to _peer, remove GNUNET_PeerIdentity from _connection
-rw-r--r-- | src/mesh/gnunet-service-mesh_connection.c | 472 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_connection.h | 34 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_local.c | 4 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_peer.c | 175 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_tunnel.c | 20 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_tunnel.h | 23 |
6 files changed, 392 insertions, 336 deletions
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index 782b6b859..31e11879e 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c | |||
@@ -27,16 +27,12 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | 29 | ||
30 | #include "gnunet_core_service.h" | ||
31 | |||
32 | #include "gnunet-service-mesh_connection.h" | 30 | #include "gnunet-service-mesh_connection.h" |
33 | #include "gnunet-service-mesh_peer.h" | 31 | #include "gnunet-service-mesh_peer.h" |
34 | #include "gnunet-service-mesh_local.h" | ||
35 | #include "mesh_protocol_enc.h" | 32 | #include "mesh_protocol_enc.h" |
36 | #include "mesh_path.h" | 33 | #include "mesh_path.h" |
37 | 34 | ||
38 | 35 | ||
39 | #define MESH_DEBUG_CONNECTION GNUNET_NO | ||
40 | #define MESH_MAX_POLL_TIME GNUNET_TIME_relative_multiply (\ | 36 | #define MESH_MAX_POLL_TIME GNUNET_TIME_relative_multiply (\ |
41 | GNUNET_TIME_UNIT_MINUTES,\ | 37 | GNUNET_TIME_UNIT_MINUTES,\ |
42 | 10) | 38 | 10) |
@@ -44,13 +40,6 @@ | |||
44 | #define MESH_RETRANSMIT_MARGIN 4 | 40 | #define MESH_RETRANSMIT_MARGIN 4 |
45 | 41 | ||
46 | 42 | ||
47 | #if MESH_DEBUG_CONNECTION | ||
48 | #define DEBUG_CONN(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | ||
49 | #else | ||
50 | #define DEBUG_CONN(...) | ||
51 | #endif | ||
52 | |||
53 | |||
54 | /** | 43 | /** |
55 | * All the states a connection can be in. | 44 | * All the states a connection can be in. |
56 | */ | 45 | */ |
@@ -281,10 +270,6 @@ static unsigned long long max_msgs_queue; | |||
281 | */ | 270 | */ |
282 | static struct GNUNET_TIME_Relative refresh_connection_time; | 271 | static struct GNUNET_TIME_Relative refresh_connection_time; |
283 | 272 | ||
284 | /** | ||
285 | * Handle to communicate with core. | ||
286 | */ | ||
287 | static struct GNUNET_CORE_Handle *core_handle; | ||
288 | 273 | ||
289 | #if 0 // avoid compiler warning for unused static function | 274 | #if 0 // avoid compiler warning for unused static function |
290 | static void | 275 | static void |
@@ -377,98 +362,6 @@ connection_get (const struct GNUNET_HashCode *cid) | |||
377 | 362 | ||
378 | 363 | ||
379 | /** | 364 | /** |
380 | * Sends an already built message on a connection, properly registering | ||
381 | * all used resources. | ||
382 | * | ||
383 | * @param message Message to send. Function makes a copy of it. | ||
384 | * If message is not hop-by-hop, decrements TTL of copy. | ||
385 | * @param c Connection on which this message is transmitted. | ||
386 | * @param ch Channel on which this message is transmitted, or NULL. | ||
387 | * @param fwd Is this a fwd message? | ||
388 | */ | ||
389 | static void | ||
390 | send_prebuilt_message_connection (const struct GNUNET_MessageHeader *message, | ||
391 | struct MeshConnection *c, | ||
392 | struct MeshChannel *ch, | ||
393 | int fwd) | ||
394 | { | ||
395 | void *data; | ||
396 | size_t size; | ||
397 | uint16_t type; | ||
398 | |||
399 | size = ntohs (message->size); | ||
400 | data = GNUNET_malloc (size); | ||
401 | memcpy (data, message, size); | ||
402 | type = ntohs (message->type); | ||
403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send %s (%u) on connection %s\n", | ||
404 | GNUNET_MESH_DEBUG_M2S (type), size, GNUNET_h2s (&c->id)); | ||
405 | |||
406 | switch (type) | ||
407 | { | ||
408 | struct GNUNET_MESH_Encrypted *emsg; | ||
409 | struct GNUNET_MESH_ACK *amsg; | ||
410 | struct GNUNET_MESH_Poll *pmsg; | ||
411 | struct GNUNET_MESH_ConnectionDestroy *dmsg; | ||
412 | struct GNUNET_MESH_ConnectionBroken *bmsg; | ||
413 | uint32_t ttl; | ||
414 | |||
415 | case GNUNET_MESSAGE_TYPE_MESH_FWD: | ||
416 | case GNUNET_MESSAGE_TYPE_MESH_BCK: | ||
417 | emsg = (struct GNUNET_MESH_Encrypted *) data; | ||
418 | ttl = ntohl (emsg->ttl); | ||
419 | if (0 == ttl) | ||
420 | { | ||
421 | GNUNET_break_op (0); | ||
422 | return; | ||
423 | } | ||
424 | emsg->cid = c->id; | ||
425 | emsg->ttl = htonl (ttl - 1); | ||
426 | emsg->pid = htonl (fwd ? c->fwd_fc.next_pid++ : c->bck_fc.next_pid++); | ||
427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " pid %u\n", ntohl (emsg->pid)); | ||
428 | break; | ||
429 | |||
430 | case GNUNET_MESSAGE_TYPE_MESH_ACK: | ||
431 | amsg = (struct GNUNET_MESH_ACK *) data; | ||
432 | amsg->cid = c->id; | ||
433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ack %u\n", ntohl (amsg->ack)); | ||
434 | break; | ||
435 | |||
436 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | ||
437 | pmsg = (struct GNUNET_MESH_Poll *) data; | ||
438 | pmsg->cid = c->id; | ||
439 | pmsg->pid = htonl (fwd ? c->fwd_fc.last_pid_sent : c->bck_fc.last_pid_sent); | ||
440 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " poll %u\n", ntohl (pmsg->pid)); | ||
441 | break; | ||
442 | |||
443 | case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: | ||
444 | dmsg = (struct GNUNET_MESH_ConnectionDestroy *) data; | ||
445 | dmsg->cid = c->id; | ||
446 | dmsg->reserved = 0; | ||
447 | break; | ||
448 | |||
449 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN: | ||
450 | bmsg = (struct GNUNET_MESH_ConnectionBroken *) data; | ||
451 | bmsg->cid = c->id; | ||
452 | bmsg->reserved = 0; | ||
453 | break; | ||
454 | |||
455 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE: | ||
456 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK: | ||
457 | break; | ||
458 | |||
459 | default: | ||
460 | GNUNET_break (0); | ||
461 | } | ||
462 | |||
463 | queue_add (data, | ||
464 | type, | ||
465 | size, | ||
466 | c, | ||
467 | ch, | ||
468 | fwd); | ||
469 | } | ||
470 | |||
471 | /** | ||
472 | * Send an ACK informing the predecessor about the available buffer space. | 365 | * Send an ACK informing the predecessor about the available buffer space. |
473 | * | 366 | * |
474 | * Note that for fwd ack, the FWD mean forward *traffic* (root->dest), | 367 | * Note that for fwd ack, the FWD mean forward *traffic* (root->dest), |
@@ -1099,128 +992,6 @@ connection_reset_timeout (struct MeshConnection *c, int fwd) | |||
1099 | 992 | ||
1100 | 993 | ||
1101 | /** | 994 | /** |
1102 | * Method called whenever a given peer connects. | ||
1103 | * | ||
1104 | * @param cls closure | ||
1105 | * @param peer peer identity this notification is about | ||
1106 | */ | ||
1107 | static void | ||
1108 | core_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | ||
1109 | { | ||
1110 | struct MeshPeer *pi; | ||
1111 | struct MeshPeerPath *path; | ||
1112 | |||
1113 | DEBUG_CONN ("Peer connected\n"); | ||
1114 | DEBUG_CONN (" %s\n", GNUNET_i2s (&my_full_id)); | ||
1115 | pi = peer_get (peer); | ||
1116 | if (myid == pi->id) | ||
1117 | { | ||
1118 | DEBUG_CONN (" (self)\n"); | ||
1119 | path = path_new (1); | ||
1120 | } | ||
1121 | else | ||
1122 | { | ||
1123 | DEBUG_CONN (" %s\n", GNUNET_i2s (peer)); | ||
1124 | path = path_new (2); | ||
1125 | path->peers[1] = pi->id; | ||
1126 | GNUNET_PEER_change_rc (pi->id, 1); | ||
1127 | GNUNET_STATISTICS_update (stats, "# peers", 1, GNUNET_NO); | ||
1128 | } | ||
1129 | path->peers[0] = myid; | ||
1130 | GNUNET_PEER_change_rc (myid, 1); | ||
1131 | peer_add_path (pi, path, GNUNET_YES); | ||
1132 | |||
1133 | pi->connections = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_YES); | ||
1134 | return; | ||
1135 | } | ||
1136 | |||
1137 | |||
1138 | /** | ||
1139 | * Method called whenever a peer disconnects. | ||
1140 | * | ||
1141 | * @param cls closure | ||
1142 | * @param peer peer identity this notification is about | ||
1143 | */ | ||
1144 | static void | ||
1145 | core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | ||
1146 | { | ||
1147 | struct MeshPeer *pi; | ||
1148 | |||
1149 | DEBUG_CONN ("Peer disconnected\n"); | ||
1150 | pi = GNUNET_CONTAINER_multipeermap_get (peers, peer); | ||
1151 | if (NULL == pi) | ||
1152 | { | ||
1153 | GNUNET_break (0); | ||
1154 | return; | ||
1155 | } | ||
1156 | |||
1157 | GNUNET_CONTAINER_multihashmap_iterate (pi->connections, | ||
1158 | GMC_notify_broken, | ||
1159 | pi); | ||
1160 | GNUNET_CONTAINER_multihashmap_destroy (pi->connections); | ||
1161 | pi->connections = NULL; | ||
1162 | if (NULL != pi->core_transmit) | ||
1163 | { | ||
1164 | GNUNET_CORE_notify_transmit_ready_cancel (pi->core_transmit); | ||
1165 | pi->core_transmit = NULL; | ||
1166 | } | ||
1167 | if (myid == pi->id) | ||
1168 | { | ||
1169 | DEBUG_CONN (" (self)\n"); | ||
1170 | } | ||
1171 | GNUNET_STATISTICS_update (stats, "# peers", -1, GNUNET_NO); | ||
1172 | |||
1173 | return; | ||
1174 | } | ||
1175 | |||
1176 | |||
1177 | |||
1178 | /** | ||
1179 | * To be called on core init/fail. | ||
1180 | * | ||
1181 | * @param cls Closure (config) | ||
1182 | * @param identity the public identity of this peer | ||
1183 | */ | ||
1184 | static void | ||
1185 | core_init (void *cls, | ||
1186 | const struct GNUNET_PeerIdentity *identity) | ||
1187 | { | ||
1188 | const struct GNUNET_CONFIGURATION_Handle *c = cls; | ||
1189 | static int i = 0; | ||
1190 | |||
1191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core init\n"); | ||
1192 | if (0 != memcmp (identity, &my_full_id, sizeof (my_full_id))) | ||
1193 | { | ||
1194 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Wrong CORE service\n")); | ||
1195 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1196 | " core id %s\n", | ||
1197 | GNUNET_i2s (identity)); | ||
1198 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1199 | " my id %s\n", | ||
1200 | GNUNET_i2s (&my_full_id)); | ||
1201 | GNUNET_CORE_disconnect (core_handle); | ||
1202 | core_handle = GNUNET_CORE_connect (c, /* Main configuration */ | ||
1203 | NULL, /* Closure passed to MESH functions */ | ||
1204 | &core_init, /* Call core_init once connected */ | ||
1205 | &core_connect, /* Handle connects */ | ||
1206 | &core_disconnect, /* remove peers on disconnects */ | ||
1207 | NULL, /* Don't notify about all incoming messages */ | ||
1208 | GNUNET_NO, /* For header only in notification */ | ||
1209 | NULL, /* Don't notify about all outbound messages */ | ||
1210 | GNUNET_NO, /* For header-only out notification */ | ||
1211 | core_handlers); /* Register these handlers */ | ||
1212 | if (10 < i++) | ||
1213 | GNUNET_abort(); | ||
1214 | } | ||
1215 | GML_start (); | ||
1216 | return; | ||
1217 | } | ||
1218 | |||
1219 | |||
1220 | |||
1221 | |||
1222 | |||
1223 | /** | ||
1224 | * Core handler for connection creation. | 995 | * Core handler for connection creation. |
1225 | * | 996 | * |
1226 | * @param cls Closure (unused). | 997 | * @param cls Closure (unused). |
@@ -1998,6 +1769,61 @@ send_ack (struct MeshConnection *c, struct MeshChannel *ch, int fwd) | |||
1998 | } | 1769 | } |
1999 | 1770 | ||
2000 | 1771 | ||
1772 | |||
1773 | /** | ||
1774 | * Initialize the connections subsystem | ||
1775 | * | ||
1776 | * @param c Configuration handle. | ||
1777 | */ | ||
1778 | void | ||
1779 | GMC_init (const struct GNUNET_CONFIGURATION_Handle *c) | ||
1780 | { | ||
1781 | if (GNUNET_OK != | ||
1782 | GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_MSGS_QUEUE", | ||
1783 | &max_msgs_queue)) | ||
1784 | { | ||
1785 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | ||
1786 | "MESH", "MAX_MSGS_QUEUE", "MISSING"); | ||
1787 | GNUNET_SCHEDULER_shutdown (); | ||
1788 | return; | ||
1789 | } | ||
1790 | |||
1791 | if (GNUNET_OK != | ||
1792 | GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_CONNECTIONS", | ||
1793 | &max_connections)) | ||
1794 | { | ||
1795 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | ||
1796 | "MESH", "MAX_CONNECTIONS", "MISSING"); | ||
1797 | GNUNET_SCHEDULER_shutdown (); | ||
1798 | return; | ||
1799 | } | ||
1800 | |||
1801 | if (GNUNET_OK != | ||
1802 | GNUNET_CONFIGURATION_get_value_time (c, "MESH", "REFRESH_CONNECTION_TIME", | ||
1803 | &refresh_connection_time)) | ||
1804 | { | ||
1805 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | ||
1806 | "MESH", "REFRESH_CONNECTION_TIME", "MISSING"); | ||
1807 | GNUNET_SCHEDULER_shutdown (); | ||
1808 | return; | ||
1809 | } | ||
1810 | connections = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_YES); | ||
1811 | } | ||
1812 | |||
1813 | /** | ||
1814 | * Shut down the connections subsystem. | ||
1815 | */ | ||
1816 | void | ||
1817 | GMC_shutdown (void) | ||
1818 | { | ||
1819 | if (core_handle != NULL) | ||
1820 | { | ||
1821 | GNUNET_CORE_disconnect (core_handle); | ||
1822 | core_handle = NULL; | ||
1823 | } | ||
1824 | } | ||
1825 | |||
1826 | |||
2001 | struct MeshConnection * | 1827 | struct MeshConnection * |
2002 | GMC_new (const struct GNUNET_HashCode *cid) | 1828 | GMC_new (const struct GNUNET_HashCode *cid) |
2003 | { | 1829 | { |
@@ -2054,22 +1880,18 @@ GMC_destroy (struct MeshConnection *c) | |||
2054 | 1880 | ||
2055 | 1881 | ||
2056 | /** | 1882 | /** |
2057 | * Iterator to notify all connections of a broken link. Mark connections | 1883 | * Notify other peers on a connection of a broken link. Mark connections |
2058 | * to destroy after all traffic has been sent. | 1884 | * to destroy after all traffic has been sent. |
2059 | * | 1885 | * |
2060 | * @param cls Closure (peer disconnected). | 1886 | * @param c Connection on which there has been a disconnection. |
2061 | * @param key Current key code (tid). | 1887 | * @param peer Peer that disconnected. |
2062 | * @param value Value in the hash map (connection). | 1888 | * @param my_full_id My ID (to send to other peers). |
2063 | * | ||
2064 | * @return GNUNET_YES if we should continue to iterate, | ||
2065 | * GNUNET_NO if not. | ||
2066 | */ | 1889 | */ |
2067 | int | 1890 | void |
2068 | GMC_notify_broken (void *cls, | 1891 | GMC_notify_broken (struct MeshConnection *c, |
2069 | const struct GNUNET_HashCode *key, | 1892 | struct MeshPeer *peer, |
2070 | void *value) | 1893 | struct GNUNET_PeerIdentity *my_full_id) |
2071 | { | 1894 | { |
2072 | struct MeshPeer *peer = cls; | ||
2073 | struct MeshConnection *c = value; | 1895 | struct MeshConnection *c = value; |
2074 | struct GNUNET_MESH_ConnectionBroken msg; | 1896 | struct GNUNET_MESH_ConnectionBroken msg; |
2075 | int fwd; | 1897 | int fwd; |
@@ -2087,9 +1909,9 @@ GMC_notify_broken (void *cls, | |||
2087 | msg.header.size = htons (sizeof (struct GNUNET_MESH_ConnectionBroken)); | 1909 | msg.header.size = htons (sizeof (struct GNUNET_MESH_ConnectionBroken)); |
2088 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN); | 1910 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN); |
2089 | msg.cid = c->id; | 1911 | msg.cid = c->id; |
2090 | msg.peer1 = my_full_id; | 1912 | msg.peer1 = *my_full_id; |
2091 | msg.peer2 = *GNUNET_PEER_resolve2 (peer->id); | 1913 | msg.peer2 = *GNUNET_PEER_resolve2 (peer->id); |
2092 | send_prebuilt_message_connection (&msg.header, c, NULL, fwd); | 1914 | GMC_send_prebuilt_message (&msg.header, c, NULL, fwd); |
2093 | c->destroy = GNUNET_YES; | 1915 | c->destroy = GNUNET_YES; |
2094 | 1916 | ||
2095 | return GNUNET_YES; | 1917 | return GNUNET_YES; |
@@ -2097,77 +1919,6 @@ GMC_notify_broken (void *cls, | |||
2097 | 1919 | ||
2098 | 1920 | ||
2099 | /** | 1921 | /** |
2100 | * Initialize the connections subsystem | ||
2101 | * | ||
2102 | * @param c Configuration handle. | ||
2103 | */ | ||
2104 | void | ||
2105 | GMC_init (const struct GNUNET_CONFIGURATION_Handle *c) | ||
2106 | { | ||
2107 | if (GNUNET_OK != | ||
2108 | GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_MSGS_QUEUE", | ||
2109 | &max_msgs_queue)) | ||
2110 | { | ||
2111 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | ||
2112 | "MESH", "MAX_MSGS_QUEUE", "MISSING"); | ||
2113 | GNUNET_SCHEDULER_shutdown (); | ||
2114 | return; | ||
2115 | } | ||
2116 | |||
2117 | if (GNUNET_OK != | ||
2118 | GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_CONNECTIONS", | ||
2119 | &max_connections)) | ||
2120 | { | ||
2121 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | ||
2122 | "MESH", "MAX_CONNECTIONS", "MISSING"); | ||
2123 | GNUNET_SCHEDULER_shutdown (); | ||
2124 | return; | ||
2125 | } | ||
2126 | |||
2127 | if (GNUNET_OK != | ||
2128 | GNUNET_CONFIGURATION_get_value_time (c, "MESH", "REFRESH_CONNECTION_TIME", | ||
2129 | &refresh_connection_time)) | ||
2130 | { | ||
2131 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | ||
2132 | "MESH", "REFRESH_CONNECTION_TIME", "MISSING"); | ||
2133 | GNUNET_SCHEDULER_shutdown (); | ||
2134 | return; | ||
2135 | } | ||
2136 | connections = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_YES); | ||
2137 | |||
2138 | core_handle = GNUNET_CORE_connect (c, /* Main configuration */ | ||
2139 | NULL, /* Closure passed to MESH functions */ | ||
2140 | &core_init, /* Call core_init once connected */ | ||
2141 | &core_connect, /* Handle connects */ | ||
2142 | &core_disconnect, /* remove peers on disconnects */ | ||
2143 | NULL, /* Don't notify about all incoming messages */ | ||
2144 | GNUNET_NO, /* For header only in notification */ | ||
2145 | NULL, /* Don't notify about all outbound messages */ | ||
2146 | GNUNET_NO, /* For header-only out notification */ | ||
2147 | core_handlers); /* Register these handlers */ | ||
2148 | if (NULL == core_handle) | ||
2149 | { | ||
2150 | GNUNET_break (0); | ||
2151 | GNUNET_SCHEDULER_shutdown (); | ||
2152 | return; | ||
2153 | } | ||
2154 | } | ||
2155 | |||
2156 | /** | ||
2157 | * Shut down the connections subsystem. | ||
2158 | */ | ||
2159 | void | ||
2160 | GMC_shutdown (void) | ||
2161 | { | ||
2162 | if (core_handle != NULL) | ||
2163 | { | ||
2164 | GNUNET_CORE_disconnect (core_handle); | ||
2165 | core_handle = NULL; | ||
2166 | } | ||
2167 | } | ||
2168 | |||
2169 | |||
2170 | /** | ||
2171 | * Is this peer the first one on the connection? | 1922 | * Is this peer the first one on the connection? |
2172 | * | 1923 | * |
2173 | * @param c Connection. | 1924 | * @param c Connection. |
@@ -2214,4 +1965,97 @@ GMC_count (const struct MeshConnection *head) | |||
2214 | for (count = 0, iter = head; NULL != iter; iter = iter->next, count++); | 1965 | for (count = 0, iter = head; NULL != iter; iter = iter->next, count++); |
2215 | 1966 | ||
2216 | return count; | 1967 | return count; |
1968 | } | ||
1969 | |||
1970 | |||
1971 | /** | ||
1972 | * Sends an already built message on a connection, properly registering | ||
1973 | * all used resources. | ||
1974 | * | ||
1975 | * @param message Message to send. Function makes a copy of it. | ||
1976 | * If message is not hop-by-hop, decrements TTL of copy. | ||
1977 | * @param c Connection on which this message is transmitted. | ||
1978 | * @param ch Channel on which this message is transmitted, or NULL. | ||
1979 | * @param fwd Is this a fwd message? | ||
1980 | */ | ||
1981 | void | ||
1982 | GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | ||
1983 | struct MeshConnection *c, | ||
1984 | struct MeshChannel *ch, | ||
1985 | int fwd) | ||
1986 | { | ||
1987 | void *data; | ||
1988 | size_t size; | ||
1989 | uint16_t type; | ||
1990 | |||
1991 | size = ntohs (message->size); | ||
1992 | data = GNUNET_malloc (size); | ||
1993 | memcpy (data, message, size); | ||
1994 | type = ntohs (message->type); | ||
1995 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send %s (%u) on connection %s\n", | ||
1996 | GNUNET_MESH_DEBUG_M2S (type), size, GNUNET_h2s (&c->id)); | ||
1997 | |||
1998 | switch (type) | ||
1999 | { | ||
2000 | struct GNUNET_MESH_Encrypted *emsg; | ||
2001 | struct GNUNET_MESH_ACK *amsg; | ||
2002 | struct GNUNET_MESH_Poll *pmsg; | ||
2003 | struct GNUNET_MESH_ConnectionDestroy *dmsg; | ||
2004 | struct GNUNET_MESH_ConnectionBroken *bmsg; | ||
2005 | uint32_t ttl; | ||
2006 | |||
2007 | case GNUNET_MESSAGE_TYPE_MESH_FWD: | ||
2008 | case GNUNET_MESSAGE_TYPE_MESH_BCK: | ||
2009 | emsg = (struct GNUNET_MESH_Encrypted *) data; | ||
2010 | ttl = ntohl (emsg->ttl); | ||
2011 | if (0 == ttl) | ||
2012 | { | ||
2013 | GNUNET_break_op (0); | ||
2014 | return; | ||
2015 | } | ||
2016 | emsg->cid = c->id; | ||
2017 | emsg->ttl = htonl (ttl - 1); | ||
2018 | emsg->pid = htonl (fwd ? c->fwd_fc.next_pid++ : c->bck_fc.next_pid++); | ||
2019 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " pid %u\n", ntohl (emsg->pid)); | ||
2020 | break; | ||
2021 | |||
2022 | case GNUNET_MESSAGE_TYPE_MESH_ACK: | ||
2023 | amsg = (struct GNUNET_MESH_ACK *) data; | ||
2024 | amsg->cid = c->id; | ||
2025 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ack %u\n", ntohl (amsg->ack)); | ||
2026 | break; | ||
2027 | |||
2028 | case GNUNET_MESSAGE_TYPE_MESH_POLL: | ||
2029 | pmsg = (struct GNUNET_MESH_Poll *) data; | ||
2030 | pmsg->cid = c->id; | ||
2031 | pmsg->pid = htonl (fwd ? c->fwd_fc.last_pid_sent : c->bck_fc.last_pid_sent); | ||
2032 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " poll %u\n", ntohl (pmsg->pid)); | ||
2033 | break; | ||
2034 | |||
2035 | case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: | ||
2036 | dmsg = (struct GNUNET_MESH_ConnectionDestroy *) data; | ||
2037 | dmsg->cid = c->id; | ||
2038 | dmsg->reserved = 0; | ||
2039 | break; | ||
2040 | |||
2041 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN: | ||
2042 | bmsg = (struct GNUNET_MESH_ConnectionBroken *) data; | ||
2043 | bmsg->cid = c->id; | ||
2044 | bmsg->reserved = 0; | ||
2045 | break; | ||
2046 | |||
2047 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE: | ||
2048 | case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK: | ||
2049 | break; | ||
2050 | |||
2051 | default: | ||
2052 | GNUNET_break (0); | ||
2053 | } | ||
2054 | |||
2055 | GMP_queue_add (data, | ||
2056 | type, | ||
2057 | size, | ||
2058 | c, | ||
2059 | ch, | ||
2060 | fwd); | ||
2217 | } \ No newline at end of file | 2061 | } \ No newline at end of file |
diff --git a/src/mesh/gnunet-service-mesh_connection.h b/src/mesh/gnunet-service-mesh_connection.h index 4e423e7ee..8395010fd 100644 --- a/src/mesh/gnunet-service-mesh_connection.h +++ b/src/mesh/gnunet-service-mesh_connection.h | |||
@@ -109,20 +109,17 @@ void | |||
109 | GMC_change_state (struct MeshConnection* c, enum MeshConnectionState state); | 109 | GMC_change_state (struct MeshConnection* c, enum MeshConnectionState state); |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * Iterator to notify all connections of a broken link. Mark connections | 112 | * Notify other peers on a connection of a broken link. Mark connections |
113 | * to destroy after all traffic has been sent. | 113 | * to destroy after all traffic has been sent. |
114 | * | 114 | * |
115 | * @param cls Closure (peer disconnected). | 115 | * @param c Connection on which there has been a disconnection. |
116 | * @param key Current key code (tid). | 116 | * @param peer Peer that disconnected. |
117 | * @param value Value in the hash map (connection). | 117 | * @param my_full_id My ID (to send to other peers). |
118 | * | ||
119 | * @return GNUNET_YES if we should continue to iterate, | ||
120 | * GNUNET_NO if not. | ||
121 | */ | 118 | */ |
122 | int | 119 | void |
123 | GMC_notify_broken (void *cls, | 120 | GMC_notify_broken (struct MeshConnection *c, |
124 | const struct GNUNET_HashCode *key, | 121 | struct MeshPeer *peer, |
125 | void *value); | 122 | struct GNUNET_PeerIdentity *my_full_id); |
126 | 123 | ||
127 | /** | 124 | /** |
128 | * @brief Queue and pass message to core when possible. | 125 | * @brief Queue and pass message to core when possible. |
@@ -192,6 +189,21 @@ GMC_is_origin (struct MeshConnection *c, int fwd); | |||
192 | int | 189 | int |
193 | GMC_is_terminal (struct MeshConnection *c, int fwd); | 190 | GMC_is_terminal (struct MeshConnection *c, int fwd); |
194 | 191 | ||
192 | /** | ||
193 | * Sends an already built message on a connection, properly registering | ||
194 | * all used resources. | ||
195 | * | ||
196 | * @param message Message to send. Function makes a copy of it. | ||
197 | * If message is not hop-by-hop, decrements TTL of copy. | ||
198 | * @param c Connection on which this message is transmitted. | ||
199 | * @param ch Channel on which this message is transmitted, or NULL. | ||
200 | * @param fwd Is this a fwd message? | ||
201 | */ | ||
202 | void | ||
203 | GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | ||
204 | struct MeshConnection *c, | ||
205 | struct MeshChannel *ch, | ||
206 | int fwd); | ||
195 | 207 | ||
196 | 208 | ||
197 | #if 0 /* keep Emacsens' auto-indent happy */ | 209 | #if 0 /* keep Emacsens' auto-indent happy */ |
diff --git a/src/mesh/gnunet-service-mesh_local.c b/src/mesh/gnunet-service-mesh_local.c index 7b58f0854..d8733cac7 100644 --- a/src/mesh/gnunet-service-mesh_local.c +++ b/src/mesh/gnunet-service-mesh_local.c | |||
@@ -22,7 +22,9 @@ | |||
22 | #include "platform.h" | 22 | #include "platform.h" |
23 | #include "mesh_enc.h" | 23 | #include "mesh_enc.h" |
24 | #include "mesh_protocol_enc.h" // GNUNET_MESH_Data is shared | 24 | #include "mesh_protocol_enc.h" // GNUNET_MESH_Data is shared |
25 | |||
25 | #include "gnunet-service-mesh_local.h" | 26 | #include "gnunet-service-mesh_local.h" |
27 | #include "gnunet-service-mesh_tunnel.h" | ||
26 | 28 | ||
27 | /******************************************************************************/ | 29 | /******************************************************************************/ |
28 | /******************************** STRUCTS **********************************/ | 30 | /******************************** STRUCTS **********************************/ |
@@ -394,7 +396,7 @@ handle_channel_create (void *cls, struct GNUNET_SERVER_Client *client, | |||
394 | msgcc.port = msg->port; | 396 | msgcc.port = msg->port; |
395 | msgcc.opt = msg->opt; | 397 | msgcc.opt = msg->opt; |
396 | 398 | ||
397 | tunnel_queue_data (t, ch, &msgcc.header, GNUNET_YES); | 399 | GMT_queue_data (t, ch, &msgcc.header, GNUNET_YES); |
398 | } | 400 | } |
399 | 401 | ||
400 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 402 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index 43c6259e3..0de74bb12 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c | |||
@@ -22,9 +22,12 @@ | |||
22 | #include "platform.h" | 22 | #include "platform.h" |
23 | #include "gnunet_util_lib.h" | 23 | #include "gnunet_util_lib.h" |
24 | 24 | ||
25 | #include "gnunet_core_service.h" | ||
26 | |||
25 | #include "gnunet-service-mesh_peer.h" | 27 | #include "gnunet-service-mesh_peer.h" |
26 | #include "gnunet-service-mesh_dht.h" | 28 | #include "gnunet-service-mesh_dht.h" |
27 | #include "gnunet-service-mesh_connection.h" | 29 | #include "gnunet-service-mesh_connection.h" |
30 | #include "gnunet-service-mesh_local.h" | ||
28 | #include "mesh_path.h" | 31 | #include "mesh_path.h" |
29 | 32 | ||
30 | /******************************************************************************/ | 33 | /******************************************************************************/ |
@@ -112,12 +115,162 @@ static unsigned long long max_peers; | |||
112 | */ | 115 | */ |
113 | static unsigned long long drop_percent; | 116 | static unsigned long long drop_percent; |
114 | 117 | ||
118 | /** | ||
119 | * Handle to communicate with core. | ||
120 | */ | ||
121 | static struct GNUNET_CORE_Handle *core_handle; | ||
122 | |||
123 | /** | ||
124 | * Local peer own ID (full value). | ||
125 | */ | ||
126 | const static struct GNUNET_PeerIdentity *my_full_id; | ||
127 | |||
115 | /******************************************************************************/ | 128 | /******************************************************************************/ |
116 | /***************************** CORE CALLBACKS *********************************/ | 129 | /***************************** CORE CALLBACKS *********************************/ |
117 | /******************************************************************************/ | 130 | /******************************************************************************/ |
118 | 131 | ||
119 | 132 | ||
120 | /** | 133 | /** |
134 | * Iterator to notify all connections of a broken link. Mark connections | ||
135 | * to destroy after all traffic has been sent. | ||
136 | * | ||
137 | * @param cls Closure (peer disconnected). | ||
138 | * @param key Current key code (peer id). | ||
139 | * @param value Value in the hash map (connection). | ||
140 | * | ||
141 | * @return GNUNET_YES if we should continue to iterate, | ||
142 | * GNUNET_NO if not. | ||
143 | */ | ||
144 | static int | ||
145 | notify_broken (void *cls, | ||
146 | const struct GNUNET_HashCode *key, | ||
147 | void *value) | ||
148 | { | ||
149 | struct MeshPeer *peer = cls; | ||
150 | struct MeshConnection *c = value; | ||
151 | |||
152 | GMC_notify_broken (c, peer, my_full_id); | ||
153 | |||
154 | return GNUNET_YES; | ||
155 | } | ||
156 | |||
157 | /** | ||
158 | * Method called whenever a given peer connects. | ||
159 | * | ||
160 | * @param cls closure | ||
161 | * @param peer peer identity this notification is about | ||
162 | */ | ||
163 | static void | ||
164 | core_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | ||
165 | { | ||
166 | struct MeshPeer *pi; | ||
167 | struct MeshPeerPath *path; | ||
168 | |||
169 | LOG ("Peer connected\n"); | ||
170 | LOG (" %s\n", GNUNET_i2s (&my_full_id)); | ||
171 | pi = peer_get (peer); | ||
172 | if (myid == pi->id) | ||
173 | { | ||
174 | DEBUG_CONN (" (self)\n"); | ||
175 | path = path_new (1); | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | DEBUG_CONN (" %s\n", GNUNET_i2s (peer)); | ||
180 | path = path_new (2); | ||
181 | path->peers[1] = pi->id; | ||
182 | GNUNET_PEER_change_rc (pi->id, 1); | ||
183 | GNUNET_STATISTICS_update (stats, "# peers", 1, GNUNET_NO); | ||
184 | } | ||
185 | path->peers[0] = myid; | ||
186 | GNUNET_PEER_change_rc (myid, 1); | ||
187 | peer_add_path (pi, path, GNUNET_YES); | ||
188 | |||
189 | pi->connections = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_YES); | ||
190 | return; | ||
191 | } | ||
192 | |||
193 | |||
194 | /** | ||
195 | * Method called whenever a peer disconnects. | ||
196 | * | ||
197 | * @param cls closure | ||
198 | * @param peer peer identity this notification is about | ||
199 | */ | ||
200 | static void | ||
201 | core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | ||
202 | { | ||
203 | struct MeshPeer *pi; | ||
204 | |||
205 | DEBUG_CONN ("Peer disconnected\n"); | ||
206 | pi = GNUNET_CONTAINER_multipeermap_get (peers, peer); | ||
207 | if (NULL == pi) | ||
208 | { | ||
209 | GNUNET_break (0); | ||
210 | return; | ||
211 | } | ||
212 | |||
213 | GNUNET_CONTAINER_multihashmap_iterate (pi->connections, ¬ify_broken, pi); | ||
214 | GNUNET_CONTAINER_multihashmap_destroy (pi->connections); | ||
215 | pi->connections = NULL; | ||
216 | if (NULL != pi->core_transmit) | ||
217 | { | ||
218 | GNUNET_CORE_notify_transmit_ready_cancel (pi->core_transmit); | ||
219 | pi->core_transmit = NULL; | ||
220 | } | ||
221 | if (myid == pi->id) | ||
222 | { | ||
223 | DEBUG_CONN (" (self)\n"); | ||
224 | } | ||
225 | GNUNET_STATISTICS_update (stats, "# peers", -1, GNUNET_NO); | ||
226 | |||
227 | return; | ||
228 | } | ||
229 | |||
230 | |||
231 | |||
232 | /** | ||
233 | * To be called on core init/fail. | ||
234 | * | ||
235 | * @param cls Closure (config) | ||
236 | * @param identity the public identity of this peer | ||
237 | */ | ||
238 | static void | ||
239 | core_init (void *cls, | ||
240 | const struct GNUNET_PeerIdentity *identity) | ||
241 | { | ||
242 | const struct GNUNET_CONFIGURATION_Handle *c = cls; | ||
243 | static int i = 0; | ||
244 | |||
245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core init\n"); | ||
246 | if (0 != memcmp (identity, &my_full_id, sizeof (my_full_id))) | ||
247 | { | ||
248 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Wrong CORE service\n")); | ||
249 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
250 | " core id %s\n", | ||
251 | GNUNET_i2s (identity)); | ||
252 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
253 | " my id %s\n", | ||
254 | GNUNET_i2s (&my_full_id)); | ||
255 | GNUNET_CORE_disconnect (core_handle); | ||
256 | core_handle = GNUNET_CORE_connect (c, /* Main configuration */ | ||
257 | NULL, /* Closure passed to MESH functions */ | ||
258 | &core_init, /* Call core_init once connected */ | ||
259 | &core_connect, /* Handle connects */ | ||
260 | &core_disconnect, /* remove peers on disconnects */ | ||
261 | NULL, /* Don't notify about all incoming messages */ | ||
262 | GNUNET_NO, /* For header only in notification */ | ||
263 | NULL, /* Don't notify about all outbound messages */ | ||
264 | GNUNET_NO, /* For header-only out notification */ | ||
265 | core_handlers); /* Register these handlers */ | ||
266 | if (10 < i++) | ||
267 | GNUNET_abort(); | ||
268 | } | ||
269 | GML_start (); | ||
270 | return; | ||
271 | } | ||
272 | |||
273 | /** | ||
121 | * Core callback to write a pre-constructed data packet to core buffer | 274 | * Core callback to write a pre-constructed data packet to core buffer |
122 | * | 275 | * |
123 | * @param cls Closure (MeshTransmissionDescriptor with data in "data" member). | 276 | * @param cls Closure (MeshTransmissionDescriptor with data in "data" member). |
@@ -1145,10 +1298,13 @@ GMP_queue_add (void *cls, uint16_t type, size_t size, | |||
1145 | * Initialize the peer subsystem. | 1298 | * Initialize the peer subsystem. |
1146 | * | 1299 | * |
1147 | * @param c Configuration. | 1300 | * @param c Configuration. |
1301 | * @param id Peer identity | ||
1148 | */ | 1302 | */ |
1149 | void | 1303 | void |
1150 | GMP_init (const struct GNUNET_CONFIGURATION_Handle *c) | 1304 | GMP_init (const struct GNUNET_CONFIGURATION_Handle *c, |
1305 | const struct GNUNET_PeerIdentity *id) | ||
1151 | { | 1306 | { |
1307 | my_full_id = id; | ||
1152 | peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); | 1308 | peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); |
1153 | if (GNUNET_OK != | 1309 | if (GNUNET_OK != |
1154 | GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_PEERS", | 1310 | GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_PEERS", |
@@ -1174,6 +1330,23 @@ GMP_init (const struct GNUNET_CONFIGURATION_Handle *c) | |||
1174 | "Remove the DROP_PERCENT option from your configuration.\n" | 1330 | "Remove the DROP_PERCENT option from your configuration.\n" |
1175 | "***************************************\n"); | 1331 | "***************************************\n"); |
1176 | } | 1332 | } |
1333 | |||
1334 | core_handle = GNUNET_CORE_connect (c, /* Main configuration */ | ||
1335 | NULL, /* Closure passed to MESH functions */ | ||
1336 | &core_init, /* Call core_init once connected */ | ||
1337 | &core_connect, /* Handle connects */ | ||
1338 | &core_disconnect, /* remove peers on disconnects */ | ||
1339 | NULL, /* Don't notify about all incoming messages */ | ||
1340 | GNUNET_NO, /* For header only in notification */ | ||
1341 | NULL, /* Don't notify about all outbound messages */ | ||
1342 | GNUNET_NO, /* For header-only out notification */ | ||
1343 | core_handlers); /* Register these handlers */ | ||
1344 | if (NULL == core_handle) | ||
1345 | { | ||
1346 | GNUNET_break (0); | ||
1347 | GNUNET_SCHEDULER_shutdown (); | ||
1348 | return; | ||
1349 | } | ||
1177 | } | 1350 | } |
1178 | 1351 | ||
1179 | /** | 1352 | /** |
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index d74129ec1..a1569b5d4 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include "platform.h" | 21 | #include "platform.h" |
22 | #include "gnunet_util_lib.h" | 22 | #include "gnunet_util_lib.h" |
23 | 23 | ||
24 | #include "mesh_protocol_enc.h" | ||
25 | |||
24 | #include "gnunet-service-mesh_tunnel.h" | 26 | #include "gnunet-service-mesh_tunnel.h" |
25 | #include "gnunet-service-mesh_connection.h" | 27 | #include "gnunet-service-mesh_connection.h" |
26 | #include "gnunet-service-mesh_channel.h" | 28 | #include "gnunet-service-mesh_channel.h" |
@@ -370,11 +372,11 @@ tunnel_send_queued_data (struct MeshTunnel2 *t, int fwd) | |||
370 | * @param msg Message itself (copy will be made). | 372 | * @param msg Message itself (copy will be made). |
371 | * @param fwd Is this fwd? | 373 | * @param fwd Is this fwd? |
372 | */ | 374 | */ |
373 | static void | 375 | void |
374 | tunnel_queue_data (struct MeshTunnel2 *t, | 376 | GMT_queue_data (struct MeshTunnel2 *t, |
375 | struct MeshChannel *ch, | 377 | struct MeshChannel *ch, |
376 | struct GNUNET_MessageHeader *msg, | 378 | struct GNUNET_MessageHeader *msg, |
377 | int fwd) | 379 | int fwd) |
378 | { | 380 | { |
379 | struct MeshTunnelQueue *tq; | 381 | struct MeshTunnelQueue *tq; |
380 | uint16_t size = ntohs (msg->size); | 382 | uint16_t size = ntohs (msg->size); |
@@ -476,8 +478,8 @@ GMT_new (void) | |||
476 | * @param t Tunnel whose state to change. | 478 | * @param t Tunnel whose state to change. |
477 | * @param state New state. | 479 | * @param state New state. |
478 | */ | 480 | */ |
479 | static void | 481 | void |
480 | tunnel_change_state (struct MeshTunnel2* t, enum MeshTunnelState state) | 482 | GMT_change_state (struct MeshTunnel2* t, enum MeshTunnelState state) |
481 | { | 483 | { |
482 | if (NULL == t) | 484 | if (NULL == t) |
483 | return; | 485 | return; |
@@ -657,7 +659,7 @@ GMT_handle_decrypted (struct MeshTunnel2 *t, | |||
657 | * @return Short ID of the peer disconnected (either p1 or p2). | 659 | * @return Short ID of the peer disconnected (either p1 or p2). |
658 | * 0 if the tunnel remained unaffected. | 660 | * 0 if the tunnel remained unaffected. |
659 | */ | 661 | */ |
660 | static GNUNET_PEER_Id | 662 | GNUNET_PEER_Id |
661 | GMT_notify_connection_broken (struct MeshTunnel2* t, | 663 | GMT_notify_connection_broken (struct MeshTunnel2* t, |
662 | GNUNET_PEER_Id p1, GNUNET_PEER_Id p2) | 664 | GNUNET_PEER_Id p1, GNUNET_PEER_Id p2) |
663 | { | 665 | { |
@@ -850,5 +852,5 @@ GMT_send_prebuilt_message (struct GNUNET_MESH_Encrypted *msg, | |||
850 | } | 852 | } |
851 | msg->reserved = 0; | 853 | msg->reserved = 0; |
852 | 854 | ||
853 | send_prebuilt_message_connection (&msg->header, c, ch, fwd); | 855 | GMC_send_prebuilt_message (&msg->header, c, ch, fwd); |
854 | } | 856 | } |
diff --git a/src/mesh/gnunet-service-mesh_tunnel.h b/src/mesh/gnunet-service-mesh_tunnel.h index 5954c9fd0..cd7c5670c 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.h +++ b/src/mesh/gnunet-service-mesh_tunnel.h | |||
@@ -68,6 +68,29 @@ GMT_init (const struct GNUNET_CONFIGURATION_Handle *c, | |||
68 | void | 68 | void |
69 | GMT_shutdown (void); | 69 | GMT_shutdown (void); |
70 | 70 | ||
71 | /** | ||
72 | * Change the tunnel state. | ||
73 | * | ||
74 | * @param t Tunnel whose state to change. | ||
75 | * @param state New state. | ||
76 | */ | ||
77 | void | ||
78 | GMT_change_state (struct MeshTunnel2* t, enum MeshTunnelState state); | ||
79 | |||
80 | |||
81 | /** | ||
82 | * Cache a message to be sent once tunnel is online. | ||
83 | * | ||
84 | * @param t Tunnel to hold the message. | ||
85 | * @param ch Channel the message is about. | ||
86 | * @param msg Message itself (copy will be made). | ||
87 | * @param fwd Is this fwd? | ||
88 | */ | ||
89 | void | ||
90 | GMT_queue_data (struct MeshTunnel2 *t, | ||
91 | struct MeshChannel *ch, | ||
92 | struct GNUNET_MessageHeader *msg, | ||
93 | int fwd); | ||
71 | 94 | ||
72 | #if 0 /* keep Emacsens' auto-indent happy */ | 95 | #if 0 /* keep Emacsens' auto-indent happy */ |
73 | { | 96 | { |