aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_social_service.h
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2014-07-23 16:19:49 +0000
committerGabor X Toth <*@tg-x.net>2014-07-23 16:19:49 +0000
commit3cf8ba0b60f8495892fa76635e9c23555d0a304c (patch)
tree5f27648bdb3cf3409628e4e5edc26f811cbd03a5 /src/include/gnunet_social_service.h
parent252b5599987b7ba03b879a8c2d1c455ad4c9834a (diff)
downloadgnunet-3cf8ba0b60f8495892fa76635e9c23555d0a304c.tar.gz
gnunet-3cf8ba0b60f8495892fa76635e9c23555d0a304c.zip
social: implement enter/leave/messaging; psyc: improvements and fixes
- social: implement enter/leave, send/receive messages, slicer - psyc, social: add struct GNUNET_PSYC_Message for single-fragment join messages - psyc: add message callback in addition to message part callback - client_manager, social, psyc, multicast: add disconnect callback
Diffstat (limited to 'src/include/gnunet_social_service.h')
-rw-r--r--src/include/gnunet_social_service.h261
1 files changed, 179 insertions, 82 deletions
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h
index f8b24c161..ca1578820 100644
--- a/src/include/gnunet_social_service.h
+++ b/src/include/gnunet_social_service.h
@@ -81,6 +81,8 @@ struct GNUNET_SOCIAL_Slicer;
81 * 81 *
82 * @param cls 82 * @param cls
83 * Closure. 83 * Closure.
84 * @param msg
85 * Message part, as it arrived from the network.
84 * @param message_id 86 * @param message_id
85 * Message counter, monotonically increasing from 1. 87 * Message counter, monotonically increasing from 1.
86 * @param nym 88 * @param nym
@@ -92,12 +94,53 @@ struct GNUNET_SOCIAL_Slicer;
92 * Original method name from PSYC. 94 * Original method name from PSYC.
93 * May be more specific than the registered method name due to 95 * May be more specific than the registered method name due to
94 * try-and-slice matching. 96 * try-and-slice matching.
95 * @param env 97 */
96 * Environment with operations and variables for the message. 98typedef void
97 * Only set for the first call of this function for each @a message_id, 99(*GNUNET_SOCIAL_MethodCallback) (void *cls,
98 * NULL when notifying about further data fragments. 100 const struct GNUNET_PSYC_MessageMethod *msg,
99 * It has to be freed using GNUNET_ENV_environment_destroy() 101 uint64_t message_id,
100 * when it is not needed anymore. 102 uint32_t flags,
103 const struct GNUNET_SOCIAL_Nym *nym,
104 const char *method_name);
105
106
107/**
108 * Function called upon receiving a data fragment of a message.
109 *
110 * @param cls
111 * Closure.
112 * @param message_id
113 * Message ID this data fragment belongs to.
114 * @param msg
115 * Message part, as it arrived from the network.
116 * @param oper
117 * Operation to perform.
118 * @param name
119 * Name of the modifier.
120 * @param value
121 * Value of the modifier.
122 * @param value_size
123 * Size of @value.
124 */
125typedef void
126(*GNUNET_SOCIAL_ModifierCallback) (void *cls,
127 const struct GNUNET_PSYC_MessageModifier *msg,
128 uint64_t message_id,
129 enum GNUNET_ENV_Operator oper,
130 const char *name,
131 const void *value,
132 uint16_t value_size);
133
134
135/**
136 * Function called upon receiving a data fragment of a message.
137 *
138 * @param cls
139 * Closure.
140 * @param message_id
141 * Message ID this data fragment belongs to.
142 * @param msg
143 * Message part, as it arrived from the network.
101 * @param data_offset 144 * @param data_offset
102 * Byte offset of @a data in the overall data of the method. 145 * Byte offset of @a data in the overall data of the method.
103 * @param data_size 146 * @param data_size
@@ -106,21 +149,37 @@ struct GNUNET_SOCIAL_Slicer;
106 * Data stream given to the method. 149 * Data stream given to the method.
107 * @param end 150 * @param end
108 * End of message? 151 * End of message?
109 * #GNUNET_NO if there are further fragments, 152 * #GNUNET_NO if there are further fragments,
110 * #GNUNET_YES if this is the last fragment, 153 * #GNUNET_YES if this is the last fragment,
111 * #GNUNET_SYSERR indicates the message was cancelled by the sender. 154 * #GNUNET_SYSERR indicates the message was cancelled by the sender.
112 */ 155 */
113typedef void 156typedef void
114(*GNUNET_SOCIAL_MethodCallback) (void *cls, 157(*GNUNET_SOCIAL_DataCallback) (void *cls,
115 uint64_t message_id, 158 const struct GNUNET_MessageHeader *msg,
116 uint32_t flags, 159 uint64_t message_id,
117 const struct GNUNET_SOCIAL_Nym *nym, 160 uint64_t data_offset,
118 const char *method_name, 161 const void *data,
119 struct GNUNET_ENV_Environment *env, 162 uint16_t data_size);
120 uint64_t data_offset, 163
121 size_t data_size, 164
122 const void *data, 165/**
123 int end); 166 * End of message.
167 *
168 * @param cls
169 * Closure.
170 * @param msg
171 * Message part, as it arrived from the network.
172 * @param message_id
173 * Message ID this data fragment belongs to.
174 * @param cancelled.
175 * #GNUNET_YES if the message was cancelled,
176 * #GNUNET_NO if the message is complete.
177 */
178typedef void
179(*GNUNET_SOCIAL_EndOfMessageCallback) (void *cls,
180 const struct GNUNET_MessageHeader *msg,
181 uint64_t message_id,
182 uint8_t cancelled);
124 183
125 184
126/** 185/**
@@ -148,20 +207,27 @@ void
148GNUNET_SOCIAL_slicer_add (struct GNUNET_SOCIAL_Slicer *slicer, 207GNUNET_SOCIAL_slicer_add (struct GNUNET_SOCIAL_Slicer *slicer,
149 const char *method_name, 208 const char *method_name,
150 GNUNET_SOCIAL_MethodCallback method_cb, 209 GNUNET_SOCIAL_MethodCallback method_cb,
210 GNUNET_SOCIAL_ModifierCallback modifier_cb,
211 GNUNET_SOCIAL_DataCallback data_cb,
212 GNUNET_SOCIAL_EndOfMessageCallback eom_cb,
151 void *cls); 213 void *cls);
152 214
153 215
154/** 216/**
155 * Remove a registered method from the try-and-slice instance. 217 * Remove a registered method handler from the try-and-slice instance.
156 * 218 *
157 * @param slicer The try-and-slice instance. 219 * @param slicer The try-and-slice instance.
158 * @param method_name Name of the method to remove. 220 * @param method_name Name of the method to remove.
159 * @param method Method handler. 221 * @param method Method handler.
160 */ 222 */
161void 223int
162GNUNET_SOCIAL_slicer_remove (struct GNUNET_SOCIAL_Slicer *slicer, 224GNUNET_SOCIAL_slicer_remove (struct GNUNET_SOCIAL_Slicer *slicer,
163 const char *method_name, 225 const char *method_name,
164 GNUNET_SOCIAL_MethodCallback method_cb); 226 GNUNET_SOCIAL_MethodCallback method_cb,
227 GNUNET_SOCIAL_ModifierCallback modifier_cb,
228 GNUNET_SOCIAL_DataCallback data_cb,
229 GNUNET_SOCIAL_EndOfMessageCallback eom_cb);
230
165 231
166/** 232/**
167 * Destroy a given try-and-slice instance. 233 * Destroy a given try-and-slice instance.
@@ -257,7 +323,7 @@ typedef void
257 */ 323 */
258struct GNUNET_SOCIAL_Host * 324struct GNUNET_SOCIAL_Host *
259GNUNET_SOCIAL_host_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, 325GNUNET_SOCIAL_host_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
260 struct GNUNET_IDENTITY_Ego *ego, 326 const struct GNUNET_IDENTITY_Ego *ego,
261 const struct GNUNET_CRYPTO_EddsaPrivateKey *place_key, 327 const struct GNUNET_CRYPTO_EddsaPrivateKey *place_key,
262 enum GNUNET_PSYC_Policy policy, 328 enum GNUNET_PSYC_Policy policy,
263 struct GNUNET_SOCIAL_Slicer *slicer, 329 struct GNUNET_SOCIAL_Slicer *slicer,
@@ -268,17 +334,32 @@ GNUNET_SOCIAL_host_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
268 334
269 335
270/** 336/**
271 * Admit @a nym to the place. 337 * Decision whether to admit @a nym into the place or refuse entry.
272 *
273 * The @a nym reference will remain valid until either the @a host or @a nym
274 * leaves the place.
275 * 338 *
276 * @param host Host of the place. 339 * @param hst
277 * @param nym Handle for the entity that wants to enter. 340 * Host of the place.
341 * @param nym
342 * Handle for the entity that wanted to enter.
343 * @param is_admitted
344 * #GNUNET_YES if @a nym is admitted,
345 * #GNUNET_NO if @a nym is refused entry,
346 * #GNUNET_SYSERR if we cannot answer the request.
347 * @param method_name
348 * Method name for the rejection message.
349 * @param env
350 * Environment containing variables for the message, or NULL.
351 * @param data
352 * Data for the rejection message to send back.
353 * @param data_size
354 * Number of bytes in @a data for method.
355 * @return #GNUNET_OK on success,
356 * #GNUNET_SYSERR if the message is too large.
278 */ 357 */
279void 358int
280GNUNET_SOCIAL_host_admit (struct GNUNET_SOCIAL_Host *host, 359GNUNET_SOCIAL_host_entry_decision (struct GNUNET_SOCIAL_Host *hst,
281 struct GNUNET_SOCIAL_Nym *nym); 360 struct GNUNET_SOCIAL_Nym *nym,
361 int is_admitted,
362 const struct GNUNET_PSYC_Message *entry_resp);
282 363
283 364
284/** 365/**
@@ -297,35 +378,17 @@ GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host,
297 378
298 379
299/** 380/**
300 * Refuse @a nym entry into the place.
301 *
302 * @param host Host of the place.
303 * @param nym Handle for the entity that wanted to enter.
304 * @param method_name Method name for the rejection message.
305 * @param env Environment containing variables for the message, or NULL.
306 * @param data Data for the rejection message to send back.
307 * @param data_size Number of bytes in @a data for method.
308 */
309void
310GNUNET_SOCIAL_host_refuse_entry (struct GNUNET_SOCIAL_Host *host,
311 struct GNUNET_SOCIAL_Nym *nym,
312 const char *method_name,
313 const struct GNUNET_ENV_Environment *env,
314 const void *data,
315 size_t data_size);
316
317
318/**
319 * Get the public key of a @a nym. 381 * Get the public key of a @a nym.
320 * 382 *
321 * Suitable, for example, to be used with GNUNET_NAMESTORE_zone_to_name(). 383 * Suitable, for example, to be used with GNUNET_NAMESTORE_zone_to_name().
322 * 384 *
323 * @param nym Pseudonym to map to a cryptographic identifier. 385 * @param nym
324 * @param[out] nym_key Set to the public key of the nym. 386 * Pseudonym to map to a cryptographic identifier.
387 *
388 * @return Public key of nym;
325 */ 389 */
326void 390struct GNUNET_CRYPTO_EcdsaPublicKey *
327GNUNET_SOCIAL_nym_get_key (struct GNUNET_SOCIAL_Nym *nym, 391GNUNET_SOCIAL_nym_get_key (struct GNUNET_SOCIAL_Nym *nym);
328 struct GNUNET_CRYPTO_EddsaPublicKey *nym_key);
329 392
330 393
331/** 394/**
@@ -418,9 +481,20 @@ GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host,
418 481
419 482
420/** 483/**
484 * Resume transmitting announcement.
485 *
486 * @param a
487 * The announcement to resume.
488 */
489void
490GNUNET_SOCIAL_host_announce_resume (struct GNUNET_SOCIAL_Announcement *a);
491
492
493/**
421 * Cancel announcement. 494 * Cancel announcement.
422 * 495 *
423 * @param a The announcement to cancel. 496 * @param a
497 * The announcement to cancel.
424 */ 498 */
425void 499void
426GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a); 500GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a);
@@ -431,7 +505,8 @@ GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a);
431 * 505 *
432 * The returned handle can be used to access the place API. 506 * The returned handle can be used to access the place API.
433 * 507 *
434 * @param host Handle for the host. 508 * @param host
509 * Handle for the host.
435 * 510 *
436 * @return Handle for the hosted place, valid as long as @a host is valid. 511 * @return Handle for the hosted place, valid as long as @a host is valid.
437 */ 512 */
@@ -444,11 +519,21 @@ GNUNET_SOCIAL_host_get_place (struct GNUNET_SOCIAL_Host *host);
444 * 519 *
445 * Invalidates host handle. 520 * Invalidates host handle.
446 * 521 *
447 * @param host Host leaving the place. 522 * @param host
448 * @param keep_active Keep the place active after last host disconnected. 523 * Host leaving the place.
524 * @param keep_active
525 * Keep the place active after last host disconnected.
526 * @param leave_cb
527 * Function called after the host left the place
528 * and disconnected from the social service.
529 * @param leave_cls
530 * Closure for @a leave_cb.
449 */ 531 */
450void 532void
451GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *host, int keep_active); 533GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *host,
534 int keep_active,
535 GNUNET_ContinuationCallback leave_cb,
536 void *leave_cls);
452 537
453 538
454/** 539/**
@@ -493,13 +578,10 @@ typedef void
493 * @param data 578 * @param data
494 * Payload of the message. 579 * Payload of the message.
495 */ 580 */
496typedef int 581typedef void
497(*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls, 582(*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls,
498 int is_admitted, 583 int is_admitted,
499 const char *method_name, 584 const struct GNUNET_PSYC_Message *entry_resp);
500 struct GNUNET_ENV_Environment *env,
501 size_t data_size,
502 const void *data);
503 585
504 586
505/** 587/**
@@ -521,15 +603,12 @@ typedef int
521 */ 603 */
522struct GNUNET_SOCIAL_Guest * 604struct GNUNET_SOCIAL_Guest *
523GNUNET_SOCIAL_guest_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, 605GNUNET_SOCIAL_guest_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
524 struct GNUNET_IDENTITY_Ego *ego, 606 const struct GNUNET_IDENTITY_Ego *ego,
525 struct GNUNET_CRYPTO_EddsaPublicKey *place_key, 607 const struct GNUNET_CRYPTO_EddsaPublicKey *place_key,
526 struct GNUNET_PeerIdentity *origin, 608 const struct GNUNET_PeerIdentity *origin,
527 uint32_t relay_count, 609 uint32_t relay_count,
528 struct GNUNET_PeerIdentity *relays, 610 const struct GNUNET_PeerIdentity *relays,
529 const char *method_name, 611 const struct GNUNET_PSYC_Message *entry_msg,
530 const struct GNUNET_ENV_Environment *env,
531 const void *data,
532 size_t data_size,
533 struct GNUNET_SOCIAL_Slicer *slicer, 612 struct GNUNET_SOCIAL_Slicer *slicer,
534 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, 613 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
535 GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, 614 GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb,
@@ -558,10 +637,7 @@ struct GNUNET_SOCIAL_Guest *
558GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_CONFIGURATION_Handle *cfg, 637GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_CONFIGURATION_Handle *cfg,
559 struct GNUNET_IDENTITY_Ego *ego, 638 struct GNUNET_IDENTITY_Ego *ego,
560 char *gns_name, 639 char *gns_name,
561 const char *method_name, 640 const struct GNUNET_PSYC_Message *join_msg,
562 const struct GNUNET_ENV_Environment *env,
563 const void *data,
564 size_t data_size,
565 struct GNUNET_SOCIAL_Slicer *slicer, 641 struct GNUNET_SOCIAL_Slicer *slicer,
566 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, 642 GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
567 GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, 643 GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb,
@@ -612,9 +688,20 @@ GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest,
612 688
613 689
614/** 690/**
691 * Resume talking to the host of the place.
692 *
693 * @param tr
694 * Talk request to resume.
695 */
696void
697GNUNET_SOCIAL_guest_talk_resume (struct GNUNET_SOCIAL_TalkRequest *tr);
698
699
700/**
615 * Cancel talking to the host of the place. 701 * Cancel talking to the host of the place.
616 * 702 *
617 * @param tr Talk request to cancel. 703 * @param tr
704 * Talk request to cancel.
618 */ 705 */
619void 706void
620GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr); 707GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr);
@@ -625,11 +712,21 @@ GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr);
625 * 712 *
626 * Notifies the owner of the place about leaving, and destroys the place handle. 713 * Notifies the owner of the place about leaving, and destroys the place handle.
627 * 714 *
628 * @param place Place to leave permanently. 715 * @param place
629 * @param keep_active Keep place active after last application disconnected. 716 * Place to leave permanently.
717 * @param keep_active
718 * Keep place active after last application disconnected.
719 * @param leave_cb
720 * Function called after the guest left the place
721 * and disconnected from the social service.
722 * @param leave_cls
723 * Closure for @a leave_cb.
630 */ 724 */
631void 725void
632GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *guest, int keep_active); 726GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *guest,
727 int keep_active,
728 GNUNET_ContinuationCallback leave_cb,
729 void *leave_cls);
633 730
634 731
635/** 732/**