| gnunet_bandwidth_lib.h | | gnunet_bandwidth_lib.h | |
| | | | |
| skipping to change at line 56 | | skipping to change at line 56 | |
| struct GNUNET_BANDWIDTH_Value32NBO | | struct GNUNET_BANDWIDTH_Value32NBO | |
| { | | { | |
| /** | | /** | |
| * The actual value (bytes per second). | | * The actual value (bytes per second). | |
| */ | | */ | |
| uint32_t value__ GNUNET_PACKED; | | uint32_t value__ GNUNET_PACKED; | |
| }; | | }; | |
| GNUNET_NETWORK_STRUCT_END | | GNUNET_NETWORK_STRUCT_END | |
| | | | |
| /** | | /** | |
|
| | | * Callback to be called by the bandwidth tracker if the tracker | |
| | | * was updated and the client should update it's delay values | |
| | | * | |
| | | * @param cls a closure to pass | |
| | | */ | |
| | | typedef void | |
| | | (*GNUNET_BANDWIDTH_TrackerUpdateCallback) (void *cls); | |
| | | | |
| | | /** | |
| | | * Callback to be called by the bandwidth tracker if the tracker | |
| | | * was updated and the client should update it's delay values | |
| | | * | |
| | | * @param cls a closure to pass | |
| | | */ | |
| | | typedef void | |
| | | (*GNUNET_BANDWIDTH_ExcessNotificationCallback) (void *cls); | |
| | | | |
| | | /** | |
| * Struct to track available bandwidth. Combines a time stamp with a | | * Struct to track available bandwidth. Combines a time stamp with a | |
| * number of bytes transmitted, a quota and a maximum amount that | | * number of bytes transmitted, a quota and a maximum amount that | |
| * carries over. Not opaque so that it can be inlined into data | | * carries over. Not opaque so that it can be inlined into data | |
| * structures (reducing malloc-ing); however, values should not be | | * structures (reducing malloc-ing); however, values should not be | |
| * accessed directly by clients (hence the '__'). | | * accessed directly by clients (hence the '__'). | |
| */ | | */ | |
| struct GNUNET_BANDWIDTH_Tracker | | struct GNUNET_BANDWIDTH_Tracker | |
| { | | { | |
| /** | | /** | |
|
| | | * Closure for @e update_cb. | |
| | | */ | |
| | | void *update_cb_cls; | |
| | | | |
| | | /** | |
| | | * Function we call if the tracker's bandwidth is increased and a | |
| | | * previously returned timeout might now expire earlier. | |
| | | */ | |
| | | GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb; | |
| | | | |
| | | /** | |
| | | * Closure for @e excess_cb. | |
| | | */ | |
| | | void *excess_cb_cls; | |
| | | | |
| | | /** | |
| | | * Function we call if the tracker is about to throw | |
| | | * away bandwidth due to excess (max carry exceeded). | |
| | | */ | |
| | | GNUNET_BANDWIDTH_ExcessNotificationCallback excess_cb; | |
| | | | |
| | | /** | |
| * Number of bytes consumed since we last updated the tracker. | | * Number of bytes consumed since we last updated the tracker. | |
| */ | | */ | |
| int64_t consumption_since_last_update__; | | int64_t consumption_since_last_update__; | |
| | | | |
| /** | | /** | |
|
| | | * Task scheduled to call the @e excess_cb once we have | |
| | | * reached the maximum bandwidth the tracker can hold. | |
| | | */ | |
| | | GNUNET_SCHEDULER_TaskIdentifier excess_task; | |
| | | | |
| | | /** | |
| * Time when we last updated the tracker. | | * Time when we last updated the tracker. | |
| */ | | */ | |
| struct GNUNET_TIME_Absolute last_update__; | | struct GNUNET_TIME_Absolute last_update__; | |
| | | | |
| /** | | /** | |
| * Bandwidth limit to enforce in bytes per s. | | * Bandwidth limit to enforce in bytes per s. | |
| */ | | */ | |
| uint32_t available_bytes_per_s__; | | uint32_t available_bytes_per_s__; | |
| | | | |
| /** | | /** | |
| * Maximum number of seconds over which bandwidth may "accumulate". | | * Maximum number of seconds over which bandwidth may "accumulate". | |
| * Note that additionally, we also always allow at least | | * Note that additionally, we also always allow at least | |
|
| * GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. | | * #GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. | |
| */ | | */ | |
| uint32_t max_carry_s__; | | uint32_t max_carry_s__; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Create a new bandwidth value. | | * Create a new bandwidth value. | |
| * | | * | |
| * @param bytes_per_second value to create | | * @param bytes_per_second value to create | |
| * @return the new bandwidth value | | * @return the new bandwidth value | |
| */ | | */ | |
| | | | |
| skipping to change at line 110 | | skipping to change at line 156 | |
| | | | |
| /** | | /** | |
| * At the given bandwidth, calculate how much traffic will be | | * At the given bandwidth, calculate how much traffic will be | |
| * available until the given deadline. | | * available until the given deadline. | |
| * | | * | |
| * @param bps bandwidth | | * @param bps bandwidth | |
| * @param deadline when is the deadline | | * @param deadline when is the deadline | |
| * @return number of bytes available at bps until deadline | | * @return number of bytes available at bps until deadline | |
| */ | | */ | |
| uint64_t | | uint64_t | |
|
| GNUNET_BANDWIDTH_value_get_available_until (struct GNUNET_BANDWIDTH_Value32 | | GNUNET_BANDWIDTH_value_get_available_until (struct GNUNET_BANDWIDTH_Value32 | |
| NBO | | NBO bps, | |
| bps, | | struct GNUNET_TIME_Relative dea | |
| struct GNUNET_TIME_Relative | | dline); | |
| deadline); | | | |
| | | | |
| /** | | /** | |
| * At the given bandwidth, calculate how long it would take for | | * At the given bandwidth, calculate how long it would take for | |
| * 'size' bytes to be transmitted. | | * 'size' bytes to be transmitted. | |
| * | | * | |
| * @param bps bandwidth | | * @param bps bandwidth | |
| * @param size number of bytes we want to have available | | * @param size number of bytes we want to have available | |
| * @return how long it would take | | * @return how long it would take | |
| */ | | */ | |
| struct GNUNET_TIME_Relative | | struct GNUNET_TIME_Relative | |
| | | | |
| skipping to change at line 148 | | skipping to change at line 192 | |
| /** | | /** | |
| * Initialize bandwidth tracker. Note that in addition to the | | * Initialize bandwidth tracker. Note that in addition to the | |
| * 'max_carry_s' limit, we also always allow at least | | * 'max_carry_s' limit, we also always allow at least | |
| * GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the | | * GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the | |
| * bytes-per-second limit is so small that within 'max_carry_s' not | | * bytes-per-second limit is so small that within 'max_carry_s' not | |
| * even GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is | | * even GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is | |
| * ignored and replaced by GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in | | * ignored and replaced by GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in | |
| * bytes). | | * bytes). | |
| * | | * | |
| * @param av tracker to initialize | | * @param av tracker to initialize | |
|
| | | * @param update_cb callback to notify a client about the tracker being upd | |
| | | ated | |
| | | * @param update_cb_cls cls for the callback | |
| * @param bytes_per_second_limit initial limit to assume | | * @param bytes_per_second_limit initial limit to assume | |
| * @param max_carry_s maximum number of seconds unused bandwidth | | * @param max_carry_s maximum number of seconds unused bandwidth | |
| * may accumulate before it expires | | * may accumulate before it expires | |
| */ | | */ | |
| void | | void | |
| GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av, | | GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av, | |
|
| struct GNUNET_BANDWIDTH_Value32NBO | | GNUNET_BANDWIDTH_TrackerUpdateCallback updat | |
| bytes_per_second_limit, uint32_t max_carry_s | | e_cb, | |
| ); | | void *update_cb_cls, | |
| | | struct GNUNET_BANDWIDTH_Value32NBO bytes_per | |
| | | _second_limit, | |
| | | uint32_t max_carry_s); | |
| | | | |
| | | /** | |
| | | * Initialize bandwidth tracker. Note that in addition to the | |
| | | * 'max_carry_s' limit, we also always allow at least | |
| | | * GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the | |
| | | * bytes-per-second limit is so small that within 'max_carry_s' not | |
| | | * even GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is | |
| | | * ignored and replaced by GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in | |
| | | * bytes). | |
| | | * | |
| | | * @param av tracker to initialize | |
| | | * @param update_cb callback to notify a client about the tracker being upd | |
| | | ated | |
| | | * @param update_cb_cls cls for the @a update_cb callback | |
| | | * @param bytes_per_second_limit initial limit to assume | |
| | | * @param max_carry_s maximum number of seconds unused bandwidth | |
| | | * may accumulate before it expires | |
| | | * @param excess_cb callback to notify if we have excess bandwidth | |
| | | * @param excess_cb_cls closure for @a excess_cb | |
| | | */ | |
| | | void | |
| | | GNUNET_BANDWIDTH_tracker_init2 (struct GNUNET_BANDWIDTH_Tracker *av, | |
| | | GNUNET_BANDWIDTH_TrackerUpdateCallback upda | |
| | | te_cb, | |
| | | void *update_cb_cls, | |
| | | struct GNUNET_BANDWIDTH_Value32NBO bytes_pe | |
| | | r_second_limit, | |
| | | uint32_t max_carry_s, | |
| | | GNUNET_BANDWIDTH_ExcessNotificationCallback | |
| | | excess_cb, | |
| | | void *excess_cb_cls); | |
| | | | |
| | | /** | |
| | | * Stop notifying about tracker updates and excess notifications | |
| | | * | |
| | | * @param av the respective trackers | |
| | | */ | |
| | | void | |
| | | GNUNET_BANDWIDTH_tracker_notification_stop (struct GNUNET_BANDWIDTH_Tracker | |
| | | *av); | |
| | | | |
| /** | | /** | |
| * Notify the tracker that a certain number of bytes of bandwidth have | | * Notify the tracker that a certain number of bytes of bandwidth have | |
| * been consumed. Note that it is legal to consume bytes even if not | | * been consumed. Note that it is legal to consume bytes even if not | |
| * enough bandwidth is available (in that case, | | * enough bandwidth is available (in that case, | |
|
| * GNUNET_BANDWIDTH_tracker_get_delay may return non-zero delay values | | * #GNUNET_BANDWIDTH_tracker_get_delay() may return non-zero delay values | |
| * even for a size of zero for a while). | | * even for a size of zero for a while). | |
| * | | * | |
| * @param av tracker to update | | * @param av tracker to update | |
| * @param size number of bytes consumed | | * @param size number of bytes consumed | |
|
| * @return GNUNET_YES if this consumption is above the limit | | * @return #GNUNET_YES if this consumption is above the limit | |
| */ | | */ | |
| int | | int | |
| GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, | | GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, | |
| ssize_t size); | | ssize_t size); | |
| | | | |
| /** | | /** | |
| * Compute how long we should wait until consuming 'size' | | * Compute how long we should wait until consuming 'size' | |
| * bytes of bandwidth in order to stay within the given | | * bytes of bandwidth in order to stay within the given | |
| * quota. | | * quota. | |
| * | | * | |
| | | | |
End of changes. 9 change blocks. |
| 11 lines changed or deleted | | 102 lines changed or added | |
|
| gnunet_configuration_lib.h | | gnunet_configuration_lib.h | |
| | | | |
| skipping to change at line 153 | | skipping to change at line 153 | |
| const char *filename); | | const char *filename); | |
| | | | |
| /** | | /** | |
| * Write only configuration entries that have been changed to configuration
file | | * Write only configuration entries that have been changed to configuration
file | |
| * @param cfg_default default configuration | | * @param cfg_default default configuration | |
| * @param cfg_new new configuration | | * @param cfg_new new configuration | |
| * @param filename where to write the configuration diff between default an
d new | | * @param filename where to write the configuration diff between default an
d new | |
| * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | |
| */ | | */ | |
| int | | int | |
|
| GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle | | GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle | |
| *cfg_default, | | *cfg_default, | |
| const struct GNUNET_CONFIGURATION_Handle | | const struct GNUNET_CONFIGURATION_Handle | |
| *cfg_new, const char *filename); | | *cfg_new, | |
| | | const char *filename); | |
| | | | |
| /** | | /** | |
| * Compute configuration with only entries that have been changed | | * Compute configuration with only entries that have been changed | |
| * | | * | |
| * @param cfg_default original configuration | | * @param cfg_default original configuration | |
| * @param cfg_new new configuration | | * @param cfg_new new configuration | |
| * @return configuration with only the differences, never NULL | | * @return configuration with only the differences, never NULL | |
| */ | | */ | |
| struct GNUNET_CONFIGURATION_Handle * | | struct GNUNET_CONFIGURATION_Handle * | |
|
| GNUNET_CONFIGURATION_get_diff (const struct GNUNET_CONFIGURATION_Handle | | GNUNET_CONFIGURATION_get_diff (const struct GNUNET_CONFIGURATION_Handle *cf | |
| *cfg_default, | | g_default, | |
| const struct GNUNET_CONFIGURATION_Handle | | const struct GNUNET_CONFIGURATION_Handle *cfg | |
| *cfg_new); | | _new); | |
| | | | |
| /** | | /** | |
| * Test if there are configuration options that were | | * Test if there are configuration options that were | |
| * changed since the last save. | | * changed since the last save. | |
| * | | * | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @return #GNUNET_NO if clean, #GNUNET_YES if dirty, #GNUNET_SYSERR on err
or (i.e. last save failed) | | * @return #GNUNET_NO if clean, #GNUNET_YES if dirty, #GNUNET_SYSERR on err
or (i.e. last save failed) | |
| */ | | */ | |
| int | | int | |
| GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cf
g); | | GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cf
g); | |
| | | | |
| /** | | /** | |
| * Function to iterate over options. | | * Function to iterate over options. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param section name of the section | | * @param section name of the section | |
| * @param option name of the option | | * @param option name of the option | |
| * @param value value of the option | | * @param value value of the option | |
| */ | | */ | |
|
| typedef void (*GNUNET_CONFIGURATION_Iterator) (void *cls, const char *secti | | typedef void | |
| on, | | (*GNUNET_CONFIGURATION_Iterator) (void *cls, | |
| const char *option, | | const char *section, | |
| const char *value); | | const char *option, | |
| | | const char *value); | |
| | | | |
| /** | | /** | |
| * Function to iterate over section. | | * Function to iterate over section. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param section name of the section | | * @param section name of the section | |
| */ | | */ | |
|
| typedef void (*GNUNET_CONFIGURATION_Section_Iterator) (void *cls, | | typedef void | |
| const char *section) | | (*GNUNET_CONFIGURATION_Section_Iterator) (void *cls, | |
| ; | | const char *section); | |
| | | | |
| /** | | /** | |
| * Iterate over all options in the configuration. | | * Iterate over all options in the configuration. | |
| * | | * | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @param iter function to call on each option | | * @param iter function to call on each option | |
|
| * @param iter_cls closure for iter | | * @param iter_cls closure for @a iter | |
| */ | | */ | |
| void | | void | |
| GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg
, | | GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg
, | |
| GNUNET_CONFIGURATION_Iterator iter, | | GNUNET_CONFIGURATION_Iterator iter, | |
| void *iter_cls); | | void *iter_cls); | |
| | | | |
| /** | | /** | |
| * Iterate over all sections in the configuration. | | * Iterate over all sections in the configuration. | |
| * | | * | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @param iter function to call on each section | | * @param iter function to call on each section | |
|
| * @param iter_cls closure for iter | | * @param iter_cls closure for @a iter | |
| */ | | */ | |
| void | | void | |
|
| GNUNET_CONFIGURATION_iterate_sections (const struct GNUNET_CONFIGURATION_Ha | | GNUNET_CONFIGURATION_iterate_sections (const struct GNUNET_CONFIGURATION_Ha | |
| ndle | | ndle *cfg, | |
| *cfg, | | GNUNET_CONFIGURATION_Section_Iterato | |
| GNUNET_CONFIGURATION_Section_Iterato | | r iter, | |
| r | | void *iter_cls); | |
| iter, void *iter_cls); | | | |
| | | | |
| /** | | /** | |
| * Remove the given section and all options in it. | | * Remove the given section and all options in it. | |
| * | | * | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @param section name of the section to remove | | * @param section name of the section to remove | |
| */ | | */ | |
| void | | void | |
| GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cf
g, | | GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cf
g, | |
| const char *section); | | const char *section); | |
| | | | |
| skipping to change at line 247 | | skipping to change at line 246 | |
| /** | | /** | |
| * Get a configuration value that should be a number. | | * Get a configuration value that should be a number. | |
| * | | * | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @param section section of interest | | * @param section section of interest | |
| * @param option option of interest | | * @param option option of interest | |
| * @param number where to store the numeric value of the option | | * @param number where to store the numeric value of the option | |
| * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | |
| */ | | */ | |
| int | | int | |
|
| GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Ha | | GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Ha | |
| ndle | | ndle *cfg, | |
| *cfg, const char *section, | | const char *section, | |
| const char *option, | | const char *option, | |
| unsigned long long *number); | | unsigned long long *number); | |
| | | | |
| /** | | /** | |
| * Get a configuration value that should be a relative time. | | * Get a configuration value that should be a relative time. | |
| * | | * | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @param section section of interest | | * @param section section of interest | |
| * @param option option of interest | | * @param option option of interest | |
| * @param time set to the time value stored in the configuration | | * @param time set to the time value stored in the configuration | |
| * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | |
| */ | | */ | |
| int | | int | |
|
| GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Hand | | GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Hand | |
| le | | le *cfg, | |
| *cfg, const char *section, | | const char *section, | |
| const char *option, | | const char *option, | |
| struct GNUNET_TIME_Relative *time); | | struct GNUNET_TIME_Relative *time); | |
| | | | |
| /** | | /** | |
| * Get a configuration value that should be a size in bytes. | | * Get a configuration value that should be a size in bytes. | |
| * | | * | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @param section section of interest | | * @param section section of interest | |
| * @param option option of interest | | * @param option option of interest | |
| * @param size set to the size in bytes as stored in the configuration | | * @param size set to the size in bytes as stored in the configuration | |
| * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | |
| */ | | */ | |
| int | | int | |
|
| GNUNET_CONFIGURATION_get_value_size (const struct GNUNET_CONFIGURATION_Hand | | GNUNET_CONFIGURATION_get_value_size (const struct GNUNET_CONFIGURATION_Hand | |
| le | | le *cfg, | |
| *cfg, const char *section, | | const char *section, | |
| const char *option, | | const char *option, | |
| unsigned long long *size); | | unsigned long long *size); | |
| | | | |
| /** | | /** | |
| * Test if we have a value for a particular option | | * Test if we have a value for a particular option | |
| * | | * | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @param section section of interest | | * @param section section of interest | |
| * @param option option of interest | | * @param option option of interest | |
| * @return #GNUNET_YES if so, #GNUNET_NO if not. | | * @return #GNUNET_YES if so, #GNUNET_NO if not. | |
| */ | | */ | |
| int | | int | |
| GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *
cfg, | | GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *
cfg, | |
|
| const char *section, const char *option); | | const char *section, | |
| | | const char *option); | |
| | | | |
| /** | | /** | |
| * Get a configuration value that should be a string. | | * Get a configuration value that should be a string. | |
| * | | * | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @param section section of interest | | * @param section section of interest | |
| * @param option option of interest | | * @param option option of interest | |
| * @param value will be set to a freshly allocated configuration | | * @param value will be set to a freshly allocated configuration | |
| * value, or NULL if option is not specified | | * value, or NULL if option is not specified | |
| * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | |
| | | | |
| skipping to change at line 324 | | skipping to change at line 324 | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @param section section of interest | | * @param section section of interest | |
| * @param option option of interest | | * @param option option of interest | |
| * @param value will be set to a freshly allocated configuration | | * @param value will be set to a freshly allocated configuration | |
| * value, or NULL if option is not specified | | * value, or NULL if option is not specified | |
| * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | |
| */ | | */ | |
| int | | int | |
| GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_
Handle *cfg, | | GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_
Handle *cfg, | |
| const char *section, | | const char *section, | |
|
| const char *option, char **value); | | const char *option, | |
| | | char **value); | |
| | | | |
| /** | | /** | |
| * Iterate over the set of filenames stored in a configuration value. | | * Iterate over the set of filenames stored in a configuration value. | |
| * | | * | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @param section section of interest | | * @param section section of interest | |
| * @param option option of interest | | * @param option option of interest | |
| * @param cb function to call on each filename | | * @param cb function to call on each filename | |
| * @param cb_cls closure for @a cb | | * @param cb_cls closure for @a cb | |
| * @return number of filenames iterated over, -1 on error | | * @return number of filenames iterated over, -1 on error | |
| */ | | */ | |
| int | | int | |
|
| GNUNET_CONFIGURATION_iterate_value_filenames (const struct | | GNUNET_CONFIGURATION_iterate_value_filenames (const struct GNUNET_CONFIGURA | |
| GNUNET_CONFIGURATION_Handle * | | TION_Handle *cfg, | |
| cfg, | | | |
| const char *section, | | const char *section, | |
| const char *option, | | const char *option, | |
| GNUNET_FileNameCallback cb, | | GNUNET_FileNameCallback cb, | |
| void *cb_cls); | | void *cb_cls); | |
| | | | |
| /** | | /** | |
| * Iterate over values of a section in the configuration. | | * Iterate over values of a section in the configuration. | |
| * | | * | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @param section the section | | * @param section the section | |
| * @param iter function to call on each option | | * @param iter function to call on each option | |
| * @param iter_cls closure for @a iter | | * @param iter_cls closure for @a iter | |
| */ | | */ | |
| void | | void | |
|
| GNUNET_CONFIGURATION_iterate_section_values (const struct | | GNUNET_CONFIGURATION_iterate_section_values (const struct GNUNET_CONFIGURAT | |
| GNUNET_CONFIGURATION_Handle *c | | ION_Handle *cfg, | |
| fg, | | | |
| const char *section, | | const char *section, | |
| GNUNET_CONFIGURATION_Iterator
iter, | | GNUNET_CONFIGURATION_Iterator
iter, | |
| void *iter_cls); | | void *iter_cls); | |
| | | | |
| /** | | /** | |
| * Get a configuration value that should be in a set of | | * Get a configuration value that should be in a set of | |
| * predefined strings | | * predefined strings | |
| * | | * | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @param section section of interest | | * @param section section of interest | |
| * @param option option of interest | | * @param option option of interest | |
| * @param choices NULL-terminated list of legal values | | * @param choices NULL-terminated list of legal values | |
| * @param value will be set to an entry in the legal list, | | * @param value will be set to an entry in the legal list, | |
| * or NULL if option is not specified and no default given | | * or NULL if option is not specified and no default given | |
| * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | |
| */ | | */ | |
| int | | int | |
|
| GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Ha | | GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Ha | |
| ndle | | ndle *cfg, | |
| *cfg, const char *section, | | const char *section, | |
| const char *option, const char *cons | | const char *option, | |
| t *choices, | | const char *const *choices, | |
| const char **value); | | const char **value); | |
| | | | |
| /** | | /** | |
| * Get a configuration value that should be in a set of | | * Get a configuration value that should be in a set of | |
| * "YES" or "NO". | | * "YES" or "NO". | |
| * | | * | |
| * @param cfg configuration to inspect | | * @param cfg configuration to inspect | |
| * @param section section of interest | | * @param section section of interest | |
| * @param option option of interest | | * @param option option of interest | |
| * @return #GNUNET_YES, #GNUNET_NO or if option has no valid value, #GNUNET
_SYSERR | | * @return #GNUNET_YES, #GNUNET_NO or if option has no valid value, #GNUNET
_SYSERR | |
| */ | | */ | |
| int | | int | |
|
| GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Han | | GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Han | |
| dle | | dle *cfg, | |
| *cfg, const char *section, | | const char *section, | |
| const char *option); | | const char *option); | |
| | | | |
| /** | | /** | |
| * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" | | * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" | |
| * where either in the "PATHS" section or the environtment "FOO" is | | * where either in the "PATHS" section or the environtment "FOO" is | |
| * set to "DIRECTORY". We also support default expansion, | | * set to "DIRECTORY". We also support default expansion, | |
| * i.e. ${VARIABLE:-default} will expand to $VARIABLE if VARIABLE is | | * i.e. ${VARIABLE:-default} will expand to $VARIABLE if VARIABLE is | |
| * set in PATHS or the environment, and otherwise to "default". Note | | * set in PATHS or the environment, and otherwise to "default". Note | |
| * that "default" itself can also be a $-expression, thus | | * that "default" itself can also be a $-expression, thus | |
| * "${VAR1:-{$VAR2}}" will expand to VAR1 and if that is not defined | | * "${VAR1:-{$VAR2}}" will expand to VAR1 and if that is not defined | |
| * to VAR2. | | * to VAR2. | |
| * | | * | |
| * @param cfg configuration to use for path expansion | | * @param cfg configuration to use for path expansion | |
| * @param orig string to $-expand (will be freed!) Note that multiple | | * @param orig string to $-expand (will be freed!) Note that multiple | |
| * $-expressions can be present in this string. They will all be | | * $-expressions can be present in this string. They will all be | |
| * $-expanded. | | * $-expanded. | |
| * @return $-expanded string | | * @return $-expanded string | |
| */ | | */ | |
| char * | | char * | |
|
| GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handl | | GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handl | |
| e | | e *cfg, | |
| *cfg, char *orig); | | char *orig); | |
| | | | |
| /** | | /** | |
| * Set a configuration value that should be a number. | | * Set a configuration value that should be a number. | |
| * | | * | |
| * @param cfg configuration to update | | * @param cfg configuration to update | |
| * @param section section of interest | | * @param section section of interest | |
| * @param option option of interest | | * @param option option of interest | |
| * @param number value to set | | * @param number value to set | |
| */ | | */ | |
| void | | void | |
| GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *
cfg, | | GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *
cfg, | |
|
| const char *section, const char *opt | | const char *section, | |
| ion, | | const char *option, | |
| unsigned long long number); | | unsigned long long number); | |
| | | | |
| /** | | /** | |
| * Set a configuration value that should be a string. | | * Set a configuration value that should be a string. | |
| * | | * | |
| * @param cfg configuration to update | | * @param cfg configuration to update | |
| * @param section section of interest | | * @param section section of interest | |
| * @param option option of interest | | * @param option option of interest | |
| * @param value value to set | | * @param value value to set | |
| */ | | */ | |
| void | | void | |
| GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *
cfg, | | GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *
cfg, | |
|
| const char *section, const char *opt | | const char *section, | |
| ion, | | const char *option, | |
| const char *value); | | const char *value); | |
| | | | |
| /** | | /** | |
| * Remove a filename from a configuration value that | | * Remove a filename from a configuration value that | |
| * represents a list of filenames | | * represents a list of filenames | |
| * | | * | |
| * @param cfg configuration to update | | * @param cfg configuration to update | |
| * @param section section of interest | | * @param section section of interest | |
| * @param option option of interest | | * @param option option of interest | |
| * @param value filename to remove | | * @param value filename to remove | |
| * @return #GNUNET_OK on success, | | * @return #GNUNET_OK on success, | |
| * #GNUNET_SYSERR if the filename is not in the list | | * #GNUNET_SYSERR if the filename is not in the list | |
| */ | | */ | |
| int | | int | |
|
| GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Han | | GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Han | |
| dle | | dle *cfg, | |
| *cfg, const char *section, | | const char *section, | |
| const char *option, | | const char *option, | |
| const char *value); | | const char *value); | |
| | | | |
| /** | | /** | |
| * Append a filename to a configuration value that | | * Append a filename to a configuration value that | |
| * represents a list of filenames | | * represents a list of filenames | |
| * | | * | |
| * @param cfg configuration to update | | * @param cfg configuration to update | |
| * @param section section of interest | | * @param section section of interest | |
| * @param option option of interest | | * @param option option of interest | |
| * @param value filename to append | | * @param value filename to append | |
| * @return #GNUNET_OK on success, | | * @return #GNUNET_OK on success, | |
| * #GNUNET_SYSERR if the filename already in the list | | * #GNUNET_SYSERR if the filename already in the list | |
| */ | | */ | |
| int | | int | |
|
| GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Han | | GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Han | |
| dle | | dle *cfg, | |
| *cfg, const char *section, | | const char *section, | |
| const char *option, | | const char *option, | |
| const char *value); | | const char *value); | |
| | | | |
| /** @} */ /* end of group configuration */ | | /** @} */ /* end of group configuration */ | |
| | | | |
| #if 0 /* keep Emacsens' auto-indent happy */ | | #if 0 /* keep Emacsens' auto-indent happy */ | |
| { | | { | |
| #endif | | #endif | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| | | | |
End of changes. 21 change blocks. |
| 61 lines changed or deleted | | 62 lines changed or added | |
|
| gnunet_core_service.h | | gnunet_core_service.h | |
| | | | |
| skipping to change at line 50 | | skipping to change at line 50 | |
| | | | |
| #include "gnunet_util_lib.h" | | #include "gnunet_util_lib.h" | |
| #include "gnunet_transport_service.h" | | #include "gnunet_transport_service.h" | |
| | | | |
| /** | | /** | |
| * Version number of GNUnet-core API. | | * Version number of GNUnet-core API. | |
| */ | | */ | |
| #define GNUNET_CORE_VERSION 0x00000001 | | #define GNUNET_CORE_VERSION 0x00000001 | |
| | | | |
| /** | | /** | |
|
| | | * Traffic priorities. | |
| | | */ | |
| | | enum GNUNET_CORE_Priority | |
| | | { | |
| | | | |
| | | /** | |
| | | * Lowest priority, i.e. background traffic (i.e. fs) | |
| | | */ | |
| | | GNUNET_CORE_PRIO_BACKGROUND = 0, | |
| | | | |
| | | /** | |
| | | * Normal traffic (i.e. mesh/dv relay, DHT) | |
| | | */ | |
| | | GNUNET_CORE_PRIO_BEST_EFFORT = 1, | |
| | | | |
| | | /** | |
| | | * Urgent traffic (local peer, i.e. conversation). | |
| | | */ | |
| | | GNUNET_CORE_PRIO_URGENT = 2, | |
| | | | |
| | | /** | |
| | | * Highest priority, control traffic (i.e. NSE, Core/Mesh KX). | |
| | | */ | |
| | | GNUNET_CORE_PRIO_CRITICAL_CONTROL = 3 | |
| | | | |
| | | }; | |
| | | | |
| | | /** | |
| * Opaque handle to the service. | | * Opaque handle to the service. | |
| */ | | */ | |
| struct GNUNET_CORE_Handle; | | struct GNUNET_CORE_Handle; | |
| | | | |
| /** | | /** | |
| * Method called whenever a given peer connects. | | * Method called whenever a given peer connects. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param peer peer identity this notification is about | | * @param peer peer identity this notification is about | |
| */ | | */ | |
|
| typedef void (*GNUNET_CORE_ConnectEventHandler) (void *cls, | | typedef void | |
| const struct GNUNET_PeerId | | (*GNUNET_CORE_ConnectEventHandler) (void *cls, | |
| entity *peer); | | const struct GNUNET_PeerIdentity *peer) | |
| | | ; | |
| | | | |
| /** | | /** | |
| * Method called whenever a peer disconnects. | | * Method called whenever a peer disconnects. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param peer peer identity this notification is about | | * @param peer peer identity this notification is about | |
| */ | | */ | |
|
| typedef void (*GNUNET_CORE_DisconnectEventHandler) (void *cls, | | typedef void | |
| const struct GNUNET_Pee | | (*GNUNET_CORE_DisconnectEventHandler) (void *cls, | |
| rIdentity *peer); | | const struct GNUNET_PeerIdentity *pe | |
| | | er); | |
| | | | |
| /** | | /** | |
| * Functions with this signature are called whenever a message is | | * Functions with this signature are called whenever a message is | |
| * received or transmitted. | | * received or transmitted. | |
| * | | * | |
| * @param cls closure (set from #GNUNET_CORE_connect) | | * @param cls closure (set from #GNUNET_CORE_connect) | |
| * @param peer the other peer involved (sender or receiver, NULL | | * @param peer the other peer involved (sender or receiver, NULL | |
| * for loopback messages where we are both sender and receiver) | | * for loopback messages where we are both sender and receiver) | |
| * @param message the actual message | | * @param message the actual message | |
| * @return #GNUNET_OK to keep the connection open, | | * @return #GNUNET_OK to keep the connection open, | |
| * #GNUNET_SYSERR to close connection to the peer (signal serious e
rror) | | * #GNUNET_SYSERR to close connection to the peer (signal serious e
rror) | |
| */ | | */ | |
|
| typedef int (*GNUNET_CORE_MessageCallback) (void *cls, | | typedef int | |
| const struct GNUNET_PeerIdentit | | (*GNUNET_CORE_MessageCallback) (void *cls, | |
| y * | | const struct GNUNET_PeerIdentity *other, | |
| other, | | const struct GNUNET_MessageHeader *message) | |
| const struct GNUNET_MessageHead | | ; | |
| er * | | | |
| message); | | | |
| | | | |
| /** | | /** | |
| * Message handler. Each struct specifies how to handle on particular | | * Message handler. Each struct specifies how to handle on particular | |
| * type of message received. | | * type of message received. | |
| */ | | */ | |
| struct GNUNET_CORE_MessageHandler | | struct GNUNET_CORE_MessageHandler | |
| { | | { | |
| /** | | /** | |
|
| * Function to call for messages of "type". | | * Function to call for messages of @e type. | |
| */ | | */ | |
| GNUNET_CORE_MessageCallback callback; | | GNUNET_CORE_MessageCallback callback; | |
| | | | |
| /** | | /** | |
| * Type of the message this handler covers. | | * Type of the message this handler covers. | |
| */ | | */ | |
| uint16_t type; | | uint16_t type; | |
| | | | |
| /** | | /** | |
| * Expected size of messages of this type. Use 0 for variable-size. | | * Expected size of messages of this type. Use 0 for variable-size. | |
| | | | |
| skipping to change at line 126 | | skipping to change at line 155 | |
| * for good). Note that the private key of the peer is intentionally | | * for good). Note that the private key of the peer is intentionally | |
| * not exposed here; if you need it, your process should try to read | | * not exposed here; if you need it, your process should try to read | |
| * the private key file directly (which should work if you are | | * the private key file directly (which should work if you are | |
| * authorized...). Implementations of this function must not call | | * authorized...). Implementations of this function must not call | |
| * #GNUNET_CORE_disconnect (other than by scheduling a new task to | | * #GNUNET_CORE_disconnect (other than by scheduling a new task to | |
| * do this later). | | * do this later). | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param my_identity ID of this peer, NULL if we failed | | * @param my_identity ID of this peer, NULL if we failed | |
| */ | | */ | |
|
| typedef void (*GNUNET_CORE_StartupCallback) (void *cls, | | typedef void | |
| const struct GNUNET_PeerIdenti | | (*GNUNET_CORE_StartupCallback) (void *cls, | |
| ty *my_identity); | | const struct GNUNET_PeerIdentity *my_identi | |
| | | ty); | |
| | | | |
| /** | | /** | |
| * Connect to the core service. Note that the connection may complete | | * Connect to the core service. Note that the connection may complete | |
| * (or fail) asynchronously. This function primarily causes the given | | * (or fail) asynchronously. This function primarily causes the given | |
| * callback notification functions to be invoked whenever the | | * callback notification functions to be invoked whenever the | |
| * specified event happens. The maximum number of queued | | * specified event happens. The maximum number of queued | |
| * notifications (queue length) is per client; the queue is shared | | * notifications (queue length) is per client; the queue is shared | |
| * across all types of notifications. So a slow client that registers | | * across all types of notifications. So a slow client that registers | |
| * for @a outbound_notify also risks missing @a inbound_notify messages. | | * for @a outbound_notify also risks missing @a inbound_notify messages. | |
| * Certain events (such as connect/disconnect notifications) are not | | * Certain events (such as connect/disconnect notifications) are not | |
| | | | |
| skipping to change at line 213 | | skipping to change at line 243 | |
| * called after a connection to the respective peer has been | | * called after a connection to the respective peer has been | |
| * established (and the client has been informed about this). You may | | * established (and the client has been informed about this). You may | |
| * have one request of this type pending for each connected peer at | | * have one request of this type pending for each connected peer at | |
| * any time. If a peer disconnects, the application MUST call | | * any time. If a peer disconnects, the application MUST call | |
| * #GNUNET_CORE_notify_transmit_ready_cancel on the respective | | * #GNUNET_CORE_notify_transmit_ready_cancel on the respective | |
| * transmission request, if one such request is pending. | | * transmission request, if one such request is pending. | |
| * | | * | |
| * @param handle connection to core service | | * @param handle connection to core service | |
| * @param cork is corking allowed for this transmission? | | * @param cork is corking allowed for this transmission? | |
| * @param priority how important is the message? | | * @param priority how important is the message? | |
|
| * @param maxdelay how long can the message wait? | | * @param maxdelay how long can the message wait? Only effective if @a cork
is #GNUNET_YES | |
| * @param target who should receive the message, never NULL (can be this pe
er's identity for loopback) | | * @param target who should receive the message, never NULL (can be this pe
er's identity for loopback) | |
| * @param notify_size how many bytes of buffer space does notify want? | | * @param notify_size how many bytes of buffer space does notify want? | |
| * @param notify function to call when buffer space is available; | | * @param notify function to call when buffer space is available; | |
| * will be called with NULL on timeout; clients MUST cancel | | * will be called with NULL on timeout; clients MUST cancel | |
| * all pending transmission requests DURING the disconnect | | * all pending transmission requests DURING the disconnect | |
| * handler | | * handler | |
| * @param notify_cls closure for @a notify | | * @param notify_cls closure for @a notify | |
| * @return non-NULL if the notify callback was queued, | | * @return non-NULL if the notify callback was queued, | |
| * NULL if we can not even queue the request (request already pendi
ng); | | * NULL if we can not even queue the request (request already pendi
ng); | |
| * if NULL is returned, "notify" will NOT be called. | | * if NULL is returned, "notify" will NOT be called. | |
| */ | | */ | |
| struct GNUNET_CORE_TransmitHandle * | | struct GNUNET_CORE_TransmitHandle * | |
|
| GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int c | | GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, | |
| ork, | | int cork, | |
| uint32_t priority, | | enum GNUNET_CORE_Priority priority, | |
| struct GNUNET_TIME_Relative maxdelay, | | struct GNUNET_TIME_Relative maxdelay, | |
| const struct GNUNET_PeerIdentity *target
, | | const struct GNUNET_PeerIdentity *target
, | |
| size_t notify_size, | | size_t notify_size, | |
| GNUNET_CONNECTION_TransmitReadyNotify no
tify, | | GNUNET_CONNECTION_TransmitReadyNotify no
tify, | |
| void *notify_cls); | | void *notify_cls); | |
| | | | |
| /** | | /** | |
| * Cancel the specified transmission-ready notification. | | * Cancel the specified transmission-ready notification. | |
| * | | * | |
| * @param th handle that was returned by "notify_transmit_ready". | | * @param th handle that was returned by "notify_transmit_ready". | |
| | | | |
End of changes. 8 change blocks. |
| 21 lines changed or deleted | | 50 lines changed or added | |
|
| gnunet_hello_lib.h | | gnunet_hello_lib.h | |
| | | | |
| skipping to change at line 51 | | skipping to change at line 51 | |
| * Prefix that every HELLO URI must start with. | | * Prefix that every HELLO URI must start with. | |
| */ | | */ | |
| #define GNUNET_HELLO_URI_PREFIX "gnunet://hello/" | | #define GNUNET_HELLO_URI_PREFIX "gnunet://hello/" | |
| | | | |
| /** | | /** | |
| * Prefix that every FRIEND HELLO URI must start with. | | * Prefix that every FRIEND HELLO URI must start with. | |
| */ | | */ | |
| #define GNUNET_FRIEND_HELLO_URI_PREFIX "gnunet://friend-hello/" | | #define GNUNET_FRIEND_HELLO_URI_PREFIX "gnunet://friend-hello/" | |
| | | | |
| /** | | /** | |
|
| | | * Additional local information about an address | |
| | | * | |
| | | * These information are only valid for the local peer and are not serializ | |
| | | ed | |
| | | * when a #GNUNET_HELLO_Message is created | |
| | | */ | |
| | | enum GNUNET_HELLO_AddressInfo | |
| | | { | |
| | | /** | |
| | | * No additional information | |
| | | */ | |
| | | GNUNET_HELLO_ADDRESS_INFO_NONE = 0, | |
| | | | |
| | | /** | |
| | | * This is an inbound address and cannot be used to initiate an outbound | |
| | | * connection to another peer | |
| | | */ | |
| | | GNUNET_HELLO_ADDRESS_INFO_INBOUND = 1 | |
| | | }; | |
| | | | |
| | | /** | |
| * An address for communicating with a peer. We frequently | | * An address for communicating with a peer. We frequently | |
| * need this tuple and the components cannot really be | | * need this tuple and the components cannot really be | |
| * separated. This is NOT the format that would be used | | * separated. This is NOT the format that would be used | |
| * on the wire. | | * on the wire. | |
| */ | | */ | |
| struct GNUNET_HELLO_Address | | struct GNUNET_HELLO_Address | |
| { | | { | |
| | | | |
| /** | | /** | |
| * For which peer is this an address? | | * For which peer is this an address? | |
| | | | |
| skipping to change at line 76 | | skipping to change at line 96 | |
| * this address. | | * this address. | |
| */ | | */ | |
| const char *transport_name; | | const char *transport_name; | |
| | | | |
| /** | | /** | |
| * Binary representation of the address (plugin-specific). | | * Binary representation of the address (plugin-specific). | |
| */ | | */ | |
| const void *address; | | const void *address; | |
| | | | |
| /** | | /** | |
|
| * Number of bytes in 'address'. | | * Number of bytes in @e address. | |
| */ | | */ | |
| size_t address_length; | | size_t address_length; | |
| | | | |
|
| | | /** | |
| | | * Extended information about address | |
| | | * | |
| | | * This field contains additional #GNUNET_HELLO_AddressInfo flags e.g. | |
| | | * to indicate an address is inbound and cannot be used to initiate an | |
| | | * outbound connection. | |
| | | * | |
| | | * These information are only valid for the local peer and are not serial | |
| | | ized | |
| | | * when a #GNUNET_HELLO_Message is created | |
| | | */ | |
| | | enum GNUNET_HELLO_AddressInfo local_info; | |
| | | | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Allocate an address struct. | | * Allocate an address struct. | |
| * | | * | |
| * @param peer the peer | | * @param peer the peer | |
| * @param transport_name plugin name | | * @param transport_name plugin name | |
| * @param address binary address | | * @param address binary address | |
|
| * @param address_length number of bytes in 'address' | | * @param address_length number of bytes in @a address | |
| | | * @param local_info additional local information for the address | |
| * @return the address struct | | * @return the address struct | |
| */ | | */ | |
| struct GNUNET_HELLO_Address * | | struct GNUNET_HELLO_Address * | |
| GNUNET_HELLO_address_allocate (const struct GNUNET_PeerIdentity *peer, | | GNUNET_HELLO_address_allocate (const struct GNUNET_PeerIdentity *peer, | |
|
| const char *transport_name, const void *addr | | const char *transport_name, | |
| ess, | | const void *address, | |
| size_t address_length); | | size_t address_length, | |
| | | enum GNUNET_HELLO_AddressInfo local_info); | |
| | | | |
| /** | | /** | |
| * Copy an address struct. | | * Copy an address struct. | |
| * | | * | |
| * @param address address to copy | | * @param address address to copy | |
| * @return a copy of the address struct | | * @return a copy of the address struct | |
| */ | | */ | |
| struct GNUNET_HELLO_Address * | | struct GNUNET_HELLO_Address * | |
| GNUNET_HELLO_address_copy (const struct GNUNET_HELLO_Address *address); | | GNUNET_HELLO_address_copy (const struct GNUNET_HELLO_Address *address); | |
| | | | |
| /** | | /** | |
| * Compare two addresses. Does NOT compare the peer identity, | | * Compare two addresses. Does NOT compare the peer identity, | |
| * that is assumed already to match! | | * that is assumed already to match! | |
| * | | * | |
| * @param a1 first address | | * @param a1 first address | |
| * @param a2 second address | | * @param a2 second address | |
|
| * @return 0 if the addresses are equal, -1 if a1<a2, 1 if a1>a2. | | * @return 0 if the addresses are equal, -1 if @a a1< @a a2, 1 if @a a1> @a
a2. | |
| */ | | */ | |
| int | | int | |
| GNUNET_HELLO_address_cmp (const struct GNUNET_HELLO_Address *a1, | | GNUNET_HELLO_address_cmp (const struct GNUNET_HELLO_Address *a1, | |
| const struct GNUNET_HELLO_Address *a2); | | const struct GNUNET_HELLO_Address *a2); | |
| | | | |
| /** | | /** | |
| * Get the size of an address struct. | | * Get the size of an address struct. | |
| * | | * | |
| * @param address address | | * @param address address | |
| * @return the size | | * @return the size | |
| */ | | */ | |
| size_t | | size_t | |
| GNUNET_HELLO_address_get_size (const struct GNUNET_HELLO_Address *address); | | GNUNET_HELLO_address_get_size (const struct GNUNET_HELLO_Address *address); | |
| | | | |
| /** | | /** | |
|
| | | * Check if an address has a local option set | |
| | | * | |
| | | * @param address the address to check | |
| | | * @param option the respective option to check for | |
| | | * @return #GNUNET_YES or #GNUNET_NO | |
| | | */ | |
| | | int | |
| | | GNUNET_HELLO_address_check_option (const struct GNUNET_HELLO_Address *addre | |
| | | ss, | |
| | | enum GNUNET_HELLO_AddressInfo option); | |
| | | | |
| | | /** | |
| * Free an address. | | * Free an address. | |
| * | | * | |
| * @param addr address to free | | * @param addr address to free | |
| */ | | */ | |
| #define GNUNET_HELLO_address_free(addr) GNUNET_free(addr) | | #define GNUNET_HELLO_address_free(addr) GNUNET_free(addr) | |
| | | | |
| /** | | /** | |
| * A HELLO message is used to exchange information about | | * A HELLO message is used to exchange information about | |
| * transports with other peers. This struct is guaranteed | | * transports with other peers. This struct is guaranteed | |
|
| * to start with a "GNUNET_MessageHeader", everything else | | * to start with a `struct GNUNET_MessageHeader`, everything else | |
| * should be internal to the HELLO library. | | * should be internal to the HELLO library. | |
| */ | | */ | |
| struct GNUNET_HELLO_Message; | | struct GNUNET_HELLO_Message; | |
| | | | |
|
| /** Return HELLO type | | /** | |
| | | * Return HELLO type | |
| * | | * | |
| * @param h HELLO Message to test | | * @param h HELLO Message to test | |
|
| * @return GNUNET_YES or GNUNET_NO | | * @return #GNUNET_YES or #GNUNET_NO | |
| */ | | */ | |
| int | | int | |
| GNUNET_HELLO_is_friend_only (const struct GNUNET_HELLO_Message *h); | | GNUNET_HELLO_is_friend_only (const struct GNUNET_HELLO_Message *h); | |
| | | | |
| /** | | /** | |
| * Copy the given address information into | | * Copy the given address information into | |
| * the given buffer using the format of HELLOs. | | * the given buffer using the format of HELLOs. | |
| * | | * | |
| * @param address address to add | | * @param address address to add | |
| * @param expiration expiration for the address | | * @param expiration expiration for the address | |
| * @param target where to copy the address | | * @param target where to copy the address | |
|
| * @param max maximum number of bytes to copy to target | | * @param max maximum number of bytes to copy to @a target | |
| * @return number of bytes copied, 0 if | | * @return number of bytes copied, 0 if | |
| * the target buffer was not big enough. | | * the target buffer was not big enough. | |
| */ | | */ | |
| size_t | | size_t | |
| GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address, | | GNUNET_HELLO_add_address (const struct GNUNET_HELLO_Address *address, | |
|
| struct GNUNET_TIME_Absolute expiration, char *tar | | struct GNUNET_TIME_Absolute expiration, | |
| get, | | char *target, | |
| size_t max); | | size_t max); | |
| | | | |
| /** | | /** | |
| * Callback function used to fill a buffer of max bytes with a list of | | * Callback function used to fill a buffer of max bytes with a list of | |
| * addresses in the format used by HELLOs. Should use | | * addresses in the format used by HELLOs. Should use | |
|
| * "GNUNET_HELLO_add_address" as a helper function. | | * #GNUNET_HELLO_add_address() as a helper function. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
|
| * @param max maximum number of bytes that can be written to buf | | * @param max maximum number of bytes that can be written to @a buf | |
| * @param buf where to write the address information | | * @param buf where to write the address information | |
| * @return number of bytes written, 0 to signal the | | * @return number of bytes written, 0 to signal the | |
| * end of the iteration. | | * end of the iteration. | |
| */ | | */ | |
|
| typedef size_t (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls, | | typedef size_t | |
| size_t max, | | (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls, | |
| void *buf); | | size_t max, | |
| | | void *buf); | |
| | | | |
| /** | | /** | |
| * Construct a HELLO message given the public key, | | * Construct a HELLO message given the public key, | |
| * expiration time and an iterator that spews the | | * expiration time and an iterator that spews the | |
| * transport addresses. | | * transport addresses. | |
| * | | * | |
|
| * If friend only is set to GNUNET_YES we create a FRIEND_HELLO which will | | * If friend only is set to #GNUNET_YES we create a FRIEND_HELLO which | |
| * not be gossiped to other peers | | * will not be gossiped to other peers. | |
| * | | * | |
|
| | | * @param publicKey public key to include in the HELLO | |
| | | * @param addrgen callback to invoke to get addresses | |
| | | * @param addrgen_cls closure for @a addrgen | |
| | | * @param friend_only should the returned HELLO be only visible to friends? | |
| * @return the hello message | | * @return the hello message | |
| */ | | */ | |
| struct GNUNET_HELLO_Message * | | struct GNUNET_HELLO_Message * | |
| GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EddsaPublicKey *publicKey, | | GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EddsaPublicKey *publicKey, | |
| GNUNET_HELLO_GenerateAddressListCallback addrgen, | | GNUNET_HELLO_GenerateAddressListCallback addrgen, | |
| void *addrgen_cls, | | void *addrgen_cls, | |
| int friend_only); | | int friend_only); | |
| | | | |
| /** | | /** | |
| * Return the size of the given HELLO message. | | * Return the size of the given HELLO message. | |
| | | | |
| skipping to change at line 244 | | skipping to change at line 297 | |
| GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1, | | GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1, | |
| const struct GNUNET_HELLO_Message *h2, | | const struct GNUNET_HELLO_Message *h2, | |
| struct GNUNET_TIME_Absolute now); | | struct GNUNET_TIME_Absolute now); | |
| | | | |
| /** | | /** | |
| * Iterator callback to go over all addresses. | | * Iterator callback to go over all addresses. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param address the address | | * @param address the address | |
| * @param expiration expiration time | | * @param expiration expiration time | |
|
| * @return GNUNET_OK to keep the address, | | * @return #GNUNET_OK to keep the address, | |
| * GNUNET_NO to delete it from the HELLO | | * #GNUNET_NO to delete it from the HELLO | |
| * GNUNET_SYSERR to stop iterating (but keep current address) | | * #GNUNET_SYSERR to stop iterating (but keep current address) | |
| */ | | */ | |
| typedef int (*GNUNET_HELLO_AddressIterator) (void *cls, | | typedef int | |
| const struct GNUNET_HELLO_Addr | | (*GNUNET_HELLO_AddressIterator) (void *cls, | |
| ess * | | const struct GNUNET_HELLO_Address *address | |
| address, | | , | |
| struct GNUNET_TIME_Absolute | | struct GNUNET_TIME_Absolute expiration); | |
| expiration); | | | |
| | | | |
| /** | | /** | |
| * When does the last address in the given HELLO expire? | | * When does the last address in the given HELLO expire? | |
| * | | * | |
| * @param msg HELLO to inspect | | * @param msg HELLO to inspect | |
| * @return time the last address expires, 0 if there are no addresses in th
e HELLO | | * @return time the last address expires, 0 if there are no addresses in th
e HELLO | |
| */ | | */ | |
| struct GNUNET_TIME_Absolute | | struct GNUNET_TIME_Absolute | |
| GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg); | | GNUNET_HELLO_get_last_expiration (const struct GNUNET_HELLO_Message *msg); | |
| | | | |
| /** | | /** | |
| * Iterate over all of the addresses in the HELLO. | | * Iterate over all of the addresses in the HELLO. | |
| * | | * | |
| * @param msg HELLO to iterate over; client does not need to | | * @param msg HELLO to iterate over; client does not need to | |
| * have verified that msg is well-formed (beyond starting | | * have verified that msg is well-formed (beyond starting | |
| * with a GNUNET_MessageHeader of the right type). | | * with a GNUNET_MessageHeader of the right type). | |
| * @param return_modified if a modified copy should be returned, | | * @param return_modified if a modified copy should be returned, | |
| * otherwise NULL will be returned | | * otherwise NULL will be returned | |
| * @param it iterator to call on each address | | * @param it iterator to call on each address | |
|
| * @param it_cls closure for it | | * @param it_cls closure for @a it | |
| * @return the modified HELLO or NULL | | * @return the modified HELLO or NULL | |
| */ | | */ | |
| struct GNUNET_HELLO_Message * | | struct GNUNET_HELLO_Message * | |
| GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | | GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg, | |
| int return_modified, | | int return_modified, | |
| GNUNET_HELLO_AddressIterator it, void *it_c
ls); | | GNUNET_HELLO_AddressIterator it, void *it_c
ls); | |
| | | | |
| /** | | /** | |
| * Iterate over addresses in "new_hello" that | | * Iterate over addresses in "new_hello" that | |
| * are NOT already present in "old_hello". | | * are NOT already present in "old_hello". | |
| * | | * | |
| * @param new_hello a HELLO message | | * @param new_hello a HELLO message | |
| * @param old_hello a HELLO message | | * @param old_hello a HELLO message | |
| * @param expiration_limit ignore addresses in old_hello | | * @param expiration_limit ignore addresses in old_hello | |
| * that expired before the given time stamp | | * that expired before the given time stamp | |
| * @param it iterator to call on each address | | * @param it iterator to call on each address | |
|
| * @param it_cls closure for it | | * @param it_cls closure for @a it | |
| */ | | */ | |
| void | | void | |
|
| GNUNET_HELLO_iterate_new_addresses (const struct GNUNET_HELLO_Message | | GNUNET_HELLO_iterate_new_addresses (const struct GNUNET_HELLO_Message *new_ | |
| *new_hello, | | hello, | |
| const struct GNUNET_HELLO_Message | | const struct GNUNET_HELLO_Message *old_ | |
| *old_hello, | | hello, | |
| struct GNUNET_TIME_Absolute | | struct GNUNET_TIME_Absolute expiration_ | |
| expiration_limit, | | limit, | |
| GNUNET_HELLO_AddressIterator it, | | GNUNET_HELLO_AddressIterator it, | |
| void *it_cls); | | void *it_cls); | |
| | | | |
| /** | | /** | |
| * Get the public key from a HELLO message. | | * Get the public key from a HELLO message. | |
| * | | * | |
| * @param hello the hello message | | * @param hello the hello message | |
| * @param publicKey where to copy the public key information, can be NULL | | * @param publicKey where to copy the public key information, can be NULL | |
|
| * @return GNUNET_SYSERR if the HELLO was malformed | | * @return #GNUNET_SYSERR if the HELLO was malformed | |
| */ | | */ | |
| int | | int | |
| GNUNET_HELLO_get_key (const struct GNUNET_HELLO_Message *hello, | | GNUNET_HELLO_get_key (const struct GNUNET_HELLO_Message *hello, | |
| struct GNUNET_CRYPTO_EddsaPublicKey *publicKey); | | struct GNUNET_CRYPTO_EddsaPublicKey *publicKey); | |
| | | | |
| /** | | /** | |
| * Get the peer identity from a HELLO message. | | * Get the peer identity from a HELLO message. | |
| * | | * | |
| * @param hello the hello message | | * @param hello the hello message | |
| * @param peer where to store the peer's identity | | * @param peer where to store the peer's identity | |
|
| * @return GNUNET_SYSERR if the HELLO was malformed | | * @return #GNUNET_SYSERR if the HELLO was malformed | |
| */ | | */ | |
| int | | int | |
| GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello, | | GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello, | |
| struct GNUNET_PeerIdentity *peer); | | struct GNUNET_PeerIdentity *peer); | |
| | | | |
| /** | | /** | |
| * Get the header from a HELLO message, used so other code | | * Get the header from a HELLO message, used so other code | |
| * can correctly send HELLO messages. | | * can correctly send HELLO messages. | |
| * | | * | |
| * @param hello the hello message | | * @param hello the hello message | |
| | | | |
| skipping to change at line 355 | | skipping to change at line 404 | |
| GNUNET_HELLO_compose_uri (const struct GNUNET_HELLO_Message *hello, | | GNUNET_HELLO_compose_uri (const struct GNUNET_HELLO_Message *hello, | |
| GNUNET_HELLO_TransportPluginsFind plugins_find); | | GNUNET_HELLO_TransportPluginsFind plugins_find); | |
| | | | |
| /** | | /** | |
| * Parse a hello URI string to a hello message. | | * Parse a hello URI string to a hello message. | |
| * | | * | |
| * @param uri URI string to parse | | * @param uri URI string to parse | |
| * @param pubkey Pointer to struct where public key is parsed | | * @param pubkey Pointer to struct where public key is parsed | |
| * @param hello Pointer to struct where hello message is parsed | | * @param hello Pointer to struct where hello message is parsed | |
| * @param plugins_find Function to find transport plugins by name | | * @param plugins_find Function to find transport plugins by name | |
|
| * @return GNUNET_OK on success, GNUNET_SYSERR if the URI was invalid, GNUN
ET_NO on other errors | | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the URI was invalid, #G
NUNET_NO on other errors | |
| */ | | */ | |
| int | | int | |
| GNUNET_HELLO_parse_uri (const char *uri, | | GNUNET_HELLO_parse_uri (const char *uri, | |
| struct GNUNET_CRYPTO_EddsaPublicKey *pubkey, | | struct GNUNET_CRYPTO_EddsaPublicKey *pubkey, | |
| struct GNUNET_HELLO_Message **hello, | | struct GNUNET_HELLO_Message **hello, | |
| GNUNET_HELLO_TransportPluginsFind plugins_find); | | GNUNET_HELLO_TransportPluginsFind plugins_find); | |
| | | | |
| #if 0 /* keep Emacsens' auto-indent happy */ | | #if 0 /* keep Emacsens' auto-indent happy */ | |
| { | | { | |
| #endif | | #endif | |
| | | | |
End of changes. 24 change blocks. |
| 40 lines changed or deleted | | 93 lines changed or added | |
|
| gnunet_mesh_service.h | | gnunet_mesh_service.h | |
| | | | |
| skipping to change at line 57 | | skipping to change at line 57 | |
| * Opaque handle to the service. | | * Opaque handle to the service. | |
| */ | | */ | |
| struct GNUNET_MESH_Handle; | | struct GNUNET_MESH_Handle; | |
| | | | |
| /** | | /** | |
| * Opaque handle to a channel. | | * Opaque handle to a channel. | |
| */ | | */ | |
| struct GNUNET_MESH_Channel; | | struct GNUNET_MESH_Channel; | |
| | | | |
| /** | | /** | |
|
| | | * Hash to be used in Mesh communication. Only 256 bits needed, | |
| | | * instead of the 512 from @c GNUNET_HashCode. | |
| | | * | |
| | | */ | |
| | | struct GNUNET_MESH_Hash | |
| | | { | |
| | | unsigned char bits[256 / 8]; | |
| | | }; | |
| | | | |
| | | /** | |
| * Channel options. | | * Channel options. | |
| * Second line indicates filed in the MeshChannelInfo union carrying the an
swer. | | * Second line indicates filed in the MeshChannelInfo union carrying the an
swer. | |
| */ | | */ | |
| enum GNUNET_MESH_ChannelOption | | enum GNUNET_MESH_ChannelOption | |
| { | | { | |
| /** | | /** | |
| * Default options: unreliable, default buffering, not out of order. | | * Default options: unreliable, default buffering, not out of order. | |
| */ | | */ | |
| GNUNET_MESH_OPTION_DEFAULT = 0x0, | | GNUNET_MESH_OPTION_DEFAULT = 0x0, | |
| | | | |
| | | | |
| skipping to change at line 348 | | skipping to change at line 358 | |
| /******************** MONITORING /DEBUG API *********************
****/ | | /******************** MONITORING /DEBUG API *********************
****/ | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* The following calls are not useful for normal MESH operation, but for
*/ | | /* The following calls are not useful for normal MESH operation, but for
*/ | |
| /* debug and monitoring of the mesh state. They can be safely ignored.
*/ | | /* debug and monitoring of the mesh state. They can be safely ignored.
*/ | |
| /* The API can change at any point without notice.
*/ | | /* The API can change at any point without notice.
*/ | |
| /* Please contact the developer if you consider any of this calls useful fo
r */ | | /* Please contact the developer if you consider any of this calls useful fo
r */ | |
| /* normal mesh applications.
*/ | | /* normal mesh applications.
*/ | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| | | | |
| /** | | /** | |
|
| * Method called to retrieve information about each channel the mesh peer | | * Method called to retrieve information about a specific channel the mesh | |
| * is aware of. | | peer | |
| | | * is aware of, including all transit nodes. | |
| * | | * | |
| * @param cls Closure. | | * @param cls Closure. | |
|
| * @param channel_number Channel number. | | * @param root Root of the channel. | |
| * @param origin that started the channel (owner). | | * @param dest Destination of the channel. | |
| * @param target other endpoint of the channel | | * @param port Destination port of the channel. | |
| | | * @param root_channel_number Local number for root, if known. | |
| | | * @param dest_channel_number Local number for dest, if known. | |
| | | * @param public_channel_numbe Number for P2P, always known. | |
| */ | | */ | |
|
| typedef void (*GNUNET_MESH_ChannelsCB) (void *cls, | | typedef void (*GNUNET_MESH_ChannelCB) (void *cls, | |
| uint32_t channel_number, | | const struct GNUNET_PeerIdentity *ro | |
| const struct GNUNET_PeerIdentity *o | | ot, | |
| rigin, | | const struct GNUNET_PeerIdentity *de | |
| const struct GNUNET_PeerIdentity *t | | st, | |
| arget); | | uint32_t port, | |
| | | uint32_t root_channel_number, | |
| | | uint32_t dest_channel_number, | |
| | | uint32_t public_channel_number); | |
| | | | |
| /** | | /** | |
|
| * Method called to retrieve information about a specific channel the mesh | | * Method called to retrieve information about all peers in MESH, called | |
| peer | | * once per peer. | |
| * is aware of, including all transit nodes. | | * | |
| | | * After last peer has been reported, an additional call with NULL is done. | |
| | | * | |
| | | * @param cls Closure. | |
| | | * @param peer Peer, or NULL on "EOF". | |
| | | * @param tunnel Do we have a tunnel towards this peer? | |
| | | * @param n_paths Number of known paths towards this peer. | |
| | | * @param best_path How long is the best path? | |
| | | * (0 = unknown, 1 = ourselves, 2 = neighbor) | |
| | | */ | |
| | | typedef void (*GNUNET_MESH_PeersCB) (void *cls, | |
| | | const struct GNUNET_PeerIdentity *peer | |
| | | , | |
| | | int tunnel, unsigned int n_paths, | |
| | | unsigned int best_path); | |
| | | | |
| | | /** | |
| | | * Method called to retrieve information about a specific peer | |
| | | * known to the service. | |
| | | * | |
| | | * @param cls Closure. | |
| | | * @param peer Peer ID. | |
| | | * @param tunnel Do we have a tunnel towards this peer? #GNUNET_YES/#GNUNET | |
| | | _NO | |
| | | * @param neighbor Is this a direct neighbor? #GNUNET_YES/#GNUNET_NO | |
| | | * @param n_paths Number of paths known towards peer. | |
| | | * @param paths Array of PEER_IDs representing all paths to reach the peer. | |
| | | * Each path starts with the local peer. | |
| | | * Each path ends with the destination peer (given in @c peer) | |
| | | . | |
| | | */ | |
| | | typedef void (*GNUNET_MESH_PeerCB) (void *cls, | |
| | | const struct GNUNET_PeerIdentity *peer, | |
| | | int tunnel, | |
| | | int neighbor, | |
| | | unsigned int n_paths, | |
| | | struct GNUNET_PeerIdentity *paths); | |
| | | | |
| | | /** | |
| | | * Method called to retrieve information about all tunnels in MESH, called | |
| | | * once per tunnel. | |
| | | * | |
| | | * After last tunnel has been reported, an additional call with NULL is don | |
| | | e. | |
| | | * | |
| | | * @param cls Closure. | |
| | | * @param peer Destination peer, or NULL on "EOF". | |
| | | * @param channels Number of channels. | |
| | | * @param connections Number of connections. | |
| | | * @param estate Encryption state. | |
| | | * @param cstate Connectivity state. | |
| | | */ | |
| | | typedef void (*GNUNET_MESH_TunnelsCB) (void *cls, | |
| | | const struct GNUNET_PeerIdentity *pe | |
| | | er, | |
| | | unsigned int channels, | |
| | | unsigned int connections, | |
| | | uint16_t estate, | |
| | | uint16_t cstate); | |
| | | | |
| | | /** | |
| | | * Method called to retrieve information about a specific tunnel the mesh p | |
| | | eer | |
| | | * has established, o`r is trying to establish. | |
| * | | * | |
| * @param cls Closure. | | * @param cls Closure. | |
|
| * @param peer Peer in the channel's tree. | | * @param peer Peer towards whom the tunnel is directed. | |
| * @param parent Parent of the current peer. All 0 when peer is root. | | * @param n_channels Number of channels. | |
| | | * @param n_connections Number of connections. | |
| | | * @param channels Channels. | |
| | | * @param connections Connections. | |
| | | * @param estate Encryption state. | |
| | | * @param cstate Connectivity state. | |
| */ | | */ | |
|
| typedef void (*GNUNET_MESH_ChannelCB) (void *cls, | | typedef void (*GNUNET_MESH_TunnelCB) (void *cls, | |
| const struct GNUNET_PeerIdentity *pee
r, | | const struct GNUNET_PeerIdentity *pee
r, | |
|
| const struct GNUNET_PeerIdentity *par | | unsigned int n_channels, | |
| ent); | | unsigned int n_connections, | |
| | | uint32_t *channels, | |
| | | struct GNUNET_MESH_Hash *connections, | |
| | | unsigned int estate, | |
| | | unsigned int cstate); | |
| | | | |
| /** | | /** | |
|
| * Request information about the running mesh peer. | | * Request information about a specific channel of the running mesh peer. | |
| * The callback will be called for every channel known to the service, | | | |
| * listing all active peers that belong to the channel. | | | |
| * | | | |
| * If called again on the same handle, it will overwrite the previous | | | |
| * callback and cls. To retrieve the cls, monitor_cancel must be | | | |
| * called first. | | | |
| * | | * | |
| * WARNING: unstable API, likely to change in the future! | | * WARNING: unstable API, likely to change in the future! | |
| * | | * | |
| * @param h Handle to the mesh peer. | | * @param h Handle to the mesh peer. | |
|
| | | * @param peer ID of the other end of the channel. | |
| | | * @param channel_number Channel number. | |
| * @param callback Function to call with the requested data. | | * @param callback Function to call with the requested data. | |
| * @param callback_cls Closure for @c callback. | | * @param callback_cls Closure for @c callback. | |
| */ | | */ | |
| void | | void | |
|
| GNUNET_MESH_get_channels (struct GNUNET_MESH_Handle *h, | | GNUNET_MESH_get_channel (struct GNUNET_MESH_Handle *h, | |
| GNUNET_MESH_ChannelsCB callback, | | struct GNUNET_PeerIdentity *peer, | |
| | | uint32_t channel_number, | |
| | | GNUNET_MESH_ChannelCB callback, | |
| void *callback_cls); | | void *callback_cls); | |
| | | | |
| /** | | /** | |
|
| * Request information about a specific channel of the running mesh peer. | | * Request information about peers known to the running mesh service. | |
| | | * The callback will be called for every peer known to the service. | |
| | | * Only one info request (of any kind) can be active at once. | |
| | | * | |
| * | | * | |
| * WARNING: unstable API, likely to change in the future! | | * WARNING: unstable API, likely to change in the future! | |
| * | | * | |
| * @param h Handle to the mesh peer. | | * @param h Handle to the mesh peer. | |
|
| * @param initiator ID of the owner of the channel. | | | |
| * @param channel_number Channel number. | | | |
| * @param callback Function to call with the requested data. | | * @param callback Function to call with the requested data. | |
| * @param callback_cls Closure for @c callback. | | * @param callback_cls Closure for @c callback. | |
|
| | | * | |
| | | * @return #GNUNET_OK / #GNUNET_SYSERR | |
| */ | | */ | |
|
| void | | int | |
| GNUNET_MESH_show_channel (struct GNUNET_MESH_Handle *h, | | GNUNET_MESH_get_peers (struct GNUNET_MESH_Handle *h, | |
| struct GNUNET_PeerIdentity *initiator, | | GNUNET_MESH_PeersCB callback, | |
| uint32_t channel_number, | | void *callback_cls); | |
| GNUNET_MESH_ChannelCB callback, | | | |
| void *callback_cls); | | | |
| | | | |
| /** | | /** | |
|
| * Cancel a monitor request. The monitor callback will not be called. | | * Cancel a peer info request. The callback will not be called (anymore). | |
| | | * | |
| | | * WARNING: unstable API, likely to change in the future! | |
| | | * | |
| | | * @param h Mesh handle. | |
| | | * | |
| | | * @return Closure given to GNUNET_MESH_get_peers. | |
| | | */ | |
| | | void * | |
| | | GNUNET_MESH_get_peers_cancel (struct GNUNET_MESH_Handle *h); | |
| | | | |
| | | /** | |
| | | * Request information about a peer known to the running mesh peer. | |
| | | * The callback will be called for the tunnel once. | |
| | | * Only one info request (of any kind) can be active at once. | |
| | | * | |
| | | * WARNING: unstable API, likely to change in the future! | |
| | | * | |
| | | * @param h Handle to the mesh peer. | |
| | | * @param id Peer whose tunnel to examine. | |
| | | * @param callback Function to call with the requested data. | |
| | | * @param callback_cls Closure for @c callback. | |
| | | * | |
| | | * @return #GNUNET_OK / #GNUNET_SYSERR | |
| | | */ | |
| | | int | |
| | | GNUNET_MESH_get_peer (struct GNUNET_MESH_Handle *h, | |
| | | const struct GNUNET_PeerIdentity *id, | |
| | | GNUNET_MESH_PeerCB callback, | |
| | | void *callback_cls); | |
| | | | |
| | | /** | |
| | | * Request information about tunnels of the running mesh peer. | |
| | | * The callback will be called for every tunnel of the service. | |
| | | * Only one info request (of any kind) can be active at once. | |
| * | | * | |
| * WARNING: unstable API, likely to change in the future! | | * WARNING: unstable API, likely to change in the future! | |
| * | | * | |
|
| | | * @param h Handle to the mesh peer. | |
| | | * @param callback Function to call with the requested data. | |
| | | * @param callback_cls Closure for @c callback. | |
| | | * | |
| | | * @return #GNUNET_OK / #GNUNET_SYSERR | |
| | | */ | |
| | | int | |
| | | GNUNET_MESH_get_tunnels (struct GNUNET_MESH_Handle *h, | |
| | | GNUNET_MESH_TunnelsCB callback, | |
| | | void *callback_cls); | |
| | | | |
| | | /** | |
| | | * Cancel a monitor request. The monitor callback will not be called. | |
| | | * | |
| * @param h Mesh handle. | | * @param h Mesh handle. | |
| * | | * | |
| * @return Closure given to GNUNET_MESH_monitor, if any. | | * @return Closure given to GNUNET_MESH_monitor, if any. | |
| */ | | */ | |
| void * | | void * | |
|
| GNUNET_MESH_get_channels_cancel (struct GNUNET_MESH_Handle *h); | | GNUNET_MESH_get_tunnels_cancel (struct GNUNET_MESH_Handle *h); | |
| | | | |
| | | /** | |
| | | * Request information about a tunnel of the running mesh peer. | |
| | | * The callback will be called for the tunnel once. | |
| | | * Only one info request (of any kind) can be active at once. | |
| | | * | |
| | | * WARNING: unstable API, likely to change in the future! | |
| | | * | |
| | | * @param h Handle to the mesh peer. | |
| | | * @param id Peer whose tunnel to examine. | |
| | | * @param callback Function to call with the requested data. | |
| | | * @param callback_cls Closure for @c callback. | |
| | | * | |
| | | * @return #GNUNET_OK / #GNUNET_SYSERR | |
| | | */ | |
| | | int | |
| | | GNUNET_MESH_get_tunnel (struct GNUNET_MESH_Handle *h, | |
| | | const struct GNUNET_PeerIdentity *id, | |
| | | GNUNET_MESH_TunnelCB callback, | |
| | | void *callback_cls); | |
| | | | |
| /** | | /** | |
| * Create a message queue for a mesh channel. | | * Create a message queue for a mesh channel. | |
| * The message queue can only be used to transmit messages, | | * The message queue can only be used to transmit messages, | |
| * not to receive them. | | * not to receive them. | |
| * | | * | |
| * @param channel the channel to create the message qeue for | | * @param channel the channel to create the message qeue for | |
| * @return a message queue to messages over the channel | | * @return a message queue to messages over the channel | |
| */ | | */ | |
| struct GNUNET_MQ_Handle * | | struct GNUNET_MQ_Handle * | |
| | | | |
End of changes. 18 change blocks. |
| 39 lines changed or deleted | | 195 lines changed or added | |
|
| gnunet_multicast_service.h | | gnunet_multicast_service.h | |
| | | | |
| skipping to change at line 48 | | skipping to change at line 48 | |
| | | | |
| #include "gnunet_util_lib.h" | | #include "gnunet_util_lib.h" | |
| #include "gnunet_transport_service.h" | | #include "gnunet_transport_service.h" | |
| | | | |
| /** | | /** | |
| * Version number of GNUnet-multicast API. | | * Version number of GNUnet-multicast API. | |
| */ | | */ | |
| #define GNUNET_MULTICAST_VERSION 0x00000000 | | #define GNUNET_MULTICAST_VERSION 0x00000000 | |
| | | | |
| /** | | /** | |
|
| * Maximum size of a multicast message fragment. | | | |
| */ | | | |
| #define GNUNET_MULTICAST_FRAGMENT_MAX_SIZE 63 * 1024 | | | |
| | | | |
| /** | | | |
| * Opaque handle for a multicast group member. | | * Opaque handle for a multicast group member. | |
| */ | | */ | |
| struct GNUNET_MULTICAST_Member; | | struct GNUNET_MULTICAST_Member; | |
| | | | |
| /** | | /** | |
| * Handle for the origin of a multicast group. | | * Handle for the origin of a multicast group. | |
| */ | | */ | |
| struct GNUNET_MULTICAST_Origin; | | struct GNUNET_MULTICAST_Origin; | |
| | | | |
| enum GNUNET_MULTICAST_MessageFlags | | enum GNUNET_MULTICAST_MessageFlags | |
| | | | |
| skipping to change at line 79 | | skipping to change at line 74 | |
| /** | | /** | |
| * Last fragment of a message. | | * Last fragment of a message. | |
| */ | | */ | |
| GNUNET_MULTICAST_MESSAGE_LAST_FRAGMENT = 1 << 1, | | GNUNET_MULTICAST_MESSAGE_LAST_FRAGMENT = 1 << 1, | |
| | | | |
| /** | | /** | |
| * OR'ed flags if message is not fragmented. | | * OR'ed flags if message is not fragmented. | |
| */ | | */ | |
| GNUNET_MULTICAST_MESSAGE_NOT_FRAGMENTED | | GNUNET_MULTICAST_MESSAGE_NOT_FRAGMENTED | |
| = GNUNET_MULTICAST_MESSAGE_FIRST_FRAGMENT | | = GNUNET_MULTICAST_MESSAGE_FIRST_FRAGMENT | |
|
| | GNUNET_MULTICAST_MESSAGE_LAST_FRAGMENT | | | GNUNET_MULTICAST_MESSAGE_LAST_FRAGMENT, | |
| | | | |
| | | /** | |
| | | * Historic message, used only locally when replaying messages from local | |
| | | * storage. | |
| | | */ | |
| | | GNUNET_MULTICAST_MESSAGE_HISTORIC = 1 << 30 | |
| | | | |
| }; | | }; | |
| | | | |
| GNUNET_NETWORK_STRUCT_BEGIN | | GNUNET_NETWORK_STRUCT_BEGIN | |
| | | | |
| /** | | /** | |
| * Header of a multicast message fragment. | | * Header of a multicast message fragment. | |
| * | | * | |
| * This format is public as the replay mechanism must replay message fragme
nts using the | | * This format is public as the replay mechanism must replay message fragme
nts using the | |
| * same format. This is needed as we want to integrity-check message fragm
ents within | | * same format. This is needed as we want to integrity-check message fragm
ents within | |
| * the multicast layer to avoid multicasting mal-formed messages. | | * the multicast layer to avoid multicasting mal-formed messages. | |
| | | | |
| skipping to change at line 121 | | skipping to change at line 123 | |
| * Signature must match the public key of the multicast group. | | * Signature must match the public key of the multicast group. | |
| */ | | */ | |
| struct GNUNET_CRYPTO_EddsaSignature signature; | | struct GNUNET_CRYPTO_EddsaSignature signature; | |
| | | | |
| /** | | /** | |
| * Purpose for the signature and size of the signed data. | | * Purpose for the signature and size of the signed data. | |
| */ | | */ | |
| struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | |
| | | | |
| /** | | /** | |
|
| * Number of the message fragment, monotonically increasing. | | * Number of the message fragment, monotonically increasing starting from
1. | |
| */ | | */ | |
| uint64_t fragment_id GNUNET_PACKED; | | uint64_t fragment_id GNUNET_PACKED; | |
| | | | |
| /** | | /** | |
| * Byte offset of this @e fragment of the @e message. | | * Byte offset of this @e fragment of the @e message. | |
| */ | | */ | |
| uint64_t fragment_offset GNUNET_PACKED; | | uint64_t fragment_offset GNUNET_PACKED; | |
| | | | |
| /** | | /** | |
| * Number of the message this fragment belongs to. | | * Number of the message this fragment belongs to. | |
| | | | |
| skipping to change at line 151 | | skipping to change at line 153 | |
| * | | * | |
| * It has significance in case of replay requests: when a member has miss
ed | | * It has significance in case of replay requests: when a member has miss
ed | |
| * messages and gets a replay request: in this case if the @a group_gener
ation | | * messages and gets a replay request: in this case if the @a group_gener
ation | |
| * is still the same before and after the missed messages, it means that
no | | * is still the same before and after the missed messages, it means that
no | |
| * @e join or @e part operations happened during the missed messages. | | * @e join or @e part operations happened during the missed messages. | |
| */ | | */ | |
| uint64_t group_generation GNUNET_PACKED; | | uint64_t group_generation GNUNET_PACKED; | |
| | | | |
| /** | | /** | |
| * Flags for this message fragment. | | * Flags for this message fragment. | |
|
| | | * | |
| | | * @see enum GNUNET_MULTICAST_MessageFlags | |
| */ | | */ | |
| uint32_t flags GNUNET_PACKED; | | uint32_t flags GNUNET_PACKED; | |
| | | | |
| /* Followed by message body. */ | | /* Followed by message body. */ | |
| }; | | }; | |
| | | | |
|
| | | /** | |
| | | * Header of a request from a member to the origin. | |
| | | */ | |
| | | struct GNUNET_MULTICAST_RequestHeader | |
| | | { | |
| | | /** | |
| | | * Header for all requests from a member to the origin. | |
| | | */ | |
| | | struct GNUNET_MessageHeader header; | |
| | | | |
| | | /** | |
| | | * Public key of the sending member. | |
| | | */ | |
| | | struct GNUNET_CRYPTO_EddsaPublicKey member_key; | |
| | | | |
| | | /** | |
| | | * ECC signature of the request fragment. | |
| | | * | |
| | | * Signature must match the public key of the multicast group. | |
| | | */ | |
| | | struct GNUNET_CRYPTO_EddsaSignature signature; | |
| | | | |
| | | /** | |
| | | * Purpose for the signature and size of the signed data. | |
| | | */ | |
| | | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | |
| | | | |
| | | /** | |
| | | * Number of the request fragment. | |
| | | * Monotonically increasing from 1. | |
| | | */ | |
| | | uint64_t fragment_id GNUNET_PACKED; | |
| | | | |
| | | /** | |
| | | * Byte offset of this @e fragment of the @e request. | |
| | | */ | |
| | | uint64_t fragment_offset GNUNET_PACKED; | |
| | | | |
| | | /** | |
| | | * Number of the request this fragment belongs to. | |
| | | * | |
| | | * Set in GNUNET_MULTICAST_origin_to_all(). | |
| | | */ | |
| | | uint64_t request_id GNUNET_PACKED; | |
| | | | |
| | | /** | |
| | | * Flags for this request. | |
| | | */ | |
| | | enum GNUNET_MULTICAST_MessageFlags flags GNUNET_PACKED; | |
| | | | |
| | | /* Followed by request body. */ | |
| | | }; | |
| | | | |
| GNUNET_NETWORK_STRUCT_END | | GNUNET_NETWORK_STRUCT_END | |
| | | | |
| /** | | /** | |
|
| | | * Maximum size of a multicast message fragment. | |
| | | */ | |
| | | #define GNUNET_MULTICAST_FRAGMENT_MAX_SIZE 63 * 1024 | |
| | | | |
| | | #define GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \ | |
| | | GNUNET_MULTICAST_FRAGMENT_MAX_SIZE \ | |
| | | - sizeof (struct GNUNET_MULTICAST_MessageHeader) | |
| | | | |
| | | /** | |
| * Handle that identifies a join request. | | * Handle that identifies a join request. | |
| * | | * | |
| * Used to match calls to #GNUNET_MULTICAST_JoinCallback to the | | * Used to match calls to #GNUNET_MULTICAST_JoinCallback to the | |
| * corresponding calls to #GNUNET_MULTICAST_join_decision(). | | * corresponding calls to #GNUNET_MULTICAST_join_decision(). | |
| */ | | */ | |
| struct GNUNET_MULTICAST_JoinHandle; | | struct GNUNET_MULTICAST_JoinHandle; | |
| | | | |
| /** | | /** | |
| * Function to call with the decision made for a join request. | | * Function to call with the decision made for a join request. | |
| * | | * | |
| | | | |
| skipping to change at line 463 | | skipping to change at line 529 | |
| * messages transmitted to the group. If joining is disapproved, the faile
d | | * messages transmitted to the group. If joining is disapproved, the faile
d | |
| * candidate will be given a response. Members in the group can send messa
ges | | * candidate will be given a response. Members in the group can send messa
ges | |
| * to the origin (one at a time). | | * to the origin (one at a time). | |
| * | | * | |
| * @param cfg Configuration to use. | | * @param cfg Configuration to use. | |
| * @param priv_key ECC key that will be used to sign messages for this | | * @param priv_key ECC key that will be used to sign messages for this | |
| * multicast session; public key is used to identify the multicast g
roup; | | * multicast session; public key is used to identify the multicast g
roup; | |
| * @param next_fragment_id Next fragment ID to continue counting fragments
from | | * @param next_fragment_id Next fragment ID to continue counting fragments
from | |
| * when restarting the origin. 1 for a new group. | | * when restarting the origin. 1 for a new group. | |
| * @param join_cb Function called to approve / disapprove joining of a peer
. | | * @param join_cb Function called to approve / disapprove joining of a peer
. | |
|
| * @param mem_test_cb Function multicast can use to test group membership. | | * @param member_test_cb Function multicast can use to test group membershi
p. | |
| * @param replay_frag_cb Function that can be called to replay a message fr
agment. | | * @param replay_frag_cb Function that can be called to replay a message fr
agment. | |
| * @param replay_msg_cb Function that can be called to replay a message. | | * @param replay_msg_cb Function that can be called to replay a message. | |
| * @param request_cb Function called with message fragments from group memb
ers. | | * @param request_cb Function called with message fragments from group memb
ers. | |
| * @param message_cb Function called with the message fragments sent to the | | * @param message_cb Function called with the message fragments sent to the | |
| * network by GNUNET_MULTICAST_origin_to_all(). These message fragm
ents | | * network by GNUNET_MULTICAST_origin_to_all(). These message fragm
ents | |
| * should be stored for answering replay requests later. | | * should be stored for answering replay requests later. | |
| * @param cls Closure for the various callbacks that follow. | | * @param cls Closure for the various callbacks that follow. | |
| * @return Handle for the origin, NULL on error. | | * @return Handle for the origin, NULL on error. | |
| */ | | */ | |
| struct GNUNET_MULTICAST_Origin * | | struct GNUNET_MULTICAST_Origin * | |
| GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cf
g, | | GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cf
g, | |
| const struct GNUNET_CRYPTO_EddsaPrivateKey *
priv_key, | | const struct GNUNET_CRYPTO_EddsaPrivateKey *
priv_key, | |
| uint64_t next_fragment_id, | | uint64_t next_fragment_id, | |
| GNUNET_MULTICAST_JoinCallback join_cb, | | GNUNET_MULTICAST_JoinCallback join_cb, | |
|
| GNUNET_MULTICAST_MembershipTestCallback mem_
test_cb, | | GNUNET_MULTICAST_MembershipTestCallback memb
er_test_cb, | |
| GNUNET_MULTICAST_ReplayFragmentCallback repl
ay_frag_cb, | | GNUNET_MULTICAST_ReplayFragmentCallback repl
ay_frag_cb, | |
| GNUNET_MULTICAST_ReplayMessageCallback repla
y_msg_cb, | | GNUNET_MULTICAST_ReplayMessageCallback repla
y_msg_cb, | |
| GNUNET_MULTICAST_RequestCallback request_cb, | | GNUNET_MULTICAST_RequestCallback request_cb, | |
| GNUNET_MULTICAST_MessageCallback message_cb, | | GNUNET_MULTICAST_MessageCallback message_cb, | |
| void *cls); | | void *cls); | |
| | | | |
| /** | | /** | |
| * Function called to provide data for a transmission from the origin to al
l | | * Function called to provide data for a transmission from the origin to al
l | |
| * members. | | * members. | |
| * | | * | |
| | | | |
| skipping to change at line 713 | | skipping to change at line 779 | |
| | | | |
| /** | | /** | |
| * Handle for a message to be delivered from a member to the origin. | | * Handle for a message to be delivered from a member to the origin. | |
| */ | | */ | |
| struct GNUNET_MULTICAST_MemberRequestHandle; | | struct GNUNET_MULTICAST_MemberRequestHandle; | |
| | | | |
| /** | | /** | |
| * Send a message to the origin of the multicast group. | | * Send a message to the origin of the multicast group. | |
| * | | * | |
| * @param member Membership handle. | | * @param member Membership handle. | |
|
| * @param message_id Application layer ID for the message. Opaque to multi
cast. | | * @param request_id Application layer ID for the request. Opaque to multi
cast. | |
| * @param notify Callback to call to get the message. | | * @param notify Callback to call to get the message. | |
| * @param notify_cls Closure for @a notify. | | * @param notify_cls Closure for @a notify. | |
| * @return Handle to cancel request, NULL on error (i.e. request already pe
nding). | | * @return Handle to cancel request, NULL on error (i.e. request already pe
nding). | |
| */ | | */ | |
| struct GNUNET_MULTICAST_MemberRequestHandle * | | struct GNUNET_MULTICAST_MemberRequestHandle * | |
| GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member, | | GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member, | |
|
| uint64_t message_id, | | uint64_t request_id, | |
| GNUNET_MULTICAST_MemberTransmitNotify no
tify, | | GNUNET_MULTICAST_MemberTransmitNotify no
tify, | |
| void *notify_cls); | | void *notify_cls); | |
| | | | |
| /** | | /** | |
| * Resume message transmission to origin. | | * Resume message transmission to origin. | |
| * | | * | |
| * @param rh Request to cancel. | | * @param rh Request to cancel. | |
| */ | | */ | |
| void | | void | |
| GNUNET_MULTICAST_member_to_origin_resume (struct GNUNET_MULTICAST_MemberReq
uestHandle *rh); | | GNUNET_MULTICAST_member_to_origin_resume (struct GNUNET_MULTICAST_MemberReq
uestHandle *rh); | |
| | | | |
End of changes. 10 change blocks. |
| 11 lines changed or deleted | | 77 lines changed or added | |
|
| gnunet_nat_lib.h | | gnunet_nat_lib.h | |
| /* | | /* | |
| This file is part of GNUnet. | | This file is part of GNUnet. | |
|
| (C) 2007, 2008, 2009, 2010, 2011, 2012 Christian Grothoff (and other c
ontributing authors) | | (C) 2007-2014 Christian Grothoff (and other contributing authors) | |
| | | | |
| GNUnet is free software; you can redistribute it and/or modify | | GNUnet is free software; you can redistribute it and/or modify | |
| it under the terms of the GNU General Public License as published | | it under the terms of the GNU General Public License as published | |
| by the Free Software Foundation; either version 3, or (at your | | by the Free Software Foundation; either version 3, or (at your | |
| option) any later version. | | option) any later version. | |
| | | | |
| GNUnet is distributed in the hope that it will be useful, but | | GNUnet is distributed in the hope that it will be useful, but | |
| WITHOUT ANY WARRANTY; without even the implied warranty of | | WITHOUT ANY WARRANTY; without even the implied warranty of | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| General Public License for more details. | | General Public License for more details. | |
| | | | |
| skipping to change at line 25 | | skipping to change at line 25 | |
| You should have received a copy of the GNU General Public License | | You should have received a copy of the GNU General Public License | |
| along with GNUnet; see the file COPYING. If not, write to the | | along with GNUnet; see the file COPYING. If not, write to the | |
| Free Software Foundation, Inc., 59 Temple Place - Suite 330, | | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| Boston, MA 02111-1307, USA. | | Boston, MA 02111-1307, USA. | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @file include/gnunet_nat_lib.h | | * @file include/gnunet_nat_lib.h | |
| * @brief Library handling UPnP and NAT-PMP port forwarding and | | * @brief Library handling UPnP and NAT-PMP port forwarding and | |
| * external IP address retrieval | | * external IP address retrieval | |
|
| * | | * @author Christian Grothoff | |
| * @author Milan Bouchet-Valat | | * @author Milan Bouchet-Valat | |
| */ | | */ | |
| | | | |
| #ifndef GNUNET_NAT_LIB_H | | #ifndef GNUNET_NAT_LIB_H | |
| #define GNUNET_NAT_LIB_H | | #define GNUNET_NAT_LIB_H | |
| | | | |
| #include "gnunet_util_lib.h" | | #include "gnunet_util_lib.h" | |
| | | | |
| /** | | /** | |
| * Signature of the callback passed to #GNUNET_NAT_register() for | | * Signature of the callback passed to #GNUNET_NAT_register() for | |
| * a function to call whenever our set of 'valid' addresses changes. | | * a function to call whenever our set of 'valid' addresses changes. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param add_remove #GNUNET_YES to mean the new public IP address, #GNUNET
_NO to mean | | * @param add_remove #GNUNET_YES to mean the new public IP address, #GNUNET
_NO to mean | |
| * the previous (now invalid) one | | * the previous (now invalid) one | |
| * @param addr either the previous or the new public IP address | | * @param addr either the previous or the new public IP address | |
| * @param addrlen actual length of the @a addr | | * @param addrlen actual length of the @a addr | |
| */ | | */ | |
|
| typedef void (*GNUNET_NAT_AddressCallback) (void *cls, int add_remove, | | typedef void | |
| const struct sockaddr *addr, | | (*GNUNET_NAT_AddressCallback) (void *cls, | |
| socklen_t addrlen); | | int add_remove, | |
| | | const struct sockaddr *addr, | |
| | | socklen_t addrlen); | |
| | | | |
| /** | | /** | |
| * Signature of the callback passed to #GNUNET_NAT_register(). | | * Signature of the callback passed to #GNUNET_NAT_register(). | |
| * for a function to call whenever someone asks us to do connection | | * for a function to call whenever someone asks us to do connection | |
| * reversal. | | * reversal. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param addr public IP address of the other peer | | * @param addr public IP address of the other peer | |
| * @param addrlen actual lenght of the @a addr | | * @param addrlen actual lenght of the @a addr | |
| */ | | */ | |
|
| typedef void (*GNUNET_NAT_ReversalCallback) (void *cls, | | typedef void | |
| const struct sockaddr *addr, | | (*GNUNET_NAT_ReversalCallback) (void *cls, | |
| socklen_t addrlen); | | const struct sockaddr *addr, | |
| | | socklen_t addrlen); | |
| | | | |
| /** | | /** | |
| * Handle for active NAT registrations. | | * Handle for active NAT registrations. | |
| */ | | */ | |
| struct GNUNET_NAT_Handle; | | struct GNUNET_NAT_Handle; | |
| | | | |
| /** | | /** | |
|
| * Attempt to enable port redirection and detect public IP address contacti | | * Attempt to enable port redirection and detect public IP address | |
| ng | | * contacting UPnP or NAT-PMP routers on the local network. Use addr | |
| * UPnP or NAT-PMP routers on the local network. Use addr to specify to whi | | * to specify to which of the local host's addresses should the | |
| ch | | * external port be mapped. The port is taken from the corresponding | |
| * of the local host's addresses should the external port be mapped. The po | | * sockaddr_in[6] field. The NAT module should call the given | |
| rt | | * callback for any 'plausible' external address. | |
| * is taken from the corresponding sockaddr_in[6] field. The NAT module | | | |
| * should call the given callback for any 'plausible' external address. | | | |
| * | | * | |
| * @param cfg configuration to use | | * @param cfg configuration to use | |
| * @param is_tcp #GNUNET_YES for TCP, #GNUNET_NO for UDP | | * @param is_tcp #GNUNET_YES for TCP, #GNUNET_NO for UDP | |
| * @param adv_port advertised port (port we are either bound to or that our
OS | | * @param adv_port advertised port (port we are either bound to or that our
OS | |
| * locally performs redirection from to our bound port). | | * locally performs redirection from to our bound port). | |
| * @param num_addrs number of addresses in @a addrs | | * @param num_addrs number of addresses in @a addrs | |
| * @param addrs list of local addresses packets should be redirected to | | * @param addrs list of local addresses packets should be redirected to | |
| * @param addrlens actual lengths of the addresses in @a addrs | | * @param addrlens actual lengths of the addresses in @a addrs | |
| * @param address_callback function to call everytime the public IP address
changes | | * @param address_callback function to call everytime the public IP address
changes | |
| * @param reversal_callback function to call if someone wants connection re
versal from us, | | * @param reversal_callback function to call if someone wants connection re
versal from us, | |
| | | | |
| skipping to change at line 98 | | skipping to change at line 102 | |
| int is_tcp, | | int is_tcp, | |
| uint16_t adv_port, | | uint16_t adv_port, | |
| unsigned int num_addrs, | | unsigned int num_addrs, | |
| const struct sockaddr **addrs, | | const struct sockaddr **addrs, | |
| const socklen_t *addrlens, | | const socklen_t *addrlens, | |
| GNUNET_NAT_AddressCallback address_callback, | | GNUNET_NAT_AddressCallback address_callback, | |
| GNUNET_NAT_ReversalCallback reversal_callback, | | GNUNET_NAT_ReversalCallback reversal_callback, | |
| void *callback_cls); | | void *callback_cls); | |
| | | | |
| /** | | /** | |
|
| * Test if the given address is (currently) a plausible IP address for this | | * Test if the given address is (currently) a plausible IP address for | |
| peer. | | * this peer. | |
| * | | * | |
| * @param h the handle returned by register | | * @param h the handle returned by register | |
| * @param addr IP address to test (IPv4 or IPv6) | | * @param addr IP address to test (IPv4 or IPv6) | |
| * @param addrlen number of bytes in @a addr | | * @param addrlen number of bytes in @a addr | |
| * @return #GNUNET_YES if the address is plausible, | | * @return #GNUNET_YES if the address is plausible, | |
| * #GNUNET_NO if the address is not plausible, | | * #GNUNET_NO if the address is not plausible, | |
| * #GNUNET_SYSERR if the address is malformed | | * #GNUNET_SYSERR if the address is malformed | |
| */ | | */ | |
| int | | int | |
| GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h, | | GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h, | |
| | | | |
| skipping to change at line 149 | | skipping to change at line 154 | |
| struct GNUNET_NAT_Test; | | struct GNUNET_NAT_Test; | |
| | | | |
| /** | | /** | |
| * Function called to report success or failure for | | * Function called to report success or failure for | |
| * NAT configuration test. | | * NAT configuration test. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param success #GNUNET_OK on success, #GNUNET_NO on failure, | | * @param success #GNUNET_OK on success, #GNUNET_NO on failure, | |
| * #GNUNET_SYSERR if the test could not be | | * #GNUNET_SYSERR if the test could not be | |
| * properly started (internal failure) | | * properly started (internal failure) | |
|
| | | * @param emsg NULL on success, otherwise may include an error message | |
| */ | | */ | |
|
| typedef void (*GNUNET_NAT_TestCallback) (void *cls, int success); | | typedef void (*GNUNET_NAT_TestCallback) (void *cls, | |
| | | int success, | |
| | | const char *emsg); | |
| | | | |
| /** | | /** | |
| * Start testing if NAT traversal works using the | | * Start testing if NAT traversal works using the | |
| * given configuration (IPv4-only). | | * given configuration (IPv4-only). | |
| * | | * | |
| * @param cfg configuration for the NAT traversal | | * @param cfg configuration for the NAT traversal | |
| * @param is_tcp #GNUNET_YES to test TCP, #GNUNET_NO to test UDP | | * @param is_tcp #GNUNET_YES to test TCP, #GNUNET_NO to test UDP | |
| * @param bnd_port port to bind to, 0 for connection reversal | | * @param bnd_port port to bind to, 0 for connection reversal | |
| * @param adv_port externally advertised port to use | | * @param adv_port externally advertised port to use | |
| * @param report function to call with the result of the test | | * @param report function to call with the result of the test | |
| | | | |
| skipping to change at line 185 | | skipping to change at line 193 | |
| * @param tst test to stop. | | * @param tst test to stop. | |
| */ | | */ | |
| void | | void | |
| GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst); | | GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst); | |
| | | | |
| /** | | /** | |
| * Signature of a callback that is given an IP address. | | * Signature of a callback that is given an IP address. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param addr the address, NULL on errors | | * @param addr the address, NULL on errors | |
|
| | | * @param emsg NULL on success, otherwise may include an error message | |
| */ | | */ | |
| typedef void (*GNUNET_NAT_IPCallback) (void *cls, | | typedef void (*GNUNET_NAT_IPCallback) (void *cls, | |
|
| const struct in_addr * addr); | | const struct in_addr *addr, | |
| | | const char *emsg); | |
| | | | |
| /** | | /** | |
| * Opaque handle to cancel #GNUNET_NAT_mini_get_external_ipv4() operation. | | * Opaque handle to cancel #GNUNET_NAT_mini_get_external_ipv4() operation. | |
| */ | | */ | |
| struct GNUNET_NAT_ExternalHandle; | | struct GNUNET_NAT_ExternalHandle; | |
| | | | |
| /** | | /** | |
| * Try to get the external IPv4 address of this peer. | | * Try to get the external IPv4 address of this peer. | |
| * | | * | |
| * @param timeout when to fail | | * @param timeout when to fail | |
| | | | |
| skipping to change at line 221 | | skipping to change at line 231 | |
| */ | | */ | |
| void | | void | |
| GNUNET_NAT_mini_get_external_ipv4_cancel (struct GNUNET_NAT_ExternalHandle
*eh); | | GNUNET_NAT_mini_get_external_ipv4_cancel (struct GNUNET_NAT_ExternalHandle
*eh); | |
| | | | |
| /** | | /** | |
| * Handle to a mapping created with upnpc. | | * Handle to a mapping created with upnpc. | |
| */ | | */ | |
| struct GNUNET_NAT_MiniHandle; | | struct GNUNET_NAT_MiniHandle; | |
| | | | |
| /** | | /** | |
|
| | | * Signature of the callback passed to #GNUNET_NAT_register() for | |
| | | * a function to call whenever our set of 'valid' addresses changes. | |
| | | * | |
| | | * @param cls closure | |
| | | * @param add_remove #GNUNET_YES to mean the new public IP address, #GNUNET | |
| | | _NO to mean | |
| | | * the previous (now invalid) one | |
| | | * @param addr either the previous or the new public IP address | |
| | | * @param addrlen actual length of the @a addr | |
| | | */ | |
| | | typedef void | |
| | | (*GNUNET_NAT_MiniAddressCallback) (void *cls, | |
| | | int add_remove, | |
| | | const struct sockaddr *addr, | |
| | | socklen_t addrlen, | |
| | | const char *emsg); | |
| | | | |
| | | /** | |
| * Start mapping the given port using (mini)upnpc. This function | | * Start mapping the given port using (mini)upnpc. This function | |
| * should typically not be used directly (it is used within the | | * should typically not be used directly (it is used within the | |
| * general-purpose #GNUNET_NAT_register() code). However, it can be | | * general-purpose #GNUNET_NAT_register() code). However, it can be | |
| * used if specifically UPnP-based NAT traversal is to be used or | | * used if specifically UPnP-based NAT traversal is to be used or | |
| * tested. | | * tested. | |
| * | | * | |
| * @param port port to map | | * @param port port to map | |
| * @param is_tcp #GNUNET_YES to map TCP, #GNUNET_NO for UDP | | * @param is_tcp #GNUNET_YES to map TCP, #GNUNET_NO for UDP | |
| * @param ac function to call with mapping result | | * @param ac function to call with mapping result | |
| * @param ac_cls closure for @a ac | | * @param ac_cls closure for @a ac | |
| * @return NULL on error | | * @return NULL on error | |
| */ | | */ | |
| struct GNUNET_NAT_MiniHandle * | | struct GNUNET_NAT_MiniHandle * | |
|
| GNUNET_NAT_mini_map_start (uint16_t port, int is_tcp, | | GNUNET_NAT_mini_map_start (uint16_t port, | |
| GNUNET_NAT_AddressCallback ac, | | int is_tcp, | |
| | | GNUNET_NAT_MiniAddressCallback ac, | |
| void *ac_cls); | | void *ac_cls); | |
| | | | |
| /** | | /** | |
| * Remove a mapping created with (mini)upnpc. Calling | | * Remove a mapping created with (mini)upnpc. Calling | |
|
| * this function will give 'upnpc' 1s to remove tha mapping, | | * this function will give 'upnpc' 1s to remove the mapping, | |
| * so while this function is non-blocking, a task will be | | * so while this function is non-blocking, a task will be | |
| * left with the scheduler for up to 1s past this call. | | * left with the scheduler for up to 1s past this call. | |
| * | | * | |
| * @param mini the handle | | * @param mini the handle | |
| */ | | */ | |
| void | | void | |
| GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini); | | GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini); | |
| | | | |
| /** | | /** | |
| * Handle to auto-configuration in progress. | | * Handle to auto-configuration in progress. | |
| */ | | */ | |
| struct GNUNET_NAT_AutoHandle; | | struct GNUNET_NAT_AutoHandle; | |
| | | | |
| /** | | /** | |
| * Function called with the result from the autoconfiguration. | | * Function called with the result from the autoconfiguration. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param diff minimal suggested changes to the original configuration | | * @param diff minimal suggested changes to the original configuration | |
| * to make it work (as best as we can) | | * to make it work (as best as we can) | |
|
| | | * @param emsg NULL on success, otherwise may include an error message | |
| */ | | */ | |
|
| typedef void (*GNUNET_NAT_AutoResultCallback)(void *cls, | | typedef void | |
| const struct GNUNET_CONFIGURAT | | (*GNUNET_NAT_AutoResultCallback)(void *cls, | |
| ION_Handle *diff); | | const struct GNUNET_CONFIGURATION_Handle * | |
| | | diff, | |
| | | const char *emsg); | |
| | | | |
| /** | | /** | |
| * Start auto-configuration routine. The resolver service should | | * Start auto-configuration routine. The resolver service should | |
| * be available when this function is called. | | * be available when this function is called. | |
| * | | * | |
| * @param cfg initial configuration | | * @param cfg initial configuration | |
| * @param cb function to call with autoconfiguration result | | * @param cb function to call with autoconfiguration result | |
| * @param cb_cls closure for @a cb | | * @param cb_cls closure for @a cb | |
| * @return handle to cancel operation | | * @return handle to cancel operation | |
| */ | | */ | |
| | | | |
End of changes. 15 change blocks. |
| 26 lines changed or deleted | | 54 lines changed or added | |
|
| gnunet_protocols.h | | gnunet_protocols.h | |
| | | | |
| skipping to change at line 603 | | skipping to change at line 603 | |
| /** | | /** | |
| * Acknowledge receiving PUT request | | * Acknowledge receiving PUT request | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK 155 | | #define GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK 155 | |
| | | | |
| /** | | /** | |
| * Certain results are already known to the client, filter those. | | * Certain results are already known to the client, filter those. | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN 156 | | #define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN 156 | |
| | | | |
|
| | | /** | |
| | | * Trail setup request is received by a peer. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP 157 | |
| | | | |
| | | /** | |
| | | * Trail to a particular peer is returned to this peer. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_RESULT 158 | |
| | | | |
| | | /** | |
| | | * Verify if your immediate successor is still your immediate successor. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR 159 | |
| | | | |
| | | /** | |
| | | * Notify your new immediate successor that you are its new predecessor. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_DHT_P2P_NOTIFY_NEW_SUCCESSOR 160 | |
| | | | |
| | | /** | |
| | | * Message which contains the immediate predecessor of requested successor | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR_RESULT 161 | |
| | | | |
| | | /** | |
| | | * Message which contains the get result. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_DHT_P2P_GET_RESULT 162 | |
| /**************************************************************************
***** | | /**************************************************************************
***** | |
| * HOSTLIST message types | | * HOSTLIST message types | |
| **************************************************************************
****/ | | **************************************************************************
****/ | |
| | | | |
| /** | | /** | |
| * Hostlist advertisement message | | * Hostlist advertisement message | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT 160 | | #define GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT 160 | |
| | | | |
| /**************************************************************************
***** | | /**************************************************************************
***** | |
| | | | |
| skipping to change at line 884 | | skipping to change at line 913 | |
| * Payload client <-> service | | * Payload client <-> service | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA 285 | | #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA 285 | |
| | | | |
| /** | | /** | |
| * Local ACK for data. | | * Local ACK for data. | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK 286 | | #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK 286 | |
| | | | |
| /** | | /** | |
|
| * Local NACK for rejected channels. | | * Local information about all channels of service. | |
| */ | | */ | |
|
| #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_NACK 287 | | #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNELS 290 | |
| | | | |
| /** | | /** | |
|
| * Local information about all tunnels of service. DEPRECATED | | * Local information of service about a specific channel. | |
| */ | | */ | |
|
| #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS 287 | | #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL 291 | |
| #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNELS 287 | | | |
| | | | |
| /** | | /** | |
|
| * Local information of service about a specific tunnel. DEPRECATED | | * Local information about all tunnels of service. | |
| */ | | */ | |
|
| #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL 288 | | #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS 292 | |
| #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL 288 | | | |
| | | /** | |
| | | * Local information of service about a specific tunnel. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL 293 | |
| | | | |
| | | /** | |
| | | * Local information about all connections of service. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CONNECTIONS 294 | |
| | | | |
| | | /** | |
| | | * Local information of service about a specific connection. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CONNECTION 295 | |
| | | | |
| | | /** | |
| | | * Local information about all peers known to the service. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_PEERS 296 | |
| | | | |
| | | /** | |
| | | * Local information of service about a specific peer. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_PEER 297 | |
| | | | |
| /** | | /** | |
| * Traffic (net-cat style) used by the Command Line Interface. | | * Traffic (net-cat style) used by the Command Line Interface. | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_MESH_CLI 298 | | #define GNUNET_MESSAGE_TYPE_MESH_CLI 298 | |
| | | | |
| /** | | /** | |
| * 640kb should be enough for everybody | | * 640kb should be enough for everybody | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_MESH_RESERVE_END 299 | | #define GNUNET_MESSAGE_TYPE_MESH_RESERVE_END 299 | |
| | | | |
| skipping to change at line 1250 | | skipping to change at line 1302 | |
| | | | |
| /** | | /** | |
| * Transport DISCONNECT message exchanged between transport services to | | * Transport DISCONNECT message exchanged between transport services to | |
| * indicate that a connection should be dropped. | | * indicate that a connection should be dropped. | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT 378 | | #define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT 378 | |
| | | | |
| /** | | /** | |
| * Request to monitor addresses used by a peer or all peers. | | * Request to monitor addresses used by a peer or all peers. | |
| */ | | */ | |
|
| #define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE 380 | | #define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST 380 | |
| | | | |
| /** | | /** | |
| * Message send by a peer to notify the other to keep the session alive | | * Message send by a peer to notify the other to keep the session alive | |
| * and measure latency in a regular interval | | * and measure latency in a regular interval | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE 381 | | #define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE 381 | |
| | | | |
| /** | | /** | |
|
| * Response to a GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE message to | | * Response to a #GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE message t
o | |
| * measure latency in a regular interval | | * measure latency in a regular interval | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE 382 | | #define GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE 382 | |
| | | | |
| /** | | /** | |
|
| * Request to iterate over all known addresses. | | * Response to #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST | |
| | | * request to iterate over all known addresses. | |
| */ | | */ | |
|
| #define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE 383 | | #define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE 383 | |
| | | | |
| /** | | /** | |
| * Message send by a peer to notify the other to keep the session alive. | | * Message send by a peer to notify the other to keep the session alive. | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON 384 | | #define GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON 384 | |
| | | | |
| /** | | /** | |
| * Message containing traffic metrics for transport service | | * Message containing traffic metrics for transport service | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC 385 | | #define GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC 385 | |
| | | | |
|
| | | /** | |
| | | * Request to monitor address validations by a peer or all peers. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_REQUEST 386 | |
| | | | |
| | | /** | |
| | | * Response to #GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_REQUEST | |
| | | * request to iterate over all known addresses. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_VALIDATION_RESPONSE 387 | |
| | | | |
| /**************************************************************************
***** | | /**************************************************************************
***** | |
| * FS-PUBLISH-HELPER IPC Messages | | * FS-PUBLISH-HELPER IPC Messages | |
| **************************************************************************
****/ | | **************************************************************************
****/ | |
| | | | |
| /** | | /** | |
| * Progress information from the helper: found a file | | * Progress information from the helper: found a file | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE 420 | | #define GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE 420 | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 2039 | | skipping to change at line 2103 | |
| #define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_FRAGMENT 665 | | #define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_FRAGMENT 665 | |
| | | | |
| #define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_COUNTERS 666 | | #define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_COUNTERS 666 | |
| | | | |
| #define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_STATE 667 | | #define GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_STATE 667 | |
| | | | |
| /**************************************************************************
***** | | /**************************************************************************
***** | |
| * PSYC message types | | * PSYC message types | |
| **************************************************************************
****/ | | **************************************************************************
****/ | |
| | | | |
|
| | | /** | |
| | | * C: client | |
| | | * S: service | |
| | | * M: muticast | |
| | | */ | |
| | | | |
| | | /** S->C: result of an operation */ | |
| #define GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE 680 | | #define GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE 680 | |
| | | | |
|
| | | /** C->S: request to start a master */ | |
| #define GNUNET_MESSAGE_TYPE_PSYC_MASTER_START 681 | | #define GNUNET_MESSAGE_TYPE_PSYC_MASTER_START 681 | |
| | | | |
|
| | | /** S->C: master start acknowledgement */ | |
| #define GNUNET_MESSAGE_TYPE_PSYC_MASTER_START_ACK 682 | | #define GNUNET_MESSAGE_TYPE_PSYC_MASTER_START_ACK 682 | |
| | | | |
|
| #define GNUNET_MESSAGE_TYPE_PSYC_MASTER_STOP 683 | | /** C->S: request to start a master */ | |
| | | #define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN 683 | |
| | | | |
|
| #define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN 684 | | /** S->C: slave join acknowledgement */ | |
| | | #define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK 684 | |
| | | | |
|
| #define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK 685 | | /* 685-686 */ | |
| | | | |
| #define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_PART 686 | | | |
| | | | |
|
| | | /** M->S->C: incoming join request from multicast */ | |
| #define GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST 687 | | #define GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST 687 | |
| | | | |
|
| | | /** C->S->M: decision about a join request */ | |
| #define GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION 688 | | #define GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION 688 | |
| | | | |
|
| | | /** C->S: request to remove channel slave from the membership database. */ | |
| #define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD 689 | | #define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD 689 | |
| | | | |
|
| | | /** C->S: request to add channel slave to the membership database */ | |
| #define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM 690 | | #define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM 690 | |
| | | | |
|
| #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 691 | | /** M<->S<->C: PSYC message which contains one or more message parts. */ | |
| | | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE 691 | |
| | | | |
| | | /** Message part: method */ | |
| | | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 692 | |
| | | | |
|
| #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER 692 | | /** Message part: modifier */ | |
| | | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER 693 | |
| | | | |
|
| #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT 693 | | /** Message part: modifier continuation */ | |
| | | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT 694 | |
| | | | |
|
| #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA 694 | | /** Message part: data */ | |
| | | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA 695 | |
| | | | |
|
| #define GNUNET_MESSAGE_TYPE_PSYC_TRANSMIT_ACK 695 | | /** Message part: end of message */ | |
| | | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END 696 | |
| | | | |
|
| | | /** Message part: message cancelled */ | |
| | | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL 697 | |
| | | | |
| | | /** S->C: message acknowledgment */ | |
| | | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK 698 | |
| | | | |
| | | /* 699-700 */ | |
| | | | |
| | | /** C->S: client requests channel history from PSYCstore. */ | |
| #define GNUNET_MESSAGE_TYPE_PSYC_STORY_REQUEST 701 | | #define GNUNET_MESSAGE_TYPE_PSYC_STORY_REQUEST 701 | |
| | | | |
|
| #define GNUNET_MESSAGE_TYPE_PSYC_STORY_RESPONSE 702 | | /** S->C: result for a channel history request */ | |
| | | #define GNUNET_MESSAGE_TYPE_PSYC_STORY_RESULT 702 | |
| | | | |
|
| | | /** C->S: request best matching state variable from PSYCstore. */ | |
| #define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET 703 | | #define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET 703 | |
| | | | |
|
| | | /** C->S: request state variables with a given prefix from PSYCstore. */ | |
| #define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX 704 | | #define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX 704 | |
| | | | |
|
| #define GNUNET_MESSAGE_TYPE_PSYC_STATE_RESPONSE 705 | | /** S->C: result for a state request. */ | |
| | | #define GNUNET_MESSAGE_TYPE_PSYC_STATE_RESULT 705 | |
| #define GNUNET_MESSAGE_TYPE_PSYC_STATE_MODIFIER 706 | | | |
| | | | |
| #define GNUNET_MESSAGE_TYPE_PSYC_STATE_MOD_CONT 707 | | | |
| | | | |
| /**************************************************************************
***** | | /**************************************************************************
***** | |
| * CONVERSATION message types | | * CONVERSATION message types | |
| **************************************************************************
****/ | | **************************************************************************
****/ | |
| | | | |
| /** | | /** | |
| * Message to transmit the audio between helper and speaker/microphone libr
ary. | | * Message to transmit the audio between helper and speaker/microphone libr
ary. | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO 730 | | #define GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO 730 | |
| | | | |
| /** | | /** | |
|
| * Client -> Server message register a phone. | | * Client -> Server message to register a phone. | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER 731 | | #define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER 731 | |
| | | | |
| /** | | /** | |
| * Client -> Server message to reject/hangup a call | | * Client -> Server message to reject/hangup a call | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP 732 | | #define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP 732 | |
| | | | |
| /** | | /** | |
| * Client -> Server message to reject/hangup a call | | * Client -> Server message to reject/hangup a call | |
| | | | |
| skipping to change at line 2176 | | skipping to change at line 2270 | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_AUDIO 745 | | #define GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_AUDIO 745 | |
| | | | |
| /**************************************************************************
***** | | /**************************************************************************
***** | |
| * MULTICAST message types | | * MULTICAST message types | |
| **************************************************************************
****/ | | **************************************************************************
****/ | |
| | | | |
| /* WIP: no numbers assigned yet */ | | /* WIP: no numbers assigned yet */ | |
| | | | |
| /** | | /** | |
|
| | | * Start an origin. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_MULTICAST_ORIGIN_START 750 | |
| | | | |
| | | /** | |
| | | * Stop an origin. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_MULTICAST_ORIGIN_STOP 751 | |
| | | | |
| | | /** | |
| | | * Join a group as a member. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_MULTICAST_MEMBER_JOIN 752 | |
| | | | |
| | | /** | |
| | | * Leave a group. | |
| | | */ | |
| | | #define GNUNET_MESSAGE_TYPE_MULTICAST_MEMBER_PART 753 | |
| | | | |
| | | /** | |
| * Multicast message from the origin to all members. | | * Multicast message from the origin to all members. | |
| */ | | */ | |
|
| #define GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE 750 | | #define GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE 754 | |
| | | | |
| /** | | /** | |
| * A unicast message from a group member to the origin. | | * A unicast message from a group member to the origin. | |
| */ | | */ | |
|
| #define GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST | | #define GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST 755 | |
| | | | |
| /** | | /** | |
| * A peer wants to join the group. | | * A peer wants to join the group. | |
| * | | * | |
| * Unicast message to the origin or another group member. | | * Unicast message to the origin or another group member. | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST | | #define GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST | |
| | | | |
| /** | | /** | |
| * Response to a join request. | | * Response to a join request. | |
| | | | |
| skipping to change at line 2256 | | skipping to change at line 2370 | |
| * The cryptosystem has been established. | | * The cryptosystem has been established. | |
| * Contains the peer's share. | | * Contains the peer's share. | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_SECRET_READY 783 | | #define GNUNET_MESSAGE_TYPE_SECRETSHARING_CLIENT_SECRET_READY 783 | |
| | | | |
| /** | | /** | |
| * Next available: 800 | | * Next available: 800 | |
| */ | | */ | |
| | | | |
| /**************************************************************************
***** | | /**************************************************************************
***** | |
|
| * PSYC message types | | | |
| ************************************************************************** | | | |
| ****/ | | | |
| | | | |
| /************************************************************************** | | | |
| ***** | | | |
| * PSYCSTORE message types | | | |
| ************************************************************************** | | | |
| ****/ | | | |
| | | | |
| /************************************************************************** | | | |
| ***** | | | |
| * SOCIAL message types | | * SOCIAL message types | |
| **************************************************************************
****/ | | **************************************************************************
****/ | |
| | | | |
| /** | | /** | |
| * Type used to match 'all' message types. | | * Type used to match 'all' message types. | |
| */ | | */ | |
| #define GNUNET_MESSAGE_TYPE_ALL 65535 | | #define GNUNET_MESSAGE_TYPE_ALL 65535 | |
| | | | |
| #if 0 /* keep Emacsens' auto-indent happy */ | | #if 0 /* keep Emacsens' auto-indent happy */ | |
| { | | { | |
| | | | |
End of changes. 37 change blocks. |
| 43 lines changed or deleted | | 145 lines changed or added | |
|
| gnunet_psyc_service.h | | gnunet_psyc_service.h | |
| | | | |
| skipping to change at line 111 | | skipping to change at line 111 | |
| { | | { | |
| /** | | /** | |
| * Admission must be confirmed by the master. | | * Admission must be confirmed by the master. | |
| */ | | */ | |
| GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL = 1 << 0, | | GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL = 1 << 0, | |
| | | | |
| /** | | /** | |
| * Past messages are only available to slaves who were admitted at the ti
me | | * Past messages are only available to slaves who were admitted at the ti
me | |
| * they were sent to the channel. | | * they were sent to the channel. | |
| */ | | */ | |
|
| GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY = 1 << 1, | | GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY = 1 << 1 | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * PSYC channel policies. | | * PSYC channel policies. | |
| */ | | */ | |
| enum GNUNET_PSYC_Policy | | enum GNUNET_PSYC_Policy | |
| { | | { | |
| /** | | /** | |
| * Anyone can join the channel, without announcing his presence; | | * Anyone can join the channel, without announcing his presence; | |
| * all messages are always public and can be distributed freely. | | * all messages are always public and can be distributed freely. | |
| | | | |
| skipping to change at line 133 | | skipping to change at line 133 | |
| */ | | */ | |
| GNUNET_PSYC_CHANNEL_ANONYMOUS = 0, | | GNUNET_PSYC_CHANNEL_ANONYMOUS = 0, | |
| | | | |
| /** | | /** | |
| * The master must approve membership to the channel, messages must only
be | | * The master must approve membership to the channel, messages must only
be | |
| * distributed to current channel slaves. This includes the channel | | * distributed to current channel slaves. This includes the channel | |
| * state as well as transient messages. | | * state as well as transient messages. | |
| */ | | */ | |
| GNUNET_PSYC_CHANNEL_PRIVATE | | GNUNET_PSYC_CHANNEL_PRIVATE | |
| = GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL | | = GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL | |
|
| | GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY, | | | GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY | |
| | | | |
| #if IDEAS_FOR_FUTURE | | #if IDEAS_FOR_FUTURE | |
| /** | | /** | |
| * Anyone can freely join the channel (no approval required); | | * Anyone can freely join the channel (no approval required); | |
| * however, messages must only be distributed to current channel | | * however, messages must only be distributed to current channel | |
| * slaves, so the master must still acknowledge that the slave | | * slaves, so the master must still acknowledge that the slave | |
| * joined before transient messages are delivered. As approval is | | * joined before transient messages are delivered. As approval is | |
| * guaranteed, the presistent channel state can be synchronized freely | | * guaranteed, the presistent channel state can be synchronized freely | |
| * immediately, prior to master confirmation. | | * immediately, prior to master confirmation. | |
| */ | | */ | |
| GNUNET_PSYC_CHANNEL_OPEN | | GNUNET_PSYC_CHANNEL_OPEN | |
| = GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY, | | = GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY, | |
| | | | |
| /** | | /** | |
| * The master must approve joins to the channel, but past messages can be | | * The master must approve joins to the channel, but past messages can be | |
| * freely distributed to slaves. | | * freely distributed to slaves. | |
| */ | | */ | |
| GNUNET_PSYC_CHANNEL_CLOSED | | GNUNET_PSYC_CHANNEL_CLOSED | |
| = GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL, | | = GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL, | |
|
| , | | | |
| #endif | | #endif | |
|
| | | | |
| }; | | }; | |
| | | | |
| enum GNUNET_PSYC_MessageFlags | | enum GNUNET_PSYC_MessageFlags | |
| { | | { | |
| /** | | /** | |
|
| * First fragment of a message. | | * Historic message, retrieved from PSYCstore. | |
| */ | | */ | |
|
| GNUNET_PSYC_MESSAGE_FIRST_FRAGMENT = 1 << 0, | | GNUNET_PSYC_MESSAGE_HISTORIC = 1 << 0, | |
| | | | |
| /** | | /** | |
|
| * Last fragment of a message. | | * Request from slave to master. | |
| */ | | */ | |
|
| GNUNET_PSYC_MESSAGE_LAST_FRAGMENT = 1 << 1, | | GNUNET_PSYC_MESSAGE_REQUEST = 1 << 1 | |
| | | }; | |
| | | | |
|
| | | GNUNET_NETWORK_STRUCT_BEGIN | |
| | | | |
| | | /** | |
| | | * Header of a PSYC message. | |
| | | */ | |
| | | struct GNUNET_PSYC_MessageHeader | |
| | | { | |
| /** | | /** | |
|
| * OR'ed flags if message is not fragmented. | | * Generic message header with size and type information. | |
| */ | | */ | |
|
| GNUNET_PSYC_MESSAGE_NOT_FRAGMENTED | | struct GNUNET_MessageHeader header; | |
| = GNUNET_PSYC_MESSAGE_FIRST_FRAGMENT | | | |
| | GNUNET_PSYC_MESSAGE_LAST_FRAGMENT, | | | |
| | | | |
| /** | | /** | |
|
| * Historic message, retrieved from PSYCstore. | | * Flags for this message fragment. | |
| | | * | |
| | | * @see enum GNUNET_PSYC_MessageFlags | |
| | | */ | |
| | | uint32_t flags GNUNET_PACKED; | |
| | | | |
| | | /** | |
| | | * Number of the message this message part belongs to. | |
| | | * Monotonically increasing from 1. | |
| | | */ | |
| | | uint64_t message_id GNUNET_PACKED; | |
| | | | |
| | | /** | |
| | | * Sending slave's public key. | |
| | | * Not set if the message is from the master. | |
| | | */ | |
| | | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | |
| | | | |
| | | /* Followed by concatenated PSYC message parts: | |
| | | * messages with GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_* types | |
| */ | | */ | |
|
| GNUNET_PSYC_MESSAGE_HISTORIC = 1 << 30 | | | |
| }; | | }; | |
| | | | |
| /** | | /** | |
|
| * M | | * The method of a message. | |
| */ | | */ | |
| struct GNUNET_PSYC_MessageMethod | | struct GNUNET_PSYC_MessageMethod | |
| { | | { | |
| /** | | /** | |
| * Type: GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD | | * Type: GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD | |
| */ | | */ | |
| struct GNUNET_MessageHeader header; | | struct GNUNET_MessageHeader header; | |
| | | | |
|
| uint32_t reserved GNUNET_PACKED; | | | |
| | | | |
| /** | | | |
| * Number of modifiers in the message. | | | |
| */ | | | |
| uint32_t mod_count GNUNET_PACKED; | | | |
| | | | |
| /** | | /** | |
| * OR'ed GNUNET_PSYC_MasterTransmitFlags | | * OR'ed GNUNET_PSYC_MasterTransmitFlags | |
| */ | | */ | |
| uint32_t flags GNUNET_PACKED; | | uint32_t flags GNUNET_PACKED; | |
| | | | |
|
| /** | | | |
| * Sending slave's public key. | | | |
| * NULL if the message is from the master, or when transmitting a message | | | |
| . | | | |
| */ | | | |
| struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | | | |
| | | | |
| /* Followed by NUL-terminated method name. */ | | /* Followed by NUL-terminated method name. */ | |
| }; | | }; | |
| | | | |
|
| | | /** | |
| | | * A modifier of a message. | |
| | | */ | |
| struct GNUNET_PSYC_MessageModifier | | struct GNUNET_PSYC_MessageModifier | |
| { | | { | |
| /** | | /** | |
| * Type: GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER | | * Type: GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER | |
| */ | | */ | |
| struct GNUNET_MessageHeader header; | | struct GNUNET_MessageHeader header; | |
| | | | |
| /** | | /** | |
| * Size of value. | | * Size of value. | |
| */ | | */ | |
| | | | |
| skipping to change at line 239 | | skipping to change at line 251 | |
| uint16_t name_size GNUNET_PACKED; | | uint16_t name_size GNUNET_PACKED; | |
| | | | |
| /** | | /** | |
| * enum GNUNET_ENV_Operator | | * enum GNUNET_ENV_Operator | |
| */ | | */ | |
| uint8_t oper; | | uint8_t oper; | |
| | | | |
| /* Followed by NUL-terminated name, then the value. */ | | /* Followed by NUL-terminated name, then the value. */ | |
| }; | | }; | |
| | | | |
|
| enum GNUNET_PSYC_DataStatus | | GNUNET_NETWORK_STRUCT_END | |
| { | | | |
| /** | | | |
| * To be continued. | | | |
| */ | | | |
| GNUNET_PSYC_DATA_CONT = 0, | | | |
| | | | |
| /** | | | |
| * Reached the end of message. | | | |
| */ | | | |
| GNUNET_PSYC_DATA_END = 1, | | | |
| | | | |
| /** | | | |
| * Cancelled before the end. | | | |
| */ | | | |
| GNUNET_PSYC_DATA_CANCEL = 2 | | | |
| }; | | | |
| | | | |
| struct GNUNET_PSYC_MessageData | | | |
| { | | | |
| /** | | | |
| * Type: GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA | | | |
| */ | | | |
| struct GNUNET_MessageHeader header; | | | |
| | | | |
|
| /** | | #define GNUNET_PSYC_MODIFIER_MAX_PAYLOAD \ | |
| * enum GNUNET_PSYC_DataStatus | | GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \ | |
| */ | | - sizeof (struct GNUNET_PSYC_MessageModifier) | |
| uint8_t status; | | | |
| }; | | #define GNUNET_PSYC_MOD_CONT_MAX_PAYLOAD \ | |
| | | GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \ | |
| | | - sizeof (struct GNUNET_MessageHeader) | |
| | | | |
| | | #define GNUNET_PSYC_DATA_MAX_PAYLOAD \ | |
| | | GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \ | |
| | | - sizeof (struct GNUNET_MessageHeader) | |
| | | | |
| /** | | /** | |
| * Handle that identifies a join request. | | * Handle that identifies a join request. | |
| * | | * | |
| * Used to match calls to #GNUNET_PSYC_JoinCallback to the | | * Used to match calls to #GNUNET_PSYC_JoinCallback to the | |
| * corresponding calls to GNUNET_PSYC_join_decision(). | | * corresponding calls to GNUNET_PSYC_join_decision(). | |
| */ | | */ | |
| struct GNUNET_PSYC_JoinHandle; | | struct GNUNET_PSYC_JoinHandle; | |
| | | | |
| /** | | /** | |
|
| * Method called from PSYC upon receiving a message indicating a call to a | | * Method called from PSYC upon receiving part of a message. | |
| * @e method. | | | |
| * | | * | |
| * @param cls Closure. | | * @param cls Closure. | |
|
| * @param slave_key Who transmitted the message. | | * @param msg Message part, one of the following types: | |
| * - NULL for multicast messages from the master. | | * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER | |
| * - The sending slave's public key for unicast requests from one of | | * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD | |
| the | | * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER | |
| * slaves to the master. | | * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT | |
| * @param message_id Unique message counter for this message. | | * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA | |
| * Unique only in combination with the given sender for this channel | | | |
| . | | | |
| * @param method_name Method name from PSYC. | | | |
| * @param modifier_count Number of elements in the @a modifiers array. | | | |
| * @param modifiers State modifiers and transient variables for the message | | | |
| . | | | |
| * @param data_offset Byte offset of @a data in the overall data of the met | | | |
| hod. | | | |
| * @param data Data stream given to the method (might not be zero-terminate | | | |
| d | | | |
| * if data is binary). | | | |
| * @param data_size Number of bytes in @a data. | | | |
| * @param frag Fragmentation status for the data. | | | |
| */ | | */ | |
|
| typedef int | | typedef void | |
| (*GNUNET_PSYC_Method) (void *cls, | | (*GNUNET_PSYC_MessageCallback) (void *cls, | |
| const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key | | uint64_t message_id, | |
| , | | uint32_t flags, | |
| uint64_t message_id, | | const struct GNUNET_MessageHeader *msg); | |
| const char *method_name, | | | |
| size_t modifier_count, | | | |
| const struct GNUNET_ENV_Modifier *modifiers, | | | |
| uint64_t data_offset, | | | |
| const void *data, | | | |
| size_t data_size, | | | |
| enum GNUNET_PSYC_MessageFlags flags); | | | |
| | | | |
| /** | | /** | |
| * Method called from PSYC upon receiving a join request. | | * Method called from PSYC upon receiving a join request. | |
| * | | * | |
| * @param cls Closure. | | * @param cls Closure. | |
| * @param slave requesting to join. | | * @param slave requesting to join. | |
| * @param method_name Method name in the join request. | | * @param method_name Method name in the join request. | |
| * @param variable_count Number of elements in the @a variables array. | | * @param variable_count Number of elements in the @a variables array. | |
| * @param variables Transient variables for the join request. | | * @param variables Transient variables for the join request. | |
| * @param data Data stream given to the method (might not be zero-terminate
d | | * @param data Data stream given to the method (might not be zero-terminate
d | |
| * if data is binary). | | * if data is binary). | |
| * @param data_size Number of bytes in @a data. | | * @param data_size Number of bytes in @a data. | |
| * @param jh Join handle to use with GNUNET_PSYC_join_decision() | | * @param jh Join handle to use with GNUNET_PSYC_join_decision() | |
| */ | | */ | |
|
| typedef int | | typedef void | |
| (*GNUNET_PSYC_JoinCallback) (void *cls, | | (*GNUNET_PSYC_JoinCallback) (void *cls, | |
| const struct GNUNET_CRYPTO_EddsaPublicKey | | const struct GNUNET_CRYPTO_EddsaPublicKey | |
| *slave_key, | | *slave_key, | |
| const char *method_name, | | const char *method_name, | |
| size_t variable_count, | | size_t variable_count, | |
| const struct GNUNET_ENV_Modifier *variables, | | const struct GNUNET_ENV_Modifier *variables, | |
| const void *data, | | const void *data, | |
| size_t data_size, | | size_t data_size, | |
| struct GNUNET_PSYC_JoinHandle *jh); | | struct GNUNET_PSYC_JoinHandle *jh); | |
| | | | |
| | | | |
| skipping to change at line 376 | | skipping to change at line 356 | |
| | | | |
| /** | | /** | |
| * Handle for the master of a PSYC channel. | | * Handle for the master of a PSYC channel. | |
| */ | | */ | |
| struct GNUNET_PSYC_Master; | | struct GNUNET_PSYC_Master; | |
| | | | |
| /** | | /** | |
| * Function called after the channel master started. | | * Function called after the channel master started. | |
| * | | * | |
| * @param cls Closure. | | * @param cls Closure. | |
|
| * @param last_message_id Last message ID sent to the channel. | | * @param max_message_id Last message ID sent to the channel. | |
| */ | | */ | |
| typedef void | | typedef void | |
| (*GNUNET_PSYC_MasterStartCallback) (void *cls, uint64_t max_message_id); | | (*GNUNET_PSYC_MasterStartCallback) (void *cls, uint64_t max_message_id); | |
| | | | |
| /** | | /** | |
| * Start a PSYC master channel. | | * Start a PSYC master channel. | |
| * | | * | |
| * Will start a multicast group identified by the given ECC key. Messages | | * Will start a multicast group identified by the given ECC key. Messages | |
| * received from group members will be given to the respective handler meth
ods. | | * received from group members will be given to the respective handler meth
ods. | |
| * If a new member wants to join a group, the "join" method handler will be | | * If a new member wants to join a group, the "join" method handler will be | |
| | | | |
| skipping to change at line 403 | | skipping to change at line 383 | |
| * @param cfg Configuration to use (to connect to PSYC service). | | * @param cfg Configuration to use (to connect to PSYC service). | |
| * @param channel_key ECC key that will be used to sign messages for this | | * @param channel_key ECC key that will be used to sign messages for this | |
| * PSYC session. The public key is used to identify the PSYC channel
. | | * PSYC session. The public key is used to identify the PSYC channel
. | |
| * Note that end-users will usually not use the private key directly
, but | | * Note that end-users will usually not use the private key directly
, but | |
| * rather look it up in GNS for places managed by other users, or se
lect | | * rather look it up in GNS for places managed by other users, or se
lect | |
| * a file with the private key(s) when setting up their own channels | | * a file with the private key(s) when setting up their own channels | |
| * FIXME: we'll likely want to use NOT the p521 curve here, but a ch
eaper | | * FIXME: we'll likely want to use NOT the p521 curve here, but a ch
eaper | |
| * one in the future. | | * one in the future. | |
| * @param policy Channel policy specifying join and history restrictions. | | * @param policy Channel policy specifying join and history restrictions. | |
| * Used to automate join decisions. | | * Used to automate join decisions. | |
|
| * @param method Function to invoke on messages received from slaves. | | * @param message_cb Function to invoke on message parts received from slav
es. | |
| * @param join_cb Function to invoke when a peer wants to join. | | * @param join_cb Function to invoke when a peer wants to join. | |
| * @param master_started_cb Function to invoke after the channel master sta
rted. | | * @param master_started_cb Function to invoke after the channel master sta
rted. | |
| * @param cls Closure for @a method and @a join_cb. | | * @param cls Closure for @a method and @a join_cb. | |
| * @return Handle for the channel master, NULL on error. | | * @return Handle for the channel master, NULL on error. | |
| */ | | */ | |
| struct GNUNET_PSYC_Master * | | struct GNUNET_PSYC_Master * | |
| GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | | GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |
| const struct GNUNET_CRYPTO_EddsaPrivateKey *chann
el_key, | | const struct GNUNET_CRYPTO_EddsaPrivateKey *chann
el_key, | |
| enum GNUNET_PSYC_Policy policy, | | enum GNUNET_PSYC_Policy policy, | |
|
| GNUNET_PSYC_Method method, | | GNUNET_PSYC_MessageCallback message_cb, | |
| GNUNET_PSYC_JoinCallback join_cb, | | GNUNET_PSYC_JoinCallback join_cb, | |
| GNUNET_PSYC_MasterStartCallback master_started_cb
, | | GNUNET_PSYC_MasterStartCallback master_started_cb
, | |
| void *cls); | | void *cls); | |
| | | | |
| /** | | /** | |
| * Function called to provide data for a transmission via PSYC. | | * Function called to provide data for a transmission via PSYC. | |
| * | | * | |
|
| * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO) | | * Note that returning #GNUNET_YES or #GNUNET_SYSERR (but not #GNUNET_NO) | |
| * invalidates the respective transmission handle. | | * invalidates the respective transmission handle. | |
| * | | * | |
| * @param cls Closure. | | * @param cls Closure. | |
| * @param[in,out] data_size Initially set to the number of bytes available
in | | * @param[in,out] data_size Initially set to the number of bytes available
in | |
| * @a data, should be set to the number of bytes written to data. | | * @a data, should be set to the number of bytes written to data. | |
| * @param[out] data Where to write the body of the message to give to the | | * @param[out] data Where to write the body of the message to give to the | |
| * method. The function must copy at most @a data_size bytes to @a
data. | | * method. The function must copy at most @a data_size bytes to @a
data. | |
| * @return #GNUNET_SYSERR on error (fatal, aborts transmission) | | * @return #GNUNET_SYSERR on error (fatal, aborts transmission) | |
| * #GNUNET_NO on success, if more data is to be transmitted later. | | * #GNUNET_NO on success, if more data is to be transmitted later. | |
| * Should be used if @a data_size was not big enough to take all th
e | | * Should be used if @a data_size was not big enough to take all th
e | |
| * data. If 0 is returned in @a data_size the transmission is paus
ed, | | * data. If 0 is returned in @a data_size the transmission is paus
ed, | |
| * and can be resumed with GNUNET_PSYC_master_transmit_resume(). | | * and can be resumed with GNUNET_PSYC_master_transmit_resume(). | |
| * #GNUNET_YES if this completes the transmission (all data supplie
d) | | * #GNUNET_YES if this completes the transmission (all data supplie
d) | |
| */ | | */ | |
| typedef int | | typedef int | |
|
| (*GNUNET_PSYC_MasterTransmitNotify) (void *cls, | | (*GNUNET_PSYC_TransmitNotifyData) (void *cls, | |
| size_t *data_size, | | uint16_t *data_size, | |
| void *data); | | void *data); | |
| | | | |
| | | /** | |
| | | * Function called to provide a modifier for a transmission via PSYC. | |
| | | * | |
| | | * Note that returning #GNUNET_YES or #GNUNET_SYSERR (but not #GNUNET_NO) | |
| | | * invalidates the respective transmission handle. | |
| | | * | |
| | | * @param cls Closure. | |
| | | * @param[in,out] data_size Initially set to the number of bytes available | |
| | | in | |
| | | * @a data, should be set to the number of bytes written to data. | |
| | | * @param[out] data Where to write the modifier's name and value. | |
| | | * The function must copy at most @a data_size bytes to @a data. | |
| | | * When this callback is first called for a modifier, @a data shoul | |
| | | d | |
| | | * contain: "name\0value". If the whole value does not fit, subseq | |
| | | uent | |
| | | * calls to this function should write continuations of the value t | |
| | | o | |
| | | * @a data. | |
| | | * @param[out] oper Where to write the operator of the modifier. | |
| | | * Only needed during the first call to this callback at the beginn | |
| | | ing | |
| | | * of the modifier. In case of subsequent calls asking for value | |
| | | * continuations @a oper is set to #NULL. | |
| | | * @param[out] value_size Where to write the full size of the value. | |
| | | * Only needed during the first call to this callback at the beginn | |
| | | ing | |
| | | * of the modifier. In case of subsequent calls asking for value | |
| | | * continuations @a value_size is set to #NULL. | |
| | | * @return #GNUNET_SYSERR on error (fatal, aborts transmission) | |
| | | * #GNUNET_NO on success, if more data is to be transmitted later. | |
| | | * Should be used if @a data_size was not big enough to take all th | |
| | | e | |
| | | * data for the modifier's value (the name must be always returned | |
| | | * during the first call to this callback). | |
| | | * If 0 is returned in @a data_size the transmission is paused, | |
| | | * and can be resumed with GNUNET_PSYC_master_transmit_resume(). | |
| | | * #GNUNET_YES if this completes the modifier (the whole value is s | |
| | | upplied). | |
| | | */ | |
| | | typedef int | |
| | | (*GNUNET_PSYC_TransmitNotifyModifier) (void *cls, | |
| | | uint16_t *data_size, | |
| | | void *data, | |
| | | uint8_t *oper, | |
| | | uint32_t *value_size); | |
| | | | |
| /** | | /** | |
| * Flags for transmitting messages to a channel by the master. | | * Flags for transmitting messages to a channel by the master. | |
| */ | | */ | |
| enum GNUNET_PSYC_MasterTransmitFlags | | enum GNUNET_PSYC_MasterTransmitFlags | |
| { | | { | |
| GNUNET_PSYC_MASTER_TRANSMIT_NONE = 0, | | GNUNET_PSYC_MASTER_TRANSMIT_NONE = 0, | |
| /** | | /** | |
| * Whether this message should reset the channel state, | | * Whether this message should reset the channel state, | |
| * i.e. remove all previously stored state variables. | | * i.e. remove all previously stored state variables. | |
| | | | |
| skipping to change at line 475 | | skipping to change at line 494 | |
| /** | | /** | |
| * Handle for a pending PSYC transmission operation. | | * Handle for a pending PSYC transmission operation. | |
| */ | | */ | |
| struct GNUNET_PSYC_MasterTransmitHandle; | | struct GNUNET_PSYC_MasterTransmitHandle; | |
| | | | |
| /** | | /** | |
| * Send a message to call a method to all members in the PSYC channel. | | * Send a message to call a method to all members in the PSYC channel. | |
| * | | * | |
| * @param master Handle to the PSYC channel. | | * @param master Handle to the PSYC channel. | |
| * @param method_name Which method should be invoked. | | * @param method_name Which method should be invoked. | |
|
| * @param env Environment containing state operations and transient variabl | | * @param notify_mod Function to call to obtain modifiers. | |
| es | | * @param notify_data Function to call to obtain fragments of the data. | |
| * for the message, or NULL. | | * @param notify_cls Closure for @a notify_mod and @a notify_data. | |
| * @param notify Function to call to obtain the arguments. | | | |
| * @param notify_cls Closure for @a notify. | | | |
| * @param flags Flags for the message being transmitted. | | * @param flags Flags for the message being transmitted. | |
| * @return Transmission handle, NULL on error (i.e. more than one request q
ueued). | | * @return Transmission handle, NULL on error (i.e. more than one request q
ueued). | |
| */ | | */ | |
| struct GNUNET_PSYC_MasterTransmitHandle * | | struct GNUNET_PSYC_MasterTransmitHandle * | |
| GNUNET_PSYC_master_transmit (struct GNUNET_PSYC_Master *master, | | GNUNET_PSYC_master_transmit (struct GNUNET_PSYC_Master *master, | |
| const char *method_name, | | const char *method_name, | |
|
| const struct GNUNET_ENV_Environment *env, | | GNUNET_PSYC_TransmitNotifyModifier notify_mod, | |
| GNUNET_PSYC_MasterTransmitNotify notify, | | GNUNET_PSYC_TransmitNotifyData notify_data, | |
| void *notify_cls, | | void *notify_cls, | |
| enum GNUNET_PSYC_MasterTransmitFlags flags); | | enum GNUNET_PSYC_MasterTransmitFlags flags); | |
| | | | |
| /** | | /** | |
| * Resume transmission to the channel. | | * Resume transmission to the channel. | |
| * | | * | |
| * @param th Handle of the request that is being resumed. | | * @param th Handle of the request that is being resumed. | |
| */ | | */ | |
| void | | void | |
| GNUNET_PSYC_master_transmit_resume (struct GNUNET_PSYC_MasterTransmitHandle
*th); | | GNUNET_PSYC_master_transmit_resume (struct GNUNET_PSYC_MasterTransmitHandle
*th); | |
| | | | |
| skipping to change at line 547 | | skipping to change at line 565 | |
| * | | * | |
| * @param cfg Configuration to use. | | * @param cfg Configuration to use. | |
| * @param channel_key ECC public key that identifies the channel we wish to
join. | | * @param channel_key ECC public key that identifies the channel we wish to
join. | |
| * @param slave_key ECC private-public key pair that identifies the slave,
and | | * @param slave_key ECC private-public key pair that identifies the slave,
and | |
| * used by multicast to sign the join request and subsequent unicast | | * used by multicast to sign the join request and subsequent unicast | |
| * requests sent to the master. | | * requests sent to the master. | |
| * @param origin Peer identity of the origin. | | * @param origin Peer identity of the origin. | |
| * @param relay_count Number of peers in the @a relays array. | | * @param relay_count Number of peers in the @a relays array. | |
| * @param relays Peer identities of members of the multicast group, which s
erve | | * @param relays Peer identities of members of the multicast group, which s
erve | |
| * as relays and used to join the group at. | | * as relays and used to join the group at. | |
|
| * @param method Function to invoke on messages received from the channel, | | * @param message_cb Function to invoke on message parts received from the | |
| * typically at least contains functions for @e join and @e part. | | * channel, typically at least contains method handlers for @e join | |
| | | and | |
| | | * @e part. | |
| * @param join_cb function invoked once we have joined with the current | | * @param join_cb function invoked once we have joined with the current | |
| * message ID of the channel | | * message ID of the channel | |
| * @param slave_joined_cb Function to invoke when a peer wants to join. | | * @param slave_joined_cb Function to invoke when a peer wants to join. | |
|
| * @param cls Closure for @a method_cb and @a slave_joined_cb. | | * @param cls Closure for @a message_cb and @a slave_joined_cb. | |
| * @param method_name Method name for the join request. | | * @param method_name Method name for the join request. | |
| * @param env Environment containing transient variables for the request, o
r NULL. | | * @param env Environment containing transient variables for the request, o
r NULL. | |
| * @param data Payload for the join message. | | * @param data Payload for the join message. | |
| * @param data_size Number of bytes in @a data. | | * @param data_size Number of bytes in @a data. | |
| * @return Handle for the slave, NULL on error. | | * @return Handle for the slave, NULL on error. | |
| */ | | */ | |
| struct GNUNET_PSYC_Slave * | | struct GNUNET_PSYC_Slave * | |
| GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | | GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | |
| const struct GNUNET_CRYPTO_EddsaPublicKey *channel_
key, | | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_
key, | |
| const struct GNUNET_CRYPTO_EddsaPrivateKey *slave_k
ey, | | const struct GNUNET_CRYPTO_EddsaPrivateKey *slave_k
ey, | |
| const struct GNUNET_PeerIdentity *origin, | | const struct GNUNET_PeerIdentity *origin, | |
| uint32_t relay_count, | | uint32_t relay_count, | |
| const struct GNUNET_PeerIdentity *relays, | | const struct GNUNET_PeerIdentity *relays, | |
|
| GNUNET_PSYC_Method method, | | GNUNET_PSYC_MessageCallback message_cb, | |
| GNUNET_PSYC_JoinCallback join_cb, | | GNUNET_PSYC_JoinCallback join_cb, | |
| GNUNET_PSYC_SlaveJoinCallback slave_joined_cb, | | GNUNET_PSYC_SlaveJoinCallback slave_joined_cb, | |
| void *cls, | | void *cls, | |
| const char *method_name, | | const char *method_name, | |
| const struct GNUNET_ENV_Environment *env, | | const struct GNUNET_ENV_Environment *env, | |
| const void *data, | | const void *data, | |
| uint16_t data_size); | | uint16_t data_size); | |
| | | | |
| /** | | /** | |
| * Part a PSYC channel. | | * Part a PSYC channel. | |
| * | | * | |
| * Will terminate the connection to the PSYC service. Polite clients shoul
d | | * Will terminate the connection to the PSYC service. Polite clients shoul
d | |
| * first explicitly send a part request (via GNUNET_PSYC_slave_transmit()). | | * first explicitly send a part request (via GNUNET_PSYC_slave_transmit()). | |
| * | | * | |
| * @param slave Slave handle. | | * @param slave Slave handle. | |
| */ | | */ | |
| void | | void | |
| GNUNET_PSYC_slave_part (struct GNUNET_PSYC_Slave *slave); | | GNUNET_PSYC_slave_part (struct GNUNET_PSYC_Slave *slave); | |
| | | | |
| /** | | /** | |
|
| * Function called to provide data for a transmission to the channel master | | | |
| * (a.k.a. the @e host of the channel). | | | |
| * | | | |
| * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO) | | | |
| * invalidates the respective transmission handle. | | | |
| * | | | |
| * @param cls Closure. | | | |
| * @param[in,out] data_size Initially set to the number of bytes available | | | |
| in | | | |
| * @a data, should be set to the number of bytes written to data | | | |
| * (IN/OUT). | | | |
| * @param[out] data Where to write the body of the message to give to the m | | | |
| ethod; | | | |
| * function must copy at most @a *data_size bytes to @a data. | | | |
| * @return #GNUNET_SYSERR on error (fatal, aborts transmission). | | | |
| * #GNUNET_NO on success, if more data is to be transmitted later. | | | |
| * #GNUNET_YES if this completes the transmission (all data supplie | | | |
| d). | | | |
| */ | | | |
| typedef int | | | |
| (*GNUNET_PSYC_SlaveTransmitNotify) (void *cls, | | | |
| size_t *data_size, | | | |
| char *data); | | | |
| | | | |
| /** | | | |
| * Flags for transmitting messages to the channel master by a slave. | | * Flags for transmitting messages to the channel master by a slave. | |
| */ | | */ | |
| enum GNUNET_PSYC_SlaveTransmitFlags | | enum GNUNET_PSYC_SlaveTransmitFlags | |
| { | | { | |
| GNUNET_PSYC_SLAVE_TRANSMIT_NONE = 0 | | GNUNET_PSYC_SLAVE_TRANSMIT_NONE = 0 | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Handle for a pending PSYC transmission operation. | | * Handle for a pending PSYC transmission operation. | |
| */ | | */ | |
| struct GNUNET_PSYC_SlaveTransmitHandle; | | struct GNUNET_PSYC_SlaveTransmitHandle; | |
| | | | |
| /** | | /** | |
| * Request a message to be sent to the channel master. | | * Request a message to be sent to the channel master. | |
| * | | * | |
| * @param slave Slave handle. | | * @param slave Slave handle. | |
| * @param method_name Which (PSYC) method should be invoked (on host). | | * @param method_name Which (PSYC) method should be invoked (on host). | |
|
| * @param env Environment containing transient variables for the message, o | | * @param notify_mod Function to call to obtain modifiers. | |
| r NULL. | | * @param notify_data Function to call to obtain fragments of the data. | |
| * @param notify Function to call when we are allowed to transmit (to get d | | | |
| ata). | | | |
| * @param notify_cls Closure for @a notify. | | * @param notify_cls Closure for @a notify. | |
| * @param flags Flags for the message being transmitted. | | * @param flags Flags for the message being transmitted. | |
| * @return Transmission handle, NULL on error (i.e. more than one request q
ueued). | | * @return Transmission handle, NULL on error (i.e. more than one request q
ueued). | |
| */ | | */ | |
| struct GNUNET_PSYC_SlaveTransmitHandle * | | struct GNUNET_PSYC_SlaveTransmitHandle * | |
| GNUNET_PSYC_slave_transmit (struct GNUNET_PSYC_Slave *slave, | | GNUNET_PSYC_slave_transmit (struct GNUNET_PSYC_Slave *slave, | |
| const char *method_name, | | const char *method_name, | |
|
| const struct GNUNET_ENV_Environment *env, | | GNUNET_PSYC_TransmitNotifyModifier notify_mod, | |
| GNUNET_PSYC_SlaveTransmitNotify notify, | | GNUNET_PSYC_TransmitNotifyData notify_data, | |
| void *notify_cls, | | void *notify_cls, | |
| enum GNUNET_PSYC_SlaveTransmitFlags flags); | | enum GNUNET_PSYC_SlaveTransmitFlags flags); | |
| | | | |
| /** | | /** | |
| * Resume transmission to the master. | | * Resume transmission to the master. | |
| * | | * | |
| * @param th Handle of the request that is being resumed. | | * @param th Handle of the request that is being resumed. | |
| */ | | */ | |
| void | | void | |
|
| GNUNET_PSYC_slave_transmit_resume (struct GNUNET_PSYC_MasterTransmitHandle
*th); | | GNUNET_PSYC_slave_transmit_resume (struct GNUNET_PSYC_SlaveTransmitHandle *
th); | |
| | | | |
| /** | | /** | |
| * Abort transmission request to master. | | * Abort transmission request to master. | |
| * | | * | |
| * @param th Handle of the request that is being aborted. | | * @param th Handle of the request that is being aborted. | |
| */ | | */ | |
| void | | void | |
| GNUNET_PSYC_slave_transmit_cancel (struct GNUNET_PSYC_SlaveTransmitHandle *
th); | | GNUNET_PSYC_slave_transmit_cancel (struct GNUNET_PSYC_SlaveTransmitHandle *
th); | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 773 | | skipping to change at line 770 | |
| * Request to be told the message history of the channel. | | * Request to be told the message history of the channel. | |
| * | | * | |
| * Historic messages (but NOT the state at the time) will be replayed (give
n to | | * Historic messages (but NOT the state at the time) will be replayed (give
n to | |
| * the normal method handlers) if available and if access is permitted. | | * the normal method handlers) if available and if access is permitted. | |
| * | | * | |
| * To get the latest message, use 0 for both the start and end message ID. | | * To get the latest message, use 0 for both the start and end message ID. | |
| * | | * | |
| * @param channel Which channel should be replayed? | | * @param channel Which channel should be replayed? | |
| * @param start_message_id Earliest interesting point in history. | | * @param start_message_id Earliest interesting point in history. | |
| * @param end_message_id Last (exclusive) interesting point in history. | | * @param end_message_id Last (exclusive) interesting point in history. | |
|
| * @param method Function to invoke on messages received from the story. | | * @param message_cb Function to invoke on message parts received from the
story. | |
| * @param finish_cb Function to call when the requested story has been full
y | | * @param finish_cb Function to call when the requested story has been full
y | |
| * told (counting message IDs might not suffice, as some messages | | * told (counting message IDs might not suffice, as some messages | |
| * might be secret and thus the listener would not know the story is | | * might be secret and thus the listener would not know the story is | |
| * finished without being told explicitly); once this function | | * finished without being told explicitly); once this function | |
| * has been called, the client must not call | | * has been called, the client must not call | |
| * GNUNET_PSYC_channel_story_tell_cancel() anymore. | | * GNUNET_PSYC_channel_story_tell_cancel() anymore. | |
| * @param cls Closure for the callbacks. | | * @param cls Closure for the callbacks. | |
| * @return Handle to cancel story telling operation. | | * @return Handle to cancel story telling operation. | |
| */ | | */ | |
| struct GNUNET_PSYC_Story * | | struct GNUNET_PSYC_Story * | |
| GNUNET_PSYC_channel_story_tell (struct GNUNET_PSYC_Channel *channel, | | GNUNET_PSYC_channel_story_tell (struct GNUNET_PSYC_Channel *channel, | |
| uint64_t start_message_id, | | uint64_t start_message_id, | |
| uint64_t end_message_id, | | uint64_t end_message_id, | |
|
| GNUNET_PSYC_Method method, | | GNUNET_PSYC_MessageCallback message_cb, | |
| GNUNET_PSYC_FinishCallback *finish_cb, | | GNUNET_PSYC_FinishCallback finish_cb, | |
| void *cls); | | void *cls); | |
| | | | |
| /** | | /** | |
| * Abort story telling. | | * Abort story telling. | |
| * | | * | |
| * This function must not be called from within method handlers (as given t
o | | * This function must not be called from within method handlers (as given t
o | |
| * GNUNET_PSYC_slave_join()) of the slave. | | * GNUNET_PSYC_slave_join()) of the slave. | |
| * | | * | |
| * @param story Story telling operation to stop. | | * @param story Story telling operation to stop. | |
| */ | | */ | |
| | | | |
End of changes. 39 change blocks. |
| 145 lines changed or deleted | | 138 lines changed or added | |
|
| gnunet_secretsharing_service.h | | gnunet_secretsharing_service.h | |
| | | | |
| skipping to change at line 45 | | skipping to change at line 45 | |
| #endif | | #endif | |
| #endif | | #endif | |
| | | | |
| #include "platform.h" | | #include "platform.h" | |
| #include "gnunet_common.h" | | #include "gnunet_common.h" | |
| #include "gnunet_time_lib.h" | | #include "gnunet_time_lib.h" | |
| #include "gnunet_configuration_lib.h" | | #include "gnunet_configuration_lib.h" | |
| #include <gcrypt.h> | | #include <gcrypt.h> | |
| | | | |
| /** | | /** | |
|
| * Number of bits for secretsharing keys. | | * Number of bits for secretsharing elements. | |
| * Must be smaller than the Pallier key size used internally | | * Must be smaller than the Pallier key size used internally | |
| * by the secretsharing service. | | * by the secretsharing service. | |
|
| | | * When changing this value, other internal parameters must also | |
| | | * be adjusted. | |
| */ | | */ | |
|
| #define GNUNET_SECRETSHARING_KEY_BITS 1024 | | #define GNUNET_SECRETSHARING_ELGAMAL_BITS 1024 | |
| | | | |
| | | /** | |
| | | * The q-parameter for ElGamal encryption, a 1024-bit safe prime. | |
| | | */ | |
| | | #define GNUNET_SECRETSHARING_ELGAMAL_P_HEX \ | |
| | | "0x08a347d3d69e8b2dd7d1b12a08dfbccbebf4ca" \ | |
| | | "6f4269a0814e158a34312964d946b3ef22882317" \ | |
| | | "2bcf30fc08f772774cb404f9bc002a6f66b09a79" \ | |
| | | "d810d67c4f8cb3bedc6060e3c8ef874b1b64df71" \ | |
| | | "6c7d2b002da880e269438d5a776e6b5f253c8df5" \ | |
| | | "6a16b1c7ce58def07c03db48238aadfc52a354a2" \ | |
| | | "7ed285b0c1675cad3f3" | |
| | | | |
| | | /** | |
| | | * The q-parameter for ElGamal encryption, | |
| | | * a 1023-bit Sophie Germain prime, q = (p-1)/2 | |
| | | */ | |
| | | #define GNUNET_SECRETSHARING_ELGAMAL_Q_HEX \ | |
| | | "0x0451a3e9eb4f4596ebe8d895046fde65f5fa65" \ | |
| | | "37a134d040a70ac51a1894b26ca359f79144118b" \ | |
| | | "95e7987e047bb93ba65a027cde001537b3584d3c" \ | |
| | | "ec086b3e27c659df6e303071e477c3a58db26fb8" \ | |
| | | "b63e958016d4407134a1c6ad3bb735af929e46fa" \ | |
| | | "b50b58e3e72c6f783e01eda411c556fe2951aa51" \ | |
| | | "3f6942d860b3ae569f9" | |
| | | | |
| | | /** | |
| | | * The g-parameter for ElGamal encryption, | |
| | | * a generator of the unique size q subgroup of Z_p^* | |
| | | */ | |
| | | #define GNUNET_SECRETSHARING_ELGAMAL_G_HEX \ | |
| | | "0x05c00c36d2e822950087ef09d8252994adc4e4" \ | |
| | | "8fe3ec70269f035b46063aff0c99b633fd64df43" \ | |
| | | "02442e1914c829a41505a275438871f365e91c12" \ | |
| | | "3d5303ef9e90f4b8cb89bf86cc9b513e74a72634" \ | |
| | | "9cfd9f953674fab5d511e1c078fc72d72b34086f" \ | |
| | | "c82b4b951989eb85325cb203ff98df76bc366bba" \ | |
| | | "1d7024c3650f60d0da" | |
| | | | |
| /** | | /** | |
| * Session that will eventually establish a shared secred between | | * Session that will eventually establish a shared secred between | |
| * the involved peers and allow encryption and cooperative decryption. | | * the involved peers and allow encryption and cooperative decryption. | |
| */ | | */ | |
| struct GNUNET_SECRETSHARING_Session; | | struct GNUNET_SECRETSHARING_Session; | |
| | | | |
| /** | | /** | |
| * Share of a secret shared with a group of peers. | | * Share of a secret shared with a group of peers. | |
|
| * Contains both the share and information about the peers that have | | * Contains the secret share itself, the public key, the list of peers, and | |
| * the other parts of the share. | | the | |
| | | * exponential commitments to the secret shares of the other peers. | |
| */ | | */ | |
| struct GNUNET_SECRETSHARING_Share; | | struct GNUNET_SECRETSHARING_Share; | |
| | | | |
| /** | | /** | |
| * Handle to cancel a cooperative decryption operation. | | * Handle to cancel a cooperative decryption operation. | |
| */ | | */ | |
| struct GNUNET_SECRETSHARING_DecryptionHandle; | | struct GNUNET_SECRETSHARING_DecryptionHandle; | |
| | | | |
| /** | | /** | |
| * Public key of a group sharing a secret. | | * Public key of a group sharing a secret. | |
| */ | | */ | |
| struct GNUNET_SECRETSHARING_PublicKey | | struct GNUNET_SECRETSHARING_PublicKey | |
| { | | { | |
|
| uint32_t bits[GNUNET_SECRETSHARING_KEY_BITS / 8 / sizeof (uint32_t)]; | | uint32_t bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)]; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Encrypted field element. | | * Encrypted field element. | |
| */ | | */ | |
| struct GNUNET_SECRETSHARING_Ciphertext | | struct GNUNET_SECRETSHARING_Ciphertext | |
| { | | { | |
|
| uint32_t bits[2 * GNUNET_SECRETSHARING_KEY_BITS / 8 / sizeof (uint32_t)]; | | uint32_t c1_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t | |
| | | )]; | |
| | | uint32_t c2_bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t | |
| | | )]; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Plain, unencrypted message that can be encrypted with | | * Plain, unencrypted message that can be encrypted with | |
| * a group public key. | | * a group public key. | |
|
| | | * Note that we are not operating in GF(2^n), thus not every | |
| | | * bit pattern is a valid plain text. | |
| */ | | */ | |
|
| struct GNUNET_SECRETSHARING_Message | | struct GNUNET_SECRETSHARING_Plaintext | |
| { | | { | |
| /** | | /** | |
| * Value of the message. | | * Value of the message. | |
| */ | | */ | |
|
| gcry_mpi_t value; | | uint32_t bits[GNUNET_SECRETSHARING_ELGAMAL_BITS / 8 / sizeof (uint32_t)]; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Called once the secret has been established with all peers, or the deadl
ine is due. | | * Called once the secret has been established with all peers, or the deadl
ine is due. | |
| * | | * | |
| * Note that the number of peers can be smaller than 'k' (this threshold pa
rameter), which | | * Note that the number of peers can be smaller than 'k' (this threshold pa
rameter), which | |
| * makes the threshold crypto system useless. However, in this case one ca
n still determine which peers | | * makes the threshold crypto system useless. However, in this case one ca
n still determine which peers | |
| * were able to participate in the secret sharing successfully. | | * were able to participate in the secret sharing successfully. | |
| * | | * | |
| * If the secret sharing failed, num_ready_peers is 0 and my_share and publ
ic_key is NULL. | | * If the secret sharing failed, num_ready_peers is 0 and my_share and publ
ic_key is NULL. | |
| * | | * | |
|
| | | * After this callback has been called, the secretsharing session will be i | |
| | | nvalid. | |
| | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param my_share the share of this peer | | * @param my_share the share of this peer | |
| * @param public_key public key of the session | | * @param public_key public key of the session | |
| * @param num_ready_peers number of peers in @a ready_peers | | * @param num_ready_peers number of peers in @a ready_peers | |
| * @param ready_peers peers that successfuly participated in establishing | | * @param ready_peers peers that successfuly participated in establishing | |
| * the shared secret | | * the shared secret | |
| */ | | */ | |
| typedef void (*GNUNET_SECRETSHARING_SecretReadyCallback) (void *cls, | | typedef void (*GNUNET_SECRETSHARING_SecretReadyCallback) (void *cls, | |
|
| const struct GNUN | | struct GNUNET_SEC | |
| ET_SECRETSHARING_Share *my_share, | | RETSHARING_Share *my_share, | |
| const struct GNUN | | struct GNUNET_SEC | |
| ET_SECRETSHARING_PublicKey *public_key, | | RETSHARING_PublicKey *public_key, | |
| unsigned int num_
ready_peers, | | unsigned int num_
ready_peers, | |
|
| const struct GNUN
ET_PeerIdentity *ready_peers); | | struct GNUNET_Pee
rIdentity *ready_peers); | |
| | | | |
| /** | | /** | |
| * Called when a decryption has succeeded. | | * Called when a decryption has succeeded. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param data decrypted value | | * @param data decrypted value | |
| * @param data_size number of bytes in @a data | | * @param data_size number of bytes in @a data | |
| */ | | */ | |
| typedef void (*GNUNET_SECRETSHARING_DecryptCallback) (void *cls, | | typedef void (*GNUNET_SECRETSHARING_DecryptCallback) (void *cls, | |
|
| const void *data, | | const struct GNUNET_S | |
| size_t data_size); | | ECRETSHARING_Plaintext *plaintext); | |
| | | | |
| /** | | /** | |
| * Create a session that will eventually establish a shared secret | | * Create a session that will eventually establish a shared secret | |
| * with the other peers. | | * with the other peers. | |
| * | | * | |
| * @param cfg configuration to use | | * @param cfg configuration to use | |
| * @param num_peers number of peers in 'peers' | | * @param num_peers number of peers in 'peers' | |
| * @param peers array of peers that we will share secrets with, can optiona
lly contain the local peer | | * @param peers array of peers that we will share secrets with, can optiona
lly contain the local peer | |
| * @param session_id unique session id | | * @param session_id unique session id | |
|
| | | * @param start When should all peers be available for sharing the secret? | |
| | | * Random number generation can take place before the start ti | |
| | | me. | |
| * @param deadline point in time where the session must be established; tak
en as hint | | * @param deadline point in time where the session must be established; tak
en as hint | |
| * by underlying consensus sessions | | * by underlying consensus sessions | |
| * @param threshold minimum number of peers that must cooperate to decrypt
a value | | * @param threshold minimum number of peers that must cooperate to decrypt
a value | |
| * @param cb called when the secret has been established | | * @param cb called when the secret has been established | |
| * @param cls closure for cb | | * @param cls closure for cb | |
| */ | | */ | |
| struct GNUNET_SECRETSHARING_Session * | | struct GNUNET_SECRETSHARING_Session * | |
| GNUNET_SECRETSHARING_create_session (const struct GNUNET_CONFIGURATION_Hand
le *cfg, | | GNUNET_SECRETSHARING_create_session (const struct GNUNET_CONFIGURATION_Hand
le *cfg, | |
| unsigned int num_peers, | | unsigned int num_peers, | |
| const struct GNUNET_PeerIdentity *peer
s, | | const struct GNUNET_PeerIdentity *peer
s, | |
| const struct GNUNET_HashCode *session_
id, | | const struct GNUNET_HashCode *session_
id, | |
|
| | | struct GNUNET_TIME_Absolute start, | |
| struct GNUNET_TIME_Absolute deadline, | | struct GNUNET_TIME_Absolute deadline, | |
| unsigned int threshold, | | unsigned int threshold, | |
| GNUNET_SECRETSHARING_SecretReadyCallba
ck cb, | | GNUNET_SECRETSHARING_SecretReadyCallba
ck cb, | |
| void *cls); | | void *cls); | |
| | | | |
| /** | | /** | |
|
| * Destroy a secret share. | | | |
| * | | | |
| * @param share secret share to destroy | | | |
| */ | | | |
| void | | | |
| GNUNET_SECRETSHARING_share_destroy (const struct GNUNET_SECRETSHARING_Share | | | |
| *share); | | | |
| | | | |
| /** | | | |
| * Destroy a secret sharing session. | | * Destroy a secret sharing session. | |
|
| | | * The secret ready callback will not be called. | |
| * | | * | |
| * @param session session to destroy | | * @param session session to destroy | |
| */ | | */ | |
| void | | void | |
|
| GNUNET_SECRETSHARING_destroy_session (struct GNUNET_SECRETSHARING_Session *
session); | | GNUNET_SECRETSHARING_session_destroy (struct GNUNET_SECRETSHARING_Session *
session); | |
| | | | |
| /** | | /** | |
| * Encrypt a value. This operation is executed locally, no communication i
s | | * Encrypt a value. This operation is executed locally, no communication i
s | |
| * necessary. | | * necessary. | |
| * | | * | |
| * This is a helper function, encryption can be done soley with a session's
public key | | * This is a helper function, encryption can be done soley with a session's
public key | |
| * and the crypto system parameters. | | * and the crypto system parameters. | |
| * | | * | |
| * @param public_key public key to use for decryption | | * @param public_key public key to use for decryption | |
| * @param message message to encrypt | | * @param message message to encrypt | |
| * @param message_size number of bytes in @a message | | * @param message_size number of bytes in @a message | |
| * @param result_ciphertext pointer to store the resulting ciphertext | | * @param result_ciphertext pointer to store the resulting ciphertext | |
| * @return #GNUNET_YES on succes, #GNUNET_SYSERR if the message is invalid
(invalid range) | | * @return #GNUNET_YES on succes, #GNUNET_SYSERR if the message is invalid
(invalid range) | |
| */ | | */ | |
| int | | int | |
|
| GNUNET_SECRETSHARING_encrypt (struct GNUNET_SECRETSHARING_PublicKey *public | | GNUNET_SECRETSHARING_encrypt (const struct GNUNET_SECRETSHARING_PublicKey * | |
| _key, | | public_key, | |
| const void *message, | | const struct GNUNET_SECRETSHARING_Plaintext * | |
| size_t message_size, | | plaintext, | |
| struct GNUNET_SECRETSHARING_Ciphertext *resul
t_ciphertext); | | struct GNUNET_SECRETSHARING_Ciphertext *resul
t_ciphertext); | |
| | | | |
| /** | | /** | |
| * Publish the given ciphertext for decryption. Once a sufficient (>=k) nu
mber of peers has | | * Publish the given ciphertext for decryption. Once a sufficient (>=k) nu
mber of peers has | |
| * published the same value, it will be decrypted. | | * published the same value, it will be decrypted. | |
| * | | * | |
| * When the operation is canceled, the decrypt_cb is not called anymore, bu
t the calling | | * When the operation is canceled, the decrypt_cb is not called anymore, bu
t the calling | |
| * peer may already have irrevocably contributed his share for the decrypti
on of the value. | | * peer may already have irrevocably contributed his share for the decrypti
on of the value. | |
| * | | * | |
|
| | | * @param cfg configuration to use | |
| * @param share our secret share to use for decryption | | * @param share our secret share to use for decryption | |
| * @param ciphertext ciphertext to publish in order to decrypt it (if enoug
h peers agree) | | * @param ciphertext ciphertext to publish in order to decrypt it (if enoug
h peers agree) | |
| * @param decrypt_cb callback called once the decryption succeeded | | * @param decrypt_cb callback called once the decryption succeeded | |
|
| | | * @param start By when should the cooperation for decryption start? | |
| | | * @param deadline By when should the decryption be finished? | |
| * @param decrypt_cb_cls closure for @a decrypt_cb | | * @param decrypt_cb_cls closure for @a decrypt_cb | |
| * @return handle to cancel the operation | | * @return handle to cancel the operation | |
| */ | | */ | |
| struct GNUNET_SECRETSHARING_DecryptionHandle * | | struct GNUNET_SECRETSHARING_DecryptionHandle * | |
|
| GNUNET_SECRETSHARING_decrypt (struct GNUNET_SECRETSHARING_Share *share, | | GNUNET_SECRETSHARING_decrypt (const struct GNUNET_CONFIGURATION_Handle *cfg | |
| struct GNUNET_SECRETSHARING_Ciphertext *ciphe | | , | |
| rtext, | | struct GNUNET_SECRETSHARING_Share *share, | |
| | | const struct GNUNET_SECRETSHARING_Ciphertext | |
| | | *ciphertext, | |
| | | struct GNUNET_TIME_Absolute start, | |
| | | struct GNUNET_TIME_Absolute deadline, | |
| GNUNET_SECRETSHARING_DecryptCallback decrypt_
cb, | | GNUNET_SECRETSHARING_DecryptCallback decrypt_
cb, | |
| void *decrypt_cb_cls); | | void *decrypt_cb_cls); | |
| | | | |
| /** | | /** | |
| * Cancel a decryption. | | * Cancel a decryption. | |
| * | | * | |
| * The decrypt_cb is not called anymore, but the calling | | * The decrypt_cb is not called anymore, but the calling | |
| * peer may already have irrevocably contributed his share for the decrypti
on of the value. | | * peer may already have irrevocably contributed his share for the decrypti
on of the value. | |
| * | | * | |
| * @param decryption_handle decryption to cancel | | * @param decryption_handle decryption to cancel | |
| */ | | */ | |
| void | | void | |
| GNUNET_SECRETSHARING_decrypt_cancel (struct GNUNET_SECRETSHARING_Decryption
Handle *decryption_handle); | | GNUNET_SECRETSHARING_decrypt_cancel (struct GNUNET_SECRETSHARING_Decryption
Handle *decryption_handle); | |
| | | | |
| /** | | /** | |
| * Read a share from its binary representation. | | * Read a share from its binary representation. | |
| * | | * | |
|
| * @param data binary representation of the share | | * @param data Binary representation of the share. | |
| * @param len length of @a data | | * @param len Length of @a data. | |
| * @return the share, or NULL on error | | * @param[out] readlen Number of bytes read, | |
| | | * ignored if NULL. | |
| | | * @return The share, or NULL on error. | |
| */ | | */ | |
| struct GNUNET_SECRETSHARING_Share * | | struct GNUNET_SECRETSHARING_Share * | |
|
| GNUNET_SECRETSHARING_share_read (void *data, size_t len); | | GNUNET_SECRETSHARING_share_read (const void *data, size_t len, size_t *read
len); | |
| | | | |
| /** | | /** | |
|
| * Convert a share to its binary representation. Use | | * Convert a share to its binary representation. | |
| * #GNUNET_SECRETSHARING_share_size to get the necessary size for the binar | | * Can be called with a NULL @a buf to get the size of the share. | |
| y | | * | |
| * representation. | | * @param share Share to write. | |
| * | | * @param buf Buffer to write to. | |
| * @param share share to write | | * @param buflen Number of writable bytes in @a buf. | |
| * @param buf buffer to write to | | * @param[out] writelen Pointer to store number of bytes written, | |
| * @param buflen number of writable bytes in @a buffer | | * ignored if NULL. | |
| * @param[out] writelen pointer to store number of bytes written, | | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure. | |
| * ignored if NULL | | | |
| * @return GNUNET_YES on success, GNUNET_NO on failure | | | |
| */ | | */ | |
| int | | int | |
|
| GNUNET_SECRETSHARING_share_write (struct GNUNET_SECRETSHARING_Share *share, | | GNUNET_SECRETSHARING_share_write (const struct GNUNET_SECRETSHARING_Share *
share, | |
| void *buf, size_t buflen, size_t *writele
n); | | void *buf, size_t buflen, size_t *writele
n); | |
| | | | |
|
| /** | | void | |
| * Get the number of bytes necessary to represent the given share. | | GNUNET_SECRETSHARING_share_destroy (struct GNUNET_SECRETSHARING_Share *shar | |
| * | | e); | |
| * @param share share | | | |
| * @return number of bytes necessary to represent @a share | | int | |
| */ | | GNUNET_SECRETSHARING_plaintext_generate (struct GNUNET_SECRETSHARING_Plaint | |
| size_t | | ext *plaintext, | |
| GNUNET_SECRETSHARING_share_size (struct GNUNET_SECRETSHARING_Share *share); | | gcry_mpi_t exponent); | |
| | | | |
| | | int | |
| | | GNUNET_SECRETSHARING_plaintext_generate_i (struct GNUNET_SECRETSHARING_Plai | |
| | | ntext *plaintext, | |
| | | int64_t exponent); | |
| | | | |
| #if 0 /* keep Emacsens' auto-indent happy */ | | #if 0 /* keep Emacsens' auto-indent happy */ | |
| { | | { | |
| #endif | | #endif | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 27 change blocks. |
| 56 lines changed or deleted | | 113 lines changed or added | |
|
| gnunet_transport_plugin.h | | gnunet_transport_plugin.h | |
| | | | |
| skipping to change at line 80 | | skipping to change at line 80 | |
| * use NULL wherever a session pointer is needed. This function | | * use NULL wherever a session pointer is needed. This function | |
| * should be called BEFORE a potential "TransmitContinuation" | | * should be called BEFORE a potential "TransmitContinuation" | |
| * from the "TransmitFunction". | | * from the "TransmitFunction". | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param peer which peer was the session for | | * @param peer which peer was the session for | |
| * @param session which session is being destroyed | | * @param session which session is being destroyed | |
| */ | | */ | |
| typedef void | | typedef void | |
| (*GNUNET_TRANSPORT_SessionEnd) (void *cls, | | (*GNUNET_TRANSPORT_SessionEnd) (void *cls, | |
|
| const struct GNUNET_PeerIdentity *peer, | | const struct GNUNET_HELLO_Address *address, | |
| struct Session *session); | | struct Session *session); | |
| | | | |
| /** | | /** | |
|
| * Function that will be called whenever the plugin internally | | * Plugin tells transport service about a new inbound session | |
| * creates a new session and hence transport need to tell ATS. | | | |
| * This happens when we have a inbound connection we did not | | | |
| * initiate. | | | |
| * | | * | |
|
| * @param cls closure | | * @param cls unused | |
| * @param peer peer | | * @param address the address | |
| * @param plugin plugin | | * @param session the new session | |
| * @param address address | | * @param ats ats information | |
| * @param address_len length of the @a address | | * @param ats_count number of @a ats information | |
| * @param session session | | | |
| * @param ats ATS information | | | |
| * @param ats_count number of entries in @a ats array | | | |
| */ | | */ | |
| typedef void | | typedef void | |
| (*GNUNET_TRANSPORT_SessionStart) (void *cls, | | (*GNUNET_TRANSPORT_SessionStart) (void *cls, | |
|
| const struct GNUNET_PeerIdentity *peer, | | struct GNUNET_HELLO_Address *address, | |
| const char *plugin, | | | |
| const void *address, | | | |
| uint16_t address_len, | | | |
| struct Session *session, | | struct Session *session, | |
| const struct GNUNET_ATS_Information *ats, | | const struct GNUNET_ATS_Information *ats, | |
| uint32_t ats_count); | | uint32_t ats_count); | |
| | | | |
| /** | | /** | |
| * Function called by the transport for each received message. | | * Function called by the transport for each received message. | |
| * This function should also be called with "NULL" for the | | * This function should also be called with "NULL" for the | |
| * message to signal that the other peer disconnected. | | * message to signal that the other peer disconnected. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| | | | |
| skipping to change at line 132 | | skipping to change at line 123 | |
| * for inbound TCP/UDP connections since it it not clear | | * for inbound TCP/UDP connections since it it not clear | |
| * that we could establish ourselves a connection to that | | * that we could establish ourselves a connection to that | |
| * IP address and get the same system) | | * IP address and get the same system) | |
| * @param sender_address_len number of bytes in @a sender_address | | * @param sender_address_len number of bytes in @a sender_address | |
| * @return how long the plugin should wait until receiving more data; | | * @return how long the plugin should wait until receiving more data; | |
| * returning #GNUNET_TIME_UNIT_FOREVER_REL means that the | | * returning #GNUNET_TIME_UNIT_FOREVER_REL means that the | |
| * connection should be closed | | * connection should be closed | |
| */ | | */ | |
| typedef struct GNUNET_TIME_Relative | | typedef struct GNUNET_TIME_Relative | |
| (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls, | | (*GNUNET_TRANSPORT_PluginReceiveCallback) (void *cls, | |
|
| const struct GNUNET_PeerIdentity | | const struct GNUNET_HELLO_Address *address, | |
| *peer, | | struct Session *session, | |
| const struct GNUNET_MessageHeade | | const struct GNUNET_MessageHeader *message); | |
| r *message, | | | |
| struct Session *session, | | | |
| const char *sender_address, | | | |
| uint16_t sender_address_len); | | | |
| | | | |
| /** | | /** | |
| * Function that will be called to figure if an address is an loopback, | | * Function that will be called to figure if an address is an loopback, | |
| * LAN, WAN etc. address | | * LAN, WAN etc. address | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param addr binary address | | * @param addr binary address | |
| * @param addrlen length of the @a addr | | * @param addrlen length of the @a addr | |
| * @return ATS Information containing the network type | | * @return ATS Information containing the network type | |
| */ | | */ | |
| | | | |
| skipping to change at line 165 | | skipping to change at line 154 | |
| * @param cls closure | | * @param cls closure | |
| * @param peer peer | | * @param peer peer | |
| * @param address address | | * @param address address | |
| * @param address_len length of the @a address | | * @param address_len length of the @a address | |
| * @param session session | | * @param session session | |
| * @param ats ATS information | | * @param ats ATS information | |
| * @param ats_count number entries in the @a ats array | | * @param ats_count number entries in the @a ats array | |
| */ | | */ | |
| typedef void | | typedef void | |
| (*GNUNET_TRANSPORT_UpdateAddressMetrics) (void *cls, | | (*GNUNET_TRANSPORT_UpdateAddressMetrics) (void *cls, | |
|
| const struct GNUNET_PeerIdentity * | | const struct GNUNET_HELLO_Address | |
| peer, | | *address, | |
| const void *address, | | | |
| uint16_t address_len, | | | |
| struct Session *session, | | struct Session *session, | |
| const struct GNUNET_ATS_Informatio
n *ats, | | const struct GNUNET_ATS_Informatio
n *ats, | |
| uint32_t ats_count); | | uint32_t ats_count); | |
| | | | |
| /** | | /** | |
| * Function that will be called for each address the transport | | * Function that will be called for each address the transport | |
| * is aware that it might be reachable under. | | * is aware that it might be reachable under. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param add_remove should the address added (#GNUNET_YES) or removed (#GN
UNET_NO) from the | | * @param add_remove should the address added (#GNUNET_YES) or removed (#GN
UNET_NO) from the | |
| * set of valid addresses? | | * set of valid addresses? | |
|
| * @param addr one of the addresses of the host | | * @param address the address to add or remove | |
| * the specific address format depends on the transport | | | |
| * @param addrlen length of the @a addr | | | |
| * @param dest_plugin plugin to use this address with | | | |
| */ | | */ | |
| typedef void | | typedef void | |
|
| (*GNUNET_TRANSPORT_AddressNotification) (void *cls, | | (*GNUNET_TRANSPORT_AddressNotification) (void *cls, int add_remove, | |
| int add_remove, | | const struct GNUNET_HELLO_Address *address); | |
| const void *addr, | | | |
| size_t addrlen, | | | |
| const char *dest_plugin); | | | |
| | | | |
| /** | | /** | |
| * Function that will be called whenever the plugin receives data over | | * Function that will be called whenever the plugin receives data over | |
| * the network and wants to determine how long it should wait until | | * the network and wants to determine how long it should wait until | |
| * the next time it reads from the given peer. Note that some plugins | | * the next time it reads from the given peer. Note that some plugins | |
| * (such as UDP) may not be able to wait (for a particular peer), so | | * (such as UDP) may not be able to wait (for a particular peer), so | |
| * the waiting part is optional. Plugins that can wait should call | | * the waiting part is optional. Plugins that can wait should call | |
| * this function, sleep the given amount of time, and call it again | | * this function, sleep the given amount of time, and call it again | |
| * (with zero bytes read) UNTIL it returns zero and only then read. | | * (with zero bytes read) UNTIL it returns zero and only then read. | |
| * | | * | |
| | | | |
| skipping to change at line 212 | | skipping to change at line 193 | |
| * @param amount_recved number of bytes read (can be zero) | | * @param amount_recved number of bytes read (can be zero) | |
| * @return how long to wait until reading more from this peer | | * @return how long to wait until reading more from this peer | |
| * (to enforce inbound quotas); returning #GNUNET_TIME_UNIT_FOREVER
_REL | | * (to enforce inbound quotas); returning #GNUNET_TIME_UNIT_FOREVER
_REL | |
| * means that the connection should be closed | | * means that the connection should be closed | |
| */ | | */ | |
| typedef struct GNUNET_TIME_Relative | | typedef struct GNUNET_TIME_Relative | |
| (*GNUNET_TRANSPORT_TrafficReport) (void *cls, | | (*GNUNET_TRANSPORT_TrafficReport) (void *cls, | |
| const struct GNUNET_PeerIdentity *peer, | | const struct GNUNET_PeerIdentity *peer, | |
| size_t amount_recved); | | size_t amount_recved); | |
| | | | |
|
| | | typedef void | |
| | | (*GNUNET_TRANSPORT_RegisterQuotaNotification) (void *cls, | |
| | | const struct GNUNET_PeerIdentity | |
| | | *peer, | |
| | | const char *plugin, | |
| | | struct Session *session); | |
| | | | |
| | | typedef void | |
| | | (*GNUNET_TRANSPORT_UnregisterQuotaNotification) (void *cls, | |
| | | const struct GNUNET_PeerIdentity *peer, const char *plugin, struct Sess | |
| | | ion *session); | |
| | | | |
| /** | | /** | |
| * Function that returns a HELLO message. | | * Function that returns a HELLO message. | |
| */ | | */ | |
| typedef const struct GNUNET_MessageHeader * | | typedef const struct GNUNET_MessageHeader * | |
| (*GNUNET_TRANSPORT_GetHelloCallback) (void); | | (*GNUNET_TRANSPORT_GetHelloCallback) (void); | |
| | | | |
| /** | | /** | |
| * The transport service will pass a pointer to a struct | | * The transport service will pass a pointer to a struct | |
| * of this type as the first and only argument to the | | * of this type as the first and only argument to the | |
| * entry point of each transport plugin. | | * entry point of each transport plugin. | |
| | | | |
| skipping to change at line 291 | | skipping to change at line 282 | |
| * LAN, WAN etc. address | | * LAN, WAN etc. address | |
| */ | | */ | |
| GNUNET_TRANSPORT_AddressToType get_address_type; | | GNUNET_TRANSPORT_AddressToType get_address_type; | |
| | | | |
| /** | | /** | |
| * Function that will be called to figure if an address is an loopback, | | * Function that will be called to figure if an address is an loopback, | |
| * LAN, WAN etc. address | | * LAN, WAN etc. address | |
| */ | | */ | |
| GNUNET_TRANSPORT_UpdateAddressMetrics update_address_metrics; | | GNUNET_TRANSPORT_UpdateAddressMetrics update_address_metrics; | |
| | | | |
|
| | | GNUNET_TRANSPORT_RegisterQuotaNotification register_quota_notification; | |
| | | | |
| | | GNUNET_TRANSPORT_UnregisterQuotaNotification unregister_quota_notificatio | |
| | | n; | |
| | | | |
| /** | | /** | |
| * What is the maximum number of connections that this transport | | * What is the maximum number of connections that this transport | |
| * should allow? Transports that do not have sessions (such as | | * should allow? Transports that do not have sessions (such as | |
| * UDP) can ignore this value. | | * UDP) can ignore this value. | |
| */ | | */ | |
| uint32_t max_connections; | | uint32_t max_connections; | |
| | | | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 490 | | skipping to change at line 485 | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param peer which peer was the session for | | * @param peer which peer was the session for | |
| * @param session which session is being updated | | * @param session which session is being updated | |
| */ | | */ | |
| typedef void | | typedef void | |
| (*GNUNET_TRANSPORT_UpdateSessionTimeout) (void *cls, | | (*GNUNET_TRANSPORT_UpdateSessionTimeout) (void *cls, | |
| const struct GNUNET_PeerIdentity
*peer, | | const struct GNUNET_PeerIdentity
*peer, | |
| struct Session *session); | | struct Session *session); | |
| | | | |
|
| | | typedef void | |
| | | (*GNUNET_TRANSPORT_UpdateInboundDelay) (void *cls, | |
| | | const struct GNUNET_PeerIdentity | |
| | | *peer, | |
| | | struct Session *session, | |
| | | struct GNUNET_TIME_Relative delay | |
| | | ); | |
| | | | |
| /** | | /** | |
| * Function called for a quick conversion of the binary address to | | * Function called for a quick conversion of the binary address to | |
| * a numeric address. Note that the caller must not free the | | * a numeric address. Note that the caller must not free the | |
| * address and that the next call to this function is allowed | | * address and that the next call to this function is allowed | |
| * to override the address again. | | * to override the address again. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param addr binary address | | * @param addr binary address | |
| * @param addr_len length of the @a addr | | * @param addr_len length of the @a addr | |
| * @return string representing the same address | | * @return string representing the same address | |
| | | | |
| skipping to change at line 578 | | skipping to change at line 579 | |
| */ | | */ | |
| GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session; | | GNUNET_TRANSPORT_DisconnectSessionFunction disconnect_session; | |
| | | | |
| /** | | /** | |
| * Function that will be called whenever the transport service wants to | | * Function that will be called whenever the transport service wants to | |
| * notify the plugin that a session is still active and in use and | | * notify the plugin that a session is still active and in use and | |
| * therefore the session timeout for this session has to be updated | | * therefore the session timeout for this session has to be updated | |
| */ | | */ | |
| GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout; | | GNUNET_TRANSPORT_UpdateSessionTimeout update_session_timeout; | |
| | | | |
|
| | | GNUNET_TRANSPORT_UpdateInboundDelay update_inbound_delay; | |
| | | | |
| | | /** | |
| | | * Function that will be called whenever the transport service wants to | |
| | | * notify the plugin that the inbound quota changed and that the plugin | |
| | | * should update it's delay for the next receive value | |
| | | */ | |
| | | //GNUNET_TRANSPORT_UpdateNextReceiveTimeout update_next_receive_timeout; | |
| | | | |
| /** | | /** | |
| * Function that is used to query keepalive factor. | | * Function that is used to query keepalive factor. | |
| * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to | | * GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT is divided by this number to | |
| * calculate the interval between keepalive packets. | | * calculate the interval between keepalive packets. | |
| */ | | */ | |
| GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor; | | GNUNET_TRANSPORT_QueryKeepaliveFactorFunction query_keepalive_factor; | |
| | | | |
| /** | | /** | |
| * Function to pretty-print addresses. NOTE: this function is not | | * Function to pretty-print addresses. NOTE: this function is not | |
| * yet used by transport-service, but will be used in the future | | * yet used by transport-service, but will be used in the future | |
| | | | |
| skipping to change at line 627 | | skipping to change at line 637 | |
| * object | | * object | |
| */ | | */ | |
| GNUNET_TRANSPORT_CreateSession get_session; | | GNUNET_TRANSPORT_CreateSession get_session; | |
| | | | |
| /** | | /** | |
| * Function to obtain the network type for a session | | * Function to obtain the network type for a session | |
| */ | | */ | |
| GNUNET_TRANSPORT_GetNetworkType get_network; | | GNUNET_TRANSPORT_GetNetworkType get_network; | |
| }; | | }; | |
| | | | |
|
| | | /*#ifndef PLUGIN_TRANSPORT_H*/ | |
| #endif | | #endif | |
|
| | | /* end of gnunet_transport_plugin.h */ | |
| | | | |
End of changes. 14 change blocks. |
| 37 lines changed or deleted | | 51 lines changed or added | |
|
| gnunet_transport_service.h | | gnunet_transport_service.h | |
| /* | | /* | |
| This file is part of GNUnet. | | This file is part of GNUnet. | |
|
| (C) 2009, 2010, 2011 Christian Grothoff (and other contributing author
s) | | (C) 2009-2014 Christian Grothoff (and other contributing authors) | |
| | | | |
| GNUnet is free software; you can redistribute it and/or modify | | GNUnet is free software; you can redistribute it and/or modify | |
| it under the terms of the GNU General Public License as published | | it under the terms of the GNU General Public License as published | |
| by the Free Software Foundation; either version 3, or (at your | | by the Free Software Foundation; either version 3, or (at your | |
| option) any later version. | | option) any later version. | |
| | | | |
| GNUnet is distributed in the hope that it will be useful, but | | GNUnet is distributed in the hope that it will be useful, but | |
| WITHOUT ANY WARRANTY; without even the implied warranty of | | WITHOUT ANY WARRANTY; without even the implied warranty of | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| General Public License for more details. | | General Public License for more details. | |
| | | | |
| skipping to change at line 44 | | skipping to change at line 44 | |
| } | | } | |
| #endif | | #endif | |
| #endif | | #endif | |
| | | | |
| #include "gnunet_util_lib.h" | | #include "gnunet_util_lib.h" | |
| #include "gnunet_ats_service.h" | | #include "gnunet_ats_service.h" | |
| | | | |
| /** | | /** | |
| * Version number of the transport API. | | * Version number of the transport API. | |
| */ | | */ | |
|
| #define GNUNET_TRANSPORT_VERSION 0x00000000 | | #define GNUNET_TRANSPORT_VERSION 0x00000001 | |
| | | | |
| | | /** | |
| | | * Possible state of a neighbour. Initially, we are #GNUNET_TRANSPORT_PS_N | |
| | | OT_CONNECTED. | |
| | | * | |
| | | * Then, there are two main paths. If we receive a CONNECT message, we give | |
| | | * the inbound address to ATS. After the check we ask ATS for a suggestion | |
| | | * (#GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS). If ATS makes a suggestion, we | |
| | | * send our CONNECT_ACK and go to #GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK. | |
| | | * If we receive a SESSION_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED | |
| | | * (and notify everyone about the new connection). If the operation times o | |
| | | ut, | |
| | | * we go to #GNUNET_TRANSPORT_PS_DISCONNECT. | |
| | | * | |
| | | * The other case is where we transmit a CONNECT message first. We | |
| | | * start with #GNUNET_TRANSPORT_PS_INIT_ATS. If we get an address, we send | |
| | | * the CONNECT message and go to state #GNUNET_TRANSPORT_PS_CONNECT_SENT. | |
| | | * Once we receive a CONNECT_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED | |
| | | * (and notify everyone about the new connection and send | |
| | | * back a SESSION_ACK). If the operation times out, we go to | |
| | | * #GNUNET_TRANSPORT_PS_DISCONNECT. | |
| | | * | |
| | | * If the session is in trouble (i.e. transport-level disconnect or | |
| | | * timeout), we go to #GNUNET_TRANSPORT_PS_RECONNECT_ATS where we ask ATS f | |
| | | or a new | |
| | | * address (we don't notify anyone about the disconnect yet). Once we | |
| | | * have a new address, we enter #GNUNET_TRANSPORT_PS_RECONNECT_SENT and sen | |
| | | d a | |
| | | * CONNECT message. If we receive a | |
| | | * CONNECT_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED and nobody noticed | |
| | | that we had | |
| | | * trouble; we also send a SESSION_ACK at this time just in case. If | |
| | | * the operation times out, we go to #GNUNET_TRANSPORT_PS_DISCONNECT (and n | |
| | | otify everyone | |
| | | * about the lost connection). | |
| | | * | |
| | | * If ATS decides to switch addresses while we have a normal | |
| | | * connection, we go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SE | |
| | | NT | |
| | | * and send a SESSION_CONNECT. If we get a SESSION_ACK back, we switch the | |
| | | * primary connection to the suggested alternative from ATS, go back | |
| | | * to #GNUNET_TRANSPORT_PS_CONNECTED and send a SESSION_ACK to the other pe | |
| | | er just to be | |
| | | * sure. If the operation times out | |
| | | * we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify ATS that the given a | |
| | | lternative | |
| | | * address is "invalid"). | |
| | | * | |
| | | * Once a session is in #GNUNET_TRANSPORT_PS_DISCONNECT, it is cleaned up a | |
| | | nd then goes | |
| | | * to (#GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED). If we receive an explici | |
| | | t disconnect | |
| | | * request, we can go from any state to #GNUNET_TRANSPORT_PS_DISCONNECT, po | |
| | | ssibly after | |
| | | * generating disconnect notifications. | |
| | | * | |
| | | * Note that it is quite possible that while we are in any of these | |
| | | * states, we could receive a 'CONNECT' request from the other peer. | |
| | | * We then enter a 'weird' state where we pursue our own primary state | |
| | | * machine (as described above), but with the 'send_connect_ack' flag | |
| | | * set to 1. If our state machine allows us to send a 'CONNECT_ACK' | |
| | | * (because we have an acceptable address), we send the 'CONNECT_ACK' | |
| | | * and set the 'send_connect_ack' to 2. If we then receive a | |
| | | * 'SESSION_ACK', we go to #GNUNET_TRANSPORT_PS_CONNECTED (and reset 'send_ | |
| | | connect_ack' | |
| | | * to 0). | |
| | | * | |
| | | */ | |
| | | enum GNUNET_TRANSPORT_PeerState | |
| | | { | |
| | | /** | |
| | | * Fresh peer or completely disconnected | |
| | | */ | |
| | | GNUNET_TRANSPORT_PS_NOT_CONNECTED = 0, | |
| | | | |
| | | /** | |
| | | * Asked to initiate connection, trying to get address from ATS | |
| | | */ | |
| | | GNUNET_TRANSPORT_PS_INIT_ATS, | |
| | | | |
| | | /** | |
| | | * Sent CONNECT message to other peer, waiting for CONNECT_ACK | |
| | | */ | |
| | | GNUNET_TRANSPORT_PS_CONNECT_SENT, | |
| | | | |
| | | /** | |
| | | * Received a CONNECT, asking ATS about address suggestions. | |
| | | */ | |
| | | GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS, | |
| | | | |
| | | /** | |
| | | * CONNECT request from other peer was CONNECT_ACK'ed, waiting for | |
| | | * SESSION_ACK. | |
| | | */ | |
| | | GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK, | |
| | | | |
| | | /** | |
| | | * Got our CONNECT_ACK/SESSION_ACK, connection is up. | |
| | | */ | |
| | | GNUNET_TRANSPORT_PS_CONNECTED, | |
| | | | |
| | | /** | |
| | | * Connection got into trouble, rest of the system still believes | |
| | | * it to be up, but we're getting a new address from ATS. | |
| | | */ | |
| | | GNUNET_TRANSPORT_PS_RECONNECT_ATS, | |
| | | | |
| | | /** | |
| | | * Sent CONNECT over new address (either by ATS telling us to switch | |
| | | * addresses or from RECONNECT_ATS); if this fails, we need to tell | |
| | | * the rest of the system about a disconnect. | |
| | | */ | |
| | | GNUNET_TRANSPORT_PS_RECONNECT_SENT, | |
| | | | |
| | | /** | |
| | | * We have some primary connection, but ATS suggested we switch | |
| | | * to some alternative; we now sent a CONNECT message for the | |
| | | * alternative session to the other peer and waiting for a | |
| | | * CONNECT_ACK to make this our primary connection. | |
| | | */ | |
| | | GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_CONNECT_SENT, | |
| | | | |
| | | /** | |
| | | * Disconnect in progress (we're sending the DISCONNECT message to the | |
| | | * other peer; after that is finished, the state will be cleaned up). | |
| | | */ | |
| | | GNUNET_TRANSPORT_PS_DISCONNECT, | |
| | | | |
| | | /** | |
| | | * We're finished with the disconnect; and are cleaning up the state | |
| | | * now! We put the struct into this state when we are really in the | |
| | | * task that calls 'free' on it and are about to remove the record | |
| | | * from the map. We should never find a 'struct NeighbourMapEntry' | |
| | | * in this state in the map. Accessing a 'struct NeighbourMapEntry' | |
| | | * in this state virtually always means using memory that has been | |
| | | * freed (the exception being the cleanup code in #free_neighbour()). | |
| | | */ | |
| | | GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED | |
| | | }; | |
| | | | |
| | | /** | |
| | | * Current state of a validation process | |
| | | */ | |
| | | enum GNUNET_TRANSPORT_ValidationState | |
| | | { | |
| | | /** | |
| | | * Undefined state | |
| | | * | |
| | | * Used for final callback indicating operation done | |
| | | */ | |
| | | GNUNET_TRANSPORT_VS_NONE, | |
| | | | |
| | | /** | |
| | | * Fresh validation entry | |
| | | * | |
| | | * Entry was just created, no validation process was executed | |
| | | */ | |
| | | GNUNET_TRANSPORT_VS_NEW, | |
| | | | |
| | | /** | |
| | | * Updated validation entry | |
| | | * | |
| | | * This is an update for an existing validation entry | |
| | | */ | |
| | | GNUNET_TRANSPORT_VS_UPDATE, | |
| | | | |
| | | /** | |
| | | * Timeout for validation entry | |
| | | * | |
| | | * A timeout occured during the validation process | |
| | | */ | |
| | | GNUNET_TRANSPORT_VS_TIMEOUT, | |
| | | | |
| | | /** | |
| | | * Validation entry is removed | |
| | | * | |
| | | * The validation entry is getting removed due to a failed validation | |
| | | */ | |
| | | GNUNET_TRANSPORT_VS_REMOVE | |
| | | }; | |
| | | | |
| /** | | /** | |
| * Function called by the transport for each received message. | | * Function called by the transport for each received message. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param peer (claimed) identity of the other peer | | * @param peer (claimed) identity of the other peer | |
| * @param message the message | | * @param message the message | |
| * @param ats performance data | | * @param ats performance data | |
|
| * @param ats_count number of entries in ats | | * @param ats_count number of entries in @a ats | |
| */ | | */ | |
|
| typedef void (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls, | | typedef void | |
| const struct | | (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls, | |
| GNUNET_PeerIdentity * pee | | const struct GNUNET_PeerIdentity *peer | |
| r, | | , | |
| const struct | | const struct GNUNET_MessageHeader *mes | |
| GNUNET_MessageHeader * | | sage); | |
| message); | | | |
| | | | |
| /** | | /** | |
| * Opaque handle to the service. | | * Opaque handle to the service. | |
| */ | | */ | |
| struct GNUNET_TRANSPORT_Handle; | | struct GNUNET_TRANSPORT_Handle; | |
| | | | |
| /** | | /** | |
| * Function called to notify transport users that another | | * Function called to notify transport users that another | |
| * peer connected to us. | | * peer connected to us. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param peer the peer that connected | | * @param peer the peer that connected | |
| * @param ats performance data | | * @param ats performance data | |
|
| * @param ats_count number of entries in ats (excluding 0-termination) | | * @param ats_count number of entries in @a ats (excluding 0-termination) | |
| */ | | */ | |
|
| typedef void (*GNUNET_TRANSPORT_NotifyConnect) (void *cls, | | typedef void | |
| const struct GNUNET_PeerIde | | (*GNUNET_TRANSPORT_NotifyConnect) (void *cls, | |
| ntity | | const struct GNUNET_PeerIdentity *peer); | |
| * peer); | | | |
| | | | |
| /** | | /** | |
| * Function called to notify transport users that another | | * Function called to notify transport users that another | |
| * peer disconnected from us. | | * peer disconnected from us. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param peer the peer that disconnected | | * @param peer the peer that disconnected | |
| */ | | */ | |
|
| typedef void (*GNUNET_TRANSPORT_NotifyDisconnect) (void *cls, | | typedef void | |
| const struct | | (*GNUNET_TRANSPORT_NotifyDisconnect) (void *cls, | |
| GNUNET_PeerIdentity * pe | | const struct GNUNET_PeerIdentity *pee | |
| er); | | r); | |
| | | | |
| /** | | /** | |
| * Function to call with result of the try connect request. | | * Function to call with result of the try connect request. | |
| * | | * | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
|
| * @param result GNUNET_OK if message was transmitted to transport service | | * @param result #GNUNET_OK if message was transmitted to transport service | |
| * GNUNET_SYSERR if message was not transmitted to transport | | * #GNUNET_SYSERR if message was not transmitted to transport | |
| service | | service | |
| */ | | */ | |
|
| typedef void (*GNUNET_TRANSPORT_TryConnectCallback) (void *cls, | | typedef void | |
| const int result); | | (*GNUNET_TRANSPORT_TryConnectCallback) (void *cls, | |
| | | const int result); | |
| | | | |
| /** | | /** | |
| * Function to call with a textual representation of an address. | | * Function to call with a textual representation of an address. | |
| * This function will be called several times with different possible | | * This function will be called several times with different possible | |
| * textual representations, and a last time with NULL to signal the end | | * textual representations, and a last time with NULL to signal the end | |
| * of the iteration. | | * of the iteration. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param address NULL on error or end of iteration, | | * @param address NULL on error or end of iteration, | |
| * otherwise 0-terminated printable UTF-8 string | | * otherwise 0-terminated printable UTF-8 string | |
| */ | | */ | |
|
| typedef void (*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls, | | typedef void | |
| const char *addre | | (*GNUNET_TRANSPORT_AddressToStringCallback) (void *cls, | |
| ss); | | const char *address); | |
| | | | |
| /** | | /** | |
|
| * Function to call with a binary format of an address | | * Function to call with information about a peer | |
| | | * | |
| | | * If one_shot was set to #GNUNET_YES to iterate over all peers once, | |
| | | * a final call with NULL for peer and address will follow when done. | |
| | | * In this case state and timeout do not contain valid values. | |
| | | * | |
| | | * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called from | |
| | | * within this function! | |
| | | * | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
|
| * @param peer peer this update is about (never NULL) | | * @param peer peer this update is about, | |
| | | * NULL if this is the final last callback for a iteration operation | |
| * @param address address, NULL for disconnect notification in monitor mode | | * @param address address, NULL for disconnect notification in monitor mode | |
|
| | | * @param state current state this peer is in | |
| | | * @param state_timeout timeout for the current state of the peer | |
| */ | | */ | |
|
| typedef void (*GNUNET_TRANSPORT_PeerIterateCallback) (void *cls, | | typedef void | |
| const struct | | (*GNUNET_TRANSPORT_PeerIterateCallback) (void *cls, | |
| GNUNET_PeerIdentity * | | const struct GNUNET_PeerIdentity * | |
| peer, | | peer, | |
| const struct | | const struct GNUNET_HELLO_Address | |
| GNUNET_HELLO_Address | | *address, | |
| * | | enum GNUNET_TRANSPORT_PeerState st | |
| address); | | ate, | |
| | | struct GNUNET_TIME_Absolute state_ | |
| | | timeout); | |
| | | | |
| | | /** | |
| | | * Function to call with validation information about a peer | |
| | | * | |
| | | * This function is called by the transport validation monitoring api to | |
| | | * indicate a change to a validation entry. The information included repres | |
| | | ent | |
| | | * the current state of the validation entry, | |
| | | * | |
| | | * If the monitoring was called with one_shot=GNUNET_YES, a final callback | |
| | | * with peer==NULL and address==NULL is executed. | |
| | | * | |
| | | * @param cls closure | |
| | | * @param peer peer this update is about, | |
| | | * NULL if this is the final last callback for a iteration operation | |
| | | * @param address address, | |
| | | * NULL for disconnect notification in monitor mode | |
| | | * @param last_validation when was this address last validated | |
| | | * @param valid_until when does this address expire | |
| | | * @param next_validation time of the next validation operation | |
| | | * @param state state in the validation state machine | |
| | | */ | |
| | | typedef void | |
| | | (*GNUNET_TRANSPORT_ValidationIterateCallback) (void *cls, | |
| | | const struct GNUNET_PeerIden | |
| | | tity *peer, | |
| | | const struct GNUNET_HELLO_Ad | |
| | | dress *address, | |
| | | struct GNUNET_TIME_Absolute | |
| | | last_validation, | |
| | | struct GNUNET_TIME_Absolute | |
| | | valid_until, | |
| | | struct GNUNET_TIME_Absolute | |
| | | next_validation, | |
| | | enum GNUNET_TRANSPORT_Valida | |
| | | tionState state); | |
| | | | |
| /** | | /** | |
| * Connect to the transport service. Note that the connection may | | * Connect to the transport service. Note that the connection may | |
| * complete (or fail) asynchronously. | | * complete (or fail) asynchronously. | |
| * | | * | |
| * @param cfg configuration to use | | * @param cfg configuration to use | |
| * @param self our own identity (API should check that it matches | | * @param self our own identity (API should check that it matches | |
| * the identity found by transport), or NULL (no check) | | * the identity found by transport), or NULL (no check) | |
| * @param cls closure for the callbacks | | * @param cls closure for the callbacks | |
| * @param rec receive function to call, or NULL | | * @param rec receive function to call, or NULL | |
| * @param nc function to call on connect events, or NULL | | * @param nc function to call on connect events, or NULL | |
| * @param nd function to call on disconnect events, or NULL | | * @param nd function to call on disconnect events, or NULL | |
| * @return NULL on error | | * @return NULL on error | |
| */ | | */ | |
| struct GNUNET_TRANSPORT_Handle * | | struct GNUNET_TRANSPORT_Handle * | |
| GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | | GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |
|
| const struct GNUNET_PeerIdentity *self, void *cls | | const struct GNUNET_PeerIdentity *self, | |
| , | | void *cls, | |
| GNUNET_TRANSPORT_ReceiveCallback rec, | | GNUNET_TRANSPORT_ReceiveCallback rec, | |
| GNUNET_TRANSPORT_NotifyConnect nc, | | GNUNET_TRANSPORT_NotifyConnect nc, | |
| GNUNET_TRANSPORT_NotifyDisconnect nd); | | GNUNET_TRANSPORT_NotifyDisconnect nd); | |
| | | | |
| /** | | /** | |
|
| | | * Function called if we have "excess" bandwidth to a peer. | |
| | | * The notification will happen the first time we have excess | |
| | | * bandwidth, and then only again after the client has performed | |
| | | * some transmission to the peer. | |
| | | * | |
| | | * Excess bandwidth is defined as being allowed (by ATS) to send | |
| | | * more data, and us reaching the limit of the capacity build-up | |
| | | * (which, if we go past it, means we don't use available bandwidth). | |
| | | * See also the "max carry" in `struct GNUNET_BANDWIDTH_Tracker`. | |
| | | * | |
| | | * @param cls the closure | |
| | | * @param peer peer that we have excess bandwidth to | |
| | | */ | |
| | | typedef void | |
| | | (*GNUNET_TRANSPORT_NotifyExcessBandwidth)(void *cls, | |
| | | const struct GNUNET_PeerIdentity | |
| | | *neighbour); | |
| | | | |
| | | /** | |
| | | * Connect to the transport service. Note that the connection may | |
| | | * complete (or fail) asynchronously. | |
| | | * | |
| | | * @param cfg configuration to use | |
| | | * @param self our own identity (API should check that it matches | |
| | | * the identity found by transport), or NULL (no check) | |
| | | * @param cls closure for the callbacks | |
| | | * @param rec receive function to call, or NULL | |
| | | * @param nc function to call on connect events, or NULL | |
| | | * @param nd function to call on disconnect events, or NULL | |
| | | * @param neb function to call if we have excess bandwidth to a peer | |
| | | * @return NULL on error | |
| | | */ | |
| | | struct GNUNET_TRANSPORT_Handle * | |
| | | GNUNET_TRANSPORT_connect2 (const struct GNUNET_CONFIGURATION_Handle *cfg, | |
| | | const struct GNUNET_PeerIdentity *self, | |
| | | void *cls, | |
| | | GNUNET_TRANSPORT_ReceiveCallback rec, | |
| | | GNUNET_TRANSPORT_NotifyConnect nc, | |
| | | GNUNET_TRANSPORT_NotifyDisconnect nd, | |
| | | GNUNET_TRANSPORT_NotifyExcessBandwidth neb); | |
| | | | |
| | | /** | |
| * Disconnect from the transport service. | | * Disconnect from the transport service. | |
| * | | * | |
| * @param handle handle returned from connect | | * @param handle handle returned from connect | |
| */ | | */ | |
| void | | void | |
| GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle); | | GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle); | |
| | | | |
| /** | | /** | |
| * Opaque handle for a transmission-ready request. | | * Opaque handle for a transmission-ready request. | |
| */ | | */ | |
| struct GNUNET_TRANSPORT_TryConnectHandle; | | struct GNUNET_TRANSPORT_TryConnectHandle; | |
| | | | |
| /** | | /** | |
| * Ask the transport service to establish a connection to | | * Ask the transport service to establish a connection to | |
| * the given peer. | | * the given peer. | |
| * | | * | |
| * @param handle connection to transport service | | * @param handle connection to transport service | |
| * @param target who we should try to connect to | | * @param target who we should try to connect to | |
| * @param cb callback to be called when request was transmitted to transpor
t | | * @param cb callback to be called when request was transmitted to transpor
t | |
| * service | | * service | |
|
| * @param cb_cls closure for the callback | | * @param cb_cls closure for the callback @a cb | |
| * @return a GNUNET_TRANSPORT_TryConnectHandle handle or | | * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or | |
| * NULL on failure (cb will not be called) | | * NULL on failure (@a cb will not be called) | |
| */ | | */ | |
| struct GNUNET_TRANSPORT_TryConnectHandle * | | struct GNUNET_TRANSPORT_TryConnectHandle * | |
| GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle, | | GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle, | |
| const struct GNUNET_PeerIdentity *target, | | const struct GNUNET_PeerIdentity *target, | |
| GNUNET_TRANSPORT_TryConnectCallback cb, | | GNUNET_TRANSPORT_TryConnectCallback cb, | |
| void *cb_cls); | | void *cb_cls); | |
| | | | |
| /** | | /** | |
| * Cancel the request to transport to try a connect | | * Cancel the request to transport to try a connect | |
| * Callback will not be called | | * Callback will not be called | |
| * | | * | |
| * @param tch GNUNET_TRANSPORT_TryConnectHandle handle to cancel | | * @param tch GNUNET_TRANSPORT_TryConnectHandle handle to cancel | |
| */ | | */ | |
| void | | void | |
| GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHand
le *tch); | | GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHand
le *tch); | |
| | | | |
| /** | | /** | |
|
| | | * Ask the transport service to establish a disconnect from | |
| | | * the given peer. | |
| | | * | |
| | | * @param handle connection to transport service | |
| | | * @param target who we should try to disconnect from | |
| | | * @param cb callback to be called when request was transmitted to transpor | |
| | | t | |
| | | * service | |
| | | * @param cb_cls closure for the callback @a cb | |
| | | * @return a `struct GNUNET_TRANSPORT_TryConnectHandle` handle or | |
| | | * NULL on failure (@a cb will not be called) | |
| | | */ | |
| | | struct GNUNET_TRANSPORT_TryConnectHandle * | |
| | | GNUNET_TRANSPORT_try_disconnect (struct GNUNET_TRANSPORT_Handle *handle, | |
| | | const struct GNUNET_PeerIdentity *target, | |
| | | GNUNET_TRANSPORT_TryConnectCallback cb, | |
| | | void *cb_cls); | |
| | | | |
| | | /** | |
| | | * Cancel the request to transport to try a disconnect | |
| | | * Callback will not be called | |
| | | * | |
| | | * @param tch GNUNET_TRANSPORT_TryConnectHandle handle to cancel | |
| | | */ | |
| | | void | |
| | | GNUNET_TRANSPORT_try_disconnect_cancel (struct GNUNET_TRANSPORT_TryConnectH | |
| | | andle *tch); | |
| | | | |
| | | /** | |
| * Opaque handle for a transmission-ready request. | | * Opaque handle for a transmission-ready request. | |
| */ | | */ | |
| struct GNUNET_TRANSPORT_TransmitHandle; | | struct GNUNET_TRANSPORT_TransmitHandle; | |
| | | | |
| /** | | /** | |
|
| | | * Function called to notify a client about the connection begin ready | |
| | | * to queue more data. @a buf will be NULL and @a size zero if the | |
| | | * connection was closed for writing in the meantime. | |
| | | * | |
| | | * @param cls closure | |
| | | * @param size number of bytes available in @a buf | |
| | | * @param buf where the callee should write the message | |
| | | * @return number of bytes written to @a buf | |
| | | */ | |
| | | typedef size_t | |
| | | (*GNUNET_TRANSPORT_TransmitReadyNotify) (void *cls, | |
| | | size_t size, | |
| | | void *buf); | |
| | | | |
| | | /** | |
| * Check if we could queue a message of the given size for | | * Check if we could queue a message of the given size for | |
| * transmission. The transport service will take both its internal | | * transmission. The transport service will take both its internal | |
| * buffers and bandwidth limits imposed by the other peer into | | * buffers and bandwidth limits imposed by the other peer into | |
| * consideration when answering this query. | | * consideration when answering this query. | |
| * | | * | |
| * @param handle connection to transport service | | * @param handle connection to transport service | |
| * @param target who should receive the message | | * @param target who should receive the message | |
| * @param size how big is the message we want to transmit? | | * @param size how big is the message we want to transmit? | |
|
| * @param priority how important is the message? @deprecated - remove? | | | |
| * @param timeout after how long should we give up (and call | | * @param timeout after how long should we give up (and call | |
| * notify with buf NULL and size 0)? | | * notify with buf NULL and size 0)? | |
| * @param notify function to call when we are ready to | | * @param notify function to call when we are ready to | |
| * send such a message | | * send such a message | |
|
| * @param notify_cls closure for notify | | * @param notify_cls closure for @a notify | |
| * @return NULL if someone else is already waiting to be notified | | * @return NULL if someone else is already waiting to be notified | |
| * non-NULL if the notify callback was queued (can be used to cance
l | | * non-NULL if the notify callback was queued (can be used to cance
l | |
| * using GNUNET_TRANSPORT_notify_transmit_ready_cancel) | | * using GNUNET_TRANSPORT_notify_transmit_ready_cancel) | |
| */ | | */ | |
| struct GNUNET_TRANSPORT_TransmitHandle * | | struct GNUNET_TRANSPORT_TransmitHandle * | |
| GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *han
dle, | | GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *han
dle, | |
|
| const struct GNUNET_PeerIdentity | | const struct GNUNET_PeerIdentity *t | |
| *target, size_t size, uint32_t prio | | arget, | |
| rity, | | size_t size, | |
| struct GNUNET_TIME_Relative timeout
, | | struct GNUNET_TIME_Relative timeout
, | |
|
| GNUNET_CONNECTION_TransmitReadyNoti | | GNUNET_TRANSPORT_TransmitReadyNotif | |
| fy | | y notify, | |
| notify, void *notify_cls); | | void *notify_cls); | |
| | | | |
| /** | | /** | |
| * Cancel the specified transmission-ready notification. | | * Cancel the specified transmission-ready notification. | |
| * | | * | |
| * @param th handle of the transmission notification request to cancel | | * @param th handle of the transmission notification request to cancel | |
| */ | | */ | |
| void | | void | |
|
| GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct | | GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct GNUNET_TRANSPORT_Tran | |
| GNUNET_TRANSPORT_TransmitHan | | smitHandle *th); | |
| dle | | | |
| *th); | | | |
| | | | |
| /** | | /** | |
| * Function called whenever there is an update to the | | * Function called whenever there is an update to the | |
| * HELLO of this peer. | | * HELLO of this peer. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param hello our updated HELLO | | * @param hello our updated HELLO | |
| */ | | */ | |
|
| typedef void (*GNUNET_TRANSPORT_HelloUpdateCallback) (void *cls, | | typedef void | |
| const struct | | (*GNUNET_TRANSPORT_HelloUpdateCallback) (void *cls, | |
| GNUNET_MessageHeader | | const struct GNUNET_MessageHeader | |
| * | | *hello); | |
| hello); | | | |
| | | | |
| /** | | /** | |
|
| * Handle to cancel a 'GNUNET_TRANSPORT_get_hello' operation. | | * Handle to cancel a #GNUNET_TRANSPORT_get_hello() operation. | |
| */ | | */ | |
| struct GNUNET_TRANSPORT_GetHelloHandle; | | struct GNUNET_TRANSPORT_GetHelloHandle; | |
| | | | |
| /** | | /** | |
| * Checks if a given peer is connected to us | | * Checks if a given peer is connected to us | |
| * | | * | |
| * @param handle connection to transport service | | * @param handle connection to transport service | |
| * @param peer the peer to check | | * @param peer the peer to check | |
| * @return #GNUNET_YES (connected) or #GNUNET_NO (disconnected) | | * @return #GNUNET_YES (connected) or #GNUNET_NO (disconnected) | |
| */ | | */ | |
| int | | int | |
| GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *hand
le, | | GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *hand
le, | |
|
| const struct GNUNET_PeerIdentit
y *peer); | | const struct GNUNET_PeerIdentity *pe
er); | |
| | | | |
| /** | | /** | |
| * Set transport metrics for a peer and a direction | | * Set transport metrics for a peer and a direction | |
| * | | * | |
| * @param handle transport handle | | * @param handle transport handle | |
| * @param peer the peer to set the metric for | | * @param peer the peer to set the metric for | |
|
| * @param inbound set inbound direction (GNUNET_YES or GNUNET_NO) | | * @param inbound set inbound direction (#GNUNET_YES or #GNUNET_NO) | |
| * @param outbound set outbound direction (GNUNET_YES or GNUNET_NO) | | * @param outbound set outbound direction (#GNUNET_YES or #GNUNET_NO) | |
| * @param ats the metric as ATS information | | * @param ats the metric as ATS information | |
| * @param ats_count the number of metrics | | * @param ats_count the number of metrics | |
| * | | * | |
| * Supported ATS values: | | * Supported ATS values: | |
|
| * GNUNET_ATS_QUALITY_NET_DELAY (value in ms) | | * #GNUNET_ATS_QUALITY_NET_DELAY (value in ms) | |
| * GNUNET_ATS_QUALITY_NET_DISTANCE (value in count(hops)) | | * #GNUNET_ATS_QUALITY_NET_DISTANCE (value in count(hops)) | |
| * | | * | |
| * Example | | * Example | |
| * To enforce a delay of 10 ms for peer p1 in sending direction use: | | * To enforce a delay of 10 ms for peer p1 in sending direction use: | |
| * | | * | |
| * struct GNUNET_ATS_Information ats; | | * struct GNUNET_ATS_Information ats; | |
| * ats.type = ntohl (GNUNET_ATS_QUALITY_NET_DELAY); | | * ats.type = ntohl (GNUNET_ATS_QUALITY_NET_DELAY); | |
| * ats.value = ntohl (10); | | * ats.value = ntohl (10); | |
| * GNUNET_TRANSPORT_set_traffic_metric (th, p1, TM_SEND, &ats, 1); | | * GNUNET_TRANSPORT_set_traffic_metric (th, p1, TM_SEND, &ats, 1); | |
| * | | * | |
| * Note: | | * Note: | |
| | | | |
| skipping to change at line 300 | | skipping to change at line 586 | |
| int outbound, | | int outbound, | |
| const struct GNUNET_ATS_Information *at
s, | | const struct GNUNET_ATS_Information *at
s, | |
| size_t ats_count); | | size_t ats_count); | |
| | | | |
| /** | | /** | |
| * Obtain updates on changes to the HELLO message for this peer. The callba
ck | | * Obtain updates on changes to the HELLO message for this peer. The callba
ck | |
| * given in this function is never called synchronously. | | * given in this function is never called synchronously. | |
| * | | * | |
| * @param handle connection to transport service | | * @param handle connection to transport service | |
| * @param rec function to call with the HELLO | | * @param rec function to call with the HELLO | |
|
| * @param rec_cls closure for rec | | * @param rec_cls closure for @a rec | |
| * @return handle to cancel the operation | | * @return handle to cancel the operation | |
| */ | | */ | |
| struct GNUNET_TRANSPORT_GetHelloHandle * | | struct GNUNET_TRANSPORT_GetHelloHandle * | |
| GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle, | | GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle, | |
| GNUNET_TRANSPORT_HelloUpdateCallback rec, | | GNUNET_TRANSPORT_HelloUpdateCallback rec, | |
| void *rec_cls); | | void *rec_cls); | |
| | | | |
| /** | | /** | |
| * Stop receiving updates about changes to our HELLO message. | | * Stop receiving updates about changes to our HELLO message. | |
| * | | * | |
| * @param ghh handle to cancel | | * @param ghh handle to cancel | |
| */ | | */ | |
| void | | void | |
| GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *
ghh); | | GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *
ghh); | |
| | | | |
|
| | | struct GNUNET_TRANSPORT_OfferHelloHandle; | |
| | | | |
| /** | | /** | |
| * Offer the transport service the HELLO of another peer. Note that | | * Offer the transport service the HELLO of another peer. Note that | |
| * the transport service may just ignore this message if the HELLO is | | * the transport service may just ignore this message if the HELLO is | |
| * malformed or useless due to our local configuration. | | * malformed or useless due to our local configuration. | |
| * | | * | |
| * @param handle connection to transport service | | * @param handle connection to transport service | |
| * @param hello the hello message | | * @param hello the hello message | |
| * @param cont continuation to call when HELLO has been sent, | | * @param cont continuation to call when HELLO has been sent, | |
|
| * tc reason GNUNET_SCHEDULER_REASON_TIMEOUT for fail | | * tc reason #GNUNET_SCHEDULER_REASON_TIMEOUT for fail | |
| * tc reasong GNUNET_SCHEDULER_REASON_READ_READY for success | | * tc reasong #GNUNET_SCHEDULER_REASON_READ_READY for success | |
| * @param cls closure for continuation | | * @param cls closure for continuation | |
| * @return a GNUNET_TRANSPORT_OfferHelloHandle handle or NULL on failure, | | * @return a GNUNET_TRANSPORT_OfferHelloHandle handle or NULL on failure, | |
| * in case of failure cont will not be called | | * in case of failure cont will not be called | |
| * | | * | |
| */ | | */ | |
| struct GNUNET_TRANSPORT_OfferHelloHandle * | | struct GNUNET_TRANSPORT_OfferHelloHandle * | |
| GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle, | | GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle, | |
| const struct GNUNET_MessageHeader *hello, | | const struct GNUNET_MessageHeader *hello, | |
| GNUNET_SCHEDULER_Task cont, void *cls); | | GNUNET_SCHEDULER_Task cont, void *cls); | |
| | | | |
| /** | | /** | |
| * Cancel the request to transport to offer the HELLO message | | * Cancel the request to transport to offer the HELLO message | |
| * | | * | |
|
| * @param ohh the GNUNET_TRANSPORT_OfferHelloHandle to cancel | | * @param ohh the `struct GNUNET_TRANSPORT_OfferHelloHandle` to cancel | |
| */ | | */ | |
| void | | void | |
| GNUNET_TRANSPORT_offer_hello_cancel (struct GNUNET_TRANSPORT_OfferHelloHand
le *ohh); | | GNUNET_TRANSPORT_offer_hello_cancel (struct GNUNET_TRANSPORT_OfferHelloHand
le *ohh); | |
| | | | |
| /** | | /** | |
| * Handle to cancel a pending address lookup. | | * Handle to cancel a pending address lookup. | |
| */ | | */ | |
| struct GNUNET_TRANSPORT_AddressToStringContext; | | struct GNUNET_TRANSPORT_AddressToStringContext; | |
| | | | |
| /** | | /** | |
| * Convert a binary address into a human readable address. | | * Convert a binary address into a human readable address. | |
| * | | * | |
| * @param cfg configuration to use | | * @param cfg configuration to use | |
| * @param address address to convert (binary format) | | * @param address address to convert (binary format) | |
| * @param numeric should (IP) addresses be displayed in numeric form | | * @param numeric should (IP) addresses be displayed in numeric form | |
| * (otherwise do reverse DNS lookup) | | * (otherwise do reverse DNS lookup) | |
| * @param timeout how long is the lookup allowed to take at most | | * @param timeout how long is the lookup allowed to take at most | |
| * @param aluc function to call with the results | | * @param aluc function to call with the results | |
|
| * @param aluc_cls closure for aluc | | * @param aluc_cls closure for @a aluc | |
| * @return handle to cancel the operation, NULL on error | | * @return handle to cancel the operation, NULL on error | |
| */ | | */ | |
| struct GNUNET_TRANSPORT_AddressToStringContext * | | struct GNUNET_TRANSPORT_AddressToStringContext * | |
|
| GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handl | | GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handl | |
| e | | e *cfg, | |
| *cfg, | | | |
| const struct GNUNET_HELLO_Address *addr
ess, | | const struct GNUNET_HELLO_Address *addr
ess, | |
| int numeric, | | int numeric, | |
| struct GNUNET_TIME_Relative timeout, | | struct GNUNET_TIME_Relative timeout, | |
|
| GNUNET_TRANSPORT_AddressToStringCallbac | | GNUNET_TRANSPORT_AddressToStringCallbac | |
| k | | k aluc, | |
| aluc, void *aluc_cls); | | void *aluc_cls); | |
| | | | |
| /** | | /** | |
| * Cancel request for address conversion. | | * Cancel request for address conversion. | |
| * | | * | |
|
| * @param alc handle for the request to cancel | | * @param pic the context handle | |
| | | */ | |
| | | void | |
| | | GNUNET_TRANSPORT_address_to_string_cancel (struct GNUNET_TRANSPORT_AddressT | |
| | | oStringContext *pic); | |
| | | | |
| | | /** | |
| | | * Convert a transport state to a human readable string. | |
| | | * | |
| | | * @param state the state | |
| | | */ | |
| | | const char * | |
| | | GNUNET_TRANSPORT_ps2s (enum GNUNET_TRANSPORT_PeerState state); | |
| | | | |
| | | /** | |
| | | * Check if a state is defined as connected | |
| | | * | |
| | | * @param state the state value | |
| | | * @return #GNUNET_YES or #GNUNET_NO | |
| | | */ | |
| | | int | |
| | | GNUNET_TRANSPORT_is_connected (enum GNUNET_TRANSPORT_PeerState state); | |
| | | | |
| | | /** | |
| | | * Convert validation state to human-readable string. | |
| | | * | |
| | | * @param state the state value | |
| | | * @return corresponding string | |
| | | */ | |
| | | const char * | |
| | | GNUNET_TRANSPORT_vs2s (enum GNUNET_TRANSPORT_ValidationState state); | |
| | | | |
| | | struct GNUNET_TRANSPORT_PeerMonitoringContext; | |
| | | | |
| | | /** | |
| | | * Return information about a specific peer or all peers currently known to | |
| | | * transport service once or in monitoring mode. To obtain information abou | |
| | | t | |
| | | * a specific peer, a peer identity can be passed. To obtain information ab | |
| | | out | |
| | | * all peers currently known to transport service, NULL can be passed as pe | |
| | | er | |
| | | * identity. | |
| | | * | |
| | | * For each peer, the callback is called with information about the address | |
| | | used | |
| | | * to communicate with this peer, the state this peer is currently in and t | |
| | | he | |
| | | * the current timeout for this state. | |
| | | * | |
| | | * Upon completion, the 'GNUNET_TRANSPORT_PeerIterateCallback' is called on | |
| | | e | |
| | | * more time with 'NULL'. After this, the operation must no longer be | |
| | | * explicitly canceled. | |
| | | * | |
| | | * The #GNUNET_TRANSPORT_monitor_peers_cancel call MUST not be called in th | |
| | | e | |
| | | * the peer_callback! | |
| | | * | |
| | | * @param cfg configuration to use | |
| | | * @param peer a specific peer identity to obtain information for, | |
| | | * NULL for all peers | |
| | | * @param one_shot #GNUNET_YES to return the current state and then end (wi | |
| | | th NULL+NULL), | |
| | | * #GNUNET_NO to monitor peers continuously | |
| | | * @param timeout how long is the lookup allowed to take at most | |
| | | * @param peer_callback function to call with the results | |
| | | * @param peer_callback_cls closure for @a peer_callback | |
| | | */ | |
| | | struct GNUNET_TRANSPORT_PeerMonitoringContext * | |
| | | GNUNET_TRANSPORT_monitor_peers (const struct GNUNET_CONFIGURATION_Handle *c | |
| | | fg, | |
| | | const struct GNUNET_PeerIdentity *peer, | |
| | | int one_shot, | |
| | | struct GNUNET_TIME_Relative timeout, | |
| | | GNUNET_TRANSPORT_PeerIterateCallback peer_c | |
| | | allback, | |
| | | void *peer_callback_cls); | |
| | | | |
| | | /** | |
| | | * Cancel request to monitor peers | |
| | | * | |
| | | * @param pic handle for the request to cancel | |
| */ | | */ | |
| void | | void | |
|
| GNUNET_TRANSPORT_address_to_string_cancel (struct | | GNUNET_TRANSPORT_monitor_peers_cancel (struct GNUNET_TRANSPORT_PeerMonitori | |
| GNUNET_TRANSPORT_AddressToString | | ngContext *pic); | |
| Context | | | |
| *alc); | | struct GNUNET_TRANSPORT_ValidationMonitoringContext; | |
| | | | |
| /** | | /** | |
|
| * Return all the known addresses for a specific peer or all peers. | | * Return information about pending address validation operations for a spe | |
| * Returns continuously all address if one_shot is set to GNUNET_NO | | cific | |
| * | | * or all peers | |
| * CHANGE: Returns the address(es) that we are currently using for this | | | |
| * peer. Upon completion, the 'AddressLookUpCallback' is called one more | | | |
| * time with 'NULL' for the address and the peer. After this, the operatio | | | |
| n must no | | | |
| * longer be explicitly cancelled. | | | |
| * | | * | |
| * @param cfg configuration to use | | * @param cfg configuration to use | |
|
| * @param peer peer identity to look up the addresses of, CHANGE: allow NUL | | * @param peer a specific peer identity to obtain validation entries for, | |
| L for all (connected) peers | | * NULL for all peers | |
| * @param one_shot GNUNET_YES to return the current state and then end (wit | | * @param one_shot #GNUNET_YES to return all entries and then end (with NUL | |
| h NULL+NULL), | | L+NULL), | |
| * GNUNET_NO to monitor the set of addresses used (continuo | | * #GNUNET_NO to monitor validation entries continuously | |
| usly, must be explicitly canceled, NOT implemented yet!) | | | |
| * @param timeout how long is the lookup allowed to take at most | | * @param timeout how long is the lookup allowed to take at most | |
|
| * @param peer_address_callback function to call with the results | | * @param validation_callback function to call with the results | |
| * @param peer_address_callback_cls closure for peer_address_callback | | * @param validation_callback_cls closure for @a validation_callback | |
| */ | | */ | |
|
| struct GNUNET_TRANSPORT_PeerIterateContext * | | struct GNUNET_TRANSPORT_ValidationMonitoringContext * | |
| GNUNET_TRANSPORT_peer_get_active_addresses (const struct | | GNUNET_TRANSPORT_monitor_validation_entries (const struct GNUNET_CONFIGURAT | |
| GNUNET_CONFIGURATION_Handle *cf | | ION_Handle *cfg, | |
| g, | | const struct GNUNET_PeerIdenti | |
| const struct GNUNET_PeerIdentit | | ty *peer, | |
| y | | int one_shot, | |
| *peer, int one_shot, | | struct GNUNET_TIME_Relative ti | |
| struct GNUNET_TIME_Relative tim | | meout, | |
| eout, | | GNUNET_TRANSPORT_ValidationIte | |
| GNUNET_TRANSPORT_PeerIterateCal | | rateCallback validation_callback, | |
| lback | | void *validation_callback_cls) | |
| peer_address_callback, | | ; | |
| void *peer_address_callback_cls | | | |
| ); | | | |
| | | | |
| /** | | /** | |
|
| * Cancel request for peer lookup. | | * Return information about all current pending validation operations | |
| * | | * | |
|
| * @param alc handle for the request to cancel | | * @param vic handle for the request to cancel | |
| */ | | */ | |
| void | | void | |
|
| GNUNET_TRANSPORT_peer_get_active_addresses_cancel (struct | | GNUNET_TRANSPORT_monitor_validation_entries_cancel (struct GNUNET_TRANSPORT | |
| GNUNET_TRANSPORT_PeerIte | | _ValidationMonitoringContext *vic); | |
| rateContext | | | |
| *alc); | | | |
| | | | |
| /** | | /** | |
| * Handle for blacklisting peers. | | * Handle for blacklisting peers. | |
| */ | | */ | |
| struct GNUNET_TRANSPORT_Blacklist; | | struct GNUNET_TRANSPORT_Blacklist; | |
| | | | |
| /** | | /** | |
| * Function that decides if a connection is acceptable or not. | | * Function that decides if a connection is acceptable or not. | |
| * | | * | |
| * @param cls closure | | * @param cls closure | |
| * @param pid peer to approve or disapproave | | * @param pid peer to approve or disapproave | |
|
| * @return GNUNET_OK if the connection is allowed, GNUNET_SYSERR if not | | * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not | |
| */ | | */ | |
|
| typedef int (*GNUNET_TRANSPORT_BlacklistCallback) (void *cls, | | typedef int | |
| const struct | | (*GNUNET_TRANSPORT_BlacklistCallback) (void *cls, | |
| GNUNET_PeerIdentity * pi | | const struct | |
| d); | | GNUNET_PeerIdentity * pid); | |
| | | | |
| /** | | /** | |
| * Install a blacklist callback. The service will be queried for all | | * Install a blacklist callback. The service will be queried for all | |
| * existing connections as well as any fresh connections to check if | | * existing connections as well as any fresh connections to check if | |
| * they are permitted. If the blacklisting callback is unregistered, | | * they are permitted. If the blacklisting callback is unregistered, | |
| * all hosts that were denied in the past will automatically be | | * all hosts that were denied in the past will automatically be | |
| * whitelisted again. Cancelling the blacklist handle is also the | | * whitelisted again. Cancelling the blacklist handle is also the | |
| * only way to re-enable connections from peers that were previously | | * only way to re-enable connections from peers that were previously | |
| * blacklisted. | | * blacklisted. | |
| * | | * | |
| * @param cfg configuration to use | | * @param cfg configuration to use | |
| * @param cb callback to invoke to check if connections are allowed | | * @param cb callback to invoke to check if connections are allowed | |
|
| * @param cb_cls closure for cb | | * @param cb_cls closure for @a cb | |
| * @return NULL on error, otherwise handle for cancellation | | * @return NULL on error, otherwise handle for cancellation | |
| */ | | */ | |
| struct GNUNET_TRANSPORT_Blacklist * | | struct GNUNET_TRANSPORT_Blacklist * | |
| GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg, | | GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg, | |
| GNUNET_TRANSPORT_BlacklistCallback cb, | | GNUNET_TRANSPORT_BlacklistCallback cb, | |
| void *cb_cls); | | void *cb_cls); | |
| | | | |
| /** | | /** | |
| * Abort the blacklist. Note that this function is the only way for | | * Abort the blacklist. Note that this function is the only way for | |
| * removing a peer from the blacklist. | | * removing a peer from the blacklist. | |
| | | | |
End of changes. 48 change blocks. |
| 123 lines changed or deleted | | 506 lines changed or added | |
|