[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16390 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16390 - gnunet/src/mesh |
Date: |
Fri, 5 Aug 2011 13:06:30 +0200 |
Author: bartpolot
Date: 2011-08-05 13:06:30 +0200 (Fri, 05 Aug 2011)
New Revision: 16390
Modified:
gnunet/src/mesh/gnunet-service-mesh.c
gnunet/src/mesh/mesh.h
gnunet/src/mesh/mesh_api_new.c
gnunet/src/mesh/mesh_protocol.h
Log:
Change client <-> service traffic
Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c 2011-08-05 10:50:53 UTC (rev
16389)
+++ gnunet/src/mesh/gnunet-service-mesh.c 2011-08-05 11:06:30 UTC (rev
16390)
@@ -794,11 +794,11 @@
send_core_data_to_origin (void *cls, size_t size, void *buf)
{
struct MeshDataDescriptor *info = cls;
- struct GNUNET_MESH_DataMessageToOrigin *msg = buf;
+ struct GNUNET_MESH_ToOrigin *msg = buf;
size_t total_size;
GNUNET_assert(NULL != info);
- total_size = sizeof(struct GNUNET_MESH_DataMessageToOrigin) + info->size;
+ total_size = sizeof(struct GNUNET_MESH_ToOrigin) + info->size;
GNUNET_assert(total_size < 65536); /* UNIT16_MAX */
if (total_size > size) {
@@ -836,11 +836,11 @@
send_core_data_unicast (void *cls, size_t size, void *buf)
{
struct MeshDataDescriptor *info = cls;
- struct GNUNET_MESH_DataMessageFromOrigin *msg = buf;
+ struct GNUNET_MESH_Unicast *msg = buf;
size_t total_size;
GNUNET_assert(NULL != info);
- total_size = sizeof(struct GNUNET_MESH_DataMessageFromOrigin) + info->size;
+ total_size = sizeof(struct GNUNET_MESH_Unicast) + info->size;
GNUNET_assert(total_size < 65536); /* UNIT16_MAX */
if (total_size > size) {
@@ -879,11 +879,11 @@
send_core_data_multicast (void *cls, size_t size, void *buf)
{
struct MeshDataDescriptor *info = cls;
- struct GNUNET_MESH_DataMessageMulticast *msg = buf;
+ struct GNUNET_MESH_Multicast *msg = buf;
size_t total_size;
GNUNET_assert(NULL != info);
- total_size = info->size + sizeof(struct GNUNET_MESH_DataMessageMulticast);
+ total_size = info->size + sizeof(struct GNUNET_MESH_Multicast);
GNUNET_assert(total_size < GNUNET_SERVER_MAX_MESSAGE_SIZE);
if (info->peer) {
@@ -1242,20 +1242,20 @@
const struct GNUNET_TRANSPORT_ATS_Information
*atsi)
{
- struct GNUNET_MESH_DataMessageFromOrigin *msg;
+ struct GNUNET_MESH_Unicast *msg;
struct GNUNET_PeerIdentity id;
struct MeshTunnel *t;
struct MeshPeerInfo *pi;
size_t size;
size = ntohs(message->size);
- if (size < sizeof(struct GNUNET_MESH_DataMessageFromOrigin)
+ if (size < sizeof(struct GNUNET_MESH_Unicast)
+ sizeof(struct GNUNET_MessageHeader))
{
GNUNET_break(0);
return GNUNET_OK;
}
- msg = (struct GNUNET_MESH_DataMessageFromOrigin *) message;
+ msg = (struct GNUNET_MESH_Unicast *) message;
t = retrieve_tunnel(&msg->oid, ntohl(msg->tid));
if (NULL == t) {
/* TODO notify back: we don't know this tunnel */
@@ -1303,7 +1303,7 @@
const struct GNUNET_TRANSPORT_ATS_Information
*atsi)
{
- struct GNUNET_MESH_DataMessageMulticast *msg;
+ struct GNUNET_MESH_Multicast *msg;
struct GNUNET_PeerIdentity id;
struct MeshTunnel *t;
struct MeshDataDescriptor *info;
@@ -1314,13 +1314,13 @@
size = ntohs(message->size);
- if (size < sizeof(struct GNUNET_MESH_DataMessageMulticast)
+ if (size < sizeof(struct GNUNET_MESH_Multicast)
+ sizeof(struct GNUNET_MessageHeader))
{
GNUNET_break_op (0);
return GNUNET_OK;
}
- msg = (struct GNUNET_MESH_DataMessageMulticast *) message;
+ msg = (struct GNUNET_MESH_Multicast *) message;
t = retrieve_tunnel(&msg->oid, ntohl(msg->tid));
if (NULL == t) {
@@ -1343,7 +1343,7 @@
if (!neighbors[0]) {
return GNUNET_OK;
}
- size -= sizeof(struct GNUNET_MESH_DataMessageMulticast);
+ size -= sizeof(struct GNUNET_MESH_Multicast);
info = GNUNET_malloc(sizeof(struct MeshDataDescriptor) + size);
info->origin = &t->id;
info->copies = 0;
@@ -1392,20 +1392,20 @@
const struct GNUNET_TRANSPORT_ATS_Information
*atsi)
{
- struct GNUNET_MESH_DataMessageToOrigin *msg;
+ struct GNUNET_MESH_ToOrigin *msg;
struct GNUNET_PeerIdentity id;
struct MeshTunnel *t;
struct MeshPeerInfo *peer_info;
size_t size;
size = ntohs(message->size);
- if (size < sizeof(struct GNUNET_MESH_DataMessageToOrigin)
+ if (size < sizeof(struct GNUNET_MESH_ToOrigin)
+ sizeof(struct GNUNET_MessageHeader))
{
GNUNET_break_op (0);
return GNUNET_OK;
}
- msg = (struct GNUNET_MESH_DataMessageToOrigin *) message;
+ msg = (struct GNUNET_MESH_ToOrigin *) message;
t = retrieve_tunnel(&msg->oid, ntohl(msg->tid));
if (NULL == t) {
@@ -2145,14 +2145,14 @@
* @param message the actual message
*/
static void
-handle_local_network_traffic (void *cls,
- struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+handle_local_unicast (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
{
struct MeshClient *c;
struct MeshTunnel *t;
struct MeshPeerInfo *pi;
- struct GNUNET_MESH_Data *data_msg;
+ struct GNUNET_MESH_Unicast *data_msg;
struct GNUNET_PeerIdentity next_hop;
struct MeshDataDescriptor *info;
MESH_TunnelNumber tid;
@@ -2164,10 +2164,10 @@
GNUNET_SERVER_receive_done(client, GNUNET_SYSERR);
return;
}
- data_msg = (struct GNUNET_MESH_Data *)message;
+ data_msg = (struct GNUNET_MESH_Unicast *)message;
/* Sanity check for message size */
- if (sizeof(struct GNUNET_MESH_Data) >
- ntohs(data_msg->header.size))
+ if (sizeof(struct GNUNET_MESH_Unicast) + sizeof(struct
GNUNET_MessageHeader)
+ > ntohs(data_msg->header.size))
{
GNUNET_break(0);
GNUNET_SERVER_receive_done(client, GNUNET_SYSERR);
@@ -2175,7 +2175,7 @@
}
/* Tunnel exists? */
- tid = ntohl(data_msg->tunnel_id);
+ tid = ntohl(data_msg->tid);
t = retrieve_tunnel_by_local_id(c, tid);
if (NULL == t) {
GNUNET_break(0);
@@ -2191,7 +2191,7 @@
}
pi = GNUNET_CONTAINER_multihashmap_get(t->peers,
- &data_msg->peer_id.hashPubKey);
+ &data_msg->destination.hashPubKey);
/* Is the selected peer in the tunnel? */
if (NULL == pi) {
/* TODO
@@ -2202,7 +2202,7 @@
return;
}
GNUNET_PEER_resolve(get_first_hop(pi->path), &next_hop);
- data_size = ntohs(message->size) - sizeof(struct GNUNET_MESH_Data);
+ data_size = ntohs(message->size) - sizeof(struct GNUNET_MESH_Unicast);
info = GNUNET_malloc(sizeof(struct MeshDataDescriptor) + data_size);
memcpy(&info[1], &data_msg[1], data_size);
info->destination = pi->id;
@@ -2215,8 +2215,7 @@
GNUNET_TIME_UNIT_FOREVER_REL,
&next_hop,
/* FIXME re-check types */
- message->size - sizeof(struct GNUNET_MESH_Data)
- + sizeof(struct GNUNET_MESH_DataMessageFromOrigin),
+ data_size + sizeof(struct GNUNET_MESH_Unicast),
&send_core_data_unicast,
info);
return;
@@ -2230,13 +2229,13 @@
* @param message the actual message
*/
static void
-handle_local_network_traffic_bcast (void *cls,
- struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+handle_local_multicast (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
{
struct MeshClient *c;
struct MeshTunnel *t;
- struct GNUNET_MESH_DataBroadcast *data_msg;
+ struct GNUNET_MESH_Multicast *data_msg;
MESH_TunnelNumber tid;
/* Sanity check for client registration */
@@ -2245,7 +2244,7 @@
GNUNET_SERVER_receive_done(client, GNUNET_SYSERR);
return;
}
- data_msg = (struct GNUNET_MESH_DataBroadcast *)message;
+ data_msg = (struct GNUNET_MESH_Multicast *)message;
/* Sanity check for message size */
if (sizeof(struct GNUNET_MESH_PeerControl)
!= ntohs(data_msg->header.size))
@@ -2256,7 +2255,7 @@
}
/* Tunnel exists? */
- tid = ntohl(data_msg->tunnel_id);
+ tid = ntohl(data_msg->tid);
t = retrieve_tunnel_by_local_id(c, tid);
if (NULL == t) {
GNUNET_break(0);
@@ -2297,11 +2296,11 @@
{&handle_local_connect_by_type, NULL,
GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE,
sizeof(struct GNUNET_MESH_ConnectPeerByType)},
- {&handle_local_network_traffic, NULL,
+ {&handle_local_unicast, NULL,
GNUNET_MESSAGE_TYPE_MESH_UNICAST, 0},
- {&handle_local_network_traffic, NULL,
+ {&handle_local_unicast, NULL,
GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN, 0},
- {&handle_local_network_traffic_bcast, NULL,
+ {&handle_local_multicast, NULL,
GNUNET_MESSAGE_TYPE_MESH_MULTICAST, 0},
{NULL, NULL, 0, 0}
};
Modified: gnunet/src/mesh/mesh.h
===================================================================
--- gnunet/src/mesh/mesh.h 2011-08-05 10:50:53 UTC (rev 16389)
+++ gnunet/src/mesh/mesh.h 2011-08-05 11:06:30 UTC (rev 16390)
@@ -49,15 +49,14 @@
* peer_request_connect_del GNUNET_MESH_PeerControl
* peer_request_connect_by_type GNUNET_MESH_ConnectPeerByType
*
- * notify_transmit_ready GNUNET_MESH_TransmitReady
+ * notify_transmit_ready *GNUNET_MESH_TransmitReady?*
* notify_transmit_ready_cancel None (clear of internal data
structures)
*
*
*
* EVENT MESSAGE USED
* ----- ------------
- * notify_transmit_ready reply GNUNET_MESH_TransmitReady
- * notify_transmit_ready data GNUNET_MESH_Data OR
+ * data GNUNET_MESH_Data OR
* GNUNET_MESH_DataBroadcast
* new incoming tunnel GNUNET_MESH_PeerControl
* peer connects to a tunnel GNUNET_MESH_PeerControl
@@ -170,72 +169,4 @@
GNUNET_MESH_ApplicationType type GNUNET_PACKED;
};
-
-/**
- * Message for notifying the service that the client wants to send data or
- * notifying a client that the service is ready to accept data.
- */
-struct GNUNET_MESH_TransmitReady {
- /**
- * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_REQUEST_TRANSMIT_READY
- * GNUNET_MESSAGE_TYPE_MESH_LOCAL_NOTIFY_TRANSMIT_READY
- */
- struct GNUNET_MessageHeader header;
-
- /**
- * ID of a tunnel controlled by this client.
- */
- MESH_TunnelNumber tunnel_id GNUNET_PACKED;
-
- /**
- * Size of message we would like to transmit to this tunnel
- */
- uint32_t msg_size GNUNET_PACKED;
-};
-
-
-/**
- * Message to encapsulate data transmitted to/from the service
- */
-struct GNUNET_MESH_Data {
- /**
- * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA
- * (client to service, or service to client)
- * Size: sizeof(struct GNUNET_MESH_Data) + sizeof (data)
- */
- struct GNUNET_MessageHeader header;
-
- /**
- * ID of a tunnel in which this client participates.
- */
- MESH_TunnelNumber tunnel_id GNUNET_PACKED;
-
- /**
- * Source or destination of the message (depending on direction).
- */
- struct GNUNET_PeerIdentity peer_id;
-
- /* uint8_t data[] */
-};
-
-/**
- * Message to encapsulate broadcast data transmitted to the service
- */
-struct GNUNET_MESH_DataBroadcast {
- /**
- * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA_BROADCAST
- * (client to service only, client created tunnel)
- * Size: sizeof(struct GNUNET_MESH_DataBroadcast) + sizeof (data)
- */
- struct GNUNET_MessageHeader header;
-
- /**
- * ID of a tunnel controlled by this client.
- */
- MESH_TunnelNumber tunnel_id GNUNET_PACKED;
-
- /* uint8_t data[] */
-};
-
-
#endif
Modified: gnunet/src/mesh/mesh_api_new.c
===================================================================
--- gnunet/src/mesh/mesh_api_new.c 2011-08-05 10:50:53 UTC (rev 16389)
+++ gnunet/src/mesh/mesh_api_new.c 2011-08-05 11:06:30 UTC (rev 16390)
@@ -48,6 +48,7 @@
#include "gnunet_peer_lib.h"
#include "gnunet_mesh_service_new.h"
#include "mesh.h"
+#include "mesh_protocol.h"
/******************************************************************************/
/************************ DATA STRUCTURES
****************************/
@@ -350,18 +351,22 @@
*/
static void
process_incoming_data(struct GNUNET_MESH_Handle *h,
- const struct GNUNET_MESH_Data *msg)
+ const struct GNUNET_MessageHeader *message)
{
- const struct GNUNET_MESH_Data *payload;
+ const struct GNUNET_MessageHeader *payload;
const struct GNUNET_MESH_MessageHandler *handler;
+ struct GNUNET_MESH_Unicast *ucast;
struct GNUNET_MESH_Tunnel *t;
uint16_t type;
int i;
- t = retrieve_tunnel(h, ntohl(msg->tunnel_id));
-
- payload = (struct GNUNET_MESH_Data *) &msg[1];
- type = ntohs(payload->header.type);
+ type = ntohs(message->type);
+ switch (type) {
+ case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
+ ucast = message;
+ t = retrieve_tunnel(h, ntohl(ucast->tid));
+
+ }
for (i = 0; i < h->n_handlers; i++) {
handler = &h->message_handlers[i];
if (handler->type == type) {
@@ -398,8 +403,7 @@
struct GNUNET_MESH_Handle *h = cls;
if (msg == NULL) {
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "received a NULL message from mesh\n");
+ GNUNET_break_op(0);
return;
}
@@ -418,7 +422,7 @@
case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
- process_incoming_data(h, (struct GNUNET_MESH_Data *)msg);
+ process_incoming_data(h, msg);
break;
/* We shouldn't get any other packages, log and ignore */
default:
Modified: gnunet/src/mesh/mesh_protocol.h
===================================================================
--- gnunet/src/mesh/mesh_protocol.h 2011-08-05 10:50:53 UTC (rev 16389)
+++ gnunet/src/mesh/mesh_protocol.h 2011-08-05 11:06:30 UTC (rev 16390)
@@ -67,10 +67,10 @@
/**
* Message for mesh data traffic to all tunnel targets.
*/
-struct GNUNET_MESH_DataMessageMulticast
+struct GNUNET_MESH_Multicast
{
/**
- * Type: GNUNET_MESSAGE_TYPE_DATA_MULTICAST
+ * Type: GNUNET_MESSAGE_TYPE_MESH_MULTICAST
*/
struct GNUNET_MessageHeader header;
@@ -93,10 +93,10 @@
/**
* Message for mesh data traffic to a particular destination from origin.
*/
-struct GNUNET_MESH_DataMessageFromOrigin
+struct GNUNET_MESH_Unicast
{
/**
- * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN
+ * Type: GNUNET_MESSAGE_TYPE_MESH_UNICAST
*/
struct GNUNET_MessageHeader header;
@@ -124,10 +124,10 @@
/**
* Message for mesh data traffic from a tunnel participant to origin.
*/
-struct GNUNET_MESH_DataMessageToOrigin
+struct GNUNET_MESH_ToOrigin
{
/**
- * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN
+ * Type: GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN
*/
struct GNUNET_MessageHeader header;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16390 - gnunet/src/mesh,
gnunet <=