aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_psyc_service.h
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2014-03-06 23:46:45 +0000
committerGabor X Toth <*@tg-x.net>2014-03-06 23:46:45 +0000
commit8a0b8a4604526e5f832c4971f9c3b1b48d79bea4 (patch)
treedfd18a61272a18381fe9ce9b09849a965480a303 /src/include/gnunet_psyc_service.h
parenta21beab58c1d2abc747359a98326f19aaad4e8cd (diff)
downloadgnunet-8a0b8a4604526e5f832c4971f9c3b1b48d79bea4.tar.gz
gnunet-8a0b8a4604526e5f832c4971f9c3b1b48d79bea4.zip
PSYC: implement slave to master requests, tests, fixes, reorg
Multicast lib: handle member to origin requests. Keep track of members and origins and call their callbacks when necessary.
Diffstat (limited to 'src/include/gnunet_psyc_service.h')
-rw-r--r--src/include/gnunet_psyc_service.h92
1 files changed, 50 insertions, 42 deletions
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h
index f843fbe1f..8f1707854 100644
--- a/src/include/gnunet_psyc_service.h
+++ b/src/include/gnunet_psyc_service.h
@@ -110,7 +110,7 @@ enum GNUNET_PSYC_ChannelFlags
110 * Past messages are only available to slaves who were admitted at the time 110 * Past messages are only available to slaves who were admitted at the time
111 * they were sent to the channel. 111 * they were sent to the channel.
112 */ 112 */
113 GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY = 1 << 1, 113 GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY = 1 << 1
114}; 114};
115 115
116/** 116/**
@@ -132,7 +132,7 @@ enum GNUNET_PSYC_Policy
132 */ 132 */
133 GNUNET_PSYC_CHANNEL_PRIVATE 133 GNUNET_PSYC_CHANNEL_PRIVATE
134 = GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL 134 = GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL
135 | GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY, 135 | GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY
136 136
137#if IDEAS_FOR_FUTURE 137#if IDEAS_FOR_FUTURE
138 /** 138 /**
@@ -152,9 +152,7 @@ enum GNUNET_PSYC_Policy
152 */ 152 */
153 GNUNET_PSYC_CHANNEL_CLOSED 153 GNUNET_PSYC_CHANNEL_CLOSED
154 = GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL, 154 = GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL,
155,
156#endif 155#endif
157
158}; 156};
159 157
160 158
@@ -163,7 +161,12 @@ enum GNUNET_PSYC_MessageFlags
163 /** 161 /**
164 * Historic message, retrieved from PSYCstore. 162 * Historic message, retrieved from PSYCstore.
165 */ 163 */
166 GNUNET_PSYC_MESSAGE_HISTORIC = 1 164 GNUNET_PSYC_MESSAGE_HISTORIC = 1 << 0,
165
166 /**
167 * Request from slave to master.
168 */
169 GNUNET_PSYC_MESSAGE_REQUEST = 1 << 1
167}; 170};
168 171
169GNUNET_NETWORK_STRUCT_BEGIN 172GNUNET_NETWORK_STRUCT_BEGIN
@@ -406,7 +409,7 @@ GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
406/** 409/**
407 * Function called to provide data for a transmission via PSYC. 410 * Function called to provide data for a transmission via PSYC.
408 * 411 *
409 * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO) 412 * Note that returning #GNUNET_YES or #GNUNET_SYSERR (but not #GNUNET_NO)
410 * invalidates the respective transmission handle. 413 * invalidates the respective transmission handle.
411 * 414 *
412 * @param cls Closure. 415 * @param cls Closure.
@@ -422,15 +425,43 @@ GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
422 * #GNUNET_YES if this completes the transmission (all data supplied) 425 * #GNUNET_YES if this completes the transmission (all data supplied)
423 */ 426 */
424typedef int 427typedef int
425(*GNUNET_PSYC_MasterTransmitNotify) (void *cls, 428(*GNUNET_PSYC_TransmitNotifyData) (void *cls,
426 uint16_t *data_size, 429 uint16_t *data_size,
427 void *data); 430 void *data);
428 431
432/**
433 * Function called to provide a modifier for a transmission via PSYC.
434 *
435 * Note that returning #GNUNET_YES or #GNUNET_SYSERR (but not #GNUNET_NO)
436 * invalidates the respective transmission handle.
437 *
438 * @param cls Closure.
439 * @param[in,out] data_size Initially set to the number of bytes available in
440 * @a data, should be set to the number of bytes written to data.
441 * @param[out] data Where to write the modifier's name and value.
442 * The function must copy at most @a data_size bytes to @a data.
443 * When this callback is first called for a modifier, @a data should
444 * contain: "name\0value". If the whole value does not fit, subsequent
445 * calls to this function should write continuations of the value to
446 * @a data.
447 * @param oper Where to write the operator of the modifier. Only needed during
448 * the first call to this callback at the beginning of the modifier.
449 * In case of subsequent calls asking for value continuations @a oper is
450 * set to #NULL.
451 * @return #GNUNET_SYSERR on error (fatal, aborts transmission)
452 * #GNUNET_NO on success, if more data is to be transmitted later.
453 * Should be used if @a data_size was not big enough to take all the
454 * data for the modifier's value (the name must be always returned
455 * during the first call to this callback).
456 * If 0 is returned in @a data_size the transmission is paused,
457 * and can be resumed with GNUNET_PSYC_master_transmit_resume().
458 * #GNUNET_YES if this completes the modifier (the whole value is supplied).
459 */
429typedef int 460typedef int
430(*GNUNET_PSYC_MasterTransmitNotifyModifier) (void *cls, 461(*GNUNET_PSYC_TransmitNotifyModifier) (void *cls,
431 uint16_t *data_size, 462 uint16_t *data_size,
432 void *data, 463 void *data,
433 uint8_t *oper); 464 uint8_t *oper);
434 465
435/** 466/**
436 * Flags for transmitting messages to a channel by the master. 467 * Flags for transmitting messages to a channel by the master.
@@ -477,8 +508,8 @@ struct GNUNET_PSYC_MasterTransmitHandle;
477struct GNUNET_PSYC_MasterTransmitHandle * 508struct GNUNET_PSYC_MasterTransmitHandle *
478GNUNET_PSYC_master_transmit (struct GNUNET_PSYC_Master *master, 509GNUNET_PSYC_master_transmit (struct GNUNET_PSYC_Master *master,
479 const char *method_name, 510 const char *method_name,
480 GNUNET_PSYC_MasterTransmitNotifyModifier notify_mod, 511 GNUNET_PSYC_TransmitNotifyModifier notify_mod,
481 GNUNET_PSYC_MasterTransmitNotify notify_data, 512 GNUNET_PSYC_TransmitNotifyData notify_data,
482 void *notify_cls, 513 void *notify_cls,
483 enum GNUNET_PSYC_MasterTransmitFlags flags); 514 enum GNUNET_PSYC_MasterTransmitFlags flags);
484 515
@@ -588,29 +619,6 @@ GNUNET_PSYC_slave_part (struct GNUNET_PSYC_Slave *slave);
588 619
589 620
590/** 621/**
591 * Function called to provide data for a transmission to the channel master
592 * (a.k.a. the @e host of the channel).
593 *
594 * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO)
595 * invalidates the respective transmission handle.
596 *
597 * @param cls Closure.
598 * @param[in,out] data_size Initially set to the number of bytes available in
599 * @a data, should be set to the number of bytes written to data
600 * (IN/OUT).
601 * @param[out] data Where to write the body of the message to give to the method;
602 * function must copy at most @a *data_size bytes to @a data.
603 * @return #GNUNET_SYSERR on error (fatal, aborts transmission).
604 * #GNUNET_NO on success, if more data is to be transmitted later.
605 * #GNUNET_YES if this completes the transmission (all data supplied).
606 */
607typedef int
608(*GNUNET_PSYC_SlaveTransmitNotify) (void *cls,
609 size_t *data_size,
610 char *data);
611
612
613/**
614 * Flags for transmitting messages to the channel master by a slave. 622 * Flags for transmitting messages to the channel master by a slave.
615 */ 623 */
616enum GNUNET_PSYC_SlaveTransmitFlags 624enum GNUNET_PSYC_SlaveTransmitFlags
@@ -630,8 +638,8 @@ struct GNUNET_PSYC_SlaveTransmitHandle;
630 * 638 *
631 * @param slave Slave handle. 639 * @param slave Slave handle.
632 * @param method_name Which (PSYC) method should be invoked (on host). 640 * @param method_name Which (PSYC) method should be invoked (on host).
633 * @param env Environment containing transient variables for the message, or NULL. 641 * @param notify_mod Function to call to obtain modifiers.
634 * @param notify Function to call when we are allowed to transmit (to get data). 642 * @param notify_data Function to call to obtain fragments of the data.
635 * @param notify_cls Closure for @a notify. 643 * @param notify_cls Closure for @a notify.
636 * @param flags Flags for the message being transmitted. 644 * @param flags Flags for the message being transmitted.
637 * @return Transmission handle, NULL on error (i.e. more than one request queued). 645 * @return Transmission handle, NULL on error (i.e. more than one request queued).
@@ -639,8 +647,8 @@ struct GNUNET_PSYC_SlaveTransmitHandle;
639struct GNUNET_PSYC_SlaveTransmitHandle * 647struct GNUNET_PSYC_SlaveTransmitHandle *
640GNUNET_PSYC_slave_transmit (struct GNUNET_PSYC_Slave *slave, 648GNUNET_PSYC_slave_transmit (struct GNUNET_PSYC_Slave *slave,
641 const char *method_name, 649 const char *method_name,
642 const struct GNUNET_ENV_Environment *env, 650 GNUNET_PSYC_TransmitNotifyModifier notify_mod,
643 GNUNET_PSYC_SlaveTransmitNotify notify, 651 GNUNET_PSYC_TransmitNotifyData notify_data,
644 void *notify_cls, 652 void *notify_cls,
645 enum GNUNET_PSYC_SlaveTransmitFlags flags); 653 enum GNUNET_PSYC_SlaveTransmitFlags flags);
646 654