diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-07-25 14:04:21 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-07-25 14:04:21 +0000 |
commit | 6ac182926ddc496e4154e783dcd355a255bdb624 (patch) | |
tree | 8e83dbeca37ae4a05bdef04b1d1e74f5cfaa777c | |
parent | 8d103c167f8068eba0acebadea05190d9cecdfad (diff) | |
download | gnunet-6ac182926ddc496e4154e783dcd355a255bdb624.tar.gz gnunet-6ac182926ddc496e4154e783dcd355a255bdb624.zip |
- wip
-rw-r--r-- | src/mesh/gnunet-service-mesh-enc.c | 74 |
1 files changed, 31 insertions, 43 deletions
diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c index 10378205b..644c13213 100644 --- a/src/mesh/gnunet-service-mesh-enc.c +++ b/src/mesh/gnunet-service-mesh-enc.c | |||
@@ -1375,7 +1375,6 @@ send_ack (GNUNET_PEER_Id peer, uint32_t ack) | |||
1375 | { | 1375 | { |
1376 | struct GNUNET_MESH_ACK msg; | 1376 | struct GNUNET_MESH_ACK msg; |
1377 | 1377 | ||
1378 | GNUNET_PEER_resolve (t->id.oid, &msg.oid); | ||
1379 | msg.header.size = htons (sizeof (msg)); | 1378 | msg.header.size = htons (sizeof (msg)); |
1380 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_ACK); | 1379 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_ACK); |
1381 | msg.pid = htonl (ack); | 1380 | msg.pid = htonl (ack); |
@@ -1430,7 +1429,6 @@ send_core_connection_create (void *cls, size_t size, void *buf) | |||
1430 | struct GNUNET_PeerIdentity *peer_ptr; | 1429 | struct GNUNET_PeerIdentity *peer_ptr; |
1431 | struct MeshPeerPath *p = c->path; | 1430 | struct MeshPeerPath *p = c->path; |
1432 | size_t size_needed; | 1431 | size_t size_needed; |
1433 | uint32_t opt; | ||
1434 | int i; | 1432 | int i; |
1435 | 1433 | ||
1436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CONNECTION CREATE...\n"); | 1434 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending CONNECTION CREATE...\n"); |
@@ -1446,7 +1444,7 @@ send_core_connection_create (void *cls, size_t size, void *buf) | |||
1446 | msg = (struct GNUNET_MESH_ConnectionCreate *) buf; | 1444 | msg = (struct GNUNET_MESH_ConnectionCreate *) buf; |
1447 | msg->header.size = htons (size_needed); | 1445 | msg->header.size = htons (size_needed); |
1448 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE); | 1446 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE); |
1449 | msg->cid = ntohl (c->id); | 1447 | msg->cid = htonl (c->id); |
1450 | 1448 | ||
1451 | peer_ptr = (struct GNUNET_PeerIdentity *) &msg[1]; | 1449 | peer_ptr = (struct GNUNET_PeerIdentity *) &msg[1]; |
1452 | for (i = 0; i < p->length; i++) | 1450 | for (i = 0; i < p->length; i++) |
@@ -1773,15 +1771,15 @@ peer_unlock_queue (GNUNET_PEER_Id peer_id) | |||
1773 | size_t size; | 1771 | size_t size; |
1774 | 1772 | ||
1775 | peer = peer_get_short (peer_id); | 1773 | peer = peer_get_short (peer_id); |
1776 | if (NULL != peer->core_transmit) | 1774 | if (NULL != peer->fc->core_transmit) |
1777 | return; | 1775 | return; /* Already unlocked */ |
1778 | 1776 | ||
1779 | q = queue_get_next (peer); | 1777 | q = queue_get_next (peer); |
1780 | if (NULL == q) | 1778 | if (NULL == q) |
1781 | return; | 1779 | return; /* Nothing to transmit */ |
1782 | 1780 | ||
1783 | size = q->size; | 1781 | size = q->size; |
1784 | peer->core_transmit = | 1782 | peer->fc->core_transmit = |
1785 | GNUNET_CORE_notify_transmit_ready (core_handle, | 1783 | GNUNET_CORE_notify_transmit_ready (core_handle, |
1786 | GNUNET_NO, | 1784 | GNUNET_NO, |
1787 | 0, | 1785 | 0, |
@@ -1800,7 +1798,7 @@ peer_unlock_queue (GNUNET_PEER_Id peer_id) | |||
1800 | * @param t Tunnel which to cancel. | 1798 | * @param t Tunnel which to cancel. |
1801 | */ | 1799 | */ |
1802 | static void | 1800 | static void |
1803 | peer_cancel_queues (GNUNET_PEER_Id neighbor, struct MeshTunnel *t) | 1801 | peer_cancel_queues (GNUNET_PEER_Id neighbor, struct MeshTunnel2 *t) |
1804 | { | 1802 | { |
1805 | struct MeshPeer *peer; | 1803 | struct MeshPeer *peer; |
1806 | struct MeshPeerQueue *q; | 1804 | struct MeshPeerQueue *q; |
@@ -1810,7 +1808,13 @@ peer_cancel_queues (GNUNET_PEER_Id neighbor, struct MeshTunnel *t) | |||
1810 | if (0 == neighbor) | 1808 | if (0 == neighbor) |
1811 | return; /* Was local peer, 0'ed in tunnel_destroy_iterator */ | 1809 | return; /* Was local peer, 0'ed in tunnel_destroy_iterator */ |
1812 | peer = peer_get_short (neighbor); | 1810 | peer = peer_get_short (neighbor); |
1813 | for (q = peer->queue_head; NULL != q; q = next) | 1811 | if (NULL == peer || NULL == peer->fc) |
1812 | { | ||
1813 | GNUNET_break (0); | ||
1814 | return; | ||
1815 | } | ||
1816 | fc = peer->fc; | ||
1817 | for (q = fc->queue_head; NULL != q; q = next) | ||
1814 | { | 1818 | { |
1815 | next = q->next; | 1819 | next = q->next; |
1816 | if (q->tunnel == t) | 1820 | if (q->tunnel == t) |
@@ -1819,22 +1823,24 @@ peer_cancel_queues (GNUNET_PEER_Id neighbor, struct MeshTunnel *t) | |||
1819 | GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == q->type) | 1823 | GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == q->type) |
1820 | { | 1824 | { |
1821 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1825 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1822 | "peer_cancel_queues %s\n", | 1826 | "peer_cancel_queue %s\n", |
1823 | GNUNET_MESH_DEBUG_M2S (q->type)); | 1827 | GNUNET_MESH_DEBUG_M2S (q->type)); |
1824 | } | 1828 | } |
1825 | queue_destroy (q, GNUNET_YES); | 1829 | queue_destroy (q, GNUNET_YES); |
1826 | } | 1830 | } |
1827 | } | 1831 | } |
1828 | if (NULL == peer->queue_head && NULL != peer->core_transmit) | 1832 | if (NULL == fc->queue_head) |
1829 | { | 1833 | { |
1830 | GNUNET_CORE_notify_transmit_ready_cancel (peer->core_transmit); | 1834 | if (NULL != fc->core_transmit) |
1831 | peer->core_transmit = NULL; | 1835 | { |
1832 | } | 1836 | GNUNET_CORE_notify_transmit_ready_cancel (fc->core_transmit); |
1833 | fc = neighbor == t->next_hop ? &t->next_fc : &t->prev_fc; | 1837 | fc->core_transmit = NULL; |
1834 | if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task) | 1838 | } |
1835 | { | 1839 | if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task) |
1836 | GNUNET_SCHEDULER_cancel (fc->poll_task); | 1840 | { |
1837 | fc->poll_task = GNUNET_SCHEDULER_NO_TASK; | 1841 | GNUNET_SCHEDULER_cancel (fc->poll_task); |
1842 | fc->poll_task = GNUNET_SCHEDULER_NO_TASK; | ||
1843 | } | ||
1838 | } | 1844 | } |
1839 | } | 1845 | } |
1840 | 1846 | ||
@@ -2279,21 +2285,6 @@ path_add_to_peers (struct MeshPeerPath *p, int confirmed) | |||
2279 | 2285 | ||
2280 | 2286 | ||
2281 | /** | 2287 | /** |
2282 | * Search for a tunnel among the incoming tunnels | ||
2283 | * | ||
2284 | * @param tid the local id of the tunnel | ||
2285 | * | ||
2286 | * @return tunnel handler, NULL if doesn't exist | ||
2287 | */ | ||
2288 | static struct MeshTunnel * | ||
2289 | channel_get_incoming (MESH_ChannelNumber tid) | ||
2290 | { | ||
2291 | GNUNET_assert (tid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV); | ||
2292 | return GNUNET_CONTAINER_multihashmap32_get (incoming_tunnels, tid); | ||
2293 | } | ||
2294 | |||
2295 | |||
2296 | /** | ||
2297 | * Search for a tunnel among the tunnels for a client | 2288 | * Search for a tunnel among the tunnels for a client |
2298 | * | 2289 | * |
2299 | * @param c the client whose tunnels to search in | 2290 | * @param c the client whose tunnels to search in |
@@ -2302,22 +2293,19 @@ channel_get_incoming (MESH_ChannelNumber tid) | |||
2302 | * @return tunnel handler, NULL if doesn't exist | 2293 | * @return tunnel handler, NULL if doesn't exist |
2303 | */ | 2294 | */ |
2304 | static struct MeshTunnel * | 2295 | static struct MeshTunnel * |
2305 | channel_get_by_local_id (struct MeshClient *c, MESH_ChannelNumber tid) | 2296 | channel_get_by_local_id (struct MeshClient *c, MESH_ChannelNumber chid) |
2306 | { | 2297 | { |
2307 | if (0 == (tid & GNUNET_MESH_LOCAL_CHANNEL_ID_CLI)) | 2298 | if (0 == (chid & GNUNET_MESH_LOCAL_CHANNEL_ID_CLI)) |
2308 | { | 2299 | { |
2309 | GNUNET_break_op (0); | 2300 | GNUNET_break_op (0); |
2310 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TID %X not a local tid\n", tid); | 2301 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CHID %X not a local chid\n", chid); |
2311 | return NULL; | 2302 | return NULL; |
2312 | } | 2303 | } |
2313 | if (tid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV) | 2304 | if (chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV) |
2314 | { | ||
2315 | return channel_get_incoming (tid); | ||
2316 | } | ||
2317 | else | ||
2318 | { | 2305 | { |
2319 | return GNUNET_CONTAINER_multihashmap32_get (c->own_tunnels, tid); | 2306 | return channel_get_incoming (chid); |
2320 | } | 2307 | } |
2308 | return GNUNET_CONTAINER_multihashmap32_get (c->own_channels, chid); | ||
2321 | } | 2309 | } |
2322 | 2310 | ||
2323 | 2311 | ||