aboutsummaryrefslogtreecommitdiff
path: root/src/psycutil
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2016-01-26 20:37:11 +0000
committerGabor X Toth <*@tg-x.net>2016-01-26 20:37:11 +0000
commit23f117ce9756b2fb898bba5cb3a1f638333c23d9 (patch)
treee15291bd36f696802fca5c379ad09e3ea3920d76 /src/psycutil
parent0841876fb932574a6c9ebaf2adbb64f1ffc06899 (diff)
downloadgnunet-23f117ce9756b2fb898bba5cb3a1f638333c23d9.tar.gz
gnunet-23f117ce9756b2fb898bba5cb3a1f638333c23d9.zip
social: relay msgs; psyc: slicer api; multicast: reset fragment_offset
Diffstat (limited to 'src/psycutil')
-rw-r--r--src/psycutil/psyc_message.c33
-rw-r--r--src/psycutil/psyc_slicer.c95
2 files changed, 62 insertions, 66 deletions
diff --git a/src/psycutil/psyc_message.c b/src/psycutil/psyc_message.c
index f75a809ef..e16a4e859 100644
--- a/src/psycutil/psyc_message.c
+++ b/src/psycutil/psyc_message.c
@@ -879,11 +879,10 @@ static void
879recv_error (struct GNUNET_PSYC_ReceiveHandle *recv) 879recv_error (struct GNUNET_PSYC_ReceiveHandle *recv)
880{ 880{
881 if (NULL != recv->message_part_cb) 881 if (NULL != recv->message_part_cb)
882 recv->message_part_cb (recv->cb_cls, NULL, recv->message_id, recv->flags, 882 recv->message_part_cb (recv->cb_cls, NULL, NULL);
883 0, NULL);
884 883
885 if (NULL != recv->message_cb) 884 if (NULL != recv->message_cb)
886 recv->message_cb (recv->cb_cls, recv->message_id, recv->flags, NULL); 885 recv->message_cb (recv->cb_cls, NULL);
887 886
888 GNUNET_PSYC_receive_reset (recv); 887 GNUNET_PSYC_receive_reset (recv);
889} 888}
@@ -904,7 +903,6 @@ GNUNET_PSYC_receive_message (struct GNUNET_PSYC_ReceiveHandle *recv,
904{ 903{
905 uint16_t size = ntohs (msg->header.size); 904 uint16_t size = ntohs (msg->header.size);
906 uint32_t flags = ntohl (msg->flags); 905 uint32_t flags = ntohl (msg->flags);
907 uint64_t message_id;
908 906
909 GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, 907 GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG,
910 (struct GNUNET_MessageHeader *) msg); 908 (struct GNUNET_MessageHeader *) msg);
@@ -936,7 +934,6 @@ GNUNET_PSYC_receive_message (struct GNUNET_PSYC_ReceiveHandle *recv,
936 recv_error (recv); 934 recv_error (recv);
937 return GNUNET_SYSERR; 935 return GNUNET_SYSERR;
938 } 936 }
939 message_id = recv->message_id;
940 937
941 uint16_t pos = 0, psize = 0, ptype, size_eq, size_min; 938 uint16_t pos = 0, psize = 0, ptype, size_eq, size_min;
942 939
@@ -1099,10 +1096,7 @@ GNUNET_PSYC_receive_message (struct GNUNET_PSYC_ReceiveHandle *recv,
1099 } 1096 }
1100 1097
1101 if (NULL != recv->message_part_cb) 1098 if (NULL != recv->message_part_cb)
1102 recv->message_part_cb (recv->cb_cls, &recv->slave_pub_key, 1099 recv->message_part_cb (recv->cb_cls, msg, pmsg);
1103 recv->message_id, recv->flags,
1104 GNUNET_ntohll (msg->fragment_offset),
1105 pmsg);
1106 1100
1107 switch (ptype) 1101 switch (ptype)
1108 { 1102 {
@@ -1114,7 +1108,7 @@ GNUNET_PSYC_receive_message (struct GNUNET_PSYC_ReceiveHandle *recv,
1114 } 1108 }
1115 1109
1116 if (NULL != recv->message_cb) 1110 if (NULL != recv->message_cb)
1117 recv->message_cb (recv->cb_cls, message_id, flags, msg); 1111 recv->message_cb (recv->cb_cls, msg);
1118 return GNUNET_OK; 1112 return GNUNET_OK;
1119} 1113}
1120 1114
@@ -1180,23 +1174,22 @@ struct ParseMessageClosure
1180 1174
1181static void 1175static void
1182parse_message_part_cb (void *cls, 1176parse_message_part_cb (void *cls,
1183 const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key, 1177 const struct GNUNET_PSYC_MessageHeader *msg,
1184 uint64_t message_id, uint32_t flags, uint64_t fragment_offset, 1178 const struct GNUNET_MessageHeader *pmsg)
1185 const struct GNUNET_MessageHeader *msg)
1186{ 1179{
1187 struct ParseMessageClosure *pmc = cls; 1180 struct ParseMessageClosure *pmc = cls;
1188 if (NULL == msg) 1181 if (NULL == pmsg)
1189 { 1182 {
1190 pmc->msg_state = GNUNET_PSYC_MESSAGE_STATE_ERROR; 1183 pmc->msg_state = GNUNET_PSYC_MESSAGE_STATE_ERROR;
1191 return; 1184 return;
1192 } 1185 }
1193 1186
1194 switch (ntohs (msg->type)) 1187 switch (ntohs (pmsg->type))
1195 { 1188 {
1196 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD: 1189 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD:
1197 { 1190 {
1198 struct GNUNET_PSYC_MessageMethod * 1191 struct GNUNET_PSYC_MessageMethod *
1199 pmeth = (struct GNUNET_PSYC_MessageMethod *) msg; 1192 pmeth = (struct GNUNET_PSYC_MessageMethod *) pmsg;
1200 *pmc->method_name = (const char *) &pmeth[1]; 1193 *pmc->method_name = (const char *) &pmeth[1];
1201 pmc->msg_state = GNUNET_PSYC_MESSAGE_STATE_METHOD; 1194 pmc->msg_state = GNUNET_PSYC_MESSAGE_STATE_METHOD;
1202 break; 1195 break;
@@ -1205,7 +1198,7 @@ parse_message_part_cb (void *cls,
1205 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER: 1198 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER:
1206 { 1199 {
1207 struct GNUNET_PSYC_MessageModifier * 1200 struct GNUNET_PSYC_MessageModifier *
1208 pmod = (struct GNUNET_PSYC_MessageModifier *) msg; 1201 pmod = (struct GNUNET_PSYC_MessageModifier *) pmsg;
1209 1202
1210 const char *name = (const char *) &pmod[1]; 1203 const char *name = (const char *) &pmod[1];
1211 const void *value = name + ntohs (pmod->name_size); 1204 const void *value = name + ntohs (pmod->name_size);
@@ -1216,8 +1209,8 @@ parse_message_part_cb (void *cls,
1216 } 1209 }
1217 1210
1218 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA: 1211 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA:
1219 *pmc->data = &msg[1]; 1212 *pmc->data = &pmsg[1];
1220 *pmc->data_size = ntohs (msg->size) - sizeof (*msg); 1213 *pmc->data_size = ntohs (pmsg->size) - sizeof (*pmsg);
1221 pmc->msg_state = GNUNET_PSYC_MESSAGE_STATE_DATA; 1214 pmc->msg_state = GNUNET_PSYC_MESSAGE_STATE_DATA;
1222 break; 1215 break;
1223 1216
@@ -1241,7 +1234,7 @@ parse_message_part_cb (void *cls,
1241 * @param env 1234 * @param env
1242 * The environment for the message with a list of modifiers. 1235 * The environment for the message with a list of modifiers.
1243 * @param[out] data 1236 * @param[out] data
1244 * Pointer to data inside @a pmsg. 1237 * Pointer to data inside @a msg.
1245 * @param[out] data_size 1238 * @param[out] data_size
1246 * Size of @data is written here. 1239 * Size of @data is written here.
1247 * 1240 *
diff --git a/src/psycutil/psyc_slicer.c b/src/psycutil/psyc_slicer.c
index 735eb1511..a9c96ff04 100644
--- a/src/psycutil/psyc_slicer.c
+++ b/src/psycutil/psyc_slicer.c
@@ -55,9 +55,14 @@ struct GNUNET_PSYC_Slicer
55 struct GNUNET_PSYC_ReceiveHandle *recv; 55 struct GNUNET_PSYC_ReceiveHandle *recv;
56 56
57 /** 57 /**
58 * Currently being processed message.
59 */
60 const struct GNUNET_PSYC_MessageHeader *msg;
61
62 /**
58 * Currently being processed message part. 63 * Currently being processed message part.
59 */ 64 */
60 const struct GNUNET_MessageHeader *msg; 65 const struct GNUNET_MessageHeader *pmsg;
61 66
62 /** 67 /**
63 * ID of currently being received message. 68 * ID of currently being received message.
@@ -131,6 +136,7 @@ struct GNUNET_PSYC_Slicer
131 */ 136 */
132struct SlicerMethodCallbacks 137struct SlicerMethodCallbacks
133{ 138{
139 GNUNET_PSYC_MessageCallback msg_cb;
134 GNUNET_PSYC_MethodCallback method_cb; 140 GNUNET_PSYC_MethodCallback method_cb;
135 GNUNET_PSYC_ModifierCallback modifier_cb; 141 GNUNET_PSYC_ModifierCallback modifier_cb;
136 GNUNET_PSYC_DataCallback data_cb; 142 GNUNET_PSYC_DataCallback data_cb;
@@ -171,22 +177,21 @@ slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key,
171 void *value) 177 void *value)
172{ 178{
173 struct GNUNET_PSYC_Slicer *slicer = cls; 179 struct GNUNET_PSYC_Slicer *slicer = cls;
174 const struct GNUNET_MessageHeader *msg = slicer->msg; 180 const struct GNUNET_MessageHeader *pmsg = slicer->pmsg;
175 struct SlicerMethodCallbacks *cbs = value; 181 struct SlicerMethodCallbacks *cbs = value;
176 uint16_t ptype = ntohs (msg->type);
177 182
183 uint16_t ptype = ntohs (pmsg->type);
178 switch (ptype) 184 switch (ptype)
179 { 185 {
180 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD: 186 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD:
181 { 187 {
188 if (NULL != cbs->msg_cb)
189 cbs->msg_cb (cbs->cls, slicer->msg);
182 if (NULL == cbs->method_cb) 190 if (NULL == cbs->method_cb)
183 break; 191 break;
184 struct GNUNET_PSYC_MessageMethod * 192 struct GNUNET_PSYC_MessageMethod *
185 meth = (struct GNUNET_PSYC_MessageMethod *) msg; 193 meth = (struct GNUNET_PSYC_MessageMethod *) pmsg;
186 cbs->method_cb (cbs->cls, meth, slicer->message_id, 194 cbs->method_cb (cbs->cls, slicer->msg, meth, slicer->message_id,
187 slicer->flags, slicer->fragment_offset,
188 ntohl (meth->flags),
189 &slicer->nym_pub_key,
190 slicer->method_name); 195 slicer->method_name);
191 break; 196 break;
192 } 197 }
@@ -196,9 +201,8 @@ slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key,
196 if (NULL == cbs->modifier_cb) 201 if (NULL == cbs->modifier_cb)
197 break; 202 break;
198 struct GNUNET_PSYC_MessageModifier * 203 struct GNUNET_PSYC_MessageModifier *
199 mod = (struct GNUNET_PSYC_MessageModifier *) msg; 204 mod = (struct GNUNET_PSYC_MessageModifier *) pmsg;
200 cbs->modifier_cb (cbs->cls, &mod->header, slicer->message_id, 205 cbs->modifier_cb (cbs->cls, slicer->msg, &mod->header, slicer->message_id,
201 slicer->flags, slicer->fragment_offset,
202 mod->oper, (const char *) &mod[1], 206 mod->oper, (const char *) &mod[1],
203 (const void *) &mod[1] + ntohs (mod->name_size), 207 (const void *) &mod[1] + ntohs (mod->name_size),
204 ntohs (mod->header.size) - sizeof (*mod) - ntohs (mod->name_size), 208 ntohs (mod->header.size) - sizeof (*mod) - ntohs (mod->name_size),
@@ -210,10 +214,9 @@ slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key,
210 { 214 {
211 if (NULL == cbs->modifier_cb) 215 if (NULL == cbs->modifier_cb)
212 break; 216 break;
213 cbs->modifier_cb (cbs->cls, msg, slicer->message_id, 217 cbs->modifier_cb (cbs->cls, slicer->msg, pmsg, slicer->message_id,
214 slicer->flags, slicer->fragment_offset, 218 slicer->mod_oper, slicer->mod_name, &pmsg[1],
215 slicer->mod_oper, slicer->mod_name, &msg[1], 219 ntohs (pmsg->size) - sizeof (*pmsg),
216 ntohs (msg->size) - sizeof (*msg),
217 slicer->mod_full_value_size); 220 slicer->mod_full_value_size);
218 break; 221 break;
219 } 222 }
@@ -222,24 +225,21 @@ slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key,
222 { 225 {
223 if (NULL == cbs->data_cb) 226 if (NULL == cbs->data_cb)
224 break; 227 break;
225 cbs->data_cb (cbs->cls, msg, slicer->message_id, 228 cbs->data_cb (cbs->cls, slicer->msg, pmsg, slicer->message_id,
226 slicer->flags, slicer->fragment_offset, 229 &pmsg[1], ntohs (pmsg->size) - sizeof (*pmsg));
227 &msg[1], ntohs (msg->size) - sizeof (*msg));
228 break; 230 break;
229 } 231 }
230 232
231 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END: 233 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END:
232 if (NULL == cbs->eom_cb) 234 if (NULL == cbs->eom_cb)
233 break; 235 break;
234 cbs->eom_cb (cbs->cls, msg, slicer->message_id, 236 cbs->eom_cb (cbs->cls, slicer->msg, pmsg, slicer->message_id, GNUNET_NO);
235 slicer->flags, slicer->fragment_offset, GNUNET_NO);
236 break; 237 break;
237 238
238 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL: 239 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
239 if (NULL == cbs->eom_cb) 240 if (NULL == cbs->eom_cb)
240 break; 241 break;
241 cbs->eom_cb (cbs->cls, msg, slicer->message_id, 242 cbs->eom_cb (cbs->cls, slicer->msg, pmsg, slicer->message_id, GNUNET_YES);
242 slicer->flags, slicer->fragment_offset, GNUNET_YES);
243 break; 243 break;
244 } 244 }
245 return GNUNET_YES; 245 return GNUNET_YES;
@@ -256,8 +256,7 @@ slicer_modifier_handler_notify (void *cls, const struct GNUNET_HashCode *key,
256 struct GNUNET_PSYC_Slicer *slicer = cls; 256 struct GNUNET_PSYC_Slicer *slicer = cls;
257 struct SlicerModifierCallbacks *cbs = value; 257 struct SlicerModifierCallbacks *cbs = value;
258 258
259 cbs->modifier_cb (cbs->cls, slicer->msg, 259 cbs->modifier_cb (cbs->cls, slicer->msg, slicer->pmsg, slicer->message_id,
260 slicer->message_id, slicer->flags, slicer->fragment_offset,
261 slicer->mod_oper, slicer->mod_name, slicer->mod_value, 260 slicer->mod_oper, slicer->mod_name, slicer->mod_value,
262 slicer->mod_value_size, slicer->mod_full_value_size); 261 slicer->mod_value_size, slicer->mod_full_value_size);
263 return GNUNET_YES; 262 return GNUNET_YES;
@@ -295,40 +294,36 @@ GNUNET_PSYC_slicer_message (struct GNUNET_PSYC_Slicer *slicer,
295 */ 294 */
296void 295void
297GNUNET_PSYC_slicer_message_part (struct GNUNET_PSYC_Slicer *slicer, 296GNUNET_PSYC_slicer_message_part (struct GNUNET_PSYC_Slicer *slicer,
298 const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key, 297 const struct GNUNET_PSYC_MessageHeader *msg,
299 uint64_t message_id, 298 const struct GNUNET_MessageHeader *pmsg)
300 uint32_t flags,
301 uint64_t fragment_offset,
302 const struct GNUNET_MessageHeader *msg)
303{ 299{
304 slicer->nym_pub_key = *slave_pub_key; 300 slicer->msg = msg;
301 slicer->pmsg = pmsg;
305 302
306 uint16_t ptype = ntohs (msg->type); 303 uint64_t message_id = GNUNET_ntohll (msg->message_id);
304
305 uint16_t ptype = ntohs (pmsg->type);
307 if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD == ptype) 306 if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD == ptype)
308 { 307 {
309 struct GNUNET_PSYC_MessageMethod * 308 struct GNUNET_PSYC_MessageMethod *
310 meth = (struct GNUNET_PSYC_MessageMethod *) msg; 309 meth = (struct GNUNET_PSYC_MessageMethod *) pmsg;
311 slicer->method_name_size = ntohs (meth->header.size) - sizeof (*meth); 310 slicer->method_name_size = ntohs (meth->header.size) - sizeof (*meth);
312 slicer->method_name = GNUNET_malloc (slicer->method_name_size); 311 slicer->method_name = GNUNET_malloc (slicer->method_name_size);
313 memcpy (slicer->method_name, &meth[1], slicer->method_name_size); 312 memcpy (slicer->method_name, &meth[1], slicer->method_name_size);
314 slicer->message_id = message_id; 313 slicer->message_id = message_id;
315 slicer->flags = flags;
316 slicer->fragment_offset = fragment_offset;
317 } 314 }
318 else 315 else
319 { 316 {
320 GNUNET_assert (message_id == slicer->message_id); 317 GNUNET_assert (message_id == slicer->message_id);
321 } 318 }
322 319
323 char *nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (slave_pub_key); 320 char *nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&msg->slave_pub_key);
324 LOG (GNUNET_ERROR_TYPE_DEBUG, 321 LOG (GNUNET_ERROR_TYPE_DEBUG,
325 "Slicer received message of type %u and size %u, " 322 "Slicer received message of type %u and size %u, "
326 "with ID %" PRIu64 " and method %s from %s\n", 323 "with ID %" PRIu64 " and method %s from %s\n",
327 ptype, ntohs (msg->size), message_id, slicer->method_name, nym_str); 324 ptype, ntohs (pmsg->size), message_id, slicer->method_name, nym_str);
328 GNUNET_free (nym_str); 325 GNUNET_free (nym_str);
329 326
330 slicer->msg = msg;
331
332 /* try-and-slice modifier */ 327 /* try-and-slice modifier */
333 328
334 switch (ptype) 329 switch (ptype)
@@ -336,7 +331,7 @@ GNUNET_PSYC_slicer_message_part (struct GNUNET_PSYC_Slicer *slicer,
336 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER: 331 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER:
337 { 332 {
338 struct GNUNET_PSYC_MessageModifier * 333 struct GNUNET_PSYC_MessageModifier *
339 mod = (struct GNUNET_PSYC_MessageModifier *) msg; 334 mod = (struct GNUNET_PSYC_MessageModifier *) pmsg;
340 slicer->mod_oper = mod->oper; 335 slicer->mod_oper = mod->oper;
341 slicer->mod_name_size = ntohs (mod->name_size); 336 slicer->mod_name_size = ntohs (mod->name_size);
342 slicer->mod_name = GNUNET_malloc (slicer->mod_name_size); 337 slicer->mod_name = GNUNET_malloc (slicer->mod_name_size);
@@ -350,8 +345,8 @@ GNUNET_PSYC_slicer_message_part (struct GNUNET_PSYC_Slicer *slicer,
350 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT: 345 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT:
351 if (ptype == GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT) 346 if (ptype == GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT)
352 { 347 {
353 slicer->mod_value = (char *) &msg[1]; 348 slicer->mod_value = (char *) &pmsg[1];
354 slicer->mod_value_size = ntohs (msg->size) - sizeof (*msg); 349 slicer->mod_value_size = ntohs (pmsg->size) - sizeof (*pmsg);
355 } 350 }
356 slicer->mod_value_remaining -= slicer->mod_value_size; 351 slicer->mod_value_remaining -= slicer->mod_value_size;
357 char *name = GNUNET_malloc (slicer->mod_name_size); 352 char *name = GNUNET_malloc (slicer->mod_name_size);
@@ -405,6 +400,7 @@ GNUNET_PSYC_slicer_message_part (struct GNUNET_PSYC_Slicer *slicer,
405 } 400 }
406 401
407 slicer->msg = NULL; 402 slicer->msg = NULL;
403 slicer->pmsg = NULL;
408} 404}
409 405
410 406
@@ -454,6 +450,7 @@ GNUNET_PSYC_slicer_create (void)
454void 450void
455GNUNET_PSYC_slicer_method_add (struct GNUNET_PSYC_Slicer *slicer, 451GNUNET_PSYC_slicer_method_add (struct GNUNET_PSYC_Slicer *slicer,
456 const char *method_name, 452 const char *method_name,
453 GNUNET_PSYC_MessageCallback msg_cb,
457 GNUNET_PSYC_MethodCallback method_cb, 454 GNUNET_PSYC_MethodCallback method_cb,
458 GNUNET_PSYC_ModifierCallback modifier_cb, 455 GNUNET_PSYC_ModifierCallback modifier_cb,
459 GNUNET_PSYC_DataCallback data_cb, 456 GNUNET_PSYC_DataCallback data_cb,
@@ -464,6 +461,7 @@ GNUNET_PSYC_slicer_method_add (struct GNUNET_PSYC_Slicer *slicer,
464 GNUNET_CRYPTO_hash (method_name, strlen (method_name), &key); 461 GNUNET_CRYPTO_hash (method_name, strlen (method_name), &key);
465 462
466 struct SlicerMethodCallbacks *cbs = GNUNET_malloc (sizeof (*cbs)); 463 struct SlicerMethodCallbacks *cbs = GNUNET_malloc (sizeof (*cbs));
464 cbs->msg_cb = msg_cb,
467 cbs->method_cb = method_cb; 465 cbs->method_cb = method_cb;
468 cbs->modifier_cb = modifier_cb; 466 cbs->modifier_cb = modifier_cb;
469 cbs->data_cb = data_cb; 467 cbs->data_cb = data_cb;
@@ -483,10 +481,11 @@ slicer_method_remove (void *cls, const struct GNUNET_HashCode *key, void *value)
483 struct SlicerMethodCallbacks *rm_cbs = &rm_cls->rm_cbs; 481 struct SlicerMethodCallbacks *rm_cbs = &rm_cls->rm_cbs;
484 struct SlicerMethodCallbacks *cbs = value; 482 struct SlicerMethodCallbacks *cbs = value;
485 483
486 if (cbs->method_cb == rm_cbs->method_cb 484 if ((NULL == rm_cbs->msg_cb || cbs->msg_cb == rm_cbs->msg_cb)
487 && cbs->modifier_cb == rm_cbs->modifier_cb 485 && (NULL == rm_cbs->method_cb || cbs->method_cb == rm_cbs->method_cb)
488 && cbs->data_cb == rm_cbs->data_cb 486 && (NULL == rm_cbs->modifier_cb || cbs->modifier_cb == rm_cbs->modifier_cb)
489 && cbs->eom_cb == rm_cbs->eom_cb) 487 && (NULL == rm_cbs->data_cb || cbs->data_cb == rm_cbs->data_cb)
488 && (NULL == rm_cbs->eom_cb || cbs->eom_cb == rm_cbs->eom_cb))
490 { 489 {
491 GNUNET_CONTAINER_multihashmap_remove (slicer->method_handlers, key, cbs); 490 GNUNET_CONTAINER_multihashmap_remove (slicer->method_handlers, key, cbs);
492 GNUNET_free (cbs); 491 GNUNET_free (cbs);
@@ -521,6 +520,7 @@ slicer_method_remove (void *cls, const struct GNUNET_HashCode *key, void *value)
521int 520int
522GNUNET_PSYC_slicer_method_remove (struct GNUNET_PSYC_Slicer *slicer, 521GNUNET_PSYC_slicer_method_remove (struct GNUNET_PSYC_Slicer *slicer,
523 const char *method_name, 522 const char *method_name,
523 GNUNET_PSYC_MessageCallback msg_cb,
524 GNUNET_PSYC_MethodCallback method_cb, 524 GNUNET_PSYC_MethodCallback method_cb,
525 GNUNET_PSYC_ModifierCallback modifier_cb, 525 GNUNET_PSYC_ModifierCallback modifier_cb,
526 GNUNET_PSYC_DataCallback data_cb, 526 GNUNET_PSYC_DataCallback data_cb,
@@ -532,6 +532,7 @@ GNUNET_PSYC_slicer_method_remove (struct GNUNET_PSYC_Slicer *slicer,
532 struct SlicerMethodRemoveClosure rm_cls; 532 struct SlicerMethodRemoveClosure rm_cls;
533 rm_cls.slicer = slicer; 533 rm_cls.slicer = slicer;
534 struct SlicerMethodCallbacks *rm_cbs = &rm_cls.rm_cbs; 534 struct SlicerMethodCallbacks *rm_cbs = &rm_cls.rm_cbs;
535 rm_cbs->msg_cb = msg_cb;
535 rm_cbs->method_cb = method_cb; 536 rm_cbs->method_cb = method_cb;
536 rm_cbs->modifier_cb = modifier_cb; 537 rm_cbs->modifier_cb = modifier_cb;
537 rm_cbs->data_cb = data_cb; 538 rm_cbs->data_cb = data_cb;
@@ -659,6 +660,7 @@ GNUNET_PSYC_slicer_method_clear (struct GNUNET_PSYC_Slicer *slicer)
659{ 660{
660 GNUNET_CONTAINER_multihashmap_iterate (slicer->method_handlers, 661 GNUNET_CONTAINER_multihashmap_iterate (slicer->method_handlers,
661 slicer_method_free, NULL); 662 slicer_method_free, NULL);
663 GNUNET_CONTAINER_multihashmap_clear (slicer->method_handlers);
662} 664}
663 665
664 666
@@ -673,6 +675,7 @@ GNUNET_PSYC_slicer_modifier_clear (struct GNUNET_PSYC_Slicer *slicer)
673{ 675{
674 GNUNET_CONTAINER_multihashmap_iterate (slicer->modifier_handlers, 676 GNUNET_CONTAINER_multihashmap_iterate (slicer->modifier_handlers,
675 slicer_modifier_free, NULL); 677 slicer_modifier_free, NULL);
678 GNUNET_CONTAINER_multihashmap_clear (slicer->modifier_handlers);
676} 679}
677 680
678 681