aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-05-03 16:19:17 +0200
committerChristian Grothoff <christian@grothoff.org>2019-05-03 16:19:17 +0200
commitba33155b4f60b8f8049c4f77e3b7b40e29ae63e2 (patch)
treee08efba6a4081c9976f9caa5f149a277c6420298 /src/core
parent782565417337605572b66758bf13d7123e26f744 (diff)
downloadgnunet-ba33155b4f60b8f8049c4f77e3b7b40e29ae63e2.tar.gz
gnunet-ba33155b4f60b8f8049c4f77e3b7b40e29ae63e2.zip
reindentation
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Makefile.am2
-rw-r--r--src/core/gnunet-service-core_typemap.c49
2 files changed, 26 insertions, 25 deletions
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 2723151c5..70ec91fbc 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -58,7 +58,7 @@ gnunet_core_LDADD = \
58 58
59if HAVE_TESTING 59if HAVE_TESTING
60 TESTING_TESTS = \ 60 TESTING_TESTS = \
61 test_core_api_send_to_self 61 test_core_api_send_to_self
62endif 62endif
63 63
64check_PROGRAMS = \ 64check_PROGRAMS = \
diff --git a/src/core/gnunet-service-core_typemap.c b/src/core/gnunet-service-core_typemap.c
index b73267544..9dd3c71c8 100644
--- a/src/core/gnunet-service-core_typemap.c
+++ b/src/core/gnunet-service-core_typemap.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -80,12 +80,9 @@ rehash_typemap ()
80 * @param hc where to store the hash code 80 * @param hc where to store the hash code
81 */ 81 */
82void 82void
83GSC_TYPEMAP_hash (const struct GSC_TypeMap *tm, 83GSC_TYPEMAP_hash (const struct GSC_TypeMap *tm, struct GNUNET_HashCode *hc)
84 struct GNUNET_HashCode *hc)
85{ 84{
86 GNUNET_CRYPTO_hash (tm, 85 GNUNET_CRYPTO_hash (tm, sizeof (struct GSC_TypeMap), hc);
87 sizeof (struct GSC_TypeMap),
88 hc);
89} 86}
90 87
91 88
@@ -100,12 +97,12 @@ GSC_TYPEMAP_check_hash (const struct GNUNET_HashCode *hc)
100{ 97{
101 if (GNUNET_NO == hash_current) 98 if (GNUNET_NO == hash_current)
102 { 99 {
103 GSC_TYPEMAP_hash (&my_type_map, 100 GSC_TYPEMAP_hash (&my_type_map, &my_tm_hash);
104 &my_tm_hash);
105 hash_current = GNUNET_YES; 101 hash_current = GNUNET_YES;
106 } 102 }
107 return (0 == memcmp (hc, &my_tm_hash, sizeof (struct GNUNET_HashCode))) 103 return (0 == memcmp (hc, &my_tm_hash, sizeof (struct GNUNET_HashCode)))
108 ? GNUNET_YES : GNUNET_NO; 104 ? GNUNET_YES
105 : GNUNET_NO;
109} 106}
110 107
111 108
@@ -130,9 +127,12 @@ GSC_TYPEMAP_compute_type_map_message ()
130#endif 127#endif
131 hdr = GNUNET_malloc (dlen + sizeof (struct GNUNET_MessageHeader)); 128 hdr = GNUNET_malloc (dlen + sizeof (struct GNUNET_MessageHeader));
132 tmp = (char *) &hdr[1]; 129 tmp = (char *) &hdr[1];
133 if ((Z_OK != 130 if ((Z_OK != compress2 ((Bytef *) tmp,
134 compress2 ((Bytef *) tmp, &dlen, (const Bytef *) &my_type_map, 131 &dlen,
135 sizeof (my_type_map), 9)) || (dlen >= sizeof (my_type_map))) 132 (const Bytef *) &my_type_map,
133 sizeof (my_type_map),
134 9)) ||
135 (dlen >= sizeof (my_type_map)))
136 { 136 {
137 /* compression failed, use uncompressed map */ 137 /* compression failed, use uncompressed map */
138 dlen = sizeof (my_type_map); 138 dlen = sizeof (my_type_map);
@@ -166,8 +166,10 @@ GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg)
166 switch (ntohs (msg->type)) 166 switch (ntohs (msg->type))
167 { 167 {
168 case GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP: 168 case GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP:
169 GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# type maps received"), 169 GNUNET_STATISTICS_update (GSC_stats,
170 1, GNUNET_NO); 170 gettext_noop ("# type maps received"),
171 1,
172 GNUNET_NO);
171 if (size != sizeof (struct GSC_TypeMap)) 173 if (size != sizeof (struct GSC_TypeMap))
172 { 174 {
173 GNUNET_break_op (0); 175 GNUNET_break_op (0);
@@ -183,9 +185,11 @@ GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg)
183 GNUNET_NO); 185 GNUNET_NO);
184 ret = GNUNET_new (struct GSC_TypeMap); 186 ret = GNUNET_new (struct GSC_TypeMap);
185 dlen = sizeof (struct GSC_TypeMap); 187 dlen = sizeof (struct GSC_TypeMap);
186 if ((Z_OK != 188 if ((Z_OK != uncompress ((Bytef *) ret,
187 uncompress ((Bytef *) ret, &dlen, (const Bytef *) &msg[1], 189 &dlen,
188 (uLong) size)) || (dlen != sizeof (struct GSC_TypeMap))) 190 (const Bytef *) &msg[1],
191 (uLong) size)) ||
192 (dlen != sizeof (struct GSC_TypeMap)))
189 { 193 {
190 GNUNET_break_op (0); 194 GNUNET_break_op (0);
191 GNUNET_free (ret); 195 GNUNET_free (ret);
@@ -224,8 +228,7 @@ broadcast_my_type_map ()
224 * @param tlen number of entries in @a types 228 * @param tlen number of entries in @a types
225 */ 229 */
226void 230void
227GSC_TYPEMAP_add (const uint16_t *types, 231GSC_TYPEMAP_add (const uint16_t *types, unsigned int tlen)
228 unsigned int tlen)
229{ 232{
230 unsigned int i; 233 unsigned int i;
231 int changed; 234 int changed;
@@ -241,8 +244,7 @@ GSC_TYPEMAP_add (const uint16_t *types,
241 } 244 }
242 if (GNUNET_YES == changed) 245 if (GNUNET_YES == changed)
243 { 246 {
244 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 247 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Typemap changed, broadcasting!\n");
245 "Typemap changed, broadcasting!\n");
246 rehash_typemap (); 248 rehash_typemap ();
247 broadcast_my_type_map (); 249 broadcast_my_type_map ();
248 } 250 }
@@ -256,8 +258,7 @@ GSC_TYPEMAP_add (const uint16_t *types,
256 * @param tlen length of the @a types array 258 * @param tlen length of the @a types array
257 */ 259 */
258void 260void
259GSC_TYPEMAP_remove (const uint16_t *types, 261GSC_TYPEMAP_remove (const uint16_t *types, unsigned int tlen)
260 unsigned int tlen)
261{ 262{
262 int changed; 263 int changed;
263 264
@@ -295,7 +296,7 @@ GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap,
295 if (NULL == tmap) 296 if (NULL == tmap)
296 return GNUNET_NO; 297 return GNUNET_NO;
297 if (0 == tcnt) 298 if (0 == tcnt)
298 return GNUNET_YES; /* matches all */ 299 return GNUNET_YES; /* matches all */
299 for (unsigned int i = 0; i < tcnt; i++) 300 for (unsigned int i = 0; i < tcnt; i++)
300 if (0 != (tmap->bits[types[i] / 32] & (1 << (types[i] % 32)))) 301 if (0 != (tmap->bits[types[i] / 32] & (1 << (types[i] % 32))))
301 return GNUNET_YES; 302 return GNUNET_YES;