GNUnet  0.11.x
Data Structures | Macros | Typedefs | Enumerations | Functions
Set service

Two-peer set operations. More...

Data Structures

struct  GNUNET_SET_Element
 Element stored in a set. More...
 
struct  GNUNET_SET_Option
 Option for set operations. More...
 
struct  GNUNET_SETI_Element
 Element stored in a set. More...
 
struct  GNUNET_SETI_Option
 Option for set operations. More...
 
struct  GNUNET_SETU_Element
 Element stored in a set. More...
 
struct  GNUNET_SETU_Option
 Option for set operations. More...
 

Macros

#define GNUNET_SET_CONTEXT_MESSAGE_MAX_SIZE   ((1 << 16) - 1024)
 Maximum size of a context message for set operation requests. More...
 
#define GNUNET_SETI_CONTEXT_MESSAGE_MAX_SIZE   ((1 << 16) - 1024)
 Maximum size of a context message for set operation requests. More...
 
#define GNUNET_SETU_CONTEXT_MESSAGE_MAX_SIZE   ((1 << 16) - 1024)
 Maximum size of a context message for set operation requests. More...
 

Typedefs

typedef void(* GNUNET_SET_Continuation) (void *cls)
 Continuation used for some of the set operations. More...
 
typedef void(* GNUNET_SET_ResultIterator) (void *cls, const struct GNUNET_SET_Element *element, uint64_t current_size, enum GNUNET_SET_Status status)
 Callback for set operation results. More...
 
typedef int(* GNUNET_SET_ElementIterator) (void *cls, const struct GNUNET_SET_Element *element)
 Iterator for set elements. More...
 
typedef void(* GNUNET_SET_ListenCallback) (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SET_Request *request)
 Called when another peer wants to do a set operation with the local peer. More...
 
typedef void(* GNUNET_SET_CopyReadyCallback) (void *cls, struct GNUNET_SET_Handle *copy)
 
typedef void(* GNUNET_SETI_ResultIterator) (void *cls, const struct GNUNET_SETI_Element *element, uint64_t current_size, enum GNUNET_SETI_Status status)
 Callback for set union operation results. More...
 
typedef void(* GNUNET_SETI_ListenCallback) (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETI_Request *request)
 Called when another peer wants to do a set operation with the local peer. More...
 
typedef void(* GNUNET_SETU_ResultIterator) (void *cls, const struct GNUNET_SETU_Element *element, uint64_t current_size, enum GNUNET_SETU_Status status)
 Callback for set union operation results. More...
 
typedef void(* GNUNET_SETU_ListenCallback) (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETU_Request *request)
 Called when another peer wants to do a set operation with the local peer. More...
 

Enumerations

enum  GNUNET_SET_OperationType { GNUNET_SET_OPERATION_NONE , GNUNET_SET_OPERATION_INTERSECTION , GNUNET_SET_OPERATION_UNION }
 The operation that a set set supports. More...
 
enum  GNUNET_SET_Status {
  GNUNET_SET_STATUS_OK , GNUNET_SET_STATUS_ADD_LOCAL , GNUNET_SET_STATUS_ADD_REMOTE , GNUNET_SET_STATUS_FAILURE ,
  GNUNET_SET_STATUS_HALF_DONE , GNUNET_SET_STATUS_DONE
}
 Status for the result callback. More...
 
enum  GNUNET_SET_ResultMode { GNUNET_SET_RESULT_FULL , GNUNET_SET_RESULT_SYMMETRIC , GNUNET_SET_RESULT_REMOVED , GNUNET_SET_RESULT_ADDED }
 The way results are given to the client. More...
 
enum  GNUNET_SET_OptionType { GNUNET_SET_OPTION_END =0 , GNUNET_SET_OPTION_BYZANTINE =1 , GNUNET_SET_OPTION_FORCE_FULL =2 , GNUNET_SET_OPTION_FORCE_DELTA =4 }
 Possible options to pass to a set operation. More...
 
enum  GNUNET_SETI_Status { GNUNET_SETI_STATUS_ADD_LOCAL , GNUNET_SETI_STATUS_DEL_LOCAL , GNUNET_SETI_STATUS_FAILURE , GNUNET_SETI_STATUS_DONE }
 Status for the result callback. More...
 
enum  GNUNET_SETI_OptionType { GNUNET_SETI_OPTION_END = 0 , GNUNET_SETI_OPTION_RETURN_INTERSECTION = 1 }
 Possible options to pass to a set operation. More...
 
enum  GNUNET_SETU_Status { GNUNET_SETU_STATUS_ADD_LOCAL , GNUNET_SETU_STATUS_ADD_REMOTE , GNUNET_SETU_STATUS_FAILURE , GNUNET_SETU_STATUS_DONE }
 Status for the result callback. More...
 
enum  GNUNET_SETU_OptionType {
  GNUNET_SETU_OPTION_END =0 , GNUNET_SETU_OPTION_BYZANTINE =1 , GNUNET_SETU_OPTION_FORCE_FULL =2 , GNUNET_SETU_OPTION_FORCE_DELTA =4 ,
  GNUNET_SETU_OPTION_SYMMETRIC = 8 , GNUNET_SETU_OPTION_CUSTOM_BYZANTINE_UPPER_BOUND = 16 , GNUNET_SETU_OPTION_CUSTOM_BANDWIDTH_LATENCY_TRADEOFF = 32 , GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKET_NUMBER_FACTOR = 64 ,
  GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKETS_PER_ELEMENT = 128
}
 Possible options to pass to a set operation. More...
 

Functions

struct GNUNET_SET_HandleGNUNET_SET_create (const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op)
 Create an empty set, supporting the specified operation. More...
 
int GNUNET_SET_add_element (struct GNUNET_SET_Handle *set, const struct GNUNET_SET_Element *element, GNUNET_SET_Continuation cont, void *cont_cls)
 Add an element to the given set. More...
 
int GNUNET_SET_remove_element (struct GNUNET_SET_Handle *set, const struct GNUNET_SET_Element *element, GNUNET_SET_Continuation cont, void *cont_cls)
 Remove an element to the given set. More...
 
void GNUNET_SET_copy_lazy (struct GNUNET_SET_Handle *set, GNUNET_SET_CopyReadyCallback cb, void *cls)
 
void GNUNET_SET_destroy (struct GNUNET_SET_Handle *set)
 Destroy the set handle, and free all associated resources. More...
 
struct GNUNET_SET_OperationHandleGNUNET_SET_prepare (const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
 Prepare a set operation to be evaluated with another peer. More...
 
struct GNUNET_SET_ListenHandleGNUNET_SET_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op_type, const struct GNUNET_HashCode *app_id, GNUNET_SET_ListenCallback listen_cb, void *listen_cls)
 Wait for set operation requests for the given application ID. More...
 
void GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh)
 Cancel the given listen operation. More...
 
struct GNUNET_SET_OperationHandleGNUNET_SET_accept (struct GNUNET_SET_Request *request, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
 Accept a request we got via GNUNET_SET_listen(). More...
 
int GNUNET_SET_commit (struct GNUNET_SET_OperationHandle *oh, struct GNUNET_SET_Handle *set)
 Commit a set to be used with a set operation. More...
 
void GNUNET_SET_operation_cancel (struct GNUNET_SET_OperationHandle *oh)
 Cancel the given set operation. More...
 
int GNUNET_SET_iterate (struct GNUNET_SET_Handle *set, GNUNET_SET_ElementIterator iter, void *iter_cls)
 Iterate over all elements in the given set. More...
 
void GNUNET_SET_iterate_cancel (struct GNUNET_SET_Handle *set)
 Stop iteration over all elements in the given set. More...
 
struct GNUNET_SET_ElementGNUNET_SET_element_dup (const struct GNUNET_SET_Element *element)
 Create a copy of an element. More...
 
void GNUNET_SET_element_hash (const struct GNUNET_SET_Element *element, struct GNUNET_HashCode *ret_hash)
 Hash a set element. More...
 
struct GNUNET_SETI_HandleGNUNET_SETI_create (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Create an empty set, supporting the specified operation. More...
 
int GNUNET_SETI_add_element (struct GNUNET_SETI_Handle *set, const struct GNUNET_SETI_Element *element, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
 Add an element to the given set. More...
 
void GNUNET_SETI_destroy (struct GNUNET_SETI_Handle *set)
 Destroy the set handle, and free all associated resources. More...
 
struct GNUNET_SETI_OperationHandleGNUNET_SETI_prepare (const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, const struct GNUNET_SETI_Option options[], GNUNET_SETI_ResultIterator result_cb, void *result_cls)
 Prepare a set operation to be evaluated with another peer. More...
 
struct GNUNET_SETI_ListenHandleGNUNET_SETI_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HashCode *app_id, GNUNET_SETI_ListenCallback listen_cb, void *listen_cls)
 Wait for set operation requests for the given application ID. More...
 
void GNUNET_SETI_listen_cancel (struct GNUNET_SETI_ListenHandle *lh)
 Cancel the given listen operation. More...
 
struct GNUNET_SETI_OperationHandleGNUNET_SETI_accept (struct GNUNET_SETI_Request *request, const struct GNUNET_SETI_Option options[], GNUNET_SETI_ResultIterator result_cb, void *result_cls)
 Accept a request we got via GNUNET_SETI_listen(). More...
 
int GNUNET_SETI_commit (struct GNUNET_SETI_OperationHandle *oh, struct GNUNET_SETI_Handle *set)
 Commit a set to be used with a set operation. More...
 
void GNUNET_SETI_operation_cancel (struct GNUNET_SETI_OperationHandle *oh)
 Cancel the given set operation. More...
 
void GNUNET_SETI_element_hash (const struct GNUNET_SETI_Element *element, struct GNUNET_HashCode *ret_hash)
 Hash a set element. More...
 
struct GNUNET_SETU_HandleGNUNET_SETU_create (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Create an empty set, supporting the specified operation. More...
 
int GNUNET_SETU_add_element (struct GNUNET_SETU_Handle *set, const struct GNUNET_SETU_Element *element, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
 Add an element to the given set. More...
 
void GNUNET_SETU_destroy (struct GNUNET_SETU_Handle *set)
 Destroy the set handle, and free all associated resources. More...
 
struct GNUNET_SETU_OperationHandleGNUNET_SETU_prepare (const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
 Prepare a set operation to be evaluated with another peer. More...
 
struct GNUNET_SETU_ListenHandleGNUNET_SETU_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HashCode *app_id, GNUNET_SETU_ListenCallback listen_cb, void *listen_cls)
 Wait for set operation requests for the given application ID. More...
 
void GNUNET_SETU_listen_cancel (struct GNUNET_SETU_ListenHandle *lh)
 Cancel the given listen operation. More...
 
struct GNUNET_SETU_OperationHandleGNUNET_SETU_accept (struct GNUNET_SETU_Request *request, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
 Accept a request we got via GNUNET_SETU_listen(). More...
 
int GNUNET_SETU_commit (struct GNUNET_SETU_OperationHandle *oh, struct GNUNET_SETU_Handle *set)
 Commit a set to be used with a set operation. More...
 
void GNUNET_SETU_operation_cancel (struct GNUNET_SETU_OperationHandle *oh)
 Cancel the given set operation. More...
 
void GNUNET_SETU_element_hash (const struct GNUNET_SETU_Element *element, struct GNUNET_HashCode *ret_hash)
 Hash a set element. More...
 

Detailed Description

Two-peer set operations.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_SET_CONTEXT_MESSAGE_MAX_SIZE

#define GNUNET_SET_CONTEXT_MESSAGE_MAX_SIZE   ((1 << 16) - 1024)

Maximum size of a context message for set operation requests.

Definition at line 55 of file gnunet_set_service.h.

◆ GNUNET_SETI_CONTEXT_MESSAGE_MAX_SIZE

#define GNUNET_SETI_CONTEXT_MESSAGE_MAX_SIZE   ((1 << 16) - 1024)

Maximum size of a context message for set operation requests.

Definition at line 52 of file gnunet_seti_service.h.

◆ GNUNET_SETU_CONTEXT_MESSAGE_MAX_SIZE

#define GNUNET_SETU_CONTEXT_MESSAGE_MAX_SIZE   ((1 << 16) - 1024)

Maximum size of a context message for set operation requests.

Definition at line 52 of file gnunet_setu_service.h.

Typedef Documentation

◆ GNUNET_SET_Continuation

typedef void(* GNUNET_SET_Continuation) (void *cls)

Continuation used for some of the set operations.

Parameters
clsclosure

Definition at line 272 of file gnunet_set_service.h.

◆ GNUNET_SET_ResultIterator

typedef void(* GNUNET_SET_ResultIterator) (void *cls, const struct GNUNET_SET_Element *element, uint64_t current_size, enum GNUNET_SET_Status status)

Callback for set operation results.

Called for each element in the result set.

Parameters
clsclosure
elementa result element, only valid if status is GNUNET_SET_STATUS_OK
current_sizecurrent set size
statussee enum GNUNET_SET_Status

Definition at line 285 of file gnunet_set_service.h.

◆ GNUNET_SET_ElementIterator

typedef int(* GNUNET_SET_ElementIterator) (void *cls, const struct GNUNET_SET_Element *element)

Iterator for set elements.

Parameters
clsclosure
elementthe current element, NULL if all elements have been iterated over
Returns
GNUNET_YES to continue iterating, GNUNET_NO to stop.

Definition at line 299 of file gnunet_set_service.h.

◆ GNUNET_SET_ListenCallback

typedef void(* GNUNET_SET_ListenCallback) (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SET_Request *request)

Called when another peer wants to do a set operation with the local peer.

If a listen error occurs, the request is NULL.

Parameters
clsclosure
other_peerthe other peer
context_msgmessage with application specific information from the other peer
requestrequest from the other peer (never NULL), use GNUNET_SET_accept() to accept it, otherwise the request will be refused Note that we can't just return value from the listen callback, as it is also necessary to specify the set we want to do the operation with, with sometimes can be derived from the context message. It's necessary to specify the timeout.

Definition at line 319 of file gnunet_set_service.h.

◆ GNUNET_SET_CopyReadyCallback

typedef void(* GNUNET_SET_CopyReadyCallback) (void *cls, struct GNUNET_SET_Handle *copy)

Definition at line 326 of file gnunet_set_service.h.

◆ GNUNET_SETI_ResultIterator

typedef void(* GNUNET_SETI_ResultIterator) (void *cls, const struct GNUNET_SETI_Element *element, uint64_t current_size, enum GNUNET_SETI_Status status)

Callback for set union operation results.

Called for each element in the result set.

Parameters
clsclosure
elementa result element, only valid if status is #GNUNET_SETI_STATUS_OK
current_sizecurrent set size
statussee enum GNUNET_SETI_Status

Definition at line 178 of file gnunet_seti_service.h.

◆ GNUNET_SETI_ListenCallback

typedef void(* GNUNET_SETI_ListenCallback) (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETI_Request *request)

Called when another peer wants to do a set operation with the local peer.

If a listen error occurs, the request is NULL.

Parameters
clsclosure
other_peerthe other peer
context_msgmessage with application specific information from the other peer
requestrequest from the other peer (never NULL), use GNUNET_SETI_accept() to accept it, otherwise the request will be refused Note that we can't just return value from the listen callback, as it is also necessary to specify the set we want to do the operation with, with sometimes can be derived from the context message. It's necessary to specify the timeout.

Definition at line 200 of file gnunet_seti_service.h.

◆ GNUNET_SETU_ResultIterator

typedef void(* GNUNET_SETU_ResultIterator) (void *cls, const struct GNUNET_SETU_Element *element, uint64_t current_size, enum GNUNET_SETU_Status status)

Callback for set union operation results.

Called for each element in the result set.

Parameters
clsclosure
elementa result element, only valid if status is #GNUNET_SETU_STATUS_OK
current_sizecurrent set size
statussee enum GNUNET_SETU_Status

Definition at line 223 of file gnunet_setu_service.h.

◆ GNUNET_SETU_ListenCallback

typedef void(* GNUNET_SETU_ListenCallback) (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETU_Request *request)

Called when another peer wants to do a set operation with the local peer.

If a listen error occurs, the request is NULL.

Parameters
clsclosure
other_peerthe other peer
context_msgmessage with application specific information from the other peer
requestrequest from the other peer (never NULL), use GNUNET_SETU_accept() to accept it, otherwise the request will be refused Note that we can't just return value from the listen callback, as it is also necessary to specify the set we want to do the operation with, with sometimes can be derived from the context message. It's necessary to specify the timeout.

Definition at line 245 of file gnunet_setu_service.h.

Enumeration Type Documentation

◆ GNUNET_SET_OperationType

The operation that a set set supports.

Enumerator
GNUNET_SET_OPERATION_NONE 

A purely local set that does not support any operation.

GNUNET_SET_OPERATION_INTERSECTION 

Set intersection, only return elements that are in both sets.

GNUNET_SET_OPERATION_UNION 

Set union, return all elements that are in at least one of the sets.

Definition at line 82 of file gnunet_set_service.h.

83 {
88 
93 
98 };
@ GNUNET_SET_OPERATION_INTERSECTION
Set intersection, only return elements that are in both sets.
@ GNUNET_SET_OPERATION_UNION
Set union, return all elements that are in at least one of the sets.
@ GNUNET_SET_OPERATION_NONE
A purely local set that does not support any operation.

◆ GNUNET_SET_Status

Status for the result callback.

Enumerator
GNUNET_SET_STATUS_OK 

Everything went ok, we are transmitting an element of the result (in set, or to be removed from set, depending on the enum GNUNET_SET_ResultMode).

Only applies to GNUNET_SET_RESULT_FULL, GNUNET_SET_RESULT_ADDED, GNUNET_SET_RESULT_REMOVED,

GNUNET_SET_STATUS_ADD_LOCAL 

Element should be added to the result set of the local peer, i.e.

the local peer is missing an element.

Only applies to GNUNET_SET_RESULT_SYMMETRIC

GNUNET_SET_STATUS_ADD_REMOTE 

Element should be added to the result set of the remote peer, i.e.

the remote peer is missing an element.

Only applies to GNUNET_SET_RESULT_SYMMETRIC

GNUNET_SET_STATUS_FAILURE 

The other peer refused to to the operation with us, or something went wrong.

GNUNET_SET_STATUS_HALF_DONE 

Success, all elements have been returned (but the other peer might still be receiving some from us, so we are not done).

Only used during UNION operation.

GNUNET_SET_STATUS_DONE 

Success, all elements have been sent (and received).

Definition at line 104 of file gnunet_set_service.h.

105 {
117 
126 
135 
141 
148 
153 };
@ GNUNET_SET_STATUS_OK
Everything went ok, we are transmitting an element of the result (in set, or to be removed from set,...
@ GNUNET_SET_STATUS_FAILURE
The other peer refused to to the operation with us, or something went wrong.
@ GNUNET_SET_STATUS_ADD_REMOTE
Element should be added to the result set of the remote peer, i.e.
@ GNUNET_SET_STATUS_HALF_DONE
Success, all elements have been returned (but the other peer might still be receiving some from us,...
@ GNUNET_SET_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SET_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.

◆ GNUNET_SET_ResultMode

The way results are given to the client.

Enumerator
GNUNET_SET_RESULT_FULL 

Client gets every element in the resulting set.

Only supported for set intersection.

GNUNET_SET_RESULT_SYMMETRIC 

Client gets notified of the required changes for both the local and the remote set.

Only supported for set

GNUNET_SET_RESULT_REMOVED 

Client gets only elements that have been removed from the set.

Only supported for set intersection.

GNUNET_SET_RESULT_ADDED 

Client gets only elements that have been added to the set.

Only supported for set union.

Definition at line 159 of file gnunet_set_service.h.

160 {
167 
175 
182 
189 };
@ GNUNET_SET_RESULT_REMOVED
Client gets only elements that have been removed from the set.
@ GNUNET_SET_RESULT_FULL
Client gets every element in the resulting set.
@ GNUNET_SET_RESULT_SYMMETRIC
Client gets notified of the required changes for both the local and the remote set.
@ GNUNET_SET_RESULT_ADDED
Client gets only elements that have been added to the set.

◆ GNUNET_SET_OptionType

Possible options to pass to a set operation.

Used as tag for struct GNUNET_SET_Option.

Enumerator
GNUNET_SET_OPTION_END 

List terminator.

GNUNET_SET_OPTION_BYZANTINE 

Fail set operations when the other peer shows weird behavior that might by a Byzantine fault.

For set union, 'v.num' is a lower bound on elements that the other peer must have in common with us.

GNUNET_SET_OPTION_FORCE_FULL 

Do not use the optimized set operation, but send full sets.

Might trigger Byzantine fault detection.

GNUNET_SET_OPTION_FORCE_DELTA 

Only use optimized set operations, even though for this particular set operation they might be much slower.

Might trigger Byzantine fault detection.

Definition at line 219 of file gnunet_set_service.h.

220 {
244 };
@ GNUNET_SET_OPTION_END
List terminator.
@ GNUNET_SET_OPTION_FORCE_DELTA
Only use optimized set operations, even though for this particular set operation they might be much s...
@ GNUNET_SET_OPTION_BYZANTINE
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault.
@ GNUNET_SET_OPTION_FORCE_FULL
Do not use the optimized set operation, but send full sets.

◆ GNUNET_SETI_Status

Status for the result callback.

Enumerator
GNUNET_SETI_STATUS_ADD_LOCAL 

Element should be added to the result set of the local peer, i.e.

the element is in the intersection.

GNUNET_SETI_STATUS_DEL_LOCAL 

Element should be delete from the result set of the local peer, i.e.

the local peer is having an element that is not in the intersection.

GNUNET_SETI_STATUS_FAILURE 

The other peer refused to do the operation with us, or something went wrong.

GNUNET_SETI_STATUS_DONE 

Success, all elements have been sent (and received).

Definition at line 78 of file gnunet_seti_service.h.

79 {
80 
86 
92 
98 
103 };
@ GNUNET_SETI_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SETI_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.
@ GNUNET_SETI_STATUS_FAILURE
The other peer refused to do the operation with us, or something went wrong.
@ GNUNET_SETI_STATUS_DEL_LOCAL
Element should be delete from the result set of the local peer, i.e.

◆ GNUNET_SETI_OptionType

Possible options to pass to a set operation.

Used as tag for struct GNUNET_SETI_Option.

Enumerator
GNUNET_SETI_OPTION_END 

List terminator.

GNUNET_SETI_OPTION_RETURN_INTERSECTION 

Return the elements remaining in the intersection (GNUNET_SETI_STATUS_ADD_LOCAL).

If not given, the default is to return a list of the elements to be removed (GNUNET_SETI_STATUS_DEL_LOCAL).

Definition at line 133 of file gnunet_seti_service.h.

134 {
139 
146 };
@ GNUNET_SETI_OPTION_RETURN_INTERSECTION
Return the elements remaining in the intersection (GNUNET_SETI_STATUS_ADD_LOCAL).
@ GNUNET_SETI_OPTION_END
List terminator.

◆ GNUNET_SETU_Status

Status for the result callback.

Enumerator
GNUNET_SETU_STATUS_ADD_LOCAL 

Element should be added to the result set of the local peer, i.e.

the local peer is missing an element.

GNUNET_SETU_STATUS_ADD_REMOTE 

Element should be added to the result set of the remote peer, i.e.

the remote peer is missing an element. Only used if GNUNET_SETU_OPTION_SYMMETRIC is set.

GNUNET_SETU_STATUS_FAILURE 

The other peer refused to do the operation with us, or something went wrong.

GNUNET_SETU_STATUS_DONE 

Success, all elements have been sent (and received).

Definition at line 78 of file gnunet_setu_service.h.

79 {
80 
86 
93 
99 
104 };
@ GNUNET_SETU_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SETU_STATUS_ADD_REMOTE
Element should be added to the result set of the remote peer, i.e.
@ GNUNET_SETU_STATUS_FAILURE
The other peer refused to do the operation with us, or something went wrong.
@ GNUNET_SETU_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.

◆ GNUNET_SETU_OptionType

Possible options to pass to a set operation.

Used as tag for struct GNUNET_SETU_Option.

Enumerator
GNUNET_SETU_OPTION_END 

List terminator.

GNUNET_SETU_OPTION_BYZANTINE 

Fail set operations when the other peer shows weird behavior that might by a Byzantine fault.

For set union, 'v.num' is a lower bound on elements that the other peer must have in common with us.

GNUNET_SETU_OPTION_FORCE_FULL 

Do not use the optimized set operation, but send full sets.

Might trigger Byzantine fault detection.

GNUNET_SETU_OPTION_FORCE_DELTA 

Only use optimized set operations, even though for this particular set operation they might be much slower.

Might trigger Byzantine fault detection.

GNUNET_SETU_OPTION_SYMMETRIC 

Notify client also if we are sending a value to the other peer.

GNUNET_SETU_OPTION_CUSTOM_BYZANTINE_UPPER_BOUND 

Byzantine upper bound.

Is the maximal plausible number of elements a peer can have default max uint64

GNUNET_SETU_OPTION_CUSTOM_BANDWIDTH_LATENCY_TRADEOFF 

Bandwidth latency tradeoff determines how much bytes a single RTT is worth, which is a performance setting.

GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKET_NUMBER_FACTOR 

The factor determines the number of buckets an IBF has which is multiplied by the estimated setsize default: 2.

GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKETS_PER_ELEMENT 

This setting determines to how many IBF buckets an single elements is mapped to.

Definition at line 134 of file gnunet_setu_service.h.

135 {
140 
149 
155 
162 
167 
173 
179 
185 
191 };
@ GNUNET_SETU_OPTION_FORCE_DELTA
Only use optimized set operations, even though for this particular set operation they might be much s...
@ GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKETS_PER_ELEMENT
This setting determines to how many IBF buckets an single elements is mapped to.
@ GNUNET_SETU_OPTION_CUSTOM_BANDWIDTH_LATENCY_TRADEOFF
Bandwidth latency tradeoff determines how much bytes a single RTT is worth, which is a performance se...
@ GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKET_NUMBER_FACTOR
The factor determines the number of buckets an IBF has which is multiplied by the estimated setsize d...
@ GNUNET_SETU_OPTION_CUSTOM_BYZANTINE_UPPER_BOUND
Byzantine upper bound.
@ GNUNET_SETU_OPTION_SYMMETRIC
Notify client also if we are sending a value to the other peer.
@ GNUNET_SETU_OPTION_END
List terminator.
@ GNUNET_SETU_OPTION_BYZANTINE
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault.
@ GNUNET_SETU_OPTION_FORCE_FULL
Do not use the optimized set operation, but send full sets.

Function Documentation

◆ GNUNET_SET_create()

struct GNUNET_SET_Handle* GNUNET_SET_create ( const struct GNUNET_CONFIGURATION_Handle cfg,
enum GNUNET_SET_OperationType  op 
)

Create an empty set, supporting the specified operation.

Parameters
cfgconfiguration to use for connecting to the set service
opoperation supported by the set Note that the operation has to be specified beforehand, as certain set operations need to maintain data structures specific to the operation
Returns
a handle to the set

Definition at line 656 of file set_api.c.

658 {
659  struct GNUNET_SET_Handle *set;
660 
661  set = create_internal (cfg,
662  op,
663  NULL);
665  "Creating set %p for operation %d\n",
666  set,
667  op);
668  return set;
669 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
@ GNUNET_ERROR_TYPE_DEBUG
static struct GNUNET_SET_Handle * create_internal(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op, const uint32_t *cookie)
FIXME.
Definition: set_api.c:582
#define LOG(kind,...)
Definition: set_api.c:33
Opaque handle to a set.
Definition: set_api.c:50

References cfg, create_internal(), GNUNET_ERROR_TYPE_DEBUG, LOG, and op.

Referenced by commit_set(), handle_client_join(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_add_element()

int GNUNET_SET_add_element ( struct GNUNET_SET_Handle set,
const struct GNUNET_SET_Element element,
GNUNET_SET_Continuation  cont,
void *  cont_cls 
)

Add an element to the given set.

After the element has been added (in the sense of being transmitted to the set service), cont will be called. Calls to GNUNET_SET_add_element can be queued

Parameters
setset to add element to
elementelement to add to the set
contcontinuation called after the element has been added
cont_clsclosure for cont
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

After the element has been added (in the sense of being transmitted to the set service), cont will be called. Multiple calls to GNUNET_SET_add_element() can be queued.

Parameters
setset to add element to
elementelement to add to the set
contcontinuation called after the element has been added
cont_clsclosure for cont
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 686 of file set_api.c.

690 {
691  struct GNUNET_MQ_Envelope *mqm;
693 
695  "adding element of type %u to set %p\n",
696  (unsigned int) element->element_type,
697  set);
698  GNUNET_assert (NULL != set);
699  if (GNUNET_YES == set->invalid)
700  {
701  if (NULL != cont)
702  cont (cont_cls);
703  return GNUNET_SYSERR;
704  }
705  mqm = GNUNET_MQ_msg_extra (msg,
706  element->size,
708  msg->element_type = htons (element->element_type);
709  GNUNET_memcpy (&msg[1],
710  element->data,
711  element->size);
713  cont, cont_cls);
714  GNUNET_MQ_send (set->mq, mqm);
715  return GNUNET_OK;
716 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:355
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:52
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
Definition: mq.c:787
#define GNUNET_MESSAGE_TYPE_SET_ADD
Add element to set.
Message sent by client to the service to add or remove an element to/from the set.
Definition: set.h:281
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
uint16_t element_type
Application-specific element type.
int invalid
Has the set become invalid (e.g.
Definition: set_api.c:87
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: set_api.c:54

References GNUNET_SET_Element::data, GNUNET_SET_Element::element_type, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_ADD, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SET_Handle::invalid, LOG, GNUNET_SET_Handle::mq, msg, and GNUNET_SET_Element::size.

Referenced by commit_set(), handle_client_insert(), set_insert_iterator(), set_result_cb(), task_start_apply_round(), and task_start_eval_echo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_remove_element()

int GNUNET_SET_remove_element ( struct GNUNET_SET_Handle set,
const struct GNUNET_SET_Element element,
GNUNET_SET_Continuation  cont,
void *  cont_cls 
)

Remove an element to the given set.

After the element has been removed (in the sense of the request being transmitted to the set service), cont will be called. Calls to remove_element can be queued

Parameters
setset to remove element from
elementelement to remove from the set
contcontinuation called after the element has been removed
cont_clsclosure for cont
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

After the element has been removed (in the sense of the request being transmitted to the set service), cont will be called. Multiple calls to GNUNET_SET_remove_element() can be queued

Parameters
setset to remove element from
elementelement to remove from the set
contcontinuation called after the element has been removed
cont_clsclosure for cont
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 733 of file set_api.c.

737 {
738  struct GNUNET_MQ_Envelope *mqm;
740 
742  "Removing element from set %p\n",
743  set);
744  if (GNUNET_YES == set->invalid)
745  {
746  if (NULL != cont)
747  cont (cont_cls);
748  return GNUNET_SYSERR;
749  }
750  mqm = GNUNET_MQ_msg_extra (msg,
751  element->size,
753  msg->element_type = htons (element->element_type);
754  GNUNET_memcpy (&msg[1],
755  element->data,
756  element->size);
758  cont, cont_cls);
759  GNUNET_MQ_send (set->mq, mqm);
760  return GNUNET_OK;
761 }
#define GNUNET_MESSAGE_TYPE_SET_REMOVE
Remove element from set.

References GNUNET_SET_Element::data, GNUNET_SET_Element::element_type, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_REMOVE, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SET_Handle::invalid, LOG, GNUNET_SET_Handle::mq, msg, and GNUNET_SET_Element::size.

Referenced by set_result_cb(), task_start_apply_round(), and task_start_eval_echo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_copy_lazy()

void GNUNET_SET_copy_lazy ( struct GNUNET_SET_Handle set,
GNUNET_SET_CopyReadyCallback  cb,
void *  cls 
)

Definition at line 1193 of file set_api.c.

1196 {
1197  struct GNUNET_MQ_Envelope *ev;
1198  struct SetCopyRequest *req;
1199 
1201  "Creating lazy copy of set\n");
1203  GNUNET_MQ_send (set->mq, ev);
1204 
1205  req = GNUNET_new (struct SetCopyRequest);
1206  req->cb = cb;
1207  req->cls = cls;
1209  set->copy_req_tail,
1210  req);
1211 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_MQ_msg_header(type)
Allocate a GNUNET_MQ_Envelope, where the message only consists of a header.
Definition: gnunet_mq_lib.h:76
#define GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_PREPARE
Ask the set service to prepare a copy of a set.
struct SetCopyRequest * copy_req_head
Doubly linked list of copy requests.
Definition: set_api.c:103
struct SetCopyRequest * copy_req_tail
Doubly linked list of copy requests.
Definition: set_api.c:108
void * cls
Definition: set_api.c:41
GNUNET_SET_CopyReadyCallback cb
Definition: set_api.c:43

References SetCopyRequest::cb, SetCopyRequest::cls, GNUNET_SET_Handle::copy_req_head, GNUNET_SET_Handle::copy_req_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_PREPARE, GNUNET_MQ_msg_header, GNUNET_MQ_send(), GNUNET_new, LOG, and GNUNET_SET_Handle::mq.

Referenced by create_set_copy_for_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_destroy()

void GNUNET_SET_destroy ( struct GNUNET_SET_Handle set)

Destroy the set handle, and free all associated resources.

Iterations must have completed (or be explicitly canceled) before destroying the corresponding set. Operations may still be pending when a set is destroyed.

Parameters
setset to destroy

Destroy the set handle, and free all associated resources.

Parameters
setset handle to destroy

Definition at line 771 of file set_api.c.

772 {
773  /* destroying set while iterator is active is currently
774  not supported; we should expand the API to allow
775  clients to explicitly cancel the iteration! */
776  GNUNET_assert (NULL != set);
777  if ((NULL != set->ops_head) ||
778  (NULL != set->iterator) ||
780  {
782  "Set operations are pending, delaying set destruction\n");
784  return;
785  }
787  "Really destroying set\n");
788  if (NULL != set->mq)
789  {
790  GNUNET_MQ_destroy (set->mq);
791  set->mq = NULL;
792  }
793  GNUNET_free (set);
794 }
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:837
struct GNUNET_SET_OperationHandle * ops_head
Linked list of operations on the set.
Definition: set_api.c:59
int destroy_requested
Should the set be destroyed once all operations are gone? GNUNET_SYSERR if GNUNET_SET_destroy() must ...
Definition: set_api.c:82
GNUNET_SET_ElementIterator iterator
Callback for the current iteration over the set, NULL if no iterator is active.
Definition: set_api.c:70

References GNUNET_SET_Handle::destroy_requested, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SYSERR, GNUNET_YES, GNUNET_SET_Handle::iterator, LOG, GNUNET_SET_Handle::mq, and GNUNET_SET_Handle::ops_head.

Referenced by client_disconnect_cb(), commit_set(), GNUNET_SET_operation_cancel(), handle_iter_done(), handle_result(), handle_shutdown(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_prepare()

struct GNUNET_SET_OperationHandle* GNUNET_SET_prepare ( const struct GNUNET_PeerIdentity other_peer,
const struct GNUNET_HashCode app_id,
const struct GNUNET_MessageHeader context_msg,
enum GNUNET_SET_ResultMode  result_mode,
struct GNUNET_SET_Option  options[],
GNUNET_SET_ResultIterator  result_cb,
void *  result_cls 
)

Prepare a set operation to be evaluated with another peer.

The evaluation will not start until the client provides a local set with GNUNET_SET_commit().

Parameters
other_peerpeer with the other set
app_idhash for the application using the set
context_msgadditional information for the request
result_modespecified how results will be returned, see enum GNUNET_SET_ResultMode.
result_cbcalled on error or success
result_clsclosure for result_cb
Returns
a handle to cancel the operation

The evaluation will not start until the client provides a local set with GNUNET_SET_commit().

Parameters
other_peerpeer with the other set
app_idhash for the application using the set
context_msgadditional information for the request
result_modespecified how results will be returned, see enum GNUNET_SET_ResultMode.
result_cbcalled on error or success
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 812 of file set_api.c.

819 {
820  struct GNUNET_MQ_Envelope *mqm;
823  struct GNUNET_SET_Option *opt;
824 
826  "Client prepares set operation (%d)\n",
827  result_mode);
829  oh->result_cb = result_cb;
830  oh->result_cls = result_cls;
833  context_msg);
834  msg->app_id = *app_id;
835  msg->result_mode = htonl (result_mode);
836  msg->target_peer = *other_peer;
837  for (opt = options; opt->type != 0; opt++)
838  {
839  switch (opt->type)
840  {
842  msg->byzantine = GNUNET_YES;
843  msg->byzantine_lower_bound = opt->v.num;
844  break;
845 
847  msg->force_full = GNUNET_YES;
848  break;
849 
851  msg->force_delta = GNUNET_YES;
852  break;
853 
854  default:
856  "Option with type %d not recognized\n", (int) opt->type);
857  }
858  }
859  oh->conclude_mqm = mqm;
860  oh->request_id_addr = &msg->request_id;
861 
862  return oh;
863 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static struct GNUNET_TRANSPORT_OfferHelloHandle * oh
Active HELLO offering to transport service.
static struct GNUNET_HashCode app_id
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_MQ_msg_nested_mh(mvar, type, mh)
Allocate a GNUNET_MQ_Envelope, and append a payload message after the given message struct.
#define GNUNET_MESSAGE_TYPE_SET_EVALUATE
Evaluate a set operation.
Message sent by client to service to initiate a set operation as a client (not as listener).
Definition: set.h:181
Handle to an operation.
Definition: set_api.c:136
Option for set operations.
enum GNUNET_SET_OptionType type
Type of the option.
union GNUNET_SET_Option::@40 v
Value for the option, only used with some options.

References app_id, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_MESSAGE_TYPE_SET_EVALUATE, GNUNET_MQ_msg_nested_mh, GNUNET_new, GNUNET_SET_OPTION_BYZANTINE, GNUNET_SET_OPTION_FORCE_DELTA, GNUNET_SET_OPTION_FORCE_FULL, GNUNET_YES, LOG, msg, GNUNET_SET_Option::num, oh, options, GNUNET_SET_Option::type, and GNUNET_SET_Option::v.

Referenced by run(), and task_start_reconcile().

Here is the caller graph for this function:

◆ GNUNET_SET_listen()

struct GNUNET_SET_ListenHandle* GNUNET_SET_listen ( const struct GNUNET_CONFIGURATION_Handle cfg,
enum GNUNET_SET_OperationType  operation,
const struct GNUNET_HashCode app_id,
GNUNET_SET_ListenCallback  listen_cb,
void *  listen_cls 
)

Wait for set operation requests for the given application ID.

If the connection to the set service is lost, the listener is re-created transparently with exponential backoff.

Parameters
cfgconfiguration to use for connecting to the set service
operationoperation we want to listen for
app_idid of the application that handles set operation requests
listen_cbcalled for each incoming request matching the operation and application id
listen_clshandle for listen_cb
Returns
a handle that can be used to cancel the listen operation

Wait for set operation requests for the given application ID.

Parameters
cfgconfiguration to use for connecting to the set service, needs to be valid for the lifetime of the listen handle
operationoperation we want to listen for
app_idid of the application that handles set operation requests
listen_cbcalled for each incoming request matching the operation and application id
listen_clshandle for listen_cb
Returns
a handle that can be used to cancel the listen operation

Definition at line 1016 of file set_api.c.

1021 {
1022  struct GNUNET_SET_ListenHandle *lh;
1023 
1025  "Starting listener for app %s\n",
1026  GNUNET_h2s (app_id));
1027  lh = GNUNET_new (struct GNUNET_SET_ListenHandle);
1028  lh->listen_cb = listen_cb;
1029  lh->listen_cls = listen_cls;
1030  lh->cfg = cfg;
1031  lh->operation = operation;
1032  lh->app_id = *app_id;
1034  listen_connect (lh);
1035  if (NULL == lh->mq)
1036  {
1037  GNUNET_free (lh);
1038  return NULL;
1039  }
1040  return lh;
1041 }
static void listen_cb(void *cls)
We have been notified that our listen socket has something to read.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
static void listen_connect(void *cls)
Connect to the set service in order to listen for requests.
Definition: set_api.c:973
Opaque handle to a listen operation.
Definition: set_api.c:187
struct GNUNET_TIME_Relative reconnect_backoff
Time to wait until we try to reconnect on failure.
Definition: set_api.c:219
void * listen_cls
Closure for listen_cb.
Definition: set_api.c:209
struct GNUNET_HashCode app_id
Application ID we listen for.
Definition: set_api.c:214
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle for the listener, stored here to be able to reconnect transparently on connectio...
Definition: set_api.c:198
enum GNUNET_SET_OperationType operation
Operation we listen for.
Definition: set_api.c:229
struct GNUNET_MQ_Handle * mq
Message queue for the client.
Definition: set_api.c:191
GNUNET_SET_ListenCallback listen_cb
Function to call on a new incoming request, or on error.
Definition: set_api.c:204

References app_id, GNUNET_SET_ListenHandle::app_id, cfg, GNUNET_SET_ListenHandle::cfg, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_new, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_SET_ListenHandle::listen_cb, listen_cb(), GNUNET_SET_ListenHandle::listen_cls, listen_connect(), LOG, GNUNET_SET_ListenHandle::mq, GNUNET_SET_ListenHandle::operation, and GNUNET_SET_ListenHandle::reconnect_backoff.

Referenced by handle_client_join(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_listen_cancel()

void GNUNET_SET_listen_cancel ( struct GNUNET_SET_ListenHandle lh)

Cancel the given listen operation.

After calling cancel, the listen callback for this listen handle will not be called again. Note that cancelling a listen operation will automatically reject all operations that have not yet been accepted.

Parameters
lhhandle for the listen operation
lhhandle for the listen operation

Definition at line 1050 of file set_api.c.

1051 {
1053  "Canceling listener %s\n",
1054  GNUNET_h2s (&lh->app_id));
1055  if (NULL != lh->mq)
1056  {
1057  GNUNET_MQ_destroy (lh->mq);
1058  lh->mq = NULL;
1059  }
1060  if (NULL != lh->reconnect_task)
1061  {
1063  lh->reconnect_task = NULL;
1064  }
1065  GNUNET_free (lh);
1066 }
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
Definition: set_api.c:224

References GNUNET_SET_ListenHandle::app_id, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), LOG, GNUNET_SET_ListenHandle::mq, and GNUNET_SET_ListenHandle::reconnect_task.

Referenced by client_disconnect_cb(), and handle_shutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_accept()

struct GNUNET_SET_OperationHandle* GNUNET_SET_accept ( struct GNUNET_SET_Request request,
enum GNUNET_SET_ResultMode  result_mode,
struct GNUNET_SET_Option  options[],
GNUNET_SET_ResultIterator  result_cb,
void *  result_cls 
)

Accept a request we got via GNUNET_SET_listen().

Must be called during GNUNET_SET_listen(), as the struct GNUNET_SET_Request becomes invalid afterwards. Call GNUNET_SET_commit() to provide the local set to use for the operation, and to begin the exchange with the remote peer.

Parameters
requestrequest to accept
result_modespecified how results will be returned, see enum GNUNET_SET_ResultMode.
result_cbcallback for the results
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Accept a request we got via GNUNET_SET_listen().

Must be called during GNUNET_SET_listen, as the 'struct GNUNET_SET_Request' becomes invalid afterwards. Call GNUNET_SET_commit to provide the local set to use for the operation, and to begin the exchange with the remote peer.

Parameters
requestrequest to accept
result_modespecified how results will be returned, see enum GNUNET_SET_ResultMode.
result_cbcallback for the results
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 1084 of file set_api.c.

1089 {
1090  struct GNUNET_MQ_Envelope *mqm;
1092  struct GNUNET_SET_AcceptMessage *msg;
1093 
1094  GNUNET_assert (GNUNET_NO == request->accepted);
1096  "Client accepts set operation (%d) with id %u\n",
1097  result_mode,
1098  request->accept_id);
1099  request->accepted = GNUNET_YES;
1100  mqm = GNUNET_MQ_msg (msg,
1102  msg->accept_reject_id = htonl (request->accept_id);
1103  msg->result_mode = htonl (result_mode);
1105  oh->result_cb = result_cb;
1106  oh->result_cls = result_cls;
1107  oh->conclude_mqm = mqm;
1108  oh->request_id_addr = &msg->request_id;
1109  return oh;
1110 }
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:41
@ GNUNET_NO
Definition: gnunet_common.h:94
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MESSAGE_TYPE_SET_ACCEPT
Accept a set request.
Message sent by a listening client to the service to accept performing the operation with the other p...
Definition: set.h:83
uint32_t result_mode
How should results be sent to us? See enum GNUNET_SET_ResultMode.
Definition: set.h:103

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_ACCEPT, GNUNET_MQ_msg, GNUNET_new, GNUNET_NO, GNUNET_YES, LOG, msg, oh, request, and GNUNET_SET_AcceptMessage::result_mode.

Referenced by set_listen_cb().

Here is the caller graph for this function:

◆ GNUNET_SET_commit()

int GNUNET_SET_commit ( struct GNUNET_SET_OperationHandle oh,
struct GNUNET_SET_Handle set 
)

Commit a set to be used with a set operation.

This function is called once we have fully constructed the set that we want to use for the operation. At this time, the P2P protocol can then begin to exchange the set information and call the result callback with the result information.

Parameters
ohhandle to the set operation
setthe set to use for the operation
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 1127 of file set_api.c.

1129 {
1130  if (NULL != oh->set)
1131  {
1132  /* Some other set was already committed for this
1133  * operation, there is a logic bug in the client of this API */
1134  GNUNET_break (0);
1135  return GNUNET_OK;
1136  }
1137  GNUNET_assert (NULL != set);
1138  if (GNUNET_YES == set->invalid)
1139  return GNUNET_SYSERR;
1141  "Client commits to SET\n");
1142  GNUNET_assert (NULL != oh->conclude_mqm);
1143  oh->set = set;
1145  set->ops_tail,
1146  oh);
1147  oh->request_id = GNUNET_MQ_assoc_add (set->mq,
1148  oh);
1149  *oh->request_id_addr = htonl (oh->request_id);
1150  GNUNET_MQ_send (set->mq,
1151  oh->conclude_mqm);
1152  oh->conclude_mqm = NULL;
1153  oh->request_id_addr = NULL;
1154  return GNUNET_OK;
1155 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
uint32_t GNUNET_MQ_assoc_add(struct GNUNET_MQ_Handle *mq, void *assoc_data)
Associate the assoc_data in mq with a unique request id.
Definition: mq.c:721
struct GNUNET_SET_OperationHandle * ops_tail
Linked list of operations on the set.
Definition: set_api.c:64

References GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_assoc_add(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SET_Handle::invalid, LOG, GNUNET_SET_Handle::mq, oh, GNUNET_SET_Handle::ops_head, and GNUNET_SET_Handle::ops_tail.

Referenced by commit_set(), run(), and set_listen_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_operation_cancel()

void GNUNET_SET_operation_cancel ( struct GNUNET_SET_OperationHandle oh)

Cancel the given set operation.

May not be called after the operation's GNUNET_SET_ResultIterator has been called with a status that indicates error, timeout or done.

Parameters
ohset operation to cancel

We need to send an explicit cancel message, as all operations one one set communicate using one handle.

Parameters
ohset operation to cancel

Definition at line 516 of file set_api.c.

517 {
518  struct GNUNET_SET_Handle *set = oh->set;
519  struct GNUNET_SET_CancelMessage *m;
520  struct GNUNET_MQ_Envelope *mqm;
521 
523  "Cancelling SET operation\n");
524  if (NULL != set)
525  {
527  m->request_id = htonl (oh->request_id);
528  GNUNET_MQ_send (set->mq, mqm);
529  }
531  if ((NULL != set) &&
532  (GNUNET_YES == set->destroy_requested) &&
533  (NULL == set->ops_head))
534  {
536  "Destroying set after operation cancel\n");
537  GNUNET_SET_destroy (set);
538  }
539 }
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
#define GNUNET_MESSAGE_TYPE_SET_CANCEL
Cancel a set operation.
void GNUNET_SET_destroy(struct GNUNET_SET_Handle *set)
Destroy the set handle if no operations are left, mark the set for destruction otherwise.
Definition: set_api.c:771
static void set_operation_destroy(struct GNUNET_SET_OperationHandle *oh)
Destroy the given set operation.
Definition: set_api.c:486
Sent to the service by the client in order to cancel a set operation.
Definition: set.h:307

References GNUNET_SET_Handle::destroy_requested, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SET_destroy(), GNUNET_YES, LOG, m, GNUNET_SET_Handle::mq, oh, GNUNET_SET_Handle::ops_head, and set_operation_destroy().

Referenced by commit_set(), and handle_shutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_iterate()

int GNUNET_SET_iterate ( struct GNUNET_SET_Handle set,
GNUNET_SET_ElementIterator  iter,
void *  iter_cls 
)

Iterate over all elements in the given set.

Note that this operation involves transferring every element of the set from the service to the client, and is thus costly. Only one iteration per set may be active at the same time.

Parameters
setthe set to iterate over
iterthe iterator to call for each element
iter_clsclosure for iter
Returns
GNUNET_YES if the iteration started successfully, GNUNET_NO if another iteration was still active, GNUNET_SYSERR if the set is invalid (e.g. the server crashed, disconnected)

Note that this operation involves transferring every element of the set from the service to the client, and is thus costly.

Parameters
setthe set to iterate over
iterthe iterator to call for each element
iter_clsclosure for iter
Returns
GNUNET_YES if the iteration started successfully, GNUNET_NO if another iteration is active GNUNET_SYSERR if the set is invalid (e.g. the server crashed, disconnected)

Definition at line 1171 of file set_api.c.

1174 {
1175  struct GNUNET_MQ_Envelope *ev;
1176 
1177  GNUNET_assert (NULL != iter);
1178  if (GNUNET_YES == set->invalid)
1179  return GNUNET_SYSERR;
1180  if (NULL != set->iterator)
1181  return GNUNET_NO;
1183  "Iterating over set\n");
1184  set->iterator = iter;
1185  set->iterator_cls = iter_cls;
1187  GNUNET_MQ_send (set->mq, ev);
1188  return GNUNET_YES;
1189 }
#define GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST
Start iteration over set elements.
void * iterator_cls
Closure for iterator.
Definition: set_api.c:75

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST, GNUNET_MQ_msg_header, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, GNUNET_SET_Handle::invalid, GNUNET_SET_Handle::iterator, GNUNET_SET_Handle::iterator_cls, LOG, and GNUNET_SET_Handle::mq.

Referenced by task_start_finish().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SET_iterate_cancel()

void GNUNET_SET_iterate_cancel ( struct GNUNET_SET_Handle set)

Stop iteration over all elements in the given set.

Can only be called before the iteration has "naturally" completed its turn.

Parameters
setthe set to stop iterating over

◆ GNUNET_SET_element_dup()

struct GNUNET_SET_Element* GNUNET_SET_element_dup ( const struct GNUNET_SET_Element element)

Create a copy of an element.

The copy must be GNUNET_free-d by the caller.

Parameters
elementthe element to copy
Returns
the copied element

Definition at line 1222 of file set_api.c.

1223 {
1224  struct GNUNET_SET_Element *copy;
1225 
1226  copy = GNUNET_malloc (element->size + sizeof(struct GNUNET_SET_Element));
1227  copy->size = element->size;
1228  copy->element_type = element->element_type;
1229  copy->data = &copy[1];
1230  GNUNET_memcpy (&copy[1],
1231  element->data,
1232  copy->size);
1233  return copy;
1234 }
#define GNUNET_malloc(size)
Wrapper around malloc.
Element stored in a set.

References GNUNET_SET_Element::data, GNUNET_SET_Element::element_type, GNUNET_malloc, GNUNET_memcpy, and GNUNET_SET_Element::size.

Referenced by diff_insert(), and rfn_vote().

Here is the caller graph for this function:

◆ GNUNET_SET_element_hash()

void GNUNET_SET_element_hash ( const struct GNUNET_SET_Element element,
struct GNUNET_HashCode ret_hash 
)

Hash a set element.

Parameters
elementthe element that should be hashed
ret_hasha pointer to where the hash of element should be stored
elementthe element that should be hashed
[out]ret_hasha pointer to where the hash of element should be stored

Definition at line 1245 of file set_api.c.

1247 {
1249 
1250  /* It's not guaranteed that the element data is always after the element header,
1251  so we need to hash the chunks separately. */
1252  GNUNET_CRYPTO_hash_context_read (ctx, &element->size, sizeof(uint16_t));
1254  sizeof(uint16_t));
1255  GNUNET_CRYPTO_hash_context_read (ctx, element->data, element->size);
1257 }
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
Definition: crypto_hash.c:321
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
Definition: crypto_hash.c:340
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
Definition: crypto_hash.c:364

References ctx, GNUNET_SET_Element::data, GNUNET_SET_Element::element_type, GNUNET_CRYPTO_hash_context_finish(), GNUNET_CRYPTO_hash_context_read(), GNUNET_CRYPTO_hash_context_start(), and GNUNET_SET_Element::size.

Referenced by diff_insert(), execute_add(), execute_remove(), handle_union_p2p_elements(), handle_union_p2p_full_element(), and rfn_vote().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_create()

struct GNUNET_SETI_Handle* GNUNET_SETI_create ( const struct GNUNET_CONFIGURATION_Handle cfg)

Create an empty set, supporting the specified operation.

Parameters
cfgconfiguration to use for connecting to the set service
Returns
a handle to the set

Create an empty set, supporting the specified operation.

Parameters
cfgconfiguration to use for connecting to the set service
Returns
a handle to the set

Definition at line 399 of file seti_api.c.

400 {
401  struct GNUNET_SETI_Handle *set = GNUNET_new (struct GNUNET_SETI_Handle);
402  struct GNUNET_MQ_MessageHandler mq_handlers[] = {
406  set),
408  };
409  struct GNUNET_MQ_Envelope *mqm;
410  struct GNUNET_SETI_CreateMessage *create_msg;
411 
412  set->cfg = cfg;
413  set->mq = GNUNET_CLIENT_connect (cfg,
414  "seti",
415  mq_handlers,
417  set);
418  if (NULL == set->mq)
419  {
420  GNUNET_free (set);
421  return NULL;
422  }
424  "Creating new intersection set\n");
425  mqm = GNUNET_MQ_msg (create_msg,
427  GNUNET_MQ_send (set->mq,
428  mqm);
429  return set;
430 }
static int result
Global testing status.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1064
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_SETI_RESULT
Handle result message from operation.
#define GNUNET_MESSAGE_TYPE_SETI_CREATE
Create a new local set.
static void handle_client_set_error(void *cls, enum GNUNET_MQ_Error error)
We encountered an error communicating with the set service while performing a set operation.
Definition: seti_api.c:369
#define LOG(kind,...)
Definition: seti_api.c:33
Message handler for a specific message type.
Message sent by the client to the service to ask starting a new set to perform operations with.
Definition: seti.h:40
Opaque handle to a set.
Definition: seti_api.c:40
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: seti_api.c:44
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration, needed when creating (lazy) copies.
Definition: seti_api.c:59
Message sent by the service to the client to indicate an element that is removed (set intersection) o...
Definition: seti.h:192

References cfg, GNUNET_SETI_Handle::cfg, GNUNET_CLIENT_connect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MESSAGE_TYPE_SETI_CREATE, GNUNET_MESSAGE_TYPE_SETI_RESULT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, handle_client_set_error(), LOG, GNUNET_SETI_Handle::mq, and result.

Referenced by handle_alice_client_message(), handle_bob_client_message(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_add_element()

int GNUNET_SETI_add_element ( struct GNUNET_SETI_Handle set,
const struct GNUNET_SETI_Element element,
GNUNET_SCHEDULER_TaskCallback  cb,
void *  cb_cls 
)

Add an element to the given set.

Parameters
setset to add element to
elementelement to add to the set
cbfunction to call when finished, can be NULL
cb_clsclosure for cb
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

After the element has been added (in the sense of being transmitted to the set service), cont will be called. Multiple calls to GNUNET_SETI_add_element() can be queued.

Parameters
setset to add element to
elementelement to add to the set
cbcontinuation called after the element has been added
cb_clsclosure for cont
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 447 of file seti_api.c.

451 {
452  struct GNUNET_MQ_Envelope *mqm;
454 
456  "adding element of type %u to set %p\n",
457  (unsigned int) element->element_type,
458  set);
459  if (GNUNET_YES == set->invalid)
460  {
461  if (NULL != cb)
462  cb (cb_cls);
463  return GNUNET_SYSERR;
464  }
465  mqm = GNUNET_MQ_msg_extra (msg,
466  element->size,
468  msg->element_type = htons (element->element_type);
469  GNUNET_memcpy (&msg[1],
470  element->data,
471  element->size);
473  cb,
474  cb_cls);
475  GNUNET_MQ_send (set->mq,
476  mqm);
477  return GNUNET_OK;
478 }
#define GNUNET_MESSAGE_TYPE_SETI_ADD
Add element to set.
Message sent by client to the service to add an element to the set.
Definition: seti.h:227
const void * data
Actual data of the element.
uint16_t element_type
Application-specific element type.
uint16_t size
Number of bytes in the buffer pointed to by data.
int invalid
Has the set become invalid (e.g.
Definition: seti_api.c:71

References GNUNET_SETI_Element::data, GNUNET_SETI_Element::element_type, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SETI_ADD, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SETI_Handle::invalid, LOG, GNUNET_SETI_Handle::mq, msg, and GNUNET_SETI_Element::size.

Referenced by handle_alice_client_message(), handle_alice_client_message_multipart(), handle_bob_client_message(), handle_bob_client_message_multipart(), and set_insert_iterator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_destroy()

void GNUNET_SETI_destroy ( struct GNUNET_SETI_Handle set)

Destroy the set handle, and free all associated resources.

Operations may still be pending when a set is destroyed (and will be allowed to complete).

Parameters
setset to destroy

Destroy the set handle, and free all associated resources.

Parameters
setset handle to destroy

Definition at line 488 of file seti_api.c.

489 {
490  /* destroying set while iterator is active is currently
491  not supported; we should expand the API to allow
492  clients to explicitly cancel the iteration! */
493  if ((NULL != set->ops_head) ||
495  {
497  "Set operations are pending, delaying set destruction\n");
499  return;
500  }
502  "Really destroying set\n");
503  if (NULL != set->mq)
504  {
505  GNUNET_MQ_destroy (set->mq);
506  set->mq = NULL;
507  }
508  GNUNET_free (set);
509 }
struct GNUNET_SETI_OperationHandle * ops_head
Linked list of operations on the set.
Definition: seti_api.c:49
int destroy_requested
Should the set be destroyed once all operations are gone? GNUNET_SYSERR if GNUNET_SETI_destroy() must...
Definition: seti_api.c:66

References GNUNET_SETI_Handle::destroy_requested, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SYSERR, GNUNET_YES, LOG, GNUNET_SETI_Handle::mq, and GNUNET_SETI_Handle::ops_head.

Referenced by cb_intersection_element_removed(), destroy_service_session(), GNUNET_SETI_operation_cancel(), handle_result(), handle_shutdown(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_prepare()

struct GNUNET_SETI_OperationHandle* GNUNET_SETI_prepare ( const struct GNUNET_PeerIdentity other_peer,
const struct GNUNET_HashCode app_id,
const struct GNUNET_MessageHeader context_msg,
const struct GNUNET_SETI_Option  options[],
GNUNET_SETI_ResultIterator  result_cb,
void *  result_cls 
)

Prepare a set operation to be evaluated with another peer.

The evaluation will not start until the client provides a local set with GNUNET_SETI_commit().

Parameters
other_peerpeer with the other set
app_idhash for the application using the set
context_msgadditional information for the request
optionsoptions to use when processing the request
result_cbcalled on error or success
result_clsclosure for result_cb
Returns
a handle to cancel the operation

The evaluation will not start until the client provides a local set with GNUNET_SETI_commit().

Parameters
other_peerpeer with the other set
app_idhash for the application using the set
context_msgadditional information for the request
optionsoptions to use when processing the request
result_cbcalled on error or success
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 526 of file seti_api.c.

532 {
533  struct GNUNET_MQ_Envelope *mqm;
536 
538  oh->result_cb = result_cb;
539  oh->result_cls = result_cls;
542  context_msg);
543  msg->app_id = *app_id;
544  msg->target_peer = *other_peer;
545  for (const struct GNUNET_SETI_Option *opt = options;
546  GNUNET_SETI_OPTION_END != opt->type;
547  opt++)
548  {
549  switch (opt->type)
550  {
552  msg->return_intersection = htonl (GNUNET_YES);
553  break;
554  default:
556  "Option with type %d not recognized\n",
557  (int) opt->type);
558  }
559  }
560  oh->conclude_mqm = mqm;
561  oh->request_id_addr = &msg->request_id;
562  return oh;
563 }
#define GNUNET_MESSAGE_TYPE_SETI_EVALUATE
Evaluate a set operation.
Message sent by client to service to initiate a set operation as a client (not as listener).
Definition: seti.h:152
Handle to an operation.
Definition: seti_api.c:106
Option for set operations.

References app_id, GNUNET_ERROR_TYPE_ERROR, GNUNET_MESSAGE_TYPE_SETI_EVALUATE, GNUNET_MQ_msg_nested_mh, GNUNET_new, GNUNET_SETI_OPTION_END, GNUNET_SETI_OPTION_RETURN_INTERSECTION, GNUNET_YES, LOG, msg, oh, and options.

Referenced by run(), and start_intersection().

Here is the caller graph for this function:

◆ GNUNET_SETI_listen()

struct GNUNET_SETI_ListenHandle* GNUNET_SETI_listen ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_HashCode app_id,
GNUNET_SETI_ListenCallback  listen_cb,
void *  listen_cls 
)

Wait for set operation requests for the given application ID.

If the connection to the set service is lost, the listener is re-created transparently with exponential backoff.

Parameters
cfgconfiguration to use for connecting to the set service
app_idid of the application that handles set operation requests
listen_cbcalled for each incoming request matching the operation and application id
listen_clshandle for listen_cb
Returns
a handle that can be used to cancel the listen operation

Wait for set operation requests for the given application ID.

Parameters
cfgconfiguration to use for connecting to the set service, needs to be valid for the lifetime of the listen handle
app_idid of the application that handles set operation requests
listen_cbcalled for each incoming request matching the operation and application id
listen_clshandle for listen_cb
Returns
a handle that can be used to cancel the listen operation

Definition at line 715 of file seti_api.c.

719 {
720  struct GNUNET_SETI_ListenHandle *lh;
721 
723  "Starting listener for app %s\n",
724  GNUNET_h2s (app_id));
725  lh = GNUNET_new (struct GNUNET_SETI_ListenHandle);
726  lh->listen_cb = listen_cb;
727  lh->listen_cls = listen_cls;
728  lh->cfg = cfg;
729  lh->app_id = *app_id;
731  listen_connect (lh);
732  if (NULL == lh->mq)
733  {
734  GNUNET_free (lh);
735  return NULL;
736  }
737  return lh;
738 }
static void listen_connect(void *cls)
Connect to the set service in order to listen for requests.
Definition: seti_api.c:674
Opaque handle to a listen operation.
Definition: seti_api.c:163
struct GNUNET_HashCode app_id
Application ID we listen for.
Definition: seti_api.c:195
struct GNUNET_TIME_Relative reconnect_backoff
Time to wait until we try to reconnect on failure.
Definition: seti_api.c:200
GNUNET_SETI_ListenCallback listen_cb
Function to call on a new incoming request, or on error.
Definition: seti_api.c:180
struct GNUNET_MQ_Handle * mq
Message queue for the client.
Definition: seti_api.c:167
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle for the listener, stored here to be able to reconnect transparently on connectio...
Definition: seti_api.c:174
void * listen_cls
Closure for listen_cb.
Definition: seti_api.c:185

References app_id, GNUNET_SETI_ListenHandle::app_id, cfg, GNUNET_SETI_ListenHandle::cfg, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_new, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_SETI_ListenHandle::listen_cb, listen_cb(), GNUNET_SETI_ListenHandle::listen_cls, listen_connect(), LOG, GNUNET_SETI_ListenHandle::mq, and GNUNET_SETI_ListenHandle::reconnect_backoff.

Referenced by client_request_complete_alice(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_listen_cancel()

void GNUNET_SETI_listen_cancel ( struct GNUNET_SETI_ListenHandle lh)

Cancel the given listen operation.

After calling cancel, the listen callback for this listen handle will not be called again. Note that cancelling a listen operation will automatically reject all operations that have not yet been accepted.

Parameters
lhhandle for the listen operation
lhhandle for the listen operation

Definition at line 747 of file seti_api.c.

748 {
750  "Canceling listener %s\n",
751  GNUNET_h2s (&lh->app_id));
752  if (NULL != lh->mq)
753  {
754  GNUNET_MQ_destroy (lh->mq);
755  lh->mq = NULL;
756  }
757  if (NULL != lh->reconnect_task)
758  {
760  lh->reconnect_task = NULL;
761  }
762  GNUNET_free (lh);
763 }
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
Definition: seti_api.c:190

References GNUNET_SETI_ListenHandle::app_id, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), LOG, GNUNET_SETI_ListenHandle::mq, and GNUNET_SETI_ListenHandle::reconnect_task.

Referenced by cb_intersection_element_removed(), destroy_service_session(), and handle_shutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_accept()

struct GNUNET_SETI_OperationHandle* GNUNET_SETI_accept ( struct GNUNET_SETI_Request request,
const struct GNUNET_SETI_Option  options[],
GNUNET_SETI_ResultIterator  result_cb,
void *  result_cls 
)

Accept a request we got via GNUNET_SETI_listen().

Must be called during GNUNET_SETI_listen(), as the struct GNUNET_SETI_Request becomes invalid afterwards. Call GNUNET_SETI_commit() to provide the local set to use for the operation, and to begin the exchange with the remote peer.

Parameters
requestrequest to accept
optionsoptions to use when processing the request
result_cbcallback for the results
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Accept a request we got via GNUNET_SETI_listen().

Must be called during GNUNET_SETI_listen, as the 'struct GNUNET_SETI_Request' becomes invalid afterwards. Call GNUNET_SETI_commit to provide the local set to use for the operation, and to begin the exchange with the remote peer.

Parameters
requestrequest to accept
optionsoptions to use when processing the request
result_cbcallback for the results
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 780 of file seti_api.c.

784 {
785  struct GNUNET_MQ_Envelope *mqm;
788 
789  GNUNET_assert (GNUNET_NO == request->accepted);
791  "Client accepts set intersection operation with id %u\n",
792  request->accept_id);
793  request->accepted = GNUNET_YES;
794  mqm = GNUNET_MQ_msg (msg,
796  msg->accept_reject_id = htonl (request->accept_id);
798  oh->result_cb = result_cb;
799  oh->result_cls = result_cls;
800  oh->conclude_mqm = mqm;
801  oh->request_id_addr = &msg->request_id;
802  for (const struct GNUNET_SETI_Option *opt = options;
803  GNUNET_SETI_OPTION_END != opt->type;
804  opt++)
805  {
806  switch (opt->type)
807  {
809  oh->return_intersection = GNUNET_YES;
810  msg->return_intersection = htonl (GNUNET_YES);
811  break;
812  default:
814  "Option with type %d not recognized\n",
815  (int) opt->type);
816  }
817  }
818  return oh;
819 }
#define GNUNET_MESSAGE_TYPE_SETI_ACCEPT
Accept an incoming set request.
Message sent by a listening client to the service to accept performing the operation with the other p...
Definition: seti.h:77

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_MESSAGE_TYPE_SETI_ACCEPT, GNUNET_MQ_msg, GNUNET_new, GNUNET_NO, GNUNET_SETI_OPTION_END, GNUNET_SETI_OPTION_RETURN_INTERSECTION, GNUNET_YES, LOG, msg, oh, options, and request.

Referenced by cb_intersection_request_alice(), and set_listen_cb().

Here is the caller graph for this function:

◆ GNUNET_SETI_commit()

int GNUNET_SETI_commit ( struct GNUNET_SETI_OperationHandle oh,
struct GNUNET_SETI_Handle set 
)

Commit a set to be used with a set operation.

This function is called once we have fully constructed the set that we want to use for the operation. At this time, the P2P protocol can then begin to exchange the set information and call the result callback with the result information.

Parameters
ohhandle to the set operation
setthe set to use for the operation
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 836 of file seti_api.c.

838 {
839  if (NULL != oh->set)
840  {
841  /* Some other set was already committed for this
842  * operation, there is a logic bug in the client of this API */
843  GNUNET_break (0);
844  return GNUNET_OK;
845  }
846  GNUNET_assert (NULL != set);
847  if (GNUNET_YES == set->invalid)
848  return GNUNET_SYSERR;
850  "Client commits to SET\n");
851  GNUNET_assert (NULL != oh->conclude_mqm);
852  oh->set = set;
854  set->ops_tail,
855  oh);
856  oh->request_id = GNUNET_MQ_assoc_add (set->mq,
857  oh);
858  *oh->request_id_addr = htonl (oh->request_id);
859  GNUNET_MQ_send (set->mq,
860  oh->conclude_mqm);
861  oh->conclude_mqm = NULL;
862  oh->request_id_addr = NULL;
863  return GNUNET_OK;
864 }
struct GNUNET_SETI_OperationHandle * ops_tail
Linked list of operations on the set.
Definition: seti_api.c:54

References GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_assoc_add(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SETI_Handle::invalid, LOG, GNUNET_SETI_Handle::mq, oh, GNUNET_SETI_Handle::ops_head, and GNUNET_SETI_Handle::ops_tail.

Referenced by cb_intersection_request_alice(), run(), and set_listen_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_operation_cancel()

void GNUNET_SETI_operation_cancel ( struct GNUNET_SETI_OperationHandle oh)

Cancel the given set operation.

May not be called after the operation's GNUNET_SETI_ResultIterator has been called with a status of GNUNET_SETI_STATUS_FAILURE or GNUNET_SETI_STATUS_DONE.

Parameters
ohset operation to cancel

We need to send an explicit cancel message, as all operations one one set communicate using one handle.

Parameters
ohset operation to cancel

Definition at line 335 of file seti_api.c.

336 {
337  struct GNUNET_SETI_Handle *set = oh->set;
339  struct GNUNET_MQ_Envelope *mqm;
340 
342  "Cancelling SET operation\n");
343  if (NULL != set)
344  {
346  m->request_id = htonl (oh->request_id);
347  GNUNET_MQ_send (set->mq, mqm);
348  }
350  if ((NULL != set) &&
351  (GNUNET_YES == set->destroy_requested) &&
352  (NULL == set->ops_head))
353  {
355  "Destroying set after operation cancel\n");
356  GNUNET_SETI_destroy (set);
357  }
358 }
#define GNUNET_MESSAGE_TYPE_SETI_CANCEL
Cancel a set operation.
void GNUNET_SETI_destroy(struct GNUNET_SETI_Handle *set)
Destroy the set handle if no operations are left, mark the set for destruction otherwise.
Definition: seti_api.c:488
static void set_operation_destroy(struct GNUNET_SETI_OperationHandle *oh)
Destroy the given set operation.
Definition: seti_api.c:305
Sent to the service by the client in order to cancel a set operation.
Definition: seti.h:252

References GNUNET_SETI_Handle::destroy_requested, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SETI_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SETI_destroy(), GNUNET_YES, LOG, m, GNUNET_SETI_Handle::mq, oh, GNUNET_SETI_Handle::ops_head, and set_operation_destroy().

Referenced by destroy_service_session(), and handle_shutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETI_element_hash()

void GNUNET_SETI_element_hash ( const struct GNUNET_SETI_Element element,
struct GNUNET_HashCode ret_hash 
)

Hash a set element.

Parameters
elementthe element that should be hashed
[out]ret_hasha pointer to where the hash of element should be stored

Definition at line 875 of file seti_api.c.

877 {
879 
880  /* It's not guaranteed that the element data is always after the element header,
881  so we need to hash the chunks separately. */
883  &element->size,
884  sizeof(uint16_t));
886  &element->element_type,
887  sizeof(uint16_t));
889  element->data,
890  element->size);
892  ret_hash);
893 }

References ctx, GNUNET_SETI_Element::data, GNUNET_SETI_Element::element_type, GNUNET_CRYPTO_hash_context_finish(), GNUNET_CRYPTO_hash_context_read(), GNUNET_CRYPTO_hash_context_start(), and GNUNET_SETI_Element::size.

Referenced by handle_client_set_add().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_create()

struct GNUNET_SETU_Handle* GNUNET_SETU_create ( const struct GNUNET_CONFIGURATION_Handle cfg)

Create an empty set, supporting the specified operation.

Parameters
cfgconfiguration to use for connecting to the set service
Returns
a handle to the set

Definition at line 384 of file setu_api.c.

385 {
386  struct GNUNET_SETU_Handle *set = GNUNET_new (struct GNUNET_SETU_Handle);
387  struct GNUNET_MQ_MessageHandler mq_handlers[] = {
391  set),
393  };
394  struct GNUNET_MQ_Envelope *mqm;
395  struct GNUNET_SETU_CreateMessage *create_msg;
396 
397  set->mq = GNUNET_CLIENT_connect (cfg,
398  "setu",
399  mq_handlers,
401  set);
402  if (NULL == set->mq)
403  {
404  GNUNET_free (set);
405  return NULL;
406  }
407  mqm = GNUNET_MQ_msg (create_msg,
409  GNUNET_MQ_send (set->mq,
410  mqm);
411  return set;
412 }
#define GNUNET_MESSAGE_TYPE_SETU_RESULT
Handle result message from operation.
#define GNUNET_MESSAGE_TYPE_SETU_CREATE
Create a new local set.
static void handle_client_set_error(void *cls, enum GNUNET_MQ_Error error)
We encountered an error communicating with the set service while performing a set operation.
Definition: setu_api.c:354
Message sent by the client to the service to ask starting a new set to perform operations with.
Definition: setu.h:41
Opaque handle to a set.
Definition: setu_api.c:40
struct GNUNET_MQ_Handle * mq
Message queue for client.
Definition: setu_api.c:44
Message sent by the service to the client to indicate an element that is removed (set intersection) o...
Definition: setu.h:290

References cfg, GNUNET_CLIENT_connect(), GNUNET_free, GNUNET_MESSAGE_TYPE_SETU_CREATE, GNUNET_MESSAGE_TYPE_SETU_RESULT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, handle_client_set_error(), GNUNET_SETU_Handle::mq, and result.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_add_element()

int GNUNET_SETU_add_element ( struct GNUNET_SETU_Handle set,
const struct GNUNET_SETU_Element element,
GNUNET_SCHEDULER_TaskCallback  cb,
void *  cb_cls 
)

Add an element to the given set.

Parameters
setset to add element to
elementelement to add to the set
cbfunction to call when finished, can be NULL
cb_clsclosure for cb
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

After the element has been added (in the sense of being transmitted to the set service), cont will be called. Multiple calls to GNUNET_SETU_add_element() can be queued.

Parameters
setset to add element to
elementelement to add to the set
cbcontinuation called after the element has been added
cb_clsclosure for cb
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 429 of file setu_api.c.

433 {
434  struct GNUNET_MQ_Envelope *mqm;
436 
438  "adding element of type %u to set %p\n",
439  (unsigned int) element->element_type,
440  set);
441  GNUNET_assert (NULL != set);
442  if (GNUNET_YES == set->invalid)
443  {
444  if (NULL != cb)
445  cb (cb_cls);
446  return GNUNET_SYSERR;
447  }
448  mqm = GNUNET_MQ_msg_extra (msg,
449  element->size,
451  msg->element_type = htons (element->element_type);
452  GNUNET_memcpy (&msg[1],
453  element->data,
454  element->size);
456  cb,
457  cb_cls);
458  GNUNET_MQ_send (set->mq,
459  mqm);
460  return GNUNET_OK;
461 }
#define GNUNET_MESSAGE_TYPE_SETU_ADD
Add element to set.
#define LOG(kind,...)
Definition: setu_api.c:34
Message sent by client to the service to add an element to the set.
Definition: setu.h:326
uint16_t element_type
Application-specific element type.
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
int invalid
Has the set become invalid (e.g.
Definition: setu_api.c:66

References GNUNET_SETU_Element::data, GNUNET_SETU_Element::element_type, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SETU_ADD, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SETU_Handle::invalid, LOG, GNUNET_SETU_Handle::mq, msg, and GNUNET_SETU_Element::size.

Referenced by publicize_rm(), and set_insert_iterator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_destroy()

void GNUNET_SETU_destroy ( struct GNUNET_SETU_Handle set)

Destroy the set handle, and free all associated resources.

Operations may still be pending when a set is destroyed (and will be allowed to complete).

Parameters
setset to destroy

Destroy the set handle, and free all associated resources.

Parameters
setset handle to destroy

Definition at line 471 of file setu_api.c.

472 {
473  /* destroying set while iterator is active is currently
474  not supported; we should expand the API to allow
475  clients to explicitly cancel the iteration! */
476  GNUNET_assert (NULL != set);
477  if ((NULL != set->ops_head) ||
479  {
481  "Set operations are pending, delaying set destruction\n");
483  return;
484  }
486  "Really destroying set\n");
487  if (NULL != set->mq)
488  {
489  GNUNET_MQ_destroy (set->mq);
490  set->mq = NULL;
491  }
492  GNUNET_free (set);
493 }
int destroy_requested
Should the set be destroyed once all operations are gone? GNUNET_SYSERR if GNUNET_SETU_destroy() must...
Definition: setu_api.c:61
struct GNUNET_SETU_OperationHandle * ops_head
Linked list of operations on the set.
Definition: setu_api.c:49

References GNUNET_SETU_Handle::destroy_requested, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SYSERR, GNUNET_YES, LOG, GNUNET_SETU_Handle::mq, and GNUNET_SETU_Handle::ops_head.

Referenced by GNUNET_SETU_operation_cancel(), handle_result(), handle_shutdown(), run(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_prepare()

struct GNUNET_SETU_OperationHandle* GNUNET_SETU_prepare ( const struct GNUNET_PeerIdentity other_peer,
const struct GNUNET_HashCode app_id,
const struct GNUNET_MessageHeader context_msg,
const struct GNUNET_SETU_Option  options[],
GNUNET_SETU_ResultIterator  result_cb,
void *  result_cls 
)

Prepare a set operation to be evaluated with another peer.

The evaluation will not start until the client provides a local set with GNUNET_SETU_commit().

Parameters
other_peerpeer with the other set
app_idhash for the application using the set
context_msgadditional information for the request
optionsoptions to use when processing the request
result_cbcalled on error or success
result_clsclosure for result_cb
Returns
a handle to cancel the operation

The evaluation will not start until the client provides a local set with GNUNET_SETU_commit().

Parameters
other_peerpeer with the other set
app_idhash for the application using the set
context_msgadditional information for the request
result_cbcalled on error or success
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 509 of file setu_api.c.

515 {
516  struct GNUNET_MQ_Envelope *mqm;
519 
521  "Client prepares set union operation\n");
523  oh->result_cb = result_cb;
524  oh->result_cls = result_cls;
527  context_msg);
528  msg->app_id = *app_id;
529  msg->target_peer = *other_peer;
530 
531  /* Set default values */
532  msg->byzantine_upper_bond = UINT64_MAX;
533  msg->bandwidth_latency_tradeoff = 0;
534  msg->ibf_bucket_number_factor = 2;
535  msg->ibf_number_of_buckets_per_element = 3;
536 
537 
538  for (const struct GNUNET_SETU_Option *opt = options; opt->type != 0; opt++)
539  {
540  switch (opt->type)
541  {
543  msg->byzantine = GNUNET_YES;
544  msg->byzantine_lower_bound = htonl (opt->v.num);
545  break;
547  msg->byzantine_upper_bond = htonl (opt->v.num);
548  break;
550  msg->bandwidth_latency_tradeoff = htonl (opt->v.num);
551  break;
553  msg->ibf_bucket_number_factor = htonl (opt->v.num);
554  break;
556  msg->ibf_number_of_buckets_per_element = htonl (opt->v.num);
557  break;
559  msg->force_full = GNUNET_YES;
560  break;
562  msg->force_delta = GNUNET_YES;
563  break;
565  msg->symmetric = GNUNET_YES;
566  break;
567  default:
569  "Option with type %d not recognized\n",
570  (int) opt->type);
571  }
572  }
573  oh->conclude_mqm = mqm;
574  oh->request_id_addr = &msg->request_id;
575  return oh;
576 }
#define GNUNET_MESSAGE_TYPE_SETU_EVALUATE
Evaluate a set operation.
Message sent by client to service to initiate a set operation as a client (not as listener).
Definition: setu.h:203
Handle to an operation.
Definition: setu_api.c:95
Option for set operations.

References app_id, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_MESSAGE_TYPE_SETU_EVALUATE, GNUNET_MQ_msg_nested_mh, GNUNET_new, GNUNET_SETU_OPTION_BYZANTINE, GNUNET_SETU_OPTION_CUSTOM_BANDWIDTH_LATENCY_TRADEOFF, GNUNET_SETU_OPTION_CUSTOM_BYZANTINE_UPPER_BOUND, GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKET_NUMBER_FACTOR, GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKETS_PER_ELEMENT, GNUNET_SETU_OPTION_FORCE_DELTA, GNUNET_SETU_OPTION_FORCE_FULL, GNUNET_SETU_OPTION_SYMMETRIC, GNUNET_YES, LOG, msg, oh, and options.

Referenced by run(), and transmit_task_cb().

Here is the caller graph for this function:

◆ GNUNET_SETU_listen()

struct GNUNET_SETU_ListenHandle* GNUNET_SETU_listen ( const struct GNUNET_CONFIGURATION_Handle cfg,
const struct GNUNET_HashCode app_id,
GNUNET_SETU_ListenCallback  listen_cb,
void *  listen_cls 
)

Wait for set operation requests for the given application ID.

If the connection to the set service is lost, the listener is re-created transparently with exponential backoff.

Parameters
cfgconfiguration to use for connecting to the set service
app_idid of the application that handles set operation requests
listen_cbcalled for each incoming request matching the operation and application id
listen_clshandle for listen_cb
Returns
a handle that can be used to cancel the listen operation

Wait for set operation requests for the given application ID.

Parameters
cfgconfiguration to use for connecting to the set service, needs to be valid for the lifetime of the listen handle
app_idid of the application that handles set operation requests
listen_cbcalled for each incoming request matching the operation and application id
listen_clshandle for listen_cb
Returns
a handle that can be used to cancel the listen operation

Definition at line 729 of file setu_api.c.

733 {
734  struct GNUNET_SETU_ListenHandle *lh;
735 
737  "Starting listener for app %s\n",
738  GNUNET_h2s (app_id));
739  lh = GNUNET_new (struct GNUNET_SETU_ListenHandle);
740  lh->listen_cb = listen_cb;
741  lh->listen_cls = listen_cls;
742  lh->cfg = cfg;
743  lh->app_id = *app_id;
745  listen_connect (lh);
746  if (NULL == lh->mq)
747  {
748  GNUNET_free (lh);
749  return NULL;
750  }
751  return lh;
752 }
static void listen_connect(void *cls)
Connect to the set service in order to listen for requests.
Definition: setu_api.c:687
Opaque handle to a listen operation.
Definition: setu_api.c:146
struct GNUNET_HashCode app_id
Application ID we listen for.
Definition: setu_api.c:173
struct GNUNET_MQ_Handle * mq
Message queue for the client.
Definition: setu_api.c:150
GNUNET_SETU_ListenCallback listen_cb
Function to call on a new incoming request, or on error.
Definition: setu_api.c:163
void * listen_cls
Closure for listen_cb.
Definition: setu_api.c:168
struct GNUNET_TIME_Relative reconnect_backoff
Time to wait until we try to reconnect on failure.
Definition: setu_api.c:178
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle for the listener, stored here to be able to reconnect transparently on connectio...
Definition: setu_api.c:157

References app_id, GNUNET_SETU_ListenHandle::app_id, cfg, GNUNET_SETU_ListenHandle::cfg, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_new, GNUNET_TIME_UNIT_MILLISECONDS, GNUNET_SETU_ListenHandle::listen_cb, listen_cb(), GNUNET_SETU_ListenHandle::listen_cls, listen_connect(), LOG, GNUNET_SETU_ListenHandle::mq, and GNUNET_SETU_ListenHandle::reconnect_backoff.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_listen_cancel()

void GNUNET_SETU_listen_cancel ( struct GNUNET_SETU_ListenHandle lh)

Cancel the given listen operation.

After calling cancel, the listen callback for this listen handle will not be called again. Note that cancelling a listen operation will automatically reject all operations that have not yet been accepted.

Parameters
lhhandle for the listen operation
lhhandle for the listen operation

Definition at line 761 of file setu_api.c.

762 {
764  "Canceling listener %s\n",
765  GNUNET_h2s (&lh->app_id));
766  if (NULL != lh->mq)
767  {
768  GNUNET_MQ_destroy (lh->mq);
769  lh->mq = NULL;
770  }
771  if (NULL != lh->reconnect_task)
772  {
774  lh->reconnect_task = NULL;
775  }
776  GNUNET_free (lh);
777 }
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for reconnecting when the listener fails.
Definition: setu_api.c:183

References GNUNET_SETU_ListenHandle::app_id, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), LOG, GNUNET_SETU_ListenHandle::mq, and GNUNET_SETU_ListenHandle::reconnect_task.

Referenced by handle_shutdown(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_accept()

struct GNUNET_SETU_OperationHandle* GNUNET_SETU_accept ( struct GNUNET_SETU_Request request,
const struct GNUNET_SETU_Option  options[],
GNUNET_SETU_ResultIterator  result_cb,
void *  result_cls 
)

Accept a request we got via GNUNET_SETU_listen().

Must be called during GNUNET_SETU_listen(), as the struct GNUNET_SETU_Request becomes invalid afterwards. Call GNUNET_SETU_commit() to provide the local set to use for the operation, and to begin the exchange with the remote peer.

Parameters
requestrequest to accept
optionsoptions to use when processing the request
result_cbcallback for the results
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Accept a request we got via GNUNET_SETU_listen().

Must be called during GNUNET_SETU_listen, as the 'struct GNUNET_SETU_Request' becomes invalid afterwards. Call GNUNET_SETU_commit to provide the local set to use for the operation, and to begin the exchange with the remote peer.

Parameters
requestrequest to accept
result_modespecified how results will be returned, see enum GNUNET_SETU_ResultMode.
result_cbcallback for the results
result_clsclosure for result_cb
Returns
a handle to cancel the operation

Definition at line 795 of file setu_api.c.

799 {
800  struct GNUNET_MQ_Envelope *mqm;
803 
804  GNUNET_assert (GNUNET_NO == request->accepted);
806  "Client accepts set union operation with id %u\n",
807  request->accept_id);
808  request->accepted = GNUNET_YES;
809  mqm = GNUNET_MQ_msg (msg,
811  msg->accept_reject_id = htonl (request->accept_id);
812 
813  /* Set default values */
814  msg->byzantine_upper_bond = UINT64_MAX;
815  msg->bandwidth_latency_tradeoff = 0;
816  msg->ibf_bucket_number_factor = 2;
817  msg->ibf_number_of_buckets_per_element = 3;
818 
819  for (const struct GNUNET_SETU_Option *opt = options; opt->type != 0; opt++)
820  {
821  switch (opt->type)
822  {
824  msg->byzantine = GNUNET_YES;
825  msg->byzantine_lower_bound = htonl (opt->v.num);
826  break;
828  msg->byzantine_upper_bond = htonl (opt->v.num);
829  break;
831  msg->bandwidth_latency_tradeoff = htonl (opt->v.num);
832  break;
834  msg->ibf_bucket_number_factor = htonl (opt->v.num);
835  break;
837  msg->ibf_number_of_buckets_per_element = htonl (opt->v.num);
838  break;
840  msg->force_full = GNUNET_YES;
841  break;
843  msg->force_delta = GNUNET_YES;
844  break;
846  msg->symmetric = GNUNET_YES;
847  break;
848  default:
850  "Option with type %d not recognized\n",
851  (int) opt->type);
852  }
853  }
855  oh->result_cb = result_cb;
856  oh->result_cls = result_cls;
857  oh->conclude_mqm = mqm;
858  oh->request_id_addr = &msg->request_id;
859  return oh;
860 }
#define GNUNET_MESSAGE_TYPE_SETU_ACCEPT
Accept an incoming set request.
Message sent by a listening client to the service to accept performing the operation with the other p...
Definition: setu.h:79

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_MESSAGE_TYPE_SETU_ACCEPT, GNUNET_MQ_msg, GNUNET_new, GNUNET_NO, GNUNET_SETU_OPTION_BYZANTINE, GNUNET_SETU_OPTION_CUSTOM_BANDWIDTH_LATENCY_TRADEOFF, GNUNET_SETU_OPTION_CUSTOM_BYZANTINE_UPPER_BOUND, GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKET_NUMBER_FACTOR, GNUNET_SETU_OPTION_CUSTOM_IBF_BUCKETS_PER_ELEMENT, GNUNET_SETU_OPTION_FORCE_DELTA, GNUNET_SETU_OPTION_FORCE_FULL, GNUNET_SETU_OPTION_SYMMETRIC, GNUNET_YES, LOG, msg, oh, options, and request.

Referenced by handle_revocation_union_request(), and set_listen_cb().

Here is the caller graph for this function:

◆ GNUNET_SETU_commit()

int GNUNET_SETU_commit ( struct GNUNET_SETU_OperationHandle oh,
struct GNUNET_SETU_Handle set 
)

Commit a set to be used with a set operation.

This function is called once we have fully constructed the set that we want to use for the operation. At this time, the P2P protocol can then begin to exchange the set information and call the result callback with the result information.

Parameters
ohhandle to the set operation
setthe set to use for the operation
Returns
GNUNET_OK on success, GNUNET_SYSERR if the set is invalid (e.g. the set service crashed)

Definition at line 877 of file setu_api.c.

879 {
880  if (NULL != oh->set)
881  {
882  /* Some other set was already committed for this
883  * operation, there is a logic bug in the client of this API */
884  GNUNET_break (0);
885  return GNUNET_OK;
886  }
887  GNUNET_assert (NULL != set);
888  if (GNUNET_YES == set->invalid)
889  return GNUNET_SYSERR;
891  "Client commits to SET\n");
892  GNUNET_assert (NULL != oh->conclude_mqm);
893  oh->set = set;
895  set->ops_tail,
896  oh);
897  oh->request_id = GNUNET_MQ_assoc_add (set->mq,
898  oh);
899  *oh->request_id_addr = htonl (oh->request_id);
900  GNUNET_MQ_send (set->mq,
901  oh->conclude_mqm);
902  oh->conclude_mqm = NULL;
903  oh->request_id_addr = NULL;
904  return GNUNET_OK;
905 }
struct GNUNET_SETU_OperationHandle * ops_tail
Linked list of operations on the set.
Definition: setu_api.c:54

References GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MQ_assoc_add(), GNUNET_MQ_send(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_SETU_Handle::invalid, LOG, GNUNET_SETU_Handle::mq, oh, GNUNET_SETU_Handle::ops_head, and GNUNET_SETU_Handle::ops_tail.

Referenced by handle_revocation_union_request(), run(), and set_listen_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_operation_cancel()

void GNUNET_SETU_operation_cancel ( struct GNUNET_SETU_OperationHandle oh)

Cancel the given set operation.

May not be called after the operation's GNUNET_SETU_ResultIterator has been called with a status of GNUNET_SETU_STATUS_FAILURE or GNUNET_SETU_STATUS_DONE.

Parameters
ohset operation to cancel

We need to send an explicit cancel message, as all operations one one set communicate using one handle.

Parameters
ohset operation to cancel

Definition at line 320 of file setu_api.c.

321 {
322  struct GNUNET_SETU_Handle *set = oh->set;
324  struct GNUNET_MQ_Envelope *mqm;
325 
327  "Cancelling SET operation\n");
328  if (NULL != set)
329  {
331  m->request_id = htonl (oh->request_id);
332  GNUNET_MQ_send (set->mq, mqm);
333  }
335  if ((NULL != set) &&
336  (GNUNET_YES == set->destroy_requested) &&
337  (NULL == set->ops_head))
338  {
340  "Destroying set after operation cancel\n");
341  GNUNET_SETU_destroy (set);
342  }
343 }
#define GNUNET_MESSAGE_TYPE_SETU_CANCEL
Cancel a set operation.
void GNUNET_SETU_destroy(struct GNUNET_SETU_Handle *set)
Destroy the set handle if no operations are left, mark the set for destruction otherwise.
Definition: setu_api.c:471
static void set_operation_destroy(struct GNUNET_SETU_OperationHandle *oh)
Destroy the given set operation.
Definition: setu_api.c:290
Sent to the service by the client in order to cancel a set operation.
Definition: setu.h:350

References GNUNET_SETU_Handle::destroy_requested, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MESSAGE_TYPE_SETU_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SETU_destroy(), GNUNET_YES, LOG, m, GNUNET_SETU_Handle::mq, oh, GNUNET_SETU_Handle::ops_head, and set_operation_destroy().

Referenced by handle_core_disconnect(), and handle_shutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SETU_element_hash()

void GNUNET_SETU_element_hash ( const struct GNUNET_SETU_Element element,
struct GNUNET_HashCode ret_hash 
)

Hash a set element.

Parameters
elementthe element that should be hashed
[out]ret_hasha pointer to where the hash of element should be stored

Definition at line 916 of file setu_api.c.

918 {
920 
921  /* It's not guaranteed that the element data is always after the element header,
922  so we need to hash the chunks separately. */
924  &element->size,
925  sizeof(uint16_t));
927  &element->element_type,
928  sizeof(uint16_t));
930  element->data,
931  element->size);
933  ret_hash);
934 }

References ctx, GNUNET_SETU_Element::data, GNUNET_SETU_Element::element_type, GNUNET_CRYPTO_hash_context_finish(), GNUNET_CRYPTO_hash_context_read(), GNUNET_CRYPTO_hash_context_start(), and GNUNET_SETU_Element::size.

Referenced by handle_client_set_add(), handle_union_p2p_elements(), and handle_union_p2p_full_element().

Here is the call graph for this function:
Here is the caller graph for this function: