diff options
Diffstat (limited to 'src/core/gnunet-service-core_typemap.c')
-rw-r--r-- | src/core/gnunet-service-core_typemap.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/core/gnunet-service-core_typemap.c b/src/core/gnunet-service-core_typemap.c index d400c0b8b..0600f59ef 100644 --- a/src/core/gnunet-service-core_typemap.c +++ b/src/core/gnunet-service-core_typemap.c | |||
@@ -177,8 +177,10 @@ GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg) | |||
177 | GNUNET_memcpy (ret, &msg[1], sizeof (struct GSC_TypeMap)); | 177 | GNUNET_memcpy (ret, &msg[1], sizeof (struct GSC_TypeMap)); |
178 | return ret; | 178 | return ret; |
179 | case GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP: | 179 | case GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP: |
180 | GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# type maps received"), | 180 | GNUNET_STATISTICS_update (GSC_stats, |
181 | 1, GNUNET_NO); | 181 | gettext_noop ("# type maps received"), |
182 | 1, | ||
183 | GNUNET_NO); | ||
182 | ret = GNUNET_new (struct GSC_TypeMap); | 184 | ret = GNUNET_new (struct GSC_TypeMap); |
183 | dlen = sizeof (struct GSC_TypeMap); | 185 | dlen = sizeof (struct GSC_TypeMap); |
184 | if ((Z_OK != | 186 | if ((Z_OK != |
@@ -207,7 +209,8 @@ broadcast_my_type_map () | |||
207 | 209 | ||
208 | hdr = GSC_TYPEMAP_compute_type_map_message (); | 210 | hdr = GSC_TYPEMAP_compute_type_map_message (); |
209 | GNUNET_STATISTICS_update (GSC_stats, | 211 | GNUNET_STATISTICS_update (GSC_stats, |
210 | gettext_noop ("# updates to my type map"), 1, | 212 | gettext_noop ("# updates to my type map"), |
213 | 1, | ||
211 | GNUNET_NO); | 214 | GNUNET_NO); |
212 | GSC_SESSIONS_broadcast_typemap (hdr); | 215 | GSC_SESSIONS_broadcast_typemap (hdr); |
213 | GNUNET_free (hdr); | 216 | GNUNET_free (hdr); |
@@ -238,6 +241,8 @@ GSC_TYPEMAP_add (const uint16_t *types, | |||
238 | } | 241 | } |
239 | if (GNUNET_YES == changed) | 242 | if (GNUNET_YES == changed) |
240 | { | 243 | { |
244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
245 | "Typemap changed, broadcasting!\n"); | ||
241 | rehash_typemap (); | 246 | rehash_typemap (); |
242 | broadcast_my_type_map (); | 247 | broadcast_my_type_map (); |
243 | } | 248 | } |
@@ -254,11 +259,10 @@ void | |||
254 | GSC_TYPEMAP_remove (const uint16_t *types, | 259 | GSC_TYPEMAP_remove (const uint16_t *types, |
255 | unsigned int tlen) | 260 | unsigned int tlen) |
256 | { | 261 | { |
257 | unsigned int i; | ||
258 | int changed; | 262 | int changed; |
259 | 263 | ||
260 | changed = GNUNET_NO; | 264 | changed = GNUNET_NO; |
261 | for (i = 0; i < tlen; i++) | 265 | for (unsigned int i = 0; i < tlen; i++) |
262 | { | 266 | { |
263 | if (0 == --map_counters[types[i]]) | 267 | if (0 == --map_counters[types[i]]) |
264 | { | 268 | { |
@@ -288,13 +292,11 @@ GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap, | |||
288 | const uint16_t *types, | 292 | const uint16_t *types, |
289 | unsigned int tcnt) | 293 | unsigned int tcnt) |
290 | { | 294 | { |
291 | unsigned int i; | ||
292 | |||
293 | if (NULL == tmap) | 295 | if (NULL == tmap) |
294 | return GNUNET_NO; | 296 | return GNUNET_NO; |
295 | if (0 == tcnt) | 297 | if (0 == tcnt) |
296 | return GNUNET_YES; /* matches all */ | 298 | return GNUNET_YES; /* matches all */ |
297 | for (i = 0; i < tcnt; i++) | 299 | for (unsigned int i = 0; i < tcnt; i++) |
298 | if (0 != (tmap->bits[types[i] / 32] & (1 << (types[i] % 32)))) | 300 | if (0 != (tmap->bits[types[i] / 32] & (1 << (types[i] % 32)))) |
299 | return GNUNET_YES; | 301 | return GNUNET_YES; |
300 | return GNUNET_NO; | 302 | return GNUNET_NO; |
@@ -315,12 +317,11 @@ GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap, | |||
315 | unsigned int tcnt) | 317 | unsigned int tcnt) |
316 | { | 318 | { |
317 | struct GSC_TypeMap *ret; | 319 | struct GSC_TypeMap *ret; |
318 | unsigned int i; | ||
319 | 320 | ||
320 | ret = GNUNET_new (struct GSC_TypeMap); | 321 | ret = GNUNET_new (struct GSC_TypeMap); |
321 | if (NULL != tmap) | 322 | if (NULL != tmap) |
322 | GNUNET_memcpy (ret, tmap, sizeof (struct GSC_TypeMap)); | 323 | GNUNET_memcpy (ret, tmap, sizeof (struct GSC_TypeMap)); |
323 | for (i = 0; i < tcnt; i++) | 324 | for (unsigned int i = 0; i < tcnt; i++) |
324 | ret->bits[types[i] / 32] |= (1 << (types[i] % 32)); | 325 | ret->bits[types[i] / 32] |= (1 << (types[i] % 32)); |
325 | return ret; | 326 | return ret; |
326 | } | 327 | } |