diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-04-23 09:30:14 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-04-23 09:30:14 +0000 |
commit | 2c9743fed0eb54a28cf376ef8fbb7a934990684c (patch) | |
tree | 461b2240b7f48acb40ef3ce9aa4319322b9b152c /src/core/gnunet-service-core_typemap.c | |
parent | 3b94e08fe7391f9226184c1eb070628360354de6 (diff) | |
download | gnunet-2c9743fed0eb54a28cf376ef8fbb7a934990684c.tar.gz gnunet-2c9743fed0eb54a28cf376ef8fbb7a934990684c.zip |
-comments
Diffstat (limited to 'src/core/gnunet-service-core_typemap.c')
-rw-r--r-- | src/core/gnunet-service-core_typemap.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/core/gnunet-service-core_typemap.c b/src/core/gnunet-service-core_typemap.c index c9774ddec..8d9fcbec7 100644 --- a/src/core/gnunet-service-core_typemap.c +++ b/src/core/gnunet-service-core_typemap.c | |||
@@ -77,12 +77,14 @@ GSC_TYPEMAP_compute_type_map_message () | |||
77 | compress2 ((Bytef *) tmp, &dlen, (const Bytef *) &my_type_map, | 77 | compress2 ((Bytef *) tmp, &dlen, (const Bytef *) &my_type_map, |
78 | sizeof (my_type_map), 9)) || (dlen >= sizeof (my_type_map))) | 78 | sizeof (my_type_map), 9)) || (dlen >= sizeof (my_type_map))) |
79 | { | 79 | { |
80 | /* compression failed, use uncompressed map */ | ||
80 | dlen = sizeof (my_type_map); | 81 | dlen = sizeof (my_type_map); |
81 | memcpy (tmp, &my_type_map, sizeof (my_type_map)); | 82 | memcpy (tmp, &my_type_map, sizeof (my_type_map)); |
82 | hdr->type = htons (GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP); | 83 | hdr->type = htons (GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP); |
83 | } | 84 | } |
84 | else | 85 | else |
85 | { | 86 | { |
87 | /* compression worked, use compressed map */ | ||
86 | hdr->type = htons (GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP); | 88 | hdr->type = htons (GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP); |
87 | } | 89 | } |
88 | hdr->size = htons ((uint16_t) dlen + sizeof (struct GNUNET_MessageHeader)); | 90 | hdr->size = htons ((uint16_t) dlen + sizeof (struct GNUNET_MessageHeader)); |
@@ -157,9 +159,13 @@ broadcast_my_type_map () | |||
157 | 159 | ||
158 | /** | 160 | /** |
159 | * Add a set of types to our type map. | 161 | * Add a set of types to our type map. |
162 | * | ||
163 | * @param types array of message types supported by this peer | ||
164 | * @param tlen number of entries in @a types | ||
160 | */ | 165 | */ |
161 | void | 166 | void |
162 | GSC_TYPEMAP_add (const uint16_t * types, unsigned int tlen) | 167 | GSC_TYPEMAP_add (const uint16_t *types, |
168 | unsigned int tlen) | ||
163 | { | 169 | { |
164 | unsigned int i; | 170 | unsigned int i; |
165 | int changed; | 171 | int changed; |
@@ -180,9 +186,13 @@ GSC_TYPEMAP_add (const uint16_t * types, unsigned int tlen) | |||
180 | 186 | ||
181 | /** | 187 | /** |
182 | * Remove a set of types from our type map. | 188 | * Remove a set of types from our type map. |
189 | * | ||
190 | * @param types array of message types no longer supported by this peer | ||
191 | * @param tlen number of entries in @a types | ||
183 | */ | 192 | */ |
184 | void | 193 | void |
185 | GSC_TYPEMAP_remove (const uint16_t * types, unsigned int tlen) | 194 | GSC_TYPEMAP_remove (const uint16_t *types, |
195 | unsigned int tlen) | ||
186 | { | 196 | { |
187 | unsigned int i; | 197 | unsigned int i; |
188 | int changed; | 198 | int changed; |
@@ -207,11 +217,12 @@ GSC_TYPEMAP_remove (const uint16_t * types, unsigned int tlen) | |||
207 | * | 217 | * |
208 | * @param tmap map to test | 218 | * @param tmap map to test |
209 | * @param types array of types | 219 | * @param types array of types |
210 | * @param tcnt number of entries in types | 220 | * @param tcnt number of entries in @a types |
211 | * @return GNUNET_YES if a type is in the map, GNUNET_NO if not | 221 | * @return #GNUNET_YES if a type is in the map, #GNUNET_NO if not |
212 | */ | 222 | */ |
213 | int | 223 | int |
214 | GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap, const uint16_t * types, | 224 | GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap, |
225 | const uint16_t *types, | ||
215 | unsigned int tcnt) | 226 | unsigned int tcnt) |
216 | { | 227 | { |
217 | unsigned int i; | 228 | unsigned int i; |
@@ -232,11 +243,12 @@ GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap, const uint16_t * types, | |||
232 | * | 243 | * |
233 | * @param tmap map to extend (not changed) | 244 | * @param tmap map to extend (not changed) |
234 | * @param types array of types to add | 245 | * @param types array of types to add |
235 | * @param tcnt number of entries in types | 246 | * @param tcnt number of entries in @a types |
236 | * @return updated type map (fresh copy) | 247 | * @return updated type map (fresh copy) |
237 | */ | 248 | */ |
238 | struct GSC_TypeMap * | 249 | struct GSC_TypeMap * |
239 | GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap, const uint16_t * types, | 250 | GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap, |
251 | const uint16_t *types, | ||
240 | unsigned int tcnt) | 252 | unsigned int tcnt) |
241 | { | 253 | { |
242 | struct GSC_TypeMap *ret; | 254 | struct GSC_TypeMap *ret; |