[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r30130 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r30130 - gnunet/src/mesh |
Date: |
Fri, 11 Oct 2013 12:59:32 +0200 |
Author: bartpolot
Date: 2013-10-11 12:59:32 +0200 (Fri, 11 Oct 2013)
New Revision: 30130
Modified:
gnunet/src/mesh/gnunet-service-mesh_channel.c
gnunet/src/mesh/gnunet-service-mesh_channel.h
gnunet/src/mesh/gnunet-service-mesh_local.c
gnunet/src/mesh/gnunet-service-mesh_peer.c
gnunet/src/mesh/gnunet-service-mesh_peer.h
gnunet/src/mesh/gnunet-service-mesh_tunnel.c
Log:
- sync
Modified: gnunet/src/mesh/gnunet-service-mesh_channel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.c 2013-10-11 10:27:52 UTC
(rev 30129)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.c 2013-10-11 10:59:32 UTC
(rev 30130)
@@ -30,6 +30,7 @@
#include "gnunet-service-mesh_channel.h"
#include "gnunet-service-mesh_local.h"
#include "gnunet-service-mesh_tunnel.h"
+#include "gnunet-service-mesh_peer.h"
#define LOG(level, ...) GNUNET_log_from(level,"mesh-chn",__VA_ARGS__)
@@ -1305,6 +1306,80 @@
/**
+ * Handle a channel create requested by a client.
+ *
+ * Create the channel and the tunnel in case this was the first0 channel.
+ *
+ * @param c Client that requested the creation (will be the root).
+ * @param msg Create Channel message.
+ */
+void
+GMCH_handle_local_create (struct MeshClient *c,
+ struct GNUNET_MESH_ChannelMessage *msg)
+{
+ struct MeshChannel *ch;
+ struct MeshTunnel3 *t;
+ struct MeshPeer *peer;
+ MESH_ChannelNumber chid;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n",
+ GNUNET_i2s (&msg->peer), ntohl (msg->port));
+ chid = ntohl (msg->channel_id);
+
+ /* Sanity check for duplicate channel IDs */
+ if (NULL != GML_channel_get (c, chid))
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+
+ peer = GMP_get (&msg->peer);
+ GMP_add_tunnel (peer);
+ t = GMP_get_tunnel(peer);
+
+ if (GMP_get_short_id(peer) == myid)
+ {
+ GMT_change_state (t, MESH_TUNNEL3_READY);
+ }
+ else
+ {
+ GMP_connect (peer);
+ }
+
+ /* Create channel */
+ ch = channel_new (t, c, chid);
+ if (NULL == ch)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ ch->port = ntohl (msg->port);
+ channel_set_options (ch, ntohl (msg->opt));
+
+ /* In unreliable channels, we'll use the DLL to buffer BCK data */
+ ch->root_rel = GNUNET_new (struct MeshChannelReliability);
+ ch->root_rel->ch = ch;
+ ch->root_rel->expected_delay = MESH_RETRANSMIT_TIME;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "CREATED CHANNEL %s[%x]:%u (%x)\n",
+ peer2s (t->peer), ch->gid, ch->port, ch->lid_root);
+
+ /* Send create channel */
+ {
+ struct GNUNET_MESH_ChannelCreate msgcc;
+
+ msgcc.header.size = htons (sizeof (msgcc));
+ msgcc.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE);
+ msgcc.chid = htonl (ch->gid);
+ msgcc.port = msg->port;
+ msgcc.opt = msg->opt;
+
+ GMT_queue_data (t, ch, &msgcc.header, GNUNET_YES);
+ }
+}
+
+/**
* Handler for mesh network payload traffic.
*
* @param ch Channel for the message.
Modified: gnunet/src/mesh/gnunet-service-mesh_channel.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_channel.h 2013-10-11 10:27:52 UTC
(rev 30129)
+++ gnunet/src/mesh/gnunet-service-mesh_channel.h 2013-10-11 10:59:32 UTC
(rev 30130)
@@ -200,6 +200,18 @@
MESH_ChannelNumber chid);
/**
+ * Handle a channel create requested by a client.
+ *
+ * Create the channel and the tunnel in case this was the first0 channel.
+ *
+ * @param c Client that requested the creation (will be the root).
+ * @param msg Create Channel message.
+ */
+void
+GMCH_handle_local_create (struct MeshClient *c,
+ struct GNUNET_MESH_ChannelMessage *msg);
+
+/**
* Handler for mesh network payload traffic.
*
* @param ch Channel for the message.
Modified: gnunet/src/mesh/gnunet-service-mesh_local.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_local.c 2013-10-11 10:27:52 UTC (rev
30129)
+++ gnunet/src/mesh/gnunet-service-mesh_local.c 2013-10-11 10:59:32 UTC (rev
30130)
@@ -328,17 +328,12 @@
handle_channel_create (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
- struct GNUNET_MESH_ChannelMessage *msg;
- struct MeshPeer *peer;
- struct MeshTunnel2 *t;
- struct MeshChannel *ch;
struct MeshClient *c;
- MESH_ChannelNumber chid;
LOG (GNUNET_ERROR_TYPE_DEBUG, "new channel requested\n");
/* Sanity check for client registration */
- if (NULL == (c = client_get (client)))
+ if (NULL == (c = GML_client_get (client)))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
@@ -354,67 +349,8 @@
return;
}
- msg = (struct GNUNET_MESH_ChannelMessage *) message;
- LOG (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n",
- GNUNET_i2s (&msg->peer), ntohl (msg->port));
- chid = ntohl (msg->channel_id);
+ GMCH_handle_local_create (c, (struct GNUNET_MESH_ChannelMessage *) message);
- /* Sanity check for duplicate channel IDs */
- if (NULL != channel_get_by_local_id (c, chid))
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
-
- peer = peer_get (&msg->peer);
- if (NULL == peer->tunnel)
- {
- peer->tunnel = tunnel_new ();
- peer->tunnel->peer = peer;
- if (peer->id == myid)
- {
- tunnel_change_state (peer->tunnel, MESH_TUNNEL_READY);
- }
- else
- {
- peer_connect (peer);
- }
- }
- t = peer->tunnel;
-
- /* Create channel */
- ch = channel_new (t, c, chid);
- if (NULL == ch)
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
- ch->port = ntohl (msg->port);
- channel_set_options (ch, ntohl (msg->opt));
-
- /* In unreliable channels, we'll use the DLL to buffer BCK data */
- ch->root_rel = GNUNET_new (struct MeshChannelReliability);
- ch->root_rel->ch = ch;
- ch->root_rel->expected_delay = MESH_RETRANSMIT_TIME;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG, "CREATED CHANNEL %s[%x]:%u (%x)\n",
- peer2s (t->peer), ch->gid, ch->port, ch->lid_root);
-
- /* Send create channel */
- {
- struct GNUNET_MESH_ChannelCreate msgcc;
-
- msgcc.header.size = htons (sizeof (msgcc));
- msgcc.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE);
- msgcc.chid = htonl (ch->gid);
- msgcc.port = msg->port;
- msgcc.opt = msg->opt;
-
- GMT_queue_data (t, ch, &msgcc.header, GNUNET_YES);
- }
-
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c 2013-10-11 10:27:52 UTC (rev
30129)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c 2013-10-11 10:59:32 UTC (rev
30130)
@@ -1617,6 +1617,20 @@
/**
+ * Get the tunnel towards a peer.
+ *
+ * @param peer Peer to get from.
+ *
+ * @return Tunnel towards peer.
+ */
+struct MeshTunnel3 *
+GMP_get_tunnel (const struct MeshPeer *peer)
+{
+ return peer->tunnel;
+}
+
+
+/**
* Get the static string for a peer ID.
*
* @param peer Peer.
Modified: gnunet/src/mesh/gnunet-service-mesh_peer.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.h 2013-10-11 10:27:52 UTC (rev
30129)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.h 2013-10-11 10:59:32 UTC (rev
30130)
@@ -264,6 +264,16 @@
GMP_get_short_id (const struct MeshPeer *peer);
/**
+ * Get the tunnel towards a peer.
+ *
+ * @param peer Peer to get from.
+ *
+ * @return Tunnel towards peer.
+ */
+struct MeshTunnel3 *
+GMP_get_tunnel (const struct MeshPeer *peer);
+
+/**
* Get the static string for a peer ID.
*
* @param peer Peer.
Modified: gnunet/src/mesh/gnunet-service-mesh_tunnel.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_tunnel.c 2013-10-11 10:27:52 UTC
(rev 30129)
+++ gnunet/src/mesh/gnunet-service-mesh_tunnel.c 2013-10-11 10:59:32 UTC
(rev 30130)
@@ -611,7 +611,6 @@
}
-
/**
* Change the tunnel state.
*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r30130 - gnunet/src/mesh,
gnunet <=