aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-18 17:06:44 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-18 17:06:44 +0000
commit4a24e0518d613f184dd71658c7041b7f1913703c (patch)
tree8cec62c6e193001bc875a6b1e499ea0b69593c14 /src/mesh
parent47448e370d62bbbdac46cc4825b0e88eb013ff90 (diff)
downloadgnunet-4a24e0518d613f184dd71658c7041b7f1913703c.tar.gz
gnunet-4a24e0518d613f184dd71658c7041b7f1913703c.zip
WiP
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c69
-rw-r--r--src/mesh/mesh_protocol.h24
2 files changed, 44 insertions, 49 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 486684507..29dd2c89d 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -1704,6 +1704,25 @@ tunnel_send_multicast (struct MeshTunnel *t,
1704 1704
1705 1705
1706/** 1706/**
1707 * Send a message to all peers in this tunnel that the tunnel is no longer
1708 * valid.
1709 *
1710 * @param t The tunnel whose peers to notify.
1711 */
1712static void
1713tunnel_send_destroy (struct MeshTunnel *t)
1714{
1715 struct GNUNET_MESH_TunnelDestroy msg;
1716
1717 msg.header.size = htons (sizeof (msg));
1718 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY);
1719 msg.oid = my_full_id;
1720 msg.tid = htonl (t->id.tid);
1721 tunnel_send_multicast (t, &msg.header);
1722}
1723
1724
1725/**
1707 * Destroy the tunnel and free any allocated resources linked to it 1726 * Destroy the tunnel and free any allocated resources linked to it
1708 * 1727 *
1709 * @param t the tunnel to destroy 1728 * @param t the tunnel to destroy
@@ -1924,53 +1943,6 @@ send_core_create_path (void *cls, size_t size, void *buf)
1924} 1943}
1925 1944
1926 1945
1927#if LATER
1928/**
1929 * Function called to notify a client about the socket
1930 * being ready to queue more data. "buf" will be
1931 * NULL and "size" zero if the socket was closed for
1932 * writing in the meantime.
1933 *
1934 * @param cls closure (MeshDataDescriptor with all info to build packet)
1935 * @param size number of bytes available in buf
1936 * @param buf where the callee should write the message
1937 * @return number of bytes written to buf
1938 */
1939static size_t
1940send_core_data_to_origin (void *cls, size_t size, void *buf)
1941{
1942 struct MeshDataDescriptor *info = cls;
1943 struct GNUNET_MESH_ToOrigin *msg = buf;
1944 size_t total_size;
1945
1946 GNUNET_assert (NULL != info);
1947 total_size = sizeof (struct GNUNET_MESH_ToOrigin) + info->size;
1948 GNUNET_assert (total_size < 65536); /* UNIT16_MAX */
1949
1950 if (total_size > size)
1951 {
1952 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1953 "not enough buffer to send data to origin\n");
1954 return 0;
1955 }
1956 msg->header.size = htons (total_size);
1957 msg->header.type = htons (GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN);
1958 GNUNET_PEER_resolve (info->origin->oid, &msg->oid);
1959 msg->tid = htonl (info->origin->tid);
1960 if (0 != info->size)
1961 {
1962 memcpy (&msg[1], &info[1], info->size);
1963 }
1964 if (NULL != info->client)
1965 {
1966 GNUNET_SERVER_receive_done (info->client, GNUNET_OK);
1967 }
1968 GNUNET_free (info);
1969 return total_size;
1970}
1971#endif
1972
1973
1974/** 1946/**
1975 * Function called to notify a client about the socket 1947 * Function called to notify a client about the socket
1976 * being ready to queue more data. "buf" will be 1948 * being ready to queue more data. "buf" will be
@@ -2150,7 +2122,7 @@ send_core_data_raw (void *cls, size_t size, void *buf)
2150 * @return Size of data put in buffer 2122 * @return Size of data put in buffer
2151 */ 2123 */
2152static size_t 2124static size_t
2153send_p2p_tunnel_destroy (void *cls, size_t size, void *buf) 2125send_core_tunnel_destroy (void *cls, size_t size, void *buf)
2154{ 2126{
2155 struct MeshTunnel *t = cls; 2127 struct MeshTunnel *t = cls;
2156 struct MeshClient *c; 2128 struct MeshClient *c;
@@ -3221,7 +3193,6 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client,
3221 t = GNUNET_CONTAINER_multihashmap_get (c->tunnels, &hash); 3193 t = GNUNET_CONTAINER_multihashmap_get (c->tunnels, &hash);
3222 GNUNET_CONTAINER_multihashmap_remove (c->tunnels, &hash, t); 3194 GNUNET_CONTAINER_multihashmap_remove (c->tunnels, &hash, t);
3223 3195
3224// notify_tunnel_destroy(t);
3225 tunnel_destroy(t); 3196 tunnel_destroy(t);
3226 GNUNET_SERVER_receive_done (client, GNUNET_OK); 3197 GNUNET_SERVER_receive_done (client, GNUNET_OK);
3227 return; 3198 return;
diff --git a/src/mesh/mesh_protocol.h b/src/mesh/mesh_protocol.h
index 12723fdac..d7e28af45 100644
--- a/src/mesh/mesh_protocol.h
+++ b/src/mesh/mesh_protocol.h
@@ -183,6 +183,30 @@ struct GNUNET_MESH_PathACK
183 183
184 184
185/** 185/**
186 * Message to destroy a tunnel
187 */
188struct GNUNET_MESH_TunnelDestroy
189{
190 /**
191 * Type: GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY
192 */
193 struct GNUNET_MessageHeader header;
194
195 /**
196 * TID of the tunnel
197 */
198 uint32_t tid GNUNET_PACKED;
199
200 /**
201 * OID of the tunnel
202 */
203 struct GNUNET_PeerIdentity oid;
204
205 /* TODO: signature */
206};
207
208
209/**
186 * Message for mesh flow control 210 * Message for mesh flow control
187 */ 211 */
188struct GNUNET_MESH_SpeedNotify 212struct GNUNET_MESH_SpeedNotify