connection_change_state (c, MESH_CONNECTION_SENT);
/* Remember peers */
- dest_peer = peer_get (&id[size - 1]);
- orig_peer = peer_get (&id[0]);
+ dest_peer = GMP_get (&id[size - 1]);
+ orig_peer = GMP_get (&id[0]);
/* Is it a connection to us? */
if (c->own_pos == size - 1)
LOG (GNUNET_ERROR_TYPE_DEBUG, " It's for us!\n");
GMP_add_path_to_origin (orig_peer, path, GNUNET_YES);
- if (NULL == orig_peer->tunnel)
- {
- orig_peer->tunnel = GMT_new ();
- orig_peer->tunnel->peer = orig_peer;
- }
- GMT_add_connection (orig_peer->tunnel, c);
+ GMP_add_tunnel (orig_peer);
+ GMP_add_connection (orig_peer, c);
if (MESH_TUNNEL3_NEW == GMT_get_state (c->t))
GMT_change_state (c->t, MESH_TUNNEL3_WAITING);
/**
* Tunnel to this peer, if any.
*/
- struct MeshTunnel2 *tunnel;
+ struct MeshTunnel3 *tunnel;
/**
* Connections that go through this peer, indexed by tid;
LOG ("Peer connected\n");
LOG (" %s\n", GNUNET_i2s (&my_full_id));
- pi = peer_get (peer);
+ pi = GMP_get (peer);
if (myid == pi->id)
{
LOG (" (self)\n");
send_core_connection_ack (struct MeshConnection *c, size_t size, void *buf)
{
struct GNUNET_MESH_ConnectionACK *msg = buf;
- struct MeshTunnel2 *t = c->t;
+ struct MeshTunnel3 *t = c->t;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending CONNECTION ACK...\n");
GNUNET_assert (NULL != t);
void *value)
{
struct MeshPeer *p = value;
- struct MeshTunnel2 *t = p->tunnel;
+ struct MeshTunnel3 *t = p->tunnel;
if (NULL != t)
GMT_destroy (t);
}
-/**
- * Retrieve the MeshPeer stucture associated with the peer, create one
- * and insert it in the appropriate structures if the peer is not known yet.
- *
- * @param peer Full identity of the peer.
- *
- * @return Existing or newly created peer info.
- */
-static struct MeshPeer *
-peer_get (const struct GNUNET_PeerIdentity *peer_id)
-{
- struct MeshPeer *peer;
-
- peer = GNUNET_CONTAINER_multipeermap_get (peers, peer_id);
- if (NULL == peer)
- {
- peer = GNUNET_new (struct MeshPeer);
- if (GNUNET_CONTAINER_multipeermap_size (peers) > max_peers)
- {
- peer_delete_oldest ();
- }
- GNUNET_CONTAINER_multipeermap_put (peers, peer_id, peer,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
- peer->id = GNUNET_PEER_intern (peer_id);
- }
- peer->last_contact = GNUNET_TIME_absolute_get();
-
- return peer;
-}
-
-
-/**
- * Retrieve the MeshPeer stucture associated with the peer, create one
- * and insert it in the appropriate structures if the peer is not known yet.
- *
- * @param peer Short identity of the peer.
- *
- * @return Existing or newly created peer info.
- */
-static struct MeshPeer *
-peer_get_short (const GNUNET_PEER_Id peer)
-{
- return peer_get (GNUNET_PEER_resolve2 (peer));
-}
-
-
/**
* Get a cost of a path for a peer considering existing tunnel connections.
*
struct MeshConnection *c;
struct GNUNET_MessageHeader *msg;
struct MeshPeerQueue *queue;
- struct MeshTunnel2 *t;
+ struct MeshTunnel3 *t;
struct MeshChannel *ch;
const struct GNUNET_PeerIdentity *dst_id;
size_t data_size;
GNUNET_PEER_change_rc (myid, -1);
}
+/**
+ * Retrieve the MeshPeer stucture associated with the peer, create one
+ * and insert it in the appropriate structures if the peer is not known yet.
+ *
+ * @param peer Full identity of the peer.
+ *
+ * @return Existing or newly created peer structure.
+ */
+struct MeshPeer *
+GMP_get (const struct GNUNET_PeerIdentity *peer_id)
+{
+ struct MeshPeer *peer;
+
+ peer = GNUNET_CONTAINER_multipeermap_get (peers, peer_id);
+ if (NULL == peer)
+ {
+ peer = GNUNET_new (struct MeshPeer);
+ if (GNUNET_CONTAINER_multipeermap_size (peers) > max_peers)
+ {
+ peer_delete_oldest ();
+ }
+ GNUNET_CONTAINER_multipeermap_put (peers, peer_id, peer,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
+ peer->id = GNUNET_PEER_intern (peer_id);
+ }
+ peer->last_contact = GNUNET_TIME_absolute_get();
+
+ return peer;
+}
+
+
+/**
+ * Retrieve the MeshPeer stucture associated with the peer, create one
+ * and insert it in the appropriate structures if the peer is not known yet.
+ *
+ * @param peer Short identity of the peer.
+ *
+ * @return Existing or newly created peer structure.
+ */
+struct MeshPeer *
+GMP_get_short (const GNUNET_PEER_Id peer)
+{
+ return GMP_get (GNUNET_PEER_resolve2 (peer));
+}
/**
* Try to establish a new connection to this peer in the given tunnel.
void
GMP_connect (struct MeshPeer *peer)
{
- struct MeshTunnel2 *t;
+ struct MeshTunnel3 *t;
struct MeshPeerPath *p;
struct MeshConnection *c;
int rerun_search;
* @param t Tunnel.
*/
void
-GMP_set_tunnel (struct MeshPeer *peer, struct MeshTunnel2 *t)
+GMP_set_tunnel (struct MeshPeer *peer, struct MeshTunnel3 *t)
{
peer->tunnel = t;
}
}
+/**
+ * Create and initialize a new tunnel towards a peer, in case it has none.
+ *
+ * Does not generate any traffic, just creates the local data structures.
+ *
+ * @param peer Peer towards which to create the tunnel.
+ */
+void
+GMP_add_tunnel (struct MeshPeer *peer)
+{
+ if (NULL != peer->tunnel)
+ return;
+ peer->tunnel = GMT_new (peer);
+}
+
+
/**
* Add a connection to a neighboring peer.
*
struct MeshPeer *aux;
struct MeshPeerPath *copy;
- aux = peer_get_short (p->peers[i]);
+ aux = GMP_get_short (p->peers[i]);
copy = path_duplicate (p);
copy->length = i + 1;
GMP_add_path (aux, copy, p->length < 3 ? GNUNET_NO : confirmed);
void
GMP_shutdown (void);
+
+/**
+ * Retrieve the MeshPeer stucture associated with the peer, create one
+ * and insert it in the appropriate structures if the peer is not known yet.
+ *
+ * @param peer Full identity of the peer.
+ *
+ * @return Existing or newly created peer structure.
+ */
+struct MeshPeer *
+GMP_get (const struct GNUNET_PeerIdentity *peer_id);
+
+
+/**
+ * Retrieve the MeshPeer stucture associated with the peer, create one
+ * and insert it in the appropriate structures if the peer is not known yet.
+ *
+ * @param peer Short identity of the peer.
+ *
+ * @return Existing or newly created peer structure.
+ */
+struct MeshPeer *
+GMP_get_short (const GNUNET_PEER_Id peer);
+
/**
* @brief Queue and pass message to core when possible.
*
int
GMP_is_neighbor (const struct MeshPeer *peer);
+/**
+ * Create and initialize a new tunnel towards a peer, in case it has none.
+ *
+ * Does not generate any traffic, just creates the local data structures.
+ *
+ * @param peer Peer towards which to create the tunnel.
+ */
+void
+GMP_add_tunnel (struct MeshPeer *peer);
/**
* Add a connection to a neighboring peer.
* @return GNUNET_OK on success.
*/
int
-GMP_add_connection (struct MeshPeer *peer, struct MeshConnection *c);
+GMP_add_connection (struct MeshPeer *peer, const struct MeshConnection *c);
/**
* Add the path to the peer and update the path used to reach it in case this