From 9bb3c520e3bf10d4004f2ccc872f2871a58a6339 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Thu, 5 Dec 2013 18:57:08 +0000 Subject: [PATCH] - fix channel numbering --- src/mesh/gnunet-service-mesh_tunnel.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index 8e1899a34..692a4c879 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c @@ -1975,14 +1975,28 @@ MESH_ChannelNumber GMT_get_next_chid (struct MeshTunnel3 *t) { MESH_ChannelNumber chid; + MESH_ChannelNumber mask; + int result; + + /* Set bit 30 depending on the ID relationship. Bit 31 is always 0 for GID. + * If our ID is bigger or loopback tunnel, start at 0, bit 30 = 0 + * If peer's ID is bigger, start at 0x4... bit 30 = 1 + */ + result = GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, GMP_get_id (t->peer)); + if (0 > result) + mask = 0x4000000; + else + mask = 0x0; while (NULL != GMT_get_channel (t, t->next_chid)) { LOG (GNUNET_ERROR_TYPE_DEBUG, "Channel %u exists...\n", t->next_chid); t->next_chid = (t->next_chid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI; + t->next_chid |= mask; } chid = t->next_chid; t->next_chid = (t->next_chid + 1) & ~GNUNET_MESH_LOCAL_CHANNEL_ID_CLI; + t->next_chid |= mask; return chid; } -- 2.25.1