[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17280 - gnunet/src/core
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17280 - gnunet/src/core |
Date: |
Fri, 7 Oct 2011 13:26:17 +0200 |
Author: grothoff
Date: 2011-10-07 13:26:17 +0200 (Fri, 07 Oct 2011)
New Revision: 17280
Modified:
gnunet/src/core/gnunet-service-core_sessions.c
gnunet/src/core/gnunet-service-core_typemap.c
gnunet/src/core/gnunet-service-core_typemap.h
Log:
hxing typemap
Modified: gnunet/src/core/gnunet-service-core_sessions.c
===================================================================
--- gnunet/src/core/gnunet-service-core_sessions.c 2011-10-07 11:11:14 UTC
(rev 17279)
+++ gnunet/src/core/gnunet-service-core_sessions.c 2011-10-07 11:26:17 UTC
(rev 17280)
@@ -100,23 +100,6 @@
unsigned int ats_count;
/**
- * Bit map indicating which of the 32 sequence numbers before the last
- * were received (good for accepting out-of-order packets and
- * estimating reliability of the connection)
- */
- unsigned int last_packets_bitmap;
-
- /**
- * last sequence number received on this connection (highest)
- */
- uint32_t last_sequence_number_received;
-
- /**
- * last sequence number transmitted
- */
- uint32_t last_sequence_number_sent;
-
- /**
* Available bandwidth in for this peer (current target).
*/
struct GNUNET_BANDWIDTH_Value32NBO bw_in;
Modified: gnunet/src/core/gnunet-service-core_typemap.c
===================================================================
--- gnunet/src/core/gnunet-service-core_typemap.c 2011-10-07 11:11:14 UTC
(rev 17279)
+++ gnunet/src/core/gnunet-service-core_typemap.c 2011-10-07 11:26:17 UTC
(rev 17280)
@@ -41,13 +41,17 @@
uint32_t bits[(UINT16_MAX + 1) / 32];
};
-
/**
* Bitmap of message types this peer is able to handle.
*/
-static uint32_t my_type_map[(UINT16_MAX + 1) / 32];
+static struct GSC_TypeMap my_type_map;
+/**
+ * Counters for message types this peer is able to handle.
+ */
+static uint8_t map_counters[UINT16_MAX + 1];
+
/**
* Compute a type map message for this peer.
*
@@ -71,11 +75,11 @@
hdr->size = htons ((uint16_t) dlen + sizeof (struct GNUNET_MessageHeader));
tmp = (char *) &hdr[1];
if ((Z_OK !=
- compress2 ((Bytef *) tmp, &dlen, (const Bytef *) my_type_map,
+ compress2 ((Bytef *) tmp, &dlen, (const Bytef *) &my_type_map,
sizeof (my_type_map), 9)) || (dlen >= sizeof (my_type_map)))
{
dlen = sizeof (my_type_map);
- memcpy (tmp, my_type_map, sizeof (my_type_map));
+ memcpy (tmp, &my_type_map, sizeof (my_type_map));
hdr->type = htons (GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP);
}
else
@@ -95,7 +99,7 @@
struct GNUNET_MessageHeader *hdr;
hdr = compute_type_map_message ();
- GSC_SESSIONS_broadcast (hdr);x
+ GSC_SESSIONS_broadcast (hdr);
GNUNET_free (hdr);
}
@@ -108,10 +112,18 @@
unsigned int tlen)
{
unsigned int i;
+ int changed;
+ changed = GNUNET_NO;
for (i=0;i<tlen;i++)
- my_type_map[types[i] / 32] |= (1 << (types[i] % 32));
- if (tlen > 0)
+ {
+ if (0 == map_counters[types[i]]++)
+ {
+ my_type_map.bits[types[i] / 32] |= (1 << (types[i] % 32));
+ changed = GNUNET_YES;
+ }
+ }
+ if (GNUNET_YES == changed)
broadcast_my_type_map ();
}
@@ -123,15 +135,20 @@
GSC_TYPEMAP_remove (const uint16_t *types,
unsigned int tlen)
{
- /* rebuild my_type_map */
- memset (my_type_map, 0, sizeof (my_type_map));
- for (pos = clients; NULL != pos; pos = pos->next)
+ unsigned int i;
+ int changed;
+
+ changed = GNUNET_NO;
+ for (i=0;i<tlen;i++)
{
- wtypes = (const uint16_t *) &pos[1];
- for (i = 0; i < pos->tcnt; i++)
- my_type_map[wtypes[i] / 32] |= (1 << (wtypes[i] % 32));
+ if (0 == --map_counters[types[i]])
+ {
+ my_type_map.bits[types[i] / 32] &= ~(1 << (types[i] % 32));
+ changed = GNUNET_YES;
+ }
}
- broadcast_my_type_map ();
+ if (GNUNET_YES == changed)
+ broadcast_my_type_map ();
}
@@ -149,19 +166,32 @@
const uint16_t *types,
unsigned int tcnt)
{
- return GNUNET_YES; /* FIXME */
+ unsigned int i;
+
+ for (i=0;i<tcnt;i++)
+ if (0 != (my_type_map.bits[types[i] / 32] & (1 << (types[i] % 32))))
+ return GNUNET_YES;
+ return GNUNET_NO;
}
+/**
+ * Initialize typemap subsystem.
+ */
void
GSC_TYPEMAP_init ()
{
+ /* nothing to do */
}
+/**
+ * Shutdown typemap subsystem.
+ */
void
GSC_TYPEMAP_done ()
{
+ /* nothing to do */
}
/* end of gnunet-service-core_typemap.c */
Modified: gnunet/src/core/gnunet-service-core_typemap.h
===================================================================
--- gnunet/src/core/gnunet-service-core_typemap.h 2011-10-07 11:11:14 UTC
(rev 17279)
+++ gnunet/src/core/gnunet-service-core_typemap.h 2011-10-07 11:26:17 UTC
(rev 17280)
@@ -66,12 +66,18 @@
unsigned int tcnt);
+/**
+ * Initialize typemap subsystem.
+ */
void
-GSC_TYPEMAP_init ();
+GSC_TYPEMAP_init (void);
+/**
+ * Shutdown typemap subsystem.
+ */
void
-GSC_TYPEMAP_done ();
+GSC_TYPEMAP_done (void);
#endif
/* end of gnunet-service-core_typemap.h */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17280 - gnunet/src/core,
gnunet <=