diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-06-11 13:14:16 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-06-11 13:14:16 +0000 |
commit | 8599c7df4dff7eddba77260634dd7b94f9ebe016 (patch) | |
tree | 218305950249a590f5b35cfaa597bfec17521df0 /src/include/gnunet_psyc_service.h | |
parent | 0c0a922873c6647d07e038496d62568547c23e0b (diff) | |
download | gnunet-8599c7df4dff7eddba77260634dd7b94f9ebe016.tar.gz gnunet-8599c7df4dff7eddba77260634dd7b94f9ebe016.zip |
-further refinements to the APIs for PSYC/multicast
Diffstat (limited to 'src/include/gnunet_psyc_service.h')
-rw-r--r-- | src/include/gnunet_psyc_service.h | 98 |
1 files changed, 63 insertions, 35 deletions
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h index c4211f962..f53c9437f 100644 --- a/src/include/gnunet_psyc_service.h +++ b/src/include/gnunet_psyc_service.h | |||
@@ -95,6 +95,28 @@ extern "C" | |||
95 | 95 | ||
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Information flags for data fragments set via PSYC. | ||
99 | */ | ||
100 | enum GNUNET_PSYC_FragmentStatus | ||
101 | { | ||
102 | /** | ||
103 | * This is the first part of data for the given method call. | ||
104 | */ | ||
105 | GNUNET_PSYC_FS_FIRST = 1, | ||
106 | |||
107 | /** | ||
108 | * This is the last part of data for the given method call. | ||
109 | */ | ||
110 | GNUNET_PSYC_FS_LAST = 2, | ||
111 | |||
112 | /** | ||
113 | * OR'ed flags if payload is not fragmented. | ||
114 | */ | ||
115 | GNUNET_PSYC_FS_NOT_FRAGMENTED = (GNUNET_PSYC_FS_FIRST | GNUNET_PSYC_FS_LAST) | ||
116 | }; | ||
117 | |||
118 | |||
119 | /** | ||
98 | * Method called from PSYC upon receiving a message indicating a call | 120 | * Method called from PSYC upon receiving a message indicating a call |
99 | * to a 'method'. | 121 | * to a 'method'. |
100 | * | 122 | * |
@@ -107,18 +129,22 @@ extern "C" | |||
107 | * (unique only in combination with the given sender for | 129 | * (unique only in combination with the given sender for |
108 | * this channel) | 130 | * this channel) |
109 | * @param group_generation group generation counter for this message | 131 | * @param group_generation group generation counter for this message |
110 | * (always zero for messages from members to channel owner) | 132 | * (always zero for messages from members to channel owner); FIXME: needed? |
111 | * @param data_size number of bytes in 'data' | 133 | * @param data_off byte offset of 'data' in the overall data of the method |
134 | * @param data_size number of bytes in 'data'; | ||
112 | * @param data data stream given to the method (might not be zero-terminated | 135 | * @param data data stream given to the method (might not be zero-terminated |
113 | * if data is binary) | 136 | * if data is binary) |
137 | * @param frag fragmentation status for the data | ||
114 | */ | 138 | */ |
115 | typedef int (*GNUNET_PSYC_Method)(void *cls, | 139 | typedef int (*GNUNET_PSYC_Method)(void *cls, |
116 | const char *full_method_name, | 140 | const char *full_method_name, |
117 | const struct GNUNET_PeerIdentity *sender, | 141 | const struct GNUNET_PeerIdentity *sender, |
118 | uint64_t message_id, | 142 | uint64_t message_id, |
119 | uint64_t group_generation, | 143 | uint64_t group_generation, |
144 | uint64_t data_off, | ||
120 | size_t data_size, | 145 | size_t data_size, |
121 | const void *data); | 146 | const void *data, |
147 | enum GNUNET_PSYC_FragmentStatus frag); | ||
122 | 148 | ||
123 | 149 | ||
124 | /** | 150 | /** |
@@ -140,10 +166,9 @@ struct GNUNET_PSYC_Channel; | |||
140 | * events. | 166 | * events. |
141 | * | 167 | * |
142 | * @param cfg configuration to use (to connect to PSYC service) | 168 | * @param cfg configuration to use (to connect to PSYC service) |
143 | * @param name name of the channel, only important if this is a subchannel | 169 | * @param method functions to invoke on messages received from members, |
144 | * @param method_count number of methods in 'methods' array | ||
145 | * @param methods functions to invoke on messages received from members, | ||
146 | * typcially at least contains functions for 'join' and 'leave'. | 170 | * typcially at least contains functions for 'join' and 'leave'. |
171 | * @param method_cls closure for 'method' | ||
147 | * @param priv_key ECC key that will be used to sign messages for this | 172 | * @param priv_key ECC key that will be used to sign messages for this |
148 | * PSYC session; public key is used to identify the | 173 | * PSYC session; public key is used to identify the |
149 | * PSYC group; FIXME: we'll likely want to use | 174 | * PSYC group; FIXME: we'll likely want to use |
@@ -158,9 +183,8 @@ struct GNUNET_PSYC_Channel; | |||
158 | */ | 183 | */ |
159 | struct GNUNET_PSYC_Channel * | 184 | struct GNUNET_PSYC_Channel * |
160 | GNUNET_PSYC_channel_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 185 | GNUNET_PSYC_channel_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
161 | const char *name, | 186 | GNUNET_PSYC_Method method, |
162 | unsigned int method_count, | 187 | void *method_cls, |
163 | const struct GNUNET_PSYC_Method *methods, | ||
164 | const struct GNUNET_CRYPTO_EccPrivateKey *priv_key, | 188 | const struct GNUNET_CRYPTO_EccPrivateKey *priv_key, |
165 | enum GNUNET_MULTICAST_JoinPolicy join_policy); | 189 | enum GNUNET_MULTICAST_JoinPolicy join_policy); |
166 | 190 | ||
@@ -219,11 +243,11 @@ enum GNUNET_PSYC_Operator | |||
219 | * (i.e. state too large) | 243 | * (i.e. state too large) |
220 | */ | 244 | */ |
221 | int | 245 | int |
222 | GNUNET_PSYC_channel_update (struct GNUNET_PSYC_Channel *channel, | 246 | GNUNET_PSYC_channel_state_update (struct GNUNET_PSYC_Channel *channel, |
223 | const char *full_state_name, | 247 | const char *full_state_name, |
224 | enum GNUNET_PSYC_Operator type, | 248 | enum GNUNET_PSYC_Operator type, |
225 | size_t data_size, | 249 | size_t data_size, |
226 | const void *data); | 250 | const void *data); |
227 | 251 | ||
228 | 252 | ||
229 | /** | 253 | /** |
@@ -243,7 +267,7 @@ GNUNET_PSYC_channel_update (struct GNUNET_PSYC_Channel *channel, | |||
243 | * @return GNUNET_SYSERR on error (fatal, aborts transmission) | 267 | * @return GNUNET_SYSERR on error (fatal, aborts transmission) |
244 | * GNUNET_NO on success, if more data is to be transmitted later | 268 | * GNUNET_NO on success, if more data is to be transmitted later |
245 | * (should be used if 'data_size' was not big enough to take all the data) | 269 | * (should be used if 'data_size' was not big enough to take all the data) |
246 | * GNUNET_OK if this completes the transmission (all data supplied) | 270 | * GNUNET_YES if this completes the transmission (all data supplied) |
247 | */ | 271 | */ |
248 | typedef int (*GNUNET_PSYC_ChannelReadyNotify)(void *cls, | 272 | typedef int (*GNUNET_PSYC_ChannelReadyNotify)(void *cls, |
249 | uint64_t message_id, | 273 | uint64_t message_id, |
@@ -429,9 +453,9 @@ struct GNUNET_PSYC_StateHandler | |||
429 | * | 453 | * |
430 | * @param cfg configuration to use | 454 | * @param cfg configuration to use |
431 | * @param pub_key ECC key that identifies the channel we wish to join | 455 | * @param pub_key ECC key that identifies the channel we wish to join |
432 | * @param method_count number of methods in 'methods' array | 456 | * @param method function to invoke on messages received from the channel, |
433 | * @param methods functions to invoke on messages received from the channel, | ||
434 | * typcially at least contains functions for 'join' and 'leave'. | 457 | * typcially at least contains functions for 'join' and 'leave'. |
458 | * @param method_cls closure for 'method' | ||
435 | * @param state_count number of state handlers | 459 | * @param state_count number of state handlers |
436 | * @param state_handlers array of state event handlers | 460 | * @param state_handlers array of state event handlers |
437 | * @return handle for the member, NULL on error | 461 | * @return handle for the member, NULL on error |
@@ -439,8 +463,8 @@ struct GNUNET_PSYC_StateHandler | |||
439 | struct GNUNET_PSYC_Member * | 463 | struct GNUNET_PSYC_Member * |
440 | GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | 464 | GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, |
441 | const struct GNUNET_CRYPTO_EccPublicKey *pub_key, | 465 | const struct GNUNET_CRYPTO_EccPublicKey *pub_key, |
442 | unsigned int method_count, | 466 | GNUNET_PSYC_Method method, |
443 | const struct GNUNET_PSYC_Method *methods, | 467 | void *method_cls, |
444 | unsigned int state_count, | 468 | unsigned int state_count, |
445 | struct GNUNET_PSYC_StateHandler *state_handlers); | 469 | struct GNUNET_PSYC_StateHandler *state_handlers); |
446 | 470 | ||
@@ -469,17 +493,17 @@ GNUNET_PSYC_member_leave (struct GNUNET_PSYC_Member *member); | |||
469 | * function must copy at most '*data_size' bytes to 'data'. | 493 | * function must copy at most '*data_size' bytes to 'data'. |
470 | * @return GNUNET_SYSERR on error (fatal, aborts transmission) | 494 | * @return GNUNET_SYSERR on error (fatal, aborts transmission) |
471 | * GNUNET_NO on success, if more data is to be transmitted later | 495 | * GNUNET_NO on success, if more data is to be transmitted later |
472 | * GNUNET_OK if this completes the transmission (all data supplied) | 496 | * GNUNET_YES if this completes the transmission (all data supplied) |
473 | */ | 497 | */ |
474 | typedef int (*GNUNET_PSYC_HostReadyNotify)(void *cls, | 498 | typedef int (*GNUNET_PSYC_OriginReadyNotify)(void *cls, |
475 | size_t *data_size, | 499 | size_t *data_size, |
476 | char *data); | 500 | char *data); |
477 | 501 | ||
478 | 502 | ||
479 | /** | 503 | /** |
480 | * Handle for a pending PSYC transmission operation. | 504 | * Handle for a pending PSYC transmission operation. |
481 | */ | 505 | */ |
482 | struct GNUNET_PSYC_HostTransmitHandle; | 506 | struct GNUNET_PSYC_OriginTransmitHandle; |
483 | 507 | ||
484 | 508 | ||
485 | /** | 509 | /** |
@@ -491,11 +515,11 @@ struct GNUNET_PSYC_HostTransmitHandle; | |||
491 | * @param notify_cls closure for 'notify' | 515 | * @param notify_cls closure for 'notify' |
492 | * @return transmission handle, NULL on error (i.e. more than one request queued) | 516 | * @return transmission handle, NULL on error (i.e. more than one request queued) |
493 | */ | 517 | */ |
494 | struct GNUNET_PSYC_HostTransmitHandle * | 518 | struct GNUNET_PSYC_OriginTransmitHandle * |
495 | GNUNET_PSYC_member_send_to_host (struct GNUNET_PSYC_Member *member, | 519 | GNUNET_PSYC_member_send_to_origin (struct GNUNET_PSYC_Member *member, |
496 | const char *method_name, | 520 | const char *method_name, |
497 | GNUNET_PSYC_HostReadyNotify notify, | 521 | GNUNET_PSYC_OriginReadyNotify notify, |
498 | void *notify_cls); | 522 | void *notify_cls); |
499 | 523 | ||
500 | 524 | ||
501 | /** | 525 | /** |
@@ -511,19 +535,19 @@ GNUNET_PSYC_member_send_to_host (struct GNUNET_PSYC_Member *member, | |||
511 | * @param value_size number of bytes in 'value' | 535 | * @param value_size number of bytes in 'value' |
512 | */ | 536 | */ |
513 | uint64_t | 537 | uint64_t |
514 | GNUNET_PSYC_member_host_variable_set (struct GNUNET_PSYC_Member *member, | 538 | GNUNET_PSYC_member_origin_variable_set (struct GNUNET_PSYC_Member *member, |
515 | const char *variable_name, | 539 | const char *variable_name, |
516 | const void *value, | 540 | const void *value, |
517 | size_t value_size); | 541 | size_t value_size); |
518 | 542 | ||
519 | 543 | ||
520 | /** | 544 | /** |
521 | * Abort transmission request to host. | 545 | * Abort transmission request to origin. |
522 | * | 546 | * |
523 | * @param th handle of the request that is being aborted | 547 | * @param th handle of the request that is being aborted |
524 | */ | 548 | */ |
525 | void | 549 | void |
526 | GNUNET_PSYC_member_send_to_host_cancel (struct GNUNET_PSYC_HostTransmitHandle *th); | 550 | GNUNET_PSYC_member_send_to_origin_cancel (struct GNUNET_PSYC_OriginTransmitHandle *th); |
527 | 551 | ||
528 | 552 | ||
529 | /** | 553 | /** |
@@ -541,6 +565,8 @@ struct GNUNET_PSYC_Story; | |||
541 | * @param member which channel should be replayed? | 565 | * @param member which channel should be replayed? |
542 | * @param start earliest interesting point in history | 566 | * @param start earliest interesting point in history |
543 | * @param end last (exclusive) interesting point in history | 567 | * @param end last (exclusive) interesting point in history |
568 | * @param method function to invoke on messages received from the story | ||
569 | * @param method_cls closure for 'method' | ||
544 | * @param finish_cb function to call when the requested story has been fully | 570 | * @param finish_cb function to call when the requested story has been fully |
545 | * told (counting message IDs might not suffice, as some messages | 571 | * told (counting message IDs might not suffice, as some messages |
546 | * might be secret and thus the listener would not know the story is | 572 | * might be secret and thus the listener would not know the story is |
@@ -554,6 +580,8 @@ struct GNUNET_PSYC_Story * | |||
554 | GNUNET_PSYC_member_story_tell (struct GNUNET_PSYC_Member *member, | 580 | GNUNET_PSYC_member_story_tell (struct GNUNET_PSYC_Member *member, |
555 | uint64_t start, | 581 | uint64_t start, |
556 | uint64_t end, | 582 | uint64_t end, |
583 | GNUNET_PSYC_Method method, | ||
584 | void *method_cls, | ||
557 | void (*finish_cb)(void *), | 585 | void (*finish_cb)(void *), |
558 | void *finish_cb_cls); | 586 | void *finish_cb_cls); |
559 | 587 | ||