[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r27149 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r27149 - gnunet/src/mesh |
Date: |
Wed, 15 May 2013 14:52:16 +0200 |
Author: bartpolot
Date: 2013-05-15 14:52:16 +0200 (Wed, 15 May 2013)
New Revision: 27149
Modified:
gnunet/src/mesh/gnunet-service-mesh-new.c
gnunet/src/mesh/mesh2.h
gnunet/src/mesh/mesh2_api.c
Log:
- stop using message types of payload on service side
Modified: gnunet/src/mesh/gnunet-service-mesh-new.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh-new.c 2013-05-15 12:49:34 UTC (rev
27148)
+++ gnunet/src/mesh/gnunet-service-mesh-new.c 2013-05-15 12:52:16 UTC (rev
27149)
@@ -398,7 +398,7 @@
/**
* Struct containing information about a client of the service
*
- * TODO: add a list of 'waiting' types
+ * TODO: add a list of 'waiting' ports
*/
struct MeshClient
{
@@ -428,12 +428,6 @@
struct GNUNET_SERVER_Client *handle;
/**
- * Messages that this client has declared interest in.
- * Indexed by a GMC_hash32 (type), contains *Client.
- */
- struct GNUNET_CONTAINER_MultiHashMap *types;
-
- /**
* Ports that this client has declared interest in.
* Indexed by a GMC_hash32 (type), contains *Client.
*/
@@ -632,11 +626,6 @@
static MESH_TunnelNumber next_local_tid;
/**
- * All message types clients of this peer are interested in.
- */
-static struct GNUNET_CONTAINER_MultiHashMap *types;
-
-/**
* All ports clients of this peer have opened.
*/
static struct GNUNET_CONTAINER_MultiHashMap *ports;
@@ -3823,8 +3812,8 @@
GNUNET_CONTAINER_multihashmap_destroy (c->own_tunnels);
GNUNET_CONTAINER_multihashmap_destroy (c->incoming_tunnels);
- if (NULL != c->types)
- GNUNET_CONTAINER_multihashmap_destroy (c->types);
+ if (NULL != c->ports)
+ GNUNET_CONTAINER_multihashmap_destroy (c->ports);
next = c->next;
GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, c);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " CLIENT FREE at %p\n", c);
@@ -3851,9 +3840,6 @@
struct GNUNET_MESH_ClientConnect *cc_msg;
struct MeshClient *c;
unsigned int size;
- uint16_t ntypes;
- uint16_t nports;
- uint16_t *t;
uint32_t *p;
unsigned int i;
@@ -3862,51 +3848,29 @@
/* Check data sanity */
size = ntohs (message->size) - sizeof (struct GNUNET_MESH_ClientConnect);
cc_msg = (struct GNUNET_MESH_ClientConnect *) message;
- ntypes = ntohs (cc_msg->types);
- nports = ntohs (cc_msg->ports);
- if (size != ntypes * sizeof (uint16_t))
+ if (0 != (size % sizeof (uint32_t)))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
+ size /= sizeof (uint32_t);
/* Create new client structure */
c = GNUNET_malloc (sizeof (struct MeshClient));
c->id = next_client_id++; /* overflow not important: just for debug */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " CLIENT NEW %u\n", c->id);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " client has %u types\n", ntypes);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " client id %u\n", c->id);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " client has %u ports\n", size);
c->handle = client;
GNUNET_SERVER_client_keep (client);
- t = (uint16_t *) &cc_msg[1];
- if (ntypes > 0)
+ if (size > 0)
{
- uint16_t u16;
- struct GNUNET_HashCode hc;
-
- c->types = GNUNET_CONTAINER_multihashmap_create (ntypes, GNUNET_NO);
- for (i = 0; i < ntypes; i++)
- {
- u16 = ntohs (t[i]);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " msg type: %u\n", u16);
- GMC_hash32 ((uint32_t) u16, &hc);
-
- /* store in client's hashmap */
- GNUNET_CONTAINER_multihashmap_put (c->types, &hc, c,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
- /* store in global hashmap */
- GNUNET_CONTAINER_multihashmap_put (types, &hc, c,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
- }
- }
- if (nports > 0)
- {
uint32_t u32;
struct GNUNET_HashCode hc;
- p = (uint32_t *) &t[ntypes];
- c->ports = GNUNET_CONTAINER_multihashmap_create (nports, GNUNET_NO);
- for (i = 0; i < nports; i++)
+ p = (uint32_t *) &cc_msg[1];
+ c->ports = GNUNET_CONTAINER_multihashmap_create (size, GNUNET_NO);
+ for (i = 0; i < size; i++)
{
u32 = ntohl (p[i]);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " port: %u\n", u32);
@@ -4983,7 +4947,6 @@
tunnels = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_NO);
incoming_tunnels = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_NO);
peers = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_NO);
- types = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_NO);
ports = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_NO);
dht_handle = GNUNET_DHT_connect (c, 64);
Modified: gnunet/src/mesh/mesh2.h
===================================================================
--- gnunet/src/mesh/mesh2.h 2013-05-15 12:49:34 UTC (rev 27148)
+++ gnunet/src/mesh/mesh2.h 2013-05-15 12:52:16 UTC (rev 27149)
@@ -112,10 +112,7 @@
* sizeof(uint16_t) * types
*/
struct GNUNET_MessageHeader header;
- uint16_t types GNUNET_PACKED;
- uint16_t ports GNUNET_PACKED;
- /* uint16_t list_types[types] */
- /* uint32_t list_ports[ports] */
+ /* uint32_t list_ports[] */
};
Modified: gnunet/src/mesh/mesh2_api.c
===================================================================
--- gnunet/src/mesh/mesh2_api.c 2013-05-15 12:49:34 UTC (rev 27148)
+++ gnunet/src/mesh/mesh2_api.c 2013-05-15 12:52:16 UTC (rev 27149)
@@ -643,11 +643,10 @@
size_t size;
size = sizeof (struct GNUNET_MESH_ClientConnect);
- size += h->n_handlers * sizeof (uint16_t);
+ size += h->n_ports * sizeof (uint32_t);
{
char buf[size] GNUNET_ALIGN;
struct GNUNET_MESH_ClientConnect *msg;
- uint16_t *types;
uint32_t *ports;
uint16_t i;
@@ -655,16 +654,7 @@
msg = (struct GNUNET_MESH_ClientConnect *) buf;
msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT);
msg->header.size = htons (size);
- msg->types = htons (h->n_handlers);
- msg->ports = htons (h->n_ports);
- types = (uint16_t *) &msg[1];
- for (i = 0; i < h->n_handlers; i++)
- {
- types[i] = htons (h->message_handlers[i].type);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " type %u\n",
- h->message_handlers[i].type);
- }
- ports = (uint32_t *) &types[h->n_handlers];
+ ports = (uint32_t *) &msg[1];
for (i = 0; i < h->n_ports; i++)
{
ports[i] = htonl (h->ports[i]);
@@ -672,8 +662,8 @@
h->ports[i]);
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Sending %lu bytes long message %u types and %u ports\n",
- ntohs (msg->header.size), h->n_handlers, h->n_ports);
+ "Sending %lu bytes long message with %u ports\n",
+ ntohs (msg->header.size), h->n_ports);
send_packet (h, &msg->header, NULL);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r27149 - gnunet/src/mesh,
gnunet <=