diff options
-rw-r--r-- | src/include/gnunet_applications.h | 5 | ||||
-rw-r--r-- | src/include/gnunet_signatures.h | 2 | ||||
-rw-r--r-- | src/multicast/Makefile.am | 2 | ||||
-rw-r--r-- | src/multicast/gnunet-service-multicast.c | 727 | ||||
-rw-r--r-- | src/multicast/multicast.h | 6 | ||||
-rw-r--r-- | src/multicast/multicast_api.c | 4 | ||||
-rw-r--r-- | src/multicast/test_multicast.conf | 2 | ||||
-rw-r--r-- | src/psyc/gnunet-service-psyc.c | 10 | ||||
-rw-r--r-- | src/psyc/test_psyc.conf | 2 | ||||
-rw-r--r-- | src/social/gnunet-service-social.c | 2 | ||||
-rw-r--r-- | src/social/test_social.conf | 2 |
11 files changed, 656 insertions, 108 deletions
diff --git a/src/include/gnunet_applications.h b/src/include/gnunet_applications.h index 45835ef84..5d93d0500 100644 --- a/src/include/gnunet_applications.h +++ b/src/include/gnunet_applications.h | |||
@@ -111,6 +111,11 @@ extern "C" | |||
111 | */ | 111 | */ |
112 | #define GNUNET_APPLICATION_TYPE_SENSORUPDATE 25 | 112 | #define GNUNET_APPLICATION_TYPE_SENSORUPDATE 25 |
113 | 113 | ||
114 | /** | ||
115 | * Multicast data. | ||
116 | */ | ||
117 | #define GNUNET_APPLICATION_TYPE_MULTICAST 26 | ||
118 | |||
114 | 119 | ||
115 | #if 0 /* keep Emacsens' auto-indent happy */ | 120 | #if 0 /* keep Emacsens' auto-indent happy */ |
116 | { | 121 | { |
diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h index d875aeb6b..a2a41a256 100644 --- a/src/include/gnunet_signatures.h +++ b/src/include/gnunet_signatures.h | |||
@@ -149,7 +149,7 @@ extern "C" | |||
149 | /** | 149 | /** |
150 | * Key exchange in CADET | 150 | * Key exchange in CADET |
151 | */ | 151 | */ |
152 | #define GNUNET_SIGNATURE_PURPOSE_CADET_KX 21 | 152 | #define GNUNET_SIGNATURE_PURPOSE_CADET_KX 21 |
153 | 153 | ||
154 | /** | 154 | /** |
155 | * Signature for the first round of distributed key generation. | 155 | * Signature for the first round of distributed key generation. |
diff --git a/src/multicast/Makefile.am b/src/multicast/Makefile.am index 8d4813e54..b6ae92f0f 100644 --- a/src/multicast/Makefile.am +++ b/src/multicast/Makefile.am | |||
@@ -47,11 +47,13 @@ gnunet_service_multicast_SOURCES = \ | |||
47 | gnunet_service_multicast_LDADD = \ | 47 | gnunet_service_multicast_LDADD = \ |
48 | $(top_builddir)/src/util/libgnunetutil.la \ | 48 | $(top_builddir)/src/util/libgnunetutil.la \ |
49 | $(top_builddir)/src/core/libgnunetcore.la \ | 49 | $(top_builddir)/src/core/libgnunetcore.la \ |
50 | $(top_builddir)/src/cadet/libgnunetcadet.la \ | ||
50 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 51 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
51 | $(GN_LIBINTL) | 52 | $(GN_LIBINTL) |
52 | gnunet_service_multicast_DEPENDENCIES = \ | 53 | gnunet_service_multicast_DEPENDENCIES = \ |
53 | $(top_builddir)/src/util/libgnunetutil.la \ | 54 | $(top_builddir)/src/util/libgnunetutil.la \ |
54 | $(top_builddir)/src/core/libgnunetcore.la \ | 55 | $(top_builddir)/src/core/libgnunetcore.la \ |
56 | $(top_builddir)/src/cadet/libgnunetcadet.la \ | ||
55 | $(top_builddir)/src/statistics/libgnunetstatistics.la | 57 | $(top_builddir)/src/statistics/libgnunetstatistics.la |
56 | 58 | ||
57 | 59 | ||
diff --git a/src/multicast/gnunet-service-multicast.c b/src/multicast/gnunet-service-multicast.c index 1b8e5c8b6..4072c7066 100644 --- a/src/multicast/gnunet-service-multicast.c +++ b/src/multicast/gnunet-service-multicast.c | |||
@@ -26,8 +26,10 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_signatures.h" | 28 | #include "gnunet_signatures.h" |
29 | #include "gnunet_applications.h" | ||
29 | #include "gnunet_statistics_service.h" | 30 | #include "gnunet_statistics_service.h" |
30 | #include "gnunet_core_service.h" | 31 | #include "gnunet_core_service.h" |
32 | #include "gnunet_cadet_service.h" | ||
31 | #include "gnunet_multicast_service.h" | 33 | #include "gnunet_multicast_service.h" |
32 | #include "multicast.h" | 34 | #include "multicast.h" |
33 | 35 | ||
@@ -48,6 +50,11 @@ static struct GNUNET_SERVER_Handle *server; | |||
48 | static struct GNUNET_CORE_Handle *core; | 50 | static struct GNUNET_CORE_Handle *core; |
49 | 51 | ||
50 | /** | 52 | /** |
53 | * CADET handle. | ||
54 | */ | ||
55 | static struct GNUNET_CADET_Handle *cadet; | ||
56 | |||
57 | /** | ||
51 | * Identity of this peer. | 58 | * Identity of this peer. |
52 | */ | 59 | */ |
53 | static struct GNUNET_PeerIdentity this_peer; | 60 | static struct GNUNET_PeerIdentity this_peer; |
@@ -56,6 +63,7 @@ static struct GNUNET_PeerIdentity this_peer; | |||
56 | * Handle to the statistics service. | 63 | * Handle to the statistics service. |
57 | */ | 64 | */ |
58 | static struct GNUNET_STATISTICS_Handle *stats; | 65 | static struct GNUNET_STATISTICS_Handle *stats; |
66 | |||
59 | /** | 67 | /** |
60 | * Notification context, simplifies client broadcasts. | 68 | * Notification context, simplifies client broadcasts. |
61 | */ | 69 | */ |
@@ -63,23 +71,109 @@ static struct GNUNET_SERVER_NotificationContext *nc; | |||
63 | 71 | ||
64 | /** | 72 | /** |
65 | * All connected origins. | 73 | * All connected origins. |
66 | * Group's pub_key_hash -> struct Origin | 74 | * Group's pub_key_hash -> struct Origin * (uniq) |
67 | */ | 75 | */ |
68 | static struct GNUNET_CONTAINER_MultiHashMap *origins; | 76 | static struct GNUNET_CONTAINER_MultiHashMap *origins; |
69 | 77 | ||
70 | /** | 78 | /** |
71 | * All connected members. | 79 | * All connected members. |
72 | * Group's pub_key_hash -> struct Member | 80 | * Group's pub_key_hash -> struct Member * (multi) |
73 | */ | 81 | */ |
74 | static struct GNUNET_CONTAINER_MultiHashMap *members; | 82 | static struct GNUNET_CONTAINER_MultiHashMap *members; |
75 | 83 | ||
76 | /** | 84 | /** |
77 | * Connected members per group. | 85 | * Connected members per group. |
78 | * Group's pub_key_hash -> Member's pub_key -> struct Member | 86 | * Group's pub_key_hash -> Member's pub_key_hash (uniq) -> struct Member * (uniq) |
79 | */ | 87 | */ |
80 | static struct GNUNET_CONTAINER_MultiHashMap *group_members; | 88 | static struct GNUNET_CONTAINER_MultiHashMap *group_members; |
81 | 89 | ||
82 | /** | 90 | /** |
91 | * Incoming CADET channels. | ||
92 | * Group's pub_key_hash -> struct Channel * (multi) | ||
93 | */ | ||
94 | static struct GNUNET_CONTAINER_MultiHashMap *channels_in; | ||
95 | |||
96 | /** | ||
97 | * Outgoing CADET channels. | ||
98 | * Group's pub_key_hash -> struct Channel * (multi) | ||
99 | */ | ||
100 | static struct GNUNET_CONTAINER_MultiHashMap *channels_out; | ||
101 | |||
102 | /** | ||
103 | * Join status of a remote peer. | ||
104 | */ | ||
105 | enum JoinStatus | ||
106 | { | ||
107 | JOIN_REFUSED = -1, | ||
108 | JOIN_NOT_ASKED = 0, | ||
109 | JOIN_WAITING = 1, | ||
110 | JOIN_ADMITTED = 2, | ||
111 | }; | ||
112 | |||
113 | enum ChannelDirection | ||
114 | { | ||
115 | DIR_INCOMING = 0, | ||
116 | DIR_OUTGOING = 1, | ||
117 | }; | ||
118 | |||
119 | |||
120 | /** | ||
121 | * Context for a CADET channel. | ||
122 | */ | ||
123 | struct Channel | ||
124 | { | ||
125 | /** | ||
126 | * Group the channel belongs to. | ||
127 | * | ||
128 | * Only set for outgoing channels. | ||
129 | */ | ||
130 | struct Group *grp; | ||
131 | |||
132 | /** | ||
133 | * CADET channel. | ||
134 | */ | ||
135 | struct GNUNET_CADET_Channel *channel; | ||
136 | |||
137 | /** | ||
138 | * CADET transmission handle. | ||
139 | */ | ||
140 | struct GNUNET_CADET_TransmitHandle *tmit_handle; | ||
141 | |||
142 | /** | ||
143 | * Public key of the target group. | ||
144 | */ | ||
145 | struct GNUNET_CRYPTO_EddsaPublicKey group_key; | ||
146 | |||
147 | /** | ||
148 | * Hash of @a group_key. | ||
149 | */ | ||
150 | struct GNUNET_HashCode group_key_hash; | ||
151 | |||
152 | /** | ||
153 | * Public key of the joining member. | ||
154 | */ | ||
155 | struct GNUNET_CRYPTO_EcdsaPublicKey member_key; | ||
156 | |||
157 | /** | ||
158 | * Remote peer identity. | ||
159 | */ | ||
160 | struct GNUNET_PeerIdentity peer; | ||
161 | |||
162 | /** | ||
163 | * Is the remote peer admitted to the group? | ||
164 | * @see enum JoinStatus | ||
165 | */ | ||
166 | int8_t join_status; | ||
167 | |||
168 | /** | ||
169 | * Channel direction. | ||
170 | * @see enum ChannelDirection | ||
171 | */ | ||
172 | uint8_t direction; | ||
173 | }; | ||
174 | |||
175 | |||
176 | /** | ||
83 | * List of connected clients. | 177 | * List of connected clients. |
84 | */ | 178 | */ |
85 | struct ClientList | 179 | struct ClientList |
@@ -174,9 +268,29 @@ struct Member | |||
174 | struct MulticastJoinDecisionMessageHeader *join_dcsn; | 268 | struct MulticastJoinDecisionMessageHeader *join_dcsn; |
175 | 269 | ||
176 | /** | 270 | /** |
271 | * CADET channel to the origin. | ||
272 | */ | ||
273 | struct Channel *origin_channel; | ||
274 | |||
275 | /** | ||
276 | * Peer identity of origin. | ||
277 | */ | ||
278 | struct GNUNET_PeerIdentity origin; | ||
279 | |||
280 | /** | ||
281 | * Peer identity of relays (other members to connect). | ||
282 | */ | ||
283 | struct GNUNET_PeerIdentity *relays; | ||
284 | |||
285 | /** | ||
177 | * Last request fragment ID sent to the origin. | 286 | * Last request fragment ID sent to the origin. |
178 | */ | 287 | */ |
179 | uint64_t max_fragment_id; | 288 | uint64_t max_fragment_id; |
289 | |||
290 | /** | ||
291 | * Number of @a relays. | ||
292 | */ | ||
293 | uint32_t relay_count; | ||
180 | }; | 294 | }; |
181 | 295 | ||
182 | 296 | ||
@@ -194,6 +308,11 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
194 | GNUNET_CORE_disconnect (core); | 308 | GNUNET_CORE_disconnect (core); |
195 | core = NULL; | 309 | core = NULL; |
196 | } | 310 | } |
311 | if (NULL != cadet) | ||
312 | { | ||
313 | GNUNET_CADET_disconnect (cadet); | ||
314 | cadet = NULL; | ||
315 | } | ||
197 | if (NULL != stats) | 316 | if (NULL != stats) |
198 | { | 317 | { |
199 | GNUNET_STATISTICS_destroy (stats, GNUNET_YES); | 318 | GNUNET_STATISTICS_destroy (stats, GNUNET_YES); |
@@ -202,6 +321,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
202 | /* FIXME: do more clean up here */ | 321 | /* FIXME: do more clean up here */ |
203 | } | 322 | } |
204 | 323 | ||
324 | |||
205 | /** | 325 | /** |
206 | * Clean up origin data structures after a client disconnected. | 326 | * Clean up origin data structures after a client disconnected. |
207 | */ | 327 | */ |
@@ -264,7 +384,7 @@ cleanup_group (struct Group *grp) | |||
264 | * @param client Client handle. | 384 | * @param client Client handle. |
265 | */ | 385 | */ |
266 | static void | 386 | static void |
267 | client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | 387 | client_notify_disconnect (void *cls, struct GNUNET_SERVER_Client *client) |
268 | { | 388 | { |
269 | if (NULL == client) | 389 | if (NULL == client) |
270 | return; | 390 | return; |
@@ -317,8 +437,8 @@ client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
317 | * Send message to all clients connected to the group. | 437 | * Send message to all clients connected to the group. |
318 | */ | 438 | */ |
319 | static void | 439 | static void |
320 | message_to_clients (const struct Group *grp, | 440 | client_send (const struct Group *grp, |
321 | const struct GNUNET_MessageHeader *msg) | 441 | const struct GNUNET_MessageHeader *msg) |
322 | { | 442 | { |
323 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 443 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
324 | "%p Sending message to clients.\n", grp); | 444 | "%p Sending message to clients.\n", grp); |
@@ -337,13 +457,13 @@ message_to_clients (const struct Group *grp, | |||
337 | * Iterator callback for sending a message to origin clients. | 457 | * Iterator callback for sending a message to origin clients. |
338 | */ | 458 | */ |
339 | static int | 459 | static int |
340 | origin_message_cb (void *cls, const struct GNUNET_HashCode *pub_key_hash, | 460 | client_send_origin_cb (void *cls, const struct GNUNET_HashCode *pub_key_hash, |
341 | void *origin) | 461 | void *origin) |
342 | { | 462 | { |
343 | const struct GNUNET_MessageHeader *msg = cls; | 463 | const struct GNUNET_MessageHeader *msg = cls; |
344 | struct Member *orig = origin; | 464 | struct Member *orig = origin; |
345 | 465 | ||
346 | message_to_clients (&orig->grp, msg); | 466 | client_send (&orig->grp, msg); |
347 | return GNUNET_YES; | 467 | return GNUNET_YES; |
348 | } | 468 | } |
349 | 469 | ||
@@ -352,15 +472,15 @@ origin_message_cb (void *cls, const struct GNUNET_HashCode *pub_key_hash, | |||
352 | * Iterator callback for sending a message to member clients. | 472 | * Iterator callback for sending a message to member clients. |
353 | */ | 473 | */ |
354 | static int | 474 | static int |
355 | member_message_cb (void *cls, const struct GNUNET_HashCode *pub_key_hash, | 475 | client_send_member_cb (void *cls, const struct GNUNET_HashCode *pub_key_hash, |
356 | void *member) | 476 | void *member) |
357 | { | 477 | { |
358 | const struct GNUNET_MessageHeader *msg = cls; | 478 | const struct GNUNET_MessageHeader *msg = cls; |
359 | struct Member *mem = member; | 479 | struct Member *mem = member; |
360 | 480 | ||
361 | if (NULL != mem->join_dcsn) | 481 | if (NULL != mem->join_dcsn) |
362 | { /* Only send message to admitted members */ | 482 | { /* Only send message to admitted members */ |
363 | message_to_clients (&mem->grp, msg); | 483 | client_send (&mem->grp, msg); |
364 | } | 484 | } |
365 | return GNUNET_YES; | 485 | return GNUNET_YES; |
366 | } | 486 | } |
@@ -372,15 +492,20 @@ member_message_cb (void *cls, const struct GNUNET_HashCode *pub_key_hash, | |||
372 | * @param grp The group to send @a msg to. | 492 | * @param grp The group to send @a msg to. |
373 | * @param msg Message to send. | 493 | * @param msg Message to send. |
374 | */ | 494 | */ |
375 | static void | 495 | static int |
376 | message_to_group (struct Group *grp, const struct GNUNET_MessageHeader *msg) | 496 | client_send_all (struct GNUNET_HashCode *pub_key_hash, |
497 | const struct GNUNET_MessageHeader *msg) | ||
377 | { | 498 | { |
499 | int n = 0; | ||
378 | if (origins != NULL) | 500 | if (origins != NULL) |
379 | GNUNET_CONTAINER_multihashmap_get_multiple (origins, &grp->pub_key_hash, | 501 | n += GNUNET_CONTAINER_multihashmap_get_multiple (origins, pub_key_hash, |
380 | origin_message_cb, (void *) msg); | 502 | client_send_origin_cb, |
503 | (void *) msg); | ||
381 | if (members != NULL) | 504 | if (members != NULL) |
382 | GNUNET_CONTAINER_multihashmap_get_multiple (members, &grp->pub_key_hash, | 505 | n += GNUNET_CONTAINER_multihashmap_get_multiple (members, pub_key_hash, |
383 | member_message_cb, (void *) msg); | 506 | client_send_member_cb, |
507 | (void *) msg); | ||
508 | return n; | ||
384 | } | 509 | } |
385 | 510 | ||
386 | 511 | ||
@@ -390,21 +515,140 @@ message_to_group (struct Group *grp, const struct GNUNET_MessageHeader *msg) | |||
390 | * @param grp The group to send @a msg to. | 515 | * @param grp The group to send @a msg to. |
391 | * @param msg Message to send. | 516 | * @param msg Message to send. |
392 | */ | 517 | */ |
393 | static void | 518 | static int |
394 | message_to_origin (struct Group *grp, const struct GNUNET_MessageHeader *msg) | 519 | client_send_origin (struct GNUNET_HashCode *pub_key_hash, |
520 | const struct GNUNET_MessageHeader *msg) | ||
395 | { | 521 | { |
522 | int n = 0; | ||
396 | if (origins != NULL) | 523 | if (origins != NULL) |
397 | GNUNET_CONTAINER_multihashmap_get_multiple (origins, &grp->pub_key_hash, | 524 | n += GNUNET_CONTAINER_multihashmap_get_multiple (origins, pub_key_hash, |
398 | origin_message_cb, (void *) msg); | 525 | client_send_origin_cb, |
526 | (void *) msg); | ||
527 | return n; | ||
528 | } | ||
529 | |||
530 | |||
531 | /** | ||
532 | * CADET is ready to transmit a message. | ||
533 | */ | ||
534 | size_t | ||
535 | cadet_notify_transmit_ready (void *cls, size_t buf_size, void *buf) | ||
536 | { | ||
537 | if (0 == buf_size) | ||
538 | { | ||
539 | /* FIXME: connection closed */ | ||
540 | return 0; | ||
541 | } | ||
542 | const struct GNUNET_MessageHeader *msg = cls; | ||
543 | uint16_t msg_size = ntohs (msg->size); | ||
544 | GNUNET_assert (msg_size <= buf_size); | ||
545 | memcpy (buf, msg, msg_size); | ||
546 | return msg_size; | ||
547 | } | ||
548 | |||
549 | |||
550 | /** | ||
551 | * Send a message to a CADET channel. | ||
552 | * | ||
553 | * @param chn Channel. | ||
554 | * @param msg Message. | ||
555 | */ | ||
556 | static void | ||
557 | cadet_send_msg (struct Channel *chn, const struct GNUNET_MessageHeader *msg) | ||
558 | { | ||
559 | chn->tmit_handle | ||
560 | = GNUNET_CADET_notify_transmit_ready (chn->channel, GNUNET_NO, | ||
561 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
562 | ntohs (msg->size), | ||
563 | &cadet_notify_transmit_ready, | ||
564 | (void *) msg); | ||
565 | GNUNET_assert (NULL != chn->tmit_handle); | ||
566 | } | ||
567 | |||
568 | |||
569 | /** | ||
570 | * Create new outgoing CADET channel. | ||
571 | * | ||
572 | * @param peer | ||
573 | * Peer to connect to. | ||
574 | * @param group_key | ||
575 | * Public key of group the channel belongs to. | ||
576 | * @param group_key_hash | ||
577 | * Hash of @a group_key. | ||
578 | * | ||
579 | * @return Channel. | ||
580 | */ | ||
581 | static struct Channel * | ||
582 | cadet_channel_create (struct Group *grp, struct GNUNET_PeerIdentity *peer) | ||
583 | { | ||
584 | struct Channel *chn = GNUNET_malloc (sizeof (*chn)); | ||
585 | chn->grp = grp; | ||
586 | chn->group_key = grp->pub_key; | ||
587 | chn->group_key_hash = grp->pub_key_hash; | ||
588 | chn->peer = *peer; | ||
589 | chn->direction = DIR_OUTGOING; | ||
590 | chn->join_status = JOIN_WAITING; | ||
591 | chn->channel = GNUNET_CADET_channel_create (cadet, chn, &chn->peer, | ||
592 | GNUNET_APPLICATION_TYPE_MULTICAST, | ||
593 | GNUNET_CADET_OPTION_RELIABLE); | ||
594 | GNUNET_CONTAINER_multihashmap_put (channels_out, &chn->group_key_hash, chn, | ||
595 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
596 | return chn; | ||
597 | } | ||
598 | |||
599 | |||
600 | /** | ||
601 | * Create CADET channel and send a join request. | ||
602 | */ | ||
603 | static void | ||
604 | cadet_send_join_request (struct Member *mem) | ||
605 | { | ||
606 | mem->origin_channel = cadet_channel_create (&mem->grp, &mem->origin); | ||
607 | cadet_send_msg (mem->origin_channel, &mem->join_req->header); | ||
608 | |||
609 | uint32_t i; | ||
610 | for (i = 0; i < mem->relay_count; i++) | ||
611 | { | ||
612 | struct Channel * | ||
613 | chn = cadet_channel_create (&mem->grp, &mem->relays[i]); | ||
614 | cadet_send_msg (chn, &mem->join_req->header); | ||
615 | } | ||
399 | } | 616 | } |
400 | 617 | ||
401 | 618 | ||
402 | /** | 619 | /** |
620 | * Iterator callback for sending a message to origin clients. | ||
621 | */ | ||
622 | static int | ||
623 | cadet_send_members_cb (void *cls, const struct GNUNET_HashCode *pub_key_hash, | ||
624 | void *channel) | ||
625 | { | ||
626 | const struct GNUNET_MessageHeader *msg = cls; | ||
627 | struct Channel *chn = channel; | ||
628 | if (JOIN_ADMITTED == chn->join_status) | ||
629 | cadet_send_msg (chn, msg); | ||
630 | return GNUNET_YES; | ||
631 | } | ||
632 | |||
633 | |||
634 | static int | ||
635 | cadet_send_members (struct GNUNET_HashCode *pub_key_hash, | ||
636 | const struct GNUNET_MessageHeader *msg) | ||
637 | { | ||
638 | int n = 0; | ||
639 | if (channels_in != NULL) | ||
640 | n += GNUNET_CONTAINER_multihashmap_get_multiple (channels_in, pub_key_hash, | ||
641 | cadet_send_members_cb, | ||
642 | (void *) msg); | ||
643 | return n; | ||
644 | } | ||
645 | |||
646 | /** | ||
403 | * Handle a connecting client starting an origin. | 647 | * Handle a connecting client starting an origin. |
404 | */ | 648 | */ |
405 | static void | 649 | static void |
406 | client_origin_start (void *cls, struct GNUNET_SERVER_Client *client, | 650 | client_recv_origin_start (void *cls, struct GNUNET_SERVER_Client *client, |
407 | const struct GNUNET_MessageHeader *m) | 651 | const struct GNUNET_MessageHeader *m) |
408 | { | 652 | { |
409 | const struct MulticastOriginStartMessage * | 653 | const struct MulticastOriginStartMessage * |
410 | msg = (const struct MulticastOriginStartMessage *) m; | 654 | msg = (const struct MulticastOriginStartMessage *) m; |
@@ -454,8 +698,8 @@ client_origin_start (void *cls, struct GNUNET_SERVER_Client *client, | |||
454 | * Handle a connecting client joining a group. | 698 | * Handle a connecting client joining a group. |
455 | */ | 699 | */ |
456 | static void | 700 | static void |
457 | client_member_join (void *cls, struct GNUNET_SERVER_Client *client, | 701 | client_recv_member_join (void *cls, struct GNUNET_SERVER_Client *client, |
458 | const struct GNUNET_MessageHeader *m) | 702 | const struct GNUNET_MessageHeader *m) |
459 | { | 703 | { |
460 | const struct MulticastMemberJoinMessage * | 704 | const struct MulticastMemberJoinMessage * |
461 | msg = (const struct MulticastMemberJoinMessage *) m; | 705 | msg = (const struct MulticastMemberJoinMessage *) m; |
@@ -494,7 +738,7 @@ client_member_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
494 | { | 738 | { |
495 | grp_mem = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); | 739 | grp_mem = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); |
496 | GNUNET_CONTAINER_multihashmap_put (group_members, &grp->pub_key_hash, grp_mem, | 740 | GNUNET_CONTAINER_multihashmap_put (group_members, &grp->pub_key_hash, grp_mem, |
497 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 741 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
498 | } | 742 | } |
499 | GNUNET_CONTAINER_multihashmap_put (grp_mem, &mem->pub_key_hash, mem, | 743 | GNUNET_CONTAINER_multihashmap_put (grp_mem, &mem->pub_key_hash, mem, |
500 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 744 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
@@ -558,8 +802,9 @@ client_member_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
558 | if (0 < join_msg_size) | 802 | if (0 < join_msg_size) |
559 | memcpy (&req[1], join_msg, join_msg_size); | 803 | memcpy (&req[1], join_msg, join_msg_size); |
560 | 804 | ||
561 | req->purpose.size = htonl (sizeof (*req) + join_msg_size | 805 | req->purpose.size = htonl (msg_size |
562 | - sizeof (req->header) | 806 | - sizeof (req->header) |
807 | - sizeof (req->reserved) | ||
563 | - sizeof (req->signature)); | 808 | - sizeof (req->signature)); |
564 | req->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST); | 809 | req->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST); |
565 | 810 | ||
@@ -574,33 +819,52 @@ client_member_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
574 | GNUNET_free (mem->join_req); | 819 | GNUNET_free (mem->join_req); |
575 | mem->join_req = req; | 820 | mem->join_req = req; |
576 | 821 | ||
577 | if (GNUNET_YES | 822 | if (0 == client_send_origin (&grp->pub_key_hash, &mem->join_req->header)) |
578 | == GNUNET_CONTAINER_multihashmap_contains (origins, &grp->pub_key_hash)) | 823 | { /* No local origins, send to remote origin */ |
579 | { /* Local origin */ | 824 | cadet_send_join_request (mem); |
580 | message_to_origin (grp, (struct GNUNET_MessageHeader *) mem->join_req); | ||
581 | } | ||
582 | else | ||
583 | { | ||
584 | /* FIXME: send join request to remote peers */ | ||
585 | } | 825 | } |
586 | } | 826 | } |
587 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 827 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
588 | } | 828 | } |
589 | 829 | ||
590 | 830 | ||
831 | static void | ||
832 | client_send_join_decision (struct Member *mem, | ||
833 | const struct MulticastJoinDecisionMessageHeader *hdcsn) | ||
834 | { | ||
835 | client_send (&mem->grp, &hdcsn->header); | ||
836 | |||
837 | const struct MulticastJoinDecisionMessage * | ||
838 | dcsn = (const struct MulticastJoinDecisionMessage *) &hdcsn[1]; | ||
839 | if (GNUNET_YES == ntohl (dcsn->is_admitted)) | ||
840 | { /* Member admitted, store join_decision. */ | ||
841 | uint16_t dcsn_size = ntohs (dcsn->header.size); | ||
842 | mem->join_dcsn = GNUNET_malloc (dcsn_size); | ||
843 | memcpy (mem->join_dcsn, dcsn, dcsn_size); | ||
844 | } | ||
845 | else | ||
846 | { /* Refused entry, disconnect clients. */ | ||
847 | struct ClientList *cl = mem->grp.clients_head; | ||
848 | while (NULL != cl) | ||
849 | { | ||
850 | struct GNUNET_SERVER_Client *client = cl->client; | ||
851 | cl = cl->next; | ||
852 | GNUNET_SERVER_client_disconnect (client); | ||
853 | } | ||
854 | } | ||
855 | } | ||
856 | |||
591 | /** | 857 | /** |
592 | * Join decision from client. | 858 | * Join decision from client. |
593 | */ | 859 | */ |
594 | static void | 860 | static void |
595 | client_join_decision (void *cls, struct GNUNET_SERVER_Client *client, | 861 | client_recv_join_decision (void *cls, struct GNUNET_SERVER_Client *client, |
596 | const struct GNUNET_MessageHeader *m) | 862 | const struct GNUNET_MessageHeader *m) |
597 | { | 863 | { |
598 | struct Group * | 864 | struct Group * |
599 | grp = GNUNET_SERVER_client_get_user_context (client, struct Group); | 865 | grp = GNUNET_SERVER_client_get_user_context (client, struct Group); |
600 | const struct MulticastJoinDecisionMessageHeader * | 866 | const struct MulticastJoinDecisionMessageHeader * |
601 | hdcsn = (const struct MulticastJoinDecisionMessageHeader *) m; | 867 | hdcsn = (const struct MulticastJoinDecisionMessageHeader *) m; |
602 | const struct MulticastJoinDecisionMessage * | ||
603 | dcsn = (const struct MulticastJoinDecisionMessage *) &hdcsn[1]; | ||
604 | 868 | ||
605 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 869 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
606 | "%p Got join decision from client for group %s..\n", | 870 | "%p Got join decision from client for group %s..\n", |
@@ -623,25 +887,7 @@ client_join_decision (void *cls, struct GNUNET_SERVER_Client *client, | |||
623 | "%p ..and member %s: %p\n", | 887 | "%p ..and member %s: %p\n", |
624 | grp, GNUNET_h2s (&member_key_hash), mem); | 888 | grp, GNUNET_h2s (&member_key_hash), mem); |
625 | if (NULL != mem) | 889 | if (NULL != mem) |
626 | { | 890 | client_send_join_decision (mem, hdcsn); |
627 | message_to_clients (&mem->grp, (struct GNUNET_MessageHeader *) hdcsn); | ||
628 | if (GNUNET_YES == ntohl (dcsn->is_admitted)) | ||
629 | { /* Member admitted, store join_decision. */ | ||
630 | uint16_t dcsn_size = ntohs (dcsn->header.size); | ||
631 | mem->join_dcsn = GNUNET_malloc (dcsn_size); | ||
632 | memcpy (mem->join_dcsn, dcsn, dcsn_size); | ||
633 | } | ||
634 | else | ||
635 | { /* Refused entry, disconnect clients. */ | ||
636 | struct ClientList *cl = mem->grp.clients_head; | ||
637 | while (NULL != cl) | ||
638 | { | ||
639 | struct GNUNET_SERVER_Client *client = cl->client; | ||
640 | cl = cl->next; | ||
641 | GNUNET_SERVER_client_disconnect (client); | ||
642 | } | ||
643 | } | ||
644 | } | ||
645 | } | 891 | } |
646 | } | 892 | } |
647 | else | 893 | else |
@@ -651,12 +897,13 @@ client_join_decision (void *cls, struct GNUNET_SERVER_Client *client, | |||
651 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 897 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
652 | } | 898 | } |
653 | 899 | ||
900 | |||
654 | /** | 901 | /** |
655 | * Incoming message from a client. | 902 | * Incoming message from a client. |
656 | */ | 903 | */ |
657 | static void | 904 | static void |
658 | client_multicast_message (void *cls, struct GNUNET_SERVER_Client *client, | 905 | client_recv_multicast_message (void *cls, struct GNUNET_SERVER_Client *client, |
659 | const struct GNUNET_MessageHeader *m) | 906 | const struct GNUNET_MessageHeader *m) |
660 | { | 907 | { |
661 | struct Group * | 908 | struct Group * |
662 | grp = GNUNET_SERVER_client_get_user_context (client, struct Group); | 909 | grp = GNUNET_SERVER_client_get_user_context (client, struct Group); |
@@ -666,7 +913,7 @@ client_multicast_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
666 | msg = (struct GNUNET_MULTICAST_MessageHeader *) m; | 913 | msg = (struct GNUNET_MULTICAST_MessageHeader *) m; |
667 | 914 | ||
668 | msg->fragment_id = GNUNET_htonll (++orig->max_fragment_id); | 915 | msg->fragment_id = GNUNET_htonll (++orig->max_fragment_id); |
669 | msg->purpose.size = htonl (sizeof (*msg) + ntohs (m->size) | 916 | msg->purpose.size = htonl (ntohs (msg->header.size) |
670 | - sizeof (msg->header) | 917 | - sizeof (msg->header) |
671 | - sizeof (msg->hop_counter) | 918 | - sizeof (msg->hop_counter) |
672 | - sizeof (msg->signature)); | 919 | - sizeof (msg->signature)); |
@@ -675,13 +922,12 @@ client_multicast_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
675 | if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (&orig->priv_key, &msg->purpose, | 922 | if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (&orig->priv_key, &msg->purpose, |
676 | &msg->signature)) | 923 | &msg->signature)) |
677 | { | 924 | { |
678 | /* FIXME: handle error */ | ||
679 | GNUNET_assert (0); | 925 | GNUNET_assert (0); |
680 | } | 926 | } |
681 | 927 | ||
682 | /* FIXME: send to remote members */ | 928 | client_send_all (&grp->pub_key_hash, m); |
929 | cadet_send_members (&grp->pub_key_hash, m); | ||
683 | 930 | ||
684 | message_to_group (grp, m); | ||
685 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 931 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
686 | } | 932 | } |
687 | 933 | ||
@@ -690,8 +936,8 @@ client_multicast_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
690 | * Incoming request from a client. | 936 | * Incoming request from a client. |
691 | */ | 937 | */ |
692 | static void | 938 | static void |
693 | client_multicast_request (void *cls, struct GNUNET_SERVER_Client *client, | 939 | client_recv_multicast_request (void *cls, struct GNUNET_SERVER_Client *client, |
694 | const struct GNUNET_MessageHeader *m) | 940 | const struct GNUNET_MessageHeader *m) |
695 | { | 941 | { |
696 | struct Group * | 942 | struct Group * |
697 | grp = GNUNET_SERVER_client_get_user_context (client, struct Group); | 943 | grp = GNUNET_SERVER_client_get_user_context (client, struct Group); |
@@ -702,7 +948,7 @@ client_multicast_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
702 | req = (struct GNUNET_MULTICAST_RequestHeader *) m; | 948 | req = (struct GNUNET_MULTICAST_RequestHeader *) m; |
703 | 949 | ||
704 | req->fragment_id = GNUNET_ntohll (++mem->max_fragment_id); | 950 | req->fragment_id = GNUNET_ntohll (++mem->max_fragment_id); |
705 | req->purpose.size = htonl (sizeof (*req) + ntohs (m->size) | 951 | req->purpose.size = htonl (ntohs (req->header.size) |
706 | - sizeof (req->header) | 952 | - sizeof (req->header) |
707 | - sizeof (req->member_key) | 953 | - sizeof (req->member_key) |
708 | - sizeof (req->signature)); | 954 | - sizeof (req->signature)); |
@@ -711,58 +957,348 @@ client_multicast_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
711 | if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_sign (&mem->priv_key, &req->purpose, | 957 | if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_sign (&mem->priv_key, &req->purpose, |
712 | &req->signature)) | 958 | &req->signature)) |
713 | { | 959 | { |
714 | /* FIXME: handle error */ | ||
715 | GNUNET_assert (0); | 960 | GNUNET_assert (0); |
716 | } | 961 | } |
717 | 962 | ||
718 | if (GNUNET_YES | 963 | if (0 == client_send_origin (&grp->pub_key_hash, m)) |
719 | == GNUNET_CONTAINER_multihashmap_contains (origins, &grp->pub_key_hash)) | 964 | { /* No local origins, send to remote origin */ |
720 | { /* Local origin */ | 965 | if (NULL != mem->origin_channel) |
721 | message_to_origin (grp, m); | 966 | { |
967 | cadet_send_msg (mem->origin_channel, m); | ||
968 | } | ||
969 | else | ||
970 | { | ||
971 | /* FIXME: not yet connected to origin */ | ||
972 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
973 | return; | ||
974 | } | ||
975 | } | ||
976 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
977 | } | ||
978 | |||
979 | |||
980 | /** | ||
981 | * A new client connected. | ||
982 | */ | ||
983 | static void | ||
984 | client_notify_connect (void *cls, struct GNUNET_SERVER_Client *client) | ||
985 | { | ||
986 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client connected: %p\n", client); | ||
987 | /* FIXME: send connect ACK */ | ||
988 | } | ||
989 | |||
990 | |||
991 | /** | ||
992 | * Message handlers for the server. | ||
993 | */ | ||
994 | static const struct GNUNET_SERVER_MessageHandler server_handlers[] = { | ||
995 | { &client_recv_origin_start, NULL, | ||
996 | GNUNET_MESSAGE_TYPE_MULTICAST_ORIGIN_START, 0 }, | ||
997 | |||
998 | { &client_recv_member_join, NULL, | ||
999 | GNUNET_MESSAGE_TYPE_MULTICAST_MEMBER_JOIN, 0 }, | ||
1000 | |||
1001 | { &client_recv_join_decision, NULL, | ||
1002 | GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION, 0 }, | ||
1003 | |||
1004 | { &client_recv_multicast_message, NULL, | ||
1005 | GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE, 0 }, | ||
1006 | |||
1007 | { &client_recv_multicast_request, NULL, | ||
1008 | GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST, 0 }, | ||
1009 | |||
1010 | {NULL, NULL, 0, 0} | ||
1011 | }; | ||
1012 | |||
1013 | |||
1014 | /** | ||
1015 | * New incoming CADET channel. | ||
1016 | */ | ||
1017 | static void * | ||
1018 | cadet_notify_channel_new (void *cls, | ||
1019 | struct GNUNET_CADET_Channel *channel, | ||
1020 | const struct GNUNET_PeerIdentity *initiator, | ||
1021 | uint32_t port, | ||
1022 | enum GNUNET_CADET_ChannelOption options) | ||
1023 | { | ||
1024 | return NULL; | ||
1025 | } | ||
1026 | |||
1027 | |||
1028 | /** | ||
1029 | * CADET channel is being destroyed. | ||
1030 | */ | ||
1031 | static void | ||
1032 | cadet_notify_channel_end (void *cls, | ||
1033 | const struct GNUNET_CADET_Channel *channel, | ||
1034 | void *ctx) | ||
1035 | { | ||
1036 | if (NULL == ctx) | ||
1037 | return; | ||
1038 | |||
1039 | struct Channel *chn = ctx; | ||
1040 | if (NULL != chn->grp) | ||
1041 | { | ||
1042 | if (GNUNET_NO == chn->grp->is_origin) | ||
1043 | { | ||
1044 | struct Member *mem = (struct Member *) chn->grp; | ||
1045 | if (chn == mem->origin_channel) | ||
1046 | mem->origin_channel = NULL; | ||
1047 | } | ||
1048 | } | ||
1049 | GNUNET_free (chn); | ||
1050 | } | ||
1051 | |||
1052 | |||
1053 | /** | ||
1054 | * Incoming join request message from CADET. | ||
1055 | */ | ||
1056 | int | ||
1057 | cadet_recv_join_request (void *cls, | ||
1058 | struct GNUNET_CADET_Channel *channel, | ||
1059 | void **ctx, | ||
1060 | const struct GNUNET_MessageHeader *m) | ||
1061 | { | ||
1062 | const struct MulticastJoinRequestMessage * | ||
1063 | req = (const struct MulticastJoinRequestMessage *) m; | ||
1064 | uint16_t size = ntohs (m->size); | ||
1065 | if (size < sizeof (*req)) | ||
1066 | { | ||
1067 | GNUNET_break_op (0); | ||
1068 | return GNUNET_SYSERR; | ||
1069 | } | ||
1070 | if (NULL != *ctx) | ||
1071 | { | ||
1072 | GNUNET_break_op (0); | ||
1073 | return GNUNET_SYSERR; | ||
1074 | } | ||
1075 | if (ntohl (req->purpose.size) != (size | ||
1076 | - sizeof (req->header) | ||
1077 | - sizeof (req->reserved) | ||
1078 | - sizeof (req->signature))) | ||
1079 | { | ||
1080 | GNUNET_break_op (0); | ||
1081 | return GNUNET_SYSERR; | ||
1082 | } | ||
1083 | if (GNUNET_OK != | ||
1084 | GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST, | ||
1085 | &req->purpose, &req->signature, | ||
1086 | &req->member_key)) | ||
1087 | { | ||
1088 | GNUNET_break_op (0); | ||
1089 | return GNUNET_SYSERR; | ||
1090 | } | ||
1091 | |||
1092 | struct GNUNET_HashCode group_key_hash; | ||
1093 | GNUNET_CRYPTO_hash (&req->group_key, sizeof (req->group_key), &group_key_hash); | ||
1094 | |||
1095 | struct Channel *chn = GNUNET_malloc (sizeof *chn); | ||
1096 | chn->channel = channel; | ||
1097 | chn->group_key = req->group_key; | ||
1098 | chn->group_key_hash = group_key_hash; | ||
1099 | chn->member_key = req->member_key; | ||
1100 | chn->peer = req->member_peer; | ||
1101 | chn->join_status = JOIN_WAITING; | ||
1102 | GNUNET_CONTAINER_multihashmap_put (channels_in, &chn->group_key_hash, chn, | ||
1103 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
1104 | |||
1105 | client_send_all (&group_key_hash, m); | ||
1106 | return GNUNET_OK; | ||
1107 | } | ||
1108 | |||
1109 | |||
1110 | /** | ||
1111 | * Incoming join request message from CADET. | ||
1112 | */ | ||
1113 | int | ||
1114 | cadet_recv_join_decision (void *cls, | ||
1115 | struct GNUNET_CADET_Channel *channel, | ||
1116 | void **ctx, | ||
1117 | const struct GNUNET_MessageHeader *m) | ||
1118 | { | ||
1119 | const struct MulticastJoinDecisionMessage * | ||
1120 | dcsn = (const struct MulticastJoinDecisionMessage *) m; | ||
1121 | uint16_t size = ntohs (m->size); | ||
1122 | if (size < sizeof (*dcsn)) | ||
1123 | { | ||
1124 | GNUNET_break_op (0); | ||
1125 | return GNUNET_SYSERR; | ||
1126 | } | ||
1127 | struct Channel *chn = *ctx; | ||
1128 | if (NULL == chn) | ||
1129 | { | ||
1130 | GNUNET_break_op (0); | ||
1131 | return GNUNET_SYSERR; | ||
1132 | } | ||
1133 | if (NULL == chn->grp || GNUNET_NO != chn->grp->is_origin) | ||
1134 | { | ||
1135 | GNUNET_break_op (0); | ||
1136 | return GNUNET_SYSERR; | ||
1137 | } | ||
1138 | switch (chn->join_status) | ||
1139 | { | ||
1140 | case JOIN_REFUSED: | ||
1141 | return GNUNET_SYSERR; | ||
1142 | |||
1143 | case JOIN_ADMITTED: | ||
1144 | return GNUNET_OK; | ||
1145 | |||
1146 | case JOIN_NOT_ASKED: | ||
1147 | case JOIN_WAITING: | ||
1148 | break; | ||
1149 | } | ||
1150 | |||
1151 | struct MulticastJoinDecisionMessageHeader * | ||
1152 | hdcsn = GNUNET_malloc (sizeof (*hdcsn) + size); | ||
1153 | hdcsn->peer = chn->peer; | ||
1154 | memcpy (&hdcsn[1], dcsn, sizeof (*hdcsn) + size); | ||
1155 | |||
1156 | struct Member *mem = (struct Member *) chn->grp; | ||
1157 | client_send_join_decision (mem, hdcsn); | ||
1158 | |||
1159 | if (GNUNET_YES == ntohs (dcsn->is_admitted)) | ||
1160 | { | ||
1161 | chn->join_status = JOIN_ADMITTED; | ||
1162 | return GNUNET_OK; | ||
722 | } | 1163 | } |
723 | else | 1164 | else |
724 | { | 1165 | { |
725 | /* FIXME: send to remote origin */ | 1166 | chn->join_status = JOIN_REFUSED; |
1167 | return GNUNET_SYSERR; | ||
726 | } | 1168 | } |
727 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1169 | } |
1170 | |||
1171 | /** | ||
1172 | * Incoming multicast message from CADET. | ||
1173 | */ | ||
1174 | int | ||
1175 | cadet_recv_message (void *cls, | ||
1176 | struct GNUNET_CADET_Channel *channel, | ||
1177 | void **ctx, | ||
1178 | const struct GNUNET_MessageHeader *m) | ||
1179 | { | ||
1180 | const struct GNUNET_MULTICAST_MessageHeader * | ||
1181 | msg = (const struct GNUNET_MULTICAST_MessageHeader *) m; | ||
1182 | uint16_t size = ntohs (m->size); | ||
1183 | if (size < sizeof (*msg)) | ||
1184 | { | ||
1185 | GNUNET_break_op (0); | ||
1186 | return GNUNET_SYSERR; | ||
1187 | } | ||
1188 | struct Channel *chn = *ctx; | ||
1189 | if (NULL == chn) | ||
1190 | { | ||
1191 | GNUNET_break_op (0); | ||
1192 | return GNUNET_SYSERR; | ||
1193 | } | ||
1194 | if (ntohl (msg->purpose.size) != (size | ||
1195 | - sizeof (msg->header) | ||
1196 | - sizeof (msg->hop_counter) | ||
1197 | - sizeof (msg->signature))) | ||
1198 | { | ||
1199 | GNUNET_break_op (0); | ||
1200 | return GNUNET_SYSERR; | ||
1201 | } | ||
1202 | if (GNUNET_OK != | ||
1203 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_MULTICAST_MESSAGE, | ||
1204 | &msg->purpose, &msg->signature, | ||
1205 | &chn->group_key)) | ||
1206 | { | ||
1207 | GNUNET_break_op (0); | ||
1208 | return GNUNET_SYSERR; | ||
1209 | } | ||
1210 | |||
1211 | client_send_all (&chn->group_key_hash, m); | ||
1212 | return GNUNET_OK; | ||
728 | } | 1213 | } |
729 | 1214 | ||
730 | 1215 | ||
731 | /** | 1216 | /** |
732 | * Connected to core service. | 1217 | * Incoming multicast request message from CADET. |
733 | */ | 1218 | */ |
734 | static void | 1219 | int |
735 | core_connected_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity) | 1220 | cadet_recv_request (void *cls, |
1221 | struct GNUNET_CADET_Channel *channel, | ||
1222 | void **ctx, | ||
1223 | const struct GNUNET_MessageHeader *m) | ||
736 | { | 1224 | { |
737 | this_peer = *my_identity; | 1225 | const struct GNUNET_MULTICAST_RequestHeader * |
1226 | req = (const struct GNUNET_MULTICAST_RequestHeader *) m; | ||
1227 | uint16_t size = ntohs (m->size); | ||
1228 | if (size < sizeof (*req)) | ||
1229 | { | ||
1230 | GNUNET_break_op (0); | ||
1231 | return GNUNET_SYSERR; | ||
1232 | } | ||
1233 | struct Channel *chn = *ctx; | ||
1234 | if (NULL == chn) | ||
1235 | { | ||
1236 | GNUNET_break_op (0); | ||
1237 | return GNUNET_SYSERR; | ||
1238 | } | ||
1239 | if (ntohl (req->purpose.size) != (size | ||
1240 | - sizeof (req->header) | ||
1241 | - sizeof (req->member_key) | ||
1242 | - sizeof (req->signature))) | ||
1243 | { | ||
1244 | GNUNET_break_op (0); | ||
1245 | return GNUNET_SYSERR; | ||
1246 | } | ||
1247 | if (GNUNET_OK != | ||
1248 | GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST, | ||
1249 | &req->purpose, &req->signature, | ||
1250 | &req->member_key)) | ||
1251 | { | ||
1252 | GNUNET_break_op (0); | ||
1253 | return GNUNET_SYSERR; | ||
1254 | } | ||
738 | 1255 | ||
739 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 1256 | client_send_origin (&chn->group_key_hash, m); |
740 | { &client_origin_start, NULL, | 1257 | return GNUNET_OK; |
741 | GNUNET_MESSAGE_TYPE_MULTICAST_ORIGIN_START, 0 }, | 1258 | } |
742 | 1259 | ||
743 | { &client_member_join, NULL, | ||
744 | GNUNET_MESSAGE_TYPE_MULTICAST_MEMBER_JOIN, 0 }, | ||
745 | 1260 | ||
746 | { &client_join_decision, NULL, | 1261 | /** |
747 | GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION, 0 }, | 1262 | * Message handlers for CADET. |
1263 | */ | ||
1264 | static const struct GNUNET_CADET_MessageHandler cadet_handlers[] = { | ||
1265 | { &cadet_recv_join_request, GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST, 0 }, | ||
1266 | { &cadet_recv_message, GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE, 0 }, | ||
1267 | { &cadet_recv_request, GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST, 0 }, | ||
1268 | { NULL, 0, 0 } | ||
1269 | }; | ||
748 | 1270 | ||
749 | { &client_multicast_message, NULL, | ||
750 | GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE, 0 }, | ||
751 | 1271 | ||
752 | { &client_multicast_request, NULL, | 1272 | /** |
753 | GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST, 0 }, | 1273 | * Listening ports for CADET. |
1274 | */ | ||
1275 | static const uint32_t cadet_ports[] = { GNUNET_APPLICATION_TYPE_MULTICAST, 0 }; | ||
754 | 1276 | ||
755 | {NULL, NULL, 0, 0} | 1277 | |
756 | }; | 1278 | /** |
1279 | * Connected to core service. | ||
1280 | */ | ||
1281 | static void | ||
1282 | core_connected_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity) | ||
1283 | { | ||
1284 | this_peer = *my_identity; | ||
757 | 1285 | ||
758 | stats = GNUNET_STATISTICS_create ("multicast", cfg); | 1286 | stats = GNUNET_STATISTICS_create ("multicast", cfg); |
759 | origins = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); | 1287 | origins = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); |
760 | members = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); | 1288 | members = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); |
761 | group_members = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); | 1289 | group_members = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); |
1290 | channels_in = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); | ||
1291 | channels_out = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); | ||
1292 | |||
1293 | cadet = GNUNET_CADET_connect (cfg, NULL, | ||
1294 | &cadet_notify_channel_new, | ||
1295 | &cadet_notify_channel_end, | ||
1296 | cadet_handlers, cadet_ports); | ||
1297 | |||
762 | nc = GNUNET_SERVER_notification_context_create (server, 1); | 1298 | nc = GNUNET_SERVER_notification_context_create (server, 1); |
1299 | GNUNET_SERVER_add_handlers (server, server_handlers); | ||
1300 | GNUNET_SERVER_disconnect_notify (server, &client_notify_disconnect, NULL); | ||
763 | 1301 | ||
764 | GNUNET_SERVER_add_handlers (server, handlers); | ||
765 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect, NULL); | ||
766 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 1302 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
767 | NULL); | 1303 | NULL); |
768 | } | 1304 | } |
@@ -781,7 +1317,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *srv, | |||
781 | { | 1317 | { |
782 | cfg = c; | 1318 | cfg = c; |
783 | server = srv; | 1319 | server = srv; |
784 | core = GNUNET_CORE_connect (cfg, NULL, core_connected_cb, NULL, NULL, | 1320 | GNUNET_SERVER_connect_notify (server, &client_notify_connect, NULL); |
1321 | core = GNUNET_CORE_connect (cfg, NULL, &core_connected_cb, NULL, NULL, | ||
785 | NULL, GNUNET_NO, NULL, GNUNET_NO, NULL); | 1322 | NULL, GNUNET_NO, NULL, GNUNET_NO, NULL); |
786 | } | 1323 | } |
787 | 1324 | ||
diff --git a/src/multicast/multicast.h b/src/multicast/multicast.h index 9abf3802c..82831a218 100644 --- a/src/multicast/multicast.h +++ b/src/multicast/multicast.h | |||
@@ -72,7 +72,7 @@ struct MulticastJoinRequestMessage | |||
72 | */ | 72 | */ |
73 | struct GNUNET_PeerIdentity member_peer; | 73 | struct GNUNET_PeerIdentity member_peer; |
74 | 74 | ||
75 | /* Followed by struct GNUNET_MessageHeader join_request */ | 75 | /* Followed by struct GNUNET_MessageHeader join_message */ |
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
@@ -253,7 +253,7 @@ struct MulticastMemberJoinMessage | |||
253 | /* Followed by struct GNUNET_MessageHeader join_msg */ | 253 | /* Followed by struct GNUNET_MessageHeader join_msg */ |
254 | }; | 254 | }; |
255 | 255 | ||
256 | 256 | #if NOT_USED | |
257 | /** | 257 | /** |
258 | * Message sent from the client to the service to broadcast to all group | 258 | * Message sent from the client to the service to broadcast to all group |
259 | * members. | 259 | * members. |
@@ -414,7 +414,7 @@ struct MulticastUnicastToOriginCancelMessage | |||
414 | uint64_t message_id; | 414 | uint64_t message_id; |
415 | 415 | ||
416 | }; | 416 | }; |
417 | 417 | #endif // NOT_USED | |
418 | 418 | ||
419 | GNUNET_NETWORK_STRUCT_END | 419 | GNUNET_NETWORK_STRUCT_END |
420 | 420 | ||
diff --git a/src/multicast/multicast_api.c b/src/multicast/multicast_api.c index 05c34241b..5f22741be 100644 --- a/src/multicast/multicast_api.c +++ b/src/multicast/multicast_api.c | |||
@@ -310,6 +310,10 @@ member_recv_join_decision (void *cls, | |||
310 | uint16_t dcsn_size = ntohs (dcsn->header.size); | 310 | uint16_t dcsn_size = ntohs (dcsn->header.size); |
311 | int is_admitted = ntohl (dcsn->is_admitted); | 311 | int is_admitted = ntohl (dcsn->is_admitted); |
312 | 312 | ||
313 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
314 | "%p Member got join decision from multicast: %d\n", | ||
315 | mem, is_admitted); | ||
316 | |||
313 | const struct GNUNET_MessageHeader *join_resp = NULL; | 317 | const struct GNUNET_MessageHeader *join_resp = NULL; |
314 | uint16_t join_resp_size = 0; | 318 | uint16_t join_resp_size = 0; |
315 | 319 | ||
diff --git a/src/multicast/test_multicast.conf b/src/multicast/test_multicast.conf index 4ae899002..2a675ce2d 100644 --- a/src/multicast/test_multicast.conf +++ b/src/multicast/test_multicast.conf | |||
@@ -1,2 +1,2 @@ | |||
1 | [arm] | 1 | [arm] |
2 | DEFAULTSERVICES = cadet multicast | 2 | DEFAULTSERVICES = statistics core transport dht cadet multicast |
diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c index 35579fcfc..285bd9f73 100644 --- a/src/psyc/gnunet-service-psyc.c +++ b/src/psyc/gnunet-service-psyc.c | |||
@@ -676,10 +676,10 @@ mcast_recv_join_request (void *cls, | |||
676 | */ | 676 | */ |
677 | static void | 677 | static void |
678 | mcast_recv_join_decision (void *cls, int is_admitted, | 678 | mcast_recv_join_decision (void *cls, int is_admitted, |
679 | const struct GNUNET_PeerIdentity *peer, | 679 | const struct GNUNET_PeerIdentity *peer, |
680 | uint16_t relay_count, | 680 | uint16_t relay_count, |
681 | const struct GNUNET_PeerIdentity *relays, | 681 | const struct GNUNET_PeerIdentity *relays, |
682 | const struct GNUNET_MessageHeader *join_resp) | 682 | const struct GNUNET_MessageHeader *join_resp) |
683 | { | 683 | { |
684 | struct Slave *slv = cls; | 684 | struct Slave *slv = cls; |
685 | struct Channel *chn = &slv->chn; | 685 | struct Channel *chn = &slv->chn; |
@@ -1526,7 +1526,7 @@ client_recv_slave_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
1526 | { | 1526 | { |
1527 | chn_slv = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); | 1527 | chn_slv = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); |
1528 | GNUNET_CONTAINER_multihashmap_put (channel_slaves, &chn->pub_key_hash, chn_slv, | 1528 | GNUNET_CONTAINER_multihashmap_put (channel_slaves, &chn->pub_key_hash, chn_slv, |
1529 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1529 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
1530 | } | 1530 | } |
1531 | GNUNET_CONTAINER_multihashmap_put (chn_slv, &slv->pub_key_hash, chn, | 1531 | GNUNET_CONTAINER_multihashmap_put (chn_slv, &slv->pub_key_hash, chn, |
1532 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1532 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
diff --git a/src/psyc/test_psyc.conf b/src/psyc/test_psyc.conf index 8eb0019a9..43a5adb75 100644 --- a/src/psyc/test_psyc.conf +++ b/src/psyc/test_psyc.conf | |||
@@ -1,2 +1,2 @@ | |||
1 | [arm] | 1 | [arm] |
2 | DEFAULTSERVICES = multicast psycstore psyc | 2 | DEFAULTSERVICES = statistics core transport dht cadet multicast psycstore psyc |
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index de4163720..c75589811 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -708,7 +708,7 @@ client_recv_guest_enter (void *cls, struct GNUNET_SERVER_Client *client, | |||
708 | { | 708 | { |
709 | plc_gst = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); | 709 | plc_gst = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); |
710 | GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst, | 710 | GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst, |
711 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 711 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
712 | } | 712 | } |
713 | GNUNET_CONTAINER_multihashmap_put (plc_gst, &gst->pub_key_hash, plc, | 713 | GNUNET_CONTAINER_multihashmap_put (plc_gst, &gst->pub_key_hash, plc, |
714 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 714 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
diff --git a/src/social/test_social.conf b/src/social/test_social.conf index 58c731168..5fcfb8d3b 100644 --- a/src/social/test_social.conf +++ b/src/social/test_social.conf | |||
@@ -1,2 +1,2 @@ | |||
1 | [arm] | 1 | [arm] |
2 | DEFAULTSERVICES = multicast psycstore psyc social | 2 | DEFAULTSERVICES = statistics core transport dht cadet multicast psycstore psyc social |